Exemplo n.º 1
0
 public static function handlereFaxAct(Audit $audit, array $sourceData)
 {
     if ($audit->objectClass != 'ESignature') {
         return false;
     }
     $eSignature = new ESignature();
     $eSignature->eSignatureId = $audit->objectId;
     $eSignature->populate();
     if ($eSignature->objectClass != 'Medication') {
         return false;
     }
     $medication = new Medication();
     $medication->medicationId = $eSignature->objectId;
     $medication->populate();
     $audit = $sourceData['_audit'];
     $messaging = new Messaging(Messaging::TYPE_OUTBOUND_FAX);
     $messaging->messagingId = (int) $sourceData['transmissionId'];
     $messaging->transmissionId = $messaging->messagingId;
     $messaging->populate();
     $messaging->objectId = $messaging->messagingId;
     $messaging->objectClass = $audit->objectClass;
     $messaging->status = 'Faxed';
     $messaging->dateStatus = date('Y-m-d H:i:s');
     $messaging->auditId = $audit->auditId;
     // this must be required for retransmission in case of error
     $messaging->persist();
     $efax = new eFaxOutbound();
     $url = Zend_Registry::get('config')->healthcloud->eFax->outboundUrl;
     $url .= '?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey;
     $efax->setUrl($url);
     $efax->setTransmissionId($sourceData['transmissionId']);
     $efax->setNoDuplicate(eFaxOutbound::NO_DUPLICATE_ENABLE);
     $efax->setDispositionMethod('POST');
     // use the default disposition URL
     $dispositionUrl = Zend_Registry::get('config')->healthcloud->eFax->dispositionUrl;
     $efax->setDispositionUrl($dispositionUrl);
     //$efax->setDispositionMethod('EMAIL');
     //$efax->addDispositionEmail('Arthur Layese','*****@*****.**');
     foreach ($sourceData['recipients'] as $recipient) {
         if ($messaging->resend && strlen($messaging->faxNumber) > 9) {
             // supersedes fax number from messaging
             $recipient['fax'] = $messaging->faxNumber;
         }
         $efax->addRecipient($recipient['fax'], $recipient['name'], $recipient['company']);
     }
     foreach ($sourceData['files'] as $file) {
         $efax->addFile($file['contents'], $file['type']);
     }
     $ret = $efax->send();
     if (!$ret) {
         $messaging->status = 'Fax Error';
         $messaging->note = implode(PHP_EOL, $efax->getErrors());
     } else {
         $messaging->docid = $efax->getDocId();
         $messaging->status = 'Fax Sent';
         $messaging->note = '';
     }
     if ($messaging->resend) {
         $messaging->resend = 0;
     }
     $messaging->retries++;
     $messaging->dateStatus = date('Y-m-d H:i:s');
     $messaging->persist();
     return true;
 }
Exemplo n.º 2
0
 function editSignItemsAction()
 {
     $eSigIds = Zend_Json::decode($this->_getParam('electronicSignatureIds'));
     if (strlen($eSigIds) <= 0) {
         $msg = __('No selected signature.');
         throw new Exception($msg);
     }
     $eSigIds = explode(',', $eSigIds);
     $signature = $this->_getParam('signature');
     foreach ($eSigIds as $eSigId) {
         if (strlen($eSigId) <= 0) {
             continue;
         }
         $esig = new ESignature();
         $esig->eSignatureId = (int) $eSigId;
         $esig->populate();
         $signedDate = date('Y-m-d H:i:s');
         $esig->signedDateTime = $signedDate;
         $obj = new $esig->objectClass();
         $obj->documentId = $esig->objectId;
         $obj->eSignatureId = $esig->eSignatureId;
         $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
         $json->suppressExit = true;
         try {
             $esig->sign($obj, $signature);
         } catch (Exception $e) {
             $this->getResponse()->setHttpResponseCode(500);
             $json->direct(array('error' => $e->getMessage()));
             return;
         }
         $esig->persist();
         $obj->populate();
         $obj->eSignatureId = $esig->eSignatureId;
         $obj->persist();
     }
 }
