From 4a144167e1e131a1993320d24a5d6f699e8ff579 Mon Sep 17 00:00:00 2001 From: James Curtis Date: Tue, 21 Jul 2020 13:54:55 +0100 Subject: [PATCH 1/3] [FIX] date_terminated not converted to local timezone Reported as Food and Fluid not reporting dates in BST, but after further testing this was found true for other observations. The initial fix for F&F resulted in other obs that were previously correct were now wrong. This highlighted that the original fix for BST issue by changing the javascript was incorrect. This commit removed the previous javascript changes and updates observation models 'convert datetime' methods with the correct fields to be converted. Fixes #16529 --- nh_eobs/static/src/js/nh_eobs_v0_0_1.js | 10 ---------- .../report/nh_clinical_observation_report.py | 10 ++++++++++ .../report/nh_clinical_observation_report.py | 5 +++-- nh_observations/observations.py | 2 +- .../report/nh_clinical_patient_observation_report.py | 1 + 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/nh_eobs/static/src/js/nh_eobs_v0_0_1.js b/nh_eobs/static/src/js/nh_eobs_v0_0_1.js index 25abea38..2ad448a9 100644 --- a/nh_eobs/static/src/js/nh_eobs_v0_0_1.js +++ b/nh_eobs/static/src/js/nh_eobs_v0_0_1.js @@ -503,12 +503,6 @@ openerp.nh_eobs = function (instance) { this.set({'value': value_}); this.render_chart(); }, - localise_datetime: function (datetime) { - var pattern = /(\d{4})\-(\d{2})\-(\d{2})\s(\d{2})\:(\d{2})\:(\d{2})/; - var match = pattern.exec(datetime); - var dt = new Date(Date.UTC(match[1], match[2] - 1, match[3], match[4], match[5], match[6])); - return dt.getFullYear() + "-" + (dt.getMonth() + 1) + "-" + dt.getDate() + " " + dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds(); - }, render_chart: function () { this.model = new instance.web.Model('nh.eobs.api'); this.o2targetModel = new instance.web.Model('nh.clinical.patient.o2target'); @@ -533,10 +527,6 @@ openerp.nh_eobs = function (instance) { $(svg.el).html(''); if (records.length > 0) { - for (var i = 0; i < records.length; i++) { - var ed = records[i].effective_date_terminated; - records[i].effective_date_terminated = self.localise_datetime(ed) - } var obs = records.reverse(); obs.forEach(function (d) { diff --git a/nh_food_and_fluid/report/nh_clinical_observation_report.py b/nh_food_and_fluid/report/nh_clinical_observation_report.py index cc8c766d..3a9f806e 100644 --- a/nh_food_and_fluid/report/nh_clinical_observation_report.py +++ b/nh_food_and_fluid/report/nh_clinical_observation_report.py @@ -47,3 +47,13 @@ def _format_many_2_many_fields(self, food_and_fluid_report_data): food_and_fluid_model.format_many_2_many_fields(obs_list, ['recorded_concerns', 'dietary_needs']) + + def _localise_and_format_datetimes(self, report_data): + super(NhClinicalObservationReport, self)._localise_and_format_datetimes(report_data) + + if 'food_and_fluid' in report_data: + for obs in report_data.get('food_and_fluid'): + for record in obs['observations']: + self._localise_dict_time(record, 'date_started') + self._localise_dict_time(record, 'date_terminated') + self._localise_dict_time(record, 'effective_date_terminated') diff --git a/nh_neurological/report/nh_clinical_observation_report.py b/nh_neurological/report/nh_clinical_observation_report.py index 101819f3..f5adc48f 100644 --- a/nh_neurological/report/nh_clinical_observation_report.py +++ b/nh_neurological/report/nh_clinical_observation_report.py @@ -18,9 +18,10 @@ def get_report_data(self, data, ews_only=False): return report_data def _localise_and_format_datetimes(self, report_data): - super(NhClinicalPatientObservationReport, self)\ - ._localise_and_format_datetimes(report_data) + super(NhClinicalPatientObservationReport, self)._localise_and_format_datetimes(report_data) for obs in report_data.get('neurological', []): + self._localise_dict_time(obs, 'date_started') + self._localise_dict_time(obs, 'date_terminated') self._localise_dict_time(obs, 'effective_date_terminated') def get_neurological_observations(self, data): diff --git a/nh_observations/observations.py b/nh_observations/observations.py index f9ae0cf4..ff570b23 100644 --- a/nh_observations/observations.py +++ b/nh_observations/observations.py @@ -417,7 +417,7 @@ def get_formatted_obs(self, replace_zeros=False, if convert_datetimes_to_client_timezone: datetime_fields = ['date_terminated', 'create_date', - 'write_date', 'date_started'] + 'write_date', 'date_started', 'effective_date_terminated'] self._convert_datetime_fields_to_client_timezone( obs_dict_list, datetime_fields) diff --git a/nh_weight/report/nh_clinical_patient_observation_report.py b/nh_weight/report/nh_clinical_patient_observation_report.py index 58bc5217..60d8ac06 100644 --- a/nh_weight/report/nh_clinical_patient_observation_report.py +++ b/nh_weight/report/nh_clinical_patient_observation_report.py @@ -40,6 +40,7 @@ def _localise_and_format_datetimes(self, report_data): super(NhClinicalPatientObservationReport, self)\ ._localise_and_format_datetimes(report_data) for obs in report_data.get('weights', []): + self._localise_dict_time(obs['values'], 'date_terminated') self._localise_dict_time(obs['values'], 'effective_date_terminated') @staticmethod From 5eca5e21bdce1829373de42a2f796c9c466bf6a4 Mon Sep 17 00:00:00 2001 From: James Curtis Date: Tue, 21 Jul 2020 16:17:47 +0100 Subject: [PATCH 2/3] [FIX] Printed report observations don't show effective date --- .../views/observation_report_template.xml | 6 ++++-- nh_neurological/views/observation_report_template.xml | 8 +++++--- nh_weight/views/observation_report_template.xml | 10 ++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/nh_food_and_fluid/views/observation_report_template.xml b/nh_food_and_fluid/views/observation_report_template.xml index 67bd3293..defe5a6f 100644 --- a/nh_food_and_fluid/views/observation_report_template.xml +++ b/nh_food_and_fluid/views/observation_report_template.xml @@ -25,7 +25,8 @@ - + + @@ -40,7 +41,8 @@ - + + diff --git a/nh_neurological/views/observation_report_template.xml b/nh_neurological/views/observation_report_template.xml index ef4e98d1..449900d0 100644 --- a/nh_neurological/views/observation_report_template.xml +++ b/nh_neurological/views/observation_report_template.xml @@ -48,13 +48,14 @@ - + - + + @@ -73,7 +74,8 @@ - + + diff --git a/nh_weight/views/observation_report_template.xml b/nh_weight/views/observation_report_template.xml index 822b02e6..3be642c4 100644 --- a/nh_weight/views/observation_report_template.xml +++ b/nh_weight/views/observation_report_template.xml @@ -34,21 +34,23 @@
Date / TimeEffective DateSubmitted Date Recorded Concern Dietary Needs Fluid Intake

