public function testAddNote()
 {
     $personId = 1000;
     $authoringPersonId = 65650;
     $dateTime = date('Y-m-d h:i:s');
     $note = new ClinicalNote();
     $note->personId = $personId;
     $note->dateTime = $dateTime;
     $note->authoringPersonId = $authoringPersonId;
     $note->persist();
     $noteId = $note->clinicalNoteId;
     $note = new ClinicalNote();
     $note->clinicalNoteId = $noteId;
     $note->populate();
     $this->assertEquals($personId, $note->personId);
     $this->assertEquals($authoringPersonId, $note->authoringPersonId);
     $this->assertEquals($dateTime, $note->dateTime);
 }
示例#2
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);
 }
 function processAddNoteAction()
 {
     $personId = 0;
     $personId = (int) $this->_getParam('personId');
     $cnParams = $this->_getParam('clinicalNote');
     $clinicalNoteDefinitionId = $cnParams['clinicalNoteDefinitionId'];
     unset($cnParams['clinicalNoteDefinitionId']);
     $clinicalNote = new ClinicalNote();
     $clinicalNote->populateWithArray($cnParams);
     $noteLocationId = (int) $clinicalNote->locationId;
     if (!$noteLocationId > 0) {
         $identity = Zend_Auth::getInstance()->getIdentity();
         $user = new User();
         $user->userId = (int) $identity->userId;
         $user->populate();
         $preferences = $user->xmlPreferences;
         if ($preferences !== null) {
             $noteLocationId = (int) $preferences->currentLocation;
         }
     }
     $clinicalNote->locationId = $noteLocationId;
     $clinicalNote->personId = $personId;
     //$clinicalNote->visitId = $this->_visit->visitId;
     //$clinicalNote->locationId = $this->_location->locationId;
     foreach ($clinicalNoteDefinitionId as $cndId) {
         // add note one by one
         $clinicalNote->clinicalNoteId = 0;
         $clinicalNote->clinicalNoteDefinitionId = $cndId;
         $clinicalNote->persist();
     }
     //var_dump($_POST);exit;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('clinicalNoteId' => $clinicalNote->clinicalNoteId));
 }
 function processAddNoteAction()
 {
     $personId = 0;
     $personId = (int) $this->_getParam('personId');
     $cnParams = $this->_getParam('clinicalNote');
     $clinicalNoteDefinitionId = $cnParams['clinicalNoteDefinitionId'];
     unset($cnParams['clinicalNoteDefinitionId']);
     $clinicalNote = new ClinicalNote();
     $clinicalNote->populateWithArray($cnParams);
     $clinicalNote->personId = $personId;
     //$clinicalNote->visitId = $this->_visit->visitId;
     //$clinicalNote->locationId = $this->_location->locationId;
     foreach ($clinicalNoteDefinitionId as $cndId) {
         // add note one by one
         $clinicalNote->clinicalNoteId = 0;
         $clinicalNote->clinicalNoteDefinitionId = $cndId;
         $clinicalNote->persist();
     }
     //var_dump($_POST);exit;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('clinicalNoteId' => $clinicalNote->clinicalNoteId));
 }
 function processAction()
 {
     $clinicalNoteId = (int) $this->_getParam('clinicalNoteId');
     $revisionId = (int) $this->_getParam('revisionId');
     $data = $this->_getParam('namespaceData');
     $saveDate = date('Y-m-d H:i:s');
     $cn = new ClinicalNote();
     $cn->clinicalNoteId = $clinicalNoteId;
     $cn->populate();
     if ((int) $cn->eSignatureId > 0) {
         $msg = __('Failed to save. Note is already signed');
     } else {
         $cn->dateTime = date('Y-m-d H:i:s');
         $cn->persist();
         $msg = __('Data saved.');
         $template = $cn->clinicalNoteDefinition->clinicalNoteTemplate->template;
         $xml = simplexml_load_string($template);
         $objectClass = 'ClinicalNote';
         list($name, $value) = each($data);
         $gd = new GenericData();
         $gd->objectClass = $objectClass;
         $gd->objectId = $clinicalNoteId;
         $gd->name = $name;
         $rowExists = $gd->doesRowExist(true);
         $preQueries = null;
         if ($rowExists) {
             $revisionId = (int) $gd->revisionId;
             $preQueries = 'DELETE FROM `' . $gd->_table . '` WHERE `revisionId`=' . $revisionId;
         } else {
             $revisionId = WebVista_Model_ORM::nextSequenceId();
         }
         $otm = new WebVista_Model_ORMTransactionManager();
         foreach ($data as $name => $value) {
             $gd = new GenericData();
             $gd->objectClass = $objectClass;
             $gd->objectId = $clinicalNoteId;
             $gd->dateTime = $saveDate;
             $gd->name = ClinicalNote::decodeNamespace($name);
             $gd->value = $value;
             $gd->revisionId = $revisionId;
             $otm->addORM($gd);
         }
         if (!$otm->persist($preQueries)) {
             $msg = __('Failed to save.');
         }
         if ((string) $xml->attributes()->useNSDR && (string) $xml->attributes()->useNSDR == 'true') {
             if (!ClinicalNote::processNSDRPersist($xml, $cn, $data, $revisionId)) {
                 $msg = __('Failed to save.');
             }
         }
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($msg);
 }