Skip to content
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

Poc 392 #1370

Merged
merged 1 commit into from
Feb 15, 2024
Merged

Poc 392 #1370

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
POC-392: Develop Advanced HIV Disease Report
hiqedme committed Feb 15, 2024
commit da8df1ff0b2b063b5381d9f6f5a46effd5db5eeb
43 changes: 42 additions & 1 deletion app/reporting-framework/base-mysql.report.js
Original file line number Diff line number Diff line change
@@ -434,6 +434,13 @@ import * as rhe_plhiv_aggregate from './json-reports/plhiv-ncd-v2-reports/disagg

import * as kd_plhiv_base from './json-reports/plhiv-ncd-v2-reports/disaggregations/kidney-disease/kd-base.json';
import * as kd_plhiv_aggregate from './json-reports/plhiv-ncd-v2-reports/disaggregations/kidney-disease/kd-aggregate.json';
//ahd report
import * as ahd_monthly_summary from './json-reports/ahd_reports/ahd-monthly.json';
import * as ahd_monthly_aggregate from './json-reports/ahd_reports/ahd-monthly-aggregate.json';
import * as ahd_cohort_monthly_aggregate from './json-reports/ahd_reports/ahd-cohort-monthly-aggregate.json';
import * as ahd_monthly_dataset_base from './json-reports/ahd_reports/ahd-monthly-dataset-base.json';
import * as ahd_cohort_monthly_dataset_base from './json-reports/ahd_reports/ahd-cohort-monthly-dataset-base.json';
import * as ahd_monthly_patient_list_template from './json-reports/ahd_reports/ahd_monthly_patient_list_template_post.json';
export class BaseMysqlReport {
constructor(reportName, params) {
this.reportName = reportName;
@@ -1027,6 +1034,40 @@ export class BaseMysqlReport {
prepDatasetReport: this.cloneJsonSchema(prep_dataset_report)
});
break;
case 'ahd-monthly-summary':
resolve({
main: this.cloneJsonSchema(ahd_monthly_summary)
});
break;
case 'ahdMonthlySummaryReport':
resolve({
main: this.cloneJsonSchema(ahd_monthly_summary),
ahdMonthlyDataSetBase: this.cloneJsonSchema(
ahd_monthly_dataset_base
)
});
break;
case 'ahd-monthly-report-patient-list-template':
resolve({
main: this.cloneJsonSchema(ahd_monthly_patient_list_template)
});
break;
case 'ahdMonthlyAggregate':
resolve({
main: this.cloneJsonSchema(ahd_monthly_aggregate),
ahdMonthlyDataSetBase: this.cloneJsonSchema(
ahd_monthly_dataset_base
)
});
break;
case 'ahdCohortMonthlyAggregate':
resolve({
main: this.cloneJsonSchema(ahd_cohort_monthly_aggregate),
ahdCohortMonthlyDataSetBase: this.cloneJsonSchema(
ahd_cohort_monthly_dataset_base
)
});
break;
case 'surgeBaselineReport':
resolve({
main: this.cloneJsonSchema(ltfu_surge_baseline_aggregate_report),
@@ -1980,7 +2021,7 @@ export class BaseMysqlReport {
});
})
.catch((error) => {
// console.error('Error Executing Mysql Query', error);
console.error('Error Executing Mysql Query', error);
reject(error);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
{
"name": "ahdCohortMonthlyAggregate",
"version": "1.0",
"tag": "",
"uses": [
{
"name": "ahdCohortMonthlyDataSetBase",
"version": "1.0",
"type": "dataset_def"
}
],
"sources": [
{
"dataSet": "ahdCohortMonthlyDataSetBase",
"alias": "ahd_base"
}
],
"columns": [
{
"type": "simple_column",
"alias": "Reporting_Month",
"column": "ahd_base.reporting_month"
},
{
"type": "simple_column",
"alias": "location_id",
"column": "ahd_base.location_id"
},
{
"type": "simple_column",
"alias": "location",
"column": "ahd_base.location"
},
{
"type": "derived_column",
"alias": "cd4_justification_female_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.cd4_justification_female_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "cd4_justification_female_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.cd4_justification_female_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "cd4_justification_male_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.cd4_justification_male_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "cd4_justification_male_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.cd4_justification_male_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "cd4_justification",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.cd4_justification)"
}
},
{
"type": "derived_column",
"alias": "delayed_art_due_to_cm_female_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.delayed_art_due_to_cm_female_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "delayed_art_due_to_cm_female_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.delayed_art_due_to_cm_female_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "delayed_art_due_to_cm_male_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.delayed_art_due_to_cm_male_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "delayed_art_due_to_cm_male_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.delayed_art_due_to_cm_male_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "delayed_art_due_to_cm",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.delayed_art_due_to_cm)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_female_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_female_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_female_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_female_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_male_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_male_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_male_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_male_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_female_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_female_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_female_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_female_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_male_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_male_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_male_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_male_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_cd4_done_female_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_cd4_done_female_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_cd4_done_female_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_cd4_done_female_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_cd4_done_male_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_cd4_done_male_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_cd4_done_male_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_cd4_done_male_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_6mons_cd4_done",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_6mons_cd4_done)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_cd4_done_female_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_cd4_done_female_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_cd4_done_female_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_cd4_done_female_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_cd4_done_male_less_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_cd4_done_male_less_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_cd4_done_male_more_than_15",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_cd4_done_male_more_than_15)"
}
},
{
"type": "derived_column",
"alias": "started_cm_12mons_cd4_done",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "SUM(ahd_base.started_cm_12mons_cd4_done)"
}
}
],
"groupBy": {
"groupParam": "groupByParam",
"columns": ["ahd_base.location_id", "ahd_base.reporting_month"],
"excludeParam": "excludeParam"
},
"transFormDirectives": {
"joinColumn": "location_id",
"joinColumnParam": "",
"skipColumns": [""],
"disaggregationColumns": []
},
"dynamicJsonQueryGenerationDirectives": {
"patientListGenerator": {
"useTemplate": "ahd-monthly-report-patient-list-template",
"useTemplateVersion": "1.0",
"generatingDirectives": {
"joinDirectives": {
"joinType": "INNER",
"joinCondition": "<<base_column>> = <<template_column>>",
"baseColumn": "person_id",
"templateColumn": "person_id"
}
}
}
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"patientListCols": [
{
"headerName": "CCC Number",
"field": "ccc_number",
"width": 150,
"pinned": true
},
{
"headerName": "Name",
"field": "person_name",
"width": 250,
"pinned": true
},
{
"headerName": "NUPI Identifier",
"field": "upi_number",
"width": 150,
"pinned": true
},
{
"headerName": "Gender",
"field": "gender",
"width": 100
},
{
"headerName": "Age",
"field": "age",
"width": 100
},
{
"headerName": "Identifiers",
"field": "identifiers",
"width": 250
},
{
"headerName": "First ARV start date",
"field": "arv_first_regimen_start_date",
"width": 150
},
{
"headerName": "Phone Number",
"field": "phone_number",
"width": 150
},
{
"headerName": "Last Appointment",
"field": "last_appointment",
"width": 250
},
{
"headerName": "Latest RTC Date",
"field": "latest_rtc_date",
"width": 100
},
{
"headerName": "Latest VL",
"field": "latest_vl",
"width": 100
},
{
"headerName": "VL Category",
"field": "vl_category",
"width": 250
},
{
"headerName": "Latest VL Date",
"field": "latest_vl_date",
"width": 100
},
{
"headerName": "Previous VL",
"field": "previous_vl",
"width": 100
},
{
"headerName": "Previous VL Date",
"field": "previous_vl_date",
"width": 100
},
{
"headerName": "Covid-19 Screening Date",
"field": "covid_screening_date",
"width": 100
},
{
"headerName": "OVCID",
"field": "ovcid_id",
"width": 100
},
{
"headerName": "Covid-19 Vaccination Status",
"field": "covid_19_vaccination_status",
"width": 250
},
{
"headerName": "Nearest Center",
"field": "nearest_center",
"width": 100
},
{
"headerName": "Patient Uuid",
"field": "patient_uuid",
"width": 100,
"hide": true
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"reports": ["ahdMonthlyAggregate", "ahdCohortMonthlyAggregate"]
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"name": "ahd_monthly_report_patient_list_template_post",
"version": "1.0",
"tag": "ahd_monthly_report_patient_list_template_post",
"description": "AHD patient list template",
"sources": [
{
"table": "amrs.person",
"alias": "t1"
},
{
"table": "amrs.person_name",
"alias": "person_name",
"join": {
"type": "INNER",
"joinCondition": "t1.person_id = person_name.person_id AND (person_name.voided IS NULL || person_name.voided = 0) AND person_name.preferred = 1"
}
},
{
"table": "etl.flat_patient_identifiers_v1",
"alias": "flat_identifiers",
"join": {
"type": "LEFT",
"joinCondition": "t1.person_id = flat_identifiers.patient_id"
}
},
{
"table": "amrs.person_attribute",
"alias": "contacts",
"join": {
"type": "LEFT",
"joinCondition": "t1.person_id = contacts.person_id AND (contacts.voided IS NULL || contacts.voided = 0) AND contacts.person_attribute_type_id = 10"
}
},
{
"table": "etl.flat_hiv_summary_v15b",
"alias": "fh",
"join": {
"type": "LEFT",
"joinCondition": "t1.person_id = fh.person_id AND fh.next_clinical_datetime_hiv IS NULL AND fh.is_clinical_encounter = 1 "
}
}
],
"columns": [
{
"type": "simple_column",
"alias": "patient_uuid",
"column": "t1.uuid"
},
{
"type": "derived_column",
"alias": "uuid",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "t1.uuid"
}
},
{
"type": "simple_column",
"alias": "person_id",
"column": "t1.person_id"
},
{
"type": "simple_column",
"alias": "gender",
"column": "t1.gender"
},
{
"type": "simple_column",
"alias": "birthdate",
"column": "t1.birthdate"
},
{
"type": "derived_column",
"alias": "phone_number",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "if (contacts.value IS NULL, '', contacts.value)"
}
},
{
"type": "derived_column",
"alias": "age",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "extract(year from (from_days(datediff(now(),t1.birthdate))))"
}
},
{
"type": "derived_column",
"alias": "person_name",
"expressionType": "simple_expression",
"expressionOptions": {
"expression": "CONCAT(COALESCE(person_name.given_name, ''), ' ', COALESCE(person_name.middle_name, ''), ' ', COALESCE(person_name.family_name, ''))"
}
},
{
"type": "simple_column",
"alias": "ccc_number",
"column": "flat_identifiers.ccc"
},
{
"type": "simple_column",
"alias": "ovcid_id",
"column": "flat_identifiers.ovcid"
},
{
"type": "simple_column",
"alias": "upi_number",
"column": "flat_identifiers.nupi"
},
{
"type": "simple_column",
"alias": "who_stage",
"column": "fh.cur_who_stage"
},
{
"type": "simple_column",
"alias": "arv_first_regimen_start_date",
"column": "fh.arv_first_regimen_start_date"
},
{
"type": "simple_column",
"alias": "cur_meds",
"column": "fh.cur_arv_meds"
},
{
"type": "simple_column",
"alias": "cur_arv_line",
"column": "fh.cur_arv_line"
},
{
"type": "simple_column",
"alias": "cd4_date",
"column": "DATE_FORMAT(fh.cd4_1_date,'%Y-%m-%d')"
},
{
"type": "simple_column",
"alias": "cd4_results",
"column": "fh.cd4_1"
}
],
"groupBy": {
"columns": ["t1.person_id"]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pmtct-rri-report-patient-list-template",
"name": "pmtct-rri-patient-list-template",
"version": "1.0",
"tag": "pmtct-rri-report-patient-list-template",
"tag": "pmtct_rri_patient-list-template",
"description": "PMTCT patient list template",
"sources": [
{
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ export class MultiDatasetPatientlistReport extends MultiDatasetReport {
super(reportName, params);
}
// interprate

generatePatientListReport(indicators) {
let additionalParams = {
type: 'patient-list',
93 changes: 93 additions & 0 deletions app/routes/ahd-monthly-summary.route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
var authorizer = require('../../authorization/etl-authorizer');
import { AHDMonthlySummaryService } from '../../service/ahd-monthly-summary.service';
var etlHelpers = require('../../etl-helpers');
var privileges = authorizer.getAllPrivileges();
var preRequest = require('../../pre-request-processing');
const routes = [
{
method: 'GET',
path: '/etl/ahd-monthly-summary',
config: {
plugins: {
hapiAuthorization: {
role: privileges.canViewClinicDashBoard
}
},
handler: function (request, reply) {
preRequest.resolveLocationIdsToLocationUuids(request, function () {
let requestParams = Object.assign({}, request.query, request.params);
let reportParams = etlHelpers.getReportParams(
'ahd-monthly-summary',
['endDate', 'startDate', 'locationUuids'],
requestParams
);

reportParams.requestParams.isAggregated = true;
let service = new AHDMonthlySummaryService(
'ahd-monthly-summary',
reportParams.requestParams
);
service
.generateReport(reportParams.requestParams)
.then((result) => {
reply(result);
})
.catch((error) => {
reply(error);
});
});
},
description: 'ahd monthly summary dataset',
notes: 'ahd monthly summary dataset',
tags: ['api'],
validate: {
options: {
allowUnknown: true
},
params: {}
}
}
},
{
method: 'GET',
path: '/etl/ahd-monthly-summary-patient-list',
config: {
plugins: {
hapiAuthorization: {
role: privileges.canViewClinicDashBoard
}
},
handler: function (request, reply) {
request.query.reportName = 'ahd-monthly-summary';
preRequest.resolveLocationIdsToLocationUuids(request, function () {
let requestParams = Object.assign({}, request.query, request.params);

let requestCopy = _.cloneDeep(requestParams);
let reportParams = etlHelpers.getReportParams(
request.query.reportName,
['startDate', 'endDate', 'locationUuids', 'locations'],
requestParams
);
requestCopy.locationUuids = reportParams.requestParams.locationUuids;
const ahdService = new AHDMonthlySummaryService(
'ahd-monthly-summary',
requestCopy
);
ahdService
.generatePatientListReport(reportParams.requestParams)
.then((results) => {
reply(results);
})
.catch((err) => {
reply(err);
});
});
},
description:
'Get patient list for ahd monthly summary report of the location and month provided',
notes: 'Returns patient list of ahd monthly summary indicators',
tags: ['api']
}
}
];
exports.routes = (server) => server.route(routes);
289 changes: 289 additions & 0 deletions service/ahd-indicator-definitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
[
{
"sectionTitle": "",
"indicators": [
{
"label": "Location",
"indicator": "location"
}
]
},
{
"sectionTitle": "NEW",
"indicators": [
{
"refno": "1",
"label": "Number of NEW Clients New on ART",
"indicator": [
"new_on_art_this_month_female_less_than_15",
"new_on_art_this_month_male_less_than_15",
"new_on_art_this_month_female_more_than_15",
"new_on_art_this_month_male_more_than_15",
"new_on_art_this_month"
]
},
{
"refno": "1.1 ",
"label": "Number of New Clients who are Assessed & Classified WHO clinical Stage III/IV",
"indicator": [
"classified_as_who_stage_3_or_4_female_less_than_15",
"classified_as_who_stage_3_or_4_male_less_than_15",
"classified_as_who_stage_3_or_4_female_more_than_15",
"classified_as_who_stage_3_or_4_male_more_than_15",
"classified_as_who_stage_3_or_4"
]
},
{
"refno": "1.3",
"label": "Number of NEW clients who received Baseline CD4 Count Test & Results available",
"indicator": [
"baseline_cd4_done_this_month_female_less_than_15",
"baseline_cd4_done_this_month_male_less_than_15",
"baseline_cd4_done_this_month_female_more_than_15",
"baseline_cd4_done_this_month_male_more_than_15",
"baseline_cd4_done_this_month"
]
},
{
"refno": "2",
"label": "Number of clients CD4 Test Done for Suspected Treatment Failure or any other reasons(COHORT)",
"indicator": [
"cd4_justification_female_less_than_15",
"cd4_justification_male_less_than_15",
"cd4_justification_female_more_than_15",
"cd4_justification_male_more_than_15",
"cd4_justification"
]
},
{
"refno": "3",
"label": "Number of NEW clients whose CD4 count is below 200",
"indicator": [
"cd4_below_200_female_less_than_15",
"cd4_below_200_male_less_than_15",
"cd4_below_200_female_more_than_15",
"cd4_below_200_male_more_than_15",
"cd4_below_200"
]
}
]
},
{
"sectionTitle": "NEW TUBERCULOSIS",
"indicators": [
{
"refno": "4",
"label": "Number of NEW clients whose CD4 count is below 200 who are screened for tuberculosis",
"indicator": [
"tb_screened_cd4_below_200_female_less_than_15",
"tb_screened_cd4_below_200_male_less_than_15",
"tb_screened_cd4_below_200_female_more_than_15",
"tb_screened_cd4_below_200_male_more_than_15",
"tb_screened_cd4_below_200"
]
},
{
"refno": "4.1",
"label": "Number of NEW clients who are screened for TB who test positive for tuberculosis",
"indicator": [
"positive_tb_screened_cd4_below_200_female_less_than_15",
"positive_tb_screened_cd4_below_200_male_less_than_15",
"positive_tb_screened_cd4_below_200_female_more_than_15",
"positive_tb_screened_cd4_below_200_male_more_than_15",
"positive_tb_screened_cd4_below_200"
]
},
{
"refno": "4.2",
"label": "Number of NEW client who tested positive for tuberculosis who are treated for tuberculosis",
"indicator": [
"ontx_positive_tb_screened_cd4_below_200_female_less_than_15",
"ontx_positive_tb_screened_cd4_below_200_male_less_than_15",
"ontx_positive_tb_screened_cd4_below_200_female_more_than_15",
"ontx_positive_tb_screened_cd4_below_200_male_more_than_15",
"ontx_positive_tb_screened_cd4_below_200"
]
},
{
"refno": "4.3",
"label": "Number of NEW client whose ART initiation was delayed due to tuberculosis treatment",
"indicator": [
"delayed_art_female_less_than_15",
"delayed_art_male_less_than_15",
"delayed_art_female_more_than_15",
"delayed_art_male_more_than_15",
"delayed_art"
]
}
]
},
{
"sectionTitle": "NEW CRYPTOCOCCAL MENINGITIS",
"indicators": [
{
"refno": "5",
"label": "Number of NEW clients CD4 < 200 who received a Crag Test for cryptococcal meningitis",
"indicator": [
"crag_test_done_female_less_than_15",
"crag_test_done_male_less_than_15",
"crag_test_done_female_more_than_15",
"crag_test_done_male_more_than_15",
"crag_test_done"
]
},
{
"refno": "5.1",
"label": "Number of NEW clients CD4 < 200 Crag Test positive for cryptococcal meningitis",
"indicator": [
"crag_test_positive_female_less_than_15",
"crag_test_positive_male_less_than_15",
"crag_test_positive_female_more_than_15",
"crag_test_positive_male_more_than_15",
"crag_test_positive"
]
},
{
"refno": "5.2",
"label": "Number of NEW clients CD4 < 200 Treated for cryptococcal meningitis",
"indicator": [
"on_cm_treatment_female_less_than_15",
"on_cm_treatment_male_less_than_15",
"on_cm_treatment_female_more_than_15",
"on_cm_treatment_male_more_than_15",
"on_cm_treatment"
]
},
{
"refno": "5.3",
"label": "Number of client whose ART initiation was delayed due to cryptococcal meningitis treatment",
"indicator": [
"delayed_art_due_to_cm_female_less_than_15",
"delayed_art_due_to_cm_male_less_than_15",
"delayed_art_due_to_cm_female_more_than_15",
"delayed_art_due_to_cm_male_more_than_15",
"delayed_art_due_to_cm"
]
},
{
"refno": "6",
"label": "Number of clients Started Cryptococcal Treatment 6 months ago and still current on Cryptococcal Mengitis treatment",
"indicator": [
"started_cm_6mons_female_less_than_15",
"started_cm_6mons_male_less_than_15",
"started_cm_6mons_female_more_than_15",
"started_cm_6mons_male_more_than_15",
"started_cm_6mons"
]
},
{
"refno": "6.1",
"label": "Number of clients Started Cryptococcal Treatment 6 months ago and have CD4 Test done at month 6",
"indicator": [
"started_cm_6mons_cd4_done_female_less_than_15",
"started_cm_6mons_cd4_done_male_less_than_15",
"started_cm_6mons_cd4_done_female_more_than_15",
"started_cm_6mons_cd4_done_male_more_than_15",
"started_cm_6mons_cd4_done"
]
},
{
"refno": "7",
"label": "Number of clients Started Cryptococcal Treatment 12 months ago and still current on Cryptococcal Mengitis treatment",
"indicator": [
"started_cm_12mons_female_less_than_15",
"started_cm_12mons_male_less_than_15",
"started_cm_12mons_female_more_than_15",
"started_cm_12mons_male_more_than_15",
"started_cm_12mons"
]
},
{
"refno": "7.1",
"label": "Number of clients Started Cryptococcal Treatment 12 months ago and have CD4 Test done at month 12",
"indicator": [
"started_cm_12mons_cd4_done_female_less_than_15",
"started_cm_12mons_cd4_done_male_less_than_15",
"started_cm_12mons_cd4_done_female_more_than_15",
"started_cm_12mons_cd4_done_male_more_than_15",
"started_cm_12mons_cd4_done"
]
}
]
},
{
"sectionTitle": "NEW TOXOPLASMOSIS",
"indicators": [
{
"refno": "8",
"label": "Number of NEW Clients with CD4<200 Diagnosed with Toxoplasmosis",
"indicator": [
"on_toxoplasmosis_treatment_female_less_than_15",
"on_toxoplasmosis_treatment_male_less_than_15",
"on_toxoplasmosis_treatment_female_more_than_15",
"on_toxoplasmosis_treatment_male_more_than_15",
"on_toxoplasmosis_treatment"
]
},
{
"refno": "8.1",
"label": "Number of NEW Clients with CD4<200 on Treatment for Toxoplasmosis",
"indicator": [
"on_toxoplasmosis_treatment_female_less_than_15",
"on_toxoplasmosis_treatment_male_less_than_15",
"on_toxoplasmosis_treatment_female_more_than_15",
"on_toxoplasmosis_treatment_male_more_than_15",
"on_toxoplasmosis_treatment"
]
}
]
},
{
"sectionTitle": "NEW PCP/PJP",
"indicators": [
{
"refno": "9",
"label": "Number of NEW Clients with CD4<200 Diagnosed with PCP/PJP",
"indicator": [
"on_pcp_treatment_female_less_than_15",
"on_pcp_treatment_male_less_than_15",
"on_pcp_treatment_female_more_than_15",
"on_pcp_treatment_male_more_than_15",
"on_pcp_treatment"
]
},
{
"refno": "9.1",
"label": "Number of NEW Clients with CD4<200 on Treatment for PCP/PJP",
"indicator": [
"on_pcp_treatment_female_less_than_15",
"on_pcp_treatment_male_less_than_15",
"on_pcp_treatment_female_more_than_15",
"on_pcp_treatment_male_more_than_15",
"on_pcp_treatment"
]
},
{
"refno": "10",
"label": "Number of NEW Clients with CD4<200 Diagnosed with KS",
"indicator": [
"on_ks_treatment_female_less_than_15",
"on_ks_treatment_male_less_than_15",
"on_ks_treatment_female_more_than_15",
"on_ks_treatment_male_more_than_15",
"on_ks_treatment"
]
},
{
"refno": "10",
"label": "Number of NEW Clients with CD4<200 on Treatment for KS",
"indicator": [
"on_ks_treatment_female_less_than_15",
"on_ks_treatment_male_less_than_15",
"on_ks_treatment_female_more_than_15",
"on_ks_treatment_male_more_than_15",
"on_ks_treatment"
]
}
]
}
]
125 changes: 125 additions & 0 deletions service/ahd-monthly-summary.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import ReportProcessorHelpersService from '../app/reporting-framework/report-processor-helpers.service.js';
import { MultiDatasetPatientlistReport } from '../app/reporting-framework/multi-dataset-patientlist.report.js';

const _ = require('lodash');
const Moment = require('moment');

const ahdReportSections = require('../service/ahd-indicator-definitions.json');
const ahdReportPatientListCols = require('../app/reporting-framework/json-reports/ahd_reports/ahd-monthly-report-patient-list-cols.json');

const etlHelpers = require('../etl-helpers.js');

export class AHDMonthlySummaryService extends MultiDatasetPatientlistReport {
constructor(reportName, params) {
super(reportName, params);
params.hivMonthlyDatasetSource = 'etl.hiv_monthly_report_dataset_frozen';
}

generateReport(additionalParams) {
const that = this;
return new Promise((resolve, reject) => {
that
.getSourceTables()
.then((sourceTables) => {
that.params.hivMonthlyDatasetSource =
sourceTables.hivMonthlyDatasetSource;
super.generateReport(additionalParams).then((results) => {
if (additionalParams && additionalParams.type === 'patient-list') {
resolve(results);
} else {
let finalResult = [];
const reportProcessorHelpersService = new ReportProcessorHelpersService();
for (let result of results) {
if (
result.report &&
result.report.reportSchemas &&
result.report.reportSchemas.main &&
result.report.reportSchemas.main.transFormDirectives
.joinColumn
) {
finalResult = reportProcessorHelpersService.joinDataSets(
that.params[
result.report.reportSchemas.main.transFormDirectives
.joinColumnParam
] ||
result.report.reportSchemas.main.transFormDirectives
.joinColumn,
finalResult,
result.results.results.results
);
}
}

resolve({
queriesAndSchemas: results,
result: finalResult,
sectionDefinitions: ahdReportSections,
indicatorDefinitions: []
});
}
});
})
.catch((error) => {
reject(error);
});
});
}
getSourceTables() {
const self = this;
return new Promise((resolve, reject) => {
let query = 'select * from etl.moh_731_last_release_month';
let runner = self.getSqlRunner();

runner
.executeQuery(query)
.then((results) => {
const lastReleasedMonth = results[0]['last_released_month'];
let sourceTables = {
hivMonthlyDatasetSource: this.determineSourceTable(
self.params.endingMonth,
lastReleasedMonth
)
};

resolve(sourceTables);
})
.catch((error) => {
reject(error);
});
});
}
determineSourceTable(month, lastReleasedMonth) {
// set default source table to frozen table
let sourceTable = 'etl.hiv_monthly_report_dataset_frozen';
if (Moment(lastReleasedMonth).isSameOrAfter(Moment(month))) {
sourceTable = 'etl.hiv_monthly_report_dataset_frozen';
} else {
sourceTable = 'etl.hiv_monthly_report_dataset_v1_2';
}
return sourceTable;
}

generatePatientListReport(reportParams) {
const indicators = reportParams.requestIndicators.split(',') || [];
let self = this;
return new Promise((resolve, reject) => {
super
.generatePatientListReport(indicators)
.then((results) => {
let result = results.result;
results['results'] = {
results: result
};
results['patientListCols'] = ahdReportPatientListCols;
delete results['result'];
_.each(results.results.results, (row) => {
row.cur_meds = etlHelpers.getARVNames(row.cur_meds);
});
resolve(results);
})
.catch((err) => {
reject(err);
});
});
}
}