From 0cd7be6c97788a476f7e3228e4726b86ea6f6869 Mon Sep 17 00:00:00 2001 From: Saningo Lekalantula Date: Thu, 5 Oct 2023 10:31:03 +0300 Subject: [PATCH] POC-522 (#1328) * Add query to generate line list with no intervention done on the defaulters list report * Update line list query * POC-522: Add column outreach follow-up to defaulter list * Remove unwanted columns --------- Co-authored-by: kantush Co-authored-by: Drizzentic --- .../json-reports/defaulter-list-base.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/reporting-framework/json-reports/defaulter-list-base.json b/app/reporting-framework/json-reports/defaulter-list-base.json index 27c3363c8..7273b4c10 100644 --- a/app/reporting-framework/json-reports/defaulter-list-base.json +++ b/app/reporting-framework/json-reports/defaulter-list-base.json @@ -14,7 +14,15 @@ "alias": "de", "join": { "type": "LEFT", - "joinCondition": "de.encounter_id = fd.encounter_id" + "joinCondition": "de.encounter_id = fd.encounter_id " + } + }, + { + "table": "(SELECT MAX(am.encounter_datetime) AS max_encounter_datetime, am.encounter_datetime, am.encounter_type, am.patient_id, fd.person_id , fd.rtc_date FROM etl.flat_defaulters fd INNER JOIN amrs.encounter am on (am.patient_id = fd.person_id) WHERE am.encounter_type = 21 group by am.patient_id)", + "alias": "am", + "join": { + "type": "INNER", + "joinCondition": "am.patient_id = fd.person_id" } }, { @@ -82,6 +90,14 @@ "type": "simple_column", "alias": "rtc_date", "column": "DATE_FORMAT(fd.rtc_date,'%Y-%m-%d')" + }, + { + "type": "derived_column", + "alias": "outreach_follow_up", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "case when max_encounter_datetime >= fd.rtc_date then 'Yes' else 'No' end" + } } ], "filters": {