Coma Scale

Pupils

Limbs

DateEffective DateSubmitted Date Coma Scale Total score Eyes Verbal
- + + - + - + + - + From 7a6848e4b54b953f4811b5eb1587c4d4a458544c Mon Sep 17 00:00:00 2001 From: James Curtis Date: Wed, 22 Jul 2020 13:43:05 +0100 Subject: [PATCH 3/3] [FIX] effective_date_terminated not updated in escalation activities --- nh_eobs_mobile/controllers/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nh_eobs_mobile/controllers/main.py b/nh_eobs_mobile/controllers/main.py index 4c8a4722..f22d0079 100755 --- a/nh_eobs_mobile/controllers/main.py +++ b/nh_eobs_mobile/controllers/main.py @@ -744,8 +744,9 @@ def confirm_escalations(self, *args, **kwargs): obj_model = request.registry[task['model']] data_record = obj_model.browse(cr, uid, task['id'], context=context) activity = data_record.activity_id + effective_date = activity.creator_id.effective_date_terminated vals = { - 'effective_date_terminated': activity.creator_id.effective_date_terminated, + 'effective_date_terminated': effective_date, } if task.get('cancel'): vals.update({ @@ -758,6 +759,9 @@ def confirm_escalations(self, *args, **kwargs): obj_model.submit(cr, uid, activity.id, vals, context=context) obj_nh_activity.complete(cr, uid, activity.id, context=context) + # Calling complete method on the activity resets the effective date + activity.effective_date_terminated = effective_date + if task.get('cancel') and activity.creator_id.data_model == 'nh.clinical.patient.observation.blood_glucose': self._cancel_next_blood_glucose(cr, uid, obj_nh_activity, activity, context)
DateEffective DateSubmitted Date Weight (kg) Waist Measurement (cm) BMIUserUser