diff --git a/app/reporting-framework/json-reports/clinical-reminder-report.json b/app/reporting-framework/json-reports/clinical-reminder-report.json index c5e0f3be0..5b738f5f1 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", @@ -335,6 +343,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 74498f2b2..06932baeb 100755 --- a/service/patient-reminder.service.js +++ b/service/patient-reminder.service.js @@ -985,8 +985,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) { @@ -1028,6 +1047,9 @@ async function generateReminders(etlResults, eidResults) { let appointmentNoShowUpRiskReminder = generateAppointmentNoShowUpRiskReminder( data ); + let appointmentRescheduledRiskReminder = generateAppointmentRescheduledReminder( + data + ); let currentReminder = []; if (pending_vl_lab_result.length > 0) { @@ -1056,8 +1078,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;