public static function fromFhir($fhirObject) { $report = parent::fromFhir($fhirObject); $patient = \Patient::model()->find('id=?', array($report->patient_id)); $report->patient_id = $patient->id; $eye = 'Right'; if ($report->eye == 'L') { $eye = 'Left'; } elseif ($report->eye == 'B') { $eye = 'Both'; } $report->eye_id = \Eye::model()->find('name=:name', array(':name' => $eye))->id; if (isset($fhirObject->xml_file_data)) { $report->xml_file_data = base64_decode($fhirObject->xml_file_data); } $title = $report->file_reference; if (\ProtectedFile::model()->find('name = ?', array($title))) { throw new EverythingsFine("Duplicate filename: {$title} (patient ID {$report->patient_id})"); } $protected_file = \ProtectedFile::createForWriting($title); $protected_file->name = $title; file_put_contents($protected_file->getPath(), base64_decode($report->image_scan_data)); $protected_file->mimetype = 'image/gif'; $protected_file->save(); $cropped_file = \ProtectedFile::createForWriting($title); // all content is base64 encoded, so decode it: file_put_contents($cropped_file->getPath(), base64_decode($report->image_scan_crop_data)); $cropped_file->mimetype = 'image/gif'; $cropped_file->name = $title; $cropped_file->save(); $report->scanned_field_id = $protected_file->id; $report->scanned_field_crop_id = $cropped_file->id; return $report; }
/** * 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(); }
<fieldset class="row field-row"> <legend class="<?php echo $form->columns('label'); ?> "> Side: </legend> <div class="<?php echo $form->columns('field'); ?> "> <label class="inline"> <input type="radio" name="previous_operation_side" class="previous_operation_side" value="" checked="checked" /> None </label> <?php foreach (Eye::model()->findAll(array('order' => 'display_order')) as $eye) { ?> <label class="inline"><input type="radio" name="previous_operation_side" class="previous_operation_side" value="<?php echo $eye->id; ?> " /> <?php echo $eye->name; ?> </label> <?php } ?> </div> </fieldset> <?php
<?php $form = $this->beginWidget('BaseEventTypeCActiveForm', array('id' => 'clinical-create', 'enableAjaxValidation' => false, 'layoutColumns' => array('label' => 4, 'field' => 8))); ?> <?php $this->displayErrors($errors); ?> <?php if ($this->side_to_inject !== null) { $cls_lkup = array(0 => 'none', Eye::LEFT => 'left', Eye::RIGHT => 'right', Eye::BOTH => 'both'); if ($this->side_to_inject == 0) { $msg = 'No injection should be performed today'; } elseif ($this->side_to_inject == Eye::BOTH) { $msg = 'Both eyes to be injected'; } else { $msg = 'Only ' . strtolower(Eye::model()->findByPk($this->side_to_inject)->name) . ' eye to be injected'; } $columns = 6; $offset = 0; if ($this->side_to_inject === Eye::LEFT) { $offset = 6; } elseif ($this->side_to_inject !== Eye::RIGHT) { $columns = 12; } ?> <div class="row"> <div class="large-<?php echo $columns; ?> column large-offset-<?php echo $offset;
/** * AJAX method to check for any duplicate procedure bookings. */ public function actionVerifyProcedures() { $this->setPatient($_REQUEST['patient_id']); $resp = array('previousProcedures' => false); $procs = array(); $procs_by_id = array(); if (isset($_POST['Procedures_procs'])) { foreach ($_POST['Procedures_procs'] as $proc_id) { if ($p = Procedure::model()->findByPk((int) $proc_id)) { $procs[] = $p; $procs_by_id[$p->id] = $p; } } } $eye = Eye::model()->findByPk((int) @$_POST['Element_OphTrOperationbooking_Operation']['eye_id']); if ($eye && count($procs)) { $matched_procedures = array(); // get all the operation elements for this patient from booking events that have not been cancelled if (Yii::app()->params['OphTrOperationbooking_duplicate_proc_warn_all_eps']) { $episodes = $this->patient->episodes; } else { $episodes = array($this->getEpisode()); } foreach ($episodes as $ep) { $events = $ep->getAllEventsByType($this->event_type->id); foreach ($events as $ev) { if ($ev->id == @$_POST['event_id']) { // if we're editing, then don't want to check against that event continue; } $op = Element_OphTrOperationbooking_Operation::model()->findByAttributes(array('event_id' => $ev->id)); // check operation still valid, and that it is for a matching eye. if (!$op->operation_cancellation_date && ($op->eye_id == Eye::BOTH || $eye->id == Eye::BOTH || $op->eye_id == $eye->id)) { foreach ($op->procedures as $existing_proc) { if (in_array($existing_proc->id, array_keys($procs_by_id))) { if (!isset($matched_procedures[$existing_proc->id])) { $matched_procedures[$existing_proc->id] = array(); } $matched_procedures[$existing_proc->id][] = $op; } } } } } // if procedure matches if (count($matched_procedures)) { $resp['previousProcedures'] = true; $resp['message'] = $this->renderPartial('previous_procedures', array('matched_procedures' => $matched_procedures, 'eye' => $eye, 'procs_by_id' => $procs_by_id), true); } } echo \CJSON::encode($resp); }
public function getSelectedEye() { if (Yii::app()->getController()->getAction()->id == 'create') { // Get the procedure list and eye from the most recent booking for the episode of the current user's subspecialty if (!($patient = Patient::model()->findByPk(@$_GET['patient_id']))) { throw new SystemException('Patient not found: ' . @$_GET['patient_id']); } if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { if ($booking = $episode->getMostRecentBooking()) { return $booking->elementOperation->eye; } } } if (isset($_GET['eye'])) { return Eye::model()->findByPk($_GET['eye']); } return new Eye(); }
public function getDiagnosesForRow($type, $item, $list, $diagnoses) { $eyes = CHtml::listData(Eye::model()->findAll(), 'id', 'name'); $field_prefix = $type == 'Principal' ? 'pdis' : 'sdis'; for ($i = 0; $i < count($list); $i++) { if ($item["{$field_prefix}{$i}_date"]) { $ts = $this->getFreeTimestampIndex($item["{$field_prefix}{$i}_date"], $diagnoses); $diagnoses[$ts] = array('type' => $type, 'disorder' => $item["{$field_prefix}{$i}_fully_specified_name"], 'date' => $item["{$field_prefix}{$i}_date"], 'eye' => $eyes[$item["{$field_prefix}{$i}_eye"]]); } } return $diagnoses; }
/** * @return array */ public function getEyes() { $eyes = \Eye::model()->findAll(); $eyeIds = array(); foreach ($eyes as $eye) { $eyeIds[strtolower($eye->name)] = $eye->id; } return $eyeIds; }
/** * Customises eye options for this element. * * @FIXME: Shouldn't be touching the session stuff here if we can help it. Can we operate of the episode firm? * * @param $table * * @return array */ public function getEyeOptions() { $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); $element_type = ElementType::model()->find('event_type_id=? and class_name=?', array($event_type->id, 'Element_OphTrOperationnote_ProcedureList')); $criteria = new CDbCriteria(); $criteria->order = 't.display_order asc'; if (!in_array(Firm::model()->findByPk(Yii::app()->session['selected_firm_id'])->serviceSubspecialtyAssignment->subspecialty->name, array('Adnexal', 'Strabismus'))) { $criteria->addCondition('t.id != :three'); $criteria->params[':three'] = 3; } return CHtml::listData(Eye::model()->findAll($criteria), 'id', 'name'); }
/** * Works out the eye that should be used for an eyedraw. * * @FIXME: This should be a property on the element, or a variable passed to render. * * @return Eye * * @throws SystemException */ public function getSelectedEyeForEyedraw() { $eye = new Eye(); if (!empty($_POST['Element_OphTrOperationnote_ProcedureList']['eye_id'])) { $eye = Eye::model()->findByPk($_POST['Element_OphTrOperationnote_ProcedureList']['eye_id']); } elseif ($this->event && $this->event->id) { $eye = Element_OphTrOperationnote_ProcedureList::model()->find('event_id=?', array($this->event->id))->eye; } elseif (!empty($_GET['eye'])) { $eye = Eye::model()->findByPk($_GET['eye']); } elseif ($this->action->id == 'create') { // Get the procedure list and eye from the most recent booking for the episode of the current user's subspecialty if (!($patient = Patient::model()->findByPk(@$_GET['patient_id']))) { throw new SystemException('Patient not found: ' . @$_GET['patient_id']); } if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { if ($api = Yii::app()->moduleAPI->get('OphTrOperationbooking')) { if ($booking = $api->getMostRecentBookingForEpisode($episode)) { $eye = $booking->operation->eye; } } } } if ($eye->name == 'Both') { $eye = Eye::model()->find('name=?', array('Right')); } return $eye; }
* This file is part of OpenEyes. * OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>. * * @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 */ ?> <fieldset class="element-fields"> <?php echo $form->radioButtons($element, 'eye_id', CHtml::listData(Eye::model()->findAll(array('order' => 'display_order asc')), 'id', 'name')); ?> <?php $form->widget('application.widgets.ProcedureSelection', array('element' => $element, 'durations' => true)); ?> <?php echo $form->radioBoolean($element, 'consultant_required'); ?> <?php echo $form->dropDownList($element, 'named_consultant_id', CHtml::listData(User::model()->findAll(array('condition' => 'is_consultant = 1 and is_surgeon=1', 'order' => 'last_name, first_name')), 'id', 'reversedFullName'), array('empty' => '- Please select -'), false, array('field' => 3)); ?> <?php echo $form->radioBoolean($element, 'senior_fellow_to_do'); ?> <?php echo $form->radioBoolean($element, 'any_grade_of_doctor');