public function ajaxMarkAppointmentAction()
 {
     $appointmentId = (int) $this->_getParam('appointmentId');
     $mark = $this->_getParam('mark');
     $app = new Appointment();
     $app->appointmentId = $appointmentId;
     $app->populate();
     //todo: compare provided mark against eligible in matching enumeration
     $app->appointmentCode = $mark;
     $app->persist();
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(true);
 }
Ejemplo n.º 2
0
 public function changeTimeAppointmentAction()
 {
     $appointmentId = (int) $this->_getParam('appointmentId');
     $time = date('H:i:s', strtotime($this->_getParam('time')));
     $forced = (int) $this->_getParam('forced');
     $app = new Appointment();
     $app->appointmentId = $appointmentId;
     $data = array('error' => 'Appointment does not exists');
     if ($app->populate()) {
         $app->lastChangeId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
         $app->lastChangeDate = date('Y-m-d H:i:s');
         $startTime = strtotime($app->start);
         $endTime = strtotime($app->end);
         $diff = $endTime - $startTime;
         $x = explode(' ', date('Y-m-d H:i:s', $startTime));
         $date = $x[0];
         $start = strtotime($date . ' ' . $time);
         $end = $start + $diff;
         $app->start = date('Y-m-d H:i:s', $start);
         $app->end = date('Y-m-d H:i:s', $end);
         $data = array('appointmentId' => $appointmentId);
         if (!$forced && ($error = $app->checkRules())) {
             // prompt the user if the appointment being made would be a double book or is outside of schedule time.
             $data['confirmation'] = $error;
         } else {
             $app->persist();
             //trigger_error(print_r($params,true));
             $data['appointmentId'] = $app->appointmentId;
         }
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
 public function processAddAppointmentAction()
 {
     $appointment = $this->_getParam('appointment');
     $paramProviders = array();
     foreach ($appointment as $key => $val) {
         $providerPrefix = 'providerId-';
         if (substr($key, 0, strlen($providerPrefix)) == $providerPrefix) {
             $paramProviders[] = $val;
             unset($appointment[$key]);
         }
     }
     if (count($paramProviders) > 0) {
         // assign the first providerId
         $appointment['providerId'] = array_shift($paramProviders);
     }
     // extra providers if any, can be retrieved using $paramProviders variable, not sure where to place it
     $columnId = $this->_getParam('columnId');
     $rowId = $this->_getParam('rowId');
     $filter = $this->getCurrentDisplayFilter();
     if (strlen($columnId) <= 0) {
         // look for the column of the input provider
         if (strlen($appointment['providerId']) > 0) {
             foreach ($filter->columns as $index => $column) {
                 if ($column['providerId'] == $appointment['providerId']) {
                     $columnId = $index;
                     break;
                 }
             }
         }
         // in the meantime, no room checked, how are we going to check for the room?
     }
     if (!isset($filter->columns[$columnId])) {
         throw new Exception(__("Cannot generate column with that index, there is no filter defined for that column Index: ") . $columnId);
     }
     $column = $filter->columns[$columnId];
     $app = new Appointment();
     $app->populateWithArray($appointment);
     if ($app->appointmentId > 0) {
         $app->lastChangeId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
         $app->lastChangeDate = date('Y-m-d H:i:s');
     } else {
         $app->creatorId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
         $app->createdDate = date('Y-m-d H:i:s');
     }
     //$app->providerId = $appointment['providerId'];
     //$app->patientId = substr($appointment['patient'],stripos($appointment['patient'],'PID:') + 4);
     $app->walkin = isset($appointment['walkin']) ? 1 : 0;
     $app->start = $filter->date . ' ' . date('H:i:s', strtotime($appointment['start']));
     $app->end = $filter->date . ' ' . date('H:i:s', strtotime($appointment['end']));
     $app->persist();
     $data = array();
     $data['columnId'] = $columnId;
     $data['rowId'] = $rowId;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
Ejemplo n.º 4
0
 function ajaxStationFromAppointmentAction()
 {
     $appointmentId = (int) $this->_getParam('appointmentId');
     $stationId = $this->_getParam('stationId');
     trigger_error('st: ' . $stationId, E_USER_NOTICE);
     $personId = '';
     $routing = new Routing();
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $appointment = new Appointment();
     $appointment->appointmentId = $appointmentId;
     $appointment->populate();
     //appointment already arrived, prevent a dupe
     if ($appointment->arrived > 0) {
         return $json->direct(array(false));
     }
     $patientId = $appointment->patientId;
     $provider = new Provider();
     $provider->personId = $appointment->providerId;
     $provider->populate();
     if (strlen($stationId) > 0) {
         trigger_error('st: ' . $stationId, E_USER_NOTICE);
     } elseif (strlen($provider->routingStation) > 0) {
         $stationId = $provider->routingStation;
     } else {
         if ($appointment->roomId > 0) {
             $room = new Room();
             $room->roomId = $appointment->roomId;
             $room->populate();
             if (strlen($room->routingStation) > 0) {
                 $stationId = $room->routingStation;
             }
         }
     }
     $routing->personId = $appointment->patientId;
     $routing->stationId = $stationId;
     $routing->appointmentId = $appointment->appointmentId;
     $routing->providerId = $appointment->providerId;
     $routing->roomId = $appointment->roomId;
     $routing->timestamp = date('Y-m-d H:i:s');
     if ($routing->personId > 0 && strlen($stationId) > 0) {
         $appointment->arrived = 1;
         $appointment->persist();
         $routing->persist();
         return $json->direct(array(true));
     }
     return $json->direct(array(false));
 }