From d3cff66dedc8ca6a8f83f10a2cec244eb538805e Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 26 Sep 2016 15:06:22 +0100 Subject: [PATCH 001/164] OE-6209: Finds most recent risk from examination Finds the most recent risk from examination. Will look across episodes and take whichever was more recent. Beginning checks on patient summary risk as well in case it is added there instead of examination. --- .../Element_OphCiExamination_HistoryRisk.php | 57 ++++++++-- .../OphTrOperationbooking_Whiteboard.php | 101 ++++++++++++------ .../views/whiteboard/view.php | 4 +- 3 files changed, 118 insertions(+), 44 deletions(-) diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php index 1cd79a6e17..957af0a008 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php @@ -24,8 +24,8 @@ * * The followings are the available columns in table: * - * @property int $id - * @property int $event_id + * @property int $id + * @property int $event_id * @property OphCiExamination_GlaucomaRisk_Risk $risk * * The followings are the available model relations: @@ -74,13 +74,13 @@ public function rules() * @param $attribute * @param $params */ - public function validateName($attribute,$params) + public function validateName($attribute, $params) { - if($this->$params['type'] === '1' && !$this->$attribute){ + if ($this->$params['type'] === '1' && !$this->$attribute) { $this->addError($attribute, 'When checked a drug name is required'); } - if($this->$params['type'] !== '1' && $this->$attribute){ + if ($this->$params['type'] !== '1' && $this->$attribute) { $this->addError($attribute, 'A drug name cannot be supplied without selecting yes.'); } } @@ -144,7 +144,7 @@ public function search() */ public function anticoagulantText() { - return 'Anticoagulants: '.$this->yesNoText($this->anticoagulant).(($this->anticoagulant_name) ? ' - '.$this->anticoagulant_name : ''); + return 'Anticoagulants: ' . $this->yesNoText($this->anticoagulant) . (($this->anticoagulant_name) ? ' - ' . $this->anticoagulant_name : ''); } /** @@ -152,7 +152,7 @@ public function anticoagulantText() */ public function alphaBlockerText() { - return 'Alpha-Blockers: '.$this->yesNoText($this->alphablocker).(($this->alpha_blocker_name) ? ' - '.$this->alpha_blocker_name : ''); + return 'Alpha-Blockers: ' . $this->yesNoText($this->alphablocker) . (($this->alpha_blocker_name) ? ' - ' . $this->alpha_blocker_name : ''); } /** @@ -185,4 +185,47 @@ public function canCopy() { return true; } + + /** + * @return array|mixed|null + */ + public function mostRecentCheckedAlpha($id) + { + return $this->mostRecentChecked('alphablocker', $id); + } + + /** + * @return array|mixed|null + */ + public function mostRecentCheckedAnticoag($id) + { + return $this->mostRecentChecked('anticoagulant', $id); + } + + /** + * Find the most recent element that has actually been checked + * + * Finds the most recent element where the question of $type has + * actually been checked, yes or no. + * + * @param $type + * + * @return array|mixed|null + */ + protected function mostRecentChecked($type, $id) + { + $criteria = new \CDbCriteria(); + $criteria->join = 'join event on t.event_id = event.id '; + $criteria->join .= 'join episode on event.episode_id = episode.id '; + $criteria->join .= 'join patient on episode.patient_id = patient.id '; + $criteria->addCondition($type . ' > 0'); + $criteria->addCondition('episode.patient_id = :patient_id'); + $criteria->addCondition('event.event_date > patient.no_risks_date'); + $criteria->params = array('patient_id' => $id); + $criteria->order = 'event.event_date DESC'; + $criteria->limit = 1; + + return self::model()->find($criteria); + } + } diff --git a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php index 3270c1105a..75075e6deb 100644 --- a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php +++ b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php @@ -67,45 +67,17 @@ public function loadData($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); + $biometry = $this->recentBiometry($patient); - $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)); - } + $blockers = $risks->mostRecentCheckedAlpha($patient->id); + $anticoag = $risks->mostRecentCheckedAnticoag($patient->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 = $this->allergyString($episode); - $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(); + $operation = $this->operation($id); $this->event_id = $id; $this->booking = $booking; @@ -123,8 +95,8 @@ public function loadData($id) $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->alpha_blocker_name = ($blockers) ? $blockers->alpha_blocker_name . ' (' . $blockers->event->event_date . ')' : ''; + $this->anticoagulant_name = ($anticoag) ? $anticoag->anticoagulant_name . ' (' . $anticoag->event->event_date . ')' : ''; $this->inr = ($labResult) ? $labResult : 'None'; $this->save(); } @@ -138,4 +110,63 @@ public function isEditable() { return is_object($this->booking) && $this->booking->isEditable() && !$this->is_confirmed; } + + /** + * @param $patient + * @return mixed + */ + protected function recentBiometry($patient) + { + $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); + + return $biometry; + } + + /** + * @param $episode + * + * @return string + */ + protected function allergyString($episode) + { + $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')); + + return $allergyString; + } + + return $allergyString; + } + + /** + * @param $id + * + * @return mixed + */ + protected function operation($id) + { + $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(); + + return $operation; + } } diff --git a/protected/modules/OphTrOperationbooking/views/whiteboard/view.php b/protected/modules/OphTrOperationbooking/views/whiteboard/view.php index cd20eaa661..e6ba443c6c 100644 --- a/protected/modules/OphTrOperationbooking/views/whiteboard/view.php +++ b/protected/modules/OphTrOperationbooking/views/whiteboard/view.php @@ -90,7 +90,7 @@ alpha_blockers):?> Yes - alpha_blocker_name?> - No + No - alpha_blocker_name?> @@ -123,7 +123,7 @@ Yes - anticoagulant_name?>
INR: inr?> - No + No - anticoagulant_name?> From 6087d98141dcd6a747f25edfadfc5624171a85d8 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Tue, 27 Sep 2016 10:20:05 +0100 Subject: [PATCH 002/164] OE-6209: Changes to use any risk it can find in examination Will go back through the entire examination history looking simply for the most recent occurence of it being set to either yes or no. --- protected/models/Patient.php | 16 +++++ .../Element_OphCiExamination_HistoryRisk.php | 2 - .../OphTrOperationbooking_Whiteboard.php | 72 +++++++++++++++---- .../views/whiteboard/view.php | 14 +--- 4 files changed, 76 insertions(+), 28 deletions(-) diff --git a/protected/models/Patient.php b/protected/models/Patient.php index 0a15c81406..1a2592e4ff 100644 --- a/protected/models/Patient.php +++ b/protected/models/Patient.php @@ -1038,6 +1038,22 @@ public function hasRisk($riskCompare) return false; } + /** + * @param $riskCompare + * + * @return Risk|null + */ + public function getAssignedRisk($riskCompare) + { + foreach ($this->riskAssignments as $riskAssignment) { + if ($riskAssignment->risk->name === $riskCompare) { + return $riskAssignment; + } + } + + return null; + } + /** * marks the patient as having no family history. * diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php index 957af0a008..f6ecdf1ec8 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_HistoryRisk.php @@ -217,10 +217,8 @@ protected function mostRecentChecked($type, $id) $criteria = new \CDbCriteria(); $criteria->join = 'join event on t.event_id = event.id '; $criteria->join .= 'join episode on event.episode_id = episode.id '; - $criteria->join .= 'join patient on episode.patient_id = patient.id '; $criteria->addCondition($type . ' > 0'); $criteria->addCondition('episode.patient_id = :patient_id'); - $criteria->addCondition('event.event_date > patient.no_risks_date'); $criteria->params = array('patient_id' => $id); $criteria->order = 'event.event_date DESC'; $criteria->limit = 1; diff --git a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php index 75075e6deb..f938e74498 100644 --- a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php +++ b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php @@ -1,4 +1,5 @@ array(self::BELONGS_TO, 'Eye', 'eye_id'), - 'booking' => array(self::BELONGS_TO, 'Element_OphTrOperationbooking_Operation', '', 'on' => 't.event_id = booking.event_id', 'joinType' => 'INNER JOIN', 'alias' => 'booking'), + 'booking' => array( + self::BELONGS_TO, + 'Element_OphTrOperationbooking_Operation', + '', + 'on' => 't.event_id = booking.event_id', + 'joinType' => 'INNER JOIN', + 'alias' => 'booking', + ), ); } @@ -66,17 +74,11 @@ public function loadData($id) $episode = Episode::model()->findByPk($event->episode_id); $patient = Patient::model()->findByPk($episode->patient_id); $contact = Contact::model()->findByPk($patient->contact_id); - $biometry = $this->recentBiometry($patient); - - $risks = new \OEModule\OphCiExamination\models\Element_OphCiExamination_HistoryRisk(); - $blockers = $risks->mostRecentCheckedAlpha($patient->id); - $anticoag = $risks->mostRecentCheckedAnticoag($patient->id); - + $blockers = $this->alphaBlockerStatusAndDate($patient); + $anticoag = $this->anticoagsStatusAndDate($patient); $labResult = Element_OphInLabResults_Inr::model()->findPatientResultByType($patient->id, '1'); - $allergyString = $this->allergyString($episode); - $operation = $this->operation($id); $this->event_id = $id; @@ -85,18 +87,18 @@ public function loadData($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->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->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 = ($blockers) ? $blockers->alpha_blocker_name . ' (' . $blockers->event->event_date . ')' : ''; - $this->anticoagulant_name = ($anticoag) ? $anticoag->anticoagulant_name . ' (' . $anticoag->event->event_date . ')' : ''; + $this->alpha_blocker_name = $blockers; + $this->anticoagulant_name = $anticoag; $this->inr = ($labResult) ? $labResult : 'None'; $this->save(); } @@ -169,4 +171,44 @@ protected function operation($id) return $operation; } + + /** + * @param $patient + * + * @return string + */ + protected function alphaBlockerStatusAndDate($patient) + { + $risks = new \OEModule\OphCiExamination\models\Element_OphCiExamination_HistoryRisk(); + $blockers = $risks->mostRecentCheckedAlpha($patient->id); + if ($blockers) { + if ($blockers->alphablocker === '2') { + return 'No (' . $blockers->event->event_date . ')'; + } else { + return 'Yes - ' . $blockers->alpha_blocker_name . ' (' . $blockers->event->event_date . ')'; + } + } else { + return 'Not Checked'; + } + } + + /** + * @param $patient + * + * @return string + */ + protected function anticoagsStatusAndDate($patient) + { + $risks = new \OEModule\OphCiExamination\models\Element_OphCiExamination_HistoryRisk(); + $anticoag = $risks->mostRecentCheckedAnticoag($patient->id); + if ($anticoag) { + if ($anticoag->anticoagulant === '2') { + return 'No (' . $anticoag->event->event_date . ')'; + } else { + return 'Yes - ' . $anticoag->anticoagulant_name . ' (' . $anticoag->event->event_date . ')'; + } + } else { + return 'Not Checked'; + } + } } diff --git a/protected/modules/OphTrOperationbooking/views/whiteboard/view.php b/protected/modules/OphTrOperationbooking/views/whiteboard/view.php index e6ba443c6c..02031fc163 100644 --- a/protected/modules/OphTrOperationbooking/views/whiteboard/view.php +++ b/protected/modules/OphTrOperationbooking/views/whiteboard/view.php @@ -87,11 +87,7 @@

Alpha-blockers

- alpha_blockers):?> - Yes - alpha_blocker_name?> - - No - alpha_blocker_name?> - + alpha_blocker_name?>
@@ -119,12 +115,8 @@

Anticoagulants

- anticoagulants):?> - Yes - anticoagulant_name?>
- INR: inr?> - - No - anticoagulant_name?> - + anticoagulant_name?>
+ INR: inr?>
From b2ef6d40e21b8cfa5f0f301c5a44345772842fe1 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 28 Sep 2016 18:59:06 +0530 Subject: [PATCH 003/164] OE-5621 : Based on the new configuration 'enable_concise_med_history', frequency and dates configured --- protected/config/local.sample/common.php | 1 + ..._drop_medication_frequency_foreign_key.php | 24 +++++++++++++++++++ protected/models/Medication.php | 7 +++++- protected/views/medication/form.php | 8 ++++--- protected/views/medication/list.php | 2 +- 5 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php diff --git a/protected/config/local.sample/common.php b/protected/config/local.sample/common.php index 09d1c55876..1a69c17793 100644 --- a/protected/config/local.sample/common.php +++ b/protected/config/local.sample/common.php @@ -137,6 +137,7 @@ 'event_print_method' => 'pdf', 'wkhtmltopdf_nice_level' => 19, 'city_road_satellite_view' => 1, + 'enable_concise_med_history' => true, // default start time used for automatic worklist definitions //'worklist_default_start_time' => 'H:i', // default end time used for automatic worklist definitions diff --git a/protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php b/protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php new file mode 100644 index 0000000000..15500d0614 --- /dev/null +++ b/protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php @@ -0,0 +1,24 @@ +params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) + { + $this->alterColumn('medication', 'frequency_id', 'int(10) unsigned DEFAULT NULL'); + } + } + + public function down() + { + if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) + { + $this->alterColumn('medication', 'frequency_id', 'int(10) unsigned NOT NULL'); + } + } + +} \ No newline at end of file diff --git a/protected/models/Medication.php b/protected/models/Medication.php index abeb531d5e..1dd036098a 100644 --- a/protected/models/Medication.php +++ b/protected/models/Medication.php @@ -48,9 +48,14 @@ public function tableName() */ public function rules() { + $required_fields = 'route_id, start_date'; + if (!isset(Yii::app()->params['enable_concise_med_history']) || !Yii::app()->params['enable_concise_med_history']) + { + $required_fields .= ', frequency_id'; + } return array( array('medication_drug_id, drug_id, route_id, option_id, dose, frequency_id, start_date, end_date, stop_reason_id, prescription_item_id', 'safe'), - array('route_id, frequency_id, start_date', 'required'), + array($required_fields, 'required'), array('start_date', 'OEFuzzyDateValidatorNotFuture'), array('end_date', 'OEFuzzyDateValidator'), array('option_id', 'validateOptionId'), diff --git a/protected/views/medication/form.php b/protected/views/medication/form.php index 66b9ab8096..17091b655a 100644 --- a/protected/views/medication/form.php +++ b/protected/views/medication/form.php @@ -77,7 +77,7 @@ widget('application.widgets.DropDownList', array('element' => $medication, 'field' => 'frequency_id', 'data' => 'DrugFrequency', 'htmlOptions' => array('name' => 'frequency_id', 'empty' => '- Select -'))); ?> - renderPartial('/patient/_fuzzy_date', array('form' => $form, 'date' => $medication->start_date, 'class' => 'medication_start_date', 'label' => 'Date from')); ?> + renderPartial('/patient/_fuzzy_date', array('form' => $form, 'date' => $medication->start_date ? $medication->start_date : isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history'] ? date('Y-m-d') : null, 'class' => 'medication_start_date', 'label' => 'Date from')); ?>
@@ -88,7 +88,9 @@ class="inline">end_date, array(' - + params['enable_concise_med_history']) || !Yii::app()->params['enable_concise_med_history']) { ?> + +
@@ -96,7 +98,7 @@ class="inline">end_date, array('v renderPartial('/patient/_fuzzy_date', array('form' => $form, 'date' => $medication->end_date, 'class' => 'medication_end_date', 'label' => 'Date to')); + $this->renderPartial('/patient/_fuzzy_date', array('form' => $form, 'date' => $medication->end_date ? $medication->end_date : isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history'] ? date('Y-m-d') : null , 'class' => 'medication_end_date', 'label' => 'Date to')); $this->renderPartial('stop_reason', array('form' => $form, 'medication' => $medication)); ?> diff --git a/protected/views/medication/list.php b/protected/views/medication/list.php index f06d6ad633..77c4355e68 100644 --- a/protected/views/medication/list.php +++ b/protected/views/medication/list.php @@ -24,7 +24,7 @@ Administration - dose ?> route->name ?> option ? "({$medication->option->name})" : '' ?> frequency->name ?> + dose ?> route->name ?> option ? "({$medication->option->name})" : '' ?> frequency->name) ? $medication->frequency->name : '' ?> Date From 36b67089b61baa15544bce189bdd424553887752 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 3 Oct 2016 15:02:44 +0100 Subject: [PATCH 004/164] OE-6215: Fixes time based ordering Time ordering for injections was relying on created_date, or worse, the PK to designate when they happened, instead of the event_date. Switched to use correct date and tidied up some code. --- protected/components/Helper.php | 2 +- ...mination_Episode_MedicalRetinalHistory.php | 10 +- .../OphTrIntravitrealinjection_API.php | 99 +++-- .../controllers/DefaultController.php | 4 +- ...Intravitrealinjection_Treatment_fields.php | 368 ++++++++++-------- 5 files changed, 264 insertions(+), 219 deletions(-) diff --git a/protected/components/Helper.php b/protected/components/Helper.php index 5e56b8047d..382b300b68 100644 --- a/protected/components/Helper.php +++ b/protected/components/Helper.php @@ -123,7 +123,7 @@ public static function convertDate2HTML($value, $empty_string = '-') * * @param string $value * - * @return float + * @return int */ public static function mysqlDate2JsTimestamp($value) { diff --git a/protected/modules/OphCiExamination/widgets/OphCiExamination_Episode_MedicalRetinalHistory.php b/protected/modules/OphCiExamination/widgets/OphCiExamination_Episode_MedicalRetinalHistory.php index 8d4c564c26..425c9393e0 100644 --- a/protected/modules/OphCiExamination/widgets/OphCiExamination_Episode_MedicalRetinalHistory.php +++ b/protected/modules/OphCiExamination/widgets/OphCiExamination_Episode_MedicalRetinalHistory.php @@ -85,9 +85,9 @@ public function addData(\FlotChart $chart) } /** - * @param \FlotChart $chart - * @param Element_OphCiExamination_OCT $oct - * @param string $side + * @param \FlotChart $chart + * @param models\Element_OphCiExamination_OCT $oct + * @param string $side */ protected function addSftReading(\FlotChart $chart, models\Element_OphCiExamination_OCT $oct, $side) { @@ -114,10 +114,10 @@ protected function addInjection(\FlotChart $chart, $va_axis, array $injection, $ $this->injections[$timestamp][$side] = $drug; - if ($side == 'right' && (!$injMin || $timestamp < $injMin)) { + if ($side === 'right' && (!$injMin || $timestamp < $injMin)) { $injMin = $timestamp; } - if ($side == 'left' && (!$injMax || $timestamp > $injMax)) { + if ($side === 'left' && (!$injMax || $timestamp > $injMax)) { $injMax = $timestamp; } } diff --git a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php index 7308a5fcef..366a36492b 100644 --- a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php +++ b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php @@ -71,37 +71,63 @@ public function previousInjectionsByEvent($event_id, $side, $drug) $event = Event::model()->find('id = :id', array(':id' => $event_id)); $episode = $event->episode; $patient = $event->episode->patient; - $injections = $this->previousInjections($patient, $episode, $side, $drug); - //remove this event and events in the future - $previousInjections = array(); - foreach ($injections as $injection) { - if ($event_id > $injection['event_id']) { - $previousInjections[] = $injection; - } - } - - return $previousInjections; + return $this->previousInjections($patient, $episode, $side, $drug, $event->event_date); } /** * return the set of treatment elements from previous injection events in descending order. * - * @param Patient $patient - * @param Episode $episode - * @param string $side - * @param Drug $drug + * @param Patient $patient + * @param Episode $episode + * @param string $side + * @param OphTrIntravitrealinjection_Treatment_Drug $drug + * @param string $since * * @throws Exception * * @return array {$side . '_drug_id' => integer, $side . '_number' => integer, 'date' => datetime}[] - array of treatment elements for the eye and optional drug */ - public function previousInjections($patient, $episode, $side, $drug = null) + public function previousInjections($patient, $episode, $side, $drug = null, $since = 'now') { $res = array(); + $injections = $this->injectionsSinceByEpisodeSideAndDrug($episode, $side, $drug, $since); + + foreach ($injections as $injection) { + $res[] = array( + $side.'_drug_id' => $injection->{$side.'_drug_id'}, + $side.'_drug' => $injection->{$side.'_drug'}->name, + $side.'_number' => $injection->{$side.'_number'}, + 'date' => $injection->event->event_date, + 'event_id' => $injection->event_id, + ); + } + + // NOTE: we assume that all legacy injections would be from before any injections in + // this module. Should this prove not to be the case, we would need to sort the result + // data structure by date + if ($legacy_api = $this->getLegacyAPI()) { + foreach ($legacy_api->previousInjections($patient, $episode, $side, $drug) as $legacy) { + $res[] = $legacy; + } + } + + return $res; + } - $previous = $this->previousInjectionsForPatientEpisode($patient, $episode); + /** + * @param Episode $episode + * @param string $side + * @param OphTrIntravitrealinjection_Treatment_Drug $drug + * @param string $since + * + * @return mixed + * + * @throws Exception + */ + protected function injectionsSinceByEpisodeSideAndDrug(Episode $episode, $side, OphTrIntravitrealinjection_Treatment_Drug $drug, $since = 'now') + { switch ($side) { case 'left': $eye_ids = array(SplitEventTypeElement::LEFT, SplitEventTypeElement::BOTH); @@ -114,30 +140,27 @@ public function previousInjections($patient, $episode, $side, $drug = null) break; } - foreach ($previous as $prev) { - if (in_array($prev->eye_id, $eye_ids)) { - if ($drug == null || $prev->{$side.'_drug_id'} == $drug->id) { - $res[] = array( - $side.'_drug_id' => $prev->{$side.'_drug_id'}, - $side.'_drug' => $prev->{$side.'_drug'}->name, - $side.'_number' => $prev->{$side.'_number'}, - 'date' => $prev->created_date, - 'event_id' => $prev->event_id, - ); - } - } - } + $sinceDate = new DateTime($since); - // NOTE: we assume that all legacy injections would be from before any injections in - // this module. Should this prove not to be the case, we would need to sort the result - // data structure by date - if ($legacy_api = $this->getLegacyAPI()) { - foreach ($legacy_api->previousInjections($patient, $episode, $side, $drug) as $legacy) { - $res[] = $legacy; - } + $criteria = new CDbCriteria(); + $criteria->alias = 'treatment'; + $criteria->addCondition('event.episode_id = :episode_id'); + $criteria->addCondition('treatment.eye_id in (:eye_ids)'); + $criteria->addCondition('event_date < :since'); + $criteria->join = 'JOIN event ON treatment.event_id = event.id'; + $criteria->order = 'event.event_date ASC'; + $criteria->params = array( + 'episode_id' => $episode->id, + 'eye_ids' => implode(',', $eye_ids), + 'since' => $sinceDate->format('Y-m-d'), + ); + + if ($drug->id) { + $criteria->addCondition('treatment.' . $side . '_drug_id = :drug_id'); + $criteria->params['drug_id'] = $drug->id; } - return $res; + return Element_OphTrIntravitrealinjection_Treatment::model()->findAll($criteria); } /** @@ -151,7 +174,7 @@ public function previousInjections($patient, $episode, $side, $drug = null) */ protected function getPreviousTreatmentForSide($patient, $episode, $side) { - $checker = ($side == 'left') ? 'hasLeft' : 'hasRight'; + $checker = ($side === 'left') ? 'hasLeft' : 'hasRight'; $treatment = $this->getElementForLatestEventInEpisode($episode, 'Element_OphTrIntravitrealinjection_Treatment'); if ($treatment && $treatment->$checker()) { return $treatment; diff --git a/protected/modules/OphTrIntravitrealinjection/controllers/DefaultController.php b/protected/modules/OphTrIntravitrealinjection/controllers/DefaultController.php index df88b2d5e7..8e7cbdae8a 100644 --- a/protected/modules/OphTrIntravitrealinjection/controllers/DefaultController.php +++ b/protected/modules/OphTrIntravitrealinjection/controllers/DefaultController.php @@ -155,7 +155,7 @@ protected function setElementOptions($action) $element->eye_id = $default_eye; } - if (get_class($element) == 'Element_OphTrIntravitrealinjection_Treatment') { + if (get_class($element) === 'Element_OphTrIntravitrealinjection_Treatment') { if ($therapy_api) { // get the latest drug that has been applied for and set it as default (for the appropriate eye) if ($default_left_drug) { @@ -176,7 +176,7 @@ protected function setElementOptions($action) $element->left_injection_given_by_id = Yii::app()->user->id; $element->right_injection_given_by_id = Yii::app()->user->id; } - if (get_class($element) == 'Element_OphTrIntravitrealinjection_Site') { + if (get_class($element) === 'Element_OphTrIntravitrealinjection_Site') { $element->site_id = $this->selectedSiteId; } } diff --git a/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php b/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php index 9d1ed722d7..21b5be47e7 100644 --- a/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php +++ b/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php @@ -19,188 +19,206 @@ ?> with('allergies')->activeOrPk($element->{$side.'_pre_antisept_drug_id'})->findAll(); - $antiseptic_drugs_opts = array( - 'empty' => '- Please select -', - 'nowrapper' => true, - 'options' => array(), - ); - $antiseptic_allergic = false; - foreach ($antiseptic_drugs as $drug) { - $opts = array(); - foreach ($drug->allergies as $allergy) { - if ($this->patient->hasAllergy($allergy)) { - $opts['data-allergic'] = 1; - if ($drug->id == $element->{$side.'_pre_antisept_drug_id'}) { - $antiseptic_allergic = true; - } +$antiseptic_drugs = OphTrIntravitrealinjection_AntiSepticDrug::model()->with('allergies')->activeOrPk($element->{$side . '_pre_antisept_drug_id'})->findAll(); +$antiseptic_drugs_opts = array( + 'empty' => '- Please select -', + 'nowrapper' => true, + 'options' => array(), +); +$antiseptic_allergic = false; +foreach ($antiseptic_drugs as $drug) { + $opts = array(); + foreach ($drug->allergies as $allergy) { + if ($this->patient->hasAllergy($allergy)) { + $opts['data-allergic'] = 1; + if ($drug->id == $element->{$side . '_pre_antisept_drug_id'}) { + $antiseptic_allergic = true; } } - $antiseptic_drugs_opts['options'][(string) $drug->id] = $opts; } - $skin_drugs = OphTrIntravitrealinjection_SkinDrug::model()->with('allergies')->activeOrPk($element->{$side.'_pre_skin_drug_id'})->findAll(); - $skin_drugs_opts = array('empty' => '- Please select -', 'nowrapper' => true, 'options' => array()); - $skin_allergic = false; - foreach ($skin_drugs as $drug) { - $opts = array(); - foreach ($drug->allergies as $allergy) { - if ($this->patient->hasAllergy($allergy)) { - $opts['data-allergic'] = 1; - if ($drug->id == $element->{$side.'_pre_skin_drug_id'}) { - $skin_allergic = true; - } + $antiseptic_drugs_opts['options'][(string)$drug->id] = $opts; +} +$skin_drugs = OphTrIntravitrealinjection_SkinDrug::model()->with('allergies')->activeOrPk($element->{$side . '_pre_skin_drug_id'})->findAll(); +$skin_drugs_opts = array('empty' => '- Please select -', 'nowrapper' => true, 'options' => array()); +$skin_allergic = false; +foreach ($skin_drugs as $drug) { + $opts = array(); + foreach ($drug->allergies as $allergy) { + if ($this->patient->hasAllergy($allergy)) { + $opts['data-allergic'] = 1; + if ($drug->id == $element->{$side . '_pre_skin_drug_id'}) { + $skin_allergic = true; } } - $skin_drugs_opts['options'][(string) $drug->id] = $opts; } + $skin_drugs_opts['options'][(string)$drug->id] = $opts; +} ?> -
-
- -
-
-
- dropDownList($element, $side.'_pre_antisept_drug_id', CHtml::listData($antiseptic_drugs, 'id', 'name'), $antiseptic_drugs_opts); +
+
+ +
+
+
+ dropDownList($element, $side . '_pre_antisept_drug_id', CHtml::listData($antiseptic_drugs, 'id', 'name'), $antiseptic_drugs_opts); ?> -
-
+
+
-
-
- -
-
-
- dropDownList($element, $side.'_pre_skin_drug_id', CHtml::listData($skin_drugs, 'id', 'name'), $skin_drugs_opts); +
+
+ +
+
+
+ dropDownList($element, $side . '_pre_skin_drug_id', CHtml::listData($skin_drugs, 'id', 'name'), $skin_drugs_opts); ?> -
-
+
+
checkbox($element, $side.'_pre_ioplowering_required'); +echo $form->checkbox($element, $side . '_pre_ioplowering_required'); ?> { $side.'_pre_ioplowering_required'}; +$show = $element->{$side . '_pre_ioplowering_required'}; if (isset($_POST[get_class($element)])) { - $show = $_POST[get_class($element)][$side.'_pre_ioplowering_required']; + $show = $_POST[get_class($element)][$side . '_pre_ioplowering_required']; } ?> array(), - 'empty' => '- Please select -', - 'div_id' => 'div_'.get_class($element).'_'.$side.'_pre_ioploweringdrugs', - 'label' => $element->getAttributeLabel($side.'_pre_ioploweringdrugs'), - 'div_class' => $div_class, ); - $ioplowering_drugs = OphTrIntravitrealinjection_IOPLoweringDrug::model()->activeOrPk($element->iopLoweringDrugValues)->findAll(array('order' => 'display_order asc')); - foreach ($ioplowering_drugs as $drug) { - $html_options['options'][(string) $drug->id] = array('data-order' => $drug->display_order); - } - echo $form->multiSelectList($element, get_class($element).'['.$side.'_pre_ioploweringdrugs]', $side.'_pre_ioploweringdrugs', 'id', CHtml::listData($ioplowering_drugs, 'id', 'name'), array(), $html_options, false, false, null, false, false, array('field' => 6)); +$div_class = 'eventDetail'; +if (!$show) { + $div_class .= ' hidden'; +} - $drugs = OphTrIntravitrealinjection_Treatment_Drug::model()->activeOrPk($element->{$side.'_drug_id'})->findAll(); +$html_options = array( + 'options' => array(), + 'empty' => '- Please select -', + 'div_id' => 'div_' . get_class($element) . '_' . $side . '_pre_ioploweringdrugs', + 'label' => $element->getAttributeLabel($side . '_pre_ioploweringdrugs'), + 'div_class' => $div_class, +); +$ioplowering_drugs = OphTrIntravitrealinjection_IOPLoweringDrug::model()->activeOrPk($element->iopLoweringDrugValues)->findAll(array('order' => 'display_order asc')); +foreach ($ioplowering_drugs as $drug) { + $html_options['options'][(string)$drug->id] = array('data-order' => $drug->display_order); +} - $html_options = array( - 'empty' => '- Please select -', - 'options' => array(), - ); - // get the previous injection counts for each of the drug options for this eye - $drug_history = array(); +echo $form->multiSelectList( + $element, + get_class($element) . '[' . $side . '_pre_ioploweringdrugs]', $side . '_pre_ioploweringdrugs', + 'id', + CHtml::listData($ioplowering_drugs, 'id', 'name'), + array(), + $html_options, + false, + false, + null, + false, + false, + array('field' => 6) +); - foreach ($drugs as $drug) { - if ($element->event_id) { - $previous = $injection_api->previousInjectionsByEvent($element->event_id, $side, $drug); - } else { - $previous = $injection_api->previousInjections($this->patient, $episode, $side, $drug); - } - $count = 0; - if (sizeof($previous)) { - $count = $previous[0][$side.'_number']; - } - $drug_history[$drug->id] = array_reverse($previous); +$drugs = OphTrIntravitrealinjection_Treatment_Drug::model()->activeOrPk($element->{$side . '_drug_id'})->findAll(); - $html_options['options'][$drug->id] = array( - 'data-previous' => $count, - ); +$html_options = array( + 'empty' => '- Please select -', + 'options' => array(), +); +// get the previous injection counts for each of the drug options for this eye +$drug_history = array(); - // if this is an edit, we want to know what the original count was so that we don't replace it - if ($element->{$side.'_drug_id'} && $element->{$side.'_drug_id'} == $drug->id) { - $html_options['options'][$drug->id]['data-original-count'] = $element->{$side.'_number'}; - } +foreach ($drugs as $drug) { + if ($element->event_id) { + $previous = $injection_api->previousInjectionsByEvent($element->event_id, $side, $drug); + } else { + $previous = $injection_api->previousInjections($this->patient, $episode, $side, $drug); + var_dump($previous); + } + $count = 0; + if (count($previous)) { + $count = $previous[0][$side . '_number']; } + $drug_history[$drug->id] = array_reverse($previous); - echo $form->dropDownList($element, $side.'_drug_id', CHtml::listData($drugs, 'id', 'name'), $html_options, false, array('field' => 6)); + $html_options['options'][$drug->id] = array( + 'data-previous' => $count, + ); - $selected_drug = null; - if (@$_POST['Element_OphTrIntravitrealinjection_Treatment']) { - $selected_drug = $_POST['Element_OphTrIntravitrealinjection_Treatment'][$side.'_drug_id']; - } else { - $selected_drug = $element->{$side.'_drug_id'}; + // if this is an edit, we want to know what the original count was so that we don't replace it + if ($element->{$side . '_drug_id'} && $element->{$side . '_drug_id'} == $drug->id) { + $html_options['options'][$drug->id]['data-original-count'] = $element->{$side . '_number'}; } +} + +echo $form->dropDownList($element, $side . '_drug_id', CHtml::listData($drugs, 'id', 'name'), $html_options, false, array('field' => 6)); + +$selected_drug = null; +if (@$_POST['Element_OphTrIntravitrealinjection_Treatment']) { + $selected_drug = $_POST['Element_OphTrIntravitrealinjection_Treatment'][$side . '_drug_id']; +} else { + $selected_drug = $element->{$side . '_drug_id'}; +} ?> -
-
- -
-
-
-
- textField($element, $side.'_number', array('size' => '10', 'nowrapper' => true))?> -
-
- - +
+
+ +
+
+
+
+ textField($element, $side . '_number', array('size' => '10', 'nowrapper' => true)) ?> +
+
+ + - '; - }?> -
-
-
-
+ } ?> +
+
+
+
-textField($element, $side.'_batch_number', array(), array(), array('field' => 6))?> +textField($element, $side . '_batch_number', array(), array(), array('field' => 6)) ?> getIsNewRecord()) { @@ -210,38 +228,40 @@ class="row field-row"> } ?> -datePicker($element, $side.'_batch_expiry_date', $expiry_date_params, array(), array( +datePicker($element, $side . '_batch_expiry_date', $expiry_date_params, array(), array( 'label' => $form->layoutColumns['label'], 'field' => 3, -))?> +)) ?> -dropDownList($element, $side.'_injection_given_by_id', CHtml::listData(OphTrIntravitrealinjection_InjectionUser::model()->getUsers(), 'id', 'ReversedFullNameAndUserName'), array('empty' => '- Please select -'), false, array('field' => 6))?> +dropDownList($element, $side . '_injection_given_by_id', + CHtml::listData(OphTrIntravitrealinjection_InjectionUser::model()->getUsers(), 'id', 'ReversedFullNameAndUserName'), array('empty' => '- Please select -'), false, + array('field' => 6)) ?> -
-
- -
-
- {$side.'_injection_time'} != null) { - $val = date('H:i', strtotime($element->{$side.'_injection_time'})); - } else { - $val = date('H:i'); - } +
+
+ +
+
+ {$side . '_injection_time'} != null) { + $val = date('H:i', strtotime($element->{$side . '_injection_time'})); + } else { + $val = date('H:i'); + } - if (isset($_POST[get_class($element)])) { - $val = $_POST[get_class($element)][$side.'_injection_time']; - } - echo CHtml::textField(get_class($element).'['.$side.'_injection_time]', $val, array('autocomplete' => Yii::app()->params['html_autocomplete'])); + if (isset($_POST[get_class($element)])) { + $val = $_POST[get_class($element)][$side . '_injection_time']; + } + echo CHtml::textField(get_class($element) . '[' . $side . '_injection_time]', $val, array('autocomplete' => Yii::app()->params['html_autocomplete'])); ?> -
+
checkbox($element, $side.'_post_ioplowering_required'); +echo $form->checkbox($element, $side . '_post_ioplowering_required'); ?>
-*/?> +*/ ?> { $side.'_post_ioplowering_required'}; +$div_class = 'eventDetail'; +$show = $element->{$side . '_post_ioplowering_required'}; - if (isset($_POST[get_class($element)])) { - $show = $_POST[get_class($element)][$side.'_post_ioplowering_required']; - } +if (isset($_POST[get_class($element)])) { + $show = $_POST[get_class($element)][$side . '_post_ioplowering_required']; +} - if (!$show) { - $div_class .= ' hidden'; - } +if (!$show) { + $div_class .= ' hidden'; +} - $html_options = array( - 'options' => array(), - 'empty' => '- Please select -', - 'div_id' => 'div_'.get_class($element).'_'.$side.'_post_ioploweringdrugs', - 'label' => $element->getAttributeLabel($side.'_post_ioploweringdrugs'), - 'div_class' => $div_class, ); - $ioplowering_drugs = OphTrIntravitrealinjection_IOPLoweringDrug::model()->activeOrPk($element->iopLoweringDrugValues)->findAll(array('order' => 'display_order asc')); - foreach ($ioplowering_drugs as $drug) { - $html_options['options'][(string) $drug->id] = array('data-order' => $drug->display_order); - } - echo $form->multiSelectList($element, get_class($element).'['.$side.'_post_ioploweringdrugs]', $side.'_post_ioploweringdrugs', 'id', CHtml::listData($ioplowering_drugs, 'id', 'name'), array(), $html_options, false, false, null, false, false, array('field' => 6)); +$html_options = array( + 'options' => array(), + 'empty' => '- Please select -', + 'div_id' => 'div_' . get_class($element) . '_' . $side . '_post_ioploweringdrugs', + 'label' => $element->getAttributeLabel($side . '_post_ioploweringdrugs'), + 'div_class' => $div_class, +); +$ioplowering_drugs = OphTrIntravitrealinjection_IOPLoweringDrug::model()->activeOrPk($element->iopLoweringDrugValues)->findAll(array('order' => 'display_order asc')); +foreach ($ioplowering_drugs as $drug) { + $html_options['options'][(string)$drug->id] = array('data-order' => $drug->display_order); +} +echo $form->multiSelectList($element, get_class($element) . '[' . $side . '_post_ioploweringdrugs]', $side . '_post_ioploweringdrugs', 'id', + CHtml::listData($ioplowering_drugs, 'id', 'name'), array(), $html_options, false, false, null, false, false, array('field' => 6)); ?> From a5420c08eb52f0ae5468b3db5dc13740a38144f1 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 3 Oct 2016 16:25:32 +0100 Subject: [PATCH 005/164] OE-6215: removes var_dump. --- .../form_Element_OphTrIntravitrealinjection_Treatment_fields.php | 1 - 1 file changed, 1 deletion(-) diff --git a/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php b/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php index 21b5be47e7..10015bc4e1 100644 --- a/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php +++ b/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php @@ -146,7 +146,6 @@ class="row field-row"> $previous = $injection_api->previousInjectionsByEvent($element->event_id, $side, $drug); } else { $previous = $injection_api->previousInjections($this->patient, $episode, $side, $drug); - var_dump($previous); } $count = 0; if (count($previous)) { From 3fd3a8a103bf546c39f5c706e975337562f798c3 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 3 Oct 2016 16:47:07 +0100 Subject: [PATCH 006/164] OE-6215: Fixes the ordering of legacy events. If all legacy events happened before the actual events as the comment suggests they need to be in the array before not after. --- .../OphTrIntravitrealinjection_API.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php index 366a36492b..c3216f6ee7 100644 --- a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php +++ b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php @@ -91,6 +91,15 @@ public function previousInjectionsByEvent($event_id, $side, $drug) public function previousInjections($patient, $episode, $side, $drug = null, $since = 'now') { $res = array(); + // NOTE: we assume that all legacy injections would be from before any injections in + // this module. Should this prove not to be the case, we would need to sort the result + // data structure by date + if ($legacy_api = $this->getLegacyAPI()) { + foreach ($legacy_api->previousInjections($patient, $episode, $side, $drug) as $legacy) { + $res[] = $legacy; + } + } + $injections = $this->injectionsSinceByEpisodeSideAndDrug($episode, $side, $drug, $since); foreach ($injections as $injection) { @@ -103,15 +112,6 @@ public function previousInjections($patient, $episode, $side, $drug = null, $sin ); } - // NOTE: we assume that all legacy injections would be from before any injections in - // this module. Should this prove not to be the case, we would need to sort the result - // data structure by date - if ($legacy_api = $this->getLegacyAPI()) { - foreach ($legacy_api->previousInjections($patient, $episode, $side, $drug) as $legacy) { - $res[] = $legacy; - } - } - return $res; } From 58e6200383fc618bf5acf4de09ee7c416483fd0a Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 3 Oct 2016 16:51:35 +0100 Subject: [PATCH 007/164] OE-6215: Removes function that is no longer called --- .../OphTrIntravitrealinjection_API.php | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php index c3216f6ee7..1effd73d40 100644 --- a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php +++ b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php @@ -18,7 +18,7 @@ */ class OphTrIntravitrealinjection_API extends BaseAPI { - private $previous_treatments = array(); + private $legacy_api; /** @@ -35,34 +35,6 @@ protected function getLegacyAPI() return $this->legacy_api; } - /** - * caching method for previous injections store. - * - * @param Patient $patient - * @param Episode $episode - * - * @return Element_OphTrIntravitrealinjection_Treatment[] - */ - protected function previousInjectionsForPatientEpisode($patient, $episode) - { - if (!isset($this->previous_treatments[$patient->id])) { - $this->previous_treatments[$patient->id] = array(); - } - - if (!isset($this->previous_treatments[$patient->id][$episode->id])) { - $events = $this->getEventsInEpisode($patient, $episode); - $previous = array(); - foreach ($events as $event) { - if ($treat = Element_OphTrIntravitrealinjection_Treatment::model()->find('event_id = :event_id', array(':event_id' => $event->id))) { - $previous[] = $treat; - } - } - $this->previous_treatments[$patient->id][$episode->id] = $previous; - } - - return $this->previous_treatments[$patient->id][$episode->id]; - } - /** * return only previous injections given a starting event id. */ From a26b04a9e9139bcf7a6f0d5e833fb531142776eb Mon Sep 17 00:00:00 2001 From: Prasath Kumar Sagadevan Date: Tue, 4 Oct 2016 12:12:48 +0530 Subject: [PATCH 008/164] OE-6214 Change refraction type "Own Glasses" to "Focimetry" --- .../m161004_063341_alter_refraction_type.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php diff --git a/protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php b/protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php new file mode 100644 index 0000000000..a4266a4a28 --- /dev/null +++ b/protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php @@ -0,0 +1,25 @@ +update('ophciexamination_refraction_type', array('name' => 'Focimetry'), 'name = "Own Glasses"'); + } + + public function down() + { + return true; + } + + /* + // Use safeUp/safeDown to do migration with transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} \ No newline at end of file From 76a221c588a1d49a5d5dd6fa11a87015880a8937 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Tue, 4 Oct 2016 12:53:12 +0530 Subject: [PATCH 009/164] OE-5621 : Fixed code review comments. --- ..._drop_medication_frequency_foreign_key.php | 10 +--- protected/views/medication/form.php | 59 ++++++++++++++++--- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php b/protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php index 15500d0614..98d8175bdd 100644 --- a/protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php +++ b/protected/migrations/m160928_073106_drop_medication_frequency_foreign_key.php @@ -7,18 +7,12 @@ class m160928_073106_drop_medication_frequency_foreign_key extends CDbMigration { public function up() { - if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) - { - $this->alterColumn('medication', 'frequency_id', 'int(10) unsigned DEFAULT NULL'); - } + $this->alterColumn('medication', 'frequency_id', 'int(10) unsigned DEFAULT NULL'); } public function down() { - if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) - { - $this->alterColumn('medication', 'frequency_id', 'int(10) unsigned NOT NULL'); - } + $this->alterColumn('medication', 'frequency_id', 'int(10) unsigned NOT NULL'); } } \ No newline at end of file diff --git a/protected/views/medication/form.php b/protected/views/medication/form.php index 17091b655a..d880c0bb4d 100644 --- a/protected/views/medication/form.php +++ b/protected/views/medication/form.php @@ -36,7 +36,12 @@ id="medication_drug_name">getDrugLabel()) ?>
- listBySubspecialtyWithCommonMedications($firm->getSubspecialtyID()), array('empty' => '- Select -')) ?> + listBySubspecialtyWithCommonMedications($firm->getSubspecialtyID()), + array('empty' => '- Select -') + ) ?>
@@ -66,7 +71,15 @@ widget('application.widgets.TextField', array('element' => $medication, 'field' => 'dose', 'name' => 'dose')); ?> - widget('application.widgets.DropDownList', array('element' => $medication, 'field' => 'route_id', 'data' => 'DrugRoute', 'htmlOptions' => array('name' => 'route_id', 'empty' => '- Select -'))); ?> + widget( + 'application.widgets.DropDownList', + array( + 'element' => $medication, + 'field' => 'route_id', + 'data' => 'DrugRoute', + 'htmlOptions' => array('name' => 'route_id', 'empty' => '- Select -') + ) + ); ?>
route) { @@ -74,10 +87,31 @@ } ?>
- widget('application.widgets.DropDownList', array('element' => $medication, 'field' => 'frequency_id', 'data' => 'DrugFrequency', 'htmlOptions' => array('name' => 'frequency_id', 'empty' => '- Select -'))); ?> + widget( + 'application.widgets.DropDownList', + array( + 'element' => $medication, + 'field' => 'frequency_id', + 'data' => 'DrugFrequency', + 'htmlOptions' => array('name' => 'frequency_id', 'empty' => '- Select -') + ) + ); ?> - renderPartial('/patient/_fuzzy_date', array('form' => $form, 'date' => $medication->start_date ? $medication->start_date : isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history'] ? date('Y-m-d') : null, 'class' => 'medication_start_date', 'label' => 'Date from')); ?> + start_date ?: ''; + $medication_start_date = (array_key_exists('enable_concise_med_history', Yii::app()->params) + && Yii::app()->params['enable_concise_med_history'] + && !$medication_start_date) ? date('Y-m-d') : null; + $this->renderPartial( + '/patient/_fuzzy_date', + array( + 'form' => $form, + 'date' => $medication_start_date, + 'class' => 'medication_start_date', + 'label' => 'Date from' + ) + ); ?>
@@ -88,7 +122,7 @@ class="inline">end_date, array(' - params['enable_concise_med_history']) || !Yii::app()->params['enable_concise_med_history']) { ?> + params) || !Yii::app()->params['enable_concise_med_history']) { ?>
@@ -97,8 +131,19 @@ class="inline">end_date, array('v
renderPartial('/patient/_fuzzy_date', array('form' => $form, 'date' => $medication->end_date ? $medication->end_date : isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history'] ? date('Y-m-d') : null , 'class' => 'medication_end_date', 'label' => 'Date to')); + $medication_end_date = $medication->end_date ?: ''; + $medication_end_date = (array_key_exists('enable_concise_med_history', Yii::app()->params) + && Yii::app()->params['enable_concise_med_history'] + && !$medication_end_date) ? date('Y-m-d') : null; + $this->renderPartial( + '/patient/_fuzzy_date', + array( + 'form' => $form, + 'date' => $medication_end_date, + 'class' => 'medication_end_date', + 'label' => 'Date to' + ) + ); $this->renderPartial('stop_reason', array('form' => $form, 'medication' => $medication)); ?> From 10088d2037aa22ebe73bb8a4ef8e53bc8309e92a Mon Sep 17 00:00:00 2001 From: Sabi Date: Tue, 4 Oct 2016 10:27:47 +0100 Subject: [PATCH 010/164] OE-6231 : Removing unnecessary 'currentPage' as Yii handles it automatically --- protected/models/Patient.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/protected/models/Patient.php b/protected/models/Patient.php index 0a15c81406..9cb580b6c6 100644 --- a/protected/models/Patient.php +++ b/protected/models/Patient.php @@ -211,7 +211,6 @@ public function search($params = array()) { $params += array( 'pageSize' => 20, - 'currentPage' => 0, 'sortBy' => 'hos_num*1', 'sortDir' => 'asc', ); @@ -238,7 +237,7 @@ public function search($params = array()) $dataProvider = new CActiveDataProvider(get_class($this), array( 'criteria' => $criteria, - 'pagination' => array('pageSize' => $params['pageSize'], 'currentPage' => $params['currentPage']), + 'pagination' => array('pageSize' => $params['pageSize']), )); return $dataProvider; From 7655440e69d7062bc6702220623512ce87a8eebf Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Tue, 4 Oct 2016 15:11:43 +0530 Subject: [PATCH 011/164] OE-5621 : Changed the medications ternary operations for the medication date. Also, added null to the widget --- protected/views/medication/form.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/protected/views/medication/form.php b/protected/views/medication/form.php index d880c0bb4d..7eb07dc36e 100644 --- a/protected/views/medication/form.php +++ b/protected/views/medication/form.php @@ -99,10 +99,13 @@ start_date ?: ''; - $medication_start_date = (array_key_exists('enable_concise_med_history', Yii::app()->params) - && Yii::app()->params['enable_concise_med_history'] - && !$medication_start_date) ? date('Y-m-d') : null; + $medication_start_date = null; + if ($medication->start_date) { + $medication_start_date = $medication->start_date; + } + else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) { + $medication_start_date = date('Y-m-d'); + } $this->renderPartial( '/patient/_fuzzy_date', array( @@ -122,7 +125,7 @@ class="inline">end_date, array(' - params) || !Yii::app()->params['enable_concise_med_history']) { ?> + params['enable_concise_med_history'] || !Yii::app()->params['enable_concise_med_history']) { ?>
@@ -131,10 +134,13 @@ class="inline">end_date, array('v
end_date ?: ''; - $medication_end_date = (array_key_exists('enable_concise_med_history', Yii::app()->params) - && Yii::app()->params['enable_concise_med_history'] - && !$medication_end_date) ? date('Y-m-d') : null; + $medication_end_date = null; + if ($medication->end_date) { + $medication_end_date = $medication->end_date; + } + else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) { + $medication_end_date = date('Y-m-d'); + } $this->renderPartial( '/patient/_fuzzy_date', array( From f7d1f18415eab5d48fce76b1f26b469c8694f7dd Mon Sep 17 00:00:00 2001 From: Prasath Kumar Sagadevan Date: Tue, 4 Oct 2016 15:15:13 +0530 Subject: [PATCH 012/164] OE-6214 Change refraction type "Own Glasses" to "Focimetry" - added down migration --- .../m161004_063341_alter_refraction_type.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php b/protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php index a4266a4a28..d3f76ab014 100644 --- a/protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php +++ b/protected/modules/OphCiExamination/migrations/m161004_063341_alter_refraction_type.php @@ -9,17 +9,7 @@ public function up() public function down() { - return true; + $this->update('ophciexamination_refraction_type', array('name' => 'Own Glasses'), 'name = "Focimetry"'); } - - /* - // Use safeUp/safeDown to do migration with transaction - public function safeUp() - { - } - - public function safeDown() - { - } - */ + } \ No newline at end of file From f64552ffdde331c34818450664fc867f65fa3c15 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Tue, 4 Oct 2016 15:34:07 +0530 Subject: [PATCH 013/164] OE-5621 : Changed paranthesis and added isset condition which is missed. --- protected/views/medication/form.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/protected/views/medication/form.php b/protected/views/medication/form.php index 7eb07dc36e..2559838c44 100644 --- a/protected/views/medication/form.php +++ b/protected/views/medication/form.php @@ -100,10 +100,12 @@ start_date) { + if ($medication->start_date) + { $medication_start_date = $medication->start_date; } - else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) { + else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) + { $medication_start_date = date('Y-m-d'); } $this->renderPartial( @@ -125,7 +127,7 @@ class="inline">end_date, array(' - params['enable_concise_med_history'] || !Yii::app()->params['enable_concise_med_history']) { ?> + params['enable_concise_med_history']) || !Yii::app()->params['enable_concise_med_history']) { ?>
@@ -135,10 +137,12 @@ class="inline">end_date, array('v end_date) { + if ($medication->end_date) + { $medication_end_date = $medication->end_date; } - else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) { + else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) + { $medication_end_date = date('Y-m-d'); } $this->renderPartial( From c7e7380b208f67a1a3796582dd5b85a2d4d2c2f1 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Tue, 4 Oct 2016 15:47:52 +0530 Subject: [PATCH 014/164] OE-5621 : Formatting for the code for the whole file. --- protected/views/medication/form.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/protected/views/medication/form.php b/protected/views/medication/form.php index 2559838c44..b2da71d0bc 100644 --- a/protected/views/medication/form.php +++ b/protected/views/medication/form.php @@ -21,7 +21,8 @@ - +
@@ -69,7 +70,8 @@
- widget('application.widgets.TextField', array('element' => $medication, 'field' => 'dose', 'name' => 'dose')); ?> + widget('application.widgets.TextField', + array('element' => $medication, 'field' => 'dose', 'name' => 'dose')); ?> widget( 'application.widgets.DropDownList', @@ -77,7 +79,7 @@ 'element' => $medication, 'field' => 'route_id', 'data' => 'DrugRoute', - 'htmlOptions' => array('name' => 'route_id', 'empty' => '- Select -') + 'htmlOptions' => array('name' => 'route_id', 'empty' => '- Select -'), ) ); ?> @@ -93,19 +95,16 @@ 'element' => $medication, 'field' => 'frequency_id', 'data' => 'DrugFrequency', - 'htmlOptions' => array('name' => 'frequency_id', 'empty' => '- Select -') + 'htmlOptions' => array('name' => 'frequency_id', 'empty' => '- Select -'), ) ); ?> start_date) - { + if ($medication->start_date) { $medication_start_date = $medication->start_date; - } - else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) - { + } elseif (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) { $medication_start_date = date('Y-m-d'); } $this->renderPartial( @@ -114,7 +113,7 @@ 'form' => $form, 'date' => $medication_start_date, 'class' => 'medication_start_date', - 'label' => 'Date from' + 'label' => 'Date from', ) ); ?> @@ -137,12 +136,9 @@ class="inline">end_date, array('v end_date) - { + if ($medication->end_date) { $medication_end_date = $medication->end_date; - } - else if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) - { + } elseif (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) { $medication_end_date = date('Y-m-d'); } $this->renderPartial( @@ -151,7 +147,7 @@ class="inline">end_date, array('v 'form' => $form, 'date' => $medication_end_date, 'class' => 'medication_end_date', - 'label' => 'Date to' + 'label' => 'Date to', ) ); $this->renderPartial('stop_reason', array('form' => $form, 'medication' => $medication)); From 1abcca69599709404fa9cd84f7427a494cae0741 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Tue, 4 Oct 2016 11:38:59 +0100 Subject: [PATCH 015/164] OE-6215: Changes ordering Previously the order went from PK ascending to event date ascending which switched the order round for the events so that is now updated to work the same way here. --- ...rm_Element_OphTrIntravitrealinjection_Treatment_fields.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php b/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php index 10015bc4e1..a177e5c826 100644 --- a/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php +++ b/protected/modules/OphTrIntravitrealinjection/views/default/form_Element_OphTrIntravitrealinjection_Treatment_fields.php @@ -149,9 +149,9 @@ class="row field-row"> } $count = 0; if (count($previous)) { - $count = $previous[0][$side . '_number']; + $count = $previous[count($previous) - 1][$side . '_number']; } - $drug_history[$drug->id] = array_reverse($previous); + $drug_history[$drug->id] = $previous; $html_options['options'][$drug->id] = array( 'data-previous' => $count, From c589967ee39f2a56bc724f177fb99c6a30d312b4 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Tue, 4 Oct 2016 12:01:22 +0100 Subject: [PATCH 016/164] OE-6215: Fixes issue of $drug being null --- .../components/OphTrIntravitrealinjection_API.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php index 1effd73d40..93fa4aaa04 100644 --- a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php +++ b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php @@ -72,6 +72,10 @@ public function previousInjections($patient, $episode, $side, $drug = null, $sin } } + if(!$drug || get_class($drug) !== 'OphTrIntravitrealinjection_Treatment_Drug'){ + $drug = new OphTrIntravitrealinjection_Treatment_Drug(); + } + $injections = $this->injectionsSinceByEpisodeSideAndDrug($episode, $side, $drug, $since); foreach ($injections as $injection) { From 3ea9b6e50c610e09ffa0c84875c13c47c51115a7 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Tue, 4 Oct 2016 13:16:26 +0100 Subject: [PATCH 017/164] OE-6215: Fixes style issues --- .../OphTrIntravitrealinjection_API.php | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php index 93fa4aaa04..ccf89c5934 100644 --- a/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php +++ b/protected/modules/OphTrIntravitrealinjection/components/OphTrIntravitrealinjection_API.php @@ -1,4 +1,5 @@ $injection->{$side.'_drug_id'}, - $side.'_drug' => $injection->{$side.'_drug'}->name, - $side.'_number' => $injection->{$side.'_number'}, + $side . '_drug_id' => $injection->{$side . '_drug_id'}, + $side . '_drug' => $injection->{$side . '_drug'}->name, + $side . '_number' => $injection->{$side . '_number'}, 'date' => $injection->event->event_date, 'event_id' => $injection->event_id, ); @@ -112,7 +113,7 @@ protected function injectionsSinceByEpisodeSideAndDrug(Episode $episode, $side, $eye_ids = array(SplitEventTypeElement::RIGHT, SplitEventTypeElement::BOTH); break; default: - throw new Exception('invalid side value provided: '.$side); + throw new Exception('invalid side value provided: ' . $side); break; } @@ -169,7 +170,7 @@ protected function getPreviousTreatmentForSide($patient, $episode, $side) public function getLetterTreatmentDrugForSide($patient, $episode, $side) { if ($injection = $this->getPreviousTreatmentForSide($patient, $episode, $side)) { - return $injection->{$side.'_drug'}->name; + return $injection->{$side . '_drug'}->name; } } @@ -215,12 +216,12 @@ public function getLetterTreatmentDrugBoth($patient) $right = $this->getLetterTreatmentDrugForSide($patient, $episode, 'right'); $left = $this->getLetterTreatmentDrugForSide($patient, $episode, 'left'); if ($right) { - $res = $right.' injection to the right eye'; + $res = $right . ' injection to the right eye'; if ($left) { - $res .= ', and '.$left.' injection to the left eye'; + $res .= ', and ' . $left . ' injection to the left eye'; } } elseif ($left) { - $res = $left.' injection on the left eye'; + $res = $left . ' injection on the left eye'; } return $res; @@ -239,7 +240,7 @@ public function getLetterTreatmentDrugBoth($patient) public function getLetterTreatmentNumberForSide($patient, $episode, $side) { if ($injection = $this->getPreviousTreatmentForSide($patient, $episode, $side)) { - return $injection->{$side.'_number'}; + return $injection->{$side . '_number'}; } } @@ -282,12 +283,12 @@ public function getLetterTreatmentNumberBoth($patient) $left = $this->getLetterTreatmentNumberLeft($patient); $res = ''; if ($right) { - $res = $right.' on the right eye'; + $res = $right . ' on the right eye'; if ($left) { - $res .= ', and '.$left.' on the left eye'; + $res .= ', and ' . $left . ' on the left eye'; } } elseif ($left) { - $res = $left.' on the left eye'; + $res = $left . ' on the left eye'; } return $res; @@ -306,10 +307,10 @@ public function getLetterPostInjectionDrops($patient) if ($el = $this->getElementForLatestEventInEpisode($episode, 'Element_OphTrIntravitrealinjection_PostInjectionExamination')) { $drops = array(); if ($el->hasRight()) { - $drops[] = $el->right_drops->name.' to the right eye'; + $drops[] = $el->right_drops->name . ' to the right eye'; } if ($el->hasLeft()) { - $drops[] = $el->left_drops->name.' to the left eye'; + $drops[] = $el->left_drops->name . ' to the left eye'; } return implode(', and ', $drops); From 4a26460a6db4538a12504b3b6802d2013ecaeb95 Mon Sep 17 00:00:00 2001 From: Prasath Kumar Sagadevan Date: Tue, 4 Oct 2016 18:41:09 +0530 Subject: [PATCH 018/164] OE-6197 UI render crash when any combinations of special characters entered in admin settings(user/admin banner) --- protected/controllers/AdminController.php | 4 +--- protected/views/admin/_admin_setting_text_field.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/protected/controllers/AdminController.php b/protected/controllers/AdminController.php index 7670d9ef99..aa9c68c214 100644 --- a/protected/controllers/AdminController.php +++ b/protected/controllers/AdminController.php @@ -1868,9 +1868,7 @@ public function actionEditSetting() $setting = new SettingInstallation(); $setting->key = $metadata->key; } - - $setting->value = @$_POST[$metadata->key]; - + $setting->value = htmlspecialchars(@$_POST[$metadata->key]); if (!$setting->save()) { $errors = $setting->errors; } else { diff --git a/protected/views/admin/_admin_setting_text_field.php b/protected/views/admin/_admin_setting_text_field.php index 045cf05349..c5f33a4c84 100644 --- a/protected/views/admin/_admin_setting_text_field.php +++ b/protected/views/admin/_admin_setting_text_field.php @@ -17,7 +17,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ ?> -getSettingName(); +getSettingName()); if (!isset($currentValue) || $currentValue == null) { // we need this to prevent HTML value without = $currentValue = ''; From c0c4f60061f8aea60273e79b1fbc89f9116632e0 Mon Sep 17 00:00:00 2001 From: Prasath Kumar Sagadevan Date: Wed, 5 Oct 2016 12:20:48 +0530 Subject: [PATCH 019/164] OE-6197 UI render crash when any combinations of words is entered in admin settings - user/admin banner --- protected/controllers/AdminController.php | 2 +- protected/views/admin/_admin_setting_text_field.php | 2 +- protected/views/base/_banner_watermark.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/protected/controllers/AdminController.php b/protected/controllers/AdminController.php index aa9c68c214..d5d155d7f5 100644 --- a/protected/controllers/AdminController.php +++ b/protected/controllers/AdminController.php @@ -1868,7 +1868,7 @@ public function actionEditSetting() $setting = new SettingInstallation(); $setting->key = $metadata->key; } - $setting->value = htmlspecialchars(@$_POST[$metadata->key]); + $setting->value = @$_POST[$metadata->key]; if (!$setting->save()) { $errors = $setting->errors; } else { diff --git a/protected/views/admin/_admin_setting_text_field.php b/protected/views/admin/_admin_setting_text_field.php index c5f33a4c84..045cf05349 100644 --- a/protected/views/admin/_admin_setting_text_field.php +++ b/protected/views/admin/_admin_setting_text_field.php @@ -17,7 +17,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ ?> -getSettingName()); +getSettingName(); if (!isset($currentValue) || $currentValue == null) { // we need this to prevent HTML value without = $currentValue = ''; diff --git a/protected/views/base/_banner_watermark.php b/protected/views/base/_banner_watermark.php index 9b18857c4e..38c52c3e48 100644 --- a/protected/views/base/_banner_watermark.php +++ b/protected/views/base/_banner_watermark.php @@ -20,13 +20,13 @@ user->checkAccess('admin') && Yii::app()->params['watermark_admin']) {?> params['watermark']) {?> params['watermark_description']) {?> -

params['watermark_description']?>

+

params['watermark_description']);?>

From 6e7661105c27735f8720a60894c1e9d9fdc8eb80 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 5 Oct 2016 19:17:09 +0530 Subject: [PATCH 020/164] OE-6191 : Changed the created_date to event_date for the search for reports in Intravitreal Injection. --- ...Intravitrealinjection_ReportInjections.php | 190 ++++++++++-------- 1 file changed, 105 insertions(+), 85 deletions(-) diff --git a/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php b/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php index 878f9bc12e..576c9485cf 100644 --- a/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php +++ b/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php @@ -1,4 +1,5 @@ given_by_id) { if (!$user = User::model()->findByPk($this->given_by_id)) { - throw new Exception('User not found: '.$this->given_by_id); + throw new Exception('User not found: ' . $this->given_by_id); } } if ($this->drug_id) { if (!$drug = OphTrIntravitrealinjection_Treatment_Drug::model()->findByPk($this->drug_id)) { - throw new Exception('Drug not found: '.$this->drug_id); + throw new Exception('Drug not found: ' . $this->drug_id); } } if ($this->pre_antisept_drug_id) { if (!$pre_antisept_drug = OphTrIntravitrealinjection_AntiSepticDrug::model()->findByPk($this->pre_antisept_drug_id)) { - throw new Exception('Drug not found: '.$this->pre_antisept_drug_id); + throw new Exception('Drug not found: ' . $this->pre_antisept_drug_id); } } if ($this->summary) { - $this->injections = $this->getSummaryInjections($this->date_from, $this->date_to, @$user, @$drug, @$pre_antisept_drug); + $this->injections = $this->getSummaryInjections($this->date_from, $this->date_to, @$user, @$drug, + @$pre_antisept_drug); $this->view = '_summary_injections'; } else { - $this->injections = $this->getInjections($this->date_from, $this->date_to, @$user, @$drug, @$pre_antisept_drug); + $this->injections = $this->getInjections($this->date_from, $this->date_to, @$user, @$drug, + @$pre_antisept_drug); $this->view = '_injections'; } } @@ -145,19 +148,19 @@ protected function getSummaryInjections($date_from, $date_to, $given_by_user, $d $patient_data = array(); $where = ''; $command = Yii::app()->db->createCommand() - ->select( - 'p.id as patient_id, treat.left_drug_id, treat.right_drug_id, treat.left_number, treat.right_number, e.id, + ->select( + 'p.id as patient_id, treat.left_drug_id, treat.right_drug_id, treat.left_number, treat.right_number, e.id, e.created_date, c.first_name, c.last_name, e.created_date, p.hos_num,p.gender, p.dob, eye.name AS eye, site.name as site_name' - ) - ->from('et_ophtrintravitinjection_treatment treat') - ->join('event e', 'e.id = treat.event_id') - ->join('episode ep', 'e.episode_id = ep.id') - ->join('patient p', 'ep.patient_id = p.id') - ->join('contact c', 'p.contact_id = c.id') - ->join('eye', 'eye.id = treat.eye_id') - ->join('et_ophtrintravitinjection_site insite', 'insite.event_id = treat.event_id') - ->leftJoin('site', 'insite.site_id = site.id') - ->order('p.id, e.created_date asc'); + ) + ->from('et_ophtrintravitinjection_treatment treat') + ->join('event e', 'e.id = treat.event_id') + ->join('episode ep', 'e.episode_id = ep.id') + ->join('patient p', 'ep.patient_id = p.id') + ->join('contact c', 'p.contact_id = c.id') + ->join('eye', 'eye.id = treat.eye_id') + ->join('et_ophtrintravitinjection_site insite', 'insite.event_id = treat.event_id') + ->leftJoin('site', 'insite.site_id = site.id') + ->order('p.id, e.created_date asc'); // for debug if ($this->patient_id) { $where = 'ep.patient_id = :pat_id and e.deleted = 0 and ep.deleted = 0 and e.created_date >= :from_date and e.created_date < (:to_date + interval 1 day)'; @@ -206,9 +209,9 @@ protected function getSummaryInjections($date_from, $date_to, $given_by_user, $d } foreach (array('left', 'right') as $side) { $dt = date('j M Y', strtotime($row['created_date'])); - if ($drug = $this->getDrugById($row[$side.'_drug_id'])) { + if ($drug = $this->getDrugById($row[$side . '_drug_id'])) { $patient_data[$side][$drug->name][$site]['last_injection_date'] = $dt; - $patient_data[$side][$drug->name][$site]['injection_number'] = $row[$side.'_number']; + $patient_data[$side][$drug->name][$site]['injection_number'] = $row[$side . '_number']; if (!isset($patient_data[$side][$drug->name][$site]['first_injection_date'])) { $patient_data[$side][$drug->name][$site]['first_injection_date'] = $dt; } @@ -227,21 +230,22 @@ protected function getInjections($date_from, $date_to, $given_by_user, $drug, $p $where = 'e.deleted = 0 and ep.deleted = 0 and e.created_date >= :from_date and e.created_date < (:to_date + interval 1 day)'; $command = Yii::app()->db->createCommand() - ->select( - 'p.id as patient_id, treat.left_drug_id, treat.right_drug_id, treat.left_number, treat.right_number, e.id, - e.created_date, c.first_name, c.last_name, e.created_date, p.hos_num,p.gender, p.dob, eye.name AS eye, site.name as site_name,treat.left_injection_given_by_id, treat.right_injection_given_by_id, - treat.left_pre_antisept_drug_id, treat.right_pre_antisept_drug_id, anteriorseg.left_lens_status_id, anteriorseg.right_lens_status_id' - ) - ->from('et_ophtrintravitinjection_treatment treat') - ->join('event e', 'e.id = treat.event_id') - ->join('episode ep', 'e.episode_id = ep.id') - ->join('patient p', 'ep.patient_id = p.id') - ->join('contact c', 'p.contact_id = c.id') - ->join('eye', 'eye.id = treat.eye_id') - ->join('et_ophtrintravitinjection_site insite', 'insite.event_id = treat.event_id') - ->join('et_ophtrintravitinjection_anteriorseg anteriorseg', 'anteriorseg.event_id = treat.event_id') - ->join('site', 'insite.site_id = site.id') - ->order('p.id, e.created_date asc'); + ->select( + 'p.id as patient_id, treat.left_drug_id, treat.right_drug_id, treat.left_number, treat.right_number, e.id, + e.event_date, c.first_name, c.last_name, p.hos_num, p.gender, p.dob, eye.name AS eye, site.name as site_name, + treat.left_injection_given_by_id, treat.right_injection_given_by_id, + treat.left_pre_antisept_drug_id, treat.right_pre_antisept_drug_id, anteriorseg.left_lens_status_id, anteriorseg.right_lens_status_id' + ) + ->from('et_ophtrintravitinjection_treatment treat') + ->join('event e', 'e.id = treat.event_id') + ->join('episode ep', 'e.episode_id = ep.id') + ->join('patient p', 'ep.patient_id = p.id') + ->join('contact c', 'p.contact_id = c.id') + ->join('eye', 'eye.id = treat.eye_id') + ->join('et_ophtrintravitinjection_site insite', 'insite.event_id = treat.event_id') + ->join('et_ophtrintravitinjection_anteriorseg anteriorseg', 'anteriorseg.event_id = treat.event_id') + ->join('site', 'insite.site_id = site.id') + ->order('p.id, e.event_date asc'); $params = array(':from_date' => $date_from, ':to_date' => $date_to); if ($given_by_user) { @@ -263,32 +267,32 @@ protected function getInjections($date_from, $date_to, $given_by_user, $drug, $p $results = array(); foreach ($command->queryAll(true, $params) as $row) { - $diagnosisData = $this->getDiagnosisData($row['patient_id'], $row['created_date']); + $diagnosisData = $this->getDiagnosisData($row['patient_id'], $row['event_date']); $record = array( - 'injection_date' => date('j M Y', strtotime($row['created_date'])), - 'patient_hosnum' => $row['hos_num'], - 'patient_firstname' => $row['first_name'], - 'patient_surname' => $row['last_name'], - 'patient_gender' => $row['gender'], - 'patient_dob' => date('j M Y', strtotime($row['dob'])), - 'eye' => $row['eye'], - 'site_name' => $row['site_name'], - 'left_drug' => $this->getDrugString($row['left_drug_id']), - 'left_injection_number' => $row['left_number'], - 'right_drug' => $this->getDrugString($row['right_drug_id']), - 'right_injection_number' => $row['right_number'], - 'pre_antisept_drug_left' => $this->getPreAntiseptDrugString($row['left_pre_antisept_drug_id']), - 'pre_antisept_drug_right' => $this->getPreAntiseptDrugString($row['right_pre_antisept_drug_id']), - 'given_by_left' => $this->getGivenByName($row['left_injection_given_by_id']), - 'given_by_right' => $this->getGivenByName($row['right_injection_given_by_id']), - 'lens_status_left' => $this->getLensStatus($row['left_lens_status_id']), - 'lens_status_right' => $this->getLensStatus($row['right_lens_status_id']), - 'diagnosis_left' => $this->getDiagnosisName($diagnosisData['left_diagnosis_id']), - 'diagnosis_right' => $this->getDiagnosisName($diagnosisData['right_diagnosis_id']), + 'injection_date' => date('j M Y', strtotime($row['event_date'])), + 'patient_hosnum' => $row['hos_num'], + 'patient_firstname' => $row['first_name'], + 'patient_surname' => $row['last_name'], + 'patient_gender' => $row['gender'], + 'patient_dob' => date('j M Y', strtotime($row['dob'])), + 'eye' => $row['eye'], + 'site_name' => $row['site_name'], + 'left_drug' => $this->getDrugString($row['left_drug_id']), + 'left_injection_number' => $row['left_number'], + 'right_drug' => $this->getDrugString($row['right_drug_id']), + 'right_injection_number' => $row['right_number'], + 'pre_antisept_drug_left' => $this->getPreAntiseptDrugString($row['left_pre_antisept_drug_id']), + 'pre_antisept_drug_right' => $this->getPreAntiseptDrugString($row['right_pre_antisept_drug_id']), + 'given_by_left' => $this->getGivenByName($row['left_injection_given_by_id']), + 'given_by_right' => $this->getGivenByName($row['right_injection_given_by_id']), + 'lens_status_left' => $this->getLensStatus($row['left_lens_status_id']), + 'lens_status_right' => $this->getLensStatus($row['right_lens_status_id']), + 'diagnosis_left' => $this->getDiagnosisName($diagnosisData['left_diagnosis_id']), + 'diagnosis_right' => $this->getDiagnosisName($diagnosisData['right_diagnosis_id']), ); - $this->appendExaminationValues($record, $row['patient_id'], $row['created_date']); + $this->appendExaminationValues($record, $row['patient_id'], $row['event_date']); $results[] = $record; } @@ -305,10 +309,11 @@ public function description() } if ($this->given_by_id) { - $description .= ' given by '.User::model()->findByPk($this->given_by_id)->fullName; + $description .= ' given by ' . User::model()->findByPk($this->given_by_id)->fullName; } - $description .= ' between '.date('j M Y', strtotime($this->date_from)).' and '.date('j M Y', strtotime($this->date_to)); + $description .= ' between ' . date('j M Y', strtotime($this->date_from)) . ' and ' . date('j M Y', + strtotime($this->date_to)); if ($this->pre_va && $this->post_va) { $description .= ' with pre-injection and post-injection VA'; @@ -328,10 +333,10 @@ public function description() */ public function toCSV() { - $output = $this->description()."\n\n"; + $output = $this->description() . "\n\n"; if ($this->summary) { - $output .= Patient::model()->getAttributeLabel('hos_num').','.Patient::model()->getAttributeLabel('first_name').','.Patient::model()->getAttributeLabel('last_name').','.Patient::model()->getAttributeLabel('gender').','.Patient::model()->getAttributeLabel('dob').',Eye,Drug,Site,First injection date,Last injection date,Injection no'; + $output .= Patient::model()->getAttributeLabel('hos_num') . ',' . Patient::model()->getAttributeLabel('first_name') . ',' . Patient::model()->getAttributeLabel('last_name') . ',' . Patient::model()->getAttributeLabel('gender') . ',' . Patient::model()->getAttributeLabel('dob') . ',Eye,Drug,Site,First injection date,Last injection date,Injection no'; if ($this->pre_va) { $output .= ',Left pre-injection VA,Right pre-injection VA'; @@ -341,7 +346,7 @@ public function toCSV() } $output .= "\n"; } else { - $output .= 'Date,'.Patient::model()->getAttributeLabel('hos_num').','.Patient::model()->getAttributeLabel('first_name').','.Patient::model()->getAttributeLabel('last_name').','.Patient::model()->getAttributeLabel('gender').','.Patient::model()->getAttributeLabel('dob').',Eye,Site,Left drug,Left injection no,Right drug,Right injection no,Left Pre-injection Antiseptics,Right Pre-injection Antiseptics,Left Injection given by,Right Injection given by,Left Lens Status,Right Lens Status,Left Diagnosis,Right Diagnosis'; + $output .= 'Date,' . Patient::model()->getAttributeLabel('hos_num') . ',' . Patient::model()->getAttributeLabel('first_name') . ',' . Patient::model()->getAttributeLabel('last_name') . ',' . Patient::model()->getAttributeLabel('gender') . ',' . Patient::model()->getAttributeLabel('dob') . ',Eye,Site,Left drug,Left injection no,Right drug,Right injection no,Left Pre-injection Antiseptics,Right Pre-injection Antiseptics,Left Injection given by,Right Injection given by,Left Lens Status,Right Lens Status,Left Diagnosis,Right Diagnosis'; if ($this->pre_va) { $output .= ',Left pre-injection VA,Right pre-injection VA'; @@ -352,7 +357,7 @@ public function toCSV() $output .= "\n"; } - return $output.$this->array2Csv($this->injections); + return $output . $this->array2Csv($this->injections); } protected function getDiagnosisDataFromEvent($patient_id, $close_to_date, $event_type_id, $model) @@ -374,7 +379,7 @@ protected function getDiagnosisDataFromEvent($patient_id, $close_to_date, $event if ($eventData) { $criteria = new CDbCriteria(); - $criteria->addCondition('event_id = '.$eventData['id']); + $criteria->addCondition('event_id = ' . $eventData['id']); $injectionManagementData = $model::model()->find($criteria); //var_dump($injectionManagementData); @@ -392,14 +397,18 @@ protected function getDiagnosisDataFromEvent($patient_id, $close_to_date, $event } } } + //var_dump('Patient: '.$patient_id.' LEFT: '.$left_diagnosis_id." RIGHT: ".$right_diagnosis_id." Command: ".$command->getText()." :: ".print_r($command->params)); return array('left_diagnosis_id' => $left_diagnosis_id, 'right_diagnosis_id' => $right_diagnosis_id); } /** - * a) From the injection management element under Examination event saved before the injection event - usually on the same day - * b) If no injection management saved then this can be obtained from the application event If there is an application event saved before the injection started for the patient - * c) if there is no application then diagnoses for the episode. + * a) From the injection management element under Examination event saved before the injection event - usually on the same day + * b) If no injection management saved then this can be obtained from the application event If there is an application event saved before the injection started for the patient + * c) if there is no application then diagnoses for the episode. + * @param $patient_id + * @param $close_to_date + * @return array */ protected function getDiagnosisData($patient_id, $close_to_date) { @@ -407,10 +416,13 @@ protected function getDiagnosisData($patient_id, $close_to_date) // check for examination data // search for the closest examination event first - $diagnosisData = $this->getDiagnosisDataFromEvent($patient_id, $close_to_date, $this->getExaminationEventTypeId(), 'OEModule\OphCiExamination\models\Element_OphCiExamination_InjectionManagementComplex'); + $diagnosisData = $this->getDiagnosisDataFromEvent($patient_id, $close_to_date, + $this->getExaminationEventTypeId(), + 'OEModule\OphCiExamination\models\Element_OphCiExamination_InjectionManagementComplex'); if (!$diagnosisData['left_diagnosis_id'] || !$diagnosisData['right_diagnosis_id']) { - $diagnosisData = $this->getDiagnosisDataFromEvent($patient_id, $close_to_date, $this->getApplicationEventTypeID(), 'Element_OphCoTherapyapplication_Therapydiagnosis'); + $diagnosisData = $this->getDiagnosisDataFromEvent($patient_id, $close_to_date, + $this->getApplicationEventTypeID(), 'Element_OphCoTherapyapplication_Therapydiagnosis'); } return $diagnosisData; @@ -450,7 +462,7 @@ protected function getGivenByName($user_id) return 'N/A'; } if ($user = User::model()->findByPk($user_id)) { - return $user->first_name.' '.$user->last_name; + return $user->first_name . ' ' . $user->last_name; } else { return 'UNKNOWN'; } @@ -502,16 +514,21 @@ protected function getDrugString($drug_id) protected function appendExaminationValues(&$record, $patient_id, $event_date) { if ($this->pre_va || $this->post_va) { - foreach (array('left_preinjection_va', 'right_preinjection_va', 'left_postinjection_va', 'right_postinjection_va') as $k) { + foreach (array( + 'left_preinjection_va', + 'right_preinjection_va', + 'left_postinjection_va', + 'right_postinjection_va', + ) as $k) { $record[$k] = 'N/A'; } $vas = $this->getPatientVAElements($patient_id); $before = null; $after = null; foreach ($vas as $va) { - if ($va->created_date < $event_date) { + if ($va->event->event_date < $event_date) { $before = $va; - } elseif ($va->created_date > $event_date) { + } elseif ($va->event->event_date > $event_date) { $after = $va; break; } @@ -550,21 +567,22 @@ protected function getPatientVAElements($patient_id) if ($patient_id != $this->_current_patient_id) { $this->_current_patient_id = $patient_id; $command = Yii::app()->db->createCommand() - ->select( - 'e.id' - ) - ->from('event e') - ->join('episode ep', 'e.episode_id = ep.id') - ->where('e.deleted = 0 and ep.deleted = 0 and ep.patient_id = :patient_id and e.event_type_id = :etype_id', - array(':patient_id' => $patient_id, ':etype_id' => $this->getExaminationEventTypeId()) - ); + ->select( + 'e.id' + ) + ->from('event e') + ->join('episode ep', 'e.episode_id = ep.id') + ->where('e.deleted = 0 and ep.deleted = 0 and ep.patient_id = :patient_id and e.event_type_id = :etype_id', + array(':patient_id' => $patient_id, ':etype_id' => $this->getExaminationEventTypeId()) + ); $event_ids = array(); foreach ($command->queryAll() as $res) { $event_ids[] = $res['id']; } $criteria = new CDbCriteria(); $criteria->addInCondition('event_id', $event_ids); - $this->_patient_vas = OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity::model()->with('right_readings', 'left_readings')->findAll($criteria); + $this->_patient_vas = OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity::model()->with('right_readings', + 'left_readings', 'event')->findAll($criteria); } return $this->_patient_vas; @@ -574,14 +592,16 @@ protected function getPatientVAElements($patient_id) * Simple wrapper function for getting a string representation of the best VA reading for a side from the given element. * * @param $side - * @param Element_OphCiExamination_VisualAcuity $va + * @param OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity $va * * @return string */ - protected function getBestVaFromReading($side, OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity $va) - { + protected function getBestVaFromReading( + $side, + OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity $va + ) { if ($reading = $va->getBestReading($side)) { - return $reading->convertTo($reading->value, $va->unit_id).' ('.$reading->method->name.')'; + return $reading->convertTo($reading->value, $va->unit_id) . ' (' . $reading->method->name . ')'; } return 'N/A'; From 643f81e7be530c7063ef1a9726ea2db076b28770 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 5 Oct 2016 19:20:26 +0530 Subject: [PATCH 021/164] OE-6191 : Changed the report criteria to event date --- .../models/OphTrIntravitrealinjection_ReportInjections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php b/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php index 576c9485cf..da2e560319 100644 --- a/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php +++ b/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php @@ -227,7 +227,7 @@ protected function getSummaryInjections($date_from, $date_to, $given_by_user, $d protected function getInjections($date_from, $date_to, $given_by_user, $drug, $pre_antisept_drug) { - $where = 'e.deleted = 0 and ep.deleted = 0 and e.created_date >= :from_date and e.created_date < (:to_date + interval 1 day)'; + $where = 'e.deleted = 0 and ep.deleted = 0 and e.event_date >= :from_date and e.event_date < (:to_date + interval 1 day)'; $command = Yii::app()->db->createCommand() ->select( From 182280db1777351886a2b831156075303a898b56 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 5 Oct 2016 19:32:57 +0530 Subject: [PATCH 022/164] OE-6191 : Fixed the injection summary results with the event date instead of created_date. --- .../OphTrIntravitrealinjection_ReportInjections.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php b/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php index da2e560319..ceef695d4e 100644 --- a/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php +++ b/protected/modules/OphTrIntravitrealinjection/models/OphTrIntravitrealinjection_ReportInjections.php @@ -150,7 +150,7 @@ protected function getSummaryInjections($date_from, $date_to, $given_by_user, $d $command = Yii::app()->db->createCommand() ->select( 'p.id as patient_id, treat.left_drug_id, treat.right_drug_id, treat.left_number, treat.right_number, e.id, - e.created_date, c.first_name, c.last_name, e.created_date, p.hos_num,p.gender, p.dob, eye.name AS eye, site.name as site_name' + e.event_date, c.first_name, c.last_name, e.created_date, p.hos_num,p.gender, p.dob, eye.name AS eye, site.name as site_name' ) ->from('et_ophtrintravitinjection_treatment treat') ->join('event e', 'e.id = treat.event_id') @@ -160,13 +160,13 @@ protected function getSummaryInjections($date_from, $date_to, $given_by_user, $d ->join('eye', 'eye.id = treat.eye_id') ->join('et_ophtrintravitinjection_site insite', 'insite.event_id = treat.event_id') ->leftJoin('site', 'insite.site_id = site.id') - ->order('p.id, e.created_date asc'); + ->order('p.id, e.event_date asc'); // for debug if ($this->patient_id) { - $where = 'ep.patient_id = :pat_id and e.deleted = 0 and ep.deleted = 0 and e.created_date >= :from_date and e.created_date < (:to_date + interval 1 day)'; + $where = 'ep.patient_id = :pat_id and e.deleted = 0 and ep.deleted = 0 and e.event_date >= :from_date and e.event_date < (:to_date + interval 1 day)'; $params = array(':from_date' => $date_from, ':to_date' => $date_to, ':pat_id' => $this->patient_id); } else { - $where = 'e.deleted = 0 and ep.deleted = 0 and e.created_date >= :from_date and e.created_date < (:to_date + interval 1 day)'; + $where = 'e.deleted = 0 and ep.deleted = 0 and e.event_date >= :from_date and e.event_date < (:to_date + interval 1 day)'; $params = array(':from_date' => $date_from, ':to_date' => $date_to); } @@ -208,7 +208,7 @@ protected function getSummaryInjections($date_from, $date_to, $given_by_user, $d $site = 'Unknown'; } foreach (array('left', 'right') as $side) { - $dt = date('j M Y', strtotime($row['created_date'])); + $dt = date('j M Y', strtotime($row['event_date'])); if ($drug = $this->getDrugById($row[$side . '_drug_id'])) { $patient_data[$side][$drug->name][$site]['last_injection_date'] = $dt; $patient_data[$side][$drug->name][$site]['injection_number'] = $row[$side . '_number']; From c4db60f2121ca29a96da210f441edda9b9490b99 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Tue, 11 Oct 2016 15:52:09 +0530 Subject: [PATCH 023/164] OE-5376 : Configure devices for (cataract) op note via admin interface --- .../SiteSubspecialtyOperativeDevice.php | 7 +- .../OphTrOperationnote/config/common.php | 1 + .../OperativeDeviceMappingController.php | 164 ++++++++++++++++++ 3 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php diff --git a/protected/models/SiteSubspecialtyOperativeDevice.php b/protected/models/SiteSubspecialtyOperativeDevice.php index 4809ce62ec..174dde0515 100644 --- a/protected/models/SiteSubspecialtyOperativeDevice.php +++ b/protected/models/SiteSubspecialtyOperativeDevice.php @@ -62,6 +62,11 @@ public function rules() */ public function relations() { - return array(); + return array( + 'sites' => array(self::BELONGS_TO, 'Site', 'site_id'), + 'subspecialties' => array(self::BELONGS_TO, 'Subspecialty', 'subspecialty_id'), + 'devices' => array(self::BELONGS_TO, 'OperativeDevice', 'operative_device_id'), + ); } + } diff --git a/protected/modules/OphTrOperationnote/config/common.php b/protected/modules/OphTrOperationnote/config/common.php index d4fe3e8ca5..254e78fab2 100644 --- a/protected/modules/OphTrOperationnote/config/common.php +++ b/protected/modules/OphTrOperationnote/config/common.php @@ -28,6 +28,7 @@ 'Per Op Instructions' => '/OphTrOperationnote/admin/postOpInstructions', 'Default Incision Length' => '/OphTrOperationnote/admin/viewIncisionLengthDefaults', 'Operative Devices' => '/OphTrOperationnote/OperativeDevice/list', + 'Operative Devices Mapping' => '/OphTrOperationnote/OperativeDeviceMapping/list', ), 'reports' => array( 'Operations' => '/OphTrOperationnote/report/operation', diff --git a/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php b/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php new file mode 100644 index 0000000000..cd8323a541 --- /dev/null +++ b/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php @@ -0,0 +1,164 @@ +. + * + * @link http://www.openeyes.org.uk + * + * @author OpenEyes + * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust + * @copyright Copyright (c) 2011-2012, OpenEyes Foundation + * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 + */ + +class OperativeDeviceMappingController extends BaseAdminController +{ + public function actionList() + { + $admin = new AdminListAutocomplete(SiteSubspecialtyOperativeDevice::model(), $this); + + $admin->setListFields(array( + 'id', + 'devices.name', + 'default', + )); + + $admin->setCustomDeleteURL('/OphTrOperationnote/OperativeDeviceMapping/delete'); + $admin->setCustomSaveURL('/OphTrOperationnote/OperativeDeviceMapping/add'); + $admin->setCustomSetDefaultURL('/OphTrOperationnote/OperativeDeviceMapping/setDefault'); + $admin->setCustomRemoveDefaultURL('/OphTrOperationnote/OperativeDeviceMapping/removeDefault'); + $admin->setModelDisplayName('Operation Note Operative Device Mapping'); + $admin->setFilterFields( + array( + array( + 'label' => 'Site', + 'dropDownName' => 'site_id', + 'defaultValue' => Yii::app()->session['selected_site_id'], + 'listModel' => Site::model(), + 'listIdField' => 'id', + 'listDisplayField' => 'short_name', + ), + array( + 'label' => 'Subspecialty', + 'dropDownName' => 'subspecialty_id', + 'defaultValue' => Firm::model()->findByPk(Yii::app()->session['selected_firm_id'])->serviceSubspecialtyAssignment->subspecialty_id, + 'listModel' => Subspecialty::model(), + 'listIdField' => 'id', + 'listDisplayField' => 'name', + ), + ) + ); + + // we set default search options + if ($this->request->getParam('search') == '') { + $admin->getSearch()->initSearch(array( + 'filterid' => array( + 'subspecialty_id' => Firm::model()->findByPk(Yii::app()->session['selected_firm_id'])->serviceSubspecialtyAssignment->subspecialty_id, + 'site_id' => Yii::app()->session['selected_site_id'], + ), + ) + ); + } + + $admin->setAutocompleteField( + array( + 'fieldName' => 'operative_device_id', + 'allowBlankSearch' => 1, + 'jsonURL' => '/OphTrOperationnote/OperativeDeviceMapping/search', + 'placeholder' => 'search for adding operative devices', + ) + ); + //$admin->searchAll(); + $admin->listModel(); + } + + public function actionDelete($itemId) + { + /* + * We make sure to not allow deleting directly with the URL, user must come from the commondrugs list page + */ + if (!Yii::app()->request->isAjaxRequest) { + $this->render('errorpage', array('errorMessage' => 'notajaxcall')); + } else { + if ($leafletSubspecialy = SiteSubspecialtyOperativeDevice::model()->findByPk($itemId)) { + $leafletSubspecialy->delete(); + echo 'success'; + } else { + $this->render('errorpage', array('errormessage' => 'recordmissing')); + } + } + } + + public function actionAdd() + { + $subspecialtyId = $this->request->getParam('subspecialty_id'); + $siteId = $this->request->getParam('site_id'); + $operativeDeviceId = $this->request->getParam('operative_device_id'); + if (!Yii::app()->request->isAjaxRequest) { + $this->render('errorpage', array('errormessage' => 'notajaxcall')); + } else { + if (!is_numeric($subspecialtyId) || !is_numeric($siteId) || !is_numeric($operativeDeviceId)) { + echo 'error'; + } else { + $criteria = new CDbCriteria(); + $criteria->condition = 'operative_device_id=:operative_device_id AND site_id=:site_id AND subspecialty_id=:subspecialty_id'; + $criteria->params = array( + ':operative_device_id' => $operativeDeviceId, + ':site_id' => $siteId, + ':subspecialty_id' => $subspecialtyId, + ); + $currentSSAA = SiteSubspecialtyOperativeDevice::model()->findall($criteria); + if (!$currentSSAA) { + $newSSAA = new SiteSubspecialtyOperativeDevice(); + $newSSAA->subspecialty_id = $subspecialtyId; + $newSSAA->site_id = $siteId; + $newSSAA->operative_device_id = $operativeDeviceId; + if ($newSSAA->save()) { + echo 'success added to SSAA'; + } else { + echo 'error'; + } + } else { + echo 'success'; + } + } + } + } + + public function actionSearch() + { + if (Yii::app()->request->isAjaxRequest) { + $criteria = new CDbCriteria(); + if (isset($_GET['term'])) { + $term = $_GET['term']; + $criteria->addCondition(array('LOWER(name) LIKE :term'), + 'OR'); + $params[':term'] = '%'.strtolower(strtr($term, array('%' => '\%'))).'%'; + } + + $criteria->order = 'name'; + $criteria->select = 'id, name'; + $criteria->params = $params; + + $results = OperativeDevice::model()->active()->findAll($criteria); + + $return = array(); + foreach ($results as $resultRow) { + $return[] = array( + 'label' => $resultRow->name, + 'value' => $resultRow->name, + 'id' => $resultRow->id, + ); + } + echo CJSON::encode($return); + } + } + +} \ No newline at end of file From e445ccfebf3eae0828ff2e4e9dccc78f703f3689 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Tue, 11 Oct 2016 18:43:37 +0530 Subject: [PATCH 024/164] OE-5376 : Added code to add default values for operative devices. --- .../OperativeDeviceMappingController.php | 61 ++++++++++++++++++- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php b/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php index cd8323a541..c15c314d5d 100644 --- a/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php +++ b/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php @@ -17,8 +17,7 @@ * @copyright Copyright (c) 2011-2012, OpenEyes Foundation * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ - -class OperativeDeviceMappingController extends BaseAdminController +class OperativeDeviceMappingController extends BaseAdminController { public function actionList() { @@ -96,6 +95,62 @@ public function actionDelete($itemId) } } + /** + * To set default values to Operative Device + * @param $item_id + * @param $site_id + * @param $subspecialty_id + */ + public function actionSetDefault($itemId) + { + /* + * We make sure to not allow deleting directly with the URL, user must come from the commondrugs list page + */ + if (!Yii::app()->request->isAjaxRequest) { + $this->render('errorpage', array('errorMessage' => 'notajaxcall')); + } else { + $currentSSOD = SiteSubspecialtyOperativeDevice::model()->findByPk($itemId); + if ($currentSSOD) { + $currentSSOD->default = 1; + if ($currentSSOD->update()) { + echo 'success set default to SSOD'; + } else { + echo 'error'; + } + } else { + echo 'error'; + } + } + } + + /** + * To remove default values to Operative Device + * @param $item_id + * @param $site_id + * @param $subspecialty_id + */ + public function actionRemoveDefault($itemId) + { + /* + * We make sure to not allow deleting directly with the URL, user must come from the commondrugs list page + */ + if (!Yii::app()->request->isAjaxRequest) { + $this->render('errorpage', array('errorMessage' => 'notajaxcall')); + } else { + $currentSSOD = SiteSubspecialtyOperativeDevice::model()->findByPk($itemId); + if ($currentSSOD) { + $currentSSOD->default = 0; + if ($currentSSOD->save()) { + echo 'success remove default to SSOD'; + } else { + echo 'error'; + } + } else { + echo 'error'; + } + } + } + public function actionAdd() { $subspecialtyId = $this->request->getParam('subspecialty_id'); @@ -140,7 +195,7 @@ public function actionSearch() $term = $_GET['term']; $criteria->addCondition(array('LOWER(name) LIKE :term'), 'OR'); - $params[':term'] = '%'.strtolower(strtr($term, array('%' => '\%'))).'%'; + $params[':term'] = '%' . strtolower(strtr($term, array('%' => '\%'))) . '%'; } $criteria->order = 'name'; From b17f4a2f2dc40aefce23ce606008a4bd1c32592f Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 12 Oct 2016 12:12:58 +0530 Subject: [PATCH 025/164] OE-5376 : Added PHPDoc. --- .../OperativeDeviceMappingController.php | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php b/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php index c15c314d5d..b56372e019 100644 --- a/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php +++ b/protected/modules/OphTrOperationnote/controllers/OperativeDeviceMappingController.php @@ -19,6 +19,9 @@ */ class OperativeDeviceMappingController extends BaseAdminController { + /** + * To list the operative devices per site per subspeciality + */ public function actionList() { $admin = new AdminListAutocomplete(SiteSubspecialtyOperativeDevice::model(), $this); @@ -78,6 +81,10 @@ public function actionList() $admin->listModel(); } + /** + * Delete an operative device association with the site + * @param $itemId + */ public function actionDelete($itemId) { /* @@ -98,8 +105,6 @@ public function actionDelete($itemId) /** * To set default values to Operative Device * @param $item_id - * @param $site_id - * @param $subspecialty_id */ public function actionSetDefault($itemId) { @@ -126,8 +131,6 @@ public function actionSetDefault($itemId) /** * To remove default values to Operative Device * @param $item_id - * @param $site_id - * @param $subspecialty_id */ public function actionRemoveDefault($itemId) { @@ -151,6 +154,9 @@ public function actionRemoveDefault($itemId) } } + /** + * To add new operative devices to the site. + */ public function actionAdd() { $subspecialtyId = $this->request->getParam('subspecialty_id'); @@ -169,13 +175,13 @@ public function actionAdd() ':site_id' => $siteId, ':subspecialty_id' => $subspecialtyId, ); - $currentSSAA = SiteSubspecialtyOperativeDevice::model()->findall($criteria); - if (!$currentSSAA) { - $newSSAA = new SiteSubspecialtyOperativeDevice(); - $newSSAA->subspecialty_id = $subspecialtyId; - $newSSAA->site_id = $siteId; - $newSSAA->operative_device_id = $operativeDeviceId; - if ($newSSAA->save()) { + $currentSSOD = SiteSubspecialtyOperativeDevice::model()->findall($criteria); + if (!$currentSSOD) { + $newSSOD = new SiteSubspecialtyOperativeDevice(); + $newSSOD->subspecialty_id = $subspecialtyId; + $newSSOD->site_id = $siteId; + $newSSOD->operative_device_id = $operativeDeviceId; + if ($newSSOD->save()) { echo 'success added to SSAA'; } else { echo 'error'; @@ -187,6 +193,9 @@ public function actionAdd() } } + /** + * To search the operative devices. + */ public function actionSearch() { if (Yii::app()->request->isAjaxRequest) { From a8c195a2fa17490dada7ab8d6235d0c1f854a615 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 12 Oct 2016 14:48:26 +0530 Subject: [PATCH 026/164] OE-6237 : Have added pupillary abnormalities. --- ...ion_pupillaryabnormalities_abnormality.csv | 3 ++- ...012_084258_add_pupillary_abnormalities.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php diff --git a/protected/modules/OphCiExamination/migrations/data/m130913_000001_consolidation_for_ophciexamination/01_ophciexamination_pupillaryabnormalities_abnormality.csv b/protected/modules/OphCiExamination/migrations/data/m130913_000001_consolidation_for_ophciexamination/01_ophciexamination_pupillaryabnormalities_abnormality.csv index a23e76a2b2..b461087321 100644 --- a/protected/modules/OphCiExamination/migrations/data/m130913_000001_consolidation_for_ophciexamination/01_ophciexamination_pupillaryabnormalities_abnormality.csv +++ b/protected/modules/OphCiExamination/migrations/data/m130913_000001_consolidation_for_ophciexamination/01_ophciexamination_pupillaryabnormalities_abnormality.csv @@ -3,4 +3,5 @@ id,name,display_order 2,"RAPD",20 3,"Holmes-Adie",30 4,"Argyll Robertson",40 -5,"APD",50 \ No newline at end of file +5,"APD",50 +6,"Poor Dilator",60 \ No newline at end of file diff --git a/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php b/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php new file mode 100644 index 0000000000..11fbcbe0ad --- /dev/null +++ b/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php @@ -0,0 +1,19 @@ +insert($this->table, array('name' => $this->pupillaryabnormalities_abnormality, 'display_order' =>'60')); + } + + public function down() + { + $this->delete($this->table, 'name = :name', array(':name' => $this->pupillaryabnormalities_abnormality)); + } + +} \ No newline at end of file From e061edbebae37baa1d4ee934983676161e8aecf2 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 12 Oct 2016 14:50:29 +0530 Subject: [PATCH 027/164] OE-6237 : styling fix --- .../migrations/m161012_084258_add_pupillary_abnormalities.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php b/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php index 11fbcbe0ad..5854c58d83 100644 --- a/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php +++ b/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php @@ -13,7 +13,7 @@ public function up() public function down() { - $this->delete($this->table, 'name = :name', array(':name' => $this->pupillaryabnormalities_abnormality)); + $this->delete($this->table, 'name = :name', array(':name' => $this->pupillaryabnormalities_abnormality)); } } \ No newline at end of file From 0d2244d6ead3bdab0d0a55189bf268f6f8a4e5d5 Mon Sep 17 00:00:00 2001 From: Poornimapriya Sevugarajan Date: Wed, 12 Oct 2016 14:53:52 +0530 Subject: [PATCH 028/164] Oe-6237 : Styling fixes --- ...1012_084258_add_pupillary_abnormalities.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php b/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php index 5854c58d83..925770bbd9 100644 --- a/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php +++ b/protected/modules/OphCiExamination/migrations/m161012_084258_add_pupillary_abnormalities.php @@ -5,15 +5,15 @@ class m161012_084258_add_pupillary_abnormalities extends CDbMigration private $table = 'ophciexamination_pupillaryabnormalities_abnormality'; private $pupillaryabnormalities_abnormality = 'Poor Dilator'; + + public function up() + { + $this->insert($this->table, array('name' => $this->pupillaryabnormalities_abnormality, 'display_order' =>'60')); + } - public function up() - { - $this->insert($this->table, array('name' => $this->pupillaryabnormalities_abnormality, 'display_order' =>'60')); - } - - public function down() - { - $this->delete($this->table, 'name = :name', array(':name' => $this->pupillaryabnormalities_abnormality)); - } + public function down() + { + $this->delete($this->table, 'name = :name', array(':name' => $this->pupillaryabnormalities_abnormality)); + } } \ No newline at end of file From 48852d0e352c205a9a4f811f0bce62bf3dc3c3ac Mon Sep 17 00:00:00 2001 From: Sabi Date: Wed, 12 Oct 2016 17:07:07 +0100 Subject: [PATCH 029/164] OE-6240 : Patient Merge : Move camelCase variable names to underscore --- protected/assets/js/patient_merge.js | 6 +- protected/components/PatientMerge.php | 288 +++++++-------- .../PatientMergeRequestController.php | 150 ++++---- .../unit/components/PatientMergeTest.php | 328 +++++++++--------- protected/views/patientmergerequest/_list.php | 20 +- protected/views/patientmergerequest/_view.php | 47 --- .../views/patientmergerequest/create.php | 2 +- protected/views/patientmergerequest/index.php | 5 +- protected/views/patientmergerequest/log.php | 2 +- protected/views/patientmergerequest/merge.php | 4 +- .../views/patientmergerequest/update.php | 8 +- 11 files changed, 406 insertions(+), 454 deletions(-) diff --git a/protected/assets/js/patient_merge.js b/protected/assets/js/patient_merge.js index 4f777dc185..224cbda66a 100644 --- a/protected/assets/js/patient_merge.js +++ b/protected/assets/js/patient_merge.js @@ -274,10 +274,10 @@ $(document).ready(function(){ if(!isValid){ e.preventDefault(); } - - if( $('#patientDataConflictConfirmation').is(':visible') && !$('#PatientMergeRequest_personalDetailsConflictConfirm').is(':checked') ){ + + if( $('#patientDataConflictConfirmation').is(':visible') && !$('#PatientMergeRequest_personal_details_conflict_confirm').is(':checked') ){ e.preventDefault(); - $('#PatientMergeRequest_personalDetailsConflictConfirm').closest('label').css({"border":'3px solid red',"padding":"5px"}); + $('#PatientMergeRequest_personal_details_conflict_confirm').closest('label').css({"border":'3px solid red',"padding":"5px"}); } if( $('#PatientMergeRequest_confirm').length > 0 && !$('#PatientMergeRequest_confirm').is(':checked') ){ diff --git a/protected/components/PatientMerge.php b/protected/components/PatientMerge.php index 2e5519b38d..9de6d64706 100644 --- a/protected/components/PatientMerge.php +++ b/protected/components/PatientMerge.php @@ -21,12 +21,12 @@ class PatientMerge /** * @var Patient AR */ - private $primaryPatient; + private $primary_patient; /** * @var Patient AR */ - private $secondaryPatient; + private $secondary_patient; /** * @var array @@ -40,7 +40,7 @@ class PatientMerge */ public function setPrimaryPatientById($id) { - $this->primaryPatient = Patient::model()->findByPk($id); + $this->primary_patient = Patient::model()->findByPk($id); } /** @@ -50,7 +50,7 @@ public function setPrimaryPatientById($id) */ public function getPrimaryPatient() { - return $this->primaryPatient; + return $this->primary_patient; } /** @@ -60,7 +60,7 @@ public function getPrimaryPatient() */ public function setSecondaryPatientById($id) { - $this->secondaryPatient = Patient::model()->findByPk($id); + $this->secondary_patient = Patient::model()->findByPk($id); } /** @@ -70,7 +70,7 @@ public function setSecondaryPatientById($id) */ public function getSecondaryPatient() { - return $this->secondaryPatient; + return $this->secondary_patient; } /** @@ -132,7 +132,7 @@ public function comparePatientDetails(Patient $primary, Patient $secondary) } return array( - 'isConflict' => !empty($conflict), + 'is_conflict' => !empty($conflict), 'details' => $conflict, ); } @@ -140,49 +140,49 @@ public function comparePatientDetails(Patient $primary, Patient $secondary) /** * Do the actual merging by calling separated functions to move episodes, events etc... * - * @return bool $isMerged success or fail + * @return bool $is_merged success or fail */ public function merge() { - $isMerged = false; + $is_merged = false; // Update Episode - $isMerged = $this->updateEpisodes($this->primaryPatient, $this->secondaryPatient); + $is_merged = $this->updateEpisodes($this->primary_patient, $this->secondary_patient); // Update legacy episodes - $isMerged = $isMerged && $this->updateLegacyEpisodes($this->primaryPatient, $this->secondaryPatient); + $is_merged = $is_merged && $this->updateLegacyEpisodes($this->primary_patient, $this->secondary_patient); // Update allergyAssignments - $isMerged = $isMerged && $this->updateAllergyAssignments($this->primaryPatient, $this->secondaryPatient); + $is_merged = $is_merged && $this->updateAllergyAssignments($this->primary_patient, $this->secondary_patient); // Updates riskAssignments - $isMerged = $isMerged && $this->updateRiskAssignments($this->primaryPatient->id, $this->secondaryPatient->riskAssignments); + $is_merged = $is_merged && $this->updateRiskAssignments($this->primary_patient->id, $this->secondary_patient->riskAssignments); // Update previousOperations - $isMerged = $isMerged && $this->updatePreviousOperations($this->primaryPatient, $this->secondaryPatient->previousOperations); + $is_merged = $is_merged && $this->updatePreviousOperations($this->primary_patient, $this->secondary_patient->previousOperations); //Update Other ophthalmic diagnoses - $isMerged = $isMerged && $this->updateOphthalmicDiagnoses($this->primaryPatient, $this->secondaryPatient->ophthalmicDiagnoses); + $is_merged = $is_merged && $this->updateOphthalmicDiagnoses($this->primary_patient, $this->secondary_patient->ophthalmicDiagnoses); // Update Systemic Diagnoses - $isMerged = $isMerged && $this->updateSystemicDiagnoses($this->primaryPatient, $this->secondaryPatient->systemicDiagnoses); + $is_merged = $is_merged && $this->updateSystemicDiagnoses($this->primary_patient, $this->secondary_patient->systemicDiagnoses); - if ($isMerged) { - $secondaryPatient = $this->secondaryPatient; + if ($is_merged) { + $secondary_patient = $this->secondary_patient; - $secondaryPatient->deleted = 1; + $secondary_patient->deleted = 1; - if ($secondaryPatient->save()) { - $msg = 'Patient hos_num: '.$this->secondaryPatient->hos_num.' flagged as deleted.'; + if ($secondary_patient->save()) { + $msg = 'Patient hos_num: '.$this->secondary_patient->hos_num.' flagged as deleted.'; $this->addLog($msg); Audit::add('Patient Merge', 'Patient flagged as deleted', $msg); - $isMerged = $isMerged && true; + $is_merged = $is_merged && true; } else { - throw new Exception('Failed to update Patient: '.print_r($secondaryPatient->errors, true)); + throw new Exception('Failed to update Patient: '.print_r($secondary_patient->errors, true)); } } - return $isMerged; + return $is_merged; } /** @@ -193,78 +193,78 @@ public function merge() * - we move the non conflictong episodes from secondary to primary * - when two episodes are conflicting we move the events from the secondary patient's episode to the primary patient's episode then delete the secondary empty episode. * - * @param Patient $primaryPatient - * @param Patient $secondaryPatient + * @param Patient $primary_patient + * @param Patient $secondary_patient * * @return bool * * @throws Exception */ - public function updateEpisodes(Patient $primaryPatient, Patient $secondaryPatient) + public function updateEpisodes(Patient $primary_patient, Patient $secondary_patient) { - $primaryHasEpisodes = $primaryPatient->episodes; - $secondaryHasEpisodes = $secondaryPatient->episodes; + $primary_has_episodes = $primary_patient->episodes; + $secondary_has_episodes = $secondary_patient->episodes; // if primary has no episodes than we just assign the secondary patient's episodes to the primary - if (!$primaryHasEpisodes && $secondaryHasEpisodes) { + if (!$primary_has_episodes && $secondary_has_episodes) { // this case is fine, we can assign the episodes from secondary to primary - $this->updateEpisodesPatientId($primaryPatient->id, $secondaryPatient->episodes); - } elseif ($primaryHasEpisodes && !$secondaryHasEpisodes) { + $this->updateEpisodesPatientId($primary_patient->id, $secondary_patient->episodes); + } elseif ($primary_has_episodes && !$secondary_has_episodes) { // primary has episodes but secondary has not, nothing to do here } else { // Both have episodes, we have to compare the subspecialties - foreach ($secondaryPatient->episodes as $secondaryEpisode) { - $secondary_subspecialty = $secondaryEpisode->getSubspecialtyID(); + foreach ($secondary_patient->episodes as $secondary_episode) { + $secondary_subspecialty = $secondary_episode->getSubspecialtyID(); - $isSameSubspecialty = false; - foreach ($primaryHasEpisodes as $primaryEpisode) { - $primary_subspecialty = $primaryEpisode->getSubspecialtyID(); + $is_same_subspecialty = false; + foreach ($primary_has_episodes as $primary_episode) { + $primary_subspecialty = $primary_episode->getSubspecialtyID(); if ($secondary_subspecialty == $primary_subspecialty) { /* We need to keep the newer/most recent episode so we compare the dates **/ - if ($primaryEpisode->created_date > $secondaryEpisode->created_date) { + if ($primary_episode->created_date > $secondary_episode->created_date) { // the primary episode is older than the secondary so we move the events from the Secondary into the Primary - $this->updateEventsEpisodeId($primaryEpisode->id, $secondaryEpisode->events); + $this->updateEventsEpisodeId($primary_episode->id, $secondary_episode->events); // after all events are moved we flag the secondary episode as deleted - $secondaryEpisode->deleted = 1; - if ($secondaryEpisode->save()) { - $msg = 'Episode '.$secondaryEpisode->id." marked as deleted, events moved under the primary patient's same firm episode."; + $secondary_episode->deleted = 1; + if ($secondary_episode->save()) { + $msg = 'Episode '.$secondary_episode->id." marked as deleted, events moved under the primary patient's same firm episode."; $this->addLog($msg); Audit::add('Patient Merge', 'Episode marked as deleted', $msg); } else { - throw new Exception('Failed to update Episode: '.$secondaryEpisode->id.' '.print_r($secondaryEpisode->errors, true)); + throw new Exception('Failed to update Episode: '.$secondary_episode->id.' '.print_r($secondary_episode->errors, true)); } } else { // the secondary episode is older than the primary so we move the events from the Primary into the Secondary - $this->updateEventsEpisodeId($secondaryEpisode->id, $primaryEpisode->events); + $this->updateEventsEpisodeId($secondary_episode->id, $primary_episode->events); /* BUT do not forget we have to delete the primary episode AND move the secondary episode to the primary patient **/ - $primaryEpisode->deleted = 1; + $primary_episode->deleted = 1; - if ($primaryEpisode->save()) { - $msg = 'Episode '.$primaryEpisode->id." marked as deleted, events moved under the secondary patient's same firm episode."; + if ($primary_episode->save()) { + $msg = 'Episode '.$primary_episode->id." marked as deleted, events moved under the secondary patient's same firm episode."; $this->addLog($msg); Audit::add('Patient Merge', 'Episode marked as deleted', $msg); } else { - throw new Exception('Failed to update Episode: '.$primaryEpisode->id.' '.print_r($primaryEpisode->errors, true)); + throw new Exception('Failed to update Episode: '.$primary_episode->id.' '.print_r($primary_episode->errors, true)); } //then we move the episode to the pri1mary - $this->updateEpisodesPatientId($primaryPatient->id, array($secondaryEpisode)); + $this->updateEpisodesPatientId($primary_patient->id, array($secondary_episode)); } - $isSameSubspecialty = true; + $is_same_subspecialty = true; } } // if there is no conflict we still need to move the secondary episode to the primary patient - if (!$isSameSubspecialty) { - $this->updateEpisodesPatientId($primaryPatient->id, array($secondaryEpisode)); + if (!$is_same_subspecialty) { + $this->updateEpisodesPatientId($primary_patient->id, array($secondary_episode)); } else { // there was a conflict and the episode was already moved in the foreach above } @@ -278,49 +278,49 @@ public function updateEpisodes(Patient $primaryPatient, Patient $secondaryPatien /** * Moving Legacy episode from secondary patient to primary. * - * @param type $primaryPatient - * @param type $secondaryPatient + * @param type $primary_patient + * @param type $secondary_patient * * @return bool * * @throws Exception */ - public function updateLegacyEpisodes($primaryPatient, $secondaryPatient) + public function updateLegacyEpisodes($primary_patient, $secondary_patient) { // if the secondary patient has legacy episodes - if ($secondaryPatient->legacyepisodes) { + if ($secondary_patient->legacyepisodes) { // if primary patient doesn't have legacy episode we can just update the episode's patient_id to assign it to the primary patient - if (!$primaryPatient->legacyepisodes) { + if (!$primary_patient->legacyepisodes) { // Patient can have only one legacy episode - $legacyEpisode = $secondaryPatient->legacyepisodes[0]; + $legacy_episode = $secondary_patient->legacyepisodes[0]; - $legacyEpisode->patient_id = $primaryPatient->id; - if ($legacyEpisode->save()) { - $msg = 'Legacy Episode '.$legacyEpisode->id.' moved from patient '.$secondaryPatient->hos_num.' to '.$primaryPatient->hos_num; + $legacy_episode->patient_id = $primary_patient->id; + if ($legacy_episode->save()) { + $msg = 'Legacy Episode '.$legacy_episode->id.' moved from patient '.$secondary_patient->hos_num.' to '.$primary_patient->hos_num; $this->addLog($msg); Audit::add('Patient Merge', 'Legacy Episode moved', $msg); } else { - throw new Exception('Failed to update (legacy) Episode: '.$legacyEpisode->id.' '.print_r($legacyEpisode->errors, true)); + throw new Exception('Failed to update (legacy) Episode: '.$legacy_episode->id.' '.print_r($legacy_episode->errors, true)); } } else { - $primaryLegacyEpisode = $primaryPatient->legacyepisodes[0]; - $secondaryLegacyEpisode = $secondaryPatient->legacyepisodes[0]; + $primary_legacy_episode = $primary_patient->legacyepisodes[0]; + $secondary_legacy_episode = $secondary_patient->legacyepisodes[0]; - if ($primaryLegacyEpisode->created_date < $secondaryLegacyEpisode->created_date) { + if ($primary_legacy_episode->created_date < $secondary_legacy_episode->created_date) { // we move the events from the secondaty patient's legacy episod to the primary patient's legacy epiode - $this->updateEventsEpisodeId($primaryLegacyEpisode->id, $secondaryLegacyEpisode->events); + $this->updateEventsEpisodeId($primary_legacy_episode->id, $secondary_legacy_episode->events); // Flag secondary patient's legacy episode deleted as it will be empty - $secondaryLegacyEpisode->deleted = 1; - if ($secondaryLegacyEpisode->save()) { - $msg = 'Legacy Episode '.$secondaryLegacyEpisode->id."marked as deleted, events moved under the primary patient's same firm episode."; + $secondary_legacy_episode->deleted = 1; + if ($secondary_legacy_episode->save()) { + $msg = 'Legacy Episode '.$secondary_legacy_episode->id."marked as deleted, events moved under the primary patient's same firm episode."; $this->addLog($msg); Audit::add('Patient Merge', 'Legacy Episode marked as deleted', $msg); } else { - throw new Exception('Failed to update (legacy) Episode: '.$secondaryLegacyEpisode->id.' '.print_r($secondaryLegacyEpisode->errors, true)); + throw new Exception('Failed to update (legacy) Episode: '.$secondary_legacy_episode->id.' '.print_r($secondary_legacy_episode->errors, true)); } } else { // in this case the secondary legacy episode is older than the primary @@ -328,20 +328,20 @@ public function updateLegacyEpisodes($primaryPatient, $secondaryPatient) // then move the secondary legacy episode to the Primary patient // then flag the primary's legacy episode as deleted // as only 1 legacy episode can be assigned to the patient - $this->updateEventsEpisodeId($secondaryLegacyEpisode->id, $primaryLegacyEpisode->events); + $this->updateEventsEpisodeId($secondary_legacy_episode->id, $primary_legacy_episode->events); - $primaryLegacyEpisode->deleted = 1; + $primary_legacy_episode->deleted = 1; - if ($primaryLegacyEpisode->save()) { - $msg = 'Legacy Episode '.$primaryLegacyEpisode->id."marked as deleted, events moved under the secondary patient's same firm episode."; + if ($primary_legacy_episode->save()) { + $msg = 'Legacy Episode '.$primary_legacy_episode->id."marked as deleted, events moved under the secondary patient's same firm episode."; $this->addLog($msg); Audit::add('Patient Merge', 'Legacy Episode marked as deleted', $msg); } else { - throw new Exception('Failed to update (legacy) Episode: '.$primaryLegacyEpisode->id.' '.print_r($primaryLegacyEpisode->errors, true)); + throw new Exception('Failed to update (legacy) Episode: '.$primary_legacy_episode->id.' '.print_r($primary_legacy_episode->errors, true)); } //then we move the episode to the pri1mary - $this->updateEpisodesPatientId($primaryPatient->id, array($secondaryLegacyEpisode)); + $this->updateEpisodesPatientId($primary_patient->id, array($secondary_legacy_episode)); } } } @@ -353,64 +353,64 @@ public function updateLegacyEpisodes($primaryPatient, $secondaryPatient) /** * Updates the patient id in the Allergy Assigment. * - * @param int $newPatientId Primary patient id + * @param int $new_patient_id Primary patient id * @param array of AR $allergies * * @throws Exception AllergyAssigment cannot be saved */ - public function updateAllergyAssignments($primaryPatient, $secondaryPatient) + public function updateAllergyAssignments($primary_patient, $secondary_patient) { - $primaryAssignments = $primaryPatient->allergyAssignments; - $secondaryAssignments = $secondaryPatient->allergyAssignments; - - if (!$primaryAssignments && $secondaryAssignments) { - foreach ($secondaryAssignments as $allergyAssignment) { - $msg = 'AllergyAssignment '.$allergyAssignment->id.' moved from patient '.$allergyAssignment->patient->hos_num.' to '.$primaryPatient->hos_num; - $allergyAssignment->patient_id = $primaryPatient->id; - if ($allergyAssignment->save()) { + $primary_assignments = $primary_patient->allergyAssignments; + $secondary_assignments = $secondary_patient->allergyAssignments; + + if (!$primary_assignments && $secondary_assignments) { + foreach ($secondary_assignments as $allergy_assignment) { + $msg = 'AllergyAssignment '.$allergy_assignment->id.' moved from patient '.$allergy_assignment->patient->hos_num.' to '.$primary_patient->hos_num; + $allergy_assignment->patient_id = $primary_patient->id; + if ($allergy_assignment->save()) { $this->addLog($msg); Audit::add('Patient Merge', 'AllergyAssignment moved patient', $msg); } else { - throw new Exception('Failed to update AllergyAssigment: '.$allergyAssignment->id.' '.print_r($allergyAssignment->errors, true)); + throw new Exception('Failed to update AllergyAssigment: '.$allergy_assignment->id.' '.print_r($allergy_assignment->errors, true)); } } - } elseif ($primaryAssignments && $secondaryAssignments) { - foreach ($secondaryAssignments as $secondaryAssignment) { - $sameAssignment = false; - foreach ($primaryAssignments as $primaryAssignment) { - if ($primaryAssignment->allergy_id == $secondaryAssignment->allergy_id) { + } elseif ($primary_assignments && $secondary_assignments) { + foreach ($secondary_assignments as $secondary_assignment) { + $same_assignment = false; + foreach ($primary_assignments as $primary_assignment) { + if ($primary_assignment->allergy_id == $secondary_assignment->allergy_id) { // the allergy is already present in the primary patient's record so we just update the 'comment' and 'other' fields - $sameAssignment = true; + $same_assignment = true; - $comments = $primaryAssignment->comments.' ; '.$secondaryAssignment->comments; - $other = $primaryAssignment->other.' ; '.$secondaryAssignment->other; + $comments = $primary_assignment->comments.' ; '.$secondary_assignment->comments; + $other = $primary_assignment->other.' ; '.$secondary_assignment->other; - $primaryAssignment->comments = $comments; - $primaryAssignment->other = $other; + $primary_assignment->comments = $comments; + $primary_assignment->other = $other; - if ($primaryAssignment->save()) { + if ($primary_assignment->save()) { $msg = "AllergyAssignment 'comments' and 'other' updated"; $this->addLog($msg); Audit::add('Patient Merge', 'AllergyAssignment updated', $msg); } else { - throw new Exception('Failed to update AllergyAssigment: '.$primaryAssignment->id.' '.print_r($primaryAssignment->errors, true)); + throw new Exception('Failed to update AllergyAssigment: '.$primary_assignment->id.' '.print_r($primary_assignment->errors, true)); } // as we just copied the comments and other fields we remove the assignment - $secondaryAssignment->delete(); + $secondary_assignment->delete(); } } // This means we have to move the assignment from secondary to primary - if (!$sameAssignment) { - $secondaryAssignment->patient_id = $primaryPatient->id; - if ($secondaryAssignment->save()) { - $msg = 'AllergyAssignment '.$secondaryAssignment->id.' moved from patient '.$secondaryPatient->hos_num.' to '.$primaryPatient->hos_num; + if (!$same_assignment) { + $secondary_assignment->patient_id = $primary_patient->id; + if ($secondary_assignment->save()) { + $msg = 'AllergyAssignment '.$secondary_assignment->id.' moved from patient '.$secondary_patient->hos_num.' to '.$primary_patient->hos_num; $this->addLog($msg); Audit::add('Patient Merge', 'AllergyAssignment moved from patient', $msg); } else { - throw new Exception('Failed to update AllergyAssigment: '.$allergyAssignment->id.' '.print_r($allergyAssignment->errors, true)); + throw new Exception('Failed to update AllergyAssigment: '.$allergy_assignment->id.' '.print_r($allergy_assignment->errors, true)); } } } @@ -422,21 +422,21 @@ public function updateAllergyAssignments($primaryPatient, $secondaryPatient) /** * Updates patient id in Risk Assignment. * - * @param int $newPatientId + * @param int $new_patient_id * @param array of AR $risks * * @throws Exception Failed to save RiskAssigment */ - public function updateRiskAssignments($newPatientId, $riskAssignments) + public function updateRiskAssignments($new_patient_id, $risk_assignments) { - foreach ($riskAssignments as $riskAssignment) { - $msg = 'RiskAssignment '.$riskAssignment->id.' moved from patient '.$riskAssignment->patient->hos_num.' to '.$newPatientId; - $riskAssignment->patient_id = $newPatientId; - if ($riskAssignment->save()) { + foreach ($risk_assignments as $risk_assignment) { + $msg = 'RiskAssignment '.$risk_assignment->id.' moved from patient '.$risk_assignment->patient->hos_num.' to '.$new_patient_id; + $risk_assignment->patient_id = $new_patient_id; + if ($risk_assignment->save()) { $this->addLog($msg); Audit::add('Patient Merge', 'RiskAssignment moved patient', $msg); } else { - throw new Exception('Failed to update RiskAssigment: '.$riskAssignment->id.' '.print_r($riskAssignment->errors, true)); + throw new Exception('Failed to update RiskAssigment: '.$risk_assignment->id.' '.print_r($risk_assignment->errors, true)); } } @@ -446,24 +446,24 @@ public function updateRiskAssignments($newPatientId, $riskAssignments) /** * Moving previous operations from secondaty patient to primary. * - * @param Patient $newPatient - * @param type $previousOperations + * @param Patient $new_patient + * @param type $previous_operations * * @return bool * * @throws Exception */ - public function updatePreviousOperations($newPatient, $previousOperations) + public function updatePreviousOperations($new_patient, $previous_operations) { - foreach ($previousOperations as $previousOperation) { - $msg = 'Previous Operation '.$previousOperation->id.' moved from Patient ' . $previousOperation->patient->hos_num.' to '.$newPatient->hos_num; - $previousOperation->patient_id = $newPatient->id; - if ($previousOperation->save()) { + foreach ($previous_operations as $previous_operation) { + $msg = 'Previous Operation '.$previous_operation->id.' moved from Patient ' . $previous_operation->patient->hos_num.' to '.$new_patient->hos_num; + $previous_operation->patient_id = $new_patient->id; + if ($previous_operation->save()) { $this->addLog($msg); Audit::add('Patient Merge', 'Previous Operation moved patient', $msg); } else { - throw new Exception('Failed to update Previous Operation: ' . $previousOperation->id.' ' . print_r($previousOperation->errors, true)); + throw new Exception('Failed to update Previous Operation: ' . $previous_operation->id.' ' . print_r($previous_operation->errors, true)); } } @@ -473,20 +473,20 @@ public function updatePreviousOperations($newPatient, $previousOperations) /** * Updates the Ophthalmic Diagnoses' patient_id * - * @param Patient $newPatient - * @param type $ophthalmicDiagnoses + * @param Patient $new_patient + * @param type $ophthalmic_diagnoses * @throws Exception */ - public function updateOphthalmicDiagnoses($newPatient, $ophthalmicDiagnoses) + public function updateOphthalmicDiagnoses($new_patient, $ophthalmic_diagnoses) { - foreach ($ophthalmicDiagnoses as $ophthalmicDiagnosis) { - $msg = 'Ophthalmic Diagnosis(SecondaryDiagnosis) ' . $ophthalmicDiagnosis->id . ' moved from Patient ' . $ophthalmicDiagnosis->patient->hos_num . ' to ' . $newPatient->hos_num; - $ophthalmicDiagnosis->patient_id = $newPatient->id; - if ($ophthalmicDiagnosis->save()) { + foreach ($ophthalmic_diagnoses as $ophthalmic_diagnosis) { + $msg = 'Ophthalmic Diagnosis(SecondaryDiagnosis) ' . $ophthalmic_diagnosis->id . ' moved from Patient ' . $ophthalmic_diagnosis->patient->hos_num . ' to ' . $new_patient->hos_num; + $ophthalmic_diagnosis->patient_id = $new_patient->id; + if ($ophthalmic_diagnosis->save()) { $this->addLog($msg); Audit::add('Patient Merge', 'Ophthalmic Diagnosis(SecondaryDiagnosis) moved patient', $msg); } else { - throw new Exception('Failed to update Ophthalmic Diagnosis(SecondaryDiagnosis): ' . $ophthalmicDiagnosis->id . ' ' . print_r($ophthalmicDiagnosis->errors, true)); + throw new Exception('Failed to update Ophthalmic Diagnosis(SecondaryDiagnosis): ' . $ophthalmic_diagnosis->id . ' ' . print_r($ophthalmic_diagnosis->errors, true)); } } @@ -496,21 +496,21 @@ public function updateOphthalmicDiagnoses($newPatient, $ophthalmicDiagnoses) /** * Update Systemati Diagnoses' patient id * - * @param Patient $newPatient - * @param type $systemicDiagnoses + * @param Patient $new_patient + * @param type $systemic_diagnoses * @return boolean * @throws Exception */ - public function updateSystemicDiagnoses($newPatient, $systemicDiagnoses) + public function updateSystemicDiagnoses($new_patient, $systemic_diagnoses) { - foreach ($systemicDiagnoses as $systemicDiagnosis) { - $msg = 'Systemic Diagnoses ' . $systemicDiagnosis->id . ' moved from Patient ' . $systemicDiagnosis->patient->hos_num . ' to ' . $newPatient->hos_num; - $systemicDiagnosis->patient_id = $newPatient->id; - if ($systemicDiagnosis->save()) { + foreach ($systemic_diagnoses as $systemic_diagnosis) { + $msg = 'Systemic Diagnoses ' . $systemic_diagnosis->id . ' moved from Patient ' . $systemic_diagnosis->patient->hos_num . ' to ' . $new_patient->hos_num; + $systemic_diagnosis->patient_id = $new_patient->id; + if ($systemic_diagnosis->save()) { $this->addLog($msg); Audit::add('Patient Merge', 'Systemic Diagnoses moved patient', $msg); } else { - throw new Exception('Failed to update Systemic Diagnoses: ' . $systemicDiagnosis->id . ' ' . print_r($systemicDiagnosis->errors, true)); + throw new Exception('Failed to update Systemic Diagnoses: ' . $systemic_diagnosis->id . ' ' . print_r($systemic_diagnosis->errors, true)); } } @@ -527,17 +527,17 @@ public function updateSystemicDiagnoses($newPatient, $systemicDiagnoses) * * @return bool true if no error thrown */ - public function updateEpisodesPatientId($newPatientId, $episodes) + public function updateEpisodesPatientId($new_patient_id, $episodes) { foreach ($episodes as $episode) { - $msg = 'Episode '.$episode->id.' moved from patient '.$episode->patient_id.' to '.$newPatientId; - $episode->patient_id = $newPatientId; + $msg = 'Episode '.$episode->id.' moved from patient '.$episode->patient_id.' to '.$new_patient_id; + $episode->patient_id = $new_patient_id; if ($episode->save()) { $this->addLog($msg); Audit::add('Patient Merge', 'Episode moved patient', $msg); } else { - throw new Exception('Failed to save Episode: '.print_r($secondaryPatient->errors, true)); + throw new Exception('Failed to save Episode: '.print_r($secondary_patient->errors, true)); } } @@ -547,19 +547,19 @@ public function updateEpisodesPatientId($newPatientId, $episodes) /** * Moving event from one episode to another. * - * @param int $newEpisodeId + * @param int $new_episode_id * @param array $events * * @return bool * * @throws Exception */ - public function updateEventsEpisodeId($newEpisodeId, $events) + public function updateEventsEpisodeId($new_episode_id, $events) { foreach ($events as $event) { - $msg = 'Event '.$event->id.' moved from Episode '.$event->episode_id.' to '.$newEpisodeId; + $msg = 'Event '.$event->id.' moved from Episode '.$event->episode_id.' to '.$new_episode_id; - $event->episode_id = $newEpisodeId; + $event->episode_id = $new_episode_id; if ($event->save()) { $this->addLog($msg); diff --git a/protected/controllers/PatientMergeRequestController.php b/protected/controllers/PatientMergeRequestController.php index d08ebc70b5..2903ba4a97 100644 --- a/protected/controllers/PatientMergeRequestController.php +++ b/protected/controllers/PatientMergeRequestController.php @@ -94,12 +94,12 @@ public function actionIndex() $criteria->params[':status'] = PatientMergeRequest::STATUS_NOT_PROCESSED; } - $itemsCount = PatientMergeRequest::model()->count($criteria); - $pagination = new CPagination($itemsCount); + $items_count = PatientMergeRequest::model()->count($criteria); + $pagination = new CPagination($items_count); $pagination->pageSize = 15; $pagination->applyLimit($criteria); - $dataProvider = new CActiveDataProvider('PatientMergeRequest', array( + $data_provider = new CActiveDataProvider('PatientMergeRequest', array( 'criteria' => $criteria, 'pagination' => $pagination, 'sort' => array( @@ -108,7 +108,7 @@ public function actionIndex() )); $this->render('//patientmergerequest/index', array( - 'dataProvider' => $dataProvider, + 'data_provider' => $data_provider, 'filters' => $filters, )); } @@ -116,13 +116,13 @@ public function actionIndex() public function actionCreate() { $model = new PatientMergeRequest(); - $mergeHandler = new PatientMerge(); - $patientMergeRequest = Yii::app()->request->getParam('PatientMergeRequest', null); - $personalDetailsConflictConfirm = null; + $merge_handler = new PatientMerge(); + $patient_merge_request = Yii::app()->request->getParam('PatientMergeRequest', null); + $personal_details_conflict_confirm = null; - if ($patientMergeRequest && isset($patientMergeRequest['primary_id']) && isset($patientMergeRequest['secondary_id'])) { - $primaryPatient = Patient::model()->findByPk($patientMergeRequest['primary_id']); - $secondaryPatient = Patient::model()->findByPk($patientMergeRequest['secondary_id']); + if ($patient_merge_request && isset($patient_merge_request['primary_id']) && isset($patient_merge_request['secondary_id'])) { + $primary_patient = Patient::model()->findByPk($patient_merge_request['primary_id']); + $secondary_patient = Patient::model()->findByPk($patient_merge_request['secondary_id']); //check if the patients' ids are already submited // we do not allow the same patient id in the list multiple times @@ -136,37 +136,37 @@ public function actionCreate() //we allow primary patients only if it has no active/unmerged requests $criteria->condition .= 'AND ( (primary_id=@primary AND STATUS != 20) OR (primary_id=@secondary AND STATUS != 20) )'; - $criteria->params = array(':primary_id' => $patientMergeRequest['primary_id'], ':secondary_id' => $patientMergeRequest['secondary_id']); + $criteria->params = array(':primary_id' => $patient_merge_request['primary_id'], ':secondary_id' => $patient_merge_request['secondary_id']); - $numbersNotUnique = PatientMergeRequest::model()->find($criteria); + $numbers_not_unique = PatientMergeRequest::model()->find($criteria); - $personalDetailsConflictConfirm = $mergeHandler->comparePatientDetails($primaryPatient, $secondaryPatient); + $personal_details_conflict_confirm = $merge_handler->comparePatientDetails($primary_patient, $secondary_patient); - if (empty($numbersNotUnique) && (!$personalDetailsConflictConfirm['isConflict'] || ($personalDetailsConflictConfirm['isConflict'] && isset($patientMergeRequest['personalDetailsConflictConfirm'])))) { + if (empty($numbers_not_unique) && (!$personal_details_conflict_confirm['is_conflict'] || ($personal_details_conflict_confirm['is_conflict'] && isset($patient_merge_request['personal_details_conflict_confirm'])))) { // the Primary and Secondary user cannot be the same user , same database record I mean - if ((!empty($patientMergeRequest['secondary_id']) && !empty($patientMergeRequest['primary_id'])) && $patientMergeRequest['secondary_id'] == $patientMergeRequest['primary_id']) { + if ((!empty($patient_merge_request['secondary_id']) && !empty($patient_merge_request['primary_id'])) && $patient_merge_request['secondary_id'] == $patient_merge_request['primary_id']) { Yii::app()->user->setFlash('warning.merge_error', 'The Primary and Secondary patient cannot be the same. Record cannot be merged into itself.'); } else { - if (empty($patientMergeRequest['secondary_id']) || empty($patientMergeRequest['primary_id'])) { + if (empty($patient_merge_request['secondary_id']) || empty($patient_merge_request['primary_id'])) { Yii::app()->user->setFlash('warning.merge_error', 'Both Primary and Secondary patients have to be selected.'); } else { - $model->attributes = $patientMergeRequest; + $model->attributes = $patient_merge_request; if ($model->save()) { $this->redirect(array('index')); } } } - } elseif ($personalDetailsConflictConfirm['isConflict'] && !isset($patientMergeRequest['personalDetailsConflictConfirm'])) { + } elseif ($personal_details_conflict_confirm['is_conflict'] && !isset($patient_merge_request['personal_details_conflict_confirm'])) { Yii::app()->user->setFlash('warning.user_error', 'Please tick the checkboxes.'); - } elseif ($numbersNotUnique) { + } elseif ($numbers_not_unique) { Yii::app()->user->setFlash('warning.merge_error_duplicate', 'One of the Hospital Numbers are already in the Patient Merge Request list, please merge them first.'); $this->redirect(array('index')); } } - if ($personalDetailsConflictConfirm && $personalDetailsConflictConfirm['isConflict'] == true) { - foreach ($personalDetailsConflictConfirm['details'] as $conflict) { + if ($personal_details_conflict_confirm && $personal_details_conflict_confirm['is_conflict'] == true) { + foreach ($personal_details_conflict_confirm['details'] as $conflict) { Yii::app()->user->setFlash('warning.merge_error_'.$conflict['column'], 'Patients have different personal details : '.$conflict['column']); } } @@ -195,7 +195,7 @@ public function actionLog($id) $this->render('//patientmergerequest/log', array( 'model' => $model, - 'dataProvider' => new CArrayDataProvider($log), + 'data_provider' => new CArrayDataProvider($log), )); } @@ -221,37 +221,37 @@ public function actionView($id) */ public function actionUpdate($id) { - $mergeRequest = $this->loadModel($id); - $mergeHandler = new PatientMerge(); + $merge_request = $this->loadModel($id); + $merge_handler = new PatientMerge(); // if the personal details are conflictng (DOB and Gender at the moment) we need extra confirmation - $personalDetailsConflictConfirm = $mergeHandler->comparePatientDetails($mergeRequest->primaryPatient, $mergeRequest->secondaryPatient); - if ($personalDetailsConflictConfirm && $personalDetailsConflictConfirm['isConflict'] == true) { - foreach ($personalDetailsConflictConfirm['details'] as $conflict) { + $personal_details_conflict_confirm = $merge_handler->comparePatientDetails($merge_request->primaryPatient, $merge_request->secondaryPatient); + if ($personal_details_conflict_confirm && $personal_details_conflict_confirm['is_conflict'] == true) { + foreach ($personal_details_conflict_confirm['details'] as $conflict) { Yii::app()->user->setFlash('warning.merge_error_'.$conflict['column'], 'Patients have different personal details : '.$conflict['column']); } } if (isset($_POST['PatientMergeRequest'])) { - if (!$personalDetailsConflictConfirm['isConflict'] || ($personalDetailsConflictConfirm['isConflict'] && isset($_POST['PatientMergeRequest']['personalDetailsConflictConfirm']))) { - $mergeRequest->attributes = $_POST['PatientMergeRequest']; - if ($mergeRequest->status == PatientMergeRequest::STATUS_MERGED) { - $this->redirect(array('view', 'id' => $mergeRequest->id)); - } elseif ($mergeRequest->save()) { + if (!$personal_details_conflict_confirm['is_conflict'] || ($personal_details_conflict_confirm['is_conflict'] && isset($_POST['PatientMergeRequest']['personal_details_conflict_confirm']))) { + $merge_request->attributes = $_POST['PatientMergeRequest']; + if ($merge_request->status == PatientMergeRequest::STATUS_MERGED) { + $this->redirect(array('view', 'id' => $merge_request->id)); + } elseif ($merge_request->save()) { $this->redirect(array('index')); } - } elseif ($personalDetailsConflictConfirm['isConflict'] && !isset($_POST['PatientMergeRequest']['personalDetailsConflictConfirm'])) { + } elseif ($personal_details_conflict_confirm['is_conflict'] && !isset($_POST['PatientMergeRequest']['personal_details_conflict_confirm'])) { Yii::app()->user->setFlash('warning.user_error', 'Please tick the checkboxes.'); } } - $primary = Patient::model()->findByPk($mergeRequest->primary_id); - $secondary = Patient::model()->findByPk($mergeRequest->secondary_id); + $primary = Patient::model()->findByPk($merge_request->primary_id); + $secondary = Patient::model()->findByPk($merge_request->secondary_id); $this->render('//patientmergerequest/update', array( - 'model' => $mergeRequest, - 'personalDetailsConflictConfirm' => $personalDetailsConflictConfirm['isConflict'], - 'primaryPatientJSON' => CJavaScript::jsonEncode(array( + 'model' => $merge_request, + 'personal_details_conflict_confirm' => $personal_details_conflict_confirm['is_conflict'], + 'primary_patient_JSON' => CJavaScript::jsonEncode(array( 'id' => $primary->id, 'first_name' => $primary->first_name, 'last_name' => $primary->last_name, @@ -265,7 +265,7 @@ public function actionUpdate($id) ) ), - 'secondaryPatientJSON' => CJavaScript::jsonEncode(array( + 'secondary_patient_JSON' => CJavaScript::jsonEncode(array( 'id' => $secondary->id, 'first_name' => $secondary->first_name, 'last_name' => $secondary->last_name, @@ -288,19 +288,19 @@ public function actionUpdate($id) */ public function actionMerge($id) { - $mergeRequest = $this->loadModel($id); + $merge_request = $this->loadModel($id); //if the model already merged we just redirect to the index page - if ($mergeRequest->status == PatientMergeRequest::STATUS_MERGED) { + if ($merge_request->status == PatientMergeRequest::STATUS_MERGED) { $this->redirect(array('index')); } - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); // if the personal details are conflictng (DOB and Gender at the moment) we need extra confirmation - $personalDetailsConflictConfirm = $mergeHandler->comparePatientDetails($mergeRequest->primaryPatient, $mergeRequest->secondaryPatient); - if ($personalDetailsConflictConfirm && $personalDetailsConflictConfirm['isConflict'] == true) { - foreach ($personalDetailsConflictConfirm['details'] as $conflict) { + $personal_details_conflict_confirm = $merge_handler->comparePatientDetails($merge_request->primaryPatient, $merge_request->secondaryPatient); + if ($personal_details_conflict_confirm && $personal_details_conflict_confirm['is_conflict'] == true) { + foreach ($personal_details_conflict_confirm['details'] as $conflict) { Yii::app()->user->setFlash('warning.merge_error_'.$conflict['column'], 'Patients have different personal details : '.$conflict['column']); } } @@ -309,48 +309,48 @@ public function actionMerge($id) // if personal details are not conflictin than its fine, // but if there is a conflict we need the extra confirmation - if (!$personalDetailsConflictConfirm['isConflict'] || ($personalDetailsConflictConfirm['isConflict'] && isset($_POST['PatientMergeRequest']['personalDetailsConflictConfirm']))) { + if (!$personal_details_conflict_confirm['is_conflict'] || ($personal_details_conflict_confirm['is_conflict'] && isset($_POST['PatientMergeRequest']['personal_details_conflict_confirm']))) { // Load data from PatientMergeRequest AR record - $mergeHandler->load($mergeRequest); - - if ($mergeHandler->merge()) { - $msg = 'Merge Request '.$mergeRequest->secondaryPatient->hos_num.' INTO '.$mergeRequest->primaryPatient->hos_num.'(hos_num) successfully done.'; - $mergeHandler->addLog($msg); - $mergeRequest->status = $mergeRequest::STATUS_MERGED; - $mergeRequest->merge_json = json_encode(array('log' => $mergeHandler->getLog())); - $mergeRequest->save(); + $merge_handler->load($merge_request); + + if ($merge_handler->merge()) { + $msg = 'Merge Request '.$merge_request->secondaryPatient->hos_num.' INTO '.$merge_request->primaryPatient->hos_num.'(hos_num) successfully done.'; + $merge_handler->addLog($msg); + $merge_request->status = $merge_request::STATUS_MERGED; + $merge_request->merge_json = json_encode(array('log' => $merge_handler->getLog())); + $merge_request->save(); Audit::add('Patient Merge', $msg); - $this->redirect(array('log', 'id' => $mergeRequest->id)); + $this->redirect(array('log', 'id' => $merge_request->id)); } else { - $msg = 'Merge Request '.$mergeRequest->secondaryPatient->hos_num.' INTO '.$mergeRequest->primaryPatient->hos_num.' FAILED.'; - $mergeHandler->addLog($msg); - $mergeRequest->status = $mergeRequest::STATUS_CONFLICT; - $mergeRequest->merge_json = json_encode(array('log' => $mergeHandler->getLog())); - $mergeRequest->save(); + $msg = 'Merge Request '.$merge_request->secondaryPatient->hos_num.' INTO '.$merge_request->primaryPatient->hos_num.' FAILED.'; + $merge_handler->addLog($msg); + $merge_request->status = $merge_request::STATUS_CONFLICT; + $merge_request->merge_json = json_encode(array('log' => $merge_handler->getLog())); + $merge_request->save(); Yii::app()->user->setFlash('warning.search_error', 'Merge failed.'); $this->redirect(array('index')); } } } - $primary = Patient::model()->findByPk($mergeRequest->primary_id); - $secondary = Patient::model()->findByPk($mergeRequest->secondary_id); + $primary = Patient::model()->findByPk($merge_request->primary_id); + $secondary = Patient::model()->findByPk($merge_request->secondary_id); $this->render('//patientmergerequest/merge', array( - 'model' => $mergeRequest, - 'personalDetailsConflictConfirm' => $personalDetailsConflictConfirm['isConflict'], + 'model' => $merge_request, + 'personal_details_conflict_confirm' => $personal_details_conflict_confirm['is_conflict'], )); } public function actionDelete() { - if (isset($_POST['patientMergeRequestIds'])) { + if (isset($_POST['patient_merge_request_ids'])) { $criteria = new CDbCriteria(); $criteria->condition = 't.status = '.PatientMergeRequest::STATUS_NOT_PROCESSED; - $requests = PatientMergeRequest::model()->findAllByPk($_POST['patientMergeRequestIds'], $criteria); + $requests = PatientMergeRequest::model()->findAllByPk($_POST['patient_merge_request_ids'], $criteria); foreach ($requests as $request) { $request->deleted = 1; @@ -402,9 +402,9 @@ public function isPatientInRequestList($patientId) $criteria->params = array(':patient_id' => $patientId); - $mergeRequest = PatientMergeRequest::model()->find($criteria); + $merge_request = PatientMergeRequest::model()->find($criteria); - return $mergeRequest ? ($mergeRequest->primary_id == $patientId ? 'primary' : 'secondary') : null; + return $merge_request ? ($merge_request->primary_id == $patientId ? 'primary' : 'secondary') : null; } public function actionSearch() @@ -412,17 +412,17 @@ public function actionSearch() $term = trim(\Yii::app()->request->getParam('term', '')); $result = array(); - $patientSearch = new PatientSearch(); + $patient_search = new PatientSearch(); - if ($patientSearch->isValidSearchTerm($term)) { - $dataProvider = $patientSearch->search($term); - foreach ($dataProvider->getData() as $patient) { + if ($patient_search->isValidSearchTerm($term)) { + $data_provider = $patient_search->search($term); + foreach ($data_provider->getData() as $patient) { // check if the patient is already in the Request List $warning = ''; - $isInList = $this->isPatientInRequestList($patient->id); - if ($isInList) { - $warning = "This patient is already requested for merge as $isInList patient."; + $is_in_list = $this->isPatientInRequestList($patient->id); + if ($is_in_list) { + $warning = "This patient is already requested for merge as $is_in_list patient."; } $result[] = array( diff --git a/protected/tests/unit/components/PatientMergeTest.php b/protected/tests/unit/components/PatientMergeTest.php index baf09fd135..596273331e 100644 --- a/protected/tests/unit/components/PatientMergeTest.php +++ b/protected/tests/unit/components/PatientMergeTest.php @@ -43,26 +43,26 @@ public function setUp() public function testComparePatientDetails() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); - $result = $mergeHandler->comparePatientDetails($primaryPatient, $secondaryPatient); + $result = $merge_handler->comparePatientDetails($primary_patient, $secondary_patient); $this->assertTrue(is_array($result)); - $this->assertFalse($result['isConflict'], 'Personal details should be the same at this point.'); + $this->assertFalse($result['is_conflict'], 'Personal details should be the same at this point.'); $this->assertEmpty($result['details']); // Change the dob and gender - $primaryPatient->gender = 'M'; - $primaryPatient->dob = '1981-12-21'; + $primary_patient->gender = 'M'; + $primary_patient->dob = '1981-12-21'; - $primaryPatient->save(); + $primary_patient->save(); - $result = $mergeHandler->comparePatientDetails($primaryPatient, $secondaryPatient); + $result = $merge_handler->comparePatientDetails($primary_patient, $secondary_patient); - $this->assertTrue($result['isConflict'], 'Personal details should NOT be the same. Both DOB and Gender are different at this point.'); + $this->assertTrue($result['is_conflict'], 'Personal details should NOT be the same. Both DOB and Gender are different at this point.'); $this->assertEquals($result['details'][0]['column'], 'dob'); $this->assertEquals($result['details'][0]['primary'], '1981-12-21'); @@ -75,10 +75,10 @@ public function testComparePatientDetails() public function testUpdateEpisodesWhenPrimaryHasNoEpisodes() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); $episode7 = $this->episodes('episode7'); $episode7->patient_id = 1; @@ -88,15 +88,15 @@ public function testUpdateEpisodesWhenPrimaryHasNoEpisodes() $episode8->patient_id = 1; $episode8->save(); - $primaryPatient->refresh(); + $primary_patient->refresh(); // primary has no episodes - $this->assertEquals(count($primaryPatient->episodes), 0); + $this->assertEquals(count($primary_patient->episodes), 0); // at this pont the primary patient has no episodes and the secondary has // move the episodes , (secondary INTO primary) - $result = $mergeHandler->updateEpisodes($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateEpisodes($primary_patient, $secondary_patient); $this->assertTrue($result); @@ -106,25 +106,25 @@ public function testUpdateEpisodesWhenPrimaryHasNoEpisodes() $episode10 = $this->episodes('episode10'); $this->assertEquals($episode10->patient_id, 7); - $secondaryPatient->refresh(); + $secondary_patient->refresh(); // secondary has no episodes - $this->assertEquals(count($secondaryPatient->episodes), 0); + $this->assertEquals(count($secondary_patient->episodes), 0); } public function testUpdateEpisodesWhenBothHaveEpisodesNoConflict() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); // this episode conflicts with episode7, so assign it to a different user to avoid the conflict $eposode9 = $this->episodes('episode9'); $eposode9->patient_id = 1; $eposode9->save(); - $secondaryPatient->refresh(); + $secondary_patient->refresh(); // now primary has Episode7 and Episode8 //secondary has Episode 10 @@ -138,10 +138,10 @@ public function testUpdateEpisodesWhenBothHaveEpisodesNoConflict() $eposode10 = $this->episodes('episode10'); $this->assertEquals($eposode10->patient_id, 8); - $this->assertEquals(2, count($primaryPatient->episodes)); - $this->assertEquals(1, count($secondaryPatient->episodes)); + $this->assertEquals(2, count($primary_patient->episodes)); + $this->assertEquals(1, count($secondary_patient->episodes)); - $result = $mergeHandler->updateEpisodes($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateEpisodes($primary_patient, $secondary_patient); $this->assertTrue($result); @@ -160,13 +160,13 @@ public function testUpdateEpisodesWhenBothHaveEpisodesNoConflict() */ public function testUpdateEpisodesWhenBothHaveEpisodesConflict_secondaryEpisodeOlder() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - // $primaryPatient has episode7 and episode8 - $primaryPatient = $this->patients('patient7'); // episode7 + // $primary_patient has episode7 and episode8 + $primary_patient = $this->patients('patient7'); // episode7 - // $secondaryPatient has episode9, episode10 - $secondaryPatient = $this->patients('patient8'); //episode9 + // $secondary_patient has episode9, episode10 + $secondary_patient = $this->patients('patient8'); //episode9 $episode7 = $this->episodes('episode7'); $episode7->created_date = date('Y-m-d', strtotime('-15 days')); @@ -181,11 +181,11 @@ public function testUpdateEpisodesWhenBothHaveEpisodesConflict_secondaryEpisodeO $this->assertTrue($episode7->created_date > $episode9->created_date); - $this->assertEquals(count($primaryPatient->episodes), 2); - $this->assertEquals(count($secondaryPatient->episodes), 2); + $this->assertEquals(count($primary_patient->episodes), 2); + $this->assertEquals(count($secondary_patient->episodes), 2); // move the episodes , (secondary INTO primary) - $result = $mergeHandler->updateEpisodes($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateEpisodes($primary_patient, $secondary_patient); $this->assertTrue($result, 'Merge result FALSE.'); @@ -193,7 +193,7 @@ public function testUpdateEpisodesWhenBothHaveEpisodesConflict_secondaryEpisodeO // episode9 created 30 days ago and the episode7 created 15 days ago // as we keep the older episode we move events from episode7 to episode9 than move episode9 to Patient7 - $this->assertEquals(count($primaryPatient->episodes), 2); + $this->assertEquals(count($primary_patient->episodes), 2); $event16 = $this->events('event16'); $this->assertEquals($event16->episode_id, 7); @@ -219,22 +219,22 @@ public function testUpdateEpisodesWhenBothHaveEpisodesConflict_secondaryEpisodeO $episode10->refresh(); $this->assertEquals($episode10->patient_id, 7); - $secondaryPatient->refresh(); - $this->assertEquals(count($secondaryPatient->episodes), 0); + $secondary_patient->refresh(); + $this->assertEquals(count($secondary_patient->episodes), 0); - $primaryPatient->refresh(); - $this->assertEquals(count($primaryPatient->episodes), 3); + $primary_patient->refresh(); + $this->assertEquals(count($primary_patient->episodes), 3); } public function testUpdateEpisodesWhenBothHaveEpisodesConflict_primaryEpisodeOlder() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - // $primaryPatient has episode7 and episode8 - $primaryPatient = $this->patients('patient7'); + // $primary_patient has episode7 and episode8 + $primary_patient = $this->patients('patient7'); - // $secondaryPatient has episode9, episode10 - $secondaryPatient = $this->patients('patient8'); + // $secondary_patient has episode9, episode10 + $secondary_patient = $this->patients('patient8'); // conflicting episodes : // episode7 <-> episode9 @@ -243,10 +243,10 @@ public function testUpdateEpisodesWhenBothHaveEpisodesConflict_primaryEpisodeOld $episode9 = $this->episodes('episode9'); $this->assertTrue($episode7->created_date < $episode9->created_date); - $this->assertEquals(count($primaryPatient->episodes), 2); - $this->assertEquals(count($secondaryPatient->episodes), 2); + $this->assertEquals(count($primary_patient->episodes), 2); + $this->assertEquals(count($secondary_patient->episodes), 2); - $result = $mergeHandler->updateEpisodes($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateEpisodes($primary_patient, $secondary_patient); $this->assertTrue($result, 'Merge result FALSE.'); @@ -273,22 +273,22 @@ public function testUpdateEpisodesWhenBothHaveEpisodesConflict_primaryEpisodeOld $episode8 = $this->episodes('episode8'); $this->assertEquals($episode8->patient_id, 7); - $secondaryPatient->refresh(); - $this->assertEquals(count($secondaryPatient->episodes), 0); + $secondary_patient->refresh(); + $this->assertEquals(count($secondary_patient->episodes), 0); - $primaryPatient->refresh(); - $this->assertEquals(count($primaryPatient->episodes), 3); + $primary_patient->refresh(); + $this->assertEquals(count($primary_patient->episodes), 3); } public function testUpdateLegacyEpisodes_primaryNoLegacyEpisodes() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - // $primaryPatient has episode7 and episode8 - $primaryPatient = $this->patients('patient7'); + // $primary_patient has episode7 and episode8 + $primary_patient = $this->patients('patient7'); - // $secondaryPatient has episode9, episode10 - $secondaryPatient = $this->patients('patient8'); + // $secondary_patient has episode9, episode10 + $secondary_patient = $this->patients('patient8'); // Lets modify the episodes to have a legacy episode @@ -300,9 +300,9 @@ public function testUpdateLegacyEpisodes_primaryNoLegacyEpisodes() $episode9->save(); $this->assertEquals(1, $episode9->legacy); - $primaryPatient->refresh(); + $primary_patient->refresh(); - $result = $mergeHandler->updateLegacyEpisodes($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateLegacyEpisodes($primary_patient, $secondary_patient); $this->assertTrue($result, 'Merge result FALSE.'); @@ -311,22 +311,22 @@ public function testUpdateLegacyEpisodes_primaryNoLegacyEpisodes() $episode9 = $this->episodes('episode9'); $this->assertEquals($episode9->patient_id, 7); - $secondaryPatient->refresh(); - $this->assertEquals(count($secondaryPatient->legacyepisodes), 0); + $secondary_patient->refresh(); + $this->assertEquals(count($secondary_patient->legacyepisodes), 0); - $primaryPatient->refresh(); - $this->assertEquals(count($primaryPatient->legacyepisodes), 1); + $primary_patient->refresh(); + $this->assertEquals(count($primary_patient->legacyepisodes), 1); } public function testUpdateLegacyEpisodes_bothHaveLegacyEpisodes_secondaryOlder() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - // $primaryPatient has episode7 and episode8 - $primaryPatient = $this->patients('patient7'); + // $primary_patient has episode7 and episode8 + $primary_patient = $this->patients('patient7'); - // $secondaryPatient has episode9, episode10 - $secondaryPatient = $this->patients('patient8'); + // $secondary_patient has episode9, episode10 + $secondary_patient = $this->patients('patient8'); // Lets modify the episodes to have a legacy episode @@ -346,7 +346,7 @@ public function testUpdateLegacyEpisodes_bothHaveLegacyEpisodes_secondaryOlder() $this->assertTrue($episode7->created_date > $episode9->created_date); - $result = $mergeHandler->updateLegacyEpisodes($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateLegacyEpisodes($primary_patient, $secondary_patient); $this->assertTrue($result, 'Merge result FALSE.'); @@ -361,23 +361,23 @@ public function testUpdateLegacyEpisodes_bothHaveLegacyEpisodes_secondaryOlder() $this->assertEquals($episode9->patient_id, 7); $this->assertEquals(count($episode9->events), 4); - $primaryPatient->refresh(); - $this->assertEquals(count($primaryPatient->legacyepisodes), 1); - $this->assertEquals(count($primaryPatient->legacyepisodes[0]->events), 4); + $primary_patient->refresh(); + $this->assertEquals(count($primary_patient->legacyepisodes), 1); + $this->assertEquals(count($primary_patient->legacyepisodes[0]->events), 4); - $secondaryPatient->refresh(); - $this->assertEquals(count($secondaryPatient->legacyepisodes), 0); + $secondary_patient->refresh(); + $this->assertEquals(count($secondary_patient->legacyepisodes), 0); } public function testUpdateLegacyEpisodes_bothHaveLegacyEpisodes_primaryOlder() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - // $primaryPatient has episode7 and episode8 - $primaryPatient = $this->patients('patient7'); + // $primary_patient has episode7 and episode8 + $primary_patient = $this->patients('patient7'); - // $secondaryPatient has episode9, episode10 - $secondaryPatient = $this->patients('patient8'); + // $secondary_patient has episode9, episode10 + $secondary_patient = $this->patients('patient8'); // Lets modify the episodes to have a legacy episode @@ -395,7 +395,7 @@ public function testUpdateLegacyEpisodes_bothHaveLegacyEpisodes_primaryOlder() $this->assertTrue($episode7->created_date < $episode9->created_date); - $result = $mergeHandler->updateLegacyEpisodes($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateLegacyEpisodes($primary_patient, $secondary_patient); $this->assertTrue($result, 'Merge result FALSE.'); @@ -411,16 +411,16 @@ public function testUpdateLegacyEpisodes_bothHaveLegacyEpisodes_primaryOlder() $episode9->refresh(); $this->assertEquals(count($episode9->events), 0); - $primaryPatient->refresh(); - $this->assertEquals(count($primaryPatient->legacyepisodes), 1); + $primary_patient->refresh(); + $this->assertEquals(count($primary_patient->legacyepisodes), 1); - $secondaryPatient->refresh(); - $this->assertEquals(count($secondaryPatient->legacyepisodes), 0); + $secondary_patient->refresh(); + $this->assertEquals(count($secondary_patient->legacyepisodes), 0); } public function testUpdateAllergyAssignments_primaryHasNoAllergyAssignments() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); $assignment1 = $this->patient_allergy_assignment('assignment1'); $assignment2 = $this->patient_allergy_assignment('assignment2'); @@ -428,43 +428,43 @@ public function testUpdateAllergyAssignments_primaryHasNoAllergyAssignments() $assignment1->patient_id = 1; $assignment1->save(); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); - $this->assertEquals(count($primaryPatient->allergyAssignments), 0); - $this->assertEquals(count($secondaryPatient->allergyAssignments), 1); + $this->assertEquals(count($primary_patient->allergyAssignments), 0); + $this->assertEquals(count($secondary_patient->allergyAssignments), 1); - $result = $mergeHandler->updateAllergyAssignments($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateAllergyAssignments($primary_patient, $secondary_patient); - $primaryPatient->refresh(); - $secondaryPatient->refresh(); + $primary_patient->refresh(); + $secondary_patient->refresh(); $this->assertTrue($result, 'Update Allergy Assigmant FAILED.'); $assignment2->refresh(); $this->assertEquals($assignment2->patient_id, 7); - $this->assertEquals(count($primaryPatient->allergyAssignments), 1); - $this->assertEquals(count($secondaryPatient->allergyAssignments), 0); + $this->assertEquals(count($primary_patient->allergyAssignments), 1); + $this->assertEquals(count($secondary_patient->allergyAssignments), 0); } public function testUpdateAllergyAssignments_bothHaveDifferentAllergyAssignments() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); $assignment1 = $this->patient_allergy_assignment('assignment1'); $assignment2 = $this->patient_allergy_assignment('assignment2'); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); - $this->assertEquals(count($primaryPatient->allergyAssignments), 1); - $this->assertEquals(count($secondaryPatient->allergyAssignments), 1); + $this->assertEquals(count($primary_patient->allergyAssignments), 1); + $this->assertEquals(count($secondary_patient->allergyAssignments), 1); - $result = $mergeHandler->updateAllergyAssignments($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateAllergyAssignments($primary_patient, $secondary_patient); - $primaryPatient->refresh(); - $secondaryPatient->refresh(); + $primary_patient->refresh(); + $secondary_patient->refresh(); $this->assertTrue($result, 'Update Allergy Assigmant FAILED.'); @@ -474,13 +474,13 @@ public function testUpdateAllergyAssignments_bothHaveDifferentAllergyAssignments $assignment2->refresh(); $this->assertEquals($assignment2->patient_id, 7); - $this->assertEquals(count($primaryPatient->allergyAssignments), 2); - $this->assertEquals(count($secondaryPatient->allergyAssignments), 0); + $this->assertEquals(count($primary_patient->allergyAssignments), 2); + $this->assertEquals(count($secondary_patient->allergyAssignments), 0); } public function testUpdateAllergyAssignments_bothHaveSameAllergyAssignments() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); $assignment1 = $this->patient_allergy_assignment('assignment1'); $assignment2 = $this->patient_allergy_assignment('assignment2'); @@ -491,16 +491,16 @@ public function testUpdateAllergyAssignments_bothHaveSameAllergyAssignments() $this->assertEquals($assignment1->allergy_id, $assignment2->allergy_id); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); - $this->assertEquals(count($primaryPatient->allergyAssignments), 1); - $this->assertEquals(count($secondaryPatient->allergyAssignments), 1); + $this->assertEquals(count($primary_patient->allergyAssignments), 1); + $this->assertEquals(count($secondary_patient->allergyAssignments), 1); - $result = $mergeHandler->updateAllergyAssignments($primaryPatient, $secondaryPatient); + $result = $merge_handler->updateAllergyAssignments($primary_patient, $secondary_patient); - $primaryPatient->refresh(); - $secondaryPatient->refresh(); + $primary_patient->refresh(); + $secondary_patient->refresh(); $assignment1->refresh(); $this->assertEquals($assignment1->patient_id, 7); @@ -515,101 +515,101 @@ public function testUpdateRiskAssignments() public function testUpdatePreviousOperations() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); - $previousOperation1 = $this->previous_operation('previousOperation1'); + $previous_operation1 = $this->previous_operation('previousOperation1'); - $previousOperation1->patient_id = 8; - $previousOperation1->save(); - $previousOperation1->refresh(); + $previous_operation1->patient_id = 8; + $previous_operation1->save(); + $previous_operation1->refresh(); // Before we update the Previous Operations we check if the patient id is equals to the secondary patient id - $this->assertEquals(8, $previousOperation1->patient_id); + $this->assertEquals(8, $previous_operation1->patient_id); - $primaryPatient->refresh(); - $secondaryPatient->refresh(); - $this->assertEquals(0, count($primaryPatient->previousOperations) ); - $this->assertEquals(1, count($secondaryPatient->previousOperations) ); + $primary_patient->refresh(); + $secondary_patient->refresh(); + $this->assertEquals(0, count($primary_patient->previousOperations) ); + $this->assertEquals(1, count($secondary_patient->previousOperations) ); - $mergeHandler->updatePreviousOperations($primaryPatient, $secondaryPatient->previousOperations); + $merge_handler->updatePreviousOperations($primary_patient, $secondary_patient->previousOperations); - $primaryPatient->refresh(); - $secondaryPatient->refresh(); - $this->assertTrue(is_array($secondaryPatient->previousOperations)); + $primary_patient->refresh(); + $secondary_patient->refresh(); + $this->assertTrue(is_array($secondary_patient->previousOperations)); - $this->assertEquals(0, count($secondaryPatient->previousOperations) ); - $this->assertEquals(1, count($primaryPatient->previousOperations) ); + $this->assertEquals(0, count($secondary_patient->previousOperations) ); + $this->assertEquals(1, count($primary_patient->previousOperations) ); - $previousOperation1->refresh(); + $previous_operation1->refresh(); - $this->assertEquals(7, $previousOperation1->patient_id); + $this->assertEquals(7, $previous_operation1->patient_id); } public function testUpdateOphthalmicDiagnoses() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); - $secondaryDiagnoses8 = $this->secondary_diagnosis('secondaryDiagnoses8'); - $secondaryDiagnoses8->patient_id = 8; - $secondaryDiagnoses8->save(); - $secondaryDiagnoses8->refresh(); + $secondary_diagnoses8 = $this->secondary_diagnosis('secondaryDiagnoses8'); + $secondary_diagnoses8->patient_id = 8; + $secondary_diagnoses8->save(); + $secondary_diagnoses8->refresh(); // Before we update the Ophthalmic Diagnoses we check if the patient id is equals to the secondary patient id - $this->assertEquals(8, $secondaryDiagnoses8->patient_id); + $this->assertEquals(8, $secondary_diagnoses8->patient_id); - $secondaryPatient->refresh(); - $this->assertTrue(is_array($secondaryPatient->ophthalmicDiagnoses) ); - $this->assertEquals(1, count($secondaryPatient->ophthalmicDiagnoses) ); + $secondary_patient->refresh(); + $this->assertTrue(is_array($secondary_patient->ophthalmicDiagnoses) ); + $this->assertEquals(1, count($secondary_patient->ophthalmicDiagnoses) ); - $mergeHandler->updateOphthalmicDiagnoses($primaryPatient, $secondaryPatient->ophthalmicDiagnoses); + $merge_handler->updateOphthalmicDiagnoses($primary_patient, $secondary_patient->ophthalmicDiagnoses); - $secondaryDiagnoses8->refresh(); - $secondaryPatient->refresh(); + $secondary_diagnoses8->refresh(); + $secondary_patient->refresh(); - $this->assertEquals(0, count($secondaryPatient->ophthalmicDiagnoses) ); + $this->assertEquals(0, count($secondary_patient->ophthalmicDiagnoses) ); - $this->assertEquals(7, $secondaryDiagnoses8->patient_id); + $this->assertEquals(7, $secondary_diagnoses8->patient_id); } public function testUpdateSystemicDiagnoses() { - $mergeHandler = new PatientMerge(); + $merge_handler = new PatientMerge(); - $primaryPatient = $this->patients('patient7'); - $secondaryPatient = $this->patients('patient8'); + $primary_patient = $this->patients('patient7'); + $secondary_patient = $this->patients('patient8'); - $secondaryDiagnoses8 = $this->secondary_diagnosis('secondaryDiagnoses8'); - $secondaryDiagnoses8->patient_id = 8; - $secondaryDiagnoses8->disorder_id = 5; - $secondaryDiagnoses8->save(); - $secondaryDiagnoses8->refresh(); + $secondary_diagnoses8 = $this->secondary_diagnosis('secondaryDiagnoses8'); + $secondary_diagnoses8->patient_id = 8; + $secondary_diagnoses8->disorder_id = 5; + $secondary_diagnoses8->save(); + $secondary_diagnoses8->refresh(); // Befor we update the Ophthalmic Diagnoses we check if the patient id is equals to the secondary patient id - $this->assertEquals(8, $secondaryDiagnoses8->patient_id); - $this->assertEquals(5, $secondaryDiagnoses8->disorder_id); + $this->assertEquals(8, $secondary_diagnoses8->patient_id); + $this->assertEquals(5, $secondary_diagnoses8->disorder_id); - $secondaryPatient->refresh(); - $this->assertTrue(is_array($secondaryPatient->systemicDiagnoses) ); - $this->assertEquals(1, count($secondaryPatient->systemicDiagnoses) ); + $secondary_patient->refresh(); + $this->assertTrue(is_array($secondary_patient->systemicDiagnoses) ); + $this->assertEquals(1, count($secondary_patient->systemicDiagnoses) ); - $mergeHandler->updateOphthalmicDiagnoses($primaryPatient, $secondaryPatient->systemicDiagnoses); + $merge_handler->updateOphthalmicDiagnoses($primary_patient, $secondary_patient->systemicDiagnoses); - $secondaryDiagnoses8->refresh(); + $secondary_diagnoses8->refresh(); - $this->assertEquals(7, $secondaryDiagnoses8->patient_id); + $this->assertEquals(7, $secondary_diagnoses8->patient_id); - $this->assertEquals(0, count($secondaryPatient->systemicDiagnoses) ); - $this->assertEquals(1, count($primaryPatient->systemicDiagnoses) ); + $this->assertEquals(0, count($secondary_patient->systemicDiagnoses) ); + $this->assertEquals(1, count($primary_patient->systemicDiagnoses) ); } diff --git a/protected/views/patientmergerequest/_list.php b/protected/views/patientmergerequest/_list.php index ec6ddf6c42..35aafcd4ce 100644 --- a/protected/views/patientmergerequest/_list.php +++ b/protected/views/patientmergerequest/_list.php @@ -4,19 +4,19 @@ - getSort()->link('secondary_hos_num', 'Secondary
hospital num', array('class' => 'sort-link')) ?> + getSort()->link('secondary_hos_num', 'Secondary
hospital num', array('class' => 'sort-link')) ?> - getSort()->link('primary_hos_num', 'Primary
hospital num', array('class' => 'sort-link')) ?> + getSort()->link('primary_hos_num', 'Primary
hospital num', array('class' => 'sort-link')) ?> - getSort()->link('status', 'Status', array('class' => 'sort-link')); ?> - getSort()->link('created_date', 'Created', array('class' => 'sort-link')); ?> + getSort()->link('status', 'Status', array('class' => 'sort-link')); ?> + getSort()->link('created_date', 'Created', array('class' => 'sort-link')); ?> - getSort()->link('last_modified_date', 'Merged', array('class' => 'sort-link')); ?> + getSort()->link('last_modified_date', 'Merged', array('class' => 'sort-link')); ?> - itemCount): ?> + itemCount): ?> @@ -36,15 +36,15 @@ 'rq_delete', 'class' => 'button small', 'disabled' => ($filters['show_merged'] ? 'disabled' : ''))); ?> renderPartial('//admin/_pagination', array( - 'pagination' => $dataProvider->getPagination(), + 'pagination' => $data_provider->getPagination(), )); ?> - itemCount): ?> - getData() as $i => $request): ?> + itemCount): ?> + getData() as $i => $request): ?> status == PatientMergeRequest::STATUS_NOT_PROCESSED): ?> @@ -52,7 +52,7 @@ - status == PatientMergeRequest::STATUS_NOT_PROCESSED ? '' : 'disabled'?>> + status == PatientMergeRequest::STATUS_NOT_PROCESSED ? '' : 'disabled'?>> secondary_hos_num?> INTO diff --git a/protected/views/patientmergerequest/_view.php b/protected/views/patientmergerequest/_view.php index 56729ad5b2..8dc5437715 100644 --- a/protected/views/patientmergerequest/_view.php +++ b/protected/views/patientmergerequest/_view.php @@ -33,51 +33,4 @@ secondary_id); ?>
- getAttributeLabel('secondary_hos_num')); ?>: - secondary_hos_num); ?> -
- - getAttributeLabel('secondary_nhsnum')); ?>: - secondary_nhsnum); ?> -
- - getAttributeLabel('secondary_dob')); ?>: - secondary_dob); ?> -
- - getAttributeLabel('secondary_gender')); ?>: - secondary_gender); ?> -
- - getAttributeLabel('merge_json')); ?>: - merge_json); ?> -
- - getAttributeLabel('comment')); ?>: - comment); ?> -
- - getAttributeLabel('status')); ?>: - status); ?> -
- - getAttributeLabel('last_modified_user_id')); ?>: - last_modified_user_id); ?> -
- - getAttributeLabel('last_modified_date')); ?>: - last_modified_date); ?> -
- - getAttributeLabel('created_user_id')); ?>: - created_user_id); ?> -
- - getAttributeLabel('created_date')); ?>: - created_date); ?> -
- - */ ?> -
\ No newline at end of file diff --git a/protected/views/patientmergerequest/create.php b/protected/views/patientmergerequest/create.php index 1bcec4b79a..bba3756817 100644 --- a/protected/views/patientmergerequest/create.php +++ b/protected/views/patientmergerequest/create.php @@ -68,7 +68,7 @@ Please confirm you selected the right patients.
Note, the primary patient's personal details will NOT be overwritten.

+ I hereby confirm that I selected the right patients.
diff --git a/protected/views/patientmergerequest/index.php b/protected/views/patientmergerequest/index.php index 294a4505d1..bcb41dad95 100644 --- a/protected/views/patientmergerequest/index.php +++ b/protected/views/patientmergerequest/index.php @@ -1,6 +1,6 @@ @@ -10,7 +10,6 @@ 'id' => 'merge-form', 'enableAjaxValidation' => false, 'enableClientValidation' => true, - //'focus' => array($model,'firstName'), )); ?> @@ -38,7 +37,7 @@
- renderPartial('//patientmergerequest/_list', array('dataProvider' => $dataProvider, 'filters' => $filters))?> + renderPartial('//patientmergerequest/_list', array('data_provider' => $data_provider, 'filters' => $filters))?>
diff --git a/protected/views/patientmergerequest/log.php b/protected/views/patientmergerequest/log.php index 918f0097f7..ab51e48d16 100644 --- a/protected/views/patientmergerequest/log.php +++ b/protected/views/patientmergerequest/log.php @@ -24,7 +24,7 @@ widget('zii.widgets.grid.CGridView', array( 'itemsCssClass' => 'grid', - 'dataProvider' => $dataProvider, + 'dataProvider' => $data_provider, 'summaryText' => '

{start}-{end} of {count}

', 'htmlOptions' => array('id' => 'patientMergeList'), 'columns' => array('log'), diff --git a/protected/views/patientmergerequest/merge.php b/protected/views/patientmergerequest/merge.php index 7b1f4fb878..26d5616532 100644 --- a/protected/views/patientmergerequest/merge.php +++ b/protected/views/patientmergerequest/merge.php @@ -57,14 +57,14 @@
- user->checkAccess('Patient Merge')):?> + user->checkAccess('Patient Merge')):?>

Personal details are conflicting.

Please confirm you selected the right patients.
Note, the primary patient's personal details will NOT be overwritten.

+ I hereby confirm that I selected the right patients.
diff --git a/protected/views/patientmergerequest/update.php b/protected/views/patientmergerequest/update.php index ec3a868dc3..233c28e251 100644 --- a/protected/views/patientmergerequest/update.php +++ b/protected/views/patientmergerequest/update.php @@ -63,14 +63,14 @@

renderPartial('//base/_messages')?> - user->checkAccess('Patient Merge')):?> + user->checkAccess('Patient Merge')):?>

Personal details are conflicting.

Please confirm you selected the right patients.
Note, the primary patient's personal details will NOT be overwritten.

+ I hereby confirm that I selected the right patients.
@@ -92,10 +92,10 @@
\ No newline at end of file diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php index 6e28f7f406..489afc6e05 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php @@ -1,34 +1,74 @@ +getAssetManager()->registerScriptFile('js/PCRCalculation.js') +?> +
condition = 'has_pcr_risk'; $grades = \DoctorGrade::model()->findAll($criteria, array('order' => 'display_order')); $dropDowns = array( - 'glaucoma' => array('NK' => 'Not Known', 'N' => 'No Glaucoma', 'Y' => 'Glaucoma present'), - 'pxf' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), - 'diabetic' => array('NK' => 'Not Known', 'N' => 'No Diabetes', 'Y' => 'Diabetes present'), - 'pupil_size' => array('Large' => 'Large', 'Medium' => 'Medium', 'Small' => 'Small'), - 'no_fundal_view' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), - 'axial_length_group' => array('NK' => 'Not Known', 1 => '< 26', 2 => '> or = 26'), - 'brunescent_white_cataract' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), - 'alpha_receptor_blocker' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), - 'doctor_grade_id' => CHtml::listData($grades, 'pcr_risk_value', 'grade'), - 'can_lie_flat' => array('N' => 'No', 'Y' => 'Yes'), + 'glaucoma' => array( + 'options' => array('NK' => 'Not Known', 'N' => 'No Glaucoma', 'Y' => 'Glaucoma present'), + 'class' => 'pcrrisk_glaucoma', + ), + 'pxf' => array( + 'options' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), + 'class' => 'pcrrisk_pxf_phako', + ), + 'diabetic' => array( + 'options' => array('NK' => 'Not Known', 'N' => 'No Diabetes', 'Y' => 'Diabetes present'), + 'class' => 'pcrrisk_diabetic', + ), + 'pupil_size' => array( + 'options' => array('Large' => 'Large', 'Medium' => 'Medium', 'Small' => 'Small'), + 'class' => 'pcrrisk_pupil_size', + ), + 'no_fundal_view' => array( + 'options' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), + 'class' => 'pcrrisk_no_fundal_view', + ), + 'axial_length_group' => array( + 'options' => array('NK' => 'Not Known', 1 => '< 26', 2 => '> or = 26'), + 'class' => '', + ), + 'brunescent_white_cataract' => array( + 'options' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), + 'class' => 'pcrrisk_brunescent_white_cataract', + ), + 'alpha_receptor_blocker' => array( + 'options' => array('NK' => 'Not Known', 'N' => 'No', 'Y' => 'Yes'), + 'class' => '', + ), + 'doctor_grade_id' => array( + 'options' => CHtml::listData($grades, 'pcr_risk_value', 'grade'), + 'class' => 'pcr_doctor_grade', + ), + 'can_lie_flat' => array( + 'options' => array('N' => 'No', 'Y' => 'Yes'), + 'class' => '', + ), ); +echo $form->hiddenInput($element, 'eye_id', false, array('class' => 'sideField')); + foreach (array('right', 'left') as $side): - $opposite = ($side === 'right') ? 'left' : 'right' -?> - hiddenInput($element, 'eye_id', false, array('class' => 'sideField')) ?> - {'has'.ucfirst($side)}()) ? 'active' : 'inactive'; ?> + $opposite = ($side === 'right') ? 'left' : 'right'; + $pcrRisk = new PcrRisk(); + $activeClass = ($element->{'has'.ucfirst($side)}()) ? 'active' : 'inactive'; ?>
+ getPCRData($this->event->episode->patient->id, $side, $element); + echo CHtml::hiddenField('age', $pcr['age_group']); + echo CHtml::hiddenField('gender', $pcr['gender']); + ?>
Remove side $data): echo $form->dropDownList( $element, $side.'_'.$key, - $data, - array(), + $data['options'], + array('class' => $data['class']), false, array('label' => 4, 'field' => 4) ); @@ -63,4 +103,22 @@
+ diff --git a/protected/modules/OphTrOperationnote/assets/js/module.js b/protected/modules/OphTrOperationnote/assets/js/module.js index 43afbe3b56..0b5c8d4bd9 100644 --- a/protected/modules/OphTrOperationnote/assets/js/module.js +++ b/protected/modules/OphTrOperationnote/assets/js/module.js @@ -675,11 +675,11 @@ function changeEye() { if(typeof pcrCalculate === 'function'){ if($("#Element_OphTrOperationnote_ProcedureList_eye_id_2").attr('checked') == "checked") { - pcrCalculate('right'); + pcrCalculate($('#ophCiExaminationPCRRiskRightEye'), 'right'); } if($("#Element_OphTrOperationnote_ProcedureList_eye_id_1").attr('checked') == "checked") { - pcrCalculate('left'); + pcrCalculate($('#ophCiExaminationPCRRiskLeftEye'), 'left'); } } diff --git a/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract.php b/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract.php index 3a81980cd1..4ecfba7dea 100644 --- a/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract.php +++ b/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract.php @@ -23,39 +23,39 @@ $form->layoutColumns = array('label' => 3, 'field' => 9); ?>
-
-
- renderPartial($element->form_view.'_OEEyeDraw', array( +
+
+ renderPartial($element->form_view . '_OEEyeDraw', array( 'element' => $element, 'form' => $form, )); ?> -
-
- renderPartial($element->form_view.'_OEEyeDraw_fields', array( +
+
+ renderPartial($element->form_view . '_OEEyeDraw_fields', array( 'form' => $form, 'element' => $element, )); ?> -
-
- - PCR Risk - % - +
+
+ + PCR Risk + % + -
- +
From ef152a9c13b867cb38b0d000c69eb4222f555c03 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 27 Oct 2016 16:16:13 +0100 Subject: [PATCH 054/164] OE-6198: Fixes issue with calling function before file is loaded --- ...CiExamination_CataractSurgicalManagement.php | 17 ----------------- .../form_Element_OphCiExamination_PcrRisk.php | 2 +- protected/views/default/_pcr_risk_form.php | 16 +++++++++++++++- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_CataractSurgicalManagement.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_CataractSurgicalManagement.php index 57e240f9e0..f90683b8e8 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_CataractSurgicalManagement.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_CataractSurgicalManagement.php @@ -137,21 +137,4 @@ }); $('#refraction_slider').after('
-10010
'); - - $(document).ready(function () { - //Map the elements - mapExaminationToPcr(); - //Make the initial calculations - pcrCalculate($('#ophCiExaminationPCRRiskLeftEye'), 'left'); - pcrCalculate($('#ophCiExaminationPCRRiskRightEye'), 'right'); - - $(document.body).on('change', '#ophCiExaminationPCRRiskLeftEye', function () { - pcrCalculate($('#ophCiExaminationPCRRiskLeftEye'), 'left'); - }); - - $(document.body).on('change', '#ophCiExaminationPCRRiskRightEye', function () { - pcrCalculate($('#ophCiExaminationPCRRiskRightEye'), 'right'); - }); - - }); \ No newline at end of file diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php index 489afc6e05..27ca84b37c 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php @@ -103,7 +103,7 @@
- Date: Fri, 28 Oct 2016 10:33:55 +0100 Subject: [PATCH 055/164] OE-6239 Fix migration script to include _version table. --- .../m161021_110716_add_eye_comments.php | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/protected/modules/OphInBiometry/migrations/m161021_110716_add_eye_comments.php b/protected/modules/OphInBiometry/migrations/m161021_110716_add_eye_comments.php index a505324373..faec17c68f 100644 --- a/protected/modules/OphInBiometry/migrations/m161021_110716_add_eye_comments.php +++ b/protected/modules/OphInBiometry/migrations/m161021_110716_add_eye_comments.php @@ -2,26 +2,30 @@ class m161021_110716_add_eye_comments extends CDbMigration { - public function up() - { + public function up() + { $this->addColumn('et_ophinbiometry_calculation', 'comments_right', 'text'); $this->addColumn('et_ophinbiometry_calculation', 'comments_left', 'text'); - } + $this->addColumn('et_ophinbiometry_calculation_version', 'comments_right', 'text'); + $this->addColumn('et_ophinbiometry_calculation_version', 'comments_left', 'text'); + } - public function down() - { + public function down() + { $this->dropColumn('et_ophinbiometry_calculation', 'comments_right'); $this->dropColumn('et_ophinbiometry_calculation', 'comments_left'); - } + $this->dropColumn('et_ophinbiometry_calculation_version', 'comments_right'); + $this->dropColumn('et_ophinbiometry_calculation_version', 'comments_left'); + } - /* - // Use safeUp/safeDown to do migration with transaction - public function safeUp() - { - } + /* + // Use safeUp/safeDown to do migration with transaction + public function safeUp() + { + } - public function safeDown() - { - } - */ + public function safeDown() + { + } + */ } \ No newline at end of file From c5f9a28deca32777144995131a2e473f1444f010 Mon Sep 17 00:00:00 2001 From: Sabi Date: Fri, 28 Oct 2016 10:35:21 +0100 Subject: [PATCH 056/164] OE-6296 :adding eye adjective to procedure in getAllBookingsWithoutOperationNotes() --- .../components/OphTrOperationbooking_API.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php index 7a168a8943..a1ced7d30a 100644 --- a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php +++ b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php @@ -423,7 +423,7 @@ public function getAllBookingsWithoutOperationNotes(\Patient $patient) $booking_procs = OphTrOperationbooking_Operation_Procedures::model()->findAll($criteria); if ($booking_procs) { foreach ($booking_procs as $proc) { - $not_booked_events[] = $proc->procedure->term; + $not_booked_events[] = $proc->element->eye->getAdjective() . ' ' . $proc->procedure->term; } } From b03aa23d186e2f48ac20b18388dcb7a47a34a8a0 Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Fri, 28 Oct 2016 11:56:27 +0000 Subject: [PATCH 057/164] OE-6239 Fixes minor presentation issues. --- .../models/Element_OphInBiometry_Calculation.php | 4 ++-- .../form_Element_OphInBiometry_Calculation.php | 15 ++++++--------- .../view_Element_OphInBiometry_Calculation.php | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/protected/modules/OphInBiometry/models/Element_OphInBiometry_Calculation.php b/protected/modules/OphInBiometry/models/Element_OphInBiometry_Calculation.php index f30f60b46a..29d84b4186 100644 --- a/protected/modules/OphInBiometry/models/Element_OphInBiometry_Calculation.php +++ b/protected/modules/OphInBiometry/models/Element_OphInBiometry_Calculation.php @@ -108,8 +108,8 @@ public function attributeLabels() 'formula_id_right' => 'Formula', 'emmetropia_left' => 'Emmetropic IOL power', 'emmetropia_right' => 'Emmetropic IOL power', - 'comments_right' => 'General Comments (Right)', - 'comments_left' => 'General Comments (Left)', + 'comments_right' => 'General Comments', + 'comments_left' => 'General Comments', ); } diff --git a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Calculation.php b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Calculation.php index b9f3f052ff..8183a19918 100644 --- a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Calculation.php +++ b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Calculation.php @@ -74,19 +74,16 @@
- + is_auto) { if (!$this->getAutoBiometryEventData($this->event->id)[0]->is700() || $element->{'comments'}) { - echo 'Device Comments:'; - if (!$element->{'comments'}) { - echo " Empty"; - } - echo '
' . $element->{'comments'} . '
'; - } else { - echo $form->textField($element, 'comments', array('style' => 'width:1027px;'), null, - array('label' => 4, 'field' => 200)); + echo 'Device Comments:'; + echo '
' . $element->{'comments'} . '
'; } + } else { + echo $form->textField($element, 'comments', array('style' => 'width:1027px;'), null, + array('label' => 4, 'field' => 200)); } ?> diff --git a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation.php b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation.php index f9d354ccbd..53a13df07f 100644 --- a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation.php +++ b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation.php @@ -39,7 +39,7 @@
  Device Comments: '.$element->{'comments'}; + echo 'Device Comments: '.$element->{'comments'}; ?>
From 0a4021751668916168104430608d6fb88a5fe165 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 31 Oct 2016 10:58:09 +0000 Subject: [PATCH 058/164] OE-6198: View page for PCR risk element --- protected/components/PcrRisk.php | 42 +++++++++ .../Element_OphCiExamination_PcrRisk.php | 2 + .../form_Element_OphCiExamination_PcrRisk.php | 2 +- .../view_Element_OphCiExamination_PcrRisk.php | 91 +++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) diff --git a/protected/components/PcrRisk.php b/protected/components/PcrRisk.php index ff87affb52..c4d46f4f8d 100644 --- a/protected/components/PcrRisk.php +++ b/protected/components/PcrRisk.php @@ -18,10 +18,34 @@ */ class PcrRisk { + protected $stringMap = array( + 'general' => array( + 'NK' => 'Not Known', + 'N' => 'No', + 'Y' => 'Yes', + ), + 'glaucoma' => array( + 'NK' => 'Not Known', + 'N' => 'No Glaucoma', + 'Y' => 'Glaucoma Present', + ), + 'diabetes' => array( + 'NK' => 'Not Known', + 'N' => 'No Diabetes', + 'Y' => 'Diabetes Present', + ), + 'axial' => array( + '0' => 'Not Known', + '1' => '< 26', + '2' => '> or = 26', + ), + ); + /** * @var Patient */ protected $patient; + /** * @param $patientId * @param $side @@ -339,4 +363,22 @@ public function persist($side, Patient $patient, $data = array()) throw new CException('PCR Risk failed to save'); } } + + /** + * @param string $value + * @param string $type + * @return string + */ + public function displayValues($value, $type = 'general') + { + if(!array_key_exists($type, $this->stringMap)){ + $type = 'general'; + } + + if(array_key_exists($value, $this->stringMap[$type])){ + return $this->stringMap[$type][$value]; + } + + return $value; + } } diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php index 63388be4a9..d71704572d 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php @@ -72,6 +72,8 @@ public function relations() 'user' => array(self::BELONGS_TO, 'User', 'created_user_id'), 'usermodified' => array(self::BELONGS_TO, 'User', 'last_modified_user_id'), 'eye' => array(self::BELONGS_TO, 'Eye', 'eye_id'), + 'right_doctor' => array(self::BELONGS_TO, 'DoctorGrade', 'right_doctor_grade_id'), + 'left_doctor' => array(self::BELONGS_TO, 'DoctorGrade', 'left_doctor_grade_id'), ); } diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php index 27ca84b37c..c145540b11 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php @@ -29,7 +29,7 @@ 'class' => 'pcrrisk_no_fundal_view', ), 'axial_length_group' => array( - 'options' => array('NK' => 'Not Known', 1 => '< 26', 2 => '> or = 26'), + 'options' => array(0 => 'Not Known', 1 => '< 26', 2 => '> or = 26'), 'class' => '', ), 'brunescent_white_cataract' => array( diff --git a/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php index e69de29bb2..060cbfe927 100644 --- a/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php @@ -0,0 +1,91 @@ +
+{'has'.ucfirst($side)}()) ? 'active' : 'inactive'; +?> +
+
+
+
getAttributeLabel($side.'_glaucoma')?>:
+
+
+
displayValues($element->{$side.'_glaucoma'}, 'glaucoma')?>
+
+
+
+
+
getAttributeLabel($side.'_pxf')?>:
+
+
+
displayValues($element->{$side.'_pxf'})?>
+
+
+
+
+
getAttributeLabel($side.'_diabetic')?>:
+
+
+
displayValues($element->{$side.'_diabetic'}, 'diabetic')?>
+
+
+
+
+
getAttributeLabel($side.'_pupil_size')?>:
+
+
+
{$side.'_pupil_size'}?>
+
+
+
+
+
getAttributeLabel($side.'_no_fundal_view')?>:
+
+
+
displayValues($element->{$side.'_no_fundal_view'})?>
+
+
+
+
+
getAttributeLabel($side.'_axial_length_group')?>:
+
+
+
displayValues($element->{$side.'_axial_length_group'}, 'axial')?>
+
+
+
+
+
getAttributeLabel($side.'_brunescent_white_cataract')?>:
+
+
+
displayValues($element->{$side.'_brunescent_white_cataract'})?>
+
+
+
+
+
getAttributeLabel($side.'_alpha_receptor_blocker')?>:
+
+
+
displayValues($element->{$side.'_alpha_receptor_blocker'})?>
+
+
+
+
+
getAttributeLabel($side.'_doctor_grade_id')?>:
+
+
+
{$side.'_doctor'}->grade?>
+
+
+
+
+
getAttributeLabel($side.'_can_lie_flat')?>:
+
+
+
displayValues($element->{$side.'_can_lie_flat'})?>
+
+
+
+ +
\ No newline at end of file From 4b9a63a4dab4e31729389885d6c1bd5644bbbe90 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 31 Oct 2016 13:38:56 +0000 Subject: [PATCH 059/164] OE-6198: Store and display the PCR risk on the view page --- protected/assets/js/PCRCalculation.js | 6 +++ .../OphCiExamination/assets/css/module.css | 14 +++++- .../assets/sass/components/elements/_pcr.scss | 12 +++++ .../m161026_095125_pcr_risk_element.php | 6 ++- .../Element_OphCiExamination_PcrRisk.php | 45 ++++++++++++++++++- .../form_Element_OphCiExamination_PcrRisk.php | 2 + .../view_Element_OphCiExamination_PcrRisk.php | 12 +++++ 7 files changed, 93 insertions(+), 4 deletions(-) diff --git a/protected/assets/js/PCRCalculation.js b/protected/assets/js/PCRCalculation.js index a1f553a6b8..df3f25e87b 100644 --- a/protected/assets/js/PCRCalculation.js +++ b/protected/assets/js/PCRCalculation.js @@ -399,6 +399,12 @@ function pcrCalculate($eyeSide, side) { $eyeSide.find('#pcr-risk-div, .pcr-risk-div label').css('background', pcrData.pcrColour); $eyeSide.find('.pcr-span').html(pcrData.pcrRisk); $eyeSide.find('.pcr-erisk').html(pcrData.excessRisk); + if(pcrData.pcrRisk !== 'N/A'){ + $eyeSide.find('.pcr-input').val(pcrData.pcrRisk); + } else { + $eyeSide.find('.pcr-input').val(''); + } + $eyeSide.find('.pcr-erisk-input').val(pcrData.excessRisk); $('#ophCiExaminationPCRRisk' + side + 'EyeLabel').find('a').css('color', pcrData.pcrColour); $('#ophCiExaminationPCRRisk' + side + 'EyeLabel').find('.pcr-span1').html(pcrData.pcrRisk); diff --git a/protected/modules/OphCiExamination/assets/css/module.css b/protected/modules/OphCiExamination/assets/css/module.css index a036308991..7ca3348fb8 100644 --- a/protected/modules/OphCiExamination/assets/css/module.css +++ b/protected/modules/OphCiExamination/assets/css/module.css @@ -146,10 +146,22 @@ /* line 6, ../sass/components/elements/_pcr.scss */ .pcr-risk-div label { - background-color: #00f; + background-color: #f00; padding: 5px; text-align: center; } +/* line 10, ../sass/components/elements/_pcr.scss */ +.pcr-risk-div label.red { + background-color: #f00; +} +/* line 13, ../sass/components/elements/_pcr.scss */ +.pcr-risk-div label.blue { + background-color: #00f; +} +/* line 16, ../sass/components/elements/_pcr.scss */ +.pcr-risk-div label.orange { + background-color: #ffa500; +} /* line 17, ../sass/components/_gonio-cross.scss */ .gonio-cross { diff --git a/protected/modules/OphCiExamination/assets/sass/components/elements/_pcr.scss b/protected/modules/OphCiExamination/assets/sass/components/elements/_pcr.scss index 5176426882..3611782a58 100644 --- a/protected/modules/OphCiExamination/assets/sass/components/elements/_pcr.scss +++ b/protected/modules/OphCiExamination/assets/sass/components/elements/_pcr.scss @@ -7,5 +7,17 @@ background-color: #f00; padding: 5px; text-align: center; + &.red { + background-color: #f00; + } + &.blue { + background-color: #00f; + } + &.orange { + background-color: #ffa500; + } + &.green { + background-color: #0f0; + } } } \ No newline at end of file diff --git a/protected/modules/OphCiExamination/migrations/m161026_095125_pcr_risk_element.php b/protected/modules/OphCiExamination/migrations/m161026_095125_pcr_risk_element.php index 833cdbc90b..32363d2967 100644 --- a/protected/modules/OphCiExamination/migrations/m161026_095125_pcr_risk_element.php +++ b/protected/modules/OphCiExamination/migrations/m161026_095125_pcr_risk_element.php @@ -20,6 +20,8 @@ public function up() 'left_alpha_receptor_blocker' => 'VARCHAR(2)', 'left_doctor_grade_id' => 'INTEGER(11) NOT NULL', 'left_can_lie_flat' => 'VARCHAR(2)', + 'left_pcr_risk' => 'DECIMAL(5,2)', + 'left_excess_risk' => 'DECIMAL(5,2)', 'right_glaucoma' => 'VARCHAR(2)', 'right_pxf' => 'VARCHAR(2)', 'right_diabetic' => 'VARCHAR(2)', @@ -30,6 +32,8 @@ public function up() 'right_alpha_receptor_blocker' => 'VARCHAR(2)', 'right_doctor_grade_id' => 'INTEGER(11) NOT NULL', 'right_can_lie_flat' => 'VARCHAR(2)', + 'right_pcr_risk' => 'DECIMAL(5,2)', + 'right_excess_risk' => 'DECIMAL(5,2)', 'CONSTRAINT el_pcr_eye foreign key (eye_id) references eye (id)', 'CONSTRAINT el_right_pcr_doctor_grade foreign key (right_doctor_grade_id) references doctor_grade (id)', 'CONSTRAINT el_left_pcr_doctor_grade foreign key (left_doctor_grade_id) references doctor_grade (id)', @@ -44,7 +48,7 @@ public function up() public function down() { - //$this->dropOETable('et_ophciexamination_pcr_risk', true); + $this->dropOETable('et_ophciexamination_pcr_risk', true); $this->delete('element_type', 'class_name = "Element_OphCiExamination_PcrRisk"'); } } \ No newline at end of file diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php index d71704572d..ecf6178181 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php @@ -32,9 +32,9 @@ public function rules() array( 'event_id, eye_id, left_glaucoma, left_pxf, left_diabetic, left_pupil_size, left_no_fundal_view, left_axial_length_group, - left_brunescent_white_cataract, left_alpha_receptor_blocker, left_doctor_grade_id, left_can_lie_flat, + left_brunescent_white_cataract, left_alpha_receptor_blocker, left_doctor_grade_id, left_can_lie_flat, left_pcr_risk, left_excess_risk right_glaucoma, right_pxf, right_diabetic, right_pupil_size, right_no_fundal_view, right_axial_length_group, - right_brunescent_white_cataract, right_alpha_receptor_blocker, right_doctor_grade_id, right_can_lie_flat', + right_brunescent_white_cataract, right_alpha_receptor_blocker, right_doctor_grade_id, right_can_lie_flat, right_pcr_risk, right_excess_risk', 'safe', ), ); @@ -121,4 +121,45 @@ public function search() 'criteria' => $criteria, )); } + + /** + * Set the risk to be null if it's empty string to stop it being stored as 0.00 + * + * @return bool + */ + public function beforeSave() + { + if($this->left_pcr_risk === ''){ + $this->left_pcr_risk = null; + } + + if($this->right_pcr_risk === ''){ + $this->right_pcr_risk = null; + } + + return parent::beforeSave(); + } + + /** + * Get the class required to make the risk the correct colour + * + * @param $side + * @return string + */ + public function pcrRiskColour($side) + { + $value = $this->{$side.'_pcr_risk'}; + + if(!$value){ + return 'blue'; + } + + if($value <= 1){ + return 'green'; + }else if ($value > 1 && $value <= 5) { + return 'orange'; + } else { + return 'red'; + } + } } \ No newline at end of file diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php index c145540b11..3900f8cdd9 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php @@ -77,11 +77,13 @@
diff --git a/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php index 060cbfe927..35d6084fbe 100644 --- a/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/view_Element_OphCiExamination_PcrRisk.php @@ -86,6 +86,18 @@
displayValues($element->{$side.'_can_lie_flat'})?>
+
+
+ +
+
+ +
+
\ No newline at end of file From 67916de66b83b132f5ed140672cacc7dcf72a4f5 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 31 Oct 2016 13:57:42 +0000 Subject: [PATCH 060/164] OE-6198: Persist data to existing table for OpNote. --- protected/components/PcrRisk.php | 16 ++++++++-------- .../models/Element_OphCiExamination_PcrRisk.php | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/protected/components/PcrRisk.php b/protected/components/PcrRisk.php index c4d46f4f8d..a1f1cdc0fe 100644 --- a/protected/components/PcrRisk.php +++ b/protected/components/PcrRisk.php @@ -347,15 +347,15 @@ public function persist($side, Patient $patient, $data = array()) if ($existing) { $pcrRiskValues = $existing; } - $data['doctor_grade_id'] = '1'; - $pcrRiskValues->glaucoma = (isset($data['glaucoma']) && $data['glaucoma'] != 'NK') ? $data['glaucoma'] : null; - $pcrRiskValues->pxf = (isset($data['pxf_phako']) && $data['pxf_phako'] != 'NK') ? $data['pxf_phako'] : null; - $pcrRiskValues->diabetic = (isset($data['diabetic']) && $data['diabetic'] != 'NK') ? $data['diabetic'] : null; - $pcrRiskValues->pupil_size = (isset($data['pupil_size']) && $data['pupil_size'] != 'NK') ? $data['pupil_size'] : null; - $pcrRiskValues->no_fundal_view = (isset($data['no_fundal_view']) && $data['no_fundal_view'] != 'NK') ? $data['no_fundal_view'] : null; - $pcrRiskValues->axial_length_group = (isset($data['axial_length']) && $data['axial_length'] != 'NK') ? $data['axial_length'] : null; + + $pcrRiskValues->glaucoma = (isset($data['glaucoma']) && $data['glaucoma'] !== 'NK') ? $data['glaucoma'] : null; + $pcrRiskValues->pxf = (isset($data['pxf_phako']) && $data['pxf_phako'] !== 'NK') ? $data['pxf_phako'] : null; + $pcrRiskValues->diabetic = (isset($data['diabetic']) && $data['diabetic'] !== 'NK') ? $data['diabetic'] : null; + $pcrRiskValues->pupil_size = (isset($data['pupil_size']) && $data['pupil_size'] !== 'NK') ? $data['pupil_size'] : null; + $pcrRiskValues->no_fundal_view = (isset($data['no_fundal_view']) && $data['no_fundal_view'] !== 'NK') ? $data['no_fundal_view'] : null; + $pcrRiskValues->axial_length_group = (isset($data['axial_length']) && $data['axial_length'] !== 'NK') ? $data['axial_length'] : null; $pcrRiskValues->brunescent_white_cataract = (isset($data['brunescent_white_cataract']) && $data['brunescent_white_cataract'] !== 'NK') ? $data['brunescent_white_cataract'] : null; - $pcrRiskValues->alpha_receptor_blocker = (isset($data['arb']) && $data['arb'] != 'NK') ? $data['arb'] : null; + $pcrRiskValues->alpha_receptor_blocker = (isset($data['arb']) && $data['arb'] !== 'NK') ? $data['arb'] : null; $pcrRiskValues->doctor_grade_id = (isset($data['doctor_grade_id']) && $data['doctor_grade_id'] !== '') ? $data['doctor_grade_id'] : null; $pcrRiskValues->can_lie_flat = (isset($data['abletolieflat']) && $data['abletolieflat'] !== 'NK') ? $data['abletolieflat'] : null; diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php index ecf6178181..e9850cd2f3 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php @@ -137,6 +137,23 @@ public function beforeSave() $this->right_pcr_risk = null; } + $pcr = new PcrRisk(); + foreach(array('left', 'right') as $side){ + $data = array( + 'glaucoma' => $this->{$side.'_glaucoma'}, + 'pxf_phako' => $this->{$side.'_pxf'}, + 'diabetic' => $this->{$side.'_diabetic'}, + 'pupil_size' => $this->{$side.'_pupil_size'}, + 'no_fundal_view' => $this->{$side.'_no_fundal_view'}, + 'axial_length' => $this->{$side.'_axial_length_group'}, + 'brunescent_white_cataract' => $this->{$side.'_brunescent_white_cataract'}, + 'arb' => $this->{$side.'_alpha_receptor_blocker'}, + 'doctor_grade_id' => $this->{$side.'_doctor_grade_id'}, + 'abletolieflat' => $this->{$side.'_can_lie_flat'}, + ); + $pcr->persist($side, $this->event->episode->patient, $data); + } + return parent::beforeSave(); } From 885c45722a82857df4e04516fe40237c1ad4c6ff Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 31 Oct 2016 14:22:24 +0000 Subject: [PATCH 061/164] OE-6198: Fixes issue saving opnote with PCR risk Was not setting doctor grade correctly, now it is. --- protected/components/PcrRisk.php | 2 +- protected/views/default/_pcr_risk_form.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protected/components/PcrRisk.php b/protected/components/PcrRisk.php index a1f1cdc0fe..d10da463c5 100644 --- a/protected/components/PcrRisk.php +++ b/protected/components/PcrRisk.php @@ -356,7 +356,7 @@ public function persist($side, Patient $patient, $data = array()) $pcrRiskValues->axial_length_group = (isset($data['axial_length']) && $data['axial_length'] !== 'NK') ? $data['axial_length'] : null; $pcrRiskValues->brunescent_white_cataract = (isset($data['brunescent_white_cataract']) && $data['brunescent_white_cataract'] !== 'NK') ? $data['brunescent_white_cataract'] : null; $pcrRiskValues->alpha_receptor_blocker = (isset($data['arb']) && $data['arb'] !== 'NK') ? $data['arb'] : null; - $pcrRiskValues->doctor_grade_id = (isset($data['doctor_grade_id']) && $data['doctor_grade_id'] !== '') ? $data['doctor_grade_id'] : null; + $pcrRiskValues->doctor_grade_id = (isset($data['pcr_doctor_grade']) && $data['pcr_doctor_grade'] !== '') ? $data['pcr_doctor_grade'] : null; $pcrRiskValues->can_lie_flat = (isset($data['abletolieflat']) && $data['abletolieflat'] !== 'NK') ? $data['abletolieflat'] : null; if (!$pcrRiskValues->save()) { diff --git a/protected/views/default/_pcr_risk_form.php b/protected/views/default/_pcr_risk_form.php index c99d564335..9bf6351d8d 100644 --- a/protected/views/default/_pcr_risk_form.php +++ b/protected/views/default/_pcr_risk_form.php @@ -215,7 +215,7 @@
findAll($criteria->condition = 'has_pcr_risk', array('order' => 'display_order'));?> - From b0a3ea289dc81f8d4723a9c7e373ea94a8ca48bc Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 31 Oct 2016 14:41:55 +0000 Subject: [PATCH 062/164] OE-6198: Fixes for doctor grade on element and js not loading when ajax element. --- .../Element_OphCiExamination_PcrRisk.php | 2 +- .../form_Element_OphCiExamination_PcrRisk.php | 39 +++++++++---------- protected/views/default/_pcr_risk_form.php | 3 +- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php index e9850cd2f3..06428d0ed3 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_PcrRisk.php @@ -148,7 +148,7 @@ public function beforeSave() 'axial_length' => $this->{$side.'_axial_length_group'}, 'brunescent_white_cataract' => $this->{$side.'_brunescent_white_cataract'}, 'arb' => $this->{$side.'_alpha_receptor_blocker'}, - 'doctor_grade_id' => $this->{$side.'_doctor_grade_id'}, + 'pcr_doctor_grade' => $this->{$side.'_doctor_grade_id'}, 'abletolieflat' => $this->{$side.'_can_lie_flat'}, ); $pcr->persist($side, $this->event->episode->patient, $data); diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php index 3900f8cdd9..475e614321 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php @@ -1,7 +1,24 @@ getAssetManager()->registerScriptFile('js/PCRCalculation.js') +$jsPath = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets.js'), false, -1); ?> +
{'has'.ucfirst($side)}()) ? 'active' : 'inactive'; ?>
getPCRData($this->event->episode->patient->id, $side, $element); + $pcr = $pcrRisk->getPCRData(Yii::app()->request->getQuery('patient_id'), $side, $element); echo CHtml::hiddenField('age', $pcr['age_group']); echo CHtml::hiddenField('gender', $pcr['gender']); ?> @@ -105,22 +122,4 @@
- diff --git a/protected/views/default/_pcr_risk_form.php b/protected/views/default/_pcr_risk_form.php index 9bf6351d8d..98598c19ae 100644 --- a/protected/views/default/_pcr_risk_form.php +++ b/protected/views/default/_pcr_risk_form.php @@ -20,8 +20,7 @@ $side = 'left'; } if ($side === 'left') { - $jsPath = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets.js'), - false, -1); + $jsPath = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets.js'), false, -1); ?> From 62112fe07aa3bd6c1e8a5d63ecd588aa399be96d Mon Sep 17 00:00:00 2001 From: petergallagher Date: Wed, 16 Nov 2016 10:57:38 +0000 Subject: [PATCH 082/164] Stops import failing if the email is not sent. --- .../modules/OphCoMessaging/components/MessageCreator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protected/modules/OphCoMessaging/components/MessageCreator.php b/protected/modules/OphCoMessaging/components/MessageCreator.php index bf88e6ed0a..ba78cffd67 100644 --- a/protected/modules/OphCoMessaging/components/MessageCreator.php +++ b/protected/modules/OphCoMessaging/components/MessageCreator.php @@ -182,7 +182,11 @@ public function emailAlert(array $recipients, $subject, $content) $message->setSubject($subject); $message->setBody($content); - return \Yii::app()->mailer->sendMessage($message); + try { + return \Yii::app()->mailer->sendMessage($message); + } catch (\Exception $e) { + return false; + } } } From 4a2ad1c00a56d25f1a28e37307d48cd37113f50d Mon Sep 17 00:00:00 2001 From: petergallagher Date: Mon, 21 Nov 2016 11:03:29 +0000 Subject: [PATCH 083/164] Removes PPAs which do not exist and are not required. Adding these PPAs was causing the build to fail because they don't exist. As they are not required at all they have been removed. --- ansible/tasks/init-debian.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ansible/tasks/init-debian.yml b/ansible/tasks/init-debian.yml index c28ffc13fc..463aad1cbd 100644 --- a/ansible/tasks/init-debian.yml +++ b/ansible/tasks/init-debian.yml @@ -16,14 +16,6 @@ apt_repository: repo='ppa:ondrej/apache2' when: ansible_distribution_release == "precise" and ansible_distribution == "Ubuntu" -- name: Add repository for PHP 5.6. - apt_repository: repo='ppa:ondrej/php5-5.6' - when: php_version == "5.6" and ansible_distribution == "Ubuntu" - -- name: Add repository for PHP 7.0. - apt_repository: repo='ppa:ondrej/php' - when: php_version == "7.0" and ansible_distribution == "Ubuntu" - - name: Define php_xhprof_html_dir. set_fact: php_xhprof_html_dir: "/usr/share/php/xhprof_html" From f588a933fe5e39dd1e3784d96d13f9f77aca3b15 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 24 Nov 2016 11:15:00 +0000 Subject: [PATCH 084/164] OE-6199 Addition of VA and Refraction to Biometry editing page. Addition of functions to ophciexamination_api to get relevant element data to biometry. --- .../components/OphCiExamination_API.php | 197 ++++++++++++ ...form_Element_OphInBiometry_Measurement.php | 295 +++++++++++++++++- ...nt_OphInBiometry_Measurement_OEEyeDraw.php | 39 +++ ...iew_Element_OphInBiometry_VisualAcuity.php | 124 ++++++++ 4 files changed, 645 insertions(+), 10 deletions(-) create mode 100644 protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Measurement_OEEyeDraw.php create mode 100644 protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_VisualAcuity.php diff --git a/protected/modules/OphCiExamination/components/OphCiExamination_API.php b/protected/modules/OphCiExamination/components/OphCiExamination_API.php index 2ac0ed60c6..528a0da7c5 100644 --- a/protected/modules/OphCiExamination/components/OphCiExamination_API.php +++ b/protected/modules/OphCiExamination/components/OphCiExamination_API.php @@ -294,6 +294,17 @@ public function getLetterPosteriorPolePrincipal($patient) } } + public function getRefractionValues($eventid) + { + if ($unit = models\Element_OphCiExamination_Refraction::model()->find('event_id = ' . $eventid)) { + return $unit; + } + + return; + + } + + /** * returns the best visual acuity for the specified side in the given episode for the patient. This is from the most recent * examination that has a visual acuity element. @@ -316,6 +327,138 @@ public function getBestVisualAcuity($patient, $episode, $side) } } + public function getBestNearVisualAcuity($patient, $episode, $side) + { + if ($va = $this->getElementForLatestEventInEpisode($episode, 'models\Element_OphCiExamination_NearVisualAcuity')) { + switch ($side) { + case 'left': + return $va->getBestReading('left'); + case 'right': + return $va->getBestReading('right'); + } + } + } + + public function getVAId($patient, $episode) + { + if ($va = $this->getElementForLatestEventInEpisode($episode, 'models\Element_OphCiExamination_VisualAcuity')) { + return $va; + } + } + + public function getNearVAId($patient, $episode) + { + if ($va = $this->getElementForLatestEventInEpisode($episode, 'models\Element_OphCiExamination_NearVisualAcuity')) { + return $va->id; + } + } + public function getVAvalue($vareading, $unitId) + { + if ($unit = models\OphCiExamination_VisualAcuityUnitValue::model()->find('base_value = ' . $vareading . ' AND unit_id = ' . $unitId)) { + return $unit->value; + } + + return; + + } + + public function getVARight($vaid) + { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0')) { + return $unit; + } + + return; + + } + + public function getVALeft($vaid) + { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1')) { + return $unit; + } + + return; + + } + + + public function getNearVARight($vaid) + { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0')) { + return $unit; + } + + return; + + } + + public function getNearVALeft($vaid) + { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1')) { + return $unit; + } + + return; + + } + + + public function getMethodIdRight($vaid, $episode) + { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0', array($vaid))) { + return $unit; + } + + return; + } + + public function getMethodIdNearRight($vaid, $episode) + { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0', array($vaid))) { + return $unit; + } + + return; + } + + + public function getMethodIdLeft($vaid, $episode) + { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1', array($vaid))) { + return $unit; + } + + return; + } + + public function getMethodIdNearLeft($vaid, $episode) + { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1', array($vaid))) { + return $unit; + } + + return; + } + + + public function getUnitId($vaid, $episode) + { + if ($unit = models\Element_OphCiExamination_VisualAcuity::model()->find('id = ?', array($vaid))) { + return $unit->unit_id; + } + + return; + } + + public function getNearUnitId($vaid, $episode) + { + if ($unit = models\Element_OphCiExamination_NearVisualAcuity::model()->find('id = ?', array($vaid))) { + return $unit->unit_id; + } + + return; + } /** * gets the id for the Snellen Metre unit type for VA. * @@ -330,6 +473,41 @@ protected function getSnellenUnitId() return; } + public function getAllVisualAcuityLeft($patient) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + return ($best = $this->getBestVisualAcuity($patient, $episode, 'left')) ? $best->convertTo($best->value, + $this->getSnellenUnitId()) : null; + } + } + + public function getAllVisualAcuityRight($patient) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + return ($best = $this->getBestVisualAcuity($patient, $episode, 'right')) ? $best->convertTo($best->value, + $this->getSnellenUnitId()) : null; + } + } + + + public function getUnitName($unitId) + { + if ($unit = models\OphCiExamination_VisualAcuityUnit::model()->find('id = ?', array($unitId))) { + return $unit->name; + } + + return; + } + + public function getMethodName($methodId) + { + if ($unit = models\OphCiExamination_VisualAcuity_Method::model()->find('id = ?', array($methodId))) { + return $unit->name; + } + + return; + } + public function getLetterVisualAcuityLeft($patient) { if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { @@ -369,6 +547,25 @@ public function getLetterVisualAcuityPrincipal($patient) } } + /** + * Get a combined string of the different readings. If a unit_id is given, the readings will + * be converted to unit type of that id. + * + * @param string $side + * @param null $unit_id + * + * @return string + */ + public function getCombined($side, $unit_id = null) + { + $combined = array(); + foreach ($this->{$side.'_readings'} as $reading) { + $combined[] = $reading->convertTo($reading->value, $unit_id).' '.$reading->method->name; + } + + return implode(', ', $combined); + } + /** * Get the default findings string from VA in te latest examination event (if it exists). * diff --git a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php index dcaaf055f0..f685cab65f 100644 --- a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php +++ b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php @@ -28,8 +28,270 @@ } else { $iolRefValues = array(); } + ?> +patient->episodes as $episode ){ +// echo $episode->id; +} +if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) { + if ($api->getLetterVisualAcuityRight($this->patient) || $api->getLetterVisualAcuityLeft($this->patient)){ + + $VAid = $api->getVAId($this->patient, $episode); + $unitId = $api->getUnitId($VAid->id, $episode); + + $VAright = $api->getVARight($VAid->id); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); + } + + $VAleft = $api->getVALeft($VAid->id); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); + } + $VAdate = "- (exam date " . date("d M Y h:ia", strtotime($VAid->last_modified_date)) . ")"; + + $methodIdRight = $api->getMethodIdRight($VAid->id, $episode); + for ($i = 0; $i < count($methodIdRight); ++$i) { + $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); + } + + $methodIdLeft = $api->getMethodIdLeft($VAid->id, $episode); + for ($i = 0; $i < count($methodIdLeft); ++$i) { + $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); + } + + $unitnameRight = $api->getUnitName($unitId); + $unitnameLeft = $unitnameRight; + } +} ?> +
+
  +
+
+
+

Visual Acuity

+
+
+
+ hasRight()) { + if ($api->getLetterVisualAcuityRight($this->patient)) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; + if ($i != (count($methodnameRight) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
+ getLetterVisualAcuityLeft($this->patient)) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; + if ($i != (count($methodnameLeft) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
+ +moduleAPI->get('OphCiExamination')) { + if ($api->getBestNearVisualAcuity($this->patient, $episode, 'right') || $api->getBestNearVisualAcuity($this->patient, $episode, 'left')){ + + $VAid = $api->getNearVAId($this->patient, $episode); + $unitId = $api->getNearUnitId($VAid, $episode); + + $VAright = $api->getNearVARight($VAid); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); + } + + $VAleft = $api->getNearVALeft($VAid); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); + } + + $methodIdRight = $api->getMethodIdNearRight($VAid, $episode); + for ($i = 0; $i < count($methodIdRight); ++$i) { + $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); + } + + $methodIdLeft = $api->getMethodIdNearLeft($VAid, $episode); + for ($i = 0; $i < count($methodIdLeft); ++$i) { + $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); + } + + $unitnameRight = $api->getUnitName($unitId); + $unitnameLeft = $unitnameRight; + } +} +?> + +
+

Near Visual Acuity

+
+
+
+ hasRight()) { + if ($api->getBestNearVisualAcuity($this->patient, $episode, 'left')) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; + if ($i != (count($methodnameRight) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
+ getBestNearVisualAcuity($this->patient, $episode, 'right')) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; + if ($i != (count($methodnameLeft) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
+
+find('event_type_id = 27 AND episode_id = ' . $episode->id)){ +if ($refractelement = $api->getRefractionValues($eventid->id)) { +?> +
+
+

Refraction - (exam date last_modified_date)); ?>)

+
+
+
+ hasRight()) { + ?> + renderPartial($element->view_view . '_OEEyeDraw', + array('side' => 'right', 'element' => $refractelement)); + ?> + + Not recorded + +
+
+ hasLeft()) { + ?> + renderPartial($element->view_view . '_OEEyeDraw', + array('side' => 'left', 'element' => $refractelement)); + ?> + + Not recorded + +
+
+ +
Remove side + id, array('class' => 'element_id')); ?> renderPartial('form_Element_OphInBiometry_Measurement_fields', array('side' => 'right', 'element' => $element, 'form' => $form, 'data' => $data, 'measurementInput' => $iolRefValues)); ?>
@@ -62,17 +325,29 @@

LEFT

- Remove side - renderPartial('form_Element_OphInBiometry_Measurement_fields', array('side' => 'left', 'element' => $element, 'form' => $form, 'data' => $data, 'measurementInput' => $iolRefValues)); ?> -
-
-
- - Add left side - + hasLeft()) { + ?> +
+ Remove side + renderPartial('form_Element_OphInBiometry_Measurement_fields', array( + 'side' => 'left', + 'element' => $element, + 'form' => $form, + 'data' => $data, + 'measurementInput' => $iolRefValues + )); ?>
+ +
-
+ \ No newline at end of file diff --git a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Measurement_OEEyeDraw.php b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Measurement_OEEyeDraw.php new file mode 100644 index 0000000000..d5338cb271 --- /dev/null +++ b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Measurement_OEEyeDraw.php @@ -0,0 +1,39 @@ +. + * + * @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 + */ +?> +
+ format->text($element->getCombined($side)) ?>
+ Spherical equivalent: {$side.'_sphere'} + 0.5 * $element->{$side.'_cylinder'}, 2)?> + {$side.'_notes'}) { + ?> + textWithLineBreaks($side.'_notes')?> + +
+
+ widget('application.modules.eyedraw.OEEyeDrawWidget', array( + 'idSuffix' => $side.'_'.$element->elementType->id.'_'.$element->id, + 'side' => ($side == 'right') ? 'R' : 'L', + 'mode' => 'view', + 'width' => 100, + 'height' => 100, + 'model' => $element, + 'attribute' => $side.'_axis_eyedraw', + ))?> +
diff --git a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_VisualAcuity.php b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_VisualAcuity.php new file mode 100644 index 0000000000..731e60ca84 --- /dev/null +++ b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_VisualAcuity.php @@ -0,0 +1,124 @@ +. + * + * @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 + */ +?> + +id, array('class' => 'element_id')); ?> + +
+
+ hasRight()) { + ?> + getCombined('right')) { + ?> +
+
+ unit->name ?> +
+
+
+
+ getCombined('right') ?> +
+
+ +
+
+ Not recorded + right_unable_to_assess) { + ?> + (Unable to assessright_eye_missing) { + ?>, eye missing) + right_eye_missing) { + ?> + (Eye missing) + +
+
+ + +
+
+ Not recorded +
+
+ +
+
+ hasLeft()) { + ?> + getCombined('left')) { + ?> +
+
+ unit->name ?> +
+
+
+
+ getCombined('left') ?> +
+
+ +
+
+ Not recorded + left_unable_to_assess) { + ?> + (Unable to assessleft_eye_missing) { + ?>, eye missing) + left_eye_missing) { + ?> + (Eye missing) + +
+
+ + +
+
+ Not recorded +
+
+ +
+
From 7eedd09e4fa06b7903d69a063f3fe842cac5e1e3 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 24 Nov 2016 16:22:27 +0000 Subject: [PATCH 085/164] OE-6199 Addition of VA and Refraction to Biometry editing page. Addition of functions to ophciexamination_api to get relevant element data to biometry. --- .../components/OphCiExamination_API.php | 32 +- ...form_Element_OphInBiometry_Measurement.php | 646 +++++++++--------- 2 files changed, 353 insertions(+), 325 deletions(-) diff --git a/protected/modules/OphCiExamination/components/OphCiExamination_API.php b/protected/modules/OphCiExamination/components/OphCiExamination_API.php index 528a0da7c5..c1bdab289c 100644 --- a/protected/modules/OphCiExamination/components/OphCiExamination_API.php +++ b/protected/modules/OphCiExamination/components/OphCiExamination_API.php @@ -24,6 +24,10 @@ class OphCiExamination_API extends \BaseAPI { + + const LEFT = 1; + const RIGHT = 0; + /** * Extends parent method to prepend model namespace. * @@ -364,7 +368,8 @@ public function getVAvalue($vareading, $unitId) public function getVARight($vaid) { - if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0')) { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' + . $vaid . ' AND side = ' . self::RIGHT)) { return $unit; } @@ -374,7 +379,8 @@ public function getVARight($vaid) public function getVALeft($vaid) { - if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1')) { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' + . $vaid . ' AND side = ' . self::LEFT)) { return $unit; } @@ -385,7 +391,8 @@ public function getVALeft($vaid) public function getNearVARight($vaid) { - if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0')) { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' + . $vaid . ' AND side = ' . self::RIGHT)) { return $unit; } @@ -395,7 +402,8 @@ public function getNearVARight($vaid) public function getNearVALeft($vaid) { - if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1')) { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' + . $vaid . ' AND side = ' . self::LEFT)) { return $unit; } @@ -406,16 +414,18 @@ public function getNearVALeft($vaid) public function getMethodIdRight($vaid, $episode) { - if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0', array($vaid))) { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' + . $vaid . ' AND side = ' . self::RIGHT)) { return $unit; } return; } - public function getMethodIdNearRight($vaid, $episode) + public function getMethodIdNearRight($vaid) { - if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 0', array($vaid))) { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid + . ' AND side = ' . self::RIGHT)) { return $unit; } @@ -425,16 +435,18 @@ public function getMethodIdNearRight($vaid, $episode) public function getMethodIdLeft($vaid, $episode) { - if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1', array($vaid))) { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid + . ' AND side = ' . self::LEFT)) { return $unit; } return; } - public function getMethodIdNearLeft($vaid, $episode) + public function getMethodIdNearLeft($vaid) { - if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = 1', array($vaid))) { + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $vaid + . ' AND side = ' . self::LEFT)) { return $unit; } diff --git a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php index f685cab65f..8a7c1f9ca6 100644 --- a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php +++ b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php @@ -20,356 +20,372 @@ event != null && $element->event->id > 0) { - $iolRefValues = Element_OphInBiometry_IolRefValues::Model()->findAllByAttributes( - array( - 'event_id' => $element->event->id, - )); - } else { - $iolRefValues = array(); - } - ?> +if ($element->event != null && $element->event->id > 0) { + $iolRefValues = Element_OphInBiometry_IolRefValues::Model()->findAllByAttributes( + array( + 'event_id' => $element->event->id, + )); +} else { + $iolRefValues = array(); +} +?> patient->episodes as $episode ){ +foreach ($this->patient->episodes as $episode) { // echo $episode->id; } if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) { - if ($api->getLetterVisualAcuityRight($this->patient) || $api->getLetterVisualAcuityLeft($this->patient)){ + if ($api->getLetterVisualAcuityRight($this->patient) || $api->getLetterVisualAcuityLeft($this->patient)) { - $VAid = $api->getVAId($this->patient, $episode); - $unitId = $api->getUnitId($VAid->id, $episode); + $VAid = $api->getVAId($this->patient, $episode); + $unitId = $api->getUnitId($VAid->id, $episode); - $VAright = $api->getVARight($VAid->id); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); - } + $VAright = $api->getVARight($VAid->id); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); + } - $VAleft = $api->getVALeft($VAid->id); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); - } - $VAdate = "- (exam date " . date("d M Y h:ia", strtotime($VAid->last_modified_date)) . ")"; + $VAleft = $api->getVALeft($VAid->id); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); + } + $VAdate = "- (exam date " . date("d M Y h:ia", strtotime($VAid->last_modified_date)) . ")"; - $methodIdRight = $api->getMethodIdRight($VAid->id, $episode); - for ($i = 0; $i < count($methodIdRight); ++$i) { - $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); - } + $methodIdRight = $api->getMethodIdRight($VAid->id, $episode); + for ($i = 0; $i < count($methodIdRight); ++$i) { + $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); + } - $methodIdLeft = $api->getMethodIdLeft($VAid->id, $episode); - for ($i = 0; $i < count($methodIdLeft); ++$i) { - $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); - } + $methodIdLeft = $api->getMethodIdLeft($VAid->id, $episode); + for ($i = 0; $i < count($methodIdLeft); ++$i) { + $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); + } - $unitnameRight = $api->getUnitName($unitId); - $unitnameLeft = $unitnameRight; - } + $unitnameRight = $api->getUnitName($unitId); + $unitnameLeft = $unitnameRight; + } } ?>
-
  -
+
  +
-
-

Visual Acuity

-
-
-
- hasRight()) { - if ($api->getLetterVisualAcuityRight($this->patient)) { - ?> -
-
- -
-
-
-
- getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; - if ($i != (count($methodnameRight) - 1)) { - echo ", "; - } - } - ?> -
-
- -
-
- Not recorded -
-
- -
-
- getLetterVisualAcuityLeft($this->patient)) { - ?> -
-
- -
-
-
-
- getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; - if ($i != (count($methodnameLeft) - 1)) { - echo ", "; - } - } - ?> -
-
- -
-
- Not recorded -
-
- -
-
+
+
+

Visual Acuity

+
+
+
+ hasRight()) { + if ($api->getLetterVisualAcuityRight($this->patient)) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; + if ($i != (count($methodnameRight) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
+ getLetterVisualAcuityLeft($this->patient)) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; + if ($i != (count($methodnameLeft) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
moduleAPI->get('OphCiExamination')) { - if ($api->getBestNearVisualAcuity($this->patient, $episode, 'right') || $api->getBestNearVisualAcuity($this->patient, $episode, 'left')){ + if ($api->getBestNearVisualAcuity($this->patient, $episode, + 'right') || $api->getBestNearVisualAcuity($this->patient, $episode, 'left') + ) { - $VAid = $api->getNearVAId($this->patient, $episode); - $unitId = $api->getNearUnitId($VAid, $episode); + $VAid = $api->getNearVAId($this->patient, $episode); + $unitId = $api->getNearUnitId($VAid, $episode); - $VAright = $api->getNearVARight($VAid); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); - } + $VAright = $api->getNearVARight($VAid); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); + } - $VAleft = $api->getNearVALeft($VAid); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); - } + $VAleft = $api->getNearVALeft($VAid); + for ($i = 0; $i < count($VAright); ++$i) { + $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); + } - $methodIdRight = $api->getMethodIdNearRight($VAid, $episode); - for ($i = 0; $i < count($methodIdRight); ++$i) { - $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); - } + $methodIdRight = $api->getMethodIdNearRight($VAid); + for ($i = 0; $i < count($methodIdRight); ++$i) { + $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); + } - $methodIdLeft = $api->getMethodIdNearLeft($VAid, $episode); - for ($i = 0; $i < count($methodIdLeft); ++$i) { - $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); - } + $methodIdLeft = $api->getMethodIdNearLeft($VAid); + for ($i = 0; $i < count($methodIdLeft); ++$i) { + $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); + } - $unitnameRight = $api->getUnitName($unitId); - $unitnameLeft = $unitnameRight; - } + $unitnameRight = $api->getUnitName($unitId); + $unitnameLeft = $unitnameRight; + } } ?> -
-

Near Visual Acuity

-
-
-
- hasRight()) { - if ($api->getBestNearVisualAcuity($this->patient, $episode, 'left')) { - ?> -
-
- -
-
-
-
- getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; - if ($i != (count($methodnameRight) - 1)) { - echo ", "; - } - } - ?> -
-
- -
-
- Not recorded -
-
- -
-
- getBestNearVisualAcuity($this->patient, $episode, 'right')) { - ?> -
-
- -
-
-
-
- getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; - if ($i != (count($methodnameLeft) - 1)) { - echo ", "; - } - } - ?> -
-
- -
-
- Not recorded -
-
- -
-
+
+
+

Near Visual Acuity

+
+
+
+ hasRight()) { + if ($api->getBestNearVisualAcuity($this->patient, $episode, 'left')) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; + if ($i != (count($methodnameRight) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
+ getBestNearVisualAcuity($this->patient, $episode, 'right')) { + ?> +
+
+ +
+
+
+
+ getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; + if ($i != (count($methodnameLeft) - 1)) { + echo ", "; + } + } + ?> +
+
+ +
+
+ Not recorded +
+
+ +
+
find('event_type_id = 27 AND episode_id = ' . $episode->id)){ +if ($eventtype = EventType::model()->find('class_name = "OphCiExamination"')){ + $eventtypeid = $eventtype->id; +} + +if ($eventid = Event::model()->find('event_type_id = ' . $eventtypeid . ' AND episode_id = ' . $episode->id)){ if ($refractelement = $api->getRefractionValues($eventid->id)) { ?>
-
-

Refraction - (exam date last_modified_date)); ?>)

-
-
-
- hasRight()) { - ?> - renderPartial($element->view_view . '_OEEyeDraw', - array('side' => 'right', 'element' => $refractelement)); - ?> - - Not recorded - -
-
- hasLeft()) { - ?> - renderPartial($element->view_view . '_OEEyeDraw', - array('side' => 'left', 'element' => $refractelement)); - ?> - - Not recorded - -
-
- -
-
-
- hiddenInput($element, 'eye_id', false, array('class' => 'sideField')); ?> -
-
-

RIGHT

-
-
- Remove side - id, array('class' => 'element_id')); ?> - renderPartial('form_Element_OphInBiometry_Measurement_fields', array('side' => 'right', 'element' => $element, 'form' => $form, 'data' => $data, 'measurementInput' => $iolRefValues)); ?> -
- -
-
-
-

LEFT

-
-
- hasLeft()) { - ?> -
- Remove side - renderPartial('form_Element_OphInBiometry_Measurement_fields', array( - 'side' => 'left', - 'element' => $element, - 'form' => $form, - 'data' => $data, - 'measurementInput' => $iolRefValues - )); ?> -
- - -
-
-
- \ No newline at end of file + $('#right-eye-lens').removeClass('disabled').addClass('highlighted-lens'); + $('#right-eye-selection').removeClass('disabled').addClass('highlighted-selection'); + $('#right-eye-calculation').removeClass('disabled').addClass('highlighted-calculation'); + } + } + \ No newline at end of file From b8572f39029bf5c36d7df2c0a7a33d7f93132165 Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Thu, 1 Dec 2016 09:45:25 +0000 Subject: [PATCH 086/164] Amended URLs for HSCIC download. --- protected/commands/ProcessHscicDataCommand.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/protected/commands/ProcessHscicDataCommand.php b/protected/commands/ProcessHscicDataCommand.php index fb66b0a944..df1850a3a3 100644 --- a/protected/commands/ProcessHscicDataCommand.php +++ b/protected/commands/ProcessHscicDataCommand.php @@ -62,7 +62,7 @@ class ProcessHscicDataCommand extends CConsoleCommand * * @var string */ - private static $base_url = 'http://systems.digital.nhs.uk'; + private static $base_url = 'https://digital.nhs.uk'; /** @@ -73,31 +73,31 @@ class ProcessHscicDataCommand extends CConsoleCommand private static $file_config = array( 'full' => array( 'gp' => array( - 'url' => '/data/ods/datadownloads/data-files/egpcur.zip', + 'url' => '/media/370/egpcur/zip/egpcur.zip', 'fields' => array('code', 'name', '', '', 'addr1', 'addr2', 'addr3', 'addr4', 'addr5', 'postcode', '', '', 'status', '', '', '', '', 'phone'), ), 'practice' => array( - 'url' => '/data/ods/datadownloads/data-files/epraccur.zip', + 'url' => '/media/372/epraccur/zip/epraccur.zip', 'fields' => array('code', 'name', '', '', 'addr1', 'addr2', 'addr3', 'addr4', 'addr5', 'postcode', '', '', 'status', '', '', '', '', 'phone'), ), 'ccg' => array( - 'url' => '/data/ods/datadownloads/data-files/eccg.zip', + 'url' => '/media/354/eccg/zip/eccg1.zip', 'fields' => array('code', 'name', '', '', 'addr1', 'addr2', 'addr3', 'addr4', 'addr5', 'postcode'), ), 'ccgAssignment' => array( - 'url' => '/data/ods/datadownloads/data-files/epcmem.zip', + 'url' => '/media/378/epcmem/zip/epcmem.zip', 'fields' => array('practice_code', 'ccg_code'), ), ), 'monthly' => array( 'gp' => array( - 'url' => '/data/ods/datadownloads/monthamend/current/egpam.zip', + 'url' => '/media/510/egpam/zip/egpam.zip', 'fields' => array('code', 'name', '', '', 'addr1', 'addr2', 'addr3', 'addr4', 'addr5', 'postcode', '', '', 'status', '', '', '', '', 'phone'), ), ), 'quarterly' => array( 'gp' => array( - 'url' => '/data/ods/datadownloads/quartamend/current/egpaq.zip', + 'url' => '/media/530/egpaq/zip/egpaq.zip', 'fields' => array('code', 'name', '', '', 'addr1', 'addr2', 'addr3', 'addr4', 'addr5', 'postcode', '', '', 'status', '', '', '', '', 'phone'), ), ), From ec1e1e5d7cda7704056d6f31a61625428254ab0c Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Thu, 1 Dec 2016 10:03:08 +0000 Subject: [PATCH 087/164] Second fix for HSCIC URLs, one of which has two aliases. --- protected/commands/ProcessHscicDataCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/commands/ProcessHscicDataCommand.php b/protected/commands/ProcessHscicDataCommand.php index df1850a3a3..312ddaab2c 100644 --- a/protected/commands/ProcessHscicDataCommand.php +++ b/protected/commands/ProcessHscicDataCommand.php @@ -81,7 +81,7 @@ class ProcessHscicDataCommand extends CConsoleCommand 'fields' => array('code', 'name', '', '', 'addr1', 'addr2', 'addr3', 'addr4', 'addr5', 'postcode', '', '', 'status', '', '', '', '', 'phone'), ), 'ccg' => array( - 'url' => '/media/354/eccg/zip/eccg1.zip', + 'url' => '/media/354/eccg/zip/eccg.zip', 'fields' => array('code', 'name', '', '', 'addr1', 'addr2', 'addr3', 'addr4', 'addr5', 'postcode'), ), 'ccgAssignment' => array( From ef94a9d79b123fb84098fe6ef59641e52e650b17 Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Thu, 1 Dec 2016 11:19:11 +0000 Subject: [PATCH 088/164] Fixed RRule to 1.2.0 --- composer.json | 2 +- composer.lock | 373 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 223 insertions(+), 152 deletions(-) diff --git a/composer.json b/composer.json index 6d80129e23..e0f592cc66 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Electronic Patient Record system for use in Ophthalmology clinics", "require": { "yiisoft/yii": "1.1.14", - "rlanvin/php-rrule": "1.*", + "rlanvin/php-rrule": "1.2.0", "endroid/qrcode": "^1.7", "setasign/fpdi-fpdf": "1.6.1" }, diff --git a/composer.lock b/composer.lock index 803ba2d96d..efed77e12f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f981b5cb6767c941ce21c6b58d831452", - "content-hash": "8879bd938cd8bc920285aba94672e6dd", + "hash": "92ef107970ebc499588b90a94b530ff3", + "content-hash": "beff8b76e4b41cec8a5709e9460eb32f", "packages": [ { "name": "endroid/qrcode", @@ -60,16 +60,16 @@ }, { "name": "rlanvin/php-rrule", - "version": "v1.3.1", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/rlanvin/php-rrule.git", - "reference": "989ddb9d9decc81306831f83dc848c8aa5247208" + "reference": "33fe88ff9ec27205e7802b560764207eb48564c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rlanvin/php-rrule/zipball/989ddb9d9decc81306831f83dc848c8aa5247208", - "reference": "989ddb9d9decc81306831f83dc848c8aa5247208", + "url": "https://api.github.com/repos/rlanvin/php-rrule/zipball/33fe88ff9ec27205e7802b560764207eb48564c7", + "reference": "33fe88ff9ec27205e7802b560764207eb48564c7", "shasum": "" }, "require": { @@ -97,7 +97,7 @@ "recurring", "rrule" ], - "time": "2016-08-09 12:13:42" + "time": "2016-04-09 15:37:43" }, { "name": "setasign/fpdf", @@ -233,16 +233,16 @@ }, { "name": "symfony/options-resolver", - "version": "v3.1.4", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "30605874d99af0cde6c41fd39e18546330c38100" + "reference": "45940bcad6388b3b6058107eca67ced738d205bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/30605874d99af0cde6c41fd39e18546330c38100", - "reference": "30605874d99af0cde6c41fd39e18546330c38100", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/45940bcad6388b3b6058107eca67ced738d205bb", + "reference": "45940bcad6388b3b6058107eca67ced738d205bb", "shasum": "" }, "require": { @@ -251,7 +251,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -283,7 +283,7 @@ "configuration", "options" ], - "time": "2016-05-12 15:59:27" + "time": "2016-05-13 18:13:23" }, { "name": "yiisoft/yii", @@ -1149,18 +1149,21 @@ }, { "name": "erusev/parsedown", - "version": "1.6.0", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/erusev/parsedown.git", - "reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7" + "reference": "20ff8bbb57205368b4b42d094642a3e52dac85fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erusev/parsedown/zipball/3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7", - "reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/20ff8bbb57205368b4b42d094642a3e52dac85fb", + "reference": "20ff8bbb57205368b4b42d094642a3e52dac85fb", "shasum": "" }, + "require": { + "php": ">=5.3.0" + }, "type": "library", "autoload": { "psr-0": { @@ -1184,20 +1187,20 @@ "markdown", "parser" ], - "time": "2015-10-04 16:44:32" + "time": "2016-11-02 15:56:58" }, { "name": "fabpot/goutte", - "version": "v3.1.2", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/Goutte.git", - "reference": "3cbc6ed222422a28400e470050f14928a153207e" + "reference": "8cc89de5e71daf84051859616891d3320d88a9e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/3cbc6ed222422a28400e470050f14928a153207e", - "reference": "3cbc6ed222422a28400e470050f14928a153207e", + "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/8cc89de5e71daf84051859616891d3320d88a9e8", + "reference": "8cc89de5e71daf84051859616891d3320d88a9e8", "shasum": "" }, "require": { @@ -1210,7 +1213,7 @@ "type": "application", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -1233,7 +1236,7 @@ "keywords": [ "scraper" ], - "time": "2015-11-05 12:58:44" + "time": "2016-11-15 16:27:29" }, { "name": "guzzle/guzzle", @@ -1333,16 +1336,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.2.1", + "version": "6.2.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427" + "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ebf29dee597f02f09f4d5bbecc68230ea9b08f60", + "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60", "shasum": "" }, "require": { @@ -1391,20 +1394,20 @@ "rest", "web service" ], - "time": "2016-07-15 17:22:37" + "time": "2016-10-08 15:01:37" }, { "name": "guzzlehttp/promises", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" + "reference": "2693c101803ca78b27972d84081d027fca790a1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", + "url": "https://api.github.com/repos/guzzle/promises/zipball/2693c101803ca78b27972d84081d027fca790a1e", + "reference": "2693c101803ca78b27972d84081d027fca790a1e", "shasum": "" }, "require": { @@ -1442,7 +1445,7 @@ "keywords": [ "promise" ], - "time": "2016-05-18 16:56:05" + "time": "2016-11-18 17:47:58" }, { "name": "guzzlehttp/psr7", @@ -1766,16 +1769,16 @@ }, { "name": "jms/serializer", - "version": "1.3.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/schmittjoh/serializer.git", - "reference": "705d0b4633b9c44e6253aa18306b3972282cd3a3" + "reference": "f39d8b4660d5cef43b0c3265ce642173d9b2c58b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/705d0b4633b9c44e6253aa18306b3972282cd3a3", - "reference": "705d0b4633b9c44e6253aa18306b3972282cd3a3", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/f39d8b4660d5cef43b0c3265ce642173d9b2c58b", + "reference": "f39d8b4660d5cef43b0c3265ce642173d9b2c58b", "shasum": "" }, "require": { @@ -1793,6 +1796,7 @@ "require-dev": { "doctrine/orm": "~2.1", "doctrine/phpcr-odm": "^1.3|^2.0", + "ext-pdo_sqlite": "*", "jackalope/jackalope-doctrine-dbal": "^1.1.5", "phpunit/phpunit": "^4.8|^5.0", "propel/propel1": "~1.7", @@ -1809,7 +1813,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1836,7 +1840,7 @@ "serialization", "xml" ], - "time": "2016-08-23 17:20:24" + "time": "2016-11-13 10:20:11" }, { "name": "justinrainbow/json-schema", @@ -1948,16 +1952,16 @@ }, { "name": "monolog/monolog", - "version": "1.21.0", + "version": "1.22.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952" + "reference": "bad29cb8d18ab0315e6c477751418a82c850d558" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f42fbdfd53e306bda545845e4dbfd3e72edb4952", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bad29cb8d18ab0315e6c477751418a82c850d558", + "reference": "bad29cb8d18ab0315e6c477751418a82c850d558", "shasum": "" }, "require": { @@ -1968,7 +1972,7 @@ "psr/log-implementation": "1.0.0" }, "require-dev": { - "aws/aws-sdk-php": "^2.4.9", + "aws/aws-sdk-php": "^2.4.9 || ^3.0", "doctrine/couchdb": "~1.0@dev", "graylog2/gelf-php": "~1.0", "jakub-onderka/php-parallel-lint": "0.9", @@ -2022,7 +2026,7 @@ "logging", "psr-3" ], - "time": "2016-07-29 03:23:52" + "time": "2016-11-26 00:15:39" }, { "name": "nikic/php-parser", @@ -2488,21 +2492,21 @@ }, { "name": "phpmd/phpmd", - "version": "2.4.3", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "2b9c2417a18696dfb578b38c116cd0ddc19b256e" + "reference": "9298602a922cd8c46666df8d540a60bc5925ce55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/2b9c2417a18696dfb578b38c116cd0ddc19b256e", - "reference": "2b9c2417a18696dfb578b38c116cd0ddc19b256e", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/9298602a922cd8c46666df8d540a60bc5925ce55", + "reference": "9298602a922cd8c46666df8d540a60bc5925ce55", "shasum": "" }, "require": { "pdepend/pdepend": "^2.0.4", - "php": ">=5.3.0" + "php": ">=5.3.9" }, "require-dev": { "phpunit/phpunit": "^4.0", @@ -2549,7 +2553,7 @@ "phpmd", "pmd" ], - "time": "2016-04-04 11:52:04" + "time": "2016-11-23 20:33:32" }, { "name": "phpoption/phpoption", @@ -2722,16 +2726,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "shasum": "" }, "require": { @@ -2765,7 +2769,7 @@ "filesystem", "iterator" ], - "time": "2015-06-21 13:08:43" + "time": "2016-10-03 07:40:28" }, { "name": "phpunit/php-invoker", @@ -3271,22 +3275,30 @@ }, { "name": "psr/log", - "version": "1.0.0", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", "shasum": "" }, + "require": { + "php": ">=5.3.0" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { - "psr-0": { - "Psr\\Log\\": "" + "psr-4": { + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", @@ -3300,12 +3312,13 @@ } ], "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ "log", "psr", "psr-3" ], - "time": "2012-12-21 11:40:51" + "time": "2016-10-10 12:19:37" }, { "name": "sebastian/finder-facade", @@ -3479,16 +3492,16 @@ }, { "name": "seld/jsonlint", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/Seldaek/jsonlint.git", - "reference": "66834d3e3566bb5798db7294619388786ae99394" + "reference": "19495c181d6d53a0a13414154e52817e3b504189" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/66834d3e3566bb5798db7294619388786ae99394", - "reference": "66834d3e3566bb5798db7294619388786ae99394", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/19495c181d6d53a0a13414154e52817e3b504189", + "reference": "19495c181d6d53a0a13414154e52817e3b504189", "shasum": "" }, "require": { @@ -3521,7 +3534,7 @@ "parser", "validator" ], - "time": "2015-11-21 02:21:41" + "time": "2016-11-14 17:59:58" }, { "name": "sensiolabs/behat-page-object-extension", @@ -3580,16 +3593,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.7.0", + "version": "2.7.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed" + "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", - "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9b324f3a1132459a7274a0ace2e1b766ba80930f", + "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f", "shasum": "" }, "require": { @@ -3654,20 +3667,20 @@ "phpcs", "standards" ], - "time": "2016-09-01 23:53:02" + "time": "2016-11-30 04:02:31" }, { "name": "symfony/browser-kit", - "version": "v3.1.4", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "d2a07cc11c5fa94820240b1e67592ffb18e347b9" + "reference": "34348c2691ce6254e8e008026f4c5e72c22bb318" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/d2a07cc11c5fa94820240b1e67592ffb18e347b9", - "reference": "d2a07cc11c5fa94820240b1e67592ffb18e347b9", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/34348c2691ce6254e8e008026f4c5e72c22bb318", + "reference": "34348c2691ce6254e8e008026f4c5e72c22bb318", "shasum": "" }, "require": { @@ -3684,7 +3697,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -3711,20 +3724,20 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2016-07-26 08:04:17" + "time": "2016-10-13 13:35:11" }, { "name": "symfony/config", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "005bf10c156335ede2e89fb9a9ee10a0b742bc84" + "reference": "1361bc4e66f97b6202ae83f4190e962c624b5e61" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/005bf10c156335ede2e89fb9a9ee10a0b742bc84", - "reference": "005bf10c156335ede2e89fb9a9ee10a0b742bc84", + "url": "https://api.github.com/repos/symfony/config/zipball/1361bc4e66f97b6202ae83f4190e962c624b5e61", + "reference": "1361bc4e66f97b6202ae83f4190e962c624b5e61", "shasum": "" }, "require": { @@ -3764,24 +3777,25 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-08-16 14:56:08" + "time": "2016-11-03 07:52:58" }, { "name": "symfony/console", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3d3e4fa5f0614c8e45220e5de80332322e33bd90" + "reference": "a871ba00e0f604dceac64c56c27f99fbeaf4854e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3d3e4fa5f0614c8e45220e5de80332322e33bd90", - "reference": "3d3e4fa5f0614c8e45220e5de80332322e33bd90", + "url": "https://api.github.com/repos/symfony/console/zipball/a871ba00e0f604dceac64c56c27f99fbeaf4854e", + "reference": "a871ba00e0f604dceac64c56c27f99fbeaf4854e", "shasum": "" }, "require": { "php": ">=5.3.9", + "symfony/debug": "~2.7,>=2.7.2|~3.0.0", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -3824,20 +3838,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" + "time": "2016-11-15 23:02:12" }, { "name": "symfony/css-selector", - "version": "v3.1.4", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "2851e1932d77ce727776154d659b232d061e816a" + "reference": "e1241f275814827c411d922ba8e64cf2a00b2994" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/2851e1932d77ce727776154d659b232d061e816a", - "reference": "2851e1932d77ce727776154d659b232d061e816a", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/e1241f275814827c411d922ba8e64cf2a00b2994", + "reference": "e1241f275814827c411d922ba8e64cf2a00b2994", "shasum": "" }, "require": { @@ -3846,7 +3860,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -3877,20 +3891,77 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:41:56" + "time": "2016-11-03 08:11:03" + }, + { + "name": "symfony/debug", + "version": "v3.0.9", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2016-07-30 07:22:48" }, { "name": "symfony/dependency-injection", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "0a732a9cafc30e54077967da4d019e1d618a8cb9" + "reference": "9d2c5033ca70ceade8d7584f997a9d3943f0fe5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/0a732a9cafc30e54077967da4d019e1d618a8cb9", - "reference": "0a732a9cafc30e54077967da4d019e1d618a8cb9", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/9d2c5033ca70ceade8d7584f997a9d3943f0fe5f", + "reference": "9d2c5033ca70ceade8d7584f997a9d3943f0fe5f", "shasum": "" }, "require": { @@ -3940,20 +4011,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-09-06 23:19:39" + "time": "2016-11-18 21:10:01" }, { "name": "symfony/dom-crawler", - "version": "v3.1.4", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "bb7395e8b1db3654de82b9f35d019958276de4d7" + "reference": "c6b6111f5aae7c58698cdc10220785627ac44a2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/bb7395e8b1db3654de82b9f35d019958276de4d7", - "reference": "bb7395e8b1db3654de82b9f35d019958276de4d7", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/c6b6111f5aae7c58698cdc10220785627ac44a2c", + "reference": "c6b6111f5aae7c58698cdc10220785627ac44a2c", "shasum": "" }, "require": { @@ -3969,7 +4040,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -3996,20 +4067,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2016-08-05 08:37:39" + "time": "2016-11-25 12:32:42" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8" + "reference": "25c576abd4e0f212e678fe8b2bd9a9a98c7ea934" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/889983a79a043dfda68f38c38b6dba092dd49cd8", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/25c576abd4e0f212e678fe8b2bd9a9a98c7ea934", + "reference": "25c576abd4e0f212e678fe8b2bd9a9a98c7ea934", "shasum": "" }, "require": { @@ -4056,7 +4127,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-07-28 16:56:28" + "time": "2016-10-13 01:43:15" }, { "name": "symfony/filesystem", @@ -4109,16 +4180,16 @@ }, { "name": "symfony/finder", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "bec5533e6ed650547d6ec8de4b541dc9929066f7" + "reference": "0023b024363dfc0cd21262e556f25a291fe8d7fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/bec5533e6ed650547d6ec8de4b541dc9929066f7", - "reference": "bec5533e6ed650547d6ec8de4b541dc9929066f7", + "url": "https://api.github.com/repos/symfony/finder/zipball/0023b024363dfc0cd21262e556f25a291fe8d7fd", + "reference": "0023b024363dfc0cd21262e556f25a291fe8d7fd", "shasum": "" }, "require": { @@ -4154,20 +4225,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-08-26 11:57:43" + "time": "2016-11-03 07:52:58" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", "shasum": "" }, "require": { @@ -4179,7 +4250,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -4213,20 +4284,20 @@ "portable", "shim" ], - "time": "2016-05-18 14:26:46" + "time": "2016-11-14 01:06:16" }, { "name": "symfony/process", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "05a03ed27073638658cab9405d99a67dd1014987" + "reference": "024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/05a03ed27073638658cab9405d99a67dd1014987", - "reference": "05a03ed27073638658cab9405d99a67dd1014987", + "url": "https://api.github.com/repos/symfony/process/zipball/024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f", + "reference": "024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f", "shasum": "" }, "require": { @@ -4262,11 +4333,11 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" + "time": "2016-09-29 14:03:54" }, { "name": "symfony/stopwatch", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", @@ -4315,16 +4386,16 @@ }, { "name": "symfony/translation", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "bf0ff95faa9b6c0708efc1986255e3608d0ed3c7" + "reference": "edbe67e8f729885b55421d5cc58223d48540df07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/bf0ff95faa9b6c0708efc1986255e3608d0ed3c7", - "reference": "bf0ff95faa9b6c0708efc1986255e3608d0ed3c7", + "url": "https://api.github.com/repos/symfony/translation/zipball/edbe67e8f729885b55421d5cc58223d48540df07", + "reference": "edbe67e8f729885b55421d5cc58223d48540df07", "shasum": "" }, "require": { @@ -4375,20 +4446,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" + "time": "2016-11-18 21:10:01" }, { "name": "symfony/validator", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/validator.git", - "reference": "53b1b1d3f7550e4b1e365dbad39a0b6c60bfcf85" + "reference": "c4ef882117461a4151064ad16c5d638dd1c70b9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/53b1b1d3f7550e4b1e365dbad39a0b6c60bfcf85", - "reference": "53b1b1d3f7550e4b1e365dbad39a0b6c60bfcf85", + "url": "https://api.github.com/repos/symfony/validator/zipball/c4ef882117461a4151064ad16c5d638dd1c70b9e", + "reference": "c4ef882117461a4151064ad16c5d638dd1c70b9e", "shasum": "" }, "require": { @@ -4448,20 +4519,20 @@ ], "description": "Symfony Validator Component", "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" + "time": "2016-11-18 21:10:01" }, { "name": "symfony/yaml", - "version": "v2.8.11", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "e7540734bad981fe59f8ef14b6fc194ae9df8d9c" + "reference": "befb26a3713c97af90d25dd12e75621ef14d91ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/e7540734bad981fe59f8ef14b6fc194ae9df8d9c", - "reference": "e7540734bad981fe59f8ef14b6fc194ae9df8d9c", + "url": "https://api.github.com/repos/symfony/yaml/zipball/befb26a3713c97af90d25dd12e75621ef14d91ff", + "reference": "befb26a3713c97af90d25dd12e75621ef14d91ff", "shasum": "" }, "require": { @@ -4497,7 +4568,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-09-02 01:57:56" + "time": "2016-11-14 16:15:57" }, { "name": "theseer/fdomdocument", @@ -4541,16 +4612,16 @@ }, { "name": "twig/twig", - "version": "v1.24.2", + "version": "v1.28.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "33093f6e310e6976baeac7b14f3a6ec02f2d79b7" + "reference": "b22ce0eb070e41f7cba65d78fe216de29726459c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/33093f6e310e6976baeac7b14f3a6ec02f2d79b7", - "reference": "33093f6e310e6976baeac7b14f3a6ec02f2d79b7", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/b22ce0eb070e41f7cba65d78fe216de29726459c", + "reference": "b22ce0eb070e41f7cba65d78fe216de29726459c", "shasum": "" }, "require": { @@ -4558,12 +4629,12 @@ }, "require-dev": { "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~2.7" + "symfony/phpunit-bridge": "~3.2@dev" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.24-dev" + "dev-master": "1.28-dev" } }, "autoload": { @@ -4598,7 +4669,7 @@ "keywords": [ "templating" ], - "time": "2016-09-01 17:50:53" + "time": "2016-11-23 18:41:40" }, { "name": "zendframework/zend-cache", From b48220ccf7f35cdfe5caf3fdda92eaf3b7ac3787 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 1 Dec 2016 15:44:05 +0000 Subject: [PATCH 089/164] Fixes inefficient counting of relations Replaces inefficient counting of related rows in PHP with an SQL count. Also @$error from controller as it's not needed and ugly. --- .../controllers/WorklistAdminController.php | 1 - protected/models/WorklistDefinition.php | 75 +++++++++++++------ .../views/admin/worklists/definitions.php | 6 +- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/protected/controllers/WorklistAdminController.php b/protected/controllers/WorklistAdminController.php index 3b04013302..d2fbe470ea 100644 --- a/protected/controllers/WorklistAdminController.php +++ b/protected/controllers/WorklistAdminController.php @@ -56,7 +56,6 @@ public function actionDefinitions() $this->render('//admin/worklists/definitions', array( 'definitions' => $definitions, - 'errors' => @$errors, )); } diff --git a/protected/models/WorklistDefinition.php b/protected/models/WorklistDefinition.php index 8d4b02a8e2..bd0718aa9c 100644 --- a/protected/models/WorklistDefinition.php +++ b/protected/models/WorklistDefinition.php @@ -22,19 +22,19 @@ * * The followings are the available columns in table: * - * @property int $id - * @property string $name - * @property string $rrule - * @property string $description - * @property string $worklist_name - * @property string $start_time - * @property string $end_time - * @property DateTime $active_from - * @property DateTime $active_until - * @property Worklist[] $worklists - * @property WorklistDefinitionMapping[] $mappings - * @property WorklistDefinitionMappingp[] $displayed_mappings - * @property WorklistDefinitionMappingp[] $hidden_mappings + * @property int $id + * @property string $name + * @property string $rrule + * @property string $description + * @property string $worklist_name + * @property string $start_time + * @property string $end_time + * @property DateTime $active_from + * @property DateTime $active_until + * @property Worklist[] $worklists + * @property WorklistDefinitionMapping[] $mappings + * @property WorklistDefinitionMappingp[] $displayed_mappings + * @property WorklistDefinitionMappingp[] $hidden_mappings * @property WorklistDefinitionDisplayContext[] $display_contexts */ class WorklistDefinition extends BaseActiveRecordVersioned @@ -54,7 +54,7 @@ public function tableName() */ public function defaultScope() { - return array('order' => $this->getTableAlias(true, false).'.display_order'); + return array('order' => $this->getTableAlias(true, false) . '.display_order'); } /** @@ -79,7 +79,7 @@ public function rules() 'allowEmpty' => true, 'allowCompareEmpty' => true, 'operator' => '<=', - 'message' => '{attribute} must be on or before {compareAttribute}' + 'message' => '{attribute} must be on or before {compareAttribute}', ), array('active_from', 'default', 'setOnEmpty' => true, 'value' => date("Y-m-d H:i:s", time())), array('active_until', 'default', 'setOnEmpty' => true, 'value' => null), @@ -90,7 +90,7 @@ public function rules() array( 'id, name, rrule, worklist_name, start_time, end_time, description, scheduled', 'safe', - 'on' => 'search' + 'on' => 'search', ), ); } @@ -110,15 +110,15 @@ public function relations() 'WorklistDefinitionMapping', 'worklist_definition_id', 'on' => 'display_order is NOT NULL', - 'order' => 'display_order ASC' + 'order' => 'display_order ASC', ), 'hidden_mappings' => array( self::HAS_MANY, 'WorklistDefinitionMapping', 'worklist_definition_id', - 'on' => 'display_order is NULL' + 'on' => 'display_order is NULL', ), - 'display_contexts' => array(self::HAS_MANY, 'WorklistDefinitionDisplayContext', 'worklist_definition_id') + 'display_contexts' => array(self::HAS_MANY, 'WorklistDefinitionDisplayContext', 'worklist_definition_id'), ); } @@ -190,7 +190,7 @@ public function validateRrule($attribute) $valid = false; } if (!$valid) { - $this->addError($attribute, $this->getAttributeLabel($attribute).' is not valid'); + $this->addError($attribute, $this->getAttributeLabel($attribute) . ' is not valid'); } } @@ -198,7 +198,7 @@ public function validateRrule($attribute) * Check whether the given key would be unique on the Definition * (optional id indicates the current mapping the key is from so it is not checked against itself). * - * @param $key + * @param $key * @param int $id * * @return bool @@ -251,11 +251,42 @@ public function getRruleHumanReadable() } $final_rrule = new RRule($rrule_str); + return $final_rrule->humanReadable(array( 'date_formatter' => function ($d) { return $d->format(Helper::NHS_DATE_FORMAT); - } + }, )); } } + + /** + * @return CDbDataReader|mixed|string + */ + public function getWorklistCount() + { + $sql = 'SELECT COUNT(id) FROM worklist where worklist_definition_id = ' . $this->id; + + return $this->getDbConnection()->createCommand($sql)->queryScalar(); + } + + /** + * @return CDbDataReader|mixed|string + */ + public function getMappingCount() + { + $sql = 'SELECT COUNT(id) FROM worklist_definition_mapping where worklist_definition_id = ' . $this->id; + + return $this->getDbConnection()->createCommand($sql)->queryScalar(); + } + + /** + * @return CDbDataReader|mixed|string + */ + public function getdisplayContextCount() + { + $sql = 'SELECT COUNT(id) FROM worklist_definition_display_context where worklist_definition_id = ' . $this->id; + + return $this->getDbConnection()->createCommand($sql)->queryScalar(); + } } diff --git a/protected/views/admin/worklists/definitions.php b/protected/views/admin/worklists/definitions.php index 1b7ce6d6d3..2d4643a4fc 100644 --- a/protected/views/admin/worklists/definitions.php +++ b/protected/views/admin/worklists/definitions.php @@ -37,9 +37,9 @@ name?> manager->canUpdateWorklistDefinition($definition)) {?>Edit | View | - Instances (worklists)?>) | - Mapping Items(mappings)?>) | - Display Context (display_contexts) > 0 ? 'limited' : 'any';?>) | + Instances (worklistCount?>) | + Mapping Items(mappingCount?>) | + Display Context (displayContextCount > 0 ? 'limited' : 'any';?>) | worklists)) {?> Delete Instances From 7ca9768a6e625c12f8296f93f345ba4289a2455c Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 1 Dec 2016 15:47:54 +0000 Subject: [PATCH 090/164] Removes missed lazy count. --- protected/views/admin/worklists/definitions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/views/admin/worklists/definitions.php b/protected/views/admin/worklists/definitions.php index 2d4643a4fc..c3212f7f42 100644 --- a/protected/views/admin/worklists/definitions.php +++ b/protected/views/admin/worklists/definitions.php @@ -40,7 +40,7 @@ Instances (worklistCount?>) | Mapping Items(mappingCount?>) | Display Context (displayContextCount > 0 ? 'limited' : 'any';?>) | - worklists)) {?> + worklistCount) {?> Delete Instances Generate | From b7505d21ce346ff3125ec72ae261c4c08ca78ea1 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 1 Dec 2016 15:53:23 +0000 Subject: [PATCH 091/164] Removes more missed lazy count. --- protected/components/WorklistManager.php | 2 +- protected/views/admin/worklists/definition_worklists_delete.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protected/components/WorklistManager.php b/protected/components/WorklistManager.php index 840bfedaa7..aa241fa876 100644 --- a/protected/components/WorklistManager.php +++ b/protected/components/WorklistManager.php @@ -1411,7 +1411,7 @@ public function canUpdateWorklistDefinition(WorklistDefinition $definition) return true; } - return $definition->isNewRecord || count($definition->worklists) == 0; + return $definition->isNewRecord || $definition->getWorklistCount() == 0; } /** diff --git a/protected/views/admin/worklists/definition_worklists_delete.php b/protected/views/admin/worklists/definition_worklists_delete.php index 41df83c1d3..fa27cffbc2 100644 --- a/protected/views/admin/worklists/definition_worklists_delete.php +++ b/protected/views/admin/worklists/definition_worklists_delete.php @@ -19,7 +19,7 @@

Confirm Delete

Are you sure you want to delete all the instances for the worklist definition name ?>? - There are currently worklists) ?> instances that have been generated.

+ There are currently getWorklistCount() ?> instances that have been generated.

From 2f7e68a15e2f10348582afdf84e9c368757bd5c6 Mon Sep 17 00:00:00 2001 From: Sabi Date: Mon, 5 Dec 2016 15:24:54 +0000 Subject: [PATCH 092/164] Correspondence : Add default option (-- Macro --) to macro dropdown, 2 error fixed --- .../models/ElementLetter.php | 2 +- .../views/default/create_ElementLetter.php | 2 +- .../views/default/update_ElementLetter.php | 2 +- protected/views/docman/index.php | 32 ++++++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/models/ElementLetter.php b/protected/modules/OphCoCorrespondence/models/ElementLetter.php index 4329def80b..9663b5539e 100644 --- a/protected/modules/OphCoCorrespondence/models/ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/models/ElementLetter.php @@ -156,7 +156,7 @@ public function getAddress_targets() $options = array($patient->contact->id => $patient->fullname.' (Patient)'); if (!isset($patient->contact->address)) { - $options['Patient'.$patient->id] .= ' - NO ADDRESS'; + $options[$patient->contact->id] .= ' - NO ADDRESS'; } if ($patient->gp) { diff --git a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php index 0c8bcb5fd6..2948b3a76c 100644 --- a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php @@ -48,7 +48,7 @@
- letter_macros, '', array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width'));?> + letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width'));?>
diff --git a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php index 0dff9e74aa..e68c7c4894 100644 --- a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php @@ -59,7 +59,7 @@
- letter_macros, '', array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width'));?> + letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width'));?>
diff --git a/protected/views/docman/index.php b/protected/views/docman/index.php index 4af50030d5..70d5fd1a55 100644 --- a/protected/views/docman/index.php +++ b/protected/views/docman/index.php @@ -57,21 +57,23 @@ if($this->getApp()->request->isPostRequest){ $data = $_POST; $data['correspondence_mode'] = true; - foreach($_POST['target_type'] as $key => $target_type){ - if($target_type == 'To'){ - $data['to'] = array( - 'contact_id' => $_POST['contact_id'][$key], - 'contact_type' => $_POST['contact_type'][$key], - 'address' => $_POST['address'][$key], - ); - - } else { - $data['cc'][] = array( - 'contact_id' => $_POST['contact_id'][$key], - 'contact_type' => $_POST['contact_type'][$key], - 'address' => $_POST['address'][$key], - ); - } + if( isset($_POST['target_type']) ){ + foreach($_POST['target_type'] as $key => $target_type){ + if($target_type == 'To'){ + $data['to'] = array( + 'contact_id' => $_POST['contact_id'][$key], + 'contact_type' => $_POST['contact_type'][$key], + 'address' => $_POST['address'][$key], + ); + + } else { + $data['cc'][] = array( + 'contact_id' => $_POST['contact_id'][$key], + 'contact_type' => $_POST['contact_type'][$key], + 'address' => $_POST['address'][$key], + ); + } + } } echo $this->renderPartial('/docman/document_table', array('data' => $data)); } From 33ca06ab7cfa8d4a2747d11f6b8948f71b273161 Mon Sep 17 00:00:00 2001 From: Tamas Vedelek Date: Fri, 9 Dec 2016 12:03:10 +0100 Subject: [PATCH 093/164] - fixed to set values for contact when adding a new user on the admin page - added Admission category and Total theatre time values to the OpBooking view - fixed to keep the confirm patient has no allergies checkbox value if there are any validation errors in Examination --- protected/controllers/AdminController.php | 22 +++++++++++++++++++ .../controllers/DefaultController.php | 4 ++++ ...lement_OphTrOperationbooking_Operation.php | 11 ++++++++++ 3 files changed, 37 insertions(+) diff --git a/protected/controllers/AdminController.php b/protected/controllers/AdminController.php index d5d155d7f5..9c17be7035 100644 --- a/protected/controllers/AdminController.php +++ b/protected/controllers/AdminController.php @@ -377,6 +377,28 @@ public function actionAddUser() if (!$user->save()) { throw new Exception('Unable to save user: ' . print_r($user->getErrors(), true)); } + + if (!$contact = $user->contact) { + $contact = new Contact(); + } + + $contact->title = $user->title; + $contact->first_name = $user->first_name; + $contact->last_name = $user->last_name; + $contact->qualifications = $user->qualifications; + + if (!$contact->save()) { + throw new Exception('Unable to save user contact: ' . print_r($contact->getErrors(), true)); + } + + if (!$user->contact) { + $user->contact_id = $contact->id; + + if (!$user->save()) { + throw new Exception('Unable to save user: ' . print_r($user->getErrors(), true)); + } + } + Audit::add('admin-User', 'add', $user->id); if (!isset($userAtt['roles'])) { diff --git a/protected/modules/OphCiExamination/controllers/DefaultController.php b/protected/modules/OphCiExamination/controllers/DefaultController.php index 7af3534592..bc2555c268 100644 --- a/protected/modules/OphCiExamination/controllers/DefaultController.php +++ b/protected/modules/OphCiExamination/controllers/DefaultController.php @@ -690,6 +690,10 @@ protected function setComplexAttributes_Element_OphCiExamination_History($elemen } $this->allergies = $allergies; + + if (isset($data['no_allergies']) && $data['no_allergies']) { + $this->patient->no_allergies_date = date('Y-m-d'); + } } /** diff --git a/protected/modules/OphTrOperationbooking/views/default/view_Element_OphTrOperationbooking_Operation.php b/protected/modules/OphTrOperationbooking/views/default/view_Element_OphTrOperationbooking_Operation.php index 9cf254dbe8..b00ea77447 100644 --- a/protected/modules/OphTrOperationbooking/views/default/view_Element_OphTrOperationbooking_Operation.php +++ b/protected/modules/OphTrOperationbooking/views/default/view_Element_OphTrOperationbooking_Operation.php @@ -131,6 +131,17 @@ +
+
+

Admission category:

+
overnight_stay) ? 'An overnight stay' : 'Day case'?> +
+
+
+

Total theatre time (mins):

+
total_duration)?>
+
+
special_equipment)): ?> From 452110faa24965e9106dff14b8697b0832d48e59 Mon Sep 17 00:00:00 2001 From: Tamas Vedelek Date: Wed, 14 Dec 2016 11:18:54 +0100 Subject: [PATCH 094/164] check for patient no allergies date --- .../modules/OphCiExamination/controllers/DefaultController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphCiExamination/controllers/DefaultController.php b/protected/modules/OphCiExamination/controllers/DefaultController.php index bc2555c268..a3a6d26bb1 100644 --- a/protected/modules/OphCiExamination/controllers/DefaultController.php +++ b/protected/modules/OphCiExamination/controllers/DefaultController.php @@ -691,7 +691,7 @@ protected function setComplexAttributes_Element_OphCiExamination_History($elemen $this->allergies = $allergies; - if (isset($data['no_allergies']) && $data['no_allergies']) { + if (isset($data['no_allergies']) && $data['no_allergies'] && !$this->patient->no_allergies_date) { $this->patient->no_allergies_date = date('Y-m-d'); } } From 893bebc7778a0851abee60b701aa1eb6da83cd0e Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 14 Dec 2016 16:21:07 +0000 Subject: [PATCH 095/164] OE-6199 Addition of VA and Refraction to Biometry editing page. Addition of functions to ophciexamination_api to get relevant element data to biometry. --- .../components/OphCiExamination_API.php | 73 +++--- ...form_Element_OphInBiometry_Measurement.php | 209 ++++++++++++------ 2 files changed, 192 insertions(+), 90 deletions(-) diff --git a/protected/modules/OphCiExamination/components/OphCiExamination_API.php b/protected/modules/OphCiExamination/components/OphCiExamination_API.php index c1bdab289c..36bfd8caab 100644 --- a/protected/modules/OphCiExamination/components/OphCiExamination_API.php +++ b/protected/modules/OphCiExamination/components/OphCiExamination_API.php @@ -303,9 +303,45 @@ public function getRefractionValues($eventid) if ($unit = models\Element_OphCiExamination_Refraction::model()->find('event_id = ' . $eventid)) { return $unit; } - return; + } + + public function getMostRecentVA($eventid) + { + if($vaevents = models\Element_OphCiExamination_VisualAcuity::model()->findAll('event_id = ' . $eventid)) { + for ($i = 0; $i < count($vaevents); ++$i) { + if($vaevents){ + return $vaevents[$i]; + } + } + } + } + + public function getMostRecentVAData($id) + { + if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $id)) { + return $unit; + } + } + + + public function getMostRecentNearVA($eventid) + { + if($vaevents = models\Element_OphCiExamination_NearVisualAcuity::model()->findAll('event_id = ' . $eventid)) { + for ($i = 0; $i < count($vaevents); ++$i) { + return $vaevents[$i]; + } + } + } + + + public function getMostRecentNearVAData($id) + { + // Then findAll data from va_reading for that element_id. Most recent. + if ($unit = models\OphCiExamination_NearVisualAcuity_Reading::model()->findAll('element_id = ' . $id)) { + return $unit; + } } @@ -353,7 +389,7 @@ public function getVAId($patient, $episode) public function getNearVAId($patient, $episode) { if ($va = $this->getElementForLatestEventInEpisode($episode, 'models\Element_OphCiExamination_NearVisualAcuity')) { - return $va->id; + return $va; } } public function getVAvalue($vareading, $unitId) @@ -361,9 +397,7 @@ public function getVAvalue($vareading, $unitId) if ($unit = models\OphCiExamination_VisualAcuityUnitValue::model()->find('base_value = ' . $vareading . ' AND unit_id = ' . $unitId)) { return $unit->value; } - return; - } public function getVARight($vaid) @@ -372,9 +406,7 @@ public function getVARight($vaid) . $vaid . ' AND side = ' . self::RIGHT)) { return $unit; } - return; - } public function getVALeft($vaid) @@ -383,9 +415,7 @@ public function getVALeft($vaid) . $vaid . ' AND side = ' . self::LEFT)) { return $unit; } - return; - } @@ -395,9 +425,7 @@ public function getNearVARight($vaid) . $vaid . ' AND side = ' . self::RIGHT)) { return $unit; } - return; - } public function getNearVALeft($vaid) @@ -406,9 +434,7 @@ public function getNearVALeft($vaid) . $vaid . ' AND side = ' . self::LEFT)) { return $unit; } - return; - } @@ -418,7 +444,6 @@ public function getMethodIdRight($vaid, $episode) . $vaid . ' AND side = ' . self::RIGHT)) { return $unit; } - return; } @@ -428,18 +453,15 @@ public function getMethodIdNearRight($vaid) . ' AND side = ' . self::RIGHT)) { return $unit; } - return; } - public function getMethodIdLeft($vaid, $episode) { if ($unit = models\OphCiExamination_VisualAcuity_Reading::model()->findAll('element_id = ' . $vaid . ' AND side = ' . self::LEFT)) { return $unit; } - return; } @@ -449,7 +471,6 @@ public function getMethodIdNearLeft($vaid) . ' AND side = ' . self::LEFT)) { return $unit; } - return; } @@ -459,7 +480,6 @@ public function getUnitId($vaid, $episode) if ($unit = models\Element_OphCiExamination_VisualAcuity::model()->find('id = ?', array($vaid))) { return $unit->unit_id; } - return; } @@ -468,9 +488,9 @@ public function getNearUnitId($vaid, $episode) if ($unit = models\Element_OphCiExamination_NearVisualAcuity::model()->find('id = ?', array($vaid))) { return $unit->unit_id; } - return; } + /** * gets the id for the Snellen Metre unit type for VA. * @@ -507,7 +527,6 @@ public function getUnitName($unitId) if ($unit = models\OphCiExamination_VisualAcuityUnit::model()->find('id = ?', array($unitId))) { return $unit->name; } - return; } @@ -516,7 +535,6 @@ public function getMethodName($methodId) if ($unit = models\OphCiExamination_VisualAcuity_Method::model()->find('id = ?', array($methodId))) { return $unit->name; } - return; } @@ -531,6 +549,7 @@ public function getLetterVisualAcuityLeft($patient) public function getLetterVisualAcuityRight($patient) { if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { +// var_dump($episode); return ($best = $this->getBestVisualAcuity($patient, $episode, 'right')) ? $best->convertTo($best->value, $this->getSnellenUnitId()) : null; } @@ -600,11 +619,11 @@ public function getLetterVisualAcuityFindings($patient) * get the va from the given episode for the left side of the episode patient. * @param Episode $episode * @param bool $include_nr_values -<<<<<<< HEAD + <<<<<<< HEAD * -======= + ======= * @param string $before_date ->>>>>>> develop + >>>>>>> develop * @return OphCiExamination_VisualAcuity_Reading */ public function getLetterVisualAcuityForEpisodeLeft($episode, $include_nr_values = false, $before_date = '') @@ -629,13 +648,13 @@ public function getLetterVisualAcuityForEpisodeLeft($episode, $include_nr_values /** * get the va from the given episode for the right side of the episode patient. * @param Episode $episode -<<<<<<< HEAD + <<<<<<< HEAD * @param bool $include_nr_values * -======= + ======= * @param bool $include_nr_values * @param string $before_date ->>>>>>> develop + >>>>>>> develop * @return OphCiExamination_VisualAcuity_Reading */ public function getLetterVisualAcuityForEpisodeRight($episode, $include_nr_values = false, $before_date = '') diff --git a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php index 8a7c1f9ca6..4542674409 100644 --- a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php +++ b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php @@ -28,43 +28,74 @@ } else { $iolRefValues = array(); } + +if ($eventtype = EventType::model()->find('class_name = "OphCiExamination"')){ + $eventtypeid = $eventtype->id; +} + ?> patient->episodes as $episode) { -// echo $episode->id; -} +$episode = $this->episode; if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) { - if ($api->getLetterVisualAcuityRight($this->patient) || $api->getLetterVisualAcuityLeft($this->patient)) { - $VAid = $api->getVAId($this->patient, $episode); - $unitId = $api->getUnitId($VAid->id, $episode); + $chosenVA[] = array(''); + + //Get All Events for episode. + $criteria = new CDbCriteria(); + $criteria->condition = 'episode_id = :e_id AND event_type_id = :e_typeid'; + $criteria->order = ' event_date DESC'; + $criteria->params = array(':e_id' => $episode->id, ':e_typeid' => $eventtypeid); - $VAright = $api->getVARight($VAid->id); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); + //For each event, check if =event_id in _visualacuity. + + if($events = Event::model()->findAll($criteria)){ + for ($i = 0; $i < count($events); ++$i) { + // Get Most Recent VA + $vaID = $api->getMostRecentVA($events[$i]->id); + if($vaID && !$data){ + $data = $api->getMostRecentVAData($vaID->id); + $chosenVA = $vaID; + $VAdate = "- (exam date " . date("d M Y", strtotime($events[$i]->event_date)) . ")"; + } } + } - $VAleft = $api->getVALeft($VAid->id); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); + for ($i = 0; $i < count($data); ++$i) { + if($data[$i]->side == 0){ + $rightData[] = $data[$i]; + } + if($data[$i]->side == 1){ + $leftData[] = $data[$i]; } - $VAdate = "- (exam date " . date("d M Y h:ia", strtotime($VAid->last_modified_date)) . ")"; + } + + if($data){ + $unitId = $chosenVA->unit_id; + - $methodIdRight = $api->getMethodIdRight($VAid->id, $episode); + for ($i = 0; $i < count($rightData); ++$i) { + $VAfinalright = $api->getVAvalue($rightData[$i]->value, $unitId); + } + + for ($i = 0; $i < count($leftData); ++$i) { + $VAfinalleft = $api->getVAvalue($leftData[$i]->value, $unitId); + } + + $methodIdRight = $api->getMethodIdRight($chosenVA->id, $episode); for ($i = 0; $i < count($methodIdRight); ++$i) { $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); } - $methodIdLeft = $api->getMethodIdLeft($VAid->id, $episode); + $methodIdLeft = $api->getMethodIdLeft($chosenVA->id, $episode); for ($i = 0; $i < count($methodIdLeft); ++$i) { $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); } - $unitnameRight = $api->getUnitName($unitId); - $unitnameLeft = $unitnameRight; + $unitname = $api->getUnitName($unitId); } } + ?>
@@ -78,18 +109,18 @@
hasRight()) { - if ($api->getLetterVisualAcuityRight($this->patient)) { + if($data){ ?>
- +
getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; + echo $api->getVAvalue($rightData[$i]->value, $unitId) . " " . $methodnameRight[$i]; if ($i != (count($methodnameRight) - 1)) { echo ", "; } @@ -111,18 +142,18 @@
getLetterVisualAcuityLeft($this->patient)) { + if($data){ ?>
- +
getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; + echo $api->getVAvalue($leftData[$i]->value, $unitId) . " " . $methodnameLeft[$i]; if ($i != (count($methodnameLeft) - 1)) { echo ", "; } @@ -146,60 +177,80 @@ moduleAPI->get('OphCiExamination')) { - if ($api->getBestNearVisualAcuity($this->patient, $episode, - 'right') || $api->getBestNearVisualAcuity($this->patient, $episode, 'left') - ) { + for ($i = 0; $i < count($events); ++$i) { + // Get Most Recent VA + $vaID = $api->getMostRecentNearVA($events[$i]->id); + // Loop through $data and separate into different eyes + if ($vaID && !$NearVAFound) { + $neardata = $api->getMostRecentNearVAData($vaID->id); + $chosenNearVA = $vaID; + $NearVAFound = true; + $NearVAdate = "- (exam date " . date("d M Y", strtotime($events[$i]->event_date)) . ")"; + } + } + + if($NearVAFound){ + for ($i = 0; $i < count($neardata); ++$i) { + if($neardata[$i]->side == 0){ + $rightNearData[] = $neardata[$i]; + } + if($neardata[$i]->side == 1){ + $leftNearData[] = $neardata[$i]; + } + } + + $unitId = $chosenNearVA->unit_id; + - $VAid = $api->getNearVAId($this->patient, $episode); - $unitId = $api->getNearUnitId($VAid, $episode); - $VAright = $api->getNearVARight($VAid); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalright = $api->getVAvalue($VAright[$i]->value, $unitId); + + for ($i = 0; $i < count($rightNearData); ++$i) { + $VAfinalright = $api->getVAvalue($rightNearData[$i]->value, $unitId); } - $VAleft = $api->getNearVALeft($VAid); - for ($i = 0; $i < count($VAright); ++$i) { - $VAfinalleft = $api->getVAvalue($VAleft[$i]->value, $unitId); + for ($i = 0; $i < count($leftNearData); ++$i) { + $VAfinalleft = $api->getVAvalue($leftNearData[$i]->value, $unitId); } - $methodIdRight = $api->getMethodIdNearRight($VAid); - for ($i = 0; $i < count($methodIdRight); ++$i) { - $methodnameRight[$i] = $api->getMethodName($methodIdRight[$i]->method_id); + $methodIdRight = $api->getMethodIdNearRight($chosenNearVA->id); + for ($i = 0; $i < count($rightNearData); ++$i) { + $methodnameRight[$i] = $api->getMethodName($rightNearData[$i]->method_id); } - $methodIdLeft = $api->getMethodIdNearLeft($VAid); - for ($i = 0; $i < count($methodIdLeft); ++$i) { - $methodnameLeft[$i] = $api->getMethodName($methodIdLeft[$i]->method_id); + $methodIdLeft = $api->getMethodIdNearLeft($chosenNearVA->id); + for ($i = 0; $i < count($leftNearData); ++$i) { + $methodnameLeft[$i] = $api->getMethodName($leftNearData[$i]->method_id); } - $unitnameRight = $api->getUnitName($unitId); - $unitnameLeft = $unitnameRight; + $unitname = $api->getUnitName($unitId); } } ?>
-

Near Visual Acuity

+

Near Visual Acuity

hasRight()) { - if ($api->getBestNearVisualAcuity($this->patient, $episode, 'left')) { + if ($NearVAFound) { ?>
- +
+ getVAvalue($VAright[$i]->value, $unitId) . " " . $methodnameRight[$i]; - if ($i != (count($methodnameRight) - 1)) { + for ($i = 0; $i < count($rightNearData); ++$i) { + echo $api->getVAvalue($rightNearData[$i]->value, $unitId). " " . $methodnameRight[$i]; + if ($i != (count($rightNearData) - 1)) { echo ", "; } } @@ -220,19 +271,19 @@
getBestNearVisualAcuity($this->patient, $episode, 'right')) { + if ($NearVAFound) { ?>
- +
getVAvalue($VAleft[$i]->value, $unitId) . " " . $methodnameLeft[$i]; - if ($i != (count($methodnameLeft) - 1)) { + for ($i = 0; $i < count($leftNearData); ++$i) { + echo $api->getVAvalue($leftNearData[$i]->value, $unitId) . " " . $methodnameLeft[$i]; + if ($i != (count($leftNearData) - 1)) { echo ", "; } } @@ -255,25 +306,39 @@
find('class_name = "OphCiExamination"')){ - $eventtypeid = $eventtype->id; +$refractfound = false; + +if ($eventid = Event::model()->findAll(array( + 'condition' => 'event_type_id = ' . $eventtypeid . ' AND episode_id = ' . $episode->id, + 'order' => 'event_date DESC', +))){ +// Loop through responses, for ones that have RefractionValues +for ($i = 0; $i < count($eventid); ++$i) { + if ($api->getRefractionValues($eventid[$i]->id)) { + if (!$refractfound){ + $refractelement = $api->getRefractionValues($eventid[$i]->id); + $refract_event_date = $eventid[$i]->event_date; + $refractfound = true; + } + } } -if ($eventid = Event::model()->find('event_type_id = ' . $eventtypeid . ' AND episode_id = ' . $episode->id)){ -if ($refractelement = $api->getRefractionValues($eventid->id)) { +if ($refractfound) { ?>
-

Refraction - (exam date last_modified_date)); ?>)

+

Refraction - (exam date )

hasRight()) { ?> - renderPartial($element->view_view . '_OEEyeDraw', - array('side' => 'right', 'element' => $refractelement)); - ?> +
+ renderPartial($element->view_view . '_OEEyeDraw', + array('side' => 'right', 'element' => $refractelement)); + ?> +
@@ -296,6 +361,20 @@
+
+
+

Refraction - (Not Recorded)

+
+
+
+
Not recorded
+
+
+
Not recorded
+
+
+ @@ -368,24 +447,28 @@ class="element-eye left-eye top-pad right side column hasLe
\ No newline at end of file From 597921bc29aefbb1a849a2b672aafb0549cd54ac Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 15 Dec 2016 11:33:15 +0000 Subject: [PATCH 096/164] OE-6239 Addition of Yellow highlighting of Comments, unless empty. --- .../view_Element_OphInBiometry_Calculation_fields.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation_fields.php b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation_fields.php index 461528e029..d4f64f122d 100644 --- a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation_fields.php +++ b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Calculation_fields.php @@ -5,7 +5,11 @@ class="field-info">getAttributeLabel('comments_'.$side)) ?>:
-
{'comments_'.$side}) ?>
+
{'comments_'.$side}) ?>
From dfe3b1da88ec7c2b40f0b387b4571169a1bb335f Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Fri, 16 Dec 2016 14:32:46 +0000 Subject: [PATCH 097/164] OE-6330 Changes to Macro dropdown to resize according to choice made. --- .../views/default/create_ElementLetter.php | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php index 72ea903c7d..0380495f59 100644 --- a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php @@ -59,8 +59,8 @@
-
- letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width')); ?> +
+ letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width resizeselect')); ?>
@@ -366,4 +366,37 @@
-
\ No newline at end of file +
+ \ No newline at end of file From b39e7c647fafd9b12583af89fbd1304818f5b9c3 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 1 Dec 2016 15:44:05 +0000 Subject: [PATCH 098/164] Fixes inefficient counting of relations Replaces inefficient counting of related rows in PHP with an SQL count. Also @$error from controller as it's not needed and ugly. --- .../controllers/WorklistAdminController.php | 1 - protected/models/WorklistDefinition.php | 75 +++++++++++++------ .../views/admin/worklists/definitions.php | 6 +- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/protected/controllers/WorklistAdminController.php b/protected/controllers/WorklistAdminController.php index 3b04013302..d2fbe470ea 100644 --- a/protected/controllers/WorklistAdminController.php +++ b/protected/controllers/WorklistAdminController.php @@ -56,7 +56,6 @@ public function actionDefinitions() $this->render('//admin/worklists/definitions', array( 'definitions' => $definitions, - 'errors' => @$errors, )); } diff --git a/protected/models/WorklistDefinition.php b/protected/models/WorklistDefinition.php index 8d4b02a8e2..bd0718aa9c 100644 --- a/protected/models/WorklistDefinition.php +++ b/protected/models/WorklistDefinition.php @@ -22,19 +22,19 @@ * * The followings are the available columns in table: * - * @property int $id - * @property string $name - * @property string $rrule - * @property string $description - * @property string $worklist_name - * @property string $start_time - * @property string $end_time - * @property DateTime $active_from - * @property DateTime $active_until - * @property Worklist[] $worklists - * @property WorklistDefinitionMapping[] $mappings - * @property WorklistDefinitionMappingp[] $displayed_mappings - * @property WorklistDefinitionMappingp[] $hidden_mappings + * @property int $id + * @property string $name + * @property string $rrule + * @property string $description + * @property string $worklist_name + * @property string $start_time + * @property string $end_time + * @property DateTime $active_from + * @property DateTime $active_until + * @property Worklist[] $worklists + * @property WorklistDefinitionMapping[] $mappings + * @property WorklistDefinitionMappingp[] $displayed_mappings + * @property WorklistDefinitionMappingp[] $hidden_mappings * @property WorklistDefinitionDisplayContext[] $display_contexts */ class WorklistDefinition extends BaseActiveRecordVersioned @@ -54,7 +54,7 @@ public function tableName() */ public function defaultScope() { - return array('order' => $this->getTableAlias(true, false).'.display_order'); + return array('order' => $this->getTableAlias(true, false) . '.display_order'); } /** @@ -79,7 +79,7 @@ public function rules() 'allowEmpty' => true, 'allowCompareEmpty' => true, 'operator' => '<=', - 'message' => '{attribute} must be on or before {compareAttribute}' + 'message' => '{attribute} must be on or before {compareAttribute}', ), array('active_from', 'default', 'setOnEmpty' => true, 'value' => date("Y-m-d H:i:s", time())), array('active_until', 'default', 'setOnEmpty' => true, 'value' => null), @@ -90,7 +90,7 @@ public function rules() array( 'id, name, rrule, worklist_name, start_time, end_time, description, scheduled', 'safe', - 'on' => 'search' + 'on' => 'search', ), ); } @@ -110,15 +110,15 @@ public function relations() 'WorklistDefinitionMapping', 'worklist_definition_id', 'on' => 'display_order is NOT NULL', - 'order' => 'display_order ASC' + 'order' => 'display_order ASC', ), 'hidden_mappings' => array( self::HAS_MANY, 'WorklistDefinitionMapping', 'worklist_definition_id', - 'on' => 'display_order is NULL' + 'on' => 'display_order is NULL', ), - 'display_contexts' => array(self::HAS_MANY, 'WorklistDefinitionDisplayContext', 'worklist_definition_id') + 'display_contexts' => array(self::HAS_MANY, 'WorklistDefinitionDisplayContext', 'worklist_definition_id'), ); } @@ -190,7 +190,7 @@ public function validateRrule($attribute) $valid = false; } if (!$valid) { - $this->addError($attribute, $this->getAttributeLabel($attribute).' is not valid'); + $this->addError($attribute, $this->getAttributeLabel($attribute) . ' is not valid'); } } @@ -198,7 +198,7 @@ public function validateRrule($attribute) * Check whether the given key would be unique on the Definition * (optional id indicates the current mapping the key is from so it is not checked against itself). * - * @param $key + * @param $key * @param int $id * * @return bool @@ -251,11 +251,42 @@ public function getRruleHumanReadable() } $final_rrule = new RRule($rrule_str); + return $final_rrule->humanReadable(array( 'date_formatter' => function ($d) { return $d->format(Helper::NHS_DATE_FORMAT); - } + }, )); } } + + /** + * @return CDbDataReader|mixed|string + */ + public function getWorklistCount() + { + $sql = 'SELECT COUNT(id) FROM worklist where worklist_definition_id = ' . $this->id; + + return $this->getDbConnection()->createCommand($sql)->queryScalar(); + } + + /** + * @return CDbDataReader|mixed|string + */ + public function getMappingCount() + { + $sql = 'SELECT COUNT(id) FROM worklist_definition_mapping where worklist_definition_id = ' . $this->id; + + return $this->getDbConnection()->createCommand($sql)->queryScalar(); + } + + /** + * @return CDbDataReader|mixed|string + */ + public function getdisplayContextCount() + { + $sql = 'SELECT COUNT(id) FROM worklist_definition_display_context where worklist_definition_id = ' . $this->id; + + return $this->getDbConnection()->createCommand($sql)->queryScalar(); + } } diff --git a/protected/views/admin/worklists/definitions.php b/protected/views/admin/worklists/definitions.php index 1b7ce6d6d3..2d4643a4fc 100644 --- a/protected/views/admin/worklists/definitions.php +++ b/protected/views/admin/worklists/definitions.php @@ -37,9 +37,9 @@ name?> manager->canUpdateWorklistDefinition($definition)) {?>Edit | View | - Instances (worklists)?>) | - Mapping Items(mappings)?>) | - Display Context (display_contexts) > 0 ? 'limited' : 'any';?>) | + Instances (worklistCount?>) | + Mapping Items(mappingCount?>) | + Display Context (displayContextCount > 0 ? 'limited' : 'any';?>) | worklists)) {?> Delete Instances From 9988ea2943dabcdfc8a56565d4da05b8e29cc445 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 1 Dec 2016 15:47:54 +0000 Subject: [PATCH 099/164] Removes missed lazy count. --- protected/views/admin/worklists/definitions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/views/admin/worklists/definitions.php b/protected/views/admin/worklists/definitions.php index 2d4643a4fc..c3212f7f42 100644 --- a/protected/views/admin/worklists/definitions.php +++ b/protected/views/admin/worklists/definitions.php @@ -40,7 +40,7 @@ Instances (worklistCount?>) | Mapping Items(mappingCount?>) | Display Context (displayContextCount > 0 ? 'limited' : 'any';?>) | - worklists)) {?> + worklistCount) {?> Delete Instances Generate | From dd3760e1a0a5a8be12c0b2ff27a8b51fcb1c8c6c Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 1 Dec 2016 15:53:23 +0000 Subject: [PATCH 100/164] Removes more missed lazy count. --- protected/components/WorklistManager.php | 2 +- protected/views/admin/worklists/definition_worklists_delete.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protected/components/WorklistManager.php b/protected/components/WorklistManager.php index 840bfedaa7..aa241fa876 100644 --- a/protected/components/WorklistManager.php +++ b/protected/components/WorklistManager.php @@ -1411,7 +1411,7 @@ public function canUpdateWorklistDefinition(WorklistDefinition $definition) return true; } - return $definition->isNewRecord || count($definition->worklists) == 0; + return $definition->isNewRecord || $definition->getWorklistCount() == 0; } /** diff --git a/protected/views/admin/worklists/definition_worklists_delete.php b/protected/views/admin/worklists/definition_worklists_delete.php index 41df83c1d3..fa27cffbc2 100644 --- a/protected/views/admin/worklists/definition_worklists_delete.php +++ b/protected/views/admin/worklists/definition_worklists_delete.php @@ -19,7 +19,7 @@

Confirm Delete

Are you sure you want to delete all the instances for the worklist definition name ?>? - There are currently worklists) ?> instances that have been generated.

+ There are currently getWorklistCount() ?> instances that have been generated.

From 1ee46adb04620c2053cb039e498f4f3fec1cc608 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 20 Dec 2016 13:34:40 +0000 Subject: [PATCH 101/164] OE-6101 Change Devices to Agents. --- ...perationnote_Cataract_OEEyeDraw_fields.php | 76 ++++++++++++------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract_OEEyeDraw_fields.php b/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract_OEEyeDraw_fields.php index 05a06d293a..9e0f1c9714 100644 --- a/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract_OEEyeDraw_fields.php +++ b/protected/modules/OphTrOperationnote/views/default/form_Element_OphTrOperationnote_Cataract_OEEyeDraw_fields.php @@ -18,33 +18,53 @@ */ ?> -dropDownList($element, 'incision_site_id', 'OphTrOperationnote_IncisionSite', array('empty' => '- Please select -', 'textAttribute' => 'data-value'), false, array('field' => 4))?> -textField($element, 'length', array(), array(), array_merge($form->layoutColumns, array('field' => 3)))?> -textField($element, 'meridian', array(), array(), array_merge($form->layoutColumns, array('field' => 3)))?> -dropDownList($element, 'incision_type_id', 'OphTrOperationnote_IncisionType', array('empty' => '- Please select -', 'textAttribute' => 'data-value'), false, array('field' => 4))?> -textArea($element, 'report', array(), false, array('rows' => 6))?> +dropDownList($element, 'incision_site_id', 'OphTrOperationnote_IncisionSite', + array('empty' => '- Please select -', 'textAttribute' => 'data-value'), false, array('field' => 4)) ?> +textField($element, 'length', array(), array(), + array_merge($form->layoutColumns, array('field' => 3))) ?> +textField($element, 'meridian', array(), array(), + array_merge($form->layoutColumns, array('field' => 3))) ?> +dropDownList($element, 'incision_type_id', 'OphTrOperationnote_IncisionType', + array('empty' => '- Please select -', 'textAttribute' => 'data-value'), false, array('field' => 4)) ?> +textArea($element, 'report', array(), false, array('rows' => 6)) ?> dropDownList($element, 'iol_type_id', array( - CHtml::listData(OphTrOperationnote_IOLType::model()->activeOrPk($element->iol_type_id)->findAll(array('condition' => 'private=0', 'order' => 'display_order asc')), 'id', 'name'), - CHtml::listData(OphTrOperationnote_IOLType::model()->activeOrPk($element->iol_type_id)->findAll(array('condition' => 'private=1', 'order' => 'display_order')), 'id', 'name'), - ), - array('empty' => '- Please select -', 'divided' => true), $element->iol_hidden, array('field' => 4))?> -
-
- -
-
- -
-
- -
-
- -
-
+ CHtml::listData(OphTrOperationnote_IOLType::model()->activeOrPk($element->iol_type_id)->findAll(array( + 'condition' => 'private=0', + 'order' => 'display_order asc', + )), 'id', 'name'), + CHtml::listData(OphTrOperationnote_IOLType::model()->activeOrPk($element->iol_type_id)->findAll(array( + 'condition' => 'private=1', + 'order' => 'display_order', + )), 'id', 'name'), +), + array('empty' => '- Please select -', 'divided' => true), $element->iol_hidden, array('field' => 4)) ?> +
+
+ +
+
+ +
+
+ +
+
+ +
+
-dropDownList($element, 'iol_position_id', 'OphTrOperationnote_IOLPosition', array('empty' => '- Please select -'), $element->iol_hidden, array('field' => 4))?> -multiSelectList($element, 'OphTrOperationnote_CataractOperativeDevices', 'operative_devices', 'id', $this->getOperativeDeviceList($element), $this->getOperativeDeviceDefaults(), array('empty' => '- Devices -', 'label' => 'Devices'), false, false, null, false, false, array('field' => 4))?> -multiSelectList($element, 'OphTrOperationnote_CataractComplications', 'complications', 'id', CHtml::listData(OphTrOperationnote_CataractComplications::model()->activeOrPk($element->cataractComplicationValues)->findAll(array('order' => 'display_order asc')), 'id', 'name'), null, array('empty' => '- Complications -', 'label' => 'Complications'), false, false, null, false, false, array('field' => 4))?> -textArea($element, 'complication_notes', array(), false, array('rows' => 6))?> -hiddenInput($element, 'pcr_risk')?> \ No newline at end of file +dropDownList($element, 'iol_position_id', 'OphTrOperationnote_IOLPosition', + array('empty' => '- Please select -'), $element->iol_hidden, array('field' => 4)) ?> +multiSelectList($element, 'OphTrOperationnote_CataractOperativeDevices', 'operative_devices', 'id', + $this->getOperativeDeviceList($element), $this->getOperativeDeviceDefaults(), + array('empty' => '- Agents -', 'label' => 'Agents'), false, false, null, false, false, array('field' => 4)) ?> +multiSelectList($element, 'OphTrOperationnote_CataractComplications', 'complications', 'id', + CHtml::listData(OphTrOperationnote_CataractComplications::model()->activeOrPk($element->cataractComplicationValues)->findAll(array('order' => 'display_order asc')), + 'id', 'name'), null, array('empty' => '- Complications -', 'label' => 'Complications'), false, false, null, + false, false, array('field' => 4)) ?> +textArea($element, 'complication_notes', array(), false, array('rows' => 6)) ?> +hiddenInput($element, 'pcr_risk') ?> \ No newline at end of file From 187a65670a99db9a5ea4df08226f7678cc02284e Mon Sep 17 00:00:00 2001 From: petergallagher Date: Thu, 22 Dec 2016 16:33:08 +0000 Subject: [PATCH 102/164] OE-6340: Tidies up code so I can work on it Before being able to work on the docman code it was neccessary to clean it up, formatting the code so it meets style guide and deleting useless crap that is not used. --- protected/commands/DocManDeliveryCommand.php | 118 +++++++++------ protected/models/Document.php | 9 -- protected/models/DocumentDispatchClass.php | 33 ----- protected/models/DocumentDispatchDocMan.php | 29 ---- protected/models/DocumentDispatchFile.php | 28 ---- protected/models/DocumentDispatchPrint.php | 27 ---- protected/models/DocumentInstance.php | 148 ++++++++++--------- protected/models/DocumentInstanceData.php | 103 ++++++------- protected/models/DocumentOutput.php | 107 +++++++------- protected/models/DocumentSet.php | 131 +++++++--------- protected/models/DocumentTarget.php | 101 ++++++------- 11 files changed, 358 insertions(+), 476 deletions(-) delete mode 100644 protected/models/DocumentDispatchClass.php delete mode 100644 protected/models/DocumentDispatchDocMan.php delete mode 100644 protected/models/DocumentDispatchFile.php delete mode 100644 protected/models/DocumentDispatchPrint.php diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index 7c7547c802..16aa2a694a 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -17,47 +17,57 @@ * @copyright Copyright (c) 2011-2012, OpenEyes Foundation * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ - class DocManDeliveryCommand extends CConsoleCommand { private $path; private $event; + /** + * DocManDeliveryCommand constructor. + */ public function __construct() { $this->path = Yii::app()->params['docman_export_dir']; // check if directory is exists - if(!is_dir($this->path)) - { + if (!is_dir($this->path)) { mkdir($this->path); - echo "ALERT! Directory ".$this->path." has been created!"; + echo "ALERT! Directory " . $this->path . " has been created!"; } parent::__construct(null, null); } - public function actionIndex() + + /** + * Run the command. + */ + public function run() { $pending_documents = $this->getPendingDocuments(); - foreach($pending_documents as $document) - { - $event_id = $document->document_target->document_instance->correspondence_event_id; - //var_dump($event_id); - $this->savePDFFile($event_id, $document->id); + + foreach ($pending_documents as $document) { + echo 'Processing event ' . $document->document_target->document_instance->correspondence_event_id . PHP_EOL; + $this->savePDFFile($document->document_target->document_instance->correspondence_event_id, $document->id); } } + /** + * @return CActiveRecord[] + */ private function getPendingDocuments() { - $documents = DocumentOutput::model()->findAllByAttributes(array("output_status"=>"PENDING","output_type"=>"Docman")); - return $documents; + return DocumentOutput::model()->findAllByAttributes(array("output_status" => "PENDING", "output_type" => "Docman")); } + /** + * @param $event_id + * @param $output_id + */ private function savePDFFile($event_id, $output_id) { - if($this->event = Event::model()->findByPk($event_id)) { - + $this->event = Event::model()->findByPk($event_id); + if ($this->event) { $login_page = Yii::app()->params['docman_login_url']; $username = Yii::app()->params['docman_user']; $password = Yii::app()->params['docman_password']; @@ -92,7 +102,7 @@ private function savePDFFile($event_id, $output_id) curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); curl_exec($ch); - + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_URL, $print_url . $this->event->id . '?auto_print=' . (int)$inject_autoprint_js . '&print_only_gp=1'); @@ -100,28 +110,35 @@ private function savePDFFile($event_id, $output_id) curl_close($ch); - if (!isset(Yii::app()->params['docman_filename_format']) || Yii::app()->params['docman_filename_format'] == 'format1') { + if (!isset(Yii::app()->params['docman_filename_format']) || Yii::app()->params['docman_filename_format'] === 'format1') { $filename = "OPENEYES_" . $this->event->episode->patient->hos_num . '_' . $this->event->id . "_" . rand(); - } else if (Yii::app()->params['docman_filename_format'] == 'format2') { - $filename = $this->event->episode->patient->hos_num . '_' . date('YmdHi', - strtotime($this->event->last_modified_date)) . '_' . $this->event->id; - } else if (Yii::app()->params['docman_filename_format'] == 'format3') { - $filename = $this->event->episode->patient->hos_num . '_edtdep-OEY_' . date('Ymd_His', - strtotime($this->event->last_modified_date)) . '_' . $this->event->id; + } else { + if (Yii::app()->params['docman_filename_format'] === 'format2') { + $filename = $this->event->episode->patient->hos_num . '_' . date('YmdHi', + strtotime($this->event->last_modified_date)) . '_' . $this->event->id; + } else { + if (Yii::app()->params['docman_filename_format'] === 'format3') { + $filename = $this->event->episode->patient->hos_num . '_edtdep-OEY_' . + date('Ymd_His', strtotime($this->event->last_modified_date)) . '_' . $this->event->id; + } + } } file_put_contents($this->path . "/" . $filename . ".pdf", $content); - if (!isset(Yii::app()->params['docman_xml_format']) || Yii::app()->params['docman_xml_format'] != 'none') { + if (!isset(Yii::app()->params['docman_xml_format']) || Yii::app()->params['docman_xml_format'] !== 'none') { $this->generateXMLOutput($filename, $output_id); } $this->updateDelivery($output_id); } } + /** + * @param string $filename + */ private function generateXMLOutput($filename) { - $element_letter = ElementLetter::model()->findByAttributes(array("event_id"=>$this->event->id)); - $letter_types = array("0"=>"","1"=>"Clinic discharge letter","2"=>"Post-op letter","3"=>"Clinic letter","4"=>"Other letter"); - + $element_letter = ElementLetter::model()->findByAttributes(array("event_id" => $this->event->id)); + $letter_types = array("0" => "", "1" => "Clinic discharge letter", "2" => "Post-op letter", "3" => "Clinic letter", "4" => "Other letter"); + $subspeciality = isset($this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->ref_spec) ? $this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->ref_spec : 'SS'; $subspeciality_name = isset($this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->name) ? $this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->name : 'Support Services'; $nat_id = isset($this->event->episode->patient->gp->nat_id) ? $this->event->episode->patient->gp->nat_id : null; @@ -136,55 +153,58 @@ private function generateXMLOutput($filename) $xml = " - ".$this->event->episode->patient->hos_num." - ".$this->event->episode->patient->nhs_num." - ".$this->event->episode->patient->contact->getFullName()." - ".$this->event->episode->patient->contact->last_name." - ".$this->event->episode->patient->contact->first_name." + " . $this->event->episode->patient->hos_num . " + " . $this->event->episode->patient->nhs_num . " + " . $this->event->episode->patient->contact->getFullName() . " + " . $this->event->episode->patient->contact->last_name . " + " . $this->event->episode->patient->contact->first_name . " - ".$this->event->episode->patient->contact->title." - ".$this->event->episode->patient->dob." - ".$this->event->episode->patient->gender." -
".implode(", ", $address)."
+ " . $this->event->episode->patient->contact->title . " + " . $this->event->episode->patient->dob . " + " . $this->event->episode->patient->gender . " +
" . implode(", ", $address) . "
" . $address1 . " - ".$city." - ".$county." - ".$post_code." + " . $city . " + " . $county . " + " . $post_code . " " . $nat_id . " " . $gp_name . " " . $practice_code . " - ".$letter_types[$element_letter->letter_type]." - ".$this->event->id." - ".$this->event->event_date." + " . $letter_types[$element_letter->letter_type] . " + " . $this->event->id . " + " . $this->event->event_date . " - ".$subspeciality." - ".$subspeciality_name." + " . $subspeciality . " + " . $subspeciality_name . " " . $element_letter->site->short_name . " " . $element_letter->site->name . "
"; - file_put_contents($this->path."/".$filename.".XML", $this->cleanXML($xml) ); + file_put_contents($this->path . "/" . $filename . ".XML", $this->cleanXML($xml)); } - + /** * Special function to sanitize XML - * - * @param type $xml - * @return type + * + * @param string $xml + * @return string */ private function cleanXML($xml) { - return str_replace ("&", "and", $xml); + return str_replace("&", "and", $xml); } + /** + * @param int $output_id + */ private function updateDelivery($output_id) { $output = DocumentOutput::model()->findByPk($output_id); diff --git a/protected/models/Document.php b/protected/models/Document.php index 1f34f6f3a0..40afa97113 100644 --- a/protected/models/Document.php +++ b/protected/models/Document.php @@ -178,15 +178,6 @@ public function getMacros() } - - // Need new document version. - // This will: - // Copy the current _version record to a new version number - - public function updateDocument($macroId, $eventId, $target, $outputs, $data = null) - { - } - /** * Dispatches all the documents associated with this DocSet, that have not already been sent. */ diff --git a/protected/models/DocumentDispatchClass.php b/protected/models/DocumentDispatchClass.php deleted file mode 100644 index d823abc1c3..0000000000 --- a/protected/models/DocumentDispatchClass.php +++ /dev/null @@ -1,33 +0,0 @@ -. - * - * @package OpenEyes - * @link http://www.openeyes.org.uk - * Written by Antony Penn - * - * This is the main API end point for the document management functions. - */ - -class DocumentDispatchClass -{ - public $obj; - - public function __construct($obj) - { - $this->obj = $obj; - } - - - public function send() - { - // TODO - } -} diff --git a/protected/models/DocumentDispatchDocMan.php b/protected/models/DocumentDispatchDocMan.php deleted file mode 100644 index 38d59cf1b6..0000000000 --- a/protected/models/DocumentDispatchDocMan.php +++ /dev/null @@ -1,29 +0,0 @@ -. - * - * @package OpenEyes - * @link http://www.openeyes.org.uk - * Written by Antony Penn - * - * This is the main API end point for the document management functions. - */ - -class DocumentDispatchDocMan extends DocumentDispatchClass -{ - public function send() - { - // TODO: Copy guts from previous docman code - // Pull the directory info from the system config documentInstance->docman - // Copy this object's binary to the right location - // Create META file and copy that to correct location - // DocumentInstance::updateStatus to write status (success/fail) of output - } -} diff --git a/protected/models/DocumentDispatchFile.php b/protected/models/DocumentDispatchFile.php deleted file mode 100644 index 43aa25f728..0000000000 --- a/protected/models/DocumentDispatchFile.php +++ /dev/null @@ -1,28 +0,0 @@ -. - * - * @package OpenEyes - * @link http://www.openeyes.org.uk - * Written by Antony Penn - * - * This is the main API end point for the document management functions. - */ - -class DocumentDispatchFile extends DocumentDispatchClass -{ - public function send() - { - // TODO: - // Pull the directory info from the system config documentInstance->file - // Copy this object's binary to the right location - // DocumentInstance::updateStatus to write status (success/fail) of output - } -} diff --git a/protected/models/DocumentDispatchPrint.php b/protected/models/DocumentDispatchPrint.php deleted file mode 100644 index 61ba067c49..0000000000 --- a/protected/models/DocumentDispatchPrint.php +++ /dev/null @@ -1,27 +0,0 @@ -. - * - * @package OpenEyes - * @link http://www.openeyes.org.uk - * Written by Antony Penn - * - * This is the main API end point for the document management functions. - */ - -class DocumentDispatchPrint extends DocumentDispatchClass -{ - public function send() - { - // TODO: - // Copy the PDF data to a temp file - // Return the temp filename - } -} diff --git a/protected/models/DocumentInstance.php b/protected/models/DocumentInstance.php index b6a3aaf9b5..93162cf313 100644 --- a/protected/models/DocumentInstance.php +++ b/protected/models/DocumentInstance.php @@ -19,85 +19,87 @@ class DocumentInstance extends BaseActiveRecord { - /** - * Returns the static model of the specified AR class. - * @return Site the static model class - */ - public static function model($className=__CLASS__) - { - return parent::model($className); - } + /** + * Returns the static model of the specified AR class. + * + * @return Site the static model class + */ + public static function model($className = __CLASS__) + { + return parent::model($className); + } - /** - * @return string the associated database table name - */ - public function tableName() - { - return 'document_instance'; - } + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'document_instance'; + } - public function behaviors() - { - return array( - 'LookupTable' => 'LookupTable', - ); - } + public function behaviors() + { + return array( + 'LookupTable' => 'LookupTable', + ); + } - /** - * @return array validation rules for model attributes. - */ - public function rules() - { - // NOTE: you should only define rules for those attributes that - // will receive user inputs. - return array( - array('document_set_id, correspondence_event_id', 'safe'), - // The following rule is used by search(). - // Please remove those attributes that should not be searched. - array('document_set_id, correspondence_event_id', 'safe', 'on' => 'search'), - ); - } + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('document_set_id, correspondence_event_id', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('document_set_id, correspondence_event_id', 'safe', 'on' => 'search'), + ); + } - /** - * @return array relational rules. - */ - public function relations() - { - return array( - 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), - 'document_set' => array(self::BELONGS_TO, 'DocumentSet', 'document_set_id'), - 'correspondence_event' => array(self::BELONGS_TO, 'Event', 'correspondence_event_id'), - 'document_instance_data' => array(self::HAS_MANY, 'DocumentInstanceData', 'document_instance_id'), - 'document_target' => array(self::HAS_MANY, 'DocumentTarget', 'document_instance_id'), - 'event' => array(self::BELONGS_TO, 'Event', 'event_id'), - ); - } + /** + * @return array relational rules. + */ + public function relations() + { + return array( + 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), + 'document_set' => array(self::BELONGS_TO, 'DocumentSet', 'document_set_id'), + 'correspondence_event' => array(self::BELONGS_TO, 'Event', 'correspondence_event_id'), + 'document_instance_data' => array(self::HAS_MANY, 'DocumentInstanceData', 'document_instance_id'), + 'document_target' => array(self::HAS_MANY, 'DocumentTarget', 'document_instance_id'), + 'event' => array(self::BELONGS_TO, 'Event', 'event_id'), + ); + } - /** - * @return array customized attribute labels (name=>label) - */ - public function attributeLabels() - { - } + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + } - public function dispatch() - { - switch ($this->dispatchType) { - case 'PRINT': - $dispatchObj = new DocumentDispatchPrint($this); - break; - case 'DOCMAN': - $dispatchObj = new DocumentDispatchDocMan($this); - break; - case 'FILE': - $dispatchObj = new DocumentDispatchFile($this); - break; - } + public function dispatch() + { + switch ($this->dispatchType) { + case 'PRINT': + $dispatchObj = new DocumentDispatchPrint($this); + break; + case 'DOCMAN': + $dispatchObj = new DocumentDispatchDocMan($this); + break; + case 'FILE': + $dispatchObj = new DocumentDispatchFile($this); + break; + } - if ($dispatchObj) { - $tempname = $dispatchObj->send(); - return $tempname; // PRINT dispatch types return the temp filename that was created - } - } + if ($dispatchObj) { + $tempname = $dispatchObj->send(); + + return $tempname; // PRINT dispatch types return the temp filename that was created + } + } } diff --git a/protected/models/DocumentInstanceData.php b/protected/models/DocumentInstanceData.php index ef72e000ae..b76b7da0a5 100644 --- a/protected/models/DocumentInstanceData.php +++ b/protected/models/DocumentInstanceData.php @@ -1,4 +1,5 @@ 'LookupTable', - ); - } + public function behaviors() + { + return array( + 'LookupTable' => 'LookupTable', + ); + } - /** - * @return array validation rules for model attributes. - */ - public function rules() - { - return array( - array('document_instance_id, macro_id', 'safe'), - // The following rule is used by search(). - // Please remove those attributes that should not be searched. - array('document_instance_id, macro_id', 'safe', 'on' => 'search'), - ); - } + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + return array( + array('document_instance_id, macro_id', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('document_instance_id, macro_id', 'safe', 'on' => 'search'), + ); + } - /** - * @return array relational rules. - */ - public function relations() - { - return array( - 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), - 'document_instance' => array(self::BELONGS_TO, 'DocumentInstance', 'document_instance_id'), - 'macro' => array(self::BELONGS_TO, 'LetterMacro', 'macro_id'), + /** + * @return array relational rules. + */ + public function relations() + { + return array( + 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), + 'document_instance' => array(self::BELONGS_TO, 'DocumentInstance', 'document_instance_id'), + 'macro' => array(self::BELONGS_TO, 'LetterMacro', 'macro_id'), - ); - } + ); + } - /** - * @return array customized attribute labels (name=>label) - */ - public function attributeLabels() - { - } + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + } } diff --git a/protected/models/DocumentOutput.php b/protected/models/DocumentOutput.php index 5fb6cb14de..9a5448d1d4 100644 --- a/protected/models/DocumentOutput.php +++ b/protected/models/DocumentOutput.php @@ -1,4 +1,5 @@ array(self::BELONGS_TO, 'User', 'created_user_id'), + 'document_target' => array(self::BELONGS_TO, 'DocumentTarget', 'document_target_id'), + 'document_instance_data' => array(self::BELONGS_TO, 'DocumentInstanceData', 'document_instance_data_id'), - /** - * @return string the associated database table name - */ - public function tableName() - { - return 'document_output'; - } + ); + } - /** - * @return array relational rules. - */ - public function relations() - { - return array( - 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), - 'document_target' => array(self::BELONGS_TO, 'DocumentTarget', 'document_target_id'), - 'document_instance_data' => array(self::BELONGS_TO, 'DocumentInstanceData', 'document_instance_data_id'), + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + return array( + array('document_target_id, ToCc, output_type, output_status, document_instance_version_id, requestor_id, request_datetime, success_datetime', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('document_target_id, ToCc, output_type, output_status, document_instance_version_id, requestor_id, request_datetime, success_datetime', 'safe', 'on' => 'search'), + ); + } - ); - } - /** - * @return array validation rules for model attributes. - */ - public function rules() - { - return array( - array('document_target_id, ToCc, output_type, output_status, document_instance_version_id, requestor_id, request_datetime, success_datetime', 'safe'), - // The following rule is used by search(). - // Please remove those attributes that should not be searched. - array('document_target_id, ToCc, output_type, output_status, document_instance_version_id, requestor_id, request_datetime, success_datetime', 'safe', 'on' => 'search'), - ); - } + public function getLongListForCurrentInstitution() + { + $institution = Institution::model()->getCurrent(); + $site = $this->findByAttributes(array('code' => Yii::app()->params['default_site_code'])); + $site = Site::model()->findByPk(Yii::app()->session['selected_site_id']); + } - public function getLongListForCurrentInstitution() - { - $institution = Institution::model()->getCurrent(); - $site = $this->findByAttributes(array('code' => Yii::app()->params['default_site_code'])); - $site = Site::model()->findByPk(Yii::app()->session['selected_site_id']); - } + public function createSet($eventId) + { + $ds = new DocumentSet; + $ds->event_id = $eventId; + $ds->save(); - public function createSet($eventId) - { - $ds = new DocumentSet; - $ds->event_id = $eventId; - $ds->save(); - return ($ds->id); - } + return ($ds->id); + } } diff --git a/protected/models/DocumentSet.php b/protected/models/DocumentSet.php index c79c9fa615..6c25f50a1a 100644 --- a/protected/models/DocumentSet.php +++ b/protected/models/DocumentSet.php @@ -19,85 +19,66 @@ class DocumentSet extends BaseActiveRecord { - /** - * Returns the static model of the specified AR class. - * @return Site the static model class - */ - public static function model($className=__CLASS__) - { - return parent::model($className); - } + /** + * Returns the static model of the specified AR class. + * + * @return Site the static model class + */ + public static function model($className = __CLASS__) + { + return parent::model($className); + } - /** - * @return string the associated database table name - */ - public function tableName() - { - return 'document_set'; - } + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'document_set'; + } - public function behaviors() - { - return array(); - } + public function behaviors() + { + return array(); + } - /** - * @return array validation rules for model attributes. - */ - public function rules() - { - // NOTE: you should only define rules for those attributes that - // will receive user inputs. - return array( - array('event_id', 'safe'), - // The following rule is used by search(). - // Please remove those attributes that should not be searched. - array('id, event_id', 'safe', 'on' => 'search'), - ); - } + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('event_id', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, event_id', 'safe', 'on' => 'search'), + ); + } - /** - * @return array relational rules. - */ - public function relations() - { - return array( - 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), - 'event' => array(self::BELONGS_TO, 'Event', 'event_id'), - 'document_instance' => array(self::HAS_MANY, 'DocumentInstance', 'document_set_id'), - ); - } + /** + * @return array relational rules. + */ + public function relations() + { + return array( + 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), + 'event' => array(self::BELONGS_TO, 'Event', 'event_id'), + 'document_instance' => array(self::HAS_MANY, 'DocumentInstance', 'document_set_id'), + ); + } - /** - * @return array customized attribute labels (name=>label) - */ - public function attributeLabels() - { - } - - - public function createNew($eventId) - { - $ds = new DocumentSet; - $ds->event_id = $eventId; - $ds->save(); - return ($ds->id); - } - - // If AUTO, pre-calculates template - // If MANUAL, takes body text from data[] arrary - public function addDocument($autoManual, $macroId, $eventId, $target, $outputs, $data=null) - { - } - - - // Need new document version. - // This will: - // Copy the current _version record to a new version number - -// It will also incement - public function updateDocument($macroId, $eventId, $target, $outputs, $data=null) - { - } + /** + * @param $eventId + * @return mixed + */ + public function createNew($eventId) + { + $documentSet = new DocumentSet(); + $documentSet->event_id = $eventId; + $documentSet->save(); + return ($documentSet->id); + } } diff --git a/protected/models/DocumentTarget.php b/protected/models/DocumentTarget.php index 1626987f9d..bcd5bcbd1d 100644 --- a/protected/models/DocumentTarget.php +++ b/protected/models/DocumentTarget.php @@ -19,59 +19,60 @@ class DocumentTarget extends BaseActiveRecord { - /** - * Returns the static model of the specified AR class. - * @return Site the static model class - */ - public static function model($className=__CLASS__) - { - return parent::model($className); - } + /** + * Returns the static model of the specified AR class. + * + * @return Site the static model class + */ + public static function model($className = __CLASS__) + { + return parent::model($className); + } - /** - * @return string the associated database table name - */ - public function tableName() - { - return 'document_target'; - } + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'document_target'; + } - public function behaviors() - { - return array(); - } + public function behaviors() + { + return array(); + } - /** - * @return array validation rules for model attributes. - */ - public function rules() - { - return array( - array('document_instance_id, contact_type, contact_id, contact_name, contact_modified, address, emailemail, ToCc', 'safe'), - // The following rule is used by search(). - // Please remove those attributes that should not be searched. - array('document_instance_id, contact_type, contact_id, contact_name, contact_modified, address, emailemail', 'safe', 'on' => 'search'), - ); - } + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + return array( + array('document_instance_id, contact_type, contact_id, contact_name, contact_modified, address, emailemail, ToCc', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('document_instance_id, contact_type, contact_id, contact_name, contact_modified, address, emailemail', 'safe', 'on' => 'search'), + ); + } - /** - * @return array relational rules. - */ - public function relations() - { - return array( - 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), - 'document_instance' => array(self::BELONGS_TO, 'DocumentInstance', 'document_instance_id'), - 'contact' => array(self::BELONGS_TO, 'Contact', 'contact_id'), - 'document_output' => array(self::HAS_MANY, 'DocumentOutput', 'document_target_id'), - ); - } + /** + * @return array relational rules. + */ + public function relations() + { + return array( + 'created_user' => array(self::BELONGS_TO, 'User', 'created_user_id'), + 'document_instance' => array(self::BELONGS_TO, 'DocumentInstance', 'document_instance_id'), + 'contact' => array(self::BELONGS_TO, 'Contact', 'contact_id'), + 'document_output' => array(self::HAS_MANY, 'DocumentOutput', 'document_target_id'), + ); + } - /** - * @return array customized attribute labels (name=>label) - */ - public function attributeLabels() - { - return array(); - } + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array(); + } } From a9080cb31391a0d5cb6fecc208172508188e18c9 Mon Sep 17 00:00:00 2001 From: petergallagher Date: Wed, 28 Dec 2016 11:53:06 +0000 Subject: [PATCH 103/164] OE-6340: Generates CSV and database log This creates the CSV file and the database log. This required some refactoring of the initial code as it wasn't checking for success on actually writing the files. Basic checking has been added so the status will not be updated if the file write fails and the logs won't be written unless the update is succesful. --- protected/commands/DocManDeliveryCommand.php | 80 +++++++++++++++--- protected/config/core/common.php | 1 + .../migrations/m161222_161414_docman_log.php | 21 +++++ protected/models/DocumentLog.php | 82 +++++++++++++++++++ 4 files changed, 172 insertions(+), 12 deletions(-) create mode 100644 protected/migrations/m161222_161414_docman_log.php create mode 100644 protected/models/DocumentLog.php diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index 16aa2a694a..b418cad081 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -23,14 +23,22 @@ class DocManDeliveryCommand extends CConsoleCommand private $event; + private $csv_format = 'OEGPLetterReport_%s.csv'; + + private $generate_xml = false; + + private $generate_csv = false; + /** * DocManDeliveryCommand constructor. */ public function __construct() { $this->path = Yii::app()->params['docman_export_dir']; - // check if directory is exists + $this->generate_xml = !isset(Yii::app()->params['docman_xml_format']) || Yii::app()->params['docman_xml_format'] !== 'none'; + $this->generate_csv = Yii::app()->params['docman_generate_csv']; + // check if directory exists if (!is_dir($this->path)) { mkdir($this->path); echo "ALERT! Directory " . $this->path . " has been created!"; @@ -42,10 +50,9 @@ public function __construct() /** * Run the command. */ - public function run() + public function run($args) { $pending_documents = $this->getPendingDocuments(); - foreach ($pending_documents as $document) { echo 'Processing event ' . $document->document_target->document_instance->correspondence_event_id . PHP_EOL; $this->savePDFFile($document->document_target->document_instance->correspondence_event_id, $document->id); @@ -63,9 +70,13 @@ private function getPendingDocuments() /** * @param $event_id * @param $output_id + * + * @return bool; */ private function savePDFFile($event_id, $output_id) { + $pdf_generated = false; + $xml_generated = false; $this->event = Event::model()->findByPk($event_id); if ($this->event) { $login_page = Yii::app()->params['docman_login_url']; @@ -123,24 +134,46 @@ private function savePDFFile($event_id, $output_id) } } } - file_put_contents($this->path . "/" . $filename . ".pdf", $content); - if (!isset(Yii::app()->params['docman_xml_format']) || Yii::app()->params['docman_xml_format'] !== 'none') { - $this->generateXMLOutput($filename, $output_id); + + $pdf_generated = (file_put_contents($this->path . "/" . $filename . ".pdf", $content) !== false); + + if ($this->generate_xml) { + $xml_generated = $this->generateXMLOutput($filename); } - $this->updateDelivery($output_id); + + if (!$pdf_generated || ($this->generate_xml && !$xml_generated)) { + echo 'Generating for file ' . $filename . ' failed' . PHP_EOL; + + return false; + } + + if ($this->updateDelivery($output_id)) { + $this->logData(array( + 'hos_num' => $this->event->episode->patient->hos_num, + 'clinician_name' => $this->event->user->getFullName(), + 'event_updated' => $this->event->last_modified_date, + 'event_date' => $this->event->created_date, + 'output_date' => date('Y-m-d H:i:s'), + )); + } + + return true; } } /** * @param string $filename + * + * @return bool */ private function generateXMLOutput($filename) { $element_letter = ElementLetter::model()->findByAttributes(array("event_id" => $this->event->id)); $letter_types = array("0" => "", "1" => "Clinic discharge letter", "2" => "Post-op letter", "3" => "Clinic letter", "4" => "Other letter"); - $subspeciality = isset($this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->ref_spec) ? $this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->ref_spec : 'SS'; - $subspeciality_name = isset($this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->name) ? $this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty->name : 'Support Services'; + $subObj = $this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty; + $subspeciality = isset($subObj->ref_spec) ? $subObj->ref_spec : 'SS'; + $subspeciality_name = isset($subObj->name) ? $subObj->name : 'Support Services'; $nat_id = isset($this->event->episode->patient->gp->nat_id) ? $this->event->episode->patient->gp->nat_id : null; $gp_name = isset($this->event->episode->patient->gp->contact) ? $this->event->episode->patient->gp->contact->getFullName() : null; $practice_code = isset($this->event->episode->patient->practice->code) ? $this->event->episode->patient->practice->code : ''; @@ -188,7 +221,7 @@ private function generateXMLOutput($filename) "; - file_put_contents($this->path . "/" . $filename . ".XML", $this->cleanXML($xml)); + return (file_put_contents($this->path . "/" . $filename . ".XML", $this->cleanXML($xml)) !== false); } /** @@ -203,12 +236,35 @@ private function cleanXML($xml) } /** - * @param int $output_id + * @param $output_id + * @return bool */ private function updateDelivery($output_id) { $output = DocumentOutput::model()->findByPk($output_id); $output->output_status = "COMPLETE"; - $output->save(); + + return $output->save(); + } + + /** + * @param $data + */ + private function logData($data) + { + if ($this->generate_csv) { + $doc_log = new DocumentLog(); + $doc_log->attributes = $data; + $doc_log->save(); + + $csv_filename = implode(DIRECTORY_SEPARATOR, array($this->path, sprintf($this->csv_format, date('Ymd')))); + + $fp = fopen($csv_filename, 'ab'); + if(!filesize($csv_filename)){ + fputcsv($fp, array_keys($data)); + } + fputcsv($fp, $data); + fclose($fp); + } } } \ No newline at end of file diff --git a/protected/config/core/common.php b/protected/config/core/common.php index b7139ed69d..0beda8c5b6 100644 --- a/protected/config/core/common.php +++ b/protected/config/core/common.php @@ -420,5 +420,6 @@ ) ), 'clinical_management_pcr' => true, + 'docman_generate_csv' => false, ), ); diff --git a/protected/migrations/m161222_161414_docman_log.php b/protected/migrations/m161222_161414_docman_log.php new file mode 100644 index 0000000000..2d9f1775a8 --- /dev/null +++ b/protected/migrations/m161222_161414_docman_log.php @@ -0,0 +1,21 @@ +createOETable('document_log', array( + 'id' => 'pk', + 'hos_num' => 'varchar(40)', + 'clinician_name' => 'varchar(256)', + 'event_updated' => 'datetime', + 'event_date' => 'datetime', + 'output_date' => 'datetime', + )); + } + + public function down() + { + $this->dropOETable('document_log'); + } +} \ No newline at end of file diff --git a/protected/models/DocumentLog.php b/protected/models/DocumentLog.php new file mode 100644 index 0000000000..c95cebe39b --- /dev/null +++ b/protected/models/DocumentLog.php @@ -0,0 +1,82 @@ +. + * + * @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 + */ + +/** + * This is the model class for table "document_log". + * + * The followings are the available columns in table 'document_log': + * + * @property int $id + * + * The followings are the available model relations: + */ +class DocumentLog extends BaseActiveRecordVersioned +{ + /** + * Returns the static model of the specified AR class. + * + * @return DocumentLog the static model class + */ + public static function model($className = __CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'document_log'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, hos_num, clinician_name, event_updated, event_date, output_date', 'safe'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + ); + } +} From a043a61584ac292959cbbb1bbc36527b5ea4f0f1 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 3 Jan 2017 11:13:57 +0000 Subject: [PATCH 104/164] OE-6331 Addition of parameter used to encode password with UTF8 if required. utf8_decode_required = true - for Moorfields --- protected/components/UserIdentity.php | 4 +++- protected/config/core/common.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/protected/components/UserIdentity.php b/protected/components/UserIdentity.php index a5199be1a2..7d2807212c 100644 --- a/protected/components/UserIdentity.php +++ b/protected/components/UserIdentity.php @@ -75,7 +75,9 @@ public function authenticate($force = false) Yii::app()->params['auth_source'] = 'BASIC'; } - $this->password = utf8_decode($this->password); + if(Yii::app()->params['utf8_decode_required']){ + $this->password = utf8_decode($this->password); + } /* * Here we diverge depending on the authentication source. diff --git a/protected/config/core/common.php b/protected/config/core/common.php index b7139ed69d..dcefd215b4 100644 --- a/protected/config/core/common.php +++ b/protected/config/core/common.php @@ -256,6 +256,7 @@ ), 'params' => array( + 'utf8_decode_required' => false, 'pseudonymise_patient_details' => false, 'ab_testing' => false, 'auth_source' => 'BASIC', // Options are BASIC or LDAP. From ecc39ff49d563f1f4aba708ab68d377484d62ae0 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 3 Jan 2017 13:55:40 +0000 Subject: [PATCH 105/164] OE-6321 Addition of Alert Box warning about Episode data for those patients with multiple episodes. For patients with single episodes, no alert is shown. --- protected/views/clinical/episodeSummary.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/protected/views/clinical/episodeSummary.php b/protected/views/clinical/episodeSummary.php index 2dd549857c..7cc8d664f9 100644 --- a/protected/views/clinical/episodeSummary.php +++ b/protected/views/clinical/episodeSummary.php @@ -37,7 +37,18 @@
- + findAll('patient_id = "' . $episode->patient->id . ' "')) { + if (count($episodesTotal) > 1){ + ?> +
Only data from the selected episode is included in this + summary. + For a full picture of the patient’s care, please look at all episodes individually. +
+

Overview

From e2f22ca3b50aee0125d22f2238f6517885b88145 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 3 Jan 2017 14:15:55 +0000 Subject: [PATCH 106/164] OE-6321 Addition of Alert Box warning about Episode data for those patients with multiple episodes. For patients with single episodes, no alert is shown. --- protected/config/core/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/config/core/common.php b/protected/config/core/common.php index dcefd215b4..30d541ee05 100644 --- a/protected/config/core/common.php +++ b/protected/config/core/common.php @@ -256,7 +256,7 @@ ), 'params' => array( - 'utf8_decode_required' => false, + 'utf8_decode_required' => true, 'pseudonymise_patient_details' => false, 'ab_testing' => false, 'auth_source' => 'BASIC', // Options are BASIC or LDAP. From a6ede9b825e50f484994a1304e73d9a212ed7016 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 3 Jan 2017 15:52:46 +0000 Subject: [PATCH 107/164] OE-5966 Changes to make sure that Warnings are displayed throughout the Op Booking pages - Create/Schedule/View. --- .../views/booking/schedule.php | 19 +++++++++++++++++++ .../views/default/create.php | 17 +++++++++++++++++ .../views/default/view.php | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/protected/modules/OphTrOperationbooking/views/booking/schedule.php b/protected/modules/OphTrOperationbooking/views/booking/schedule.php index 935daead40..4bed00cdcc 100644 --- a/protected/modules/OphTrOperationbooking/views/booking/schedule.php +++ b/protected/modules/OphTrOperationbooking/views/booking/schedule.php @@ -18,6 +18,11 @@ */ ?> beginContent('//patient/event_container'); ?> +checkAccess('OprnViewClinical'); + +$warnings = $this->patient->getWarnings($clinical); +?>
@@ -39,6 +44,20 @@
+ +
+
+
+ + + - +
+
+
+ + +
patient->getDisplayName() ?> (patient->hos_num ?> ) diff --git a/protected/modules/OphTrOperationbooking/views/default/create.php b/protected/modules/OphTrOperationbooking/views/default/create.php index a541768b33..8ed2088ab4 100644 --- a/protected/modules/OphTrOperationbooking/views/default/create.php +++ b/protected/modules/OphTrOperationbooking/views/default/create.php @@ -18,6 +18,11 @@ */ ?> beginContent('//patient/event_container'); ?> +checkAccess('OprnViewClinical'); + +$warnings = $this->patient->getWarnings($clinical); +?> beginWidget('BaseEventTypeCActiveForm', array( @@ -32,6 +37,18 @@ $this->event_actions[] = EventAction::button('Save and Schedule now', '#', array('level' => 'secondary'), array('name' => 'scheduleNow', 'id' => 'et_save_and_schedule', 'class' => 'button small', 'form' => 'clinical-create', 'style' => $this->checkScheduleAccess() ? '' : 'display: none;')); ?> + +
+
+
+ + + - +
+
+
+ displayErrors($errors); $this->renderOpenElements($this->action->id, $form); diff --git a/protected/modules/OphTrOperationbooking/views/default/view.php b/protected/modules/OphTrOperationbooking/views/default/view.php index 0cf9ed2319..13e3763e1d 100644 --- a/protected/modules/OphTrOperationbooking/views/default/view.php +++ b/protected/modules/OphTrOperationbooking/views/default/view.php @@ -17,6 +17,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ ?> +checkAccess('OprnViewClinical'); + +$warnings = $this->patient->getWarnings($clinical); +?> beginContent('//patient/event_container'); ?> @@ -24,6 +29,19 @@ $this->moduleNameCssClass .= ' highlight-fields'; $this->title .= ' ('.Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($this->event->id))->status->name.')'?> + +
+
+
+ + + - +
+
+
+ + has_gp) {?>
Patient has no GP practice address, please correct in PAS before printing GP letter. From d23d7f0822fae6cca39249835b25face02ce43d9 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 4 Jan 2017 12:58:19 +0000 Subject: [PATCH 108/164] OE-5966 Changes to make sure that Warnings are displayed throughout the Op Booking pages - Create/Schedule/View/Edit --- .../views/default/update.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/protected/modules/OphTrOperationbooking/views/default/update.php b/protected/modules/OphTrOperationbooking/views/default/update.php index 332d55b450..a0da7de49b 100644 --- a/protected/modules/OphTrOperationbooking/views/default/update.php +++ b/protected/modules/OphTrOperationbooking/views/default/update.php @@ -18,6 +18,11 @@ */ ?> beginContent('//patient/event_container'); ?> +checkAccess('OprnViewClinical'); + +$warnings = $this->patient->getWarnings($clinical); +?> beginWidget('BaseEventTypeCActiveForm', array( @@ -43,6 +48,19 @@ params['OphTrOperationbooking_duplicate_proc_warn']) {?> + +
+
+
+ + + - +
+
+
+ + displayErrors($errors)?> renderOpenElements($this->action->id, $form); ?> renderOptionalElements($this->action->id, $form); ?> From 5302111065f2b356d651e25a051e3e23dbe61034 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 4 Jan 2017 16:31:14 +0000 Subject: [PATCH 109/164] OE-6244 Changes to make sure that "Bilateral Bilateral ..." doesn't happen on Patient summary screen under "Other ophthalmic diagnoses" heading. --- protected/views/patient/_130_diagnoses.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/protected/views/patient/_130_diagnoses.php b/protected/views/patient/_130_diagnoses.php index fa28dcd4e9..f265ea4bf0 100644 --- a/protected/views/patient/_130_diagnoses.php +++ b/protected/views/patient/_130_diagnoses.php @@ -46,8 +46,15 @@ patient->ophthalmicDiagnoses as $diagnosis) {?> + disorder->term, $diagnosis->eye->adjective. ' ') === 0) { + $term = $diagnosis->disorder->term; + } else { + $term = $diagnosis->eye->adjective . ' ' . $diagnosis->disorder->term; + } + ?>
 dateText?> - eye->adjective?> disorder->term?> + checkAccess('OprnEditOtherOphDiagnosis')) { ?> Remove From 9b2a61278900c9314e7232e44316325afd1c115b Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Thu, 5 Jan 2017 09:57:39 +0000 Subject: [PATCH 110/164] Fixes problem with previous merge that lost a fix to give the Macro drop-down a default entry. --- .../views/default/create_ElementLetter.php | 4 ++-- .../views/default/update_ElementLetter.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php index a701a70f8d..4b9061def5 100644 --- a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php @@ -60,7 +60,7 @@
- letter_macros, '', array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width resizeselect')); ?> + letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width resizeselect')); ?>
@@ -399,4 +399,4 @@ $("select.resizeselect").resizeselect(); })(jQuery, window); - \ No newline at end of file + diff --git a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php index 398a736ef8..a1c8ab31d9 100644 --- a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php @@ -68,7 +68,7 @@
- letter_macros, '', array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width')); ?> + letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width')); ?>
From 442c54898dbdf99a12e6dfc2ec31390afdb368ce Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 5 Jan 2017 11:04:04 +0000 Subject: [PATCH 111/164] OE-6330 Addition of macro dynamic widening in Edit page. --- .../views/default/update_ElementLetter.php | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php index a1c8ab31d9..08a134446c 100644 --- a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php @@ -68,7 +68,7 @@
- letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width')); ?> + letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width resizeselect')); ?>
@@ -351,3 +351,36 @@ class="row field-row"re) < 1) || (!
+ \ No newline at end of file From 6667834cb656e76b6beaf9209ad71629ae8e6a30 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 5 Jan 2017 15:42:52 +0000 Subject: [PATCH 112/164] OE-6330 Addition of macro dynamic widening in Edit page. --- .../views/default/update_ElementLetter.php | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php index 08a134446c..0343fbfc18 100644 --- a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php @@ -67,11 +67,46 @@
-
+
letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width resizeselect')); ?>
+ +
@@ -351,36 +386,3 @@ class="row field-row"re) < 1) || (!
- \ No newline at end of file From c947be3c05f9cd3818efef13f15c53eee119a8a7 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 10 Jan 2017 16:13:14 +0000 Subject: [PATCH 113/164] OE-6330 Addition of macro dynamic widening in Edit page. --- ...70110_152227_remove_migration_route_fk.php | 30 +++++++++++++++++++ protected/models/Medication.php | 4 +-- protected/views/medication/list.php | 5 +++- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 protected/migrations/m170110_152227_remove_migration_route_fk.php diff --git a/protected/migrations/m170110_152227_remove_migration_route_fk.php b/protected/migrations/m170110_152227_remove_migration_route_fk.php new file mode 100644 index 0000000000..001a50dc15 --- /dev/null +++ b/protected/migrations/m170110_152227_remove_migration_route_fk.php @@ -0,0 +1,30 @@ +params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) + + { + + $this->alterColumn('medication', 'route_id', 'int(10) unsigned DEFAULT NULL'); + + } ++ } + + + + public function down() + + { + + if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) + + { + + $this->alterColumn('medication', 'route_id', 'int(10) unsigned NOT NULL'); + + } + + } + /* + // Use safeUp/safeDown to do migration with transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} \ No newline at end of file diff --git a/protected/models/Medication.php b/protected/models/Medication.php index 1dd036098a..7cf41c468d 100644 --- a/protected/models/Medication.php +++ b/protected/models/Medication.php @@ -48,10 +48,10 @@ public function tableName() */ public function rules() { - $required_fields = 'route_id, start_date'; + $required_fields = 'start_date'; if (!isset(Yii::app()->params['enable_concise_med_history']) || !Yii::app()->params['enable_concise_med_history']) { - $required_fields .= ', frequency_id'; + $required_fields .= ', frequency_id, route_id'; } return array( array('medication_drug_id, drug_id, route_id, option_id, dose, frequency_id, start_date, end_date, stop_reason_id, prescription_item_id', 'safe'), diff --git a/protected/views/medication/list.php b/protected/views/medication/list.php index 77c4355e68..00e81161da 100644 --- a/protected/views/medication/list.php +++ b/protected/views/medication/list.php @@ -24,7 +24,10 @@ Administration - dose ?> route->name ?> option ? "({$medication->option->name})" : '' ?> frequency->name) ? $medication->frequency->name : '' ?> + dose ?> + route->name) ? $medication->route->name : '' ?> + option ? "({$medication->option->name})" : '' ?> + frequency->name) ? $medication->frequency->name : '' ?> Date From 01b883b97abdcb470fda091a55f245e18603ac9c Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 11 Jan 2017 15:55:58 +0000 Subject: [PATCH 114/164] OE-5621 - Making Route optional --- .../m170110_152227_remove_migration_route_fk.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/protected/migrations/m170110_152227_remove_migration_route_fk.php b/protected/migrations/m170110_152227_remove_migration_route_fk.php index 001a50dc15..75ce27ee02 100644 --- a/protected/migrations/m170110_152227_remove_migration_route_fk.php +++ b/protected/migrations/m170110_152227_remove_migration_route_fk.php @@ -4,18 +4,12 @@ class m170110_152227_remove_migration_route_fk extends CDbMigration { + public function up() + { - + if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) - + { - + $this->alterColumn('medication', 'route_id', 'int(10) unsigned DEFAULT NULL'); - + } + $this->alterColumn('medication', 'route_id', 'int(10) unsigned DEFAULT NULL'); + } + + public function down() + { - + if (isset(Yii::app()->params['enable_concise_med_history']) && Yii::app()->params['enable_concise_med_history']) - + { - + $this->alterColumn('medication', 'route_id', 'int(10) unsigned NOT NULL'); - + } + $this->alterColumn('medication', 'route_id', 'int(10) unsigned NOT NULL'); + } /* // Use safeUp/safeDown to do migration with transaction From 36b4971278d8b34a33b5c886c0cb0eb85b6d668d Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Wed, 11 Jan 2017 16:03:47 +0000 Subject: [PATCH 115/164] OE-5621 fix some errant + signs in migration script. --- ...70110_152227_remove_migration_route_fk.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/protected/migrations/m170110_152227_remove_migration_route_fk.php b/protected/migrations/m170110_152227_remove_migration_route_fk.php index 75ce27ee02..fc9e18af6e 100644 --- a/protected/migrations/m170110_152227_remove_migration_route_fk.php +++ b/protected/migrations/m170110_152227_remove_migration_route_fk.php @@ -2,15 +2,15 @@ class m170110_152227_remove_migration_route_fk extends CDbMigration { -+ public function up() - + { - $this->alterColumn('medication', 'route_id', 'int(10) unsigned DEFAULT NULL'); -+ } - + - + public function down() - + { - $this->alterColumn('medication', 'route_id', 'int(10) unsigned NOT NULL'); - + } + public function up() + { + $this->alterColumn('medication', 'route_id', 'int(10) unsigned DEFAULT NULL'); + } + + public function down() + { + $this->alterColumn('medication', 'route_id', 'int(10) unsigned NOT NULL'); + } /* // Use safeUp/safeDown to do migration with transaction public function safeUp() @@ -21,4 +21,4 @@ public function safeDown() { } */ -} \ No newline at end of file +} From d9752d0d9b492d2ea3783b8114d722c150d14358 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 12 Jan 2017 16:52:57 +0000 Subject: [PATCH 116/164] OE-6345 Multiple Optom Portal issues. 1- Case-insensitive search on VA/NVA and Complication (as suggested by Peter Gallagher) 2- Change to RequiredIfSide function 3- If instrument has value, set as qualitative value --- protected/models/BaseEventTypeElement.php | 2 +- .../OphCiExamination/components/ExaminationCreator.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/protected/models/BaseEventTypeElement.php b/protected/models/BaseEventTypeElement.php index f22ef2dc45..b70acf8afe 100644 --- a/protected/models/BaseEventTypeElement.php +++ b/protected/models/BaseEventTypeElement.php @@ -353,7 +353,7 @@ public function getFrontEndErrors() public function requiredIfSide($attribute, $params) { - if (($params['side'] == 'left' && $this->eye_id != 2) || ($params['side'] == 'right' && $this->eye_id != 1)) { + if (($params['side'] === 'left' && $this->eye_id != 2) || ($params['side'] === 'right' && $this->eye_id != 1)) { if ($this->$attribute == null) { if (!@$params['message']) { $params['message'] = ucfirst($params['side']).' {attribute} cannot be blank.'; diff --git a/protected/modules/OphCiExamination/components/ExaminationCreator.php b/protected/modules/OphCiExamination/components/ExaminationCreator.php index 99c9789c1f..425fda1388 100644 --- a/protected/modules/OphCiExamination/components/ExaminationCreator.php +++ b/protected/modules/OphCiExamination/components/ExaminationCreator.php @@ -216,7 +216,7 @@ protected function addVisualAcuityReading($userId, $visualAcuity, $unit, $vaData $vaReading->element_id = $visualAcuity->id; $baseValue = \OEModule\OphCiExamination\models\OphCiExamination_VisualAcuityUnitValue::model()->getBaseValue($unit->id, $vaData['reading']); $vaReading->value = $baseValue; - $vaReading->method_id = \OEModule\OphCiExamination\models\OphCiExamination_VisualAcuity_Method::model()->find('name = :name', array('name' => $vaData['method']))->id; + $vaReading->method_id = \OEModule\OphCiExamination\models\OphCiExamination_VisualAcuity_Method::model()->find('LOWER(name) = :name', array('name' => strtolower($vaData['method'])))->id; if($eyeLabel === 'left'){ $vaReading->side = \OEModule\OphCiExamination\models\OphCiExamination_VisualAcuity_Reading::LEFT; } else { @@ -346,7 +346,7 @@ protected function addComplication($userId, $eyeIds, $opNoteEventId, $eye, $comp foreach ($eye['complications'] as $complicationArray) { $eyeComplication = new \OEModule\OphCiExamination\models\OphCiExamination_Et_PostOpComplications(); $eyeComplication->element_id = $complications->id; - $complicationToAdd = \OEModule\OphCiExamination\models\OphCiExamination_PostOpComplications::model()->find('name = "' . $complicationArray['complication'] . '"'); + $complicationToAdd = \OEModule\OphCiExamination\models\OphCiExamination_PostOpComplications::model()->find('LOWER(name) = "' . strtolower($complicationArray['complication']) . '"'); $eyeComplication->complication_id = $complicationToAdd->id; $eyeComplication->operation_note_id = $opNoteEventId; $eyeComplication->eye_id = $eyeIds[$eyeLabel]; @@ -384,6 +384,9 @@ protected function addIop($eyeIds, $eye, $iop, $eyeLabel) array($iopReading['mm_hg'])); $instrument = \OEModule\OphCiExamination\models\OphCiExamination_Instrument::model()->find('LOWER(name) = ?', array(strtolower($iopReading['instrument']))); + if ($instrument['scale_id']){ + $iopValue->qualitative_reading_id = $instrument['scale_id']; + } $iopValue->reading_id = $iopReadingValue['id']; $iopValue->instrument_id = $instrument['id']; if (!$iopValue->save(true, null, true)) { From 563a56319db0b8124bfa5f192f8a7ade6f3a3f99 Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Fri, 13 Jan 2017 09:32:41 +0000 Subject: [PATCH 117/164] OE-6345 fix for axis value 0. --- protected/models/BaseEventTypeElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/models/BaseEventTypeElement.php b/protected/models/BaseEventTypeElement.php index b70acf8afe..bee1f802cc 100644 --- a/protected/models/BaseEventTypeElement.php +++ b/protected/models/BaseEventTypeElement.php @@ -354,7 +354,7 @@ public function getFrontEndErrors() public function requiredIfSide($attribute, $params) { if (($params['side'] === 'left' && $this->eye_id != 2) || ($params['side'] === 'right' && $this->eye_id != 1)) { - if ($this->$attribute == null) { + if ($this->$attribute === null) { if (!@$params['message']) { $params['message'] = ucfirst($params['side']).' {attribute} cannot be blank.'; } From 8bab361bcf05cc11210f99cb652f951cca247e96 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Fri, 13 Jan 2017 15:41:37 +0000 Subject: [PATCH 118/164] OE-6198 Migration to move PCR RIsk --- .../m170113_133457_move_PCR_order.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 protected/migrations/m170113_133457_move_PCR_order.php diff --git a/protected/migrations/m170113_133457_move_PCR_order.php b/protected/migrations/m170113_133457_move_PCR_order.php new file mode 100644 index 0000000000..016b55c6ca --- /dev/null +++ b/protected/migrations/m170113_133457_move_PCR_order.php @@ -0,0 +1,29 @@ +update('element_type', array('display_order' => 94), 'name = :nm', array(':nm' => 'PCR Risk')); + } + + public function down() + { + echo "m170113_133457_move_PCR_order does not support migration down.\n"; + return false; + } + + + // Use safeUp/safeDown to do migration with transaction + public function safeUp() + { + $this->update('element_type', array('display_order' => 94), 'name = :nm', array(':nm' => 'PCR Risk')); + } + + public function safeDown() + { + echo "m170113_133457_move_PCR_order does not support migration down.\n"; + return false; + } + +} \ No newline at end of file From 3f08284db22492862bd4acec4f07495fd990fe94 Mon Sep 17 00:00:00 2001 From: Sabi Date: Fri, 13 Jan 2017 17:00:34 +0000 Subject: [PATCH 119/164] OE-6343 : initial commit : Show partially booked procedures in operation note when theatre diary is not used --- protected/config/core/common.php | 1 + .../components/OphTrOperationbooking_API.php | 97 +++++++++++++++++++ .../controllers/DefaultController.php | 13 ++- .../views/default/select_event.php | 7 +- 4 files changed, 116 insertions(+), 2 deletions(-) diff --git a/protected/config/core/common.php b/protected/config/core/common.php index 83a7646f48..2c51c5717b 100644 --- a/protected/config/core/common.php +++ b/protected/config/core/common.php @@ -419,5 +419,6 @@ 'saveprint' => 'Save and print' ) ), + "disable_theatre_diary" => false, ), ); diff --git a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php index 7a168a8943..f5131df74b 100644 --- a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php +++ b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php @@ -429,5 +429,102 @@ public function getAllBookingsWithoutOperationNotes(\Patient $patient) return implode(', ', $not_booked_events); } + + public function autoScheduleOperationBookings(\Episode $episode) + { + + $criteria = new CDbCriteria(); + $criteria->order = 't.created_date asc'; + $criteria->condition = 't.status_id = 1'; + $criteria->compare('episode_id', $episode->id); + + $operations = Element_OphTrOperationbooking_Operation::model()->with('event')->findAll($criteria); + + $op_status_scheduled = OphTrOperationbooking_Operation_Status::model()->find('name=?', array('Scheduled')); + $ep_status_listed = EpisodeStatus::model()->find('name=?', array('Listed/booked')); + + foreach($operations as $operation){ + $session = $this->getFirstBookableSessionByFirm($episode->firm_id, $operation); + + $schedule_options = Element_OphTrOperationbooking_ScheduleOperation::model()->find('event_id = ?', array($operation->event->id)); + + if($session){ + $errors = null; + + try { + + $ward = OphTrOperationbooking_Operation_Ward::model()->find('site_id = ?', array($operation->site->id)); + $booking = new OphTrOperationbooking_Operation_Booking(); + $booking->ward_id = $ward->id; + $booking->element_id = $operation->id; + $booking->session_id = $session->id; + $booking->session_theatre_id = 1; + $booking->session_date = date("Y-m-d H:i:s"); + $booking->session_start_time = $session->start_time; + $booking->admission_time = $session->start_time; + $booking->session_end_time = $session->end_time; + $booking->cancellation_comment = ''; + + $booking->save(); + + $result = $operation->schedule($booking, '', '', '', false, null, $schedule_options); + + if ($result !== true) { + $errors = $result; + Yii::app()->user->setFlash('notice', $errors); + } else { + } + + } catch (RaceConditionException $e) { + Yii::app()->user->setFlash('notice', $e->getMessage()); + } catch (Exception $e) { + // no handling of this at the moment + throw $e; + } + + if(!$errors){ + $operation->status_id = $op_status_scheduled->id; + $operation->save(); + + $episode->episode_status_id = $ep_status_listed->id; + $episode->save(); + + $operation->event->deleteIssues(); + } + } + } + + } + + public function getFirstBookableSessionByFirm($firm_id, $operation) + { + $criteria = new CDbCriteria(); + $criteria->compare('firm_id', $firm_id); + $criteria->compare('available', 1); + //$criteria->addSearchCondition('date', "$year-$month-%", false); + $criteria->addCondition("date >= " . date("Y-m-d")); + $criteria->order = 'date asc'; + + if(!$operation) { + return OphTrOperationbooking_Operation_Session::model()->find($criteria); + } + + $sessions = OphTrOperationbooking_Operation_Session::model()->findAll($criteria); + // $operation = Element_OphTrOperationbooking_Operation::model()->findByPk($operation_id); + + if($operation){ + foreach ($sessions as $session){ + $is_bookable = $session->operationBookable($operation); + + if ($session->availableMinutes >= $operation->total_duration) { + return $session; + } + } + } else { + throw new Exception("Operation event not found: $operation_id"); + } + + return null; + } } diff --git a/protected/modules/OphTrOperationnote/controllers/DefaultController.php b/protected/modules/OphTrOperationnote/controllers/DefaultController.php index a1538adfb8..6dfbd8f75f 100644 --- a/protected/modules/OphTrOperationnote/controllers/DefaultController.php +++ b/protected/modules/OphTrOperationnote/controllers/DefaultController.php @@ -197,8 +197,10 @@ protected function initActionCreate() { parent::initActionCreate(); + $api = Yii::app()->moduleAPI->get('OphTrOperationbooking'); + if (isset($_GET['booking_event_id'])) { - if (!$api = Yii::app()->moduleAPI->get('OphTrOperationbooking')) { + if (!$api) { throw new Exception('invalid request for booking event'); } if (!$this->booking_operation = $api->getOperationForEvent($_GET['booking_event_id'])) { @@ -207,6 +209,14 @@ protected function initActionCreate() } elseif (isset($_GET['unbooked'])) { $this->unbooked = true; } + + $is_theatre_diary_disabled = Yii::app()->params['disable_theatre_diary']; + // if Theatre diary is disabled we schedule the Op to the first available slot + + if ($api && $is_theatre_diary_disabled) { + $api->autoScheduleOperationBookings($this->current_episode); + } + $this->initEdit(); } @@ -273,6 +283,7 @@ public function actionCreate() $this->render('select_event', array( 'errors' => $errors, 'bookings' => $bookings, + 'is_theatre_diary_disabled' => Yii::app()->params['disable_theatre_diary'] )); } } diff --git a/protected/modules/OphTrOperationnote/views/default/select_event.php b/protected/modules/OphTrOperationnote/views/default/select_event.php index 6c07701b98..94c009e1a4 100644 --- a/protected/modules/OphTrOperationnote/views/default/select_event.php +++ b/protected/modules/OphTrOperationnote/views/default/select_event.php @@ -65,12 +65,17 @@ op - + operation->booking->session->NHSDate('date')?> + Operation + + + operation->comments; ?> + operation->procedures as $i => $procedure) { if ($i > 0) { echo '
'; } From 288d100ae3ceae41524535b598362834d5ead34a Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Mon, 16 Jan 2017 13:38:34 +0000 Subject: [PATCH 120/164] OE-6198 Move PCR location. Force choice on Diabetes to cover both eyes. --- .../default/form_Element_OphCiExamination_PcrRisk.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php index e2ef46fb74..c5127fc23d 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php @@ -17,6 +17,17 @@ $(document.body).on('change', $pcrRiskEl.find('.right-eye'), function () { pcrCalculate($pcrRiskEl.find('.right-eye'), 'right'); }); + + $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_right_diabetic").change(function () { + var $pcrDiabeticRight = $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_right_diabetic").prop('selectedIndex'); + $("select#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_left_diabetic").prop('selectedIndex', $pcrDiabeticRight); + }); + + $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_left_diabetic").change(function () { + var $pcrDiabeticLeft = $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_left_diabetic").prop('selectedIndex'); + $("select#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_right_diabetic").prop('selectedIndex', $pcrDiabeticLeft); + }); + });
From d4eb2d33c82cd229b4210b01d83bc9fb2f201be9 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Mon, 16 Jan 2017 16:28:00 +0000 Subject: [PATCH 121/164] OE-6353 Force Error if Dilation added without any items chosen. Allow dilation to be added for just one eye at a time. --- .../controllers/DefaultController.php | 5 +++-- .../Element_OphCiExamination_Dilation.php | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/protected/modules/OphCiExamination/controllers/DefaultController.php b/protected/modules/OphCiExamination/controllers/DefaultController.php index a3a6d26bb1..1446d3e1a2 100644 --- a/protected/modules/OphCiExamination/controllers/DefaultController.php +++ b/protected/modules/OphCiExamination/controllers/DefaultController.php @@ -927,10 +927,11 @@ protected function updateRisk($risk_name, $risk_value, $risk_comment) protected function saveComplexAttributes_Element_OphCiExamination_Dilation(models\Element_OphCiExamination_Dilation $element, $data, $index) { $model_name = \CHtml::modelName($element); - $element->updateTreatments(\Eye::LEFT, $element->hasLeft() ? + + $element->updateTreatments(\Eye::LEFT, $element->left_treatments ? @$data[$model_name]['left_treatments'] : array()); - $element->updateTreatments(\Eye::RIGHT, $element->hasRight() ? + $element->updateTreatments(\Eye::RIGHT, $element->right_treatments ? @$data[$model_name]['right_treatments'] : array()); } diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php index 4fcd120849..71428dad00 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php @@ -144,6 +144,23 @@ public function getUnselectedDilationDrugs($side) */ protected function afterValidate() { + if (!$this->left_treatments || !$this->right_treatments) { + $values = false; + if ($this->hasLeft()) { + if ($this->left_treatments) { + $values = true; + } + } + if ($this->hasRight()) { + if ($this->right_treatments) { + $values = true; + } + } + if (!$values) { + $this->addError(null, 'Dilation requires data'); + } + } + foreach (array('left' => 'hasLeft', 'right' => 'hasRight') as $side => $checkFunc) { if ($this->$checkFunc()) { foreach ($this->{$side.'_treatments'} as $i => $treat) { @@ -155,6 +172,7 @@ protected function afterValidate() } } } + parent::afterValidate(); } /** From a05417650bd27912a32da0ed874f41d412398850 Mon Sep 17 00:00:00 2001 From: Sabi Date: Mon, 16 Jan 2017 17:05:20 +0000 Subject: [PATCH 122/164] OE-6343 : Show partially booked procedures in operation note when theatre diary is not used - iterating over all session (ignoring firm) --- .../components/OphTrOperationbooking_API.php | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php index f5131df74b..a7f030f22f 100644 --- a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php +++ b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php @@ -444,7 +444,8 @@ public function autoScheduleOperationBookings(\Episode $episode) $ep_status_listed = EpisodeStatus::model()->find('name=?', array('Listed/booked')); foreach($operations as $operation){ - $session = $this->getFirstBookableSessionByFirm($episode->firm_id, $operation); + // get the first bookable session regardless of the firm + $session = $this->getFirstBookableSession($operation); $schedule_options = Element_OphTrOperationbooking_ScheduleOperation::model()->find('event_id = ?', array($operation->event->id)); @@ -471,12 +472,12 @@ public function autoScheduleOperationBookings(\Episode $episode) if ($result !== true) { $errors = $result; - Yii::app()->user->setFlash('notice', $errors); + Yii::app()->user->setFlash('error.alert', $errors); } else { } } catch (RaceConditionException $e) { - Yii::app()->user->setFlash('notice', $e->getMessage()); + Yii::app()->user->setFlash('error.alert', $e->getMessage()); } catch (Exception $e) { // no handling of this at the moment throw $e; @@ -491,37 +492,34 @@ public function autoScheduleOperationBookings(\Episode $episode) $operation->event->deleteIssues(); } + } else { + Yii::app()->user->setFlash('error.no-sessions', 'Operation notes cannot be created for un-scheduled Operations. Please add free sessions.'); } } } - public function getFirstBookableSessionByFirm($firm_id, $operation) - { + public function getFirstBookableSession(\Element_OphTrOperationbooking_Operation $operation) + { $criteria = new CDbCriteria(); - $criteria->compare('firm_id', $firm_id); $criteria->compare('available', 1); - //$criteria->addSearchCondition('date', "$year-$month-%", false); - $criteria->addCondition("date >= " . date("Y-m-d")); + $criteria->addCondition("date >= '" . date("Y-m-d") . "'" ); $criteria->order = 'date asc'; - if(!$operation) { - return OphTrOperationbooking_Operation_Session::model()->find($criteria); - } - - $sessions = OphTrOperationbooking_Operation_Session::model()->findAll($criteria); - // $operation = Element_OphTrOperationbooking_Operation::model()->findByPk($operation_id); + $dataProvider = new CActiveDataProvider('OphTrOperationbooking_Operation_Session', + array( + 'criteria' => $criteria + ) + ); - if($operation){ - foreach ($sessions as $session){ - $is_bookable = $session->operationBookable($operation); + $session_iterator = new CDataProviderIterator($dataProvider); + + foreach ($session_iterator as $session){ + $is_bookable = $session->operationBookable($operation); - if ($session->availableMinutes >= $operation->total_duration) { + if ($is_bookable && ($session->availableMinutes >= $operation->total_duration)) { return $session; - } } - } else { - throw new Exception("Operation event not found: $operation_id"); } return null; From 269f30d46a49d9cb735d8fae5bed9518895eaff4 Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Tue, 17 Jan 2017 09:37:44 +0000 Subject: [PATCH 123/164] Revert "OE-6353" --- .../controllers/DefaultController.php | 5 ++--- .../Element_OphCiExamination_Dilation.php | 18 ------------------ 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/protected/modules/OphCiExamination/controllers/DefaultController.php b/protected/modules/OphCiExamination/controllers/DefaultController.php index 1446d3e1a2..a3a6d26bb1 100644 --- a/protected/modules/OphCiExamination/controllers/DefaultController.php +++ b/protected/modules/OphCiExamination/controllers/DefaultController.php @@ -927,11 +927,10 @@ protected function updateRisk($risk_name, $risk_value, $risk_comment) protected function saveComplexAttributes_Element_OphCiExamination_Dilation(models\Element_OphCiExamination_Dilation $element, $data, $index) { $model_name = \CHtml::modelName($element); - - $element->updateTreatments(\Eye::LEFT, $element->left_treatments ? + $element->updateTreatments(\Eye::LEFT, $element->hasLeft() ? @$data[$model_name]['left_treatments'] : array()); - $element->updateTreatments(\Eye::RIGHT, $element->right_treatments ? + $element->updateTreatments(\Eye::RIGHT, $element->hasRight() ? @$data[$model_name]['right_treatments'] : array()); } diff --git a/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php b/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php index 71428dad00..4fcd120849 100644 --- a/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php +++ b/protected/modules/OphCiExamination/models/Element_OphCiExamination_Dilation.php @@ -144,23 +144,6 @@ public function getUnselectedDilationDrugs($side) */ protected function afterValidate() { - if (!$this->left_treatments || !$this->right_treatments) { - $values = false; - if ($this->hasLeft()) { - if ($this->left_treatments) { - $values = true; - } - } - if ($this->hasRight()) { - if ($this->right_treatments) { - $values = true; - } - } - if (!$values) { - $this->addError(null, 'Dilation requires data'); - } - } - foreach (array('left' => 'hasLeft', 'right' => 'hasRight') as $side => $checkFunc) { if ($this->$checkFunc()) { foreach ($this->{$side.'_treatments'} as $i => $treat) { @@ -172,7 +155,6 @@ protected function afterValidate() } } } - parent::afterValidate(); } /** From 838bc3f7d6f0bdbf23520232e30c288af1320f67 Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Tue, 17 Jan 2017 10:03:20 +0000 Subject: [PATCH 124/164] OE-6353 Fix to requiredIfSide to cope with legal value 0 for refraction axis, and illegal value array() for incomplete dilation element. --- protected/models/BaseEventTypeElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/models/BaseEventTypeElement.php b/protected/models/BaseEventTypeElement.php index bee1f802cc..afe1541227 100644 --- a/protected/models/BaseEventTypeElement.php +++ b/protected/models/BaseEventTypeElement.php @@ -354,7 +354,7 @@ public function getFrontEndErrors() public function requiredIfSide($attribute, $params) { if (($params['side'] === 'left' && $this->eye_id != 2) || ($params['side'] === 'right' && $this->eye_id != 1)) { - if ($this->$attribute === null) { + if ($this->$attribute !== 0 && $this->$attribute == null) { if (!@$params['message']) { $params['message'] = ucfirst($params['side']).' {attribute} cannot be blank.'; } From a6fa2742ee6b2aa47c0ebf083299f322054521ca Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 18 Jan 2017 10:38:41 +0000 Subject: [PATCH 125/164] OE-6198 Adds in duplication of Alpha Receptor Blocker to cover both eyes. Deals with issue of adding a previously removed Eye side, and forcing of Diabetes and Alpha Receptor Blocker choice to that set on other side. Inclusion of code that will remove the No or Not Known options if the patient had already had a diagnosis of Diabetes, only Yes is available on both eyes. --- .../form_Element_OphCiExamination_PcrRisk.php | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php index c5127fc23d..efbda4a712 100644 --- a/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php +++ b/protected/modules/OphCiExamination/views/default/form_Element_OphCiExamination_PcrRisk.php @@ -28,10 +28,27 @@ $("select#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_right_diabetic").prop('selectedIndex', $pcrDiabeticLeft); }); + $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_right_alpha_receptor_blocker").change(function () { + var $pcrAlphaRight = $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_right_alpha_receptor_blocker").prop('selectedIndex'); + $("select#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_left_alpha_receptor_blocker").prop('selectedIndex', $pcrAlphaRight); + }); + + $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_left_alpha_receptor_blocker").change(function () { + var $pcrAlphaLeft = $("#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_left_alpha_receptor_blocker").prop('selectedIndex'); + $("select#OEModule_OphCiExamination_models_Element_OphCiExamination_PcrRisk_right_alpha_receptor_blocker").prop('selectedIndex', $pcrAlphaLeft); + }); + });
patient->getDiabetes()) { + $diabeticOptions = array('Y' => 'Diabetes present'); +}else{ + $diabeticOptions = array('NK' => 'Not Known', 'N' => 'No Diabetes', 'Y' => 'Diabetes present'); +} + + $criteria = new CDbCriteria(); $criteria->condition = 'has_pcr_risk'; $grades = \DoctorGrade::model()->findAll($criteria, array('order' => 'display_order')); @@ -45,7 +62,7 @@ 'class' => 'pcrrisk_pxf_phako', ), 'diabetic' => array( - 'options' => array('NK' => 'Not Known', 'N' => 'No Diabetes', 'Y' => 'Diabetes present'), + 'options' => $diabeticOptions, 'class' => 'pcrrisk_diabetic', ), 'pupil_size' => array( @@ -124,6 +141,16 @@ class="pcr_doctor_grade"
{'left_diabetic'} == 'Y' OR $element->{'left_diabetic'} == 'N'){ + $element->{'right_diabetic'} = $element->{'left_diabetic'}; + }elseif($element->{'right_diabetic'} == 'Y' OR $element->{'right_diabetic'} == 'N'){ + $element->{'left_diabetic'} = $element->{'right_diabetic'}; + } + if($element->{'left_alpha_receptor_blocker'} == 'Y' OR $element->{'left_alpha_receptor_blocker'} == 'N'){ + $element->{'right_alpha_receptor_blocker'} = $element->{'left_alpha_receptor_blocker'}; + }elseif($element->{'right_alpha_receptor_blocker'} == 'Y' OR $element->{'right_alpha_receptor_blocker'} == 'N'){ + $element->{'left_alpha_receptor_blocker'} = $element->{'right_alpha_receptor_blocker'}; + } echo $form->dropDownList( $element, $side.'_'.$key, From bd18b60bd3c7ef159054cbc72149e4598186af56 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 18 Jan 2017 11:12:13 +0000 Subject: [PATCH 126/164] OE-6248 Removal of direct_line as a mandatory item. --- .../modules/OphCoCorrespondence/models/FirmSiteSecretary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphCoCorrespondence/models/FirmSiteSecretary.php b/protected/modules/OphCoCorrespondence/models/FirmSiteSecretary.php index 5fa3994c22..c53baf7146 100644 --- a/protected/modules/OphCoCorrespondence/models/FirmSiteSecretary.php +++ b/protected/modules/OphCoCorrespondence/models/FirmSiteSecretary.php @@ -57,7 +57,7 @@ public function rules() // will receive user inputs. return array( array('firm_id, site_id, direct_line, fax', 'safe'), - array('firm_id, site_id, direct_line', 'required'), + array('firm_id, site_id', 'required'), array('firm_id', 'ext.validators.UniqueSiteFirmValidator', 'message' => 'Only one contact can be added for each firm and site'), // The following rule is used by search(). // Please remove those attributes that should not be searched. From 8cb4682d3cdfd5f8cf71313ff419ae8b20e634f0 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 18 Jan 2017 14:07:16 +0000 Subject: [PATCH 127/164] OE-6248 Removal of direct_line as a mandatory item. --- protected/views/admin/commissioning_body_services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/views/admin/commissioning_body_services.php b/protected/views/admin/commissioning_body_services.php index 5bf229cd87..33fced8d5c 100644 --- a/protected/views/admin/commissioning_body_services.php +++ b/protected/views/admin/commissioning_body_services.php @@ -49,7 +49,7 @@ with = array('commissioning_body'); - $criteria->order = 't.name asc'; + $criteria->order = 'LOWER(t.name) asc'; if (isset($commissioning_bt)) { $criteria->addColumnCondition(array('commissioning_body.commissioning_body_type_id' => $commissioning_bt->id)); From 134bd30c8a9dd75691a9b8da83b72b4c6a7c2291 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 18 Jan 2017 14:48:17 +0000 Subject: [PATCH 128/164] OE-6356 Change to show Description for those Allergies listed as Other on Whiteboard. --- .../OphTrOperationbooking_Whiteboard.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php index b13a99bb20..2a4a2c7f12 100644 --- a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php +++ b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php @@ -144,16 +144,35 @@ protected function recentBiometry($patient) protected function allergyString($episode) { $allergies = Yii::app()->db->createCommand() - ->select('a.name as name') + ->select('a.name as name, pas.other as other') ->from('patient_allergy_assignment pas') ->leftJoin('allergy a', 'pas.allergy_id = a.id') - ->where("pas.patient_id = {$episode->patient_id}") + ->where("a.name != 'Other' AND pas.patient_id = {$episode->patient_id}") ->order('a.name') ->queryAll(); + $allergiesOther = Yii::app()->db->createCommand() + ->select('a.name as name, pas.other as other') + ->from('patient_allergy_assignment pas') + ->leftJoin('allergy a', 'pas.allergy_id = a.id') + ->where("a.name = 'Other' AND pas.patient_id = {$episode->patient_id}") + ->order('a.name') + ->queryAll(); + + $allergyString = 'None'; - if ($allergies) { + if ($allergies || $allergiesOther) { $allergyString = implode(',', array_column($allergies, 'name')); + $allergyOtherString = implode(',', array_column($allergiesOther, 'other')); + + if ($allergyOtherString && $allergyString){ + $allergyString = $allergyString . "," . $allergyOtherString; + } + + if ($allergyOtherString && !$allergyString){ + $allergyString = $allergyOtherString; + } + return $allergyString; } From fa66f0c580014658b44ac153729e6e0fdf392cec Mon Sep 17 00:00:00 2001 From: Mike Pargeter Date: Wed, 18 Jan 2017 15:08:10 +0000 Subject: [PATCH 129/164] OE-6356 Added spaces when concatenating allergies. --- .../models/OphTrOperationbooking_Whiteboard.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php index 2a4a2c7f12..6c5278497a 100644 --- a/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php +++ b/protected/modules/OphTrOperationbooking/models/OphTrOperationbooking_Whiteboard.php @@ -88,7 +88,7 @@ public function loadData($id) $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->procedure = implode(', ', array_column($operation, 'term')); $this->allergies = $allergyString; $this->iol_model = ($biometry) ? $biometry->attributes['lens_description_' . $eyeLabel] . '
' . $biometry->attributes['formula_' . $eyeLabel] : 'Unknown'; $this->iol_power = ($biometry) ? $biometry->attributes['iol_power_' . $eyeLabel] : 'None'; @@ -162,11 +162,11 @@ protected function allergyString($episode) $allergyString = 'None'; if ($allergies || $allergiesOther) { - $allergyString = implode(',', array_column($allergies, 'name')); - $allergyOtherString = implode(',', array_column($allergiesOther, 'other')); + $allergyString = implode(', ', array_column($allergies, 'name')); + $allergyOtherString = implode(', ', array_column($allergiesOther, 'other')); if ($allergyOtherString && $allergyString){ - $allergyString = $allergyString . "," . $allergyOtherString; + $allergyString = $allergyString . ", " . $allergyOtherString; } if ($allergyOtherString && !$allergyString){ From 94171e4dd70b2d45ca3e95a536c9dc9a0232470f Mon Sep 17 00:00:00 2001 From: Sabi Date: Wed, 18 Jan 2017 16:17:47 +0000 Subject: [PATCH 130/164] OE-6343 : Show partially booked procedures in operation note when theatre diary is not used - Rename param "disable_theatre_diary", introduced transaction when scheduling op, removed, setFlash from API, displaying message in Theatre Diary --- protected/config/core/common.php | 6 +- .../components/OphTrOperationbooking_API.php | 69 ++++++++++++------- .../controllers/TheatreDiaryController.php | 10 +++ .../views/theatreDiary/index.php | 8 ++- .../controllers/DefaultController.php | 16 +++-- .../views/default/select_event.php | 4 +- 6 files changed, 76 insertions(+), 37 deletions(-) diff --git a/protected/config/core/common.php b/protected/config/core/common.php index 2c51c5717b..ddc0769b6a 100644 --- a/protected/config/core/common.php +++ b/protected/config/core/common.php @@ -419,6 +419,10 @@ 'saveprint' => 'Save and print' ) ), - "disable_theatre_diary" => false, + + /** + * Operation bookings will be automatically scheduled to the next available slot (regardless of the firm) + */ + "auto_schedule_operation" => false, ), ); diff --git a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php index a7f030f22f..ee1b7f05bf 100644 --- a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php +++ b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php @@ -430,15 +430,25 @@ public function getAllBookingsWithoutOperationNotes(\Patient $patient) return implode(', ', $not_booked_events); } + /** + * Automatically scheduleds all the un-scheduled op bookings in the episode + * @param \Episode $episode + * @return type + */ public function autoScheduleOperationBookings(\Episode $episode) { + $errors = array(); $criteria = new CDbCriteria(); $criteria->order = 't.created_date asc'; $criteria->condition = 't.status_id = 1'; $criteria->compare('episode_id', $episode->id); - $operations = Element_OphTrOperationbooking_Operation::model()->with('event')->findAll($criteria); + $operations = Element_OphTrOperationbooking_Operation::model()->with(array( + 'event' => array( + 'condition'=>'event.deleted=0', + ) + ))->findAll($criteria); $op_status_scheduled = OphTrOperationbooking_Operation_Status::model()->find('name=?', array('Scheduled')); $ep_status_listed = EpisodeStatus::model()->find('name=?', array('Listed/booked')); @@ -447,15 +457,16 @@ public function autoScheduleOperationBookings(\Episode $episode) // get the first bookable session regardless of the firm $session = $this->getFirstBookableSession($operation); + //we need to pass to schedule the op $schedule_options = Element_OphTrOperationbooking_ScheduleOperation::model()->find('event_id = ?', array($operation->event->id)); if($session){ - $errors = null; - + $transaction = Yii::app()->db->beginTransaction(); + try { $ward = OphTrOperationbooking_Operation_Ward::model()->find('site_id = ?', array($operation->site->id)); - $booking = new OphTrOperationbooking_Operation_Booking(); + $booking = new OphTrOperationbooking_Operation_Booking('insert'); $booking->ward_id = $ward->id; $booking->element_id = $operation->id; $booking->session_id = $session->id; @@ -465,42 +476,48 @@ public function autoScheduleOperationBookings(\Episode $episode) $booking->admission_time = $session->start_time; $booking->session_end_time = $session->end_time; $booking->cancellation_comment = ''; - - $booking->save(); + //$booking will be saved in $operation->schedule() $result = $operation->schedule($booking, '', '', '', false, null, $schedule_options); if ($result !== true) { - $errors = $result; - Yii::app()->user->setFlash('error.alert', $errors); + $errors[$operation->id] = $result; } else { + $operation->status_id = $op_status_scheduled->id; + $operation->save(); + + $episode->episode_status_id = $ep_status_listed->id; + $episode->save(); + + $operation->event->deleteIssues(); + + $transaction->commit(); } - + } catch (RaceConditionException $e) { - Yii::app()->user->setFlash('error.alert', $e->getMessage()); + $errors[$operation->id] = $e->getMessage(); + $transaction->rollback(); } catch (Exception $e) { - // no handling of this at the moment - throw $e; - } - - if(!$errors){ - $operation->status_id = $op_status_scheduled->id; - $operation->save(); - - $episode->episode_status_id = $ep_status_listed->id; - $episode->save(); - - $operation->event->deleteIssues(); + $errors[$operation->id] = $e->getMessage(); + $transaction->rollback(); } + } else { - Yii::app()->user->setFlash('error.no-sessions', 'Operation notes cannot be created for un-scheduled Operations. Please add free sessions.'); + $errors[$operation->id] = 'Operation notes cannot be created for un-scheduled Operations. Please add free sessions.'; + } + + if( isset($errors[$operation->id]) ){ + $evevnt_date = new DateTime($operation->event->event_date); + $errors[$operation->id] .= ' (' . $evevnt_date->format("d M Y") .': '. $operation->getProceduresCommaSeparated() . ')'; } } - + + return $errors ? $errors : true; + } public function getFirstBookableSession(\Element_OphTrOperationbooking_Operation $operation) - { + { $criteria = new CDbCriteria(); $criteria->compare('available', 1); $criteria->addCondition("date >= '" . date("Y-m-d") . "'" ); @@ -518,7 +535,7 @@ public function getFirstBookableSession(\Element_OphTrOperationbooking_Operation $is_bookable = $session->operationBookable($operation); if ($is_bookable && ($session->availableMinutes >= $operation->total_duration)) { - return $session; + return $session; } } diff --git a/protected/modules/OphTrOperationbooking/controllers/TheatreDiaryController.php b/protected/modules/OphTrOperationbooking/controllers/TheatreDiaryController.php index 5e21326b3a..cecc88afd6 100644 --- a/protected/modules/OphTrOperationbooking/controllers/TheatreDiaryController.php +++ b/protected/modules/OphTrOperationbooking/controllers/TheatreDiaryController.php @@ -38,6 +38,16 @@ public function accessRules() ), ); } + + protected function beforeAction($action) + { + $is_auto_schedule_operation = isset(Yii::app()->params['auto_schedule_operation']) && Yii::app()->params['auto_schedule_operation'] === true; + + if($is_auto_schedule_operation){ + Yii::app()->user->setFlash('warning.alert', 'Operation bookings are automatically scheduled to the next available slot, regardless of the firms.'); + } + return parent::beforeAction($action); + } /** * @return array diff --git a/protected/modules/OphTrOperationbooking/views/theatreDiary/index.php b/protected/modules/OphTrOperationbooking/views/theatreDiary/index.php index a9a22b1e3f..26c3ddb244 100644 --- a/protected/modules/OphTrOperationbooking/views/theatreDiary/index.php +++ b/protected/modules/OphTrOperationbooking/views/theatreDiary/index.php @@ -18,11 +18,15 @@ */ ?>

Theatre Diaries

- +
+
+ renderPartial('//base/_messages'); ?> +
+
- +
Use the filters below to view Theatre schedules: diff --git a/protected/modules/OphTrOperationnote/controllers/DefaultController.php b/protected/modules/OphTrOperationnote/controllers/DefaultController.php index 6dfbd8f75f..beb3e51dc4 100644 --- a/protected/modules/OphTrOperationnote/controllers/DefaultController.php +++ b/protected/modules/OphTrOperationnote/controllers/DefaultController.php @@ -210,13 +210,17 @@ protected function initActionCreate() $this->unbooked = true; } - $is_theatre_diary_disabled = Yii::app()->params['disable_theatre_diary']; - // if Theatre diary is disabled we schedule the Op to the first available slot + $is_auto_schedule_operation = Yii::app()->params['auto_schedule_operation']; - if ($api && $is_theatre_diary_disabled) { - $api->autoScheduleOperationBookings($this->current_episode); + if ($api && $is_auto_schedule_operation) { + $schedule_result = $api->autoScheduleOperationBookings($this->current_episode); + if( $schedule_result !== true ){ + foreach($schedule_result as $error){ + Yii::app()->user->setFlash('error.alert', $error); + } + + } } - $this->initEdit(); } @@ -283,7 +287,7 @@ public function actionCreate() $this->render('select_event', array( 'errors' => $errors, 'bookings' => $bookings, - 'is_theatre_diary_disabled' => Yii::app()->params['disable_theatre_diary'] + 'is_auto_schedule_operation' => Yii::app()->params['auto_schedule_operation'] )); } } diff --git a/protected/modules/OphTrOperationnote/views/default/select_event.php b/protected/modules/OphTrOperationnote/views/default/select_event.php index 94c009e1a4..bc5ea54346 100644 --- a/protected/modules/OphTrOperationnote/views/default/select_event.php +++ b/protected/modules/OphTrOperationnote/views/default/select_event.php @@ -65,7 +65,7 @@ op - + operation->booking->session->NHSDate('date')?> @@ -73,7 +73,7 @@ Operation - + operation->comments; ?> From 59e25dca328af3d77e95ca9279d8911961b2cda1 Mon Sep 17 00:00:00 2001 From: Sabi Date: Wed, 18 Jan 2017 16:35:13 +0000 Subject: [PATCH 131/164] OE-6343 : Show partially booked procedures in operation note when theatre diary is not used - error thrown when site had no ward --- .../components/OphTrOperationbooking_API.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php index ee1b7f05bf..7b22c06e11 100644 --- a/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php +++ b/protected/modules/OphTrOperationbooking/components/OphTrOperationbooking_API.php @@ -466,6 +466,11 @@ public function autoScheduleOperationBookings(\Episode $episode) try { $ward = OphTrOperationbooking_Operation_Ward::model()->find('site_id = ?', array($operation->site->id)); + if(!$ward){ + //as this feature is used when the client/hospital doesn't use the + //scheduling, most likely it will have a dummy ward set up for only one site + $ward = OphTrOperationbooking_Operation_Ward::model()->find(); + } $booking = new OphTrOperationbooking_Operation_Booking('insert'); $booking->ward_id = $ward->id; $booking->element_id = $operation->id; From fa83c48d9bea4902a61b9f75d801cc09aa12b008 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 19 Jan 2017 16:08:30 +0000 Subject: [PATCH 132/164] OE-6316 Multiple changes to eCVI --- .../views/default/form_Element_OphCoCvi_ConsentSignature.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php b/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php index 9bbb24d80b..2abf76a35d 100644 --- a/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php +++ b/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php @@ -22,10 +22,11 @@ array('style' => 'width: 110px;')) ?>
- +
- radioBoolean($element, 'is_patient', array('nowrapper' => true)) ?> + checkBox($element, 'is_patient', array('nowrapper' => true)) ?> + radioBoolean($element, 'is_patient', array('nowrapper' => true)) ?>
From fd202b38fc58b2afa33770288f599a2d7672e447 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Fri, 20 Jan 2017 10:56:47 +0000 Subject: [PATCH 133/164] OE-6316 Multiple changes to eCVI --- .../models/Element_OphCoCvi_ConsentSignature.php | 2 +- .../form_Element_OphCoCvi_ConsentSignature.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/protected/modules/OphCoCvi/models/Element_OphCoCvi_ConsentSignature.php b/protected/modules/OphCoCvi/models/Element_OphCoCvi_ConsentSignature.php index 38520029d2..776fab6d57 100644 --- a/protected/modules/OphCoCvi/models/Element_OphCoCvi_ConsentSignature.php +++ b/protected/modules/OphCoCvi/models/Element_OphCoCvi_ConsentSignature.php @@ -102,7 +102,7 @@ public function attributeLabels() return array( 'id' => 'ID', 'event_id' => 'Event', - 'is_patient' => 'Is patient', + 'is_patient' => 'Patient', 'signature_date' => 'Signature date', 'representative_name' => 'Representative name', 'signature_file_id' => 'Signature File', diff --git a/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php b/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php index 2abf76a35d..ab30377296 100644 --- a/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php +++ b/protected/modules/OphCoCvi/views/default/form_Element_OphCoCvi_ConsentSignature.php @@ -22,14 +22,20 @@ array('style' => 'width: 110px;')) ?>
- +
- checkBox($element, 'is_patient', array('nowrapper' => true)) ?> - radioBoolean($element, 'is_patient', array('nowrapper' => true)) ?> + radioButtons($element, 'is_patient', array( + 1 => 'Patient', + 0 => "Patient's Representative", + ), + $element->is_patient, + false, false, false, false, + array('nowrapper' => true) + ); ?> + radioBoolean($element, 'is_patient', array('nowrapper' => true)) ?>
- textField($element, 'representative_name', array('hide' => $element->is_patient), null, array('field' => 4)) ?>
From 68f1ad601c0b37219f16649d5ffa6239ef0473ab Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Fri, 20 Jan 2017 13:29:11 +0000 Subject: [PATCH 134/164] OE-6316 Multiple changes to eCVI --- ...0119_125608_add_new_preferred_info_fmt.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 protected/migrations/m170119_125608_add_new_preferred_info_fmt.php diff --git a/protected/migrations/m170119_125608_add_new_preferred_info_fmt.php b/protected/migrations/m170119_125608_add_new_preferred_info_fmt.php new file mode 100644 index 0000000000..71318bd240 --- /dev/null +++ b/protected/migrations/m170119_125608_add_new_preferred_info_fmt.php @@ -0,0 +1,34 @@ +insert('ophcocvi_clericinfo_preferred_info_fmt', array( + 'name' => 'No Preference', + 'require_email' => '0', + 'active' => '1', + 'display_order' => '5', + 'code' => 'NOPREF', + 'last_modified_user_id' => '1', + 'created_user_id' => '1', + 'deleted' => '0', + )); + } + + public function down() + { + $this->delete('ophcocvi_clericinfo_preferred_info_fmt', '`name`="No Preference"'); + } + + /* + // Use safeUp/safeDown to do migration with transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} \ No newline at end of file From f6ff163e0b1c48e6675e33f2c6f278fc7bb1d048 Mon Sep 17 00:00:00 2001 From: Sabi Date: Mon, 23 Jan 2017 17:18:04 +0000 Subject: [PATCH 135/164] feature/OE-6330 - removing .change() event from macro_id element, moving select resizing logic to module.js --- .../OphCoCorrespondence/assets/js/module.js | 10 ++++++ .../views/default/update_ElementLetter.php | 36 ------------------- 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/assets/js/module.js b/protected/modules/OphCoCorrespondence/assets/js/module.js index 684b804917..efa90e8769 100644 --- a/protected/modules/OphCoCorrespondence/assets/js/module.js +++ b/protected/modules/OphCoCorrespondence/assets/js/module.js @@ -22,8 +22,18 @@ function updateCorrespondence(macro_id) { var nickname = $('input[id="ElementLetter_use_nickname"][type="checkbox"]').is(':checked') ? '1' : '0'; var obj = $(this); + var $option_obj; + var option_width; + var arrowWidth = 30; if ( macro_id != '') { + + $option_obj = $("").html($('#macro_id option:selected').text()); + $option_obj.appendTo('body'); + option_width = $option_obj.width(); + $option_obj.remove(); + + $('#macro_id').width(option_width + arrowWidth); $.ajax({ 'type': 'GET', diff --git a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php index 0343fbfc18..b80975379b 100644 --- a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php @@ -71,42 +71,6 @@ letter_macros, array('empty' => '- Macro -', 'nowrapper' => true, 'class' => 'full-width resizeselect')); ?>
- - -
From bc40b079a6395ba73d08a6dac5f451cd20f705b9 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 24 Jan 2017 11:02:20 +0000 Subject: [PATCH 136/164] OE-6355 New Shortcodes for Correspondence --- .../components/OphCoCorrespondence_API.php | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php index 42fb235d61..89829ea7ec 100644 --- a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php +++ b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php @@ -53,6 +53,138 @@ public function getLatestEvent($episode) } } + /** + * get the full name of the patient for use in correspondence. + * + * @param Patient $patient + * + * @return string + */ + public function getFullName($patient) + { + $fullname = trim(implode(' ', array($patient->title, $patient->first_name, $patient->last_name))); + return $fullname; + } + + /** + * get the patient title for use in correspondence. + * + * @param Patient $patient + * + * @return string + */ + public function getPatientTitle($patient) + { + return $patient->title; + } + + /** + * get the patient first name for use in correspondence. + * + * @param Patient $patient + * + * @return string + */ + public function getFirstName($patient) + { + return $patient->first_name; + } + + + /** + * get the patient last name for use in correspondence. + * + * @param Patient $patient + * + * @return string + */ + public function getLastName($patient) + { + return $patient->last_name; + } + + + /** + * get the last Examination Date for patient for use in correspondence. + * + * @param Patient $patient + * + * @return string + */ + public function getLastExaminationDate(\Patient $patient) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + $event_type = EventType::model()->find('class_name=?', array('OphCiExamination')); + $event = $this->getMostRecentEventInEpisode($episode->id, $event_type->id); + if (isset($event->event_date)) { + return Helper::convertDate2NHS($event->event_date); + } + } + + return ''; + } + + + public function getOphthalmicDiagnoses(\Patient $patient) + { + $allDiagnoses =''; + foreach ($patient->ophthalmicDiagnoses as $diagnosis) { + return $diagnosis->eye->adjective . ' ' . $diagnosis->disorder->term; + } + } + + public function getLastIOLType(\Patient $patient) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); + $element = $this->getMostRecentElementInEpisode($episode->id, $event_type->id, 'Element_OphTrOperationnote_Cataract'); + return CHtml::encode($element->iol_type->name); + } + } + + public function getLastIOLPower(\Patient $patient) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); + $element = $this->getMostRecentElementInEpisode($episode->id, $event_type->id, 'Element_OphTrOperationnote_Cataract'); + return CHtml::encode($element->iol_power); + } + } + + public function getLastOperatedEye(\Patient $patient) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); + $element = $this->getMostRecentElementInEpisode($episode->id, $event_type->id, + 'Element_OphTrOperationnote_ProcedureList'); + return $element->eye->adjective; + } + } + + /** + * Get the Pre-Op Visual Acuity - both eyes. + * + * @param $patient + * + * @return string|null + */ + public function getPreOpVABothEyes($patient) + { + if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) { + return $api->getAllVisualAcuityLeft($patient); +// if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { +// $side = 'left'; + // if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) { +// if ($va = $api->getBestVisualAcuity($patient, $episode, $side)) { +// var_dump($va); +// return $va->value . " Left"; +// } +// } +// } + } + } + + public function getMacroTargets($patient_id, $macro_id) { if (!$patient = Patient::model()->findByPk($patient_id)) { From 3b169ecb22d69e14004b0fc94f82649b78d6941a Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 24 Jan 2017 11:07:47 +0000 Subject: [PATCH 137/164] OE-6198 Move of Migration file --- .../migrations/m170113_133457_move_PCR_order.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename protected/{ => modules/OphCiExamination}/migrations/m170113_133457_move_PCR_order.php (100%) diff --git a/protected/migrations/m170113_133457_move_PCR_order.php b/protected/modules/OphCiExamination/migrations/m170113_133457_move_PCR_order.php similarity index 100% rename from protected/migrations/m170113_133457_move_PCR_order.php rename to protected/modules/OphCiExamination/migrations/m170113_133457_move_PCR_order.php From 8c0e202ebc2bca92887028ff2b5caf49f63c2af1 Mon Sep 17 00:00:00 2001 From: Sabi Date: Tue, 24 Jan 2017 11:29:36 +0000 Subject: [PATCH 138/164] FIX : creating correspondence for pation with no address gave Undefined offset notice --- protected/modules/OphCoCorrespondence/models/ElementLetter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphCoCorrespondence/models/ElementLetter.php b/protected/modules/OphCoCorrespondence/models/ElementLetter.php index 60e41b1873..8cf31408fd 100644 --- a/protected/modules/OphCoCorrespondence/models/ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/models/ElementLetter.php @@ -216,7 +216,7 @@ public function getAddress_targets() $options = array('Patient'.$patient->id => $patient->fullname.' (Patient)'); if (!isset($patient->contact->address)) { - $options[$patient->contact->id] .= ' - NO ADDRESS'; + $options['Patient'.$patient->id] .= ' - NO ADDRESS'; } if ($patient->gp) { From 7c792db07a1903862fda283e189c14c87cfeb695 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 25 Jan 2017 14:06:35 +0000 Subject: [PATCH 139/164] OE-6355 Additional Shortcodes - function --- .../m170124_151953_update_shortcodes.php | 33 +++++ ...3056_add_new_correspondence_shortcodes.php | 133 ++++++++++++++++++ .../components/OphCiExamination_API.php | 16 +++ .../components/OphCoCorrespondence_API.php | 85 +++++++++-- .../components/OphTrOperationnote_API.php | 21 +++ 5 files changed, 277 insertions(+), 11 deletions(-) create mode 100644 protected/migrations/m170124_151953_update_shortcodes.php create mode 100644 protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php diff --git a/protected/migrations/m170124_151953_update_shortcodes.php b/protected/migrations/m170124_151953_update_shortcodes.php new file mode 100644 index 0000000000..517ca95088 --- /dev/null +++ b/protected/migrations/m170124_151953_update_shortcodes.php @@ -0,0 +1,33 @@ +update('patient_shortcode', array('description'=>'Patient as object (him/her)'), 'default_code="obj"'); + $this->update('patient_shortcode', array('description'=>'Patient possessive (his/hers)'), 'default_code="pos"'); + $this->update('patient_shortcode', array('description'=>'Patient as subject (man/woman)'), 'default_code="sub"'); + $this->update('patient_shortcode', array('description'=>'Patient pronoun (he/she)'), 'default_code="pro"'); + $this->update('patient_shortcode', array('description'=>'Patient Unique Code for portal'), 'default_code="puc"'); + } + + public function down() + { + $this->update('patient_shortcode', array('description'=>'Patient as object'), 'default_code="obj"'); + $this->update('patient_shortcode', array('description'=>'Patient possessive'), 'default_code="pos"'); + $this->update('patient_shortcode', array('description'=>'Patient as subject'), 'default_code="sub"'); + $this->update('patient_shortcode', array('description'=>'Patient pronoun'), 'default_code="pro"'); + $this->update('patient_shortcode', array('description'=>'Patient Unique Code'), 'default_code="puc"'); + } + + /* + // Use safeUp/safeDown to do migration with transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} \ No newline at end of file diff --git a/protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php b/protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php new file mode 100644 index 0000000000..7cb095222b --- /dev/null +++ b/protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php @@ -0,0 +1,133 @@ +insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'pna', + 'code' => 'pna', + 'method' => 'getFullName', + 'description' => 'Get Full Patient Name', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'pnt', + 'code' => 'pnt', + 'method' => 'getPatientTitle', + 'description' => 'Get Patient Title', + 'last_modified_user_id' => '1', + )); + + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'pnf', + 'code' => 'pnf', + 'method' => 'getFirstName', + 'description' => 'Get Patient First Name', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'pnl', + 'code' => 'pnl', + 'method' => 'getLastName', + 'description' => 'Get Patient Last Name', + 'last_modified_user_id' => '1', + )); + + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'eld', + 'code' => 'eld', + 'method' => 'getLastExaminationDate', + 'description' => 'Get Date of Last Examination Date', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'aod', + 'code' => 'aod', + 'method' => 'getOphthalmicDiagnoses', + 'description' => 'List of Ophthalmic Diagnoses', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'ilt', + 'code' => 'ilt', + 'method' => 'getLastIOLType', + 'description' => 'IOL type from last cataract Operation Note', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'ilp', + 'code' => 'ilp', + 'method' => 'getLastIOLPower', + 'description' => 'IOL Power from last cataract operation note', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'loe', + 'code' => 'loe', + 'method' => 'getLastOperatedEye', + 'description' => 'Operated Eye (left/right) from last operation note', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'pov', + 'code' => 'pov', + 'method' => 'getPreOpVABothEyes', + 'description' => 'Pre-Op Visual Acuity - both eyes', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'por', + 'code' => 'por', + 'method' => 'getPreOpRefraction', + 'description' => 'Pre-Op Refraction - both eyes', + 'last_modified_user_id' => '1', + )); + $this->insert('patient_shortcode', array( + 'event_type_id' => '26', + 'default_code' => 'alg', + 'code' => 'alg', + 'method' => 'getAllergiesBulleted', + 'description' => 'List all patients assigned allergies', + 'last_modified_user_id' => '1', + )); + } + + public function down() + { + $this->delete('patient_shortcode', '`default_code`="pna"'); + $this->delete('patient_shortcode', '`default_code`="pnt"'); + $this->delete('patient_shortcode', '`default_code`="pnf"'); + $this->delete('patient_shortcode', '`default_code`="pnl"'); + $this->delete('patient_shortcode', '`default_code`="ilp"'); + $this->delete('patient_shortcode', '`default_code`="ilt"'); + $this->delete('patient_shortcode', '`default_code`="aod"'); + $this->delete('patient_shortcode', '`default_code`="eld"'); + $this->delete('patient_shortcode', '`default_code`="loe"'); + $this->delete('patient_shortcode', '`default_code`="pov"'); + $this->delete('patient_shortcode', '`default_code`="por"'); + $this->delete('patient_shortcode', '`default_code`="alg"'); + } + + /* + // Use safeUp/safeDown to do migration with transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} \ No newline at end of file diff --git a/protected/modules/OphCiExamination/components/OphCiExamination_API.php b/protected/modules/OphCiExamination/components/OphCiExamination_API.php index 36bfd8caab..eb34a6b6b1 100644 --- a/protected/modules/OphCiExamination/components/OphCiExamination_API.php +++ b/protected/modules/OphCiExamination/components/OphCiExamination_API.php @@ -521,6 +521,22 @@ public function getAllVisualAcuityRight($patient) } } + public function getAllVisualAcuityLeftByDate($patient, $opDate) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + return ($best = $this->getBestVisualAcuity($patient, $episode, 'left')) ? $best->convertTo($best->value, + $this->getSnellenUnitId()) : null; + } + } + + public function getAllVisualAcuityRightByDate($patient, $opDate) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + return ($best = $this->getBestVisualAcuity($patient, $episode, 'right')) ? $best->convertTo($best->value, + $this->getSnellenUnitId()) : null; + } + } + public function getUnitName($unitId) { diff --git a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php index 89829ea7ec..bc6077d1bd 100644 --- a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php +++ b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php @@ -170,18 +170,81 @@ public function getLastOperatedEye(\Patient $patient) */ public function getPreOpVABothEyes($patient) { - if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) { - return $api->getAllVisualAcuityLeft($patient); -// if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { -// $side = 'left'; - // if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) { -// if ($va = $api->getBestVisualAcuity($patient, $episode, $side)) { -// var_dump($va); -// return $va->value . " Left"; -// } -// } -// } + if ($apiNote = Yii::app()->moduleAPI->get('OphTrOperationnote')) { + $opDate = $apiNote->getLastOperationDateUnformatted($patient); + } + $api = Yii::app()->moduleAPI->get('OphCiExamination'); + $episode = $patient->getEpisodeForCurrentSubspecialty(); + $event_type = EventType::model()->find('class_name=?', array('OphCiExamination')); + + $criteria = new CDbCriteria(); + $criteria->condition = 'episode_id = :e_id AND event_type_id = :et_id'; + $criteria->addCondition('event_date <= :event_date'); + $criteria->order = ' event_date DESC, created_date DESC'; + $criteria->params = array(':e_id' => $episode->id, ':et_id' => $event_type->id, 'event_date' => $opDate); + + $event = Event::model()->find($criteria); + $rightVA = $api->getAllVisualAcuityRightByDate($patient, $opDate); + $leftVA = $api->getAllVisualAcuityLeftByDate($patient, $opDate); + + + return $rightVA . " Right Eye" . " " . $leftVA . " Left Eye"; + } + + /** + * Get the Pre-Op Refraction - both eyes. + * + * @param $patient + * + * @return string|null + */ + public function getPreOpRefraction($patient) + { + if ($apiNote = Yii::app()->moduleAPI->get('OphTrOperationnote')) { + $opDate = $apiNote->getLastOperationDateUnformatted($patient); + } + $api = Yii::app()->moduleAPI->get('OphCiExamination'); + $episode = $patient->getEpisodeForCurrentSubspecialty(); + $event_type = EventType::model()->find('class_name=?', array('OphCiExamination')); + $eventtypeid = $event_type->id; +// Refraction here + $refractfound = false; + + if ($eventid = Event::model()->findAll(array( + 'condition' => 'event_type_id = ' . $eventtypeid . ' AND episode_id = ' . $episode->id, + 'order' => 'event_date DESC', + )) + ) { +// Loop through responses, for ones that have RefractionValues + for ($i = 0; $i < count($eventid); ++$i) { + if ($api->getRefractionValues($eventid[$i]->id)) { + if (!$refractfound) { + $refractelement = $api->getRefractionValues($eventid[$i]->id); + $refract_event_date = $eventid[$i]->event_date; + $refractfound = true; + $rightspherical = number_format($refractelement->{'right_sphere'} + 0.5 * $refractelement->{'right_cylinder'}, 2); + $leftspherical = number_format($refractelement->{'left_sphere'} + 0.5 * $refractelement->{'left_cylinder'}, 2); + return $rightspherical . " Right Eye" . ", " . $leftspherical . " Left Eye"; + } + } + } + } + } + + /** + * Get Allergies in a bullet format. + * + * @param $patient + * + * @return string|null + */ + public function getAllergiesBulleted($patient) + { + $multiAllergies = ''; + foreach ($patient->allergyAssignments as $aa) { + $multiAllergies .= " - " . $aa->allergy->name . "\r\n"; } + return $multiAllergies; } diff --git a/protected/modules/OphTrOperationnote/components/OphTrOperationnote_API.php b/protected/modules/OphTrOperationnote/components/OphTrOperationnote_API.php index d63baa5e64..032ac10bf4 100644 --- a/protected/modules/OphTrOperationnote/components/OphTrOperationnote_API.php +++ b/protected/modules/OphTrOperationnote/components/OphTrOperationnote_API.php @@ -145,6 +145,27 @@ public function getLastOperationDate(\Patient $patient) return ''; } + /** + * Get the last operation date + * + * @param Patient $patient + * + * @return false|string + */ + public function getLastOperationDateUnformatted(\Patient $patient) + { + if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { + $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); + $event = $this->getMostRecentEventInEpisode($episode->id, $event_type->id); + if (isset($event->event_date)) { + return $event->event_date; + } + } + + return ''; + } + + /** * Get the last operation's surgeon name From 829c81fe701ab54841c5f11a53d635bd32e06326 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 25 Jan 2017 14:45:06 +0000 Subject: [PATCH 140/164] OE-6355 Additional Shortcodes - function --- .../OphCoCorrespondence/components/OphCoCorrespondence_API.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php index bc6077d1bd..e7eb35d60b 100644 --- a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php +++ b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php @@ -211,7 +211,7 @@ public function getPreOpRefraction($patient) $refractfound = false; if ($eventid = Event::model()->findAll(array( - 'condition' => 'event_type_id = ' . $eventtypeid . ' AND episode_id = ' . $episode->id, + 'condition' => 'event_type_id = ' . $eventtypeid . ' AND episode_id = ' . $episode->id . " AND event_date <= '" . $opDate . "'", 'order' => 'event_date DESC', )) ) { From d08f442fba1a6a3b0179477741e455b1242450f9 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Wed, 25 Jan 2017 16:33:37 +0000 Subject: [PATCH 141/164] OE-6355 Additional Shortcodes - function --- .../components/OphCoCorrespondence_API.php | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php index e7eb35d60b..b1783d1fcd 100644 --- a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php +++ b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php @@ -176,19 +176,39 @@ public function getPreOpVABothEyes($patient) $api = Yii::app()->moduleAPI->get('OphCiExamination'); $episode = $patient->getEpisodeForCurrentSubspecialty(); $event_type = EventType::model()->find('class_name=?', array('OphCiExamination')); - + $data = ''; $criteria = new CDbCriteria(); $criteria->condition = 'episode_id = :e_id AND event_type_id = :et_id'; $criteria->addCondition('event_date <= :event_date'); $criteria->order = ' event_date DESC, created_date DESC'; $criteria->params = array(':e_id' => $episode->id, ':et_id' => $event_type->id, 'event_date' => $opDate); - $event = Event::model()->find($criteria); - $rightVA = $api->getAllVisualAcuityRightByDate($patient, $opDate); - $leftVA = $api->getAllVisualAcuityLeftByDate($patient, $opDate); + if($events = Event::model()->findAll($criteria)){ + for ($i = 0; $i < count($events); ++$i) { + // Get Most Recent VA + $vaID = $api->getMostRecentVA($events[$i]->id); + if($vaID && !$data){ + $data = $api->getMostRecentVAData($vaID->id); + $chosenVA = $vaID; + } + } + } + + for ($i = 0; $i < count($data); ++$i) { + if($data[$i]->side == 0){ + $rightData[] = $data[$i]; + } + if($data[$i]->side == 1){ + $leftData[] = $data[$i]; + } + } + + $unitId = $chosenVA->unit_id; + $rightVA = $api->getVAvalue($rightData[0]->value, $unitId); + $leftVA = $api->getVAvalue($leftData[0]->value, $unitId); - return $rightVA . " Right Eye" . " " . $leftVA . " Left Eye"; + return $rightVA . " Right Eye" . " " . $leftVA . " Left Eye"; } /** From 2d9854ee68c9987762ee768c6c2e19ce7335e943 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 26 Jan 2017 10:03:57 +0000 Subject: [PATCH 142/164] OE-6316 Move of Migration to CVI migrations folder --- .../migrations/m170119_125608_add_new_preferred_info_fmt.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename protected/{ => modules/OphCoCvi}/migrations/m170119_125608_add_new_preferred_info_fmt.php (100%) diff --git a/protected/migrations/m170119_125608_add_new_preferred_info_fmt.php b/protected/modules/OphCoCvi/migrations/m170119_125608_add_new_preferred_info_fmt.php similarity index 100% rename from protected/migrations/m170119_125608_add_new_preferred_info_fmt.php rename to protected/modules/OphCoCvi/migrations/m170119_125608_add_new_preferred_info_fmt.php From 7018e6af33237a9b91af5c8bdca0918049e8cf97 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Fri, 27 Jan 2017 15:25:35 +0000 Subject: [PATCH 143/164] OE-6340 Rename some columns, and add a new one. --- protected/commands/DocManDeliveryCommand.php | 55 ++++++++++++++++++- .../m170126_161056_docmandb_changes.php | 25 +++++++++ protected/models/DocumentLog.php | 2 +- 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 protected/migrations/m170126_161056_docmandb_changes.php diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index b418cad081..e611bd39ca 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -147,13 +147,62 @@ private function savePDFFile($event_id, $output_id) return false; } + $correspondenceDate = $this->event->event_date; + + $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); + $event_type_id = $event_type->id; + + $criteria = new CDbCriteria(); + $criteria->compare('event_type_id', $event_type_id); + $criteria->compare('episode_id', $this->event->episode->id); + $criteria->condition = "created_date <= '$correspondenceDate'"; + $criteria->order = 'event_date desc, created_date desc'; + + $lastOpNoteDate = ''; + if($opNote = Event::model()->find($criteria)){ + $lastOpNoteDate = $opNote->event_date; + } + + $event_type = EventType::model()->find('class_name=?', array('OphCiExamination')); + $event_type_id = $event_type->id; + + $criteria = new CDbCriteria(); + $criteria->compare('event_type_id', $event_type_id); + $criteria->compare('episode_id', $this->event->episode->id); + $criteria->condition = "created_date <= '$correspondenceDate'"; + $criteria->order = 'event_date desc, created_date desc'; + + $lastExamDate = ''; + if($examEvent = Event::model()->find($criteria)){ + $lastExamDate = $examEvent->event_date; + } + + $lastSignificantEventDate = ''; + if(!$lastExamDate && $lastOpNoteDate) { + $lastSignificantEventDate = $lastOpNoteDate; + } + if($lastExamDate && !$lastOpNoteDate) { + $lastSignificantEventDate = $lastExamDate; + } + if(!$lastSignificantEventDate && $lastExamDate && $lastOpNoteDate){ + $diff = date_diff(date_create($lastExamDate), date_create($lastOpNoteDate)); + if($diff->days >= 0){ + $lastSignificantEventDate = $lastOpNoteDate; + }else{ + $lastSignificantEventDate = $lastExamDate; + } + } + + // Get Last Significant Event Date most recent examination or OpNote event on or before the correspondence event date + if ($this->updateDelivery($output_id)) { $this->logData(array( 'hos_num' => $this->event->episode->patient->hos_num, 'clinician_name' => $this->event->user->getFullName(), - 'event_updated' => $this->event->last_modified_date, - 'event_date' => $this->event->created_date, - 'output_date' => date('Y-m-d H:i:s'), + 'letter_finalised_date' => $this->event->last_modified_date, + 'letter_created_date' => $this->event->created_date, + 'last_significant_event_date' => $lastSignificantEventDate, + 'letter_sent_date' => date('Y-m-d H:i:s'), )); } diff --git a/protected/migrations/m170126_161056_docmandb_changes.php b/protected/migrations/m170126_161056_docmandb_changes.php new file mode 100644 index 0000000000..6d5b98e79c --- /dev/null +++ b/protected/migrations/m170126_161056_docmandb_changes.php @@ -0,0 +1,25 @@ +renameColumn('document_log', 'event_date', 'letter_created_date' ); + $this->renameColumn('document_log', 'event_updated', 'letter_finalised_date' ); + $this->renameColumn('document_log', 'output_date', 'letter_sent_date' ); + // Add new column + $this->addColumn('document_log', 'last_significant_event_date', 'DATETIME'); + } + + + public function down() + { + $this->renameColumn('document_log', 'letter_created_date', 'event_date' ); + $this->renameColumn('document_log', 'letter_finalised_date', 'event_updated' ); + $this->renameColumn('document_log', 'letter_sent_date', 'output_date' ); + // Add new column + $this->dropColumn('document_log', 'last_significant_event_date'); + } + +} \ No newline at end of file diff --git a/protected/models/DocumentLog.php b/protected/models/DocumentLog.php index c95cebe39b..f421b958f7 100644 --- a/protected/models/DocumentLog.php +++ b/protected/models/DocumentLog.php @@ -56,7 +56,7 @@ public function rules() return array( // The following rule is used by search(). // Please remove those attributes that should not be searched. - array('id, hos_num, clinician_name, event_updated, event_date, output_date', 'safe'), + array('id, hos_num, clinician_name, letter_finalised_date, letter_created_date, letter_sent_date, last_significant_event_date', 'safe'), ); } From faf1930d99bfa37b7fa844224ac082c2b04a4e35 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Fri, 27 Jan 2017 16:05:31 +0000 Subject: [PATCH 144/164] OE-6199 Slight styling change. --- .../views/default/form_Element_OphInBiometry_Measurement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php index 4542674409..1d54bb4ba7 100644 --- a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php +++ b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php @@ -334,7 +334,7 @@
hasRight()) { ?> -
+
renderPartial($element->view_view . '_OEEyeDraw', array('side' => 'right', 'element' => $refractelement)); ?> From 3d6d3e0f4aa9359267fa7c6baca70b3d9ef03bb6 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Mon, 30 Jan 2017 11:50:44 +0000 Subject: [PATCH 145/164] OE-6340 Fix to issue when patient has no OpNote or Examination events --- protected/commands/DocManDeliveryCommand.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index e611bd39ca..4459e9d13c 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -153,9 +153,8 @@ private function savePDFFile($event_id, $output_id) $event_type_id = $event_type->id; $criteria = new CDbCriteria(); - $criteria->compare('event_type_id', $event_type_id); - $criteria->compare('episode_id', $this->event->episode->id); - $criteria->condition = "created_date <= '$correspondenceDate'"; + $criteria->condition = "episode_id = '" . $this->event->episode->id + . "' AND created_date <= '$correspondenceDate' AND deleted = 0 AND event_type_id = '$event_type_id'"; $criteria->order = 'event_date desc, created_date desc'; $lastOpNoteDate = ''; @@ -167,9 +166,8 @@ private function savePDFFile($event_id, $output_id) $event_type_id = $event_type->id; $criteria = new CDbCriteria(); - $criteria->compare('event_type_id', $event_type_id); - $criteria->compare('episode_id', $this->event->episode->id); - $criteria->condition = "created_date <= '$correspondenceDate'"; + $criteria->condition = "episode_id = '" . $this->event->episode->id + . "' AND created_date <= '$correspondenceDate' AND deleted = 0 AND event_type_id = '$event_type_id'"; $criteria->order = 'event_date desc, created_date desc'; $lastExamDate = ''; @@ -184,6 +182,9 @@ private function savePDFFile($event_id, $output_id) if($lastExamDate && !$lastOpNoteDate) { $lastSignificantEventDate = $lastExamDate; } + if(!$lastExamDate && !$lastOpNoteDate) { + $lastSignificantEventDate = NULL; + } if(!$lastSignificantEventDate && $lastExamDate && $lastOpNoteDate){ $diff = date_diff(date_create($lastExamDate), date_create($lastOpNoteDate)); if($diff->days >= 0){ @@ -193,8 +194,6 @@ private function savePDFFile($event_id, $output_id) } } - // Get Last Significant Event Date most recent examination or OpNote event on or before the correspondence event date - if ($this->updateDelivery($output_id)) { $this->logData(array( 'hos_num' => $this->event->episode->patient->hos_num, From 3f13bb0dda120ba7645e7da37a0d9268280dae58 Mon Sep 17 00:00:00 2001 From: Sabi Date: Mon, 30 Jan 2017 16:08:12 +0000 Subject: [PATCH 146/164] FIX : Correspondence 'Save' button saved document as Draft --- protected/models/Document.php | 9 ++++----- .../modules/OphCoCorrespondence/assets/js/module.js | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/protected/models/Document.php b/protected/models/Document.php index 40afa97113..018ad20b35 100644 --- a/protected/models/Document.php +++ b/protected/models/Document.php @@ -291,9 +291,11 @@ public function createNewDocSet() if (isset($document_output['id'])) { $data['id'] = $document_output['id']; } - + if( $this->is_draft && $data['output_type'] == 'Docman' ){ $data['output_status'] = "DRAFT"; + } else if($this->is_draft == 0 && $data['output_type'] == 'Docman'){ + $data['output_status'] = "PENDING"; } $this->createNewDocOutput($doc_target, $doc_instance_version, $data); @@ -337,10 +339,7 @@ public function createNewDocOutput($doc_target, $doc_instance_version, $data) $doc_output->document_instance_data_id = $doc_instance_version->id; $doc_output->output_type = $data['output_type']; $doc_output->requestor_id = 'OE'; - if ( isset($_POST['saveprint']) ){ - $doc_output->output_status = "PENDING"; - } - + if( isset($data['output_status']) && $doc_output->output_type != "COMPLETE"){ $doc_output->output_status = $data['output_status']; } diff --git a/protected/modules/OphCoCorrespondence/assets/js/module.js b/protected/modules/OphCoCorrespondence/assets/js/module.js index efa90e8769..461029e077 100644 --- a/protected/modules/OphCoCorrespondence/assets/js/module.js +++ b/protected/modules/OphCoCorrespondence/assets/js/module.js @@ -87,6 +87,10 @@ $(document).ready(function() { handleButton($('#et_saveprint'),function() { $('#ElementLetter_draft').val(0); }); + + handleButton($('#et_save'),function() { + $('#ElementLetter_draft').val(0); + }); handleButton($('#et_cancel'),function() { $('#dialog-confirm-cancel').dialog({ From c63d4e30cc6b72669555584d566d75986f4a265a Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Mon, 30 Jan 2017 17:33:29 +0000 Subject: [PATCH 147/164] OE-6340 Fix to issue when patient has no OpNote or Examination events --- protected/commands/DocManDeliveryCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index 4459e9d13c..ecaf55d1ab 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -154,7 +154,7 @@ private function savePDFFile($event_id, $output_id) $criteria = new CDbCriteria(); $criteria->condition = "episode_id = '" . $this->event->episode->id - . "' AND created_date <= '$correspondenceDate' AND deleted = 0 AND event_type_id = '$event_type_id'"; + . "' AND event_date <= '$correspondenceDate' AND deleted = 0 AND event_type_id = '$event_type_id'"; $criteria->order = 'event_date desc, created_date desc'; $lastOpNoteDate = ''; @@ -167,7 +167,7 @@ private function savePDFFile($event_id, $output_id) $criteria = new CDbCriteria(); $criteria->condition = "episode_id = '" . $this->event->episode->id - . "' AND created_date <= '$correspondenceDate' AND deleted = 0 AND event_type_id = '$event_type_id'"; + . "' AND event_date <= '$correspondenceDate' AND deleted = 0 AND event_type_id = '$event_type_id'"; $criteria->order = 'event_date desc, created_date desc'; $lastExamDate = ''; @@ -185,7 +185,7 @@ private function savePDFFile($event_id, $output_id) if(!$lastExamDate && !$lastOpNoteDate) { $lastSignificantEventDate = NULL; } - if(!$lastSignificantEventDate && $lastExamDate && $lastOpNoteDate){ + if($lastExamDate && $lastOpNoteDate){ $diff = date_diff(date_create($lastExamDate), date_create($lastOpNoteDate)); if($diff->days >= 0){ $lastSignificantEventDate = $lastOpNoteDate; From c1443be4f1ff08c053ff34af47f68fc225968bf3 Mon Sep 17 00:00:00 2001 From: Sabi Date: Mon, 30 Jan 2017 17:37:12 +0000 Subject: [PATCH 148/164] FIX : multiple headers was generated for docman CSV file --- protected/commands/DocManDeliveryCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index 4459e9d13c..2a07b4d407 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -306,9 +306,10 @@ private function logData($data) $doc_log->save(); $csv_filename = implode(DIRECTORY_SEPARATOR, array($this->path, sprintf($this->csv_format, date('Ymd')))); + $put_header = !file_exists($csv_filename); $fp = fopen($csv_filename, 'ab'); - if(!filesize($csv_filename)){ + if($put_header){ fputcsv($fp, array_keys($data)); } fputcsv($fp, $data); From a0b204759020ee5369a70ba52d5b8389a0a6ea47 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Tue, 31 Jan 2017 14:17:07 +0000 Subject: [PATCH 149/164] OE-6355 Change to Migration to use dynamic Event-type-id rather than hard-coded 26. --- ...3056_add_new_correspondence_shortcodes.php | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php b/protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php index 7cb095222b..495b594dda 100644 --- a/protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php +++ b/protected/migrations/m170124_153056_add_new_correspondence_shortcodes.php @@ -4,8 +4,14 @@ class m170124_153056_add_new_correspondence_shortcodes extends CDbMigration { public function up() { + + $data = $this->dbConnection->createCommand() + ->select('id')->from('event_type') + ->where('name = "Correspondence"')->queryAll(); + $event_type_id = $data[0]['id']; + $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'pna', 'code' => 'pna', 'method' => 'getFullName', @@ -13,7 +19,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'pnt', 'code' => 'pnt', 'method' => 'getPatientTitle', @@ -22,7 +28,7 @@ public function up() )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'pnf', 'code' => 'pnf', 'method' => 'getFirstName', @@ -30,7 +36,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'pnl', 'code' => 'pnl', 'method' => 'getLastName', @@ -39,7 +45,7 @@ public function up() )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'eld', 'code' => 'eld', 'method' => 'getLastExaminationDate', @@ -47,7 +53,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'aod', 'code' => 'aod', 'method' => 'getOphthalmicDiagnoses', @@ -55,7 +61,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'ilt', 'code' => 'ilt', 'method' => 'getLastIOLType', @@ -63,7 +69,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'ilp', 'code' => 'ilp', 'method' => 'getLastIOLPower', @@ -71,7 +77,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'loe', 'code' => 'loe', 'method' => 'getLastOperatedEye', @@ -79,7 +85,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'pov', 'code' => 'pov', 'method' => 'getPreOpVABothEyes', @@ -87,7 +93,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'por', 'code' => 'por', 'method' => 'getPreOpRefraction', @@ -95,7 +101,7 @@ public function up() 'last_modified_user_id' => '1', )); $this->insert('patient_shortcode', array( - 'event_type_id' => '26', + 'event_type_id' => $event_type_id, 'default_code' => 'alg', 'code' => 'alg', 'method' => 'getAllergiesBulleted', From 53c479c7daa599312943de320ea9bc96fcda7199 Mon Sep 17 00:00:00 2001 From: neilsf Date: Tue, 31 Jan 2017 22:23:54 +0100 Subject: [PATCH 150/164] OE-6371 Removed Confirm button OE-6371 User is now prompted before unloading the page when in edit mode --- protected/assets/js/dashboard/whiteboard.js | 18 ++++++++++++++++++ .../views/whiteboard/header.php | 6 ------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/protected/assets/js/dashboard/whiteboard.js b/protected/assets/js/dashboard/whiteboard.js index 7ce524c787..3c4854ac81 100644 --- a/protected/assets/js/dashboard/whiteboard.js +++ b/protected/assets/js/dashboard/whiteboard.js @@ -1,4 +1,18 @@ document.addEventListener("DOMContentLoaded", function () { + + var confirm_exit = function(e){ + e = e || window.event; + var message = "You have unsaved changes. Are you sure you want to leave this page?"; + if (e) + { + e.returnValue = message; + } + + return message; + }; + + window.onbeforeunload = null; + OpenEyes.Dialog.init( document.getElementById('dialog-container'), document.getElementById('refresh-button'), @@ -25,6 +39,7 @@ document.addEventListener("DOMContentLoaded", function () { icon.textContent = 'done'; textArea[0].value = $cardContent.get(0).textContent.trim(); $cardContent.html(textArea); + window.onbeforeunload = confirm_exit; } else { contentId = $cardContent.get(0).id; text = $cardContent.find('textarea').val(); @@ -37,6 +52,7 @@ document.addEventListener("DOMContentLoaded", function () { 'success': function () { $cardContent.text(text); icon.textContent = 'create'; + window.onbeforeunload = null; }, 'error': function () { alert('Something went wrong, please try again.'); @@ -44,4 +60,6 @@ document.addEventListener("DOMContentLoaded", function () { }); } }); + + }); \ No newline at end of file diff --git a/protected/modules/OphTrOperationbooking/views/whiteboard/header.php b/protected/modules/OphTrOperationbooking/views/whiteboard/header.php index d51f66d9ba..c1aabef3d4 100644 --- a/protected/modules/OphTrOperationbooking/views/whiteboard/header.php +++ b/protected/modules/OphTrOperationbooking/views/whiteboard/header.php @@ -24,12 +24,6 @@ Refresh refresh - endWidget()?>
From 7d97ccb027effea76cddcbdb260529a7f2661ab7 Mon Sep 17 00:00:00 2001 From: feketecs Date: Wed, 1 Feb 2017 09:44:00 +0100 Subject: [PATCH 151/164] OE-6371 Whiteboard auto-refreshes when opened --- .../controllers/WhiteboardController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php b/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php index 191b50e59a..076bf0fe8f 100644 --- a/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php +++ b/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php @@ -109,6 +109,11 @@ public function actionView($id) } $this->setWhiteboard($whiteboard); + if (!(is_object($whiteboard->booking) && $whiteboard->booking->isEditable() && !$whiteboard->is_confirmed)) + { + $whiteboard->loadData($id); + } + $this->render('view', array('data' => $whiteboard), false, true); } From 2f4a11cd30525d68b5798eed4af0092e8dabce55 Mon Sep 17 00:00:00 2001 From: feketecs Date: Wed, 1 Feb 2017 10:43:03 +0100 Subject: [PATCH 152/164] OE-6371 Whiteboard auto-refreshes when opened --- .../OphTrOperationbooking/controllers/WhiteboardController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php b/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php index 076bf0fe8f..96368c455b 100644 --- a/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php +++ b/protected/modules/OphTrOperationbooking/controllers/WhiteboardController.php @@ -109,7 +109,7 @@ public function actionView($id) } $this->setWhiteboard($whiteboard); - if (!(is_object($whiteboard->booking) && $whiteboard->booking->isEditable() && !$whiteboard->is_confirmed)) + if (is_object($whiteboard->booking) && $whiteboard->booking->isEditable() && !$whiteboard->is_confirmed) { $whiteboard->loadData($id); } From 43e57c303fa30f10a2ad052708660ae54e9ef2d7 Mon Sep 17 00:00:00 2001 From: Sabi Date: Wed, 1 Feb 2017 16:06:31 +0000 Subject: [PATCH 153/164] OE-6375 : store letter types in database, updated docman command to use letter type object and adding letter_type to document_log, added (OE-6364) : Letter Macros not populating Letter Type other than Post-Op --- protected/commands/DocManDeliveryCommand.php | 13 +-- ...114016_add_letter_type_to_document_log.php | 66 ++++++++++++ .../OphCoCorrespondence/assets/js/module.js | 29 ++--- .../controllers/DefaultController.php | 2 +- .../models/ElementLetter.php | 6 +- .../models/LetterMacro.php | 2 +- .../OphCoCorrespondence/models/LetterType.php | 100 ++++++++++++++++++ .../views/admin/_macro.php | 2 +- .../views/default/create_ElementLetter.php | 47 ++------ .../views/default/update_ElementLetter.php | 9 +- 10 files changed, 207 insertions(+), 69 deletions(-) create mode 100644 protected/migrations/m170201_114016_add_letter_type_to_document_log.php create mode 100644 protected/modules/OphCoCorrespondence/models/LetterType.php diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index a79c29bd8d..159daad8a8 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -122,14 +122,14 @@ private function savePDFFile($event_id, $output_id) curl_close($ch); if (!isset(Yii::app()->params['docman_filename_format']) || Yii::app()->params['docman_filename_format'] === 'format1') { - $filename = "OPENEYES_" . $this->event->episode->patient->hos_num . '_' . $this->event->id . "_" . rand(); + $filename = "OPENEYES_" . (str_replace(' ', '', $this->event->episode->patient->hos_num)) . '_' . $this->event->id . "_" . rand(); } else { if (Yii::app()->params['docman_filename_format'] === 'format2') { - $filename = $this->event->episode->patient->hos_num . '_' . date('YmdHi', + $filename = (str_replace(' ', '', $this->event->episode->patient->hos_num)) . '_' . date('YmdHi', strtotime($this->event->last_modified_date)) . '_' . $this->event->id; } else { if (Yii::app()->params['docman_filename_format'] === 'format3') { - $filename = $this->event->episode->patient->hos_num . '_edtdep-OEY_' . + $filename = (str_replace(' ', '', $this->event->episode->patient->hos_num)) . '_edtdep-OEY_' . date('Ymd_His', strtotime($this->event->last_modified_date)) . '_' . $this->event->id; } } @@ -195,9 +195,11 @@ private function savePDFFile($event_id, $output_id) } if ($this->updateDelivery($output_id)) { + $element_letter = ElementLetter::model()->findByAttributes(array("event_id" => $this->event->id)); $this->logData(array( 'hos_num' => $this->event->episode->patient->hos_num, 'clinician_name' => $this->event->user->getFullName(), + 'letter_type' => (isset($element_letter->letterType->name) ? $element_letter->letterType->name : ''), 'letter_finalised_date' => $this->event->last_modified_date, 'letter_created_date' => $this->event->created_date, 'last_significant_event_date' => $lastSignificantEventDate, @@ -217,8 +219,6 @@ private function savePDFFile($event_id, $output_id) private function generateXMLOutput($filename) { $element_letter = ElementLetter::model()->findByAttributes(array("event_id" => $this->event->id)); - $letter_types = array("0" => "", "1" => "Clinic discharge letter", "2" => "Post-op letter", "3" => "Clinic letter", "4" => "Other letter"); - $subObj = $this->event->episode->firm->serviceSubspecialtyAssignment->subspecialty; $subspeciality = isset($subObj->ref_spec) ? $subObj->ref_spec : 'SS'; $subspeciality_name = isset($subObj->name) ? $subObj->name : 'Support Services'; @@ -231,6 +231,7 @@ private function generateXMLOutput($filename) $county = isset($this->event->episode->patient->contact->address) ? ($this->event->episode->patient->contact->address->county) : ''; $city = isset($this->event->episode->patient->contact->address) ? ($this->event->episode->patient->contact->address->city) : ''; $post_code = isset($this->event->episode->patient->contact->address) ? ($this->event->episode->patient->contact->address->postcode) : ''; + $letter_type = isset($element_letter->letterType->name) ? $element_letter->letterType->name : ''; $xml = " @@ -255,7 +256,7 @@ private function generateXMLOutput($filename) " . $gp_name . " " . $practice_code . " - " . $letter_types[$element_letter->letter_type] . " + " . $letter_type . " " . $this->event->id . " " . $this->event->event_date . " diff --git a/protected/migrations/m170201_114016_add_letter_type_to_document_log.php b/protected/migrations/m170201_114016_add_letter_type_to_document_log.php new file mode 100644 index 0000000000..e27bb592d5 --- /dev/null +++ b/protected/migrations/m170201_114016_add_letter_type_to_document_log.php @@ -0,0 +1,66 @@ +createOETable('ophcocorrespondence_letter_type', array( + 'id' => 'pk', + 'name' => 'varchar(40)' + )); + + $this->insert('ophcocorrespondence_letter_type', array( 'id' => 1, 'name' => 'Clinic discharge letter')); + $this->insert('ophcocorrespondence_letter_type', array( 'id' => 2, 'name' => 'Post-op letter')); + $this->insert('ophcocorrespondence_letter_type', array( 'id' => 3, 'name' => 'Clinic letter')); + $this->insert('ophcocorrespondence_letter_type', array( 'id' => 4, 'name' => 'Other letter')); + + $this->addColumn('document_log', 'letter_type', 'VARCHAR(40) DEFAULT NULL AFTER clinician_name'); + + //letter type is not mandatory + $this->alterColumn('et_ophcocorrespondence_letter', 'letter_type', 'int(1) DEFAULT NULL'); + $this->alterColumn('et_ophcocorrespondence_letter_version', 'letter_type', 'int(1) DEFAULT NULL'); + $this->alterColumn('ophcocorrespondence_letter_macro', 'letter_type', 'int(1) DEFAULT NULL'); + $this->alterColumn('ophcocorrespondence_letter_macro_version', 'letter_type', 'int(1) DEFAULT NULL'); + + //set back letter_type to NULL + $this->update('et_ophcocorrespondence_letter', array('letter_type' => null), 'letter_type=0'); + $this->update('et_ophcocorrespondence_letter_version', array('letter_type' => null), 'letter_type=0'); + $this->update('ophcocorrespondence_letter_macro', array('letter_type' => null), 'letter_type=0'); + $this->update('ophcocorrespondence_letter_macro_version', array('letter_type' => null), 'letter_type=0'); + + $this->renameColumn('et_ophcocorrespondence_letter', 'letter_type', 'letter_type_id'); + $this->renameColumn('et_ophcocorrespondence_letter_version', 'letter_type', 'letter_type_id'); + + $this->renameColumn('ophcocorrespondence_letter_macro', 'letter_type', 'letter_type_id'); + $this->renameColumn('ophcocorrespondence_letter_macro_version', 'letter_type', 'letter_type_id'); + + $this->addForeignKey('et_ophcocorrespondence_letter_ibfk_1', 'et_ophcocorrespondence_letter', 'letter_type_id', 'ophcocorrespondence_letter_type', 'id'); + $this->addForeignKey('ophcocorrespondence_letter_macro_ibfk_1', 'ophcocorrespondence_letter_macro', 'letter_type_id', 'ophcocorrespondence_letter_type', 'id'); + } + + public function safeDown() + { + $this->dropForeignKey('et_ophcocorrespondence_letter_ibfk_1', 'et_ophcocorrespondence_letter'); + $this->dropForeignKey('ophcocorrespondence_letter_macro_ibfk_1', 'ophcocorrespondence_letter_macro'); + + $this->dropOETable('ophcocorrespondence_letter_type'); + $this->dropColumn('document_log', 'letter_type'); + + $this->update('et_ophcocorrespondence_letter', array('letter_type_id' => 0), 'letter_type_id IS NULL'); + $this->update('et_ophcocorrespondence_letter_version', array('letter_type_id' => 0), 'letter_type_id IS NULL'); + $this->update('ophcocorrespondence_letter_macro', array('letter_type_id' => 0), 'letter_type_id IS NULL'); + $this->update('ophcocorrespondence_letter_macro_version', array('letter_type_id' => 0), 'letter_type_id IS NULL'); + + $this->alterColumn('et_ophcocorrespondence_letter', 'letter_type_id', 'int(1) NOT NULL DEFAULT 0'); + $this->alterColumn('et_ophcocorrespondence_letter_version', 'letter_type_id', 'int(1) NOT NULL DEFAULT 0'); + $this->alterColumn('ophcocorrespondence_letter_macro', 'letter_type_id', 'int(1) NOT NULL DEFAULT 0'); + $this->alterColumn('ophcocorrespondence_letter_macro_version', 'letter_type_id', 'int(1) NOT NULL DEFAULT 0'); + + $this->renameColumn('et_ophcocorrespondence_letter', 'letter_type_id', 'letter_type'); + $this->renameColumn('et_ophcocorrespondence_letter_version', 'letter_type_id', 'letter_type'); + + $this->renameColumn('ophcocorrespondence_letter_macro', 'letter_type_id', 'letter_type'); + $this->renameColumn('ophcocorrespondence_letter_macro_version', 'letter_type_id', 'letter_type'); + + } +} \ No newline at end of file diff --git a/protected/modules/OphCoCorrespondence/assets/js/module.js b/protected/modules/OphCoCorrespondence/assets/js/module.js index 461029e077..aa3f1c0331 100644 --- a/protected/modules/OphCoCorrespondence/assets/js/module.js +++ b/protected/modules/OphCoCorrespondence/assets/js/module.js @@ -18,23 +18,28 @@ var correspondence_markprinted_url, correspondence_print_url; +function setDropDownWidth(id){ + var $option_obj; + var option_width; + var arrow_width = 30; + + $option_obj = $("").html($('#' + id +' option:selected').text()); + $option_obj.appendTo('body'); + option_width = $option_obj.width(); + $option_obj.remove(); + + $('#' + id).width(option_width + arrow_width); +} + function updateCorrespondence(macro_id) { var nickname = $('input[id="ElementLetter_use_nickname"][type="checkbox"]').is(':checked') ? '1' : '0'; var obj = $(this); - var $option_obj; - var option_width; - var arrowWidth = 30; if ( macro_id != '') { - $option_obj = $("").html($('#macro_id option:selected').text()); - $option_obj.appendTo('body'); - option_width = $option_obj.width(); - $option_obj.remove(); - - $('#macro_id').width(option_width + arrowWidth); - + setDropDownWidth('macro_id'); + $.ajax({ 'type': 'GET', 'dataType': 'json', @@ -54,9 +59,7 @@ function updateCorrespondence(macro_id) obj.val(''); //set letter type - if('Post-op' == $('#macro_id option:selected').text() ){ - $('#ElementLetter_letter_type').val(2); - } + $('#ElementLetter_letter_type_id').val(data.sel_letter_type_id); } }); } diff --git a/protected/modules/OphCoCorrespondence/controllers/DefaultController.php b/protected/modules/OphCoCorrespondence/controllers/DefaultController.php index 5054d91f85..4e73ce20aa 100644 --- a/protected/modules/OphCoCorrespondence/controllers/DefaultController.php +++ b/protected/modules/OphCoCorrespondence/controllers/DefaultController.php @@ -256,7 +256,7 @@ public function actionGetMacroData() $data['textappend_ElementLetter_cc'] = implode("\n", $cc['text']); $data['elementappend_cc_targets'] = implode("\n", $cc['targets']); - $data['sel_letter_type'] = $macro->letter_type; + $data['sel_letter_type_id'] = $macro->letter_type_id; echo json_encode($data); } diff --git a/protected/modules/OphCoCorrespondence/models/ElementLetter.php b/protected/modules/OphCoCorrespondence/models/ElementLetter.php index 8cf31408fd..4f3255f6a7 100644 --- a/protected/modules/OphCoCorrespondence/models/ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/models/ElementLetter.php @@ -67,7 +67,7 @@ public function rules() 'print_all, is_signed_off', 'safe' ), - array('letter_type', 'letterTypeValidator'), + array('letter_type_id', 'letterTypeValidator'), array('site_id, date, introduction, body, footer', 'requiredIfNotDraft'), array('use_nickname', 'required'), array('date', 'OEDateValidator'), @@ -75,7 +75,7 @@ public function rules() //array('is_signed_off', 'isSignedOffValidator'), // they do not want this at the moment - waiting for the demo/feedback // The following rule is used by search(). // Please remove those attributes that should not be searched. - array('id, event_id, site_id, use_nickname, date, introduction, re, body, footer, draft, direct_line, letter_type', 'safe', 'on' => 'search'), + array('id, event_id, site_id, use_nickname, date, introduction, re, body, footer, draft, direct_line, letter_type_id', 'safe', 'on' => 'search'), ); } @@ -95,7 +95,7 @@ public function relations() 'site' => array(self::BELONGS_TO, 'Site', 'site_id'), 'enclosures' => array(self::HAS_MANY, 'LetterEnclosure', 'element_letter_id', 'order' => 'display_order'), 'document_instance' => array(self::HAS_MANY, 'DocumentInstance', array( 'correspondence_event_id' => 'event_id')), - + 'letterType' => array(self::BELONGS_TO, 'LetterType', 'letter_type_id'), ); } diff --git a/protected/modules/OphCoCorrespondence/models/LetterMacro.php b/protected/modules/OphCoCorrespondence/models/LetterMacro.php index d9f55eba4c..ab6a6e9276 100644 --- a/protected/modules/OphCoCorrespondence/models/LetterMacro.php +++ b/protected/modules/OphCoCorrespondence/models/LetterMacro.php @@ -54,7 +54,7 @@ public function tableName() public function rules() { return array( - array('name, recipient_id, use_nickname, body, cc_patient, cc_doctor, display_order, site_id, subspecialty_id, firm_id, cc_drss, episode_status_id, letter_type', 'safe'), + array('name, recipient_id, use_nickname, body, cc_patient, cc_doctor, display_order, site_id, subspecialty_id, firm_id, cc_drss, episode_status_id, letter_type_id', 'safe'), array('name, use_nickname, body, cc_patient, cc_doctor, type', 'required'), array('site_id', 'RequiredIfFieldValidator', 'field' => 'type', 'value' => 'site'), array('subspecialty_id', 'RequiredIfFieldValidator', 'field' => 'type', 'value' => 'subspecialty'), diff --git a/protected/modules/OphCoCorrespondence/models/LetterType.php b/protected/modules/OphCoCorrespondence/models/LetterType.php new file mode 100644 index 0000000000..8d48ae9e6e --- /dev/null +++ b/protected/modules/OphCoCorrespondence/models/LetterType.php @@ -0,0 +1,100 @@ +. + * + * @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 + */ + +/** + * The followings are the available columns in table '':. + * + * @property string $id + * @property int $event_id + * + * The followings are the available model relations: + * @property Event $event + */ +class LetterType extends BaseActiveRecordVersioned +{ + + /** + * Returns the static model of the specified AR class. + * + * @return ElementOperation the static model class + */ + public static function model($className = __CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'ophcocorrespondence_letter_type'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + return array( + array('name', 'safe'), + array('name', 'required'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array(); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'name' => 'Letter Type', + ); + } + + /** + * Retrieves a list of models based on the current search/filter conditions. + * + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search() + { + // Warning: Please modify the following code to remove attributes that + // should not be searched. + + $criteria = new CDbCriteria(); + + $criteria->compare('id', $this->id, true); + $criteria->compare('name', $this->name, true); + + return new CActiveDataProvider(get_class($this), array( + 'criteria' => $criteria, + )); + } +} diff --git a/protected/modules/OphCoCorrespondence/views/admin/_macro.php b/protected/modules/OphCoCorrespondence/views/admin/_macro.php index 5f51cfaf97..69c29c5c19 100644 --- a/protected/modules/OphCoCorrespondence/views/admin/_macro.php +++ b/protected/modules/OphCoCorrespondence/views/admin/_macro.php @@ -32,7 +32,7 @@ ), ))?> dropDownList($macro, 'type', array('site' => 'Site', 'subspecialty' => 'Subspecialty', 'firm' => 'Firm'), array('empty' => '- Type -'))?> - dropDownList($macro, 'letter_type', array('1'=>'Clinic discharge letter', '2'=>'Post-op letter', '3'=>'Clinic letter', '4'=>'Other letter'), array('empty' => '- Letter type -'))?> + dropDownList($macro, 'letter_type_id', CHtml::listData(LetterType::model()->findAll(array('order' => 'name asc')), 'id', 'name'), array('empty' => '- Letter type -'))?> dropDownList($macro, 'site_id', Site::model()->getListForCurrentInstitution(), array('empty' => '- Site -', 'div-class' => 'typeSite'), $macro->type != 'site')?> dropDownList($macro, 'subspecialty_id', CHtml::listData(Subspecialty::model()->findAll(array('order' => 'name asc')), 'id', 'name'), array('empty' => '- Subspecialty -', 'div-class' => 'typeSubspecialty'), $macro->type != 'subspecialty')?> dropDownList($macro, 'firm_id', Firm::model()->getListWithSpecialties(true), array('empty' => '- Firm -', 'div-class' => 'typeFirm'), $macro->type != 'firm')?> diff --git a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php index 4b9061def5..7c703563e0 100644 --- a/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/create_ElementLetter.php @@ -25,15 +25,16 @@ $layoutColumns = $form->layoutColumns; $macro_id = isset($_POST['macro_id']) ? $_POST['macro_id'] : (isset($element->macro->id) ? $element->macro->id : null); -$macro_name = null; + +$macro_letter_type_id = null; if($macro_id){ $macro = LetterMacro::model()->findByPk($macro_id); - $macro_name = $macro ? $macro->name : null; + $macro_letter_type_id = $macro->letter_type_id; } $patient_id = Yii::app()->request->getQuery('patient_id', null); $patient = Patient::model()->findByPk($patient_id); -$element->letter_type = ($element->letter_type ? $element->letter_type : ( $macro_name == 'Post-op' ? 2 : null ) ); +$element->letter_type_id = ($element->letter_type_id ? $element->letter_type_id : $macro_letter_type_id ); ?>
@@ -69,11 +70,8 @@
- dropDownList($element, 'letter_type', - array( '1' => 'Clinic discharge letter', - '2' => 'Post-op letter', - '3' => 'Clinic letter', - '4' => 'Other letter'), + + dropDownList($element, 'letter_type_id', CHtml::listData(LetterType::model()->findAll(array('order' => 'name asc')), 'id', 'name'), array('empty' => '- Please select -', 'nowrapper' => true, 'class' => 'full-width')) ?>
@@ -364,39 +362,8 @@ array('nowrapper' => true) ); ?>
-
diff --git a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php index b80975379b..65decffc43 100644 --- a/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php +++ b/protected/modules/OphCoCorrespondence/views/default/update_ElementLetter.php @@ -29,13 +29,14 @@ if( !$macro_id ){ $macro_id = isset($element->document_instance[0]->document_instance_data[0]->macro_id) ? $element->document_instance[0]->document_instance_data[0]->macro_id : null; } -$macro_name = null; + +$macro_letter_type_id = null; if($macro_id){ $macro = LetterMacro::model()->findByPk($macro_id); - $macro_name = $macro ? $macro->name : null; + $macro_letter_type_id = $macro->letter_type_id; } -$element->letter_type = ($element->letter_type ? $element->letter_type : ( $macro_name == 'Post-op' ? 2 : null ) ); +$element->letter_type_id = ($element->letter_type_id ? $element->letter_type_id : $macro_letter_type_id ); $patient_id = Yii::app()->request->getQuery('patient_id', null); $patient = Patient::model()->findByPk($patient_id); @@ -76,7 +77,7 @@
- dropDownList($element, 'letter_type', array('1' => 'Clinic discharge letter', '2' => 'Post-op letter', '3' => 'Clinic letter', '4' => 'Other letter'), + dropDownList($element, 'letter_type_id', CHtml::listData(LetterType::model()->findAll(array('order' => 'name asc')), 'id', 'name'), array('empty' => '- Please select -', 'nowrapper' => true, 'class' => 'full-width')) ?>
From e29e42d5c1e1caea9a8fd9fca62ac7bd80739f13 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Thu, 2 Feb 2017 12:11:35 +0000 Subject: [PATCH 154/164] OE-6381 Change to not print Notes letter if disable_correspondence_notes_copy parameter is set to true. --- .../controllers/DefaultController.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/controllers/DefaultController.php b/protected/modules/OphCoCorrespondence/controllers/DefaultController.php index 5054d91f85..a155b23623 100644 --- a/protected/modules/OphCoCorrespondence/controllers/DefaultController.php +++ b/protected/modules/OphCoCorrespondence/controllers/DefaultController.php @@ -396,7 +396,12 @@ public function actionPrint($id) if($to_recipient_gp){ // print an extra copy to note - $this->render('print', array('element' => $letter, 'letter_address' => ($to_recipient_gp->contact_name . "\n" . $to_recipient_gp->address))); + if(!Yii::app()->params['disable_correspondence_notes_copy']) { + $this->render('print', array( + 'element' => $letter, + 'letter_address' => ($to_recipient_gp->contact_name . "\n" . $to_recipient_gp->address) + )); + } } $print_outputs = $letter->getOutputByType("Print"); @@ -407,7 +412,9 @@ public function actionPrint($id) //extra printout for note if($document_target->ToCc == 'To' && $document_target->contact_type != 'GP'){ - $this->render('print', array('element' => $letter, 'letter_address' => ($document_target->contact_name . "\n" . $document_target->address))); + if(!Yii::app()->params['disable_correspondence_notes_copy']){ + $this->render('print', array('element' => $letter, 'letter_address' => ($document_target->contact_name . "\n" . $document_target->address))); + } } } } @@ -431,7 +438,9 @@ public function actionPrint($id) $this->render('print', array('element' => $letter)); if ($this->pdf_print_suffix == 'all' || @$_GET['all']) { - $this->render('print', array('element' => $letter)); + if(!Yii::app()->params['disable_correspondence_notes_copy']) { + $this->render('print', array('element' => $letter)); + } foreach ($letter->getCcTargets() as $letter_address) { $this->render('print', array('element' => $letter, 'letter_address' => $letter_address)); From c5f74980bdddd404b4cf19d6154128255a38474e Mon Sep 17 00:00:00 2001 From: Sabi Date: Thu, 2 Feb 2017 13:29:20 +0000 Subject: [PATCH 155/164] OE-6375 : adding letter_type to DocumentLog's rule --- protected/models/DocumentLog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protected/models/DocumentLog.php b/protected/models/DocumentLog.php index f421b958f7..a6f9bc5fda 100644 --- a/protected/models/DocumentLog.php +++ b/protected/models/DocumentLog.php @@ -56,7 +56,7 @@ public function rules() return array( // The following rule is used by search(). // Please remove those attributes that should not be searched. - array('id, hos_num, clinician_name, letter_finalised_date, letter_created_date, letter_sent_date, last_significant_event_date', 'safe'), + array('id, hos_num, clinician_name, letter_finalised_date, letter_created_date, letter_sent_date, last_significant_event_date, letter_type', 'safe'), ); } From 1bef2e2d0163e66d4cf2b4226b30addb67dc69ea Mon Sep 17 00:00:00 2001 From: Sabi Date: Fri, 3 Feb 2017 10:18:37 +0000 Subject: [PATCH 156/164] OE-6383 : HTML decode correspondence on short codes ajax call --- .../modules/OphCoCorrespondence/assets/js/module.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/protected/modules/OphCoCorrespondence/assets/js/module.js b/protected/modules/OphCoCorrespondence/assets/js/module.js index aa3f1c0331..846282c542 100644 --- a/protected/modules/OphCoCorrespondence/assets/js/module.js +++ b/protected/modules/OphCoCorrespondence/assets/js/module.js @@ -431,9 +431,18 @@ $(document).ready(function() { 'url': baseUrl+'/OphCoCorrespondence/Default/expandStrings', 'data': 'patient_id='+OE_patient_id+'&text='+text+"&YII_CSRF_TOKEN="+YII_CSRF_TOKEN, 'success': function(resp) { + + //create a textarea and put the html encoded string in it + //so later we can retrive as "normal" text + //it's like decode + var $text_area = document.createElement('textarea'); + $text_area.innerHTML = resp; + if (resp) { - $('#ElementLetter_body').val(resp); + $('#ElementLetter_body').val($text_area.value); } + + $($text_area).remove(); } }); } From ac5f93c965b3fdfc302884f74a05b3fbb44898d7 Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Fri, 3 Feb 2017 10:55:46 +0000 Subject: [PATCH 157/164] OE-6382 Fix for [pov] shortcode --- .../components/OphCoCorrespondence_API.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php index b1783d1fcd..68f953b2bc 100644 --- a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php +++ b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php @@ -194,6 +194,7 @@ public function getPreOpVABothEyes($patient) } } + if($data){ for ($i = 0; $i < count($data); ++$i) { if($data[$i]->side == 0){ $rightData[] = $data[$i]; @@ -202,13 +203,16 @@ public function getPreOpVABothEyes($patient) $leftData[] = $data[$i]; } } + $unitId = $chosenVA->unit_id; - $unitId = $chosenVA->unit_id; + $rightVA = $api->getVAvalue($rightData[0]->value, $unitId); + $leftVA = $api->getVAvalue($leftData[0]->value, $unitId); - $rightVA = $api->getVAvalue($rightData[0]->value, $unitId); - $leftVA = $api->getVAvalue($leftData[0]->value, $unitId); + return $rightVA . " Right Eye" . " " . $leftVA . " Left Eye"; + }else{ + return; + } - return $rightVA . " Right Eye" . " " . $leftVA . " Left Eye"; } /** From dc04fa807d60c0fa25d8a864325148b9844c470f Mon Sep 17 00:00:00 2001 From: Sabi Date: Fri, 3 Feb 2017 13:00:40 +0000 Subject: [PATCH 158/164] Revert "OE-6383 : HTML decode correspondence on short codes ajax call" This reverts commit 1bef2e2d0163e66d4cf2b4226b30addb67dc69ea. Decided to change the code on PHP and not in JS --- .../modules/OphCoCorrespondence/assets/js/module.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/assets/js/module.js b/protected/modules/OphCoCorrespondence/assets/js/module.js index 846282c542..aa3f1c0331 100644 --- a/protected/modules/OphCoCorrespondence/assets/js/module.js +++ b/protected/modules/OphCoCorrespondence/assets/js/module.js @@ -431,18 +431,9 @@ $(document).ready(function() { 'url': baseUrl+'/OphCoCorrespondence/Default/expandStrings', 'data': 'patient_id='+OE_patient_id+'&text='+text+"&YII_CSRF_TOKEN="+YII_CSRF_TOKEN, 'success': function(resp) { - - //create a textarea and put the html encoded string in it - //so later we can retrive as "normal" text - //it's like decode - var $text_area = document.createElement('textarea'); - $text_area.innerHTML = resp; - if (resp) { - $('#ElementLetter_body').val($text_area.value); + $('#ElementLetter_body').val(resp); } - - $($text_area).remove(); } }); } From 44979abf21b0d7246767a57ece2565b9f3ebd07a Mon Sep 17 00:00:00 2001 From: Sabi Date: Fri, 3 Feb 2017 13:08:52 +0000 Subject: [PATCH 159/164] OE-6383 : remove HTML encode from correspondence API as there is already an encoding in the input generator $form --- .../components/OphCoCorrespondence_API.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php index b1783d1fcd..99d4aec24c 100644 --- a/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php +++ b/protected/modules/OphCoCorrespondence/components/OphCoCorrespondence_API.php @@ -138,7 +138,7 @@ public function getLastIOLType(\Patient $patient) if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); $element = $this->getMostRecentElementInEpisode($episode->id, $event_type->id, 'Element_OphTrOperationnote_Cataract'); - return CHtml::encode($element->iol_type->name); + return $element->iol_type->name; } } @@ -147,7 +147,7 @@ public function getLastIOLPower(\Patient $patient) if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); $element = $this->getMostRecentElementInEpisode($episode->id, $event_type->id, 'Element_OphTrOperationnote_Cataract'); - return CHtml::encode($element->iol_power); + return $element->iol_power; } } From b4a648479f053716a4a8cab722272776ed00c063 Mon Sep 17 00:00:00 2001 From: Sabi Date: Fri, 3 Feb 2017 16:12:35 +0000 Subject: [PATCH 160/164] OE-6336 : process only the not deleted events - leave the status on PENDING on purpose --- protected/commands/DocManDeliveryCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/protected/commands/DocManDeliveryCommand.php b/protected/commands/DocManDeliveryCommand.php index 159daad8a8..84440d3c27 100644 --- a/protected/commands/DocManDeliveryCommand.php +++ b/protected/commands/DocManDeliveryCommand.php @@ -63,8 +63,15 @@ public function run($args) * @return CActiveRecord[] */ private function getPendingDocuments() - { - return DocumentOutput::model()->findAllByAttributes(array("output_status" => "PENDING", "output_type" => "Docman")); + { + $criteria = new CDbCriteria(); + $criteria->join = "JOIN `document_target` tr ON t.`document_target_id` = tr.id"; + $criteria->join .= " JOIN `document_instance` i ON tr.`document_instance_id` = i.`id`"; + $criteria->join .= " JOIN event e ON i.`correspondence_event_id` = e.id"; + $criteria->addCondition("e.deleted = 0"); + $criteria->addCondition("t.`output_status` = 'PENDING' AND t.`output_type`= 'Docman'"); + + return DocumentOutput::model()->findAll($criteria); } /** From 9fc64eca5280e74ade605272da18b9d46946e43d Mon Sep 17 00:00:00 2001 From: paulhooperAcross Date: Mon, 6 Feb 2017 12:01:10 +0000 Subject: [PATCH 161/164] OE-6239 Fix issue with removal of eye, and ability to add back in. --- ...form_Element_OphInBiometry_Measurement.php | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php index 1109ceeef6..799c5700b4 100644 --- a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php +++ b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php @@ -398,13 +398,6 @@ class="element-eye right-eye top-pad left side column hasR
Remove side id, array('class' => 'element_id')); ?> - renderPartial('form_Element_OphInBiometry_Measurement_fields', array( - 'side' => 'right', - 'element' => $element, - 'form' => $form, - 'data' => $data, - 'measurementInput' => $iolRefValues, - )); ?>
@@ -413,6 +406,16 @@ class="element-eye right-eye top-pad left side column hasR
+
+ renderPartial('form_Element_OphInBiometry_Measurement_fields', array( + 'side' => 'right', + 'element' => $element, + 'form' => $form, + 'data' => $data, + 'measurementInput' => $iolRefValues, + )); ?> +
+
hasLe

LEFT

-
- hasLeft()) { - ?>
Remove side - renderPartial('form_Element_OphInBiometry_Measurement_fields', array( - 'side' => 'left', - 'element' => $element, - 'form' => $form, - 'data' => $data, - 'measurementInput' => $iolRefValues, - )); ?>
@@ -441,9 +434,14 @@ class="element-eye left-eye top-pad right side column hasLe
- +
+ renderPartial('form_Element_OphInBiometry_Measurement_fields', array( + 'side' => 'left', + 'element' => $element, + 'form' => $form, + 'data' => $data, + 'measurementInput' => $iolRefValues, + )); ?>
From 3702bb5f03df0db8e2bea148a5af7d0c3469d067 Mon Sep 17 00:00:00 2001 From: Sabi Date: Tue, 7 Feb 2017 13:42:34 +0000 Subject: [PATCH 162/164] OE-6397 : Operation Note showing PCR risk for wrong eye --- protected/views/default/_pcr_risk_form.php | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/protected/views/default/_pcr_risk_form.php b/protected/views/default/_pcr_risk_form.php index ba58451b08..35712a0eff 100644 --- a/protected/views/default/_pcr_risk_form.php +++ b/protected/views/default/_pcr_risk_form.php @@ -23,23 +23,41 @@ $jsPath = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets.js'), false, -1); ?> - Date: Fri, 10 Feb 2017 09:18:49 +0000 Subject: [PATCH 163/164] OE-6199 Fix to avoid application error if exam event only records one eye. --- ...form_Element_OphInBiometry_Measurement.php | 53 +++++++++++++------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php index 799c5700b4..23a56ad8be 100644 --- a/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php +++ b/protected/modules/OphInBiometry/views/default/form_Element_OphInBiometry_Measurement.php @@ -61,6 +61,9 @@ } } + $rightData = array(); + $leftData = array(); + for ($i = 0; $i < count($data); ++$i) { if($data[$i]->side == 0){ $rightData[] = $data[$i]; @@ -70,10 +73,12 @@ } } + $methodnameRight = array(); + $methodnameLeft = array(); + if($data){ $unitId = $chosenVA->unit_id; - for ($i = 0; $i < count($rightData); ++$i) { $VAfinalright = $api->getVAvalue($rightData[$i]->value, $unitId); } @@ -108,8 +113,8 @@
- hasRight()) { - if($data){ +
@@ -138,11 +143,11 @@
+ ?>
@@ -193,6 +198,9 @@ } } + $rightNearData = array(); + $leftNearData = array(); + if($NearVAFound){ for ($i = 0; $i < count($neardata); ++$i) { if($neardata[$i]->side == 0){ @@ -205,9 +213,6 @@ $unitId = $chosenNearVA->unit_id; - - - for ($i = 0; $i < count($rightNearData); ++$i) { $VAfinalright = $api->getVAvalue($rightNearData[$i]->value, $unitId); } @@ -237,8 +242,8 @@
- hasRight()) { - if ($NearVAFound) { +
@@ -268,11 +273,11 @@
+ ?>
@@ -344,7 +349,11 @@ - Not recorded +
+
+ Not recorded +
+
@@ -357,7 +366,11 @@ - Not recorded +
+
+ Not recorded +
+
@@ -370,10 +383,18 @@
-
Not recorded
+
+
+ Not recorded +
+
-
Not recorded
+
+
+ Not recorded +
+
Date: Fri, 10 Feb 2017 13:53:57 +0100 Subject: [PATCH 164/164] fixed A constant display in Bimoetry event --- .../default/view_Element_OphInBiometry_Selection_fields.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Selection_fields.php b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Selection_fields.php index 4b4c23d1c1..f7c9fe5da4 100644 --- a/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Selection_fields.php +++ b/protected/modules/OphInBiometry/views/default/view_Element_OphInBiometry_Selection_fields.php @@ -54,18 +54,20 @@ class="field-info">getAttributeLabel('lens
is_auto) { $iolrefValues = Element_OphInBiometry_IolRefValues::model()->findAllByAttributes(array('event_id' => $element->event->id)); foreach ($iolrefValues as $iolrefData) { if (isset($data)) { if ($iolrefData->lens_id == $element->{'lens_'.$side}->id && $iolrefData->formula_id == $data[0]->id) { - echo $this->formatAconst($iolrefData->constant); + $aconst = $this->formatAconst($iolrefData->constant); } } } } else { - echo ($element->{'lens_'.$side}) ? $this->formatAconst($element->{'lens_'.$side}->acon) : 'None'; + $aconst = ($element->{'lens_'.$side}) ? $this->formatAconst($element->{'lens_'.$side}->acon) : 'None'; } + echo $aconst; ?>