Skip to content

Commit

Permalink
Merge branch 'master' into POC-517
Browse files Browse the repository at this point in the history
  • Loading branch information
drizzentic authored Sep 7, 2023
2 parents e3fc757 + 097171d commit 52c6d72
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@
"conditionExpression": "(if((pre.is_successful_phone_follow_up = 'NO' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'NO')), 1, 0)) = ?",
"parameterName": "failedOutcome"
},
{
"filterType": "tableColumns",
"conditionExpression": "(if((pre.is_successful_phone_follow_up IS NULL AND pre.attempted_home_visit IS NULL AND pre.was_client_found IS NULL), 0, 1)) = ?",
"parameterName": "unknownOutcome"
},
{
"filterType": "tableColumns",
"conditionExpression": "ml.predicted_risk is not null"
Expand Down
83 changes: 60 additions & 23 deletions dao/patient/etl-patient-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,66 @@ module.exports = (function () {
't1.uuid = ? and t1.encounter_type in (1,2,3,4,17,21,110,117,99999)',
uuid
];
var queryParts = {
columns:
request.query.fields ||
'fli.vl_1_date as latest_vl_date,fli.vl_1 as latest_vl,t1.*, t3.cm_result,t3.cm_result_date, t3.cm_test, t3.cm_treatment_end_date, t3.cm_treatment_phase, t3.cm_treatment_start_date',
table: 'etl.flat_hiv_summary_v15b',
where: whereClause,
leftOuterJoins: [
['etl.flat_hiv_summary_ext', 't3', 't1.encounter_id = t3.encounter_id'],
[
'(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.encounter_id = max_dates.encounter_id)',
'fli',
'fli.person_id = t1.person_id'
]
],
order: order || [
{
column: 't1.encounter_datetime',
asc: false
}
],
offset: request.query.startIndex,
limit: request.query.limit
};
var queryParts =
request.query.isHEIActive === 'false'
? {
columns:
request.query.fields ||
'fli.vl_1_date as latest_vl_date,fli.vl_1 as latest_vl,t1.*, t3.cm_result,t3.cm_result_date, t3.cm_test, t3.cm_treatment_end_date, t3.cm_treatment_phase, t3.cm_treatment_start_date',
table: 'etl.flat_hiv_summary_v15b',
where: whereClause,
leftOuterJoins: [
[
'etl.flat_hiv_summary_ext',
't3',
't1.encounter_id = t3.encounter_id'
],
[
'(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.encounter_id = max_dates.encounter_id)',
'fli',
'fli.person_id = t1.person_id'
]
],
order: order || [
{
column: 't1.encounter_datetime',
asc: false
}
],
offset: request.query.startIndex,
limit: request.query.limit
}
: {
columns:
request.query.fields ||
't1.*, t3.height, t3.weight, t4.obs, t4.pcp_prophylaxis',
table: 'etl.flat_hei_summary',
where: whereClause,
leftOuterJoins: [
[
'(SELECT person_id, weight, height FROM etl.flat_vitals WHERE uuid = "' +
uuid +
'" order by encounter_datetime desc limit 1)',
't3',
't1.person_id = t3.person_id'
],
[
'(SELECT person_id, obs, case when obs regexp "!!1263=" then cast(replace(replace((substring_index(substring(obs, locate("!!1263=", obs)), " ## ", 1)), "!!1263=", ""), "!!", "") as unsigned) end as pcp_prophylaxis FROM etl.flat_obs WHERE person_id = (SELECT person_id FROM etl.flat_hei_summary WHERE uuid = "' +
uuid +
'" limit 1) order by encounter_datetime desc limit 1)',
't4',
't4.person_id = t1.person_id'
]
],
order: order || [
{
column: 't1.encounter_datetime',
asc: false
}
],
offset: request.query.startIndex,
limit: request.query.limit
};

var qParts = {
columns: '*',
Expand Down
31 changes: 18 additions & 13 deletions service/patient-reminder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,24 @@ function viralLoadReminders(data) {
});
} // adults
else if (isAdult && data.needs_vl_coded === 3) {
reminders.push({
message:
requires +
'.Patients older than 25 years and newly on ART require ' +
'a viral load test after 12 months. ' +
labMessage,
title: 'Viral Load Reminder',
type: 'danger',
display: {
banner: true,
toast: true
}
});
if (
(data.viral_load > 200 && data.months_since_last_vl_date > 3) ||
(data.viral_load < 200 && data.months_since_last_vl_date > 6)
) {
reminders.push({
message:
requires +
'.Patients older than 25 years and newly on ART require ' +
'a viral load test after 12 months. ' +
labMessage,
title: 'Viral Load Reminder',
type: 'danger',
display: {
banner: true,
toast: true
}
});
}
} else if (
isAdult &&
(data.needs_vl_coded === 8) & (data.months_since_last_vl_date >= 12)
Expand Down

0 comments on commit 52c6d72

Please sign in to comment.