Skip to content

Commit

Permalink
CD4 Reminder Update (#1303)
Browse files Browse the repository at this point in the history
Co-authored-by: Angie-540 <[email protected]>
Co-authored-by: Drizzentic <[email protected]>
  • Loading branch information
3 people authored Aug 3, 2023
1 parent d227fe1 commit 7111508
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 70 deletions.
1 change: 0 additions & 1 deletion app/reporting-framework/base-mysql.report.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import * as referral_aggregate from './json-reports/referral-aggregate.json';
import * as referral_peer_aggregate from './json-reports/referral-peer-aggregate.json';
import * as referral_patient_list_peer_base from './json-reports/referral-peer-base.json';
import * as cdm_dataset_base from './json-reports/cdm/cdm-dataset-base.json';

import * as starting_art_aggregation_age15 from './json-reports/starting-art-aggregation-age15.json';
import * as starting_art_base_age15 from './json-reports/starting-art-base-age15.json';
import * as starting_art_disaggregation_age15 from './json-reports/starting-art-disaggregation-age15.json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@
"type": "left",
"joinCondition": "t1.person_id = t7.patient_id AND t7.program_id = 27 AND t7.date_completed IS NULL"
}
},
{
"table": "etl.flat_hiv_summary_ext",
"alias": "t11",
"join": {
"type": "left",
"joinCondition": "t11.encounter_id = t1.encounter_id "
}
}
],
"columns": [
Expand Down Expand Up @@ -168,7 +176,7 @@
"alias": "get_cd4_count_coded",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "CASE WHEN ls.cd4_1 IS NULL THEN 1 WHEN (ls.cd4_1 <= 200) AND (TIMESTAMPDIFF(MONTH, ls.cd4_1_date, '{referenceDate}') > 6) THEN 2 WHEN (ls.cd4_1 > 200 AND ls.cd4_2 <= 200) AND (TIMESTAMPDIFF(MONTH, ls.cd4_1_date, '{referenceDate}') > 6) THEN 3 WHEN ls.cd4_2 IS NULL AND (TIMESTAMPDIFF(MONTH, ls.cd4_1_date, '{referenceDate}') > 6) THEN 4 ELSE 0 END"
"expression": "CASE WHEN ls.arv_start_date >= '2023-04-01' AND ls.cd4_1 IS NULL THEN 1 WHEN (ls.vl_1 > 1000) THEN 2 WHEN (TIMESTAMPDIFF(MONTH, ls.rtc_date, '{referenceDate}') >= 3) THEN 3 WHEN ( t11.on_cm_treatment = 1 AND t11.cm_treatment_end_date IS NULL) AND (TIMESTAMPDIFF(MONTH, ls.cd4_1_date, '{referenceDate}') >= 6) THEN 4 ELSE 0 END"
}
},
{
Expand All @@ -187,6 +195,14 @@
"expression": "case when timestampdiff(day,ls.cd4_order_date, '{referenceDate}') > 30 and ls.cd4_1_date is null or ls.cd4_order_date > ls.cd4_1_date then timestampdiff(day,ls.cd4_order_date, '{referenceDate}') else 0 end "
}
},
{
"type": "derived_column",
"alias": "next_rtc_duration",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "TIMESTAMPDIFF(MONTH, ls.rtc_date, '{referenceDate}')"
}
},
{
"type": "derived_column",
"alias": "is_on_inh_treatment",
Expand All @@ -208,6 +224,11 @@
"alias": "last_encounter_date",
"column": "ls.encounter_datetime"
},
{
"type": "simple_column",
"alias": "latest_CD4_Date",
"column": "ls.cd4_1_date"
},
{
"type": "simple_column",
"alias": "on_tb_tx",
Expand Down Expand Up @@ -238,6 +259,7 @@
"alias": "arv_start_date",
"column": "t1.arv_start_date"
},

