From 621c57500f431837ba1aedb24111057f6ac109b8 Mon Sep 17 00:00:00 2001 From: Alfred Mutai <124869802+Alfred-Mutai@users.noreply.github.com> Date: Tue, 26 Sep 2023 13:14:58 +0300 Subject: [PATCH] Corrected current vl mismatch of VL on summary (#1330) * Corrected current vl mismatch of VL on summary * Updated latest vl fetch query across etl --- app/reporting-framework/hiv/moh-731.report.js | 2 +- .../json-reports/clinical-reminder-report.json | 2 +- app/reporting-framework/json-reports/patient-list-template.json | 2 +- .../json-reports/patient-list-with-contacts-template.json | 2 +- app/reporting-framework/json-reports/surge-report-base.json | 2 +- .../json-reports/tb-preventive-dataset-base.json | 2 +- dao/patient/etl-patient-dao.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/reporting-framework/hiv/moh-731.report.js b/app/reporting-framework/hiv/moh-731.report.js index 81e681672..135f8b5b5 100755 --- a/app/reporting-framework/hiv/moh-731.report.js +++ b/app/reporting-framework/hiv/moh-731.report.js @@ -15,7 +15,7 @@ export class Moh731Report extends MultiDatasetPatientlistReport { } params.hivMonthlyDatasetSource = 'etl.hiv_monthly_report_dataset_frozen'; // defaults to frozen params.hivVlDataSource = - '(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.encounter_id = max_dates.encounter_id)'; + '(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date)'; console.log('creating new moh 731 report service'); super(reportName, params); } diff --git a/app/reporting-framework/json-reports/clinical-reminder-report.json b/app/reporting-framework/json-reports/clinical-reminder-report.json index af6355db0..9a6dd239b 100644 --- a/app/reporting-framework/json-reports/clinical-reminder-report.json +++ b/app/reporting-framework/json-reports/clinical-reminder-report.json @@ -16,7 +16,7 @@ "alias": "t1" }, { - "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.encounter_id = max_dates.encounter_id)", + "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date)", "alias": "fli", "join": { "type": "LEFT", diff --git a/app/reporting-framework/json-reports/patient-list-template.json b/app/reporting-framework/json-reports/patient-list-template.json index f1c439de7..d7356dcc8 100755 --- a/app/reporting-framework/json-reports/patient-list-template.json +++ b/app/reporting-framework/json-reports/patient-list-template.json @@ -9,7 +9,7 @@ "alias": "t1" }, { - "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.encounter_id = max_dates.encounter_id)", + "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date)", "alias": "fli", "join": { "type": "LEFT", diff --git a/app/reporting-framework/json-reports/patient-list-with-contacts-template.json b/app/reporting-framework/json-reports/patient-list-with-contacts-template.json index 2d1536f60..7bfd4e81b 100755 --- a/app/reporting-framework/json-reports/patient-list-with-contacts-template.json +++ b/app/reporting-framework/json-reports/patient-list-with-contacts-template.json @@ -9,7 +9,7 @@ "alias": "t1" }, { - "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.encounter_id = max_dates.encounter_id)", + "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date)", "alias": "fli", "join": { "type": "LEFT", diff --git a/app/reporting-framework/json-reports/surge-report-base.json b/app/reporting-framework/json-reports/surge-report-base.json index aa3716467..50993a1e9 100644 --- a/app/reporting-framework/json-reports/surge-report-base.json +++ b/app/reporting-framework/json-reports/surge-report-base.json @@ -10,7 +10,7 @@ "alias": "srb" }, { - "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.encounter_id = max_dates.encounter_id)", + "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date)", "alias": "fli", "join": { "type": "LEFT", diff --git a/app/reporting-framework/json-reports/tb-preventive-dataset-base.json b/app/reporting-framework/json-reports/tb-preventive-dataset-base.json index 8192b329a..e960e0a15 100644 --- a/app/reporting-framework/json-reports/tb-preventive-dataset-base.json +++ b/app/reporting-framework/json-reports/tb-preventive-dataset-base.json @@ -10,7 +10,7 @@ "alias": "hmsd" }, { - "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.encounter_id = max_dates.encounter_id)", + "table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date)", "alias": "fli", "join": { "type": "LEFT", diff --git a/dao/patient/etl-patient-dao.js b/dao/patient/etl-patient-dao.js index 328e4b6a3..63c677804 100755 --- a/dao/patient/etl-patient-dao.js +++ b/dao/patient/etl-patient-dao.js @@ -38,7 +38,7 @@ module.exports = (function () { 't1.encounter_id = t3.encounter_id' ], [ - '(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN ( SELECT person_id, MAX(test_datetime) AS max_vl_1_date, max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id ) max_dates ON fli.person_id = max_dates.person_id AND fli.encounter_id = max_dates.encounter_id)', + '(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN ( SELECT person_id, MAX(test_datetime) AS max_vl_1_date, max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id ) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date)', 'fli', 'fli.person_id = t1.person_id' ]