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 06932baeb..caa1530af 100755 --- a/service/patient-reminder.service.js +++ b/service/patient-reminder.service.js @@ -987,6 +987,7 @@ 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) { reminders.push({