Exemplo n.º 3
0
 public function testInValidKey()
 {
     $signature = 'invalid_password';
     $objects = array();
     $clinicalNote = new ClinicalNote();
     $clinicalNote->clinicalNoteDefinitionId = $this->_objects['noteDefinition']->clinicalNoteDefinitionId;
     $clinicalNote->personId = $this->_objects['person']->personId;
     $clinicalNote->persist();
     $objects['clinicalNote'] = $clinicalNote;
     $eSig = new ESignature();
     $eSig->signingUserId = $this->_objects['user']->personId;
     $eSig->objectClass = 'ClinicalNote';
     $eSig->objectId = $clinicalNote->clinicalNoteId;
     $eSig->summary = 'Test, One #10026 - Transcription Note **Signed**';
     $eSig->persist();
     $objects['eSig'] = $eSig;
     $esig = new ESignature();
     $esig->eSignatureId = (int) $eSig->eSignatureId;
     $esig->populate();
     $signedDate = date('Y-m-d H:i:s');
     $esig->signedDateTime = $signedDate;
     $obj = new $esig->objectClass();
     $obj->documentId = $esig->objectId;
     $obj->eSignatureId = $esig->eSignatureId;
     try {
         $esig->sign($obj, $signature);
         $esig->persist();
         $obj->populate();
         $obj->eSignatureId = $esig->eSignatureId;
         $obj->persist();
     } catch (Exception $e) {
         $this->assertTrue(true, $e->getMessage());
     }
     $this->assertEquals($esig->signature, '');
     $this->_cleanUpObjects($objects);
 }
