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);
 }
 public function _setActivePatient($personId, $visitId)
 {
     if (!$personId > 0) {
         return;
     }
     $memcache = Zend_Registry::get('memcache');
     $patient = new Patient();
     $patient->personId = (int) $personId;
     $patient->populate();
     $patient->person->populate();
     $this->_patient = $patient;
     $this->view->patient = $this->_patient;
     $mostRecentRaw = $memcache->get('mostRecent');
     $currentUserId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $personId = $patient->personId;
     $teamId = $patient->teamId;
     if ($mostRecentRaw === false) {
         $mostRecent = array();
     } else {
         $mostRecent = unserialize($mostRecentRaw);
     }
     if (!array_key_exists($currentUserId, $mostRecent)) {
         $mostRecent[$currentUserId] = array();
     }
     if (array_key_exists($personId, $mostRecent[$currentUserId])) {
         unset($mostRecent[$currentUserId][$personId]);
     }
     $name = $patient->person->last_name . ', ' . $patient->person->first_name . ' ' . substr($patient->person->middle_name, 0, 1) . ' #' . $patient->record_number;
     $mostRecent[$currentUserId][$patient->personId] = array('name' => $name, 'teamId' => $teamId);
     $memcache->set('mostRecent', serialize($mostRecent));
     if (strlen($patient->teamId) > 0) {
         $name = TeamMember::ENUM_PARENT_NAME;
         $enumeration = new Enumeration();
         $enumeration->populateByEnumerationName($name);
         $enumerationsClosure = new EnumerationsClosure();
         $rowset = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
         $patientEnumerationId = 0;
         foreach ($rowset as $row) {
             if ($patient->teamId == $row->key) {
                 $patientEnumerationId = $row->enumerationId;
                 break;
             }
         }
         if ($patientEnumerationId !== 0) {
             $this->view->team = TeamMember::generateTeamTree($patientEnumerationId);
         }
     }
     // POSTINGS
     $allergies = array();
     $patientAllergy = new PatientAllergy();
     $patientAllergyIterator = $patientAllergy->getIteratorByPatient($personId);
     foreach ($patientAllergyIterator as $allergy) {
         if ($allergy->noKnownAllergies) {
             continue;
         }
         $allergies[] = $allergy->toArray();
     }
     $this->view->allergies = $allergies;
     $notes = array();
     $patientNote = new PatientNote();
     $patientNoteIterator = $patientNote->getIterator();
     $filters = array();
     $filters['patient_id'] = $personId;
     $filters['active'] = 1;
     $filters['posting'] = 1;
     $patientNoteIterator->setFilters($filters);
     foreach ($patientNoteIterator as $note) {
         $notes[] = $note->toArray();
     }
     $this->view->notes = $notes;
     //REMINDERS
     $ctr = 0;
     $hsa = new HealthStatusAlert();
     $hsaIterator = $hsa->getIteratorByStatusWithPatientId('active', $personId);
     foreach ($hsaIterator as $row) {
         $ctr++;
     }
     if ($ctr > 0) {
         $this->view->reminders = $ctr;
     }
     // VISITS
     //$this->_visit = null;
     if (!$visitId > 0) {
         return;
     }
     $visit = new Visit();
     $visit->encounter_id = (int) $visitId;
     $visit->populate();
     $this->_visit = $visit;
     $this->view->visit = $this->_visit;
 }
Exemple #3
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);
 }
 public function testTetanusShotsFulfillWithAudit()
 {
     $this->_objects = HealthStatusHandler::generateTestTetanus();
     $objects = array();
     $timeTrigger = date('h:i A', strtotime('-10 minutes'));
     $processHSA = new ProcessHSA($timeTrigger);
     $process = Processingd::getInstance();
     $process->clearProcesses();
     $process->addProcess($processHSA);
     $process->startProcessing(false);
     $audit = new Audit();
     $audit->_ormPersist = true;
     $audit->objectClass = get_class($this->_objects['medication']);
     $audit->objectId = $this->_objects['medication']->medicationId;
     $audit->dateTime = date('Y-m-d H:i:s');
     $audit->type = WebVista_Model_ORM::REPLACE;
     $audit->userId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $audit->persist();
     $objects['audit'] = $audit;
     $time = date('h:i A', strtotime('-2 minutes'));
     // advance the time to 2 minutes due to fast processing
     $processHSA->setCurrentTime($time);
     $process->clearProcesses();
     $process->addProcess($processHSA);
     $process->startProcessing(false);
     $healthStatusAlert = new HealthStatusAlert();
     $healthStatusAlert->populateByHandlerPatientId($this->_objects['healthStatusHandler']->healthStatusHandlerId, $this->_objects['patient']->personId);
     $objects['healthStatusAlert'] = $healthStatusAlert;
     $this->_cleanUpObjects($objects);
     $this->assertTrue(strlen($healthStatusAlert->status) > 0, 'No alert created');
     $this->assertEquals($healthStatusAlert->status, 'fulfilled', 'Alert is not fulfilled');
     $this->assertEquals(date('Y-m-d', strtotime($healthStatusAlert->dateDue)), date('Y-m-d', strtotime('+1 month')), 'Due date is invalid');
 }
Exemple #5
0
 public static function patientEducation(HealthStatusHandler $handler, PatientEducation $edu, Audit $audit)
 {
     $db = Zend_Registry::get('dbAdapter');
     list($code, $patientId) = explode(';', $audit->objectId);
     $alert = new HealthStatusAlert();
     $sqlSelect = $db->select()->from($alert->_table)->where('personId = ?', $patientId)->where("status = 'active'");
     if ($code = 'CYBS') {
         $sqlSelect->where('message LIKE ?', '%Diabetes Education: Controlling Your Blood Sugar%');
     } else {
         if ($code = 'LTMA') {
             $sqlSelect->where('message LIKE ?', '%Asthma Education: Learn to manage Asthma%');
         } else {
             return;
         }
     }
     $iterator = $alert->getIterator($sqlSelect);
     foreach ($iterator as $hsa) {
         $hsa->status = 'fulfilled';
         $hsa->persist();
     }
 }