From e61f48effb4235ebad834ab4ef145873b58d8eda Mon Sep 17 00:00:00 2001 From: njorocs Date: Wed, 7 Aug 2024 15:21:20 +0300 Subject: [PATCH] Added mode of temperature collection and mode of oxygen saturation collection in triage etl --- omod/src/main/resources/sql/DDL.sql | 2 ++ omod/src/main/resources/sql/DML.sql | 6 +++++- omod/src/main/resources/sql/DataTools.sql | 2 ++ omod/src/main/resources/sql/Scheduled_Updates.sql | 8 ++++++-- omod/src/main/resources/sql/dwapi/DDL.sql | 2 ++ omod/src/main/resources/sql/dwapi/DML.sql | 6 +++++- 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/omod/src/main/resources/sql/DDL.sql b/omod/src/main/resources/sql/DDL.sql index 19313cbf..d32c019c 100644 --- a/omod/src/main/resources/sql/DDL.sql +++ b/omod/src/main/resources/sql/DDL.sql @@ -1605,9 +1605,11 @@ SELECT "Successfully created etl_ART_preparation table"; systolic_pressure DOUBLE, diastolic_pressure DOUBLE, temperature DOUBLE, + temperature_collection_mode INT(11), pulse_rate DOUBLE, respiratory_rate DOUBLE, oxygen_saturation DOUBLE, + oxygen_saturation_collection_mode INT(11), muac DOUBLE, z_score_absolute DOUBLE DEFAULT NULL, z_score INT(11), diff --git a/omod/src/main/resources/sql/DML.sql b/omod/src/main/resources/sql/DML.sql index f4b2668e..6548f5d8 100644 --- a/omod/src/main/resources/sql/DML.sql +++ b/omod/src/main/resources/sql/DML.sql @@ -3440,9 +3440,11 @@ CREATE PROCEDURE sp_populate_etl_patient_triage() systolic_pressure, diastolic_pressure, temperature, + temperature_collection_mode, pulse_rate, respiratory_rate, oxygen_saturation, + oxygen_saturation_collection_mode, muac, z_score_absolute, z_score, @@ -3470,9 +3472,11 @@ CREATE PROCEDURE sp_populate_etl_patient_triage() max(if(o.concept_id=5085,o.value_numeric,null)) as systolic_pressure, max(if(o.concept_id=5086,o.value_numeric,null)) as diastolic_pressure, max(if(o.concept_id=5088,o.value_numeric,null)) as temperature, + max(if(o.concept_id=167231,o.value_coded,null)) as temperature_collection_mode, max(if(o.concept_id=5087,o.value_numeric,null)) as pulse_rate, max(if(o.concept_id=5242,o.value_numeric,null)) as respiratory_rate, max(if(o.concept_id=5092,o.value_numeric,null)) as oxygen_saturation, + max(if(o.concept_id=165932,o.value_coded,null)) as oxygen_saturation_collection_mode, max(if(o.concept_id=1343,o.value_numeric,null)) as muac, max(if(o.concept_id=162584,o.value_numeric,null)) as z_score_absolute, max(if(o.concept_id=163515,o.value_coded,null)) as z_score, @@ -3489,7 +3493,7 @@ CREATE PROCEDURE sp_populate_etl_patient_triage() select encounter_type_id, uuid, name from encounter_type where uuid in('d1059fb9-a079-4feb-a749-eedd709ae542','a0034eee-1940-4e35-847f-97537a35d05e','465a92f2-baf8-42e9-9612-53064be868e8') ) et on et.encounter_type_id=e.encounter_type left outer join obs o on o.encounter_id=e.encounter_id and o.voided=0 - and o.concept_id in (160430,1154,159368,5089,5090,5085,5086,5088,5087,5242,5092,1343,163515,167392,1427,160325,162584,163304) + and o.concept_id in (160430,1154,159368,5089,5090,5085,5086,5088,5087,5242,5092,1343,163515,167392,1427,160325,162584,163304,167231,165932) where e.voided=0 group by e.patient_id, visit_date ; diff --git a/omod/src/main/resources/sql/DataTools.sql b/omod/src/main/resources/sql/DataTools.sql index fb39e18e..0a2050ec 100644 --- a/omod/src/main/resources/sql/DataTools.sql +++ b/omod/src/main/resources/sql/DataTools.sql @@ -1225,9 +1225,11 @@ SELECT "Successfully created enhanced adherence table"; systolic_pressure, diastolic_pressure, temperature, + case temperature_collection_mode when 5112 then 'Axiliary' when 166242 then 'Forehead thermometer gun' when 160240 then 'Oral' end as temperature_collection_mode, pulse_rate, respiratory_rate, oxygen_saturation, + case oxygen_saturation_collection_mode when 162735 then 'Room air' when 162738 then 'On supplemental oxygen' end as oxygen_saturation_collection_mode, muac, z_score_absolute, (case z_score when 1115 then "Normal (Median)" when 123814 then "Mild (-1 SD)" when 123815 then "Moderate (-2 SD)" when 164131 then "Severe (-3 SD and -4 SD)" else "" end) as z_score, diff --git a/omod/src/main/resources/sql/Scheduled_Updates.sql b/omod/src/main/resources/sql/Scheduled_Updates.sql index b95ad2ae..df51fefc 100644 --- a/omod/src/main/resources/sql/Scheduled_Updates.sql +++ b/omod/src/main/resources/sql/Scheduled_Updates.sql @@ -3366,9 +3366,11 @@ CREATE PROCEDURE sp_update_etl_patient_triage(IN last_update_time DATETIME) systolic_pressure, diastolic_pressure, temperature, + temperature_collection_mode, pulse_rate, respiratory_rate, oxygen_saturation, + oxygen_saturation_collection_mode, muac, z_score_absolute, z_score, @@ -3396,9 +3398,11 @@ CREATE PROCEDURE sp_update_etl_patient_triage(IN last_update_time DATETIME) max(if(o.concept_id=5085,o.value_numeric,null)) as systolic_pressure, max(if(o.concept_id=5086,o.value_numeric,null)) as diastolic_pressure, max(if(o.concept_id=5088,o.value_numeric,null)) as temperature, + max(if(o.concept_id=167231,o.value_coded,null)) as temperature_collection_mode, max(if(o.concept_id=5087,o.value_numeric,null)) as pulse_rate, max(if(o.concept_id=5242,o.value_numeric,null)) as respiratory_rate, max(if(o.concept_id=5092,o.value_numeric,null)) as oxygen_saturation, + max(if(o.concept_id=165932,o.value_coded,null)) as oxygen_saturation_collection_mode, max(if(o.concept_id=1343,o.value_numeric,null)) as muac, max(if(o.concept_id=162584,o.value_numeric,null)) as z_score_absolute, max(if(o.concept_id=163515,o.value_coded,null)) as z_score, @@ -3414,7 +3418,7 @@ CREATE PROCEDURE sp_update_etl_patient_triage(IN last_update_time DATETIME) select encounter_type_id, uuid, name from encounter_type where uuid in('d1059fb9-a079-4feb-a749-eedd709ae542','a0034eee-1940-4e35-847f-97537a35d05e','465a92f2-baf8-42e9-9612-53064be868e8') ) et on et.encounter_type_id=e.encounter_type left outer join obs o on o.encounter_id=e.encounter_id and o.voided=0 - and o.concept_id in (160430,5089,5090,5085,5086,5088,5087,5242,5092,1343,163515,167392,1427,160325,162584,1154,159368,163304) + and o.concept_id in (160430,5089,5090,5085,5086,5088,5087,5242,5092,1343,163515,167392,1427,160325,162584,1154,159368,163304,167231,165932) where e.voided=0 and e.date_created >= last_update_time or e.date_changed >= last_update_time or e.date_voided >= last_update_time @@ -3423,7 +3427,7 @@ CREATE PROCEDURE sp_update_etl_patient_triage(IN last_update_time DATETIME) group by e.patient_id, visit_date ON DUPLICATE KEY UPDATE visit_date=VALUES(visit_date),encounter_provider=VALUES(encounter_provider),weight=VALUES(weight),height=VALUES(height),systolic_pressure=VALUES(systolic_pressure),diastolic_pressure=VALUES(diastolic_pressure), temperature=VALUES(temperature),pulse_rate=VALUES(pulse_rate),respiratory_rate=VALUES(respiratory_rate),complaint_today=VALUES(complaint_today),complaint_duration=VALUES(complaint_duration), - oxygen_saturation=VALUES(oxygen_saturation),muac=VALUES(muac),z_score=VALUES(z_score),nutritional_status=VALUES(nutritional_status),nutritional_intervention=VALUES(nutritional_intervention),last_menstrual_period=VALUES(last_menstrual_period),hpv_vaccinated=VALUES(hpv_vaccinated),voided=VALUES(voided),z_score_absolute=VALUES(z_score_absolute); + oxygen_saturation=VALUES(oxygen_saturation),muac=VALUES(muac),z_score=VALUES(z_score),nutritional_status=VALUES(nutritional_status),nutritional_intervention=VALUES(nutritional_intervention),last_menstrual_period=VALUES(last_menstrual_period),hpv_vaccinated=VALUES(hpv_vaccinated),voided=VALUES(voided),z_score_absolute=VALUES(z_score_absolute),oxygen_saturation_collection_mode=VALUES(oxygen_saturation_collection_mode),temperature_collection_mode=VALUES(temperature_collection_mode); END $$ -- ------------- populate etl_generalized_anxiety_disorder------------------------- diff --git a/omod/src/main/resources/sql/dwapi/DDL.sql b/omod/src/main/resources/sql/dwapi/DDL.sql index 86fb0a60..78703a0a 100644 --- a/omod/src/main/resources/sql/dwapi/DDL.sql +++ b/omod/src/main/resources/sql/dwapi/DDL.sql @@ -1580,9 +1580,11 @@ SELECT "Successfully created etl_ART_preparation table"; systolic_pressure DOUBLE, diastolic_pressure DOUBLE, temperature DOUBLE, + temperature_collection_mode INT(11), pulse_rate DOUBLE, respiratory_rate DOUBLE, oxygen_saturation DOUBLE, + oxygen_saturation_collection_mode INT(11), muac DOUBLE, z_score_absolute DOUBLE DEFAULT NULL, z_score INT(11), diff --git a/omod/src/main/resources/sql/dwapi/DML.sql b/omod/src/main/resources/sql/dwapi/DML.sql index ebd99da5..910c8b5f 100644 --- a/omod/src/main/resources/sql/dwapi/DML.sql +++ b/omod/src/main/resources/sql/dwapi/DML.sql @@ -3275,9 +3275,11 @@ CREATE PROCEDURE sp_populate_dwapi_patient_triage() systolic_pressure, diastolic_pressure, temperature, + temperature_collection_mode, pulse_rate, respiratory_rate, oxygen_saturation, + oxygen_saturation_collection_mode, muac, z_score_absolute, z_score, @@ -3305,9 +3307,11 @@ CREATE PROCEDURE sp_populate_dwapi_patient_triage() max(if(o.concept_id=5085,o.value_numeric,null)) as systolic_pressure, max(if(o.concept_id=5086,o.value_numeric,null)) as diastolic_pressure, max(if(o.concept_id=5088,o.value_numeric,null)) as temperature, + max(if(o.concept_id=167231,o.value_coded,null)) as temperature_collection_mode, max(if(o.concept_id=5087,o.value_numeric,null)) as pulse_rate, max(if(o.concept_id=5242,o.value_numeric,null)) as respiratory_rate, max(if(o.concept_id=5092,o.value_numeric,null)) as oxygen_saturation, + max(if(o.concept_id=165932,o.value_coded,null)) as oxygen_saturation_collection_mode, max(if(o.concept_id=1343,o.value_numeric,null)) as muac, max(if(o.concept_id=162584,o.value_numeric,null)) as z_score_absolute, max(if(o.concept_id=163515,o.value_coded,null)) as z_score, @@ -3324,7 +3328,7 @@ CREATE PROCEDURE sp_populate_dwapi_patient_triage() select encounter_type_id, uuid, name from encounter_type where uuid in('d1059fb9-a079-4feb-a749-eedd709ae542','a0034eee-1940-4e35-847f-97537a35d05e','465a92f2-baf8-42e9-9612-53064be868e8') ) et on et.encounter_type_id=e.encounter_type left outer join obs o on o.encounter_id=e.encounter_id and o.voided=0 - and o.concept_id in (160430,1154,159368,5089,5090,5085,5086,5088,5087,5242,5092,1343,163515,167392,1427,160325,162584) + and o.concept_id in (160430,1154,159368,5089,5090,5085,5086,5088,5087,5242,5092,1343,163515,167392,1427,160325,162584,163304,167231,165932) group by e.patient_id, visit_date ; SELECT "Completed processing Patient Triage data ", CONCAT("Time: ", NOW());