Exemplo n.º 4
0
 function editSignItemsAction()
 {
     $eSigIds = Zend_Json::decode($this->_getParam('electronicSignatureIds'));
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     if (strlen($eSigIds) <= 0) {
         $msg = __('No selected items to sign.');
         WebVista::log($msg);
         $this->getResponse()->setHttpResponseCode(500);
         $json->direct(array('error' => $msg));
         return;
     }
     $eSigIds = explode(',', $eSigIds);
     $signature = $this->_getParam('signature');
     foreach ($eSigIds as $eSigId) {
         if (strlen($eSigId) <= 0) {
             continue;
         }
         $esig = new ESignature();
         $esig->eSignatureId = (int) $eSigId;
         $esig->populate();
         $objectClass = $esig->objectClass;
         if ($objectClass == 'Medication') {
             // check for possible eprescribed
             $medication = new Medication();
             $medication->medicationId = (int) $esig->objectId;
             $medication->populate();
             if ($medication->transmit == 'ePrescribe') {
                 $result = $this->_checkCurrentLocation($medication);
                 if ($result !== false) {
                     $this->getResponse()->setHttpResponseCode(500);
                     $json->direct(array('error' => $result));
                     return;
                 }
             }
         }
         $signedDate = date('Y-m-d H:i:s');
         $esig->signedDateTime = $signedDate;
         $obj = new $esig->objectClass();
         $obj->documentId = $esig->objectId;
         $obj->eSignatureId = $esig->eSignatureId;
         try {
             $esig->sign($obj, $signature);
         } catch (Exception $e) {
             $this->getResponse()->setHttpResponseCode(500);
             $json->direct(array('error' => $e->getMessage()));
             return;
         }
         $esig->persist();
         $obj->populate();
         $obj->eSignatureId = $esig->eSignatureId;
         $obj->persist();
     }
 }
 function templateAction()
 {
     $clinicalNoteId = $this->_getParam('clinicalNoteId', 0);
     $revisionId = (int) $this->_getParam('revisionId');
     $cn = new ClinicalNote();
     $cn->clinicalNoteId = (int) $clinicalNoteId;
     $cn->populate();
     if ($revisionId > 0) {
         $cn->revisionId = $revisionId;
     }
     $this->_cn = $cn;
     $templateId = $cn->clinicalNoteTemplateId;
     assert("{$templateId} > 0");
     $cnTemplate = $cn->clinicalNoteDefinition->clinicalNoteTemplate;
     $this->_form = new WebVista_Form(array('name' => 'cn-template-form'));
     $this->_form->setWindow('dummyWindowId');
     $this->_form->setAction(Zend_Registry::get('baseUrl') . "clinical-notes-form.raw/process");
     $cnXML = simplexml_load_string($cnTemplate->template);
     // pre-register print element to view so that other elements can override particularly the onclick event
     $this->_buildForm($cnXML);
     $this->_form->addElement($this->_form->createElement('hidden', 'clinicalNoteId', array('value' => (int) $cn->clinicalNoteId)));
     $formData = array();
     $this->_form->removeElement('ok');
     $element = $this->_form->createElement('hidden', 'clinicalNoteOKId', array('value' => 'OK'));
     $this->_form->addElement($element);
     if ($revisionId > 0) {
         //$this->_form->removeElement('ok');
         $this->_form->removeElement('clinicalNoteOKId');
     } else {
         $revisionId = GenericData::getUnsignedRevisionId(get_class($cn), $cn->clinicalNoteId);
         //$revisionId = $cn->clinicalNoteId;
     }
     $this->_form->addElement($this->_form->createElement('hidden', 'revisionId', array('value' => (int) $revisionId)));
     $db = Zend_Registry::get('dbAdapter');
     $cndSelect = $db->select()->from('genericData')->where("objectClass = 'ClinicalNote'")->where('objectId = ?', (int) $cn->clinicalNoteId);
     if ($revisionId > 0) {
         $cndSelect->where('revisionId = ?', $revisionId);
     }
     trigger_error($cndSelect->__toString(), E_USER_NOTICE);
     foreach ($db->query($cndSelect)->fetchAll() as $row) {
         $formData[$row['name']] = $row['value'];
     }
     $eSignatureId = ESignature::retrieveSignatureId(get_class($cn), $revisionId);
     if ($eSignatureId > 0) {
         // On signed notes generic data is shown
         //$this->_form->removeElement('ok');
         $this->_form->removeElement('clinicalNoteOKId');
         $esig = new ESignature();
         $esig->eSignatureId = $eSignatureId;
         $esig->populate();
         $signPerson = new Person();
         $signPerson->personId = $esig->signingUserId;
         $signPerson->populate();
         $person = new Person();
         $person->personId = $esig->signingUserId;
         $person->populate();
         $this->view->signatureInfo = "Signed on: " . $esig->signedDateTime . " by: " . $person->firstName . ' ' . $person->lastName . ' ' . $person->suffix;
         $element = $this->_form->createElement('hidden', 'clinicalNoteSignatureId', array('value' => $this->view->signatureInfo));
         $this->_form->addElement($element);
     } else {
         // on unsigned notes NSDR is shown but a warning also needs to appear that says data has changed since last save if generic data != NSDR data
         if ((string) $cnXML->attributes()->useNSDR && (string) $cnXML->attributes()->useNSDR == 'true') {
             $nsdrData = ClinicalNote::getNSDRData($cnXML, $cn, $revisionId);
             if ($formData != $nsdrData) {
                 $msg = __('Data has been changed since last save');
                 $this->_form->addElement($this->_form->createElement('hidden', 'dataChangedId', array('value' => $msg)));
             }
             $formData = $nsdrData;
         }
     }
     $this->_form->populate($formData);
     $this->view->form = $this->_form;
     $templateRevisions = array();
     $gdIterator = GenericData::getAllRevisions(get_class($cn), $cn->clinicalNoteId);
     foreach ($gdIterator as $gd) {
         $templateRevisions[$gd->revisionId] = $gd->dateTime;
     }
     $this->view->templateRevisions = $templateRevisions;
 }