Skip to content

Commit

Permalink
Merge pull request #380 from njorocs/KHP3-3313
Browse files Browse the repository at this point in the history
Addded referred column in hts_tests tables and dmls
  • Loading branch information
makombe authored Oct 12, 2023
2 parents e8b607b + ed52e60 commit 1261eba
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 @@ -1290,6 +1290,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 @@ -2556,6 +2556,7 @@ final_test_result,
syphillis_test_result,
patient_given_result,
couple_discordant,
referred,
referral_for,
referral_facility,
other_referral_facility,
Expand Down Expand Up @@ -2609,6 +2610,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 @@ -2632,7 +2634,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 @@ -1353,6 +1353,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 @@ -2610,6 +2610,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 @@ -2663,6 +2664,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 @@ -2686,7 +2688,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 @@ -2719,7 +2721,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 @@ -1263,6 +1263,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 @@ -2565,6 +2565,7 @@ final_test_result,
syphillis_test_result,
patient_given_result,
couple_discordant,
referred,
referral_for,
referral_facility,
other_referral_facility,
Expand Down Expand Up @@ -2619,6 +2620,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 @@ -2642,7 +2644,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 1261eba

Please sign in to comment.