示例#1
0
 public static function createSignatureEntry(Document $object, $signingUserId = null)
 {
     $db = Zend_Registry::get('dbAdapter');
     $esig = new ESignature();
     if ($object->eSignatureId > 0) {
         //document is already signed, we cannot create a new signature entry for an already signed document unless the document is first unlinked
         return false;
     }
     $esigSelect = $db->select()->from('eSignatures')->where('eSignatures.objectId = ' . (int) $object->documentId)->order('eSignatureId DESC');
     if (($row = $db->query($esigSelect)->fetch()) !== false) {
         if ($row['signature'] == "") {
             //open signature record exists so do not create another
             return false;
         }
         $esig->editedSummary = $object->getSummary();
     } else {
         $esig->unsignedSummary = $object->getSummary();
     }
     $esig->objectId = $object->getDocumentId();
     $esig->objectClass = get_class($object);
     if ($signingUserId === null) {
         $signingUserId = Zend_Auth::getInstance()->getIdentity()->personId;
     }
     $esig->signingUserId = (int) $signingUserId;
     $esig->dateTime = date('Y-m-d H:i:s');
     $esig->persist();
 }
 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();
     }
 }
示例#3
0
 public function processForwardForSigningAction()
 {
     $providerId = (int) $this->_getParam('providerId');
     $ormClass = $this->_getParam('ormClass');
     $ormId = $this->_getParam('ormId');
     $data = false;
     $esign = new ESignature();
     $esign->objectClass = $ormClass;
     $esign->objectId = $ormId;
     $esign->populateByObject();
     if ($esign->signingUserId > 0) {
         $data = true;
         $esign->signingUserId = $providerId;
         $esign->persist();
     }
     /*if (class_exists($ormClass)) {
     			$orm = new $ormClass();
     			$primaryKeys = $orm->_primaryKeys;
     			$key = $primaryKeys[0];
     			$orm->$key = $ormId;
     			$orm->populate();
     			if ($orm instanceof Document && $orm->signatureNeeded()) {
     				ESignature::createSignatureEntry($orm,$providerId);
     			}
     			$data = true;
     		}*/
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
示例#4
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);
 }
 public function testUnsignedItem()
 {
     $this->_objects = GeneralAlertHandler::generateClinicalNoteHandler();
     $objects = array();
     $db = Zend_Registry::get('dbAdapter');
     $clinicalNote = new ClinicalNote();
     $clinicalNote->personId = $this->_objects['person']->person_id;
     $clinicalNote->visitId = 100;
     $clinicalNote->clinicalNoteDefinitionId = 19;
     $clinicalNote->dateTime = date('Y-m-d H:i:s');
     $clinicalNote->persist();
     $objects['clinicalNote'] = $clinicalNote;
     $eSign = new ESignature();
     // cleanup all generalAlerts
     $db->query('DELETE FROM ' . $eSign->_table);
     $eSign->dateTime = date('Y-m-d H:i:s');
     $eSign->signedDateTime = '0000-00-00 00:00:00';
     $eSign->signingUserId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $eSign->objectId = $clinicalNote->clinicalNoteId;
     $eSign->objectClass = get_class($clinicalNote);
     $eSign->summary = ' **Unsigned**';
     $eSign->persist();
     $objects['eSignature'] = $eSign;
     // cleanup all generalAlerts
     $generalAlert = new GeneralAlert();
     $db->query('DELETE FROM ' . $generalAlert->_table);
     $process = Processingd::getInstance();
     $process->clearProcesses();
     $process->addProcess(new ProcessAlert());
     $process->startProcessing(false);
     $generalAlertIterator = $generalAlert->getIterator();
     $ctr = 0;
     foreach ($generalAlertIterator as $alert) {
         $objects['generalAlert' . $ctr++] = $alert;
     }
     $this->assertEquals($ctr, 1, 'No alert created even with signed items');
     $this->_cleanUpObjects($objects);
 }