From ed52e60663db3ab95b88431f19c5007622e6da44 Mon Sep 17 00:00:00 2001 From: njorocs Date: Mon, 25 Sep 2023 07:57:26 +0300 Subject: [PATCH] Addded referred column in hts_tests tables and dmls --- omod/src/main/resources/sql/DDL.sql | 1 + omod/src/main/resources/sql/DML.sql | 4 +++- omod/src/main/resources/sql/DataTools.sql | 1 + omod/src/main/resources/sql/Scheduled_Updates.sql | 6 ++++-- omod/src/main/resources/sql/dwapi/DDL.sql | 1 + omod/src/main/resources/sql/dwapi/DML.sql | 4 +++- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/omod/src/main/resources/sql/DDL.sql b/omod/src/main/resources/sql/DDL.sql index 61f2b985..5d9ef85b 100644 --- a/omod/src/main/resources/sql/DDL.sql +++ b/omod/src/main/resources/sql/DDL.sql @@ -1285,6 +1285,7 @@ final_test_result VARCHAR(50) DEFAULT NULL, syphillis_test_result VARCHAR(50) DEFAULT NULL, patient_given_result VARCHAR(50) DEFAULT NULL, couple_discordant VARCHAR(100) DEFAULT NULL, +referred INT(10) DEFAULT NULL, referral_for VARCHAR(100) DEFAULT NULL, referral_facility VARCHAR(200) DEFAULT NULL, other_referral_facility VARCHAR(200) DEFAULT NULL, diff --git a/omod/src/main/resources/sql/DML.sql b/omod/src/main/resources/sql/DML.sql index 96142899..3241b78b 100644 --- a/omod/src/main/resources/sql/DML.sql +++ b/omod/src/main/resources/sql/DML.sql @@ -2548,6 +2548,7 @@ final_test_result, syphillis_test_result, patient_given_result, couple_discordant, +referred, referral_for, referral_facility, other_referral_facility, @@ -2601,6 +2602,7 @@ max(if(o.concept_id=159427,(case o.value_coded when 703 then "Positive" when 664 max(if(o.concept_id=299,(case o.value_coded when 1229 then "Positive" when 1228 then "Negative" else "" end),null)) as syphillis_test_result, max(if(o.concept_id=164848,(case o.value_coded when 1065 then "Yes" when 1066 then "No" else "" end),null)) as patient_given_result, max(if(o.concept_id=6096,(case o.value_coded when 1065 then "Yes" when 1066 then "No" else "" end),null)) as couple_discordant, +max(if(o.concept_id=165093,o.value_coded,null)) as referred, max(if(o.concept_id=1887,(case o.value_coded when 162082 then "Confirmatory test" when 162050 then "Comprehensive care center" when 164461 then "DBS for PCR" else "" end),null)) as referral_for, max(if(o.concept_id=160481,(case o.value_coded when 163266 then "This health facility" when 164407 then "Other health facility" else "" end),null)) as referral_facility, max(if(o.concept_id=161550,trim(o.value_text),null)) as other_referral_facility, @@ -2624,7 +2626,7 @@ from encounter e inner join person p on p.person_id=e.patient_id and p.voided=0 inner join form f on f.form_id=e.form_id and f.uuid in ("402dc5d7-46da-42d4-b2be-f43ea4ad87b0","b08471f6-0892-4bf7-ab2b-bf79797b8ea4") inner join obs o on o.encounter_id = e.encounter_id and o.concept_id in (162084, 164930, 160581, 164401, 164951, 162558,160632, 1710, 164959, 164956, - 160540,159427, 164848, 6096, 1659, 164952, 163042, 159813,165215,163556,161550,1887,1272,164359,160481,229,167163,167162) + 160540,159427, 164848, 6096, 1659, 164952, 163042, 159813,165215,163556,161550,1887,1272,164359,160481,229,167163,167162,165093) inner join ( select o.person_id, diff --git a/omod/src/main/resources/sql/DataTools.sql b/omod/src/main/resources/sql/DataTools.sql index d316b72e..c5a56bee 100644 --- a/omod/src/main/resources/sql/DataTools.sql +++ b/omod/src/main/resources/sql/DataTools.sql @@ -1349,6 +1349,7 @@ t.hts_risk_score, t.syphillis_test_result, t.patient_given_result, t.couple_discordant, + case t.referred when 1065 then 'Yes' when 1066 then 'No' end as referred, t.referral_for, t.referral_facility, t.other_referral_facility, diff --git a/omod/src/main/resources/sql/Scheduled_Updates.sql b/omod/src/main/resources/sql/Scheduled_Updates.sql index 202b2250..459c9451 100644 --- a/omod/src/main/resources/sql/Scheduled_Updates.sql +++ b/omod/src/main/resources/sql/Scheduled_Updates.sql @@ -2601,6 +2601,7 @@ CREATE PROCEDURE sp_update_hts_test(IN last_update_time DATETIME) syphillis_test_result, patient_given_result, couple_discordant, + referred, referral_for, referral_facility, other_referral_facility, @@ -2654,6 +2655,7 @@ CREATE PROCEDURE sp_update_hts_test(IN last_update_time DATETIME) max(if(o.concept_id=299,(case o.value_coded when 1229 then "Positive" when 1228 then "Negative" else "" end),null)) as syphillis_test_result, max(if(o.concept_id=164848,(case o.value_coded when 1065 then "Yes" when 1066 then "No" else null end),null)) as patient_given_result, max(if(o.concept_id=6096,(case o.value_coded when 1065 then "Yes" when 1066 then "No" else null end),null)) as couple_discordant, + max(if(o.concept_id=165093,o.value_coded,null)) as referred, max(if(o.concept_id=1887,(case o.value_coded when 162082 then "Confirmatory test" when 162050 then "Comprehensive care center" when 164461 then "DBS for PCR" else "" end),null)) as referral_for, max(if(o.concept_id=160481,(case o.value_coded when 163266 then "This health facility" when 164407 then "Other health facility" else "" end),null)) as referral_facility, max(if(o.concept_id=161550,trim(o.value_text),null)) as other_referral_facility, @@ -2677,7 +2679,7 @@ CREATE PROCEDURE sp_update_hts_test(IN last_update_time DATETIME) inner join person p on p.person_id=e.patient_id and p.voided=0 inner join form f on f.form_id=e.form_id and f.uuid in ("402dc5d7-46da-42d4-b2be-f43ea4ad87b0","b08471f6-0892-4bf7-ab2b-bf79797b8ea4") inner join obs o on o.encounter_id = e.encounter_id and o.voided=0 and o.concept_id in (162084, 164930, 160581, 164401, 164951, 162558,160632, 1710, 164959, 164956, - 159427, 164848, 6096, 1659, 164952, 163042, 159813,165215,163556,161550,1887,1272,164359,160481,299,167163,167162) + 159427, 164848, 6096, 1659, 164952, 163042, 159813,165215,163556,161550,1887,1272,164359,160481,299,167163,167162,165093) inner join ( select o.person_id, @@ -2710,7 +2712,7 @@ CREATE PROCEDURE sp_update_hts_test(IN last_update_time DATETIME) test_1_kit_name=VALUES(test_1_kit_name), test_1_kit_lot_no=VALUES(test_1_kit_lot_no), test_1_kit_expiry=VALUES(test_1_kit_expiry), test_1_result=VALUES(test_1_result), test_2_kit_name=VALUES(test_2_kit_name), test_2_kit_lot_no=VALUES(test_2_kit_lot_no), test_2_kit_expiry=VALUES(test_2_kit_expiry), test_2_result=VALUES(test_2_result), - final_test_result=VALUES(final_test_result), patient_given_result=VALUES(patient_given_result), couple_discordant=VALUES(couple_discordant), + final_test_result=VALUES(final_test_result), patient_given_result=VALUES(patient_given_result), couple_discordant=VALUES(couple_discordant),referred=VALUES(referred), tb_screening=VALUES(tb_screening), neg_referral_for=VALUES(neg_referral_for), patient_had_hiv_self_test=VALUES(patient_had_hiv_self_test), remarks=VALUES(remarks), voided=VALUES(voided) ; diff --git a/omod/src/main/resources/sql/dwapi/DDL.sql b/omod/src/main/resources/sql/dwapi/DDL.sql index 060e8d48..fa3787b4 100644 --- a/omod/src/main/resources/sql/dwapi/DDL.sql +++ b/omod/src/main/resources/sql/dwapi/DDL.sql @@ -1259,6 +1259,7 @@ final_test_result VARCHAR(50) DEFAULT NULL, syphillis_test_result VARCHAR(50) DEFAULT NULL, patient_given_result VARCHAR(50) DEFAULT NULL, couple_discordant VARCHAR(100) DEFAULT NULL, +referred INT(10) DEFAULT NULL, referral_for VARCHAR(100) DEFAULT NULL, referral_facility VARCHAR(200) DEFAULT NULL, other_referral_facility VARCHAR(200) DEFAULT NULL, diff --git a/omod/src/main/resources/sql/dwapi/DML.sql b/omod/src/main/resources/sql/dwapi/DML.sql index 09e60316..5fdd4e84 100644 --- a/omod/src/main/resources/sql/dwapi/DML.sql +++ b/omod/src/main/resources/sql/dwapi/DML.sql @@ -2557,6 +2557,7 @@ final_test_result, syphillis_test_result, patient_given_result, couple_discordant, +referred, referral_for, referral_facility, other_referral_facility, @@ -2611,6 +2612,7 @@ max(if(o.concept_id=159427,(case o.value_coded when 703 then "Positive" when 664 max(if(o.concept_id=299,(case o.value_coded when 1229 then "Positive" when 1228 then "Negative" else "" end),null)) as syphillis_test_result, max(if(o.concept_id=164848,(case o.value_coded when 1065 then "Yes" when 1066 then "No" else "" end),null)) as patient_given_result, max(if(o.concept_id=6096,(case o.value_coded when 1065 then "Yes" when 1066 then "No" else "" end),null)) as couple_discordant, +max(if(o.concept_id=165093,o.value_coded,null)) as referred, max(if(o.concept_id=1887,(case o.value_coded when 162082 then "Confirmatory test" when 162050 then "Comprehensive care center" when 164461 then "DBS for PCR" else "" end),null)) as referral_for, max(if(o.concept_id=160481,(case o.value_coded when 163266 then "This health facility" when 164407 then "Other health facility" else "" end),null)) as referral_facility, max(if(o.concept_id=161550,trim(o.value_text),null)) as other_referral_facility, @@ -2634,7 +2636,7 @@ from encounter e inner join person p on p.person_id=e.patient_id inner join form f on f.form_id=e.form_id and f.uuid in ("402dc5d7-46da-42d4-b2be-f43ea4ad87b0","b08471f6-0892-4bf7-ab2b-bf79797b8ea4") inner join obs o on o.encounter_id = e.encounter_id and o.concept_id in (162084, 164930, 160581, 164401, 164951, 162558,160632, 1710, 164959, 164956, - 160540,159427, 164848, 6096, 1659, 164952, 163042, 159813,165215,163556,161550,1887,1272,164359,160481,229,167163,167162) + 160540,159427, 164848, 6096, 1659, 164952, 163042, 159813,165215,163556,161550,1887,1272,164359,160481,229,167163,167162,165093) inner join ( select o.person_id,