Skip to content

Commit

Permalink
POC-544: added retention and vl column to patient list
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykorir committed Dec 2, 2023
1 parent ae3a46d commit ca9276a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
},
{
"table": "etl.hiv_monthly_report_dataset_v1_2",
"table": "etl.hiv_monthly_report_dataset_frozen",
"alias": "hm",
"join": {
"type": "INNER",
Expand All @@ -38,7 +38,7 @@
{
"type": "simple_column",
"alias": "endDate",
"column": "last_day(enc.encounter_datetime)"
"column": "hm.endDate"
},
{
"type": "simple_column",
Expand Down Expand Up @@ -141,27 +141,17 @@
"filters": {
"conditionJoinOperator": "AND",
"conditions": [
{
"filterType": "tableColumns",
"conditionExpression": "hm.endDate = ?",
"parameterName": "endDate"
},
{
"filterType": "tableColumns",
"conditionExpression": "loc.uuid IN ?",
"parameterName": "locationUuids"
},
{
"filterType": "tableColumns",
"conditionExpression": "obs.concept_id IN (9328,10239)"
},
{
"filterType": "tableColumns",
"conditionExpression": "obs.voided IN (0)"
"conditionExpression": "hm.on_art_this_month = 1"
},
{
"filterType": "tableColumns",
"conditionExpression": "hm.status = 'active'"
"conditionExpression": "obs.voided IN (0)"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"alias": "hypertensive_and_diabetic_comorbidity",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(IF((pnmrd.hypertensive_comorbidity = 1 AND pnmrd.diabetic_comorbidity = 1), 1, NULL))"
"expression": "SUM(pnmrd.hypertensive_and_diabetic_comorbidity)"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
{
"type": "simple_column",
"alias": "hypertensive_and_diabetic_comorbidity",
"column": "IF((pnmrb.hypertensive_comorbidity = 1 AND pnmrb.diabetic_comorbidity = 1), 1, NULL)"
"column": "IF(pnmrb.hypertensive_comorbidity = 1 AND pnmrb.diabetic_comorbidity = 1, 1, NULL)"
},
{
"type": "simple_column",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@
}
},
{
"table": "etl.flat_prep_summary_v1_1",
"alias": "fps",
"table": "amrs.person_address",
"alias": "pa",
"join": {
"type": "LEFT",
"joinCondition": "t1.person_id = fps.person_id AND fps.next_encounter_datetime IS NULL AND fps.encounter_type NOT IN (99999)"
"joinCondition": "t1.person_id = pa.person_id"
}
},
{
"table": "amrs.encounter_type",
"alias": "et",
"table": "etl.hiv_monthly_report_dataset_v1_2",
"alias": "hmrd",
"join": {
"type": "LEFT",
"joinCondition": "fps.encounter_type = et.encounter_type_id"
"joinCondition": "t1.person_id = hmrd.person_id"
}
},
{
"table": "amrs.person_address",
"alias": "pa",
"table": "(SELECT fli.person_id, fli.hiv_viral_load as vl_1, fli.test_datetime as vl_1_date FROM etl.flat_labs_and_imaging fli INNER JOIN (SELECT person_id, MAX(test_datetime) AS max_vl_1_date,max(encounter_id) as encounter_id FROM etl.flat_labs_and_imaging fli where fli.hiv_viral_load is not null GROUP BY person_id) max_dates ON fli.person_id = max_dates.person_id AND fli.test_datetime = max_dates.max_vl_1_date AND fli.encounter_id = max_dates.encounter_id)",
"alias": "vl",
"join": {
"type": "LEFT",
"joinCondition": "t1.person_id = pa.person_id"
"joinCondition": "hmrd.person_id = vl.person_id"
}
}
],
Expand Down Expand Up @@ -81,6 +81,16 @@
"alias": "gender",
"column": "t1.gender"
},
{
"type": "simple_column",
"alias": "status",
"column": "hmrd.status"
},
{
"type": "simple_column",
"alias": "enrollment_date",
"column": "date_format(hmrd.enrollment_date, '%Y-%m-%d')"
},
{
"type": "derived_column",
"alias": "person_name",
Expand Down Expand Up @@ -113,141 +123,35 @@
"expression": " GROUP_CONCAT(DISTINCT contacts.value SEPARATOR ', ')"
}
},
{
"type": "simple_column",
"alias": "cur_prep_meds",
"column": "fps.cur_prep_meds"
},
{
"type": "simple_column",
"alias": "cur_prep_meds_names",
"column": "fps.cur_prep_meds_names"
},
{
"type": "simple_column",
"alias": "inital_prep_start_date",
"column": "fps.inital_prep_start_date"
},
{
"type": "simple_column",
"alias": "initiation_reason",
"column": "fps.initiation_reason"
},
{
"type": "simple_column",
"alias": "discontinue_reason",
"column": "fps.discontinued_reason"
},
{
"type": "derived_column",
"alias": "population_type_category",
"expressionType": "case_statement",
"expressionOptions": {
"caseOptions": [
{
"condition": "fps.sub_population_type = 1",
"value": "MSM"
},
{
"condition": "fps.sub_population_type = 2",
"value": "MSW"
},
{
"condition": "fps.sub_population_type = 3",
"value": "FSW"
},
{
"condition": "fps.sub_population_type = 4",
"value": "IDU"
},
{
"condition": "fps.sub_population_type = 5",
"value": "TRANS WOMAN"
},
{
"condition": "fps.sub_population_type = 6",
"value": "TRANS MAN"
},
{
"condition": "fps.sub_population_type = 7",
"value": "FISHER FOLK"
},
{
"condition": "fps.sub_population_type = 8",
"value": "CSW"
},
{
"condition": "fps.sub_population_type = 9",
"value": "DISPLACED PERSONS"
},
{
"condition": "fps.sub_population_type = 10",
"value": "Military and other"
},
{
"condition": "fps.sub_population_type = 12",
"value": "TRUCK/LORRY DRIVER"
},
{
"condition": "fps.sub_population_type = 13",
"value": "NIDU"
}
]
}
},
{
"type": "simple_column",
"alias": "nearest_center",
"column": "pa.address3"
},
{
"type": "simple_column",
"alias": "enrollment_date",
"column": "date_format(fps.enrollment_date, '%Y-%m-%d')"
},
{
"type": "simple_column",
"alias": "death_date",
"column": "date_format(fps.death_date, '%Y-%m-%d')"
},
{
"type": "derived_column",
"alias": "hiv_rapid_test",
"alias": "vl_category",
"expressionType": "case_statement",
"expressionOptions": {
"caseOptions": [
{
"condition": "fps.hiv_rapid_test_result = 703",
"value": "Positive"
},
{
"condition": "fps.hiv_rapid_test_result = 664",
"value": "Negative"
"condition": "vl.vl_1 < 50",
"value": "LDL"
},
{
"condition": "fps.hiv_rapid_test_result = 1138",
"value": "Indeterminate"
"condition": "(vl.vl_1 >= 50 and vl.vl_1 < 200)",
"value": "Low Risk Low Level Viremia"
},
{
"condition": "fps.hiv_rapid_test_result = 1304",
"value": "Poor sample quality"
"condition": "(vl.vl_1 >= 200 and vl.vl_1 < 1000)",
"value": "High Risk Low Level Viremia"
},
{
"condition": "fps.hiv_rapid_test_result = 1067",
"value": "Unknown"
"condition": "(vl.vl_1 > 1000)",
"value": "Suspected Treatment Failure"
}
]
}
},
{
"type": "simple_column",
"alias": "rapid_test_date",
"column": "date_format(fps.hiv_rapid_test_date, '%Y-%m-%d')"
},
{
"type": "simple_column",
"alias": "turned_positive_date",
"column": "date_format(fps.turned_positive_date, '%Y-%m-%d')"
}
],
"groupBy": {
Expand Down

0 comments on commit ca9276a

Please sign in to comment.