From a46bab60231d094c4f7ec1ba643cd1843d5992ad Mon Sep 17 00:00:00 2001 From: b-ngongonda Date: Thu, 20 Feb 2025 09:37:19 +0200 Subject: [PATCH] MLW-1657: Add sickle cell encounter types to ncd diagnoses and visits tables --- .../malawi/schema/table/mw_ncd_visits.sql | 2 + .../import-into-mw-ncd-diagnoses.ktr | 2 +- .../transforms/import-into-mw-ncd-visits.ktr | 182 ++++++++++++++++-- 3 files changed, 167 insertions(+), 19 deletions(-) diff --git a/jobs/pentaho/malawi/schema/table/mw_ncd_visits.sql b/jobs/pentaho/malawi/schema/table/mw_ncd_visits.sql index 19174ee..34a0d2f 100755 --- a/jobs/pentaho/malawi/schema/table/mw_ncd_visits.sql +++ b/jobs/pentaho/malawi/schema/table/mw_ncd_visits.sql @@ -21,6 +21,8 @@ create table mw_ncd_visits ( chf_followup BOOLEAN, ncd_other_initial BOOLEAN, ncd_other_followup BOOLEAN, + sickle_cell_initial BOOLEAN, + sickle_cell_followup BOOLEAN, next_appointment_date DATE, systolic_bp DECIMAL(10,2), diastolic_bp DECIMAL(10,2), diff --git a/jobs/pentaho/malawi/transforms/import-into-mw-ncd-diagnoses.ktr b/jobs/pentaho/malawi/transforms/import-into-mw-ncd-diagnoses.ktr index 9a39fa3..6322ab3 100755 --- a/jobs/pentaho/malawi/transforms/import-into-mw-ncd-diagnoses.ktr +++ b/jobs/pentaho/malawi/transforms/import-into-mw-ncd-diagnoses.ktr @@ -726,7 +726,7 @@ from omrs_obs o where o.concept = "Chronic care diagnosis" and encounter_type IN ("DIABETES HYPERTENSION INITIAL VISIT","CHRONIC_CARE_INITIAL", "MENTAL_HEALTH_INITIAL","EPILEPSY_INITIAL","CKD_INITIAL","CHF_INITIAL", -"NCD_OTHER_INITIAL","ASTHMA_INITIAL") +"NCD_OTHER_INITIAL","ASTHMA_INITIAL","SICKLE_CELL_DISEASE_INITIAL") order by patient_id, obs_group_id, encounter_type, location 0 diff --git a/jobs/pentaho/malawi/transforms/import-into-mw-ncd-visits.ktr b/jobs/pentaho/malawi/transforms/import-into-mw-ncd-visits.ktr index 656a7a6..a0fa6be 100755 --- a/jobs/pentaho/malawi/transforms/import-into-mw-ncd-visits.ktr +++ b/jobs/pentaho/malawi/transforms/import-into-mw-ncd-visits.ktr @@ -458,6 +458,8 @@ chf_followup BOOLEAN, ncd_other_initial BOOLEAN, ncd_other_followup BOOLEAN, + sickle_cell_initial BOOLEAN, + sickle_cell_followup BOOLEAN, next_appointment_date DATE, systolic_bp DOUBLE, diastolic_bp DOUBLE, @@ -468,7 +470,7 @@ 976 80 452 - 503 + 537 Ubuntu 11 N @@ -943,6 +945,12 @@ var chf_initial = visit_types.indexOf('CHF_INITIAL') != -1; var chf_followup = visit_types.indexOf('CHF_FOLLOWUP') != -1; var ncd_other_initial = visit_types.indexOf('NCD_OTHER_INITIAL') != -1; var ncd_other_followup = visit_types.indexOf('NCD_OTHER_FOLLOWUP') != -1; +var sickle_cell_initial = visit_types.indexOf('SICKLE_CELL_DISEASE_INITIAL') != -1; +var sickle_cell_followup = visit_types.indexOf('SICKLE_CELL_DISEASE_FOLLOWUP') != -1; + + + + @@ -1155,6 +1163,150 @@ var ncd_other_followup = visit_types.indexOf('NCD_OTHER_FOLLOWUP') != -1; -1 N + + cc_initial + cc_initial + Boolean + -1 + -1 + N + + + cc_followup + cc_followup + Boolean + -1 + -1 + N + + + diabetes_htn_initial + diabetes_htn_initial + Boolean + -1 + -1 + N + + + diabetes_htn_followup + diabetes_htn_followup + Boolean + -1 + -1 + N + + + asthma_initial + asthma_initial + Boolean + -1 + -1 + N + + + asthma_followup + asthma_followup + Boolean + -1 + -1 + N + + + epilepsy_initial + epilepsy_initial + Boolean + -1 + -1 + N + + + epilepsy_followup + epilepsy_followup + Boolean + -1 + -1 + N + + + mental_health_initial + mental_health_initial + Boolean + -1 + -1 + N + + + mental_health_followup + mental_health_followup + Boolean + -1 + -1 + N + + + ckd_initial + ckd_initial + Boolean + -1 + -1 + N + + + ckd_followup + ckd_followup + Boolean + -1 + -1 + N + + + chf_initial + chf_initial + Boolean + -1 + -1 + N + + + chf_followup + chf_followup + Boolean + -1 + -1 + N + + + ncd_other_initial + ncd_other_initial + Boolean + -1 + -1 + N + + + ncd_other_followup + ncd_other_followup + Boolean + -1 + -1 + N + + + sickle_cell_initial + sickle_cell_initial + Boolean + -1 + -1 + N + + + sickle_cell_followup + sickle_cell_followup + Boolean + -1 + -1 + N + @@ -1718,7 +1870,9 @@ where e.encounter_type in ( 'CHF_INITIAL', 'CHF_FOLLOWUP', 'NCD_OTHER_INITIAL', - 'NCD_OTHER_FOLLOWUP' + 'NCD_OTHER_FOLLOWUP', + 'SICKLE_CELL_DISEASE_INITIAL', + 'SICKLE_CELL_DISEASE_FOLLOWUP' ) group by e.patient_id, e.encounter_date, e.location @@ -2920,6 +3074,14 @@ order by patient_id, visit_date, location ncd_other_followup ncd_other_followup + + sickle_cell_initial + sickle_cell_initial + + + sickle_cell_followup + sickle_cell_followup + next_appointment_date next_appointment_date @@ -2992,22 +3154,6 @@ order by patient_id, visit_date, location num_seizures num_seizures - - seizure_activity - seizure_activity_since_last_visit - - - hospitalized_since_last_visit - hospitalized - - - hiv_result - hiv_test_result - - - foot_check - foot_exam -