{
"type": "simple_column",
"alias": "cur_arv_meds",
Expand Down
13 changes: 10 additions & 3 deletions dao/patient/etl-patient-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ module.exports = (function () {
uuid
];
var queryParts = {
columns: request.query.fields || '*',
columns: request.query.fields || '*, t3.*',
columns: request.query.fields || '*, t3.*',
table: 'etl.flat_hiv_summary_v15b',
where: whereClause,
leftOuterJoins: [
['etl.flat_hiv_summary_ext', 't3', 't1.encounter_id = t3.encounter_id']
],
leftOuterJoins: [
['etl.flat_hiv_summary_ext', 't3', 't1.encounter_id = t3.encounter_id']
],
order: order || [
{
column: 'encounter_datetime',
column: 't1.encounter_datetime',
column: 't1.encounter_datetime',
asc: false
}
],
Expand All @@ -44,7 +52,6 @@ module.exports = (function () {
offset: request.query.startIndex,
limit: 1000
};

var encounterTypeNames = {};
//get encounter type Name
var encounterNamesPromise = db.queryDb(qParts);
Expand Down
186 changes: 121 additions & 65 deletions service/patient-reminder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function viralLoadReminders(data) {
let reminders = [];

let labMessage = 'Last viral load: none';
let requires = 'Patient requires viral load test. ';
let requires = 'Patient requires viral load test';
if (data.last_vl_date) {
labMessage =
'Last viral load: ' +
Expand All @@ -45,7 +45,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'Patients who are between 0-24 years old and 3 months after ART initiation ' +
'.Patients who are between 0-24 years old and 3 months after ART initiation ' +
'require a viral load test.' +
labMessage,
title: 'Viral Load Reminder',
Expand All @@ -59,7 +59,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'Patients who are between 0-24 years old ' +
'.Patients who are between 0-24 years old ' +
'require a viral load test every 6 months. ' +
labMessage,
title: 'Viral Load Reminder',
Expand All @@ -73,7 +73,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'A Patient with Viral Load that is more than 200 requires a viral load test every 3 months. ' +
'.A Patient with Viral Load that is more than 200 requires a viral load test every 3 months. ' +
labMessage,
title: 'Viral Load Reminder',
type: 'danger',
Expand All @@ -87,7 +87,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'Patients older than 25 years and newly on ART require ' +
'.Patients older than 25 years and newly on ART require ' +
'a viral load test after 12 months. ' +
labMessage,
title: 'Viral Load Reminder',
Expand All @@ -104,7 +104,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'Patients older than 25 years and on ART for more than 1 year require ' +
'.Patients older than 25 years and on ART for more than 1 year require ' +
'a viral load test every year. ' +
labMessage,
title: 'Viral Load Reminder',
Expand All @@ -118,7 +118,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'Patients older than 25 years and 3 months after ART initiation require a viral load test. ' +
'.Patients older than 25 years and 3 months after ART initiation require a viral load test. ' +
labMessage,
title: 'Viral Load Reminder',
type: 'danger',
Expand All @@ -131,7 +131,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'A Patient with Viral Load that is more than 200 requires a viral load test every 3 months. ' +
'.A Patient with Viral Load that is more than 200 requires a viral load test every 3 months. ' +
labMessage,
title: 'Viral Load Reminder',
type: 'danger',
Expand All @@ -145,7 +145,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'A pregnant or breastfeeding patient with vl > 200 requires ' +
'.A pregnant or breastfeeding patient with vl > 200 requires ' +
'a viral load test every 3 months. ' +
labMessage,
title: 'Viral Load Reminder',
Expand All @@ -159,7 +159,7 @@ function viralLoadReminders(data) {
reminders.push({
message:
requires +
'A pregnant or breastfeeding patient requires ' +
'.A pregnant or breastfeeding patient requires ' +
'a viral load test every 6 months. ' +
labMessage,
title: 'Viral Load Reminder',
Expand All @@ -173,7 +173,10 @@ function viralLoadReminders(data) {
// all patients
else if (data.needs_vl_coded === 7) {
reminders.push({
message: requires + ' 3 months after Regimen Modification ' + labMessage,
message:
requires +
'3 months after Regimen Change done on ' +
Moment(data.last_encounter_date).format('DD-MM-YYYY'),
title: 'Viral Load Reminder',
type: 'danger',
display: {
Expand All @@ -185,70 +188,123 @@ function viralLoadReminders(data) {

return reminders;
}

function cd4TestReminder(data) {
let reminders = [];

let suspected =
'Suspected Treatment Failure: Viral load is: ' + data.viral_load + '.';
if (data.viral_load < 1000) {
suspected = '';
}
switch (data.get_cd4_count_coded) {
case 1:
reminders.push({
message: 'Patient requires a baseline CD4',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
if (data.next_rtc_duration > 3) {
reminders.push({
message:
suspected +
' Patient requires a baseline CD4 test and has missed clinic by more than 3 months.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
} else {
reminders.push({
message: suspected + ' Patient requires a baseline CD4',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
}
break;
case 2:
reminders.push({
message:
'Patient requires CD4. Latest CD4 is ' +
data.latest_cd4_count +
', done ' +
data.months_since_cd4_count +
' months ago.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
if (data.months_since_cd4_count > 6) {
reminders.push({
message:
suspected +
' Patient requires CD4 test. Latest CD4 is ' +
data.latest_cd4_count +
', done (' +
Moment(data.latest_CD4_Date).format('DD-MM-YYYY') +
') ' +
data.months_since_cd4_count +
' months ago.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
} else if (!data.months_since_cd4_count) {
reminders.push({
message: suspected + ' Patient requires CD4 test.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
}
break;
case 3:
reminders.push({
message:
'Patient requires CD4 confirmation. Previous CD4 was ' +
data.previous_cd4_count +
' Latest CD4 is ' +
data.latest_cd4_count +
', done ' +
data.months_since_cd4_count +
' months ago.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
if (!data.latest_cd4_count) {
reminders.push({
message:
suspected +
' Patient requires a baseline CD4 test and has missed clinic by more than 3 months.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
} else {
reminders.push({
message:
suspected +
' Patient requires CD4 test. Patient missed clinic by more than 3 months. Latest CD4 is ' +
data.latest_cd4_count +
', and latest CD4 done on (' +
Moment(data.latest_CD4_Date).format('DD-MM-YYYY') +
') ' +
data.months_since_cd4_count +
' months ago.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
}
break;
case 4:
reminders.push({
message:
'Patient requires CD4 confirmation. First CD4 is ' +
data.latest_cd4_count +
', done ' +
data.months_since_cd4_count +
' months ago.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
if (data.months_since_cd4_count >= 6) {
reminders.push({
message:
' Patient on cryptococcal treatment, requires CD4 test. Latest CD4 is ' +
data.latest_cd4_count +
', done (' +
Moment(data.latest_CD4_Date).format('DD-MM-YYYY') +
') ' +
data.months_since_cd4_count +
' months ago.',
title: 'CD4 Reminder',
type: 'success',
display: {
banner: true,
toast: true
}
});
}
break;
default:
}
Expand Down

0 comments on commit 7111508

Please sign in to comment.