Exemplo n.º 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;
 }
Exemplo n.º 2
0
 protected function _doDailyProcess()
 {
     try {
         $cacheCodeObjects = Zend_Registry::get('cacheCodeObjects');
     } catch (Exception $e) {
         $cacheCodeObjects = array();
     }
     $handlerPatient = new HealthStatusHandlerPatient();
     $handlerPatientIterator = $handlerPatient->getIterator();
     foreach ($handlerPatientIterator as $row) {
         $handler = $row->healthStatusHandler;
         $patient = $row->person;
         $patientId = $patient->personId;
         $handlerObject = $handler->handlerObject;
         if (!strlen($handlerObject) > 0) {
             $handlerObject = $handler->generateDefaultHandlerObject();
         }
         $md5 = md5($handlerObject);
         if (!in_array($md5, $cacheCodeObjects)) {
             $cacheCodeObjects[] = $md5;
             eval($handlerObject);
             // TODO: needs to be validated
         }
         $datasource = $handler->datasource;
         if (!strlen($datasource) > 0) {
             $datasource = $handler->generateDefaultDatasource();
         }
         $md5 = md5($datasource);
         if (!in_array($md5, $cacheCodeObjects)) {
             $cacheCodeObjects[] = $md5;
             eval($datasource);
             // TODO: needs to be validated
         }
         $handlerName = Handler::normalizeHandlerName($handler->name);
         $classHandlerObject = $handlerName . 'HealthStatusHandlerObject';
         if (!parent::isParentOf($classHandlerObject, 'HealthStatusHandlerObjectAbstract')) {
             trigger_error($classHandlerObject . ' is not an instance of HealthStatusHandlerObjectAbstract', E_USER_NOTICE);
             continue;
         }
         $retPatientMatch = call_user_func_array(array($classHandlerObject, 'patientMatch'), array($handler, $patientId));
         if ($retPatientMatch !== false) {
             $classHealthStatusDatasource = $handlerName . 'HealthStatusDatasource';
             if (!parent::isParentOf($classHealthStatusDatasource, 'HealthStatusDatasourceAbstract')) {
                 trigger_error($classHealthStatusDatasource . ' is not an instance of HealthStatusDatasourceAbstract', E_USER_NOTICE);
                 continue;
             }
             try {
                 $retSourcedata = call_user_func_array(array($classHealthStatusDatasource, 'sourceData'), array($patientId, $retPatientMatch));
             } catch (Exception $e) {
                 trigger_error('Exception error (' . $e->getCode() . '): ' . $e->getMessage(), E_USER_NOTICE);
                 continue;
             }
             if (!strlen($handler->template) > 0) {
                 $handler->template = $handler->generateDefaultTemplate();
             }
             $message = TemplateXSLT::render($retSourcedata, $handler->template);
             $healthStatusAlert = new HealthStatusAlert();
             $healthStatusAlert->message = $message;
             $healthStatusAlert->status = 'active';
             $healthStatusAlert->personId = $patientId;
             $healthStatusAlert->healthStatusHandlerId = $handler->healthStatusHandlerId;
             $healthStatusAlert->dateDue = date('Y-m-d H:i:s', strtotime($handler->timeframe));
             $healthStatusAlert->persist();
         } else {
             $retFulfill = call_user_func_array(array($classHandlerObject, 'fulfill'), array($handler, $patientId));
         }
     }
     Zend_Registry::set('cacheCodeObjects', $cacheCodeObjects);
 }
Exemplo n.º 3
0
 protected function _doProcess(Handler $handler, Audit $audit)
 {
     $ret = false;
     $handlerName = $handler->normalizedName;
     $datasourceName = $handler->dataIntegrationDatasource->normalizedName;
     $destinationName = $handler->dataIntegrationDestination->normalizedName;
     $actionName = $handler->dataIntegrationAction->normalizedName;
     $classConditionHandler = $handlerName . 'ConditionHandler';
     if (!parent::isParentOf($classConditionHandler, 'DataIntegrationConditionHandlerAbstract')) {
         return false;
     }
     if (call_user_func_array(array($classConditionHandler, 'matchAudit'), array($audit))) {
         do {
             $classDatasource = $datasourceName . 'DataIntegrationDatasource';
             if (!parent::isParentOf($classDatasource, 'DataIntegrationDatasourceAbstract')) {
                 return false;
             }
             $data = call_user_func_array(array($classDatasource, 'sourceData'), array($audit));
             switch ($handler->direction) {
                 case 'INCOMING':
                     $classAction = $actionName . 'DataIntegrationAction';
                     if (!parent::isParentOf($classAction, 'DataIntegrationActionAbstract')) {
                         return false;
                     }
                     $ret = call_user_func_array(array($classAction, 'act'), array($audit, $data));
                     break;
                 case 'OUTGOING':
                     $classDestination = $destinationName . 'DataIntegrationDestination';
                     if (!parent::isParentOf($classDestination, 'DataIntegrationDestinationAbstract')) {
                         return false;
                     }
                     $template = new DataIntegrationTemplate();
                     $template->dataIntegrationTemplateId = $handler->dataIntegrationTemplateId;
                     $template->populate();
                     $data['msh'] = HL7Message::generateMSHData($audit);
                     $template->template = TemplateXSLT::render($data, $template->template);
                     // temporarily override the template
                     $ret = call_user_func_array(array($classDestination, 'transmit'), array($audit, $template, $data));
                     // temporarily set to true, transmit() skeleton does not provide boolean return
                     $ret = true;
                     break;
             }
         } while (false);
     }
     return $ret;
 }
 protected function _isValidConditionObject()
 {
     $type = $this->_handler->handlerType;
     $handlerName = Handler::normalizeHandlerName($this->_handler->name);
     $conditionObject = $this->_handler->conditionObject;
     if (!strlen($conditionObject) > 0) {
         return __('Condition object is required');
     }
     eval($conditionObject);
     $ret = true;
     do {
         $classConditionHandler = $handlerName . 'ConditionHandler';
         if (!ProcessAlert::isParentOf($classConditionHandler, 'DataIntegrationConditionHandlerAbstract')) {
             $ret = __($classConditionHandler . ' does not exists or not an instance of DataIntegrationConditionHandlerAbstract');
             break;
         }
         $classDatasource = $handlerName . 'DataIntegrationDatasource';
         if (!ProcessAlert::isParentOf($classDatasource, 'DataIntegrationDatasourceAbstract')) {
             $ret = __($classDatasource . ' does not exists or not an instance of DataIntegrationDatasourceAbstract');
             break;
         }
         // code below is for HL7 only
         if ($type !== Handler::HANDLER_TYPE_HL7) {
             break;
         }
         $classAction = $handlerName . 'DataIntegrationAction';
         if (!ProcessAbstract::isParentOf($classAction, 'DataIntegrationActionAbstract')) {
             $ret = __($classAction . ' does not exists or not an instance of DataIntegrationActionAbstract');
             break;
         }
         $classDestination = $handlerName . 'DataIntegrationDestination';
         if (!ProcessAbstract::isParentOf($classDestination, 'DataIntegrationDestinationAbstract')) {
             $ret = __($classDestination . ' does not exists or not an instance of DataIntegrationDestinationAbstract');
             break;
         }
     } while (false);
     return $ret;
 }