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); }
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 populateEncounters(SimpleXMLElement $xml) { $component = $xml->addChild('component'); $section = $component->addChild('section'); $templateId = $section->addChild('templateId'); $templateId->addAttribute('root', '2.16.840.1.113883.10.20.1.3'); // <!-- Encounters section template --> $code = $section->addChild('code'); $code->addAttribute('code', '46240-8'); $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1'); $section->addChild('title', 'Encounters'); if ($this->visit !== null) { $visitIterator = array($this->visit); } else { $visitIterator = new VisitIterator(); $visitIterator->setFilters(array('patientId' => $this->_patientId)); } $rows = array(); foreach ($visitIterator as $visit) { $building = new Building(); $building->buildingId = $visit->buildingId; $building->populate(); $appointment = new Appointment(); $appointment->appointmentId = $visit->appointmentId; $appointment->populate(); $rows[] = array('encounter' => html_convert_entities($appointment->title), 'location' => html_convert_entities($building->displayName), 'date' => date('M d, Y', strtotime($visit->dateOfTreatment))); } $text = $section->addChild('text'); if ($rows) { $table = $text->addChild('table'); $thead = $table->addChild('thead'); $tr = $thead->addChild('tr'); $tr->addChild('th', 'Encounter'); $tr->addChild('th', 'Location'); $tr->addChild('th', 'Date'); $tbody = $table->addChild('tbody'); foreach ($rows as $row) { $tr = $tbody->addChild('tr'); $tr->addChild('td', $row['encounter']); $tr->addChild('td', $row['location']); $tr->addChild('td', $row['date']); } } }
function processNextStationByAppointmentAction() { $appointmentId = (int) $this->_getParam('appointmentId'); $stationId = $this->_getParam('stationId'); $appointment = new Appointment(); $appointment->appointmentId = $appointmentId; $appointment->populate(); $provider = new Provider(); $provider->personId = $appointment->providerId; $provider->populate(); $routing = new Routing(); $routing->personId = $appointment->patientId; $routing->appointmentId = $appointment->appointmentId; $routing->providerId = $appointment->providerId; $routing->roomId = $appointment->roomId; $routing->populateByAppointments(); $routing->fromStationId = $routing->stationId; $routing->stationId = $stationId; $routing->timestamp = date('Y-m-d H:i:s'); $routing->persist(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array(true)); }
public function addPaymentAction() { $columnId = -1; $appointmentId = (int) $this->_getParam('appointmentId'); $visitId = (int) $this->_getParam('visitId'); $appointment = new Appointment(); $appointment->appointmentId = $appointmentId; $appointment->populate(); $payment = new Payment(); $payment->visitId = $visitId; $payment->personId = (int) $appointment->patientId; $payment->appointmentId = $appointmentId; if (!$visitId > 0) { $columnId = (int) $this->_getParam('columnId'); } $form = new WebVista_Form(array('name' => 'paymentId')); $form->setAction(Zend_Registry::get('baseUrl') . 'appointment.raw/process-add-payment'); $form->loadORM($payment, 'Payment'); $form->setWindow('winPaymentId'); $this->view->form = $form; $this->view->visitId = $visitId; $guid = 'd1d9039a-a21b-4dfb-b6fa-ec5f41331682'; $enumeration = new Enumeration(); $enumeration->populateByGuid($guid); $closure = new EnumerationClosure(); $this->view->paymentTypes = $closure->getAllDescendants($enumeration->enumerationId, 1, true)->toArray('key', 'name'); $this->view->columnId = $columnId; $this->render('add-payment'); }
public static function appointment($appointmentId) { $appointmentId = (int) $appointmentId; $db = Zend_Registry::get('dbAdapter'); $sqlSelect = $db->select()->from('audits', 'COUNT(*) AS ctr')->where("objectClass = 'Appointment' AND objectId = ?", $appointmentId); $newAppointment = true; if (($row = $db->fetchRow($sqlSelect)) && $row['ctr'] > 1) { $newAppointment = false; } $appointment = new Appointment(); $appointment->appointmentId = $appointmentId; $appointment->populate(); $siu = 'S12'; $statusCode = 1; // Default: Booked if (!$newAppointment) { // check appointment if cancel or no show $siu = 'S14'; $appointmentCode = $appointment->appointmentCode; if ($appointmentCode == 'CAN') { $siu = 'S15'; $statusCode = 2; } else { if ($appointmentCode == 'NS') { $siu = 'S26'; $statusCode = 3; } } } $t = microtime(); $x = explode(' ', $t); $date = date('YmdHis', $x[1]); $messageId = $date . str_replace('.', '0', $x[0]); $id = 0; $fillerStatusCodes = array('1' => 'BOOKED', '2' => 'CANCELLED', '3' => 'NO SHOW', '4' => 'COMPLETE', '5' => 'OVERBOOK', '6' => 'BLOCKED', '7' => 'DELETED', '8' => 'STARTED', '9' => 'PENDING', '10' => 'WAITLIST', '11' => 'DC'); $appointmentTemplate = new AppointmentTemplate(); $reasons = $appointmentTemplate->appointmentReasons; $data = array(); $data['appointmentId'] = $appointment->appointmentId; $data['appointmentReasonIdentifier'] = $appointment->reason; $data['appointmentReasonText'] = isset($reasons[$appointment->reason]) ? $reasons[$appointment->reason]['name'] : ''; $start = strtotime($appointment->start); $end = strtotime($appointment->end); $time = ($end - $start) / 60; $unit = 'minute'; if ($time >= 60) { $time /= 60; $unit = 'hour'; } if ($time > 1) { $unit .= 's'; } $data['durationTime'] = $time; $data['durationUnit'] = $unit; $data['start'] = date('YmdHi', $start); $data['end'] = date('YmdHi', $end); $data['statusCode'] = isset($fillerStatusCodes[$statusCode]) ? $fillerStatusCodes[$statusCode] : $statusCode; $data['title'] = $appointment->title; $personId = (int) $appointment->patientId; $providerId = (int) $appointment->providerId; $roomId = (int) $appointment->roomId; $patientData = self::_getPatientData($personId, true, $providerId, $roomId); $patient = $patientData['patient']; $provider = $patientData['provider']; // TODO: identify SCH 72 AND PV1 second to the last segment $data['unknownId'] = ''; // sample value = 72 $hl7Message = array(); $hl7Message[] = "MSH|^~\\&|MedMgr|989801|aroeshl7_prod|HEST|{$date}||SIU^{$siu}|{$messageId}|P|2.3|{$id}|"; $hl7Message[] = self::_SCH($data); $hl7Message[] = "NTE|1||{$data['title']}|"; $hl7Message[] = "NTE|2||\"\"|"; $hl7Message[] = self::_PID($patient); $hl7Message[] = self::_PV1($provider); $hl7Message[] = "RGS|1|A|"; $hl7Message[] = self::_AIL($provider); $hl7Message[] = self::_AIP($provider); $separator = "\r\n"; return implode($separator, $hl7Message); }
public function addAppointmentAction() { $appointmentId = $this->_getParam('appointmentId'); $appointment = new Appointment(); if (strlen($appointmentId) > 0) { $filter = $this->getCurrentDisplayFilter(); $appointment->appointmentId = (int) $appointmentId; $appointment->populate(); $this->view->start = date('H:i', strtotime($appointment->start)); $this->view->end = date('H:i', strtotime($appointment->end)); foreach ($filter->columns as $index => $col) { if ($col['providerId'] > 0 && $col['roomId'] > 0 && $col['providerId'] == $appointment->providerId && $col['roomId'] == $appointment->roomId || $col['providerId'] > 0 && $col['providerId'] == $appointment->providerId || $col['roomId'] > 0 && $col['roomId'] == $appointment->roomId) { $this->view->columnId = $index; break; } } $recordNumber = $appointment->patient->record_number; $lastName = $appointment->patient->last_name; $firstName = $appointment->patient->first_name; $middleInitial = ''; if (strlen($appointment->patient->middle_name) > 0) { $middleInitial = $appointment->patient->middle_name[0]; } $this->view->patient = "{$lastName}, {$firstName} {$middleInitial} #{$recordNumber} PID:{$appointment->patient->person_id}"; } else { $columnId = $this->_getParam('columnId'); $rowId = $this->_getParam('rowId'); $start = $this->_getParam('start'); if (strlen($columnId) > 0) { $this->view->columnId = $columnId; $filter = $this->getCurrentDisplayFilter(); 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]; $appointment->providerId = isset($column['providerId']) ? $column['providerId'] : 0; $appointment->roomId = isset($column['roomId']) ? $column['roomId'] : 0; } if (strlen($start) > 0) { $this->view->start = $start; $this->view->end = date('H:i', strtotime('+1 hour', strtotime($start))); } } $form = new WebVista_Form(array('name' => 'add-appointment')); $form->setAction(Zend_Registry::get('baseUrl') . "calendar.raw/process-add-appointment"); $form->loadORM($appointment, "Appointment"); $form->setWindow('windowNewAppointment'); $this->view->form = $form; $reasons = array(); $enumeration = new Enumeration(); $enumeration->populateByEnumerationName(PatientNote::ENUM_REASON_PARENT_NAME); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $ctr = 0; foreach ($enumerationIterator as $enum) { // since data type of patient_note.reason is tinyint we simply use the counter as id $reasons[$ctr++] = $enum->name; } /* $patientNotes = array(); $patientNote = new PatientNote(); $patientNoteIterator = $patientNote->getIterator(); $filters = array(); $filters['patient_id'] = (int)$appointment->patientId; $filters['active'] = 1; $filters['posting'] = 0; $patientNoteIterator->setFilters($filters); foreach ($patientNoteIterator as $row) { $patientNotes[$row->patientNoteId] = $reasons[$row->reason]; } $this->view->patientNotes = $patientNotes; */ $phones = array(); $phone = new PhoneNumber(); $phoneIterator = $phone->getIteratorByPatientId($appointment->patientId); foreach ($phoneIterator as $row) { $phones[] = $row->number; } $this->view->phones = $phones; $appointmentTemplate = new AppointmentTemplate(); $appointmentReasons = $appointmentTemplate->getAppointmentReasons(); $this->view->appointmentReasons = $appointmentReasons; $this->view->appointment = $appointment; $this->render('add-appointment'); }