From 001a0c7bd0cf9b5fb96b0b8c34fa85ee44422573 Mon Sep 17 00:00:00 2001 From: Angie-540 Date: Wed, 15 Nov 2023 16:26:28 +0300 Subject: [PATCH] added reminders for patients who wish to reschedule appointments --- .../clinical-reminder-report.json | 18 +++++++++++ service/patient-reminder.service.js | 31 +++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/reporting-framework/json-reports/clinical-reminder-report.json b/app/reporting-framework/json-reports/clinical-reminder-report.json index af46abd99..3b538c3d4 100644 --- a/app/reporting-framework/json-reports/clinical-reminder-report.json +++ b/app/reporting-framework/json-reports/clinical-reminder-report.json @@ -79,6 +79,14 @@ "joinCondition": "mwl.person_id = t1.person_id" } }, + { + "table": "etl.pre_appointment_summary", + "alias": "pre_s", + "join": { + "type": "left", + "joinCondition": "mwl.person_id = pre_s.person_id " + } + }, { "table": "amrs.relationship", "alias": "t6", @@ -305,6 +313,16 @@ "alias": "prediction_generated_date", "column": "mwl.prediction_generated_date" }, + { + "type": "simple_column", + "alias": "reschedule_appointment", + "column": "pre_s.reschedule_appointment" + }, + { + "type": "simple_column", + "alias": "rescheduled_date", + "column": "pre_s.rescheduled_date" + }, { "type": "simple_column", "alias": "test_date", diff --git a/service/patient-reminder.service.js b/service/patient-reminder.service.js index f52fd9f7b..ce3e266c3 100755 --- a/service/patient-reminder.service.js +++ b/service/patient-reminder.service.js @@ -1001,8 +1001,27 @@ function generateAppointmentNoShowUpRiskReminder(data) { return reminders; } +function generateAppointmentRescheduledReminder(data) { + let reminders = []; + if (data.reschedule_appointment && data.reschedule_appointment === 'YES') { + if (data.last_encounter_date < data.prediction_generated_date) { + reminders.push({ + message: + 'Promised to come date is ' + + Moment(data.rescheduled_date).format('DD-MM-YYYY'), + title: 'Appointment reschedule request', + type: 'ml', + display: { + banner: true, + toast: true + } + }); + } + } + return reminders; +} + async function generateReminders(etlResults, eidResults) { - // console.log('REMINDERS generateReminders'); let reminders = []; let patientReminder; if (etlResults && etlResults.length > 0) { @@ -1044,6 +1063,9 @@ async function generateReminders(etlResults, eidResults) { let appointmentNoShowUpRiskReminder = generateAppointmentNoShowUpRiskReminder( data ); + let appointmentRescheduledRiskReminder = generateAppointmentRescheduledReminder( + data + ); let currentReminder = []; if (pending_vl_lab_result.length > 0) { @@ -1072,8 +1094,11 @@ async function generateReminders(etlResults, eidResults) { reminders = reminders.concat(currentReminder); - // Add appointment no show up risk reminder - reminders = reminders.concat(appointmentNoShowUpRiskReminder); + // Add appointment no show up risk reminder and + reminders = reminders.concat( + appointmentNoShowUpRiskReminder, + appointmentRescheduledRiskReminder + ); patientReminder.reminders = reminders; return patientReminder;