Skip to content

Commit

Permalink
Addded referred column in hts_tests tables and dmls
Browse files Browse the repository at this point in the history
  • Loading branch information
njorocs committed Sep 25, 2023
1 parent 6329d67 commit ed52e60
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions omod/src/main/resources/sql/DDL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion omod/src/main/resources/sql/DML.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2548,6 +2548,7 @@ final_test_result,
syphillis_test_result,
patient_given_result,
couple_discordant,
referred,
referral_for,
referral_facility,
other_referral_facility,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions omod/src/main/resources/sql/DataTools.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions omod/src/main/resources/sql/Scheduled_Updates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
;
Expand Down
1 change: 1 addition & 0 deletions omod/src/main/resources/sql/dwapi/DDL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion omod/src/main/resources/sql/dwapi/DML.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,7 @@ final_test_result,
syphillis_test_result,
patient_given_result,
couple_discordant,
referred,
referral_for,
referral_facility,
other_referral_facility,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit ed52e60

Please sign in to comment.