Skip to content

Commit

Permalink
Merge branch 'master' into POC-495
Browse files Browse the repository at this point in the history
  • Loading branch information
Angie-540 authored Nov 15, 2023
2 parents 001a0c7 + f39d96e commit 7df39d3
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@
"alias": "pre",
"join": {
"type": "LEFT",
"joinCondition": "pre.person_id = ml.person_id"
"joinCondition": "pre.person_id = ml.person_id and(DATEDIFF(ml.start_date, pre.encounter_datetime) <= 7)"
}
},

{
"table": "( select max(is_successful_phone_follow_up) as latest_phone_follow_up, person_id, follow_up_type from etl.pre_appointment_summary group by person_id )",
"alias": "s",
"join": {
"type": "LEFT",
"joinCondition": "pre.person_id = s.person_id"
}
}
],
Expand Down Expand Up @@ -180,12 +189,12 @@
},
{
"filterType": "tableColumns",
"conditionExpression": "(if((pre.is_successful_phone_follow_up = 'YES' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'YES')), 1, 0)) = ?",
"conditionExpression": "(if((latest_phone_follow_up = 'YES' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'YES')), 1, 0)) = ?",
"parameterName": "successfulOutcome"
},
{
"filterType": "tableColumns",
"conditionExpression": "(if((pre.is_successful_phone_follow_up = 'NO' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'NO')), 1, 0)) = ?",
"conditionExpression": "(if((latest_phone_follow_up = 'NO' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'NO')), 1, 0)) = ?",
"parameterName": "failedOutcome"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@
"type": "LEFT",
"joinCondition": "delivery_report.person_id = t1.person_id and DATE_FORMAT(delivery_report.date_created, '%Y-%m-%d')='{startDate}'"
}
},
{
"table": "etl.flat_prep_summary_v1_1",
"alias": "fps",
"join": {
"type": "LEFT",
"joinCondition": "t1.person_id = fps.person_id AND fps.next_encounter_datetime IS NULL AND fps.encounter_type NOT IN (99999)"
}
}
],
"columns": [
Expand Down Expand Up @@ -142,6 +150,112 @@
"expression": "extract(year from (from_days(datediff(now(),t1.birthdate))))"
}
},
{
"type": "simple_column",
"alias": "prev_rtc_date",
"column": "date_format(fps.prev_rtc_date, '%Y-%m-%d')"
},
{
"type": "simple_column",
"alias": "cur_prep_meds_names",
"column": "fps.cur_prep_meds_names"
},
{
"type": "simple_column",
"alias": "rapid_test_date",
"column": "date_format(fps.hiv_rapid_test_date, '%Y-%m-%d')"
},
{
"type": "derived_column",
"alias": "hiv_rapid_test",
"expressionType": "case_statement",
"expressionOptions": {
"caseOptions": [
{
"condition": "fps.hiv_rapid_test_result = 703",
"value": "Positive"
},
{
"condition": "fps.hiv_rapid_test_result = 664",
"value": "Negative"
},
{
"condition": "fps.hiv_rapid_test_result = 1138",
"value": "Indeterminate"
},
{
"condition": "fps.hiv_rapid_test_result = 1304",
"value": "Poor sample quality"
},
{
"condition": "fps.hiv_rapid_test_result = 1067",
"value": "Unknown"
}
]
}
},
{
"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": "enrollment_date",
"column": "date_format(fps.enrollment_date, '%Y-%m-%d')"
},
{
"type": "derived_column",
"alias": "person_name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{
"type": "simple_column",
"alias": "ccc_number",
"column": "fi.ccc"
"column": "IFNULL(fi.ccc, 'No CCC')"
},
{
"type": "simple_column",
Expand All @@ -60,6 +60,11 @@
"alias": "age",
"column": "pd.age"
},
{
"type": "simple_column",
"alias": "latest_rtc_date",
"column": "date_format(pd.rtc_date, '%Y-%m-%d')"
},
{
"type": "simple_column",
"alias": "location_id",
Expand All @@ -76,9 +81,29 @@
"column": "l.uuid"
},
{
"type": "simple_column",
"type": "derived_column",
"alias": "population_type",
"column": "pd.population_type"
"expressionType": "case_statement",
"expressionOptions": {
"caseOptions": [
{
"condition": "pd.population_type = 1",
"value": "discordant"
},
{
"condition": "pd.population_type = 2",
"value": "priority"
},
{
"condition": "pd.population_type = 3 or pd.population_type is null",
"value": "general"
},
{
"condition": "pd.population_type = 4",
"value": "key"
}
]
}
},
{
"type": "derived_column",
Expand Down
42 changes: 11 additions & 31 deletions service/patient-reminder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ function TPTReminders(data) {
data.inh_treatment_days_remaining < 150
) {
showReminder = true;
} else if (
data.is_on_inh_treatment &&
data.inh_treatment_days_remaining <= 30 &&
data.inh_treatment_days_remaining > 0
) {
showReminder = true;
}
// INH Treatment Reminder - last month
try {
Expand All @@ -432,7 +438,7 @@ function TPTReminders(data) {
message:
'Patient started ' +
months +
' months' +
' months ' +
treatment +
' treatment on (' +
Moment(data.ipt_start_date).format('DD-MM-YYYY') +
Expand All @@ -442,7 +448,7 @@ function TPTReminders(data) {
'). ' +
data.inh_treatment_days_remaining +
' days remaining.',
title: 'INH Treatment Reminder',
title: 'TPT Treatment Reminder',
type: 'danger',
display: {
banner: true,
Expand All @@ -453,32 +459,6 @@ function TPTReminders(data) {
} catch (e) {
console.log(e);
}
// INH Treatment Reminder - last month
if (
data.is_on_inh_treatment &&
data.inh_treatment_days_remaining <= 30 &&
data.inh_treatment_days_remaining > 0
) {
reminders.push({
message:
'Patient started ' +
months +
' month ' +
treatment +
'treatment since (' +
Moment(data.ipt_start_date).format('DD-MM-YYYY') +
'). Expected to end on (' +
Moment(data.ipt_completion_date).format('DD-MM-YYYY') +
') ',
title: 'INH Treatment Reminder',
type: 'danger',
display: {
banner: true,
toast: true
}
});
}

// TPT Reminders
if (
calculateAge(data.birth_date) >= 1 &&
Expand Down Expand Up @@ -761,19 +741,19 @@ function getIptCompletionReminder(data) {
message:
'Patient started ' +
months +
' month IPT on ' +
' month TPT on ' +
Moment(data.ipt_start_date).format('DD-MM-YYYY') +
' and was supposed to be completed on ' +
Moment(data.ipt_start_date).add(months, 'months').format('DD-MM-YYYY'),
title: 'IPT Completion Reminder',
title: 'TPT Completion Reminder',
type: 'danger',
display: {
banner: true,
toast: true
}
});
} else {
console.info.call('No IPT Completion Reminder For Selected Patient');
console.info.call('No TPT Completion Reminder For Selected Patient');
}

return reminders;
Expand Down

0 comments on commit 7df39d3

Please sign in to comment.