public function testSetOperationStatus_ScheduledOrRescheduled_Rescheduled() { $api = Yii::app()->moduleAPI->get('OphTrOperationbooking'); $eo = $this->el_o('eo12'); $api->setOperationStatus($eo->event_id, 'Scheduled or Rescheduled'); $this->assertEquals('Rescheduled', Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($eo->event_id))->status->name); }
/** * Collate the data and persist it to the table. * * @param $id * * @throws CHttpException * @throws Exception */ public function loadData($id) { $booking = Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($id)); $eye = Eye::model()->findByPk($booking->eye_id); if ($eye->name === 'Both') { throw new CHttpException(400, 'Can\'t display whiteboard for dual eye bookings'); } $eyeLabel = strtolower($eye->name); $event = Event::model()->findByPk($id); $episode = Episode::model()->findByPk($event->episode_id); $patient = Patient::model()->findByPk($episode->patient_id); $contact = Contact::model()->findByPk($patient->contact_id); $biometryCriteria = new CDbCriteria(); $biometryCriteria->addCondition('patient_id = :patient_id'); $biometryCriteria->params = array('patient_id' => $patient->id); $biometryCriteria->order = 'last_modified_date DESC'; $biometryCriteria->limit = 1; $biometry = Element_OphTrOperationnote_Biometry::model()->find($biometryCriteria); $examination = $event->getPreviousInEpisode(EventType::model()->findByAttributes(array('name' => 'Examination'))->id); //$management = new \OEModule\OphCiExamination\models\Element_OphCiExamination_Management(); //$anterior = new \OEModule\OphCiExamination\models\Element_OphCiExamination_AnteriorSegment(); $risks = new \OEModule\OphCiExamination\models\Element_OphCiExamination_HistoryRisk(); if ($examination) { //$management = $management->findByAttributes(array('event_id' => $examination->id)); //$anterior = $anterior->findByAttributes(array('event_id' => $examination->id)); $risks = $risks->findByAttributes(array('event_id' => $examination->id)); } $labResult = Element_OphInLabResults_Inr::model()->findPatientResultByType($patient->id, '1'); $allergies = Yii::app()->db->createCommand()->select('a.name as name')->from('patient_allergy_assignment pas')->leftJoin('allergy a', 'pas.allergy_id = a.id')->where("pas.patient_id = {$episode->patient_id}")->order('a.name')->queryAll(); $allergyString = 'None'; if ($allergies) { $allergyString = implode(',', array_column($allergies, 'name')); } $operation = Yii::app()->db->createCommand()->select('proc.term as term')->from('et_ophtroperationbooking_operation op')->leftJoin('ophtroperationbooking_operation_procedures_procedures opp', 'opp.element_id = op.id')->leftJoin('proc', 'opp.proc_id = proc.id')->where("op.event_id = {$id}")->queryAll(); $this->event_id = $id; $this->booking = $booking; $this->eye_id = $eye->id; $this->eye = $eye; $this->predicted_additional_equipment = $booking->special_equipment_details; $this->comments = ''; $this->patient_name = $contact['title'] . ' ' . $contact['first_name'] . ' ' . $contact['last_name']; $this->date_of_birth = $patient['dob']; $this->hos_num = $patient['hos_num']; $this->procedure = implode(',', array_column($operation, 'term')); $this->allergies = $allergyString; $this->iol_model = $biometry ? $biometry->attributes['lens_description_' . $eyeLabel] : 'Unknown'; $this->iol_power = $biometry ? $biometry->attributes['iol_power_' . $eyeLabel] : 'none'; $this->predicted_refractive_outcome = $biometry ? $biometry->attributes['predicted_refraction_' . $eyeLabel] : 'Unknown'; $this->alpha_blockers = $patient->hasRisk('Alpha blockers'); $this->anticoagulants = $patient->hasRisk('Anticoagulants'); $this->alpha_blocker_name = $risks ? $risks->alpha_blocker_name : ''; $this->anticoagulant_name = $risks ? $risks->anticoagulant_name : ''; $this->inr = $labResult ? $labResult : 'None'; $this->save(); }
protected function deceasedPatients() { echo 'Cancelling operations for deceased patients: '; // TODO: This needs to be made more robust $cancellation_reason = OphTrOperationbooking_Operation_Cancellation_Reason::model()->find("text = 'Patient has died'"); if (!$cancellation_reason) { throw new CException('Cannot find cancellation code for "patient has died"'); } $criteria = new CDbCriteria(); $criteria->addInCondition('`t`.status_id', array(1, 2, 3, 4)); $criteria->addCondition('is_deceased = 1 and session_date > :dateNow'); $criteria->params[':dateNow'] = date('Y-m-d'); foreach (Element_OphTrOperationbooking_Operation::model()->with(array('event' => array('with' => array('episode' => array('with' => 'patient'))), 'booking'))->findAll($criteria) as $operation) { $operation = Element_OphTrOperationbooking_Operation::model()->findByPk($operation['id']); $operation->cancel($cancellation_reason->id, 'Booking cancelled automatically', 1); echo '.'; } echo "\n"; }
/** * Cancel operation action. * * @param $id * * @throws CHttpException * @throws Exception */ public function actionCancel($id) { $operation = $this->operation; if ($operation->status->name == 'Cancelled') { return $this->redirect(array('default/view/' . $this->event->id)); } $errors = array(); if (isset($_POST['cancellation_reason']) && isset($_POST['operation_id'])) { $comment = isset($_POST['cancellation_comment']) ? strip_tags(@$_POST['cancellation_comment']) : ''; $result = $operation->cancel(@$_POST['cancellation_reason'], $comment); if ($result['result']) { $operation->event->deleteIssues(); $operation->event->audit('event', 'cancel'); die(json_encode(array())); } foreach ($result['errors'] as $form_errors) { foreach ($form_errors as $error) { $errors[] = $error; } } die(json_encode($errors)); } if (!($operation = Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($id)))) { throw new CHttpException(500, 'Operation not found'); } $this->patient = $operation->event->episode->patient; $this->title = 'Cancel operation'; $this->processJsVars(); $this->render('cancel', array('operation' => $operation, 'patient' => $operation->event->episode->patient, 'date' => $operation->minDate, 'errors' => $errors)); }
/** * Ajax method to check whether various attributes are required on a given session * (used to prevent them being turned off when they are needed on the session). * * @throws Exception */ public function actionCheckRequired() { if (!($session = OphTrOperationbooking_Operation_Session::model()->findByPk(@$_POST['session_id']))) { throw new Exception('Session not found: ' . $_POST['session_id']); } Yii::app()->event->dispatch('start_batch_mode'); switch (@$_POST['type']) { case 'consultant': $criteria = new CDbCriteria(); $criteria->addInCondition('`t`.status_id', array(2, 4)); $criteria->addCondition('session.id = :sessionId and booking.booking_cancellation_date is null and `t`.consultant_required = :required'); $criteria->params[':sessionId'] = $session->id; $criteria->params[':required'] = 1; if (Element_OphTrOperationbooking_Operation::model()->with(array('booking' => array('with' => 'session')))->find($criteria)) { echo '1'; } else { echo '0'; } return; case 'paediatric': foreach ($session->activeBookings as $booking) { if ($booking->operation->event->episode->patient->isChild($session->date)) { echo '1'; return; } } echo '0'; return; case 'anaesthetist': $criteria = new CDbCriteria(); $criteria->addCondition('session.id = :sessionId and booking.booking_cancellation_date is null and `t`.anaesthetist_required = :required'); $criteria->addInCondition('`t`.status_id', array(2, 4)); $criteria->params[':sessionId'] = $session->id; $criteria->params[':required'] = 1; if (Element_OphTrOperationbooking_Operation::model()->with(array('booking' => array('with' => 'session')))->find($criteria)) { echo '1'; } else { echo '0'; } return; case 'general_anaesthetic': $criteria = new CDbCriteria(); $criteria->addCondition('session.id = :sessionId and booking.booking_cancellation_date is null and `t`.anaesthetic_type_id = :anaestheticType'); $criteria->addInCondition('`t`.status_id', array(2, 4)); $criteria->params[':sessionId'] = $session->id; $criteria->params[':anaestheticType'] = 5; if (Element_OphTrOperationbooking_Operation::model()->with(array('booking' => array('with' => 'session')))->find($criteria)) { echo '1'; } else { echo '0'; } return; } throw new Exception('Unknown type: ' . @$_POST['type']); }
public function testActionScheduleOperation() { $this->markTestIncomplete(); $this->scheduleOperation(array('event_id' => 5, 'firm_id' => 2, 'session_id' => 6, 'date' => date('Ym'), 'day' => date('j'))); $eo = Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array(5)); $booking = OphTrOperationbooking_Operation_Booking::model()->find(array('condition' => 'element_id = :eoid', 'params' => array(':eoid' => $eo->id), 'order' => 'id desc')); $this->assertInstanceOf('OphTrOperationbooking_Operation_Booking', $booking); $this->assertEquals(6, $booking->session_id); $this->assertEquals('09:14:00', $booking->admission_time); $this->assertEquals('08:00:00', $booking->session_start_time); $this->assertEquals('13:00:00', $booking->session_end_time); $this->assertEquals('2014-01-27', $booking->session_date); $this->assertEquals(1, $booking->session_theatre_id); $this->assertEquals(1, $booking->ward_id); $this->assertEquals('Test 123', $eo->comments); $this->assertEquals('Test 456', $eo->comments_rtt); $this->assertEquals('Test 789', $booking->session->comments); $this->assertEquals(1, $eo->site_id); $this->assertEquals(2, $eo->status_id); $this->undoLastBooking(); }
* @link http://www.openeyes.org.uk * * @author OpenEyes <*****@*****.**> * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust * @copyright Copyright (c) 2011-2013, OpenEyes Foundation * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ ?> <?php $this->beginContent('//patient/event_container'); ?> <?php $this->moduleNameCssClass .= ' highlight-fields'; $this->title .= ' (' . Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($this->event->id))->status->name . ')'; ?> <?php if (!$operation->has_gp) { ?> <div class="alert-box alert with-icon"> Patient has no GP practice address, please correct in PAS before printing GP letter. </div> <?php } ?> <?php if (!$operation->has_address) { ?> <div class="alert-box alert with-icon">
public function findBookingByEventID($event_id) { if ($eo = Element_OphTrOperationbooking_Operation::model()->with('booking')->find('event_id=?', array($event_id))) { return $eo->booking; } return false; }
/** * Ajax method to mark the given operations with transport arranged. * * @throws Exception */ public function actionConfirm() { if (is_array(@$_POST['operations'])) { foreach ($_POST['operations'] as $operation_id) { if (!($operation = Element_OphTrOperationbooking_Operation::model()->with('latestBooking')->findByPk($operation_id))) { throw new Exception('Operation not found: ' . $operation_id); } $booking = $operation->latestBooking; if (!$booking->transport_arranged) { $booking->transport_arranged = 1; $booking->transport_arranged_date = date('Y-m-d'); if (!$booking->save(true, null, true)) { throw new Exception('Unable to save booking: ' . print_r($booking->getErrors(), true)); } } } } echo '1'; }
/** * Set operations printed letter state. */ public function actionConfirmPrinted() { Audit::add('waiting list', 'confirm'); foreach ($_POST['operations'] as $operation_id) { if ($operation = Element_OphTrOperationbooking_Operation::Model()->findByPk($operation_id)) { if (Yii::app()->user->checkAccess('admin') and isset($_POST['adminconfirmto']) and $_POST['adminconfirmto'] != 'OFF' and $_POST['adminconfirmto'] != '') { $operation->confirmLetterPrinted($_POST['adminconfirmto'], $_POST['adminconfirmdate']); } else { $operation->confirmLetterPrinted(); } } } }
/** * Get the operation booking for the event. * * @return OphTrOperationbooking_Operation_Booking */ public function getCurrentBooking() { if ($this->event_id && ($op = Element_OphTrOperationbooking_Operation::model()->with('booking')->find('event_id = ?', array($this->event_id)))) { return $op->booking; } }
</thead> <tbody> <tr> <td> <?php echo CHtml::dropDownList('subspecialty-id', @$_POST['subspecialty-id'], Subspecialty::model()->getList(), array('empty' => 'All specialties', 'ajax' => array('type' => 'POST', 'data' => array('subspecialty_id' => 'js:this.value', 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken), 'url' => Yii::app()->createUrl('/OphTrOperationbooking/waitingList/filterFirms'), 'success' => "js:function(data) {\n\t\t\t\t\t\t\t\t\t\t\tif (\$('#subspecialty-id').val() != '') {\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#firm-id').attr('disabled', false);\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#firm-id').html(data);\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#firm-id').attr('disabled', true);\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#firm-id').html(data);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}"))); ?> </td> <td> <?php echo CHtml::dropDownList('firm-id', @$_POST['firm-id'], $this->getFilteredFirms(@$_POST['subspecialty-id']), array('empty' => 'All firms', 'disabled' => !@$_POST['firm-id'])); ?> </td> <td> <?php echo CHtml::dropDownList('status', @$_POST['status'], Element_OphTrOperationbooking_Operation::getLetterOptions()); ?> </td> <td> <?php echo CHtml::dropDownList('site_id', @$_POST['site_id'], Site::model()->getListForCurrentInstitution(), array('empty' => 'All sites')); ?> </td> <td> <?php echo CHtml::textField('hos_num', @$_POST['hos_num'], array('autocomplete' => Yii::app()->params['html_autocomplete'], 'size' => 12)); ?> <span id="hos_num_error" class="red"<?php if (!@$_POST['hos_num'] || ctype_digit($_POST['hos_num'])) { ?> style="display: none;"<?php
public function testgetRTT_referral2Active() { $test = new Element_OphTrOperationbooking_Operation(); $active_rtt = array(new RTT(), new RTT()); $referral = ComponentStubGenerator::generate('Referral', array('activeRTT' => $active_rtt)); $test->referral = $referral; $this->assertNull($test->getRTT()); }