/**
  * Default action to dispatch
  */
 public function indexAction()
 {
     $personId = (int) $this->_getParam('personId', 0);
     $visitId = (int) $this->_getParam('visitId', 0);
     $this->_setActivePatient($personId, $visitId);
     // ALERTS
     $personId = Zend_Auth::getInstance()->getIdentity()->personId;
     $team = new TeamMember();
     $teamId = $team->getTeamByPersonId($personId);
     $ctr = 0;
     if (strlen($teamId) > 0) {
         $alert = new GeneralAlert();
         $alertIterator = $alert->getIteratorByTeam($teamId);
         foreach ($alertIterator as $item) {
             $ctr++;
         }
     }
     if ($ctr > 0) {
         $this->view->alerts = $ctr;
     }
     $this->view->xmlHeader = '<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>' . "\n";
     $contentType = stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml") ? "application/xhtml+xml" : "text/xml";
     header("Content-type: " . $contentType);
     $this->render();
 }
Пример #2
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;
 }
 public static function refillRequestActionHandler(Audit $auditOrm, array $dataSourceData)
 {
     if (!count($dataSourceData) > 0) {
         WebVista::debug('Received an empty datasource');
         return false;
     }
     $orm = new GeneralAlert();
     $orm->populateWithArray($dataSourceData);
     $orm->persist();
     return true;
 }
 public function processForwardAlertAction()
 {
     $ret = false;
     $recipients = $this->_getParam('recipients');
     $alertData = $this->_getParam('forwardAlert');
     $alertData['dateTime'] = date('Y-m-d H:i:s');
     $alert = new GeneralAlert();
     if (isset($alertData['generalAlertId'])) {
         $alert->generalAlertId = (int) $alertData['generalAlertId'];
         if ($alert->populate()) {
             $alert->populateWithArray($alertData);
             $arrRecipients = explode(',', $recipients);
             foreach ($arrRecipients as $recipient) {
                 $tmpAlert = clone $alert;
                 $tmpAlert->generalAlertId = 0;
                 $tmpAlert->userId = (int) $recipient;
                 $tmpAlert->forwardedBy = (int) Zend_Auth::getInstance()->getIdentity()->personId;
                 $tmpAlert->persist();
             }
             $ret = true;
         }
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($ret);
 }
 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);
 }