Skip to content

POC-1008: Update surge reporting indicators to reference the start of the financial year #1439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions app/reporting-framework/json-reports/surge-report-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
"type": "INNER",
"joinCondition": "l.location_id = srb.location_id"
}
},
{
"table": "etl.flat_defaulters",
"alias": "d",
"join": {
"type": "INNER",
"joinCondition": "d.encounter_id = srb.encounter_id"
}
}
],
"columns": [
Expand Down Expand Up @@ -565,19 +573,28 @@
"column": "srb.ltfu_death_this_week"
},
{
"type": "simple_column",
"type": "derived_column",
"alias": "ltfu_active_this_week",
"column": "srb.ltfu_active_this_week"
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "CASE WHEN d.encounter_datetime >= '2024-10-01' and d.days_since_rtc >= 28 THEN old_ltfus_to_active_this_week ELSE 0 END"
}
},
{
"type": "simple_column",
"type": "derived_column",
"alias": "is_ltfu_after_may",
"column": "srb.is_ltfu_after_may"
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "CASE WHEN d.encounter_datetime >= '2024-10-01' and d.days_since_rtc >= 28 THEN is_ltfu_after_may ELSE 0 END"
}
},
{
"type": "simple_column",
"type": "derived_column",
"alias": "old_ltfus_to_active",
"column": "srb.old_ltfus_to_active"
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "CASE WHEN d.encounter_datetime >= '2024-10-01' and d.days_since_rtc >= 28 THEN old_ltfus_to_active ELSE 0 END"
}
},
{
"type": "simple_column",
Expand Down Expand Up @@ -640,9 +657,12 @@
"column": "srb.not_elligible_and_on_dc"
},
{
"type": "simple_column",
"type": "derived_column",
"alias": "is_ltfu_after_may_total",
"column": "srb.is_ltfu_after_may_total"
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "CASE WHEN d.encounter_datetime >= '2024-10-01' and d.days_since_rtc >= 28 THEN is_ltfu_after_may_total ELSE 0 END"
}
},
{
"type": "simple_column",
Expand Down
42 changes: 21 additions & 21 deletions service/surge-reports/surge-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@
"sectionTitle": "Client Disengagements",
"indicators": [
{
"label": "Cumulative LTFUs (All LTFUs)",
"label": "Cumulative IITs (All IITs)",
"description": "All patients who have missed their rtc more than 28 days",
"indicator": "all_ltfus"
},
{
"label": "Cumulative Surge LTFUs (LTFUs as from October 2020)",
"description": "All patients who became LTFUs as from October 2020 including those who have been resolved",
"label": "Cumulative Surge IITs (IITs as from October {{YEAR}})",
"description": "All patients who became IITs as from October {{YEAR}} including those who have been resolved",
"indicator": "is_ltfu_after_may_total"
},
{
"label": "Target to bring back this week (LTFUs as from October 2020 not yet resolved)",
"description": "All patients who became LTFUs as from October 2020 and have not been resolved",
"label": "Target to bring back this week (IITs as from October {{YEAR}} not yet resolved)",
"description": "All patients who became IITs as from October {{YEAR}} and have not been resolved",
"indicator": "is_ltfu_after_may"
},
{
"label": "Cumulative Medication refill LTFUs(Missed medication pickup rtc for more that 28 days)",
"label": "Cumulative Medication refill IITs(Missed medication pickup rtc for more that 28 days)",
"description": "All patients who have missed their medication pickup rtc for more that 28 days as from October 2020 to now, including those with outcomes already",
"indicator": "med_surge_ltfus_cumulative"
},
{
"label": "Medication refill LTFUs not yet resolved",
"label": "Medication refill IITs not yet resolved",
"description": "All patients who have missed their medication pickup rtc for more that 28 days as from October 2020 to now and have not been resolved yet",
"indicator": "med_surge_ltfu_and_med_ltfu_after_may"
},
Expand Down Expand Up @@ -102,12 +102,12 @@
"indicator": "med_defaulters"
},
{
"label": "LTFUs this week (patients who became LTFU this week)",
"description": "Patients who became LTFU this week",
"label": "IITs this week (patients who became IIT this week)",
"description": "Patients who became IIT this week",
"indicator": "newly_ltfu_this_week"
},
{
"label": "Medication refill LTFUs this week(Missed medication pickup rtc date more than 28 days this week)",
"label": "Medication refill IITs this week(Missed medication pickup rtc date more than 28 days this week)",
"description": "Patients who have missed their medication pickup rtc date for more than 28 days this week",
"indicator": "newly_med_ltfu_this_week"
},
Expand All @@ -124,7 +124,7 @@
]
},
{
"sectionTitle": "LTFU Outcomes this week(Surge LTFUs)",
"sectionTitle": "IIT Outcomes this week(Surge IITs)",
"indicators": [
{
"label": "Brought back to care",
Expand All @@ -143,52 +143,52 @@
},
{
"label": "Medication refill brought back this week",
"description": "Medication refill LTFUs that have been brought back this week",
"description": "Medication refill IITs that have been brought back this week",
"indicator": "med_surge_ltfus_outcomes_this_week"
}
]
},
{
"sectionTitle": "LTFU cumulative outcome(Surge LTFUs)",
"sectionTitle": "IIT cumulative outcome(Surge IITs)",
"indicators": [
{
"label": "Cumulative Outcomes (brought back, self transfers and dead)",
"description": "surge LTFUs brought back, transfered out or those who are confirmed dead",
"description": "surge IITs brought back, transfered out or those who are confirmed dead",
"indicator": "ltfu_cumulative_outcomes_total"
},
{
"label": "Brought back to care cumulative",
"description": "Total Surge LTFUs who were brought back to care",
"description": "Total Surge IITs who were brought back to care",
"indicator": "ltfu_cumulative_outcomes_active"
},
{
"label": "Reported self transfered cumulative",
"description": "Total Surge LTFUs that have been reported self transfered",
"description": "Total Surge IITs that have been reported self transfered",
"indicator": "ltfu_cumulative_outcomes_transfer_out"
},
{
"label": "Reported dead cumulative",
"description": "Total Surge LTFUs that have been confirmed dead",
"description": "Total Surge IITs that have been confirmed dead",
"indicator": "ltfu_cumulative_outcomes_death"
},
{
"label": "Cumulative medication refill brought back",
"description": "All medication refill LTFUs that have been brought back",
"description": "All medication refill IITs that have been brought back",
"indicator": "med_surge_ltfus_outcomes"
}
]
},
{
"sectionTitle": "LTFU Outcomes (clients lost before october 2019)",
"sectionTitle": "IIT Outcomes (clients lost before october {{YEAR}})",
"indicators": [
{
"label": "Returnees cumulative",
"description": "Patients who were LTFU before october 2019 and have returned",
"description": "Patients who were IIT before october {{YEAR}} and have returned",
"indicator": "old_ltfus_to_active"
},
{
"label": "Returnees this week",
"description": "Patients who were LTFU before october 2019 and have returned this week",
"description": "Patients who were IIT before october {{YEAR}} and have returned this week",
"indicator": "old_ltfus_to_active_this_week"
}
]
Expand Down
12 changes: 11 additions & 1 deletion service/surge-reports/surge-report.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ import { SurgeMultiDatasetPatientlistReport } from './surge-multi-dataset-patien
import { PatientlistMysqlReport } from '../../app/reporting-framework/patientlist-mysql.report';
const patientListCols = require('./surge-report-patientlist.json');
import moment from 'moment';
const path = require('path');
const fs = require('fs');

const helpers = require('../../etl-helpers');
const Promise = require('bluebird');
const _ = require('lodash');
const surgeSectionDefinitions = require('./surge-report.json');

const filePath = path.join(__dirname, 'surge-report.json');
const raw = fs.readFileSync(filePath, 'utf-8');
const previousYear = new Date().getFullYear() - 1;

// Replace all occurrences of {{YEAR}} with previous year
const replaced = raw.replace(/{{YEAR}}/g, previousYear);

const surgeSectionDefinitions = JSON.parse(replaced);
const surgeSchemaReportMap = require('./surge-indicators-config.json');

export class SurgeService extends SurgeMultiDatasetPatientlistReport {
Expand Down
11 changes: 10 additions & 1 deletion service/surge-reports/surge-service.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { Promise } from 'bluebird';
const path = require('path');
const fs = require('fs');
import { MultiDatasetPatientlistReport } from '../../app/reporting-framework/multi-dataset-patientlist.report';
import ReportProcessorHelpersService from '../../app/reporting-framework/report-processor-helpers.service';

const surgeDefs = require('./surge-report.json');
const filePath = path.join(__dirname, 'surge-report.json');
const raw = fs.readFileSync(filePath, 'utf-8');
const previousYear = new Date().getFullYear() - 1;

// Replace all occurrences of {{YEAR}} with previous year
const replaced = raw.replace(/{{YEAR}}/g, previousYear);

const surgeDefs = JSON.parse(replaced);
const dao = require('../../etl-dao');

export class SurgeReportService extends MultiDatasetPatientlistReport {
Expand Down