コード例 #1
0
 protected function _doProcess(GeneralAlertHandler $handler, Audit $audit)
 {
     $handlerName = Handler::normalizeHandlerName($handler->name);
     $classHandlerObject = $handlerName . 'GeneralAlertHandlerObject';
     if (!parent::isParentOf($classHandlerObject, 'GeneralAlertHandlerObjectAbstract')) {
         trigger_error($classHandlerObject . ' is not an instance of GeneralAlertHandlerObjectAbstract', E_USER_NOTICE);
         return false;
     }
     $ret = false;
     if (call_user_func_array(array($classHandlerObject, 'matchAudit'), array($audit))) {
         do {
             $classDatasource = $handlerName . 'GeneralAlertDatasource';
             if (!parent::isParentOf($classDatasource, 'GeneralAlertDatasourceAbstract')) {
                 trigger_error($classDatasource . ' is not an instance of GeneralAlertDatasourceAbstract', E_USER_NOTICE);
                 break;
             }
             try {
                 $data = call_user_func_array(array($classDatasource, 'sourceData'), array($audit));
             } catch (Exception $e) {
                 trigger_error('Exception error (' . $e->getCode() . '): ' . $e->getMessage(), E_USER_NOTICE);
                 break;
             }
             $ret = true;
             if (!strlen($handler->template) > 0) {
                 $handler->template = $handler->generateDefaultTemplate();
             }
             foreach ($data as $row) {
                 $message = TemplateXSLT::render($row, $handler->template);
                 $generalAlert = new GeneralAlert();
                 $generalAlert->message = $message;
                 $generalAlert->urgency = 'Med';
                 $generalAlert->status = 'new';
                 $generalAlert->dateTime = date('Y-m-d H:i:s');
                 if (isset($row['teamId'])) {
                     $generalAlert->teamId = $row['teamId'];
                 }
                 if (isset($row['signingUserId'])) {
                     $generalAlert->userId = $row['signingUserId'];
                 }
                 if (isset($row['objectId'])) {
                     $generalAlert->objectId = $row['objectId'];
                 }
                 if (isset($row['objectClass'])) {
                     $generalAlert->objectClass = $row['objectClass'];
                 }
                 $generalAlert->persist();
             }
         } while (false);
     }
     return $ret;
 }
コード例 #2
0
 public function generateTestDataAction()
 {
     GeneralAlertHandler::generateTestData();
     echo 'Done';
     die;
 }
コード例 #3
0
 public function generateDefaultCodesAction()
 {
     $code = $this->_getParam('code');
     $handlerName = $this->_getParam('handlerName');
     $condition = (int) $this->_getParam('condition');
     $generalAlertHandler = new GeneralAlertHandler();
     $generalAlertHandler->name = $handlerName;
     $generalAlertHandler->condition = $condition;
     $data = '';
     switch ($code) {
         case 'handlerObject':
             $data = $generalAlertHandler->generateDefaultHandlerObject();
             break;
         case 'datasource':
             $data = $generalAlertHandler->generateDefaultDatasource();
             break;
         case 'template':
             $data = $generalAlertHandler->generateDefaultTemplate();
             break;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
    public static function generateUserLoggedOut()
    {
        $objects = self::_generatePatient();
        $handler = new GeneralAlertHandler();
        $handler->name = 'Logout Handler ' . NSDR::create_guid();
        $handler->active = 1;
        $handler->condition = 0;
        $handlerName = Handler::normalizeHandlerName($handler->name);
        $handler->handlerObject = <<<EOL

class {$handlerName}GeneralAlertHandlerObject extends GeneralAlertHandlerObjectAbstract {
\t//abstract requires at least this method
\tpublic static function matchAudit(Audit \$auditOrm) {
\t\tif (\$auditOrm->objectClass == 'Logout' && \$auditOrm->type == '1') {
\t\t\treturn true;
\t\t}
\t\treturn false;
\t}

}

EOL;
        $handler->datasource = <<<EOL

class {$handlerName}GeneralAlertDatasource extends GeneralAlertDatasourceAbstract {
\t//abstract requires at least this method
\tpublic static function sourceData(Audit \$audit) {
\t\t\$eSignIterator = new ESignatureIterator();
\t\t\$eSignIterator->setFilter(\$audit->userId,'signList');
\t\t\$ret = array();
\t\tforeach (\$eSignIterator as \$eSign) {
\t\t\t\$objectClass = \$eSign->objectClass;
\t\t\t\$obj = new \$objectClass();
\t\t\tforeach (\$obj->_primaryKeys as \$key) {
\t\t\t\t\$obj->\$key = \$eSign->objectId;
\t\t\t}
\t\t\t\$obj->populate();
\t\t\t\$personId = \$obj->personId;
\t\t\t\$patient = new Patient();
\t\t\t\$patient->personId = \$personId;
\t\t\t\$patient->populate();
\t\t\t\$teamId = \$patient->teamId;

\t\t\t\$row = array();
\t\t\t\$row['teamId'] = \$teamId;
\t\t\t\$row['signingUserId'] = \$eSign->signingUserId;
\t\t\t\$row['objectId'] = \$eSign->objectId;
\t\t\t\$row['objectClass'] = \$eSign->objectClass;
\t\t\t\$ret[] = \$row;
\t\t}
\t\treturn \$ret;
\t}
}

EOL;
        $handler->template = $handler->generateDefaultTemplate();
        $handler->persist();
        $objects['generalAlertHandler'] = $handler;
        return $objects;
    }