From ee82b098c2a6054b34f2761d62b05051f07adbf1 Mon Sep 17 00:00:00 2001 From: Angie-540 Date: Thu, 11 Jan 2024 11:13:26 +0300 Subject: [PATCH 1/3] restricted reschedule reminder within biweekly period --- service/patient-reminder.service.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/service/patient-reminder.service.js b/service/patient-reminder.service.js index 06932baeb..eed547efe 100755 --- a/service/patient-reminder.service.js +++ b/service/patient-reminder.service.js @@ -988,7 +988,10 @@ function generateAppointmentNoShowUpRiskReminder(data) { function generateAppointmentRescheduledReminder(data) { let reminders = []; if (data.reschedule_appointment && data.reschedule_appointment === 'YES') { - if (data.last_encounter_date < data.prediction_generated_date) { + if ( + data.last_encounter_date < data.prediction_generated_date && + data.last_encounter_date - data.prediction_generated_date <= 14 + ) { reminders.push({ message: 'Promised to come date is ' + From 7ec4bf68d9452fba3b0714506fb3b8dae8a6d50a Mon Sep 17 00:00:00 2001 From: Angie-540 Date: Fri, 12 Jan 2024 15:03:25 +0300 Subject: [PATCH 2/3] POC-613:remove clincal reminder after visit has been made --- service/patient-reminder.service.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/service/patient-reminder.service.js b/service/patient-reminder.service.js index eed547efe..171903719 100755 --- a/service/patient-reminder.service.js +++ b/service/patient-reminder.service.js @@ -985,12 +985,23 @@ function generateAppointmentNoShowUpRiskReminder(data) { return reminders; } +function datesWithinPrediction(encounterDate, predictionDate) { + const timeDifference = Math.abs(encounterDate - predictionDate); + const millisecondsInTwoWeeks = 2 * 7 * 24 * 60 * 60 * 1000; + + return timeDifference <= millisecondsInTwoWeeks; +} + function generateAppointmentRescheduledReminder(data) { let reminders = []; + if (data.reschedule_appointment && data.reschedule_appointment === 'YES') { if ( data.last_encounter_date < data.prediction_generated_date && - data.last_encounter_date - data.prediction_generated_date <= 14 + datesWithinPrediction( + data.last_encounter_date, + data.prediction_generated_date + ) ) { reminders.push({ message: From 70d71d117b84d9288535c25431cddb6a44d13b31 Mon Sep 17 00:00:00 2001 From: Angie-540 Date: Wed, 17 Jan 2024 12:34:43 +0300 Subject: [PATCH 3/3] POC-613: fixed bug on reschedule reminders displaying after clinical visit --- .../json-reports/clinical-reminder-report.json | 12 ++++++++++-- service/patient-reminder.service.js | 15 +-------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/app/reporting-framework/json-reports/clinical-reminder-report.json b/app/reporting-framework/json-reports/clinical-reminder-report.json index 5b738f5f1..05cc0b639 100644 --- a/app/reporting-framework/json-reports/clinical-reminder-report.json +++ b/app/reporting-framework/json-reports/clinical-reminder-report.json @@ -87,6 +87,14 @@ "joinCondition": "mwl.person_id = pre_s.person_id " } }, + { + "table": "(SELECT ps.* FROM etl.pre_appointment_summary ps JOIN ( SELECT MAX(encounter_datetime) AS max_encounter_datetime, person_id FROM etl.pre_appointment_summary GROUP BY person_id ) latest_dates ON ps.encounter_datetime = latest_dates.max_encounter_datetime AND ps.person_id = latest_dates.person_id)", + "alias": "pre_u", + "join": { + "type": "LEFT", + "joinCondition": "pre_s.person_id = pre_u.person_id" + } + }, { "table": "amrs.relationship", "alias": "t6", @@ -346,12 +354,12 @@ { "type": "simple_column", "alias": "reschedule_appointment", - "column": "pre_s.reschedule_appointment" + "column": "pre_u.reschedule_appointment" }, { "type": "simple_column", "alias": "rescheduled_date", - "column": "pre_s.rescheduled_date" + "column": "pre_u.rescheduled_date" }, { "type": "simple_column", diff --git a/service/patient-reminder.service.js b/service/patient-reminder.service.js index 171903719..caa1530af 100755 --- a/service/patient-reminder.service.js +++ b/service/patient-reminder.service.js @@ -985,24 +985,11 @@ function generateAppointmentNoShowUpRiskReminder(data) { return reminders; } -function datesWithinPrediction(encounterDate, predictionDate) { - const timeDifference = Math.abs(encounterDate - predictionDate); - const millisecondsInTwoWeeks = 2 * 7 * 24 * 60 * 60 * 1000; - - return timeDifference <= millisecondsInTwoWeeks; -} - function generateAppointmentRescheduledReminder(data) { let reminders = []; if (data.reschedule_appointment && data.reschedule_appointment === 'YES') { - if ( - data.last_encounter_date < data.prediction_generated_date && - datesWithinPrediction( - data.last_encounter_date, - data.prediction_generated_date - ) - ) { + if (data.last_encounter_date < data.prediction_generated_date) { reminders.push({ message: 'Promised to come date is ' +