protected static function createHSA(HealthStatusHandler $handler, $patientId, $message) { $db = Zend_Registry::get('dbAdapter'); $ret = false; // create an alert $healthStatusAlert = new HealthStatusAlert(); $sqlSelect = $db->select()->from($healthStatusAlert->_table)->where('personId = ?', (int) $patientId)->where("status = 'active'")->where('message LIKE ?', '%' . (string) $message . '%')->where('healthStatusHandlerId = ?', (int) $handler->healthStatusHandlerId)->limit(1); if ($db->fetchRow($sqlSelect)) { return $ret; } $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(); return true; }
public function processEditStatusAction() { $status = $this->_getParam('status', ''); $healthStatusAlertId = (int) $this->_getParam('healthStatusAlertId'); $healthStatusAlert = new HealthStatusAlert(); $healthStatusAlert->healthStatusAlertId = $healthStatusAlertId; $healthStatusAlert->populate(); $healthStatusAlert->status = $status; $healthStatusAlert->persist(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(true); }
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); }