From da8df1ff0b2b063b5381d9f6f5a46effd5db5eeb Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:24:02 +0300 Subject: [PATCH] POC-392: Develop Advanced HIV Disease Report --- app/reporting-framework/base-mysql.report.js | 43 +- .../ahd-cohort-monthly-aggregate.json | 300 ++++++ .../ahd-cohort-monthly-dataset-base.json | 415 ++++++++ .../ahd_reports/ahd-monthly-aggregate.json | 624 +++++++++++ .../ahd_reports/ahd-monthly-dataset-base.json | 787 ++++++++++++++ .../ahd-monthly-report-patient-list-cols.json | 108 ++ .../json-reports/ahd_reports/ahd-monthly.json | 3 + .../ahd_monthly_patient_list_template.json | 967 ++++++++++++++++++ ...hd_monthly_patient_list_template_post.json | 146 +++ .../rri/pmtct_rri_patient_list_template.json | 4 +- .../multi-dataset-patientlist.report.js | 1 + app/routes/ahd-monthly-summary.route.js | 93 ++ service/ahd-indicator-definitions.json | 289 ++++++ service/ahd-monthly-summary.service.js | 125 +++ 14 files changed, 3902 insertions(+), 3 deletions(-) create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-aggregate.json create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-dataset-base.json create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd-monthly-aggregate.json create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd-monthly-dataset-base.json create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd-monthly-report-patient-list-cols.json create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd-monthly.json create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template.json create mode 100644 app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template_post.json create mode 100644 app/routes/ahd-monthly-summary.route.js create mode 100644 service/ahd-indicator-definitions.json create mode 100644 service/ahd-monthly-summary.service.js diff --git a/app/reporting-framework/base-mysql.report.js b/app/reporting-framework/base-mysql.report.js index d7128c4e9..369feb0bf 100755 --- a/app/reporting-framework/base-mysql.report.js +++ b/app/reporting-framework/base-mysql.report.js @@ -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); }); }); diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-aggregate.json b/app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-aggregate.json new file mode 100644 index 000000000..fa5a1c316 --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-aggregate.json @@ -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": "<> = <>", + "baseColumn": "person_id", + "templateColumn": "person_id" + } + } + } + } +} diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-dataset-base.json b/app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-dataset-base.json new file mode 100644 index 000000000..b20b7fe97 --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd-cohort-monthly-dataset-base.json @@ -0,0 +1,415 @@ +{ + "name": "ahdCohortMonthlyDataSetBase", + "version": "1.0", + "tag": "", + "description": "", + "uses": [], + "sources": [ + { + "table": "etl.hiv_monthly_report_dataset_frozen", + "alias": "hmd" + }, + + { + "table": "etl.flat_hiv_summary_v15b", + "alias": "fhs", + "join": { + "type": "left", + "joinCondition": "hmd.person_id = fhs.person_id AND fhs.is_clinical_encounter = 1" + } + }, + { + "table": "etl.dates", + "alias": "dts", + "join": { + "type": "INNER", + "joinCondition": "fhs.encounter_datetime <= dts.endDate" + } + }, + { + "table": "etl.flat_hiv_summary_ext_v1", + "alias": "fhse", + "join": { + "type": "left", + "joinCondition": "fhs.encounter_id = fhse.encounter_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "INNER", + "joinCondition": "hmd.location_id = l.location_id" + } + }, + { + "table": "amrs.person", + "alias": "p", + "join": { + "type": "INNER", + "joinCondition": "p.person_id = hmd.person_id" + } + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "location", + "column": "l.name" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "l.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "hmd.location_id" + }, + { + "type": "simple_column", + "alias": "encounter_datetime", + "column": "fhs.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "month", + "column": "fhs.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "person_id", + "column": "p.person_id" + }, + { + "type": "simple_column", + "alias": "gender", + "column": "p.gender" + }, + { + "type": "simple_column", + "alias": "age", + "column": "hmd.age" + }, + { + "type": "derived_column", + "alias": "cd4_justification_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.cd4_justification in(9469,12083) and (p.gender = 'F' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "cd4_justification_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.cd4_justification in(9469,12083) and (p.gender = 'F' AND hmd.age > 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "cd4_justification_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.cd4_justification in(9469,12083) and (p.gender = 'M' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "cd4_justification_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.cd4_justification in(9469,12083) and (p.gender = 'M' AND hmd.age > 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "cd4_justification", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.cd4_justification in(9469,12083) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_due_to_cm_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.reason_for_arv_init_delay = 12045 and (p.gender = 'F' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_due_to_cm_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.reason_for_arv_init_delay = 12045 and (p.gender = 'F' AND hmd.age > 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_due_to_cm_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.reason_for_arv_init_delay = 12045 and (p.gender = 'M' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_due_to_cm_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.reason_for_arv_init_delay = 12045 and (p.gender = 'M' AND hmd.age > 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_due_to_cm", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN fhse.reason_for_arv_init_delay = 12045 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_cd4_done_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 6) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_cd4_done_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 6) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_cd4_done_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 6) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_cd4_done_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 6) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_6mons_cd4_done", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 6) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 6) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_cd4_done_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 12) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_cd4_done_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'F' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 12) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_cd4_done_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 12) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_cd4_done_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (p.gender = 'M' AND hmd.age > 15) AND (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 12) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "started_cm_12mons_cd4_done", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (TIMESTAMPDIFF(MONTH, fhse.cm_treatment_start_date, DATE(hmd.endDate)) = 12) AND fhse.cm_treatment_end_date IS NULL AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(fhse.cm_treatment_start_date)) = 12) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "age_range", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "extract(year from (from_days(datediff(now(),p.birthdate)))) >= 15", + "value": "15_and_above" + }, + { + "condition": "else", + "value": "below_15" + } + ] + } + }, + { + "type": "derived_column", + "alias": "encounter_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "MONTH(fhs.encounter_datetime)" + } + }, + { + "type": "derived_column", + "alias": "reporting_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "date_format(fhs.encounter_datetime, '%m/%Y')" + } + }, + { + "type": "derived_column", + "alias": "encounter_year", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "YEAR(fhs.encounter_datetime)" + } + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "hmd.endDate = ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.encounter_datetime >= ?", + "parameterName": "startDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.encounter_datetime <= ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "l.uuid in ?", + "parameterName": "locationUuids" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(fhs.encounter_datetime,p.birthdate)/365) >= 0" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(fhs.encounter_datetime,p.birthdate)/365) <= 120" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["hmd.person_id"], + "excludeParam": "excludeParam" + } +} diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-aggregate.json b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-aggregate.json new file mode 100644 index 000000000..69bb775a6 --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-aggregate.json @@ -0,0 +1,624 @@ +{ + "name": "ahdMonthlyAggregate", + "version": "1.0", + "tag": "", + "uses": [ + { + "name": "ahdMonthlyDataSetBase", + "version": "1.0", + "type": "dataset_def" + } + ], + "sources": [ + { + "dataSet": "ahdMonthlyDataSetBase", + "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": "new_on_art_this_month_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.new_on_art_this_month_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.new_on_art_this_month_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.new_on_art_this_month_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.new_on_art_this_month_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.new_on_art_this_month)" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.classified_as_who_stage_3_or_4_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.classified_as_who_stage_3_or_4_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.classified_as_who_stage_3_or_4_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.classified_as_who_stage_3_or_4_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.classified_as_who_stage_3_or_4)" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.baseline_cd4_done_this_month_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.baseline_cd4_done_this_month_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.baseline_cd4_done_this_month_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.baseline_cd4_done_this_month_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.baseline_cd4_done_this_month)" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.cd4_below_200_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.cd4_below_200_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.cd4_below_200_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.cd4_below_200_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.cd4_below_200)" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.tb_screened_cd4_below_200_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.tb_screened_cd4_below_200_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.tb_screened_cd4_below_200_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.tb_screened_cd4_below_200_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.tb_screened_cd4_below_200)" + } + }, + + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.positive_tb_screened_cd4_below_200_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.positive_tb_screened_cd4_below_200_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.positive_tb_screened_cd4_below_200_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.positive_tb_screened_cd4_below_200_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.positive_tb_screened_cd4_below_200)" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.ontx_positive_tb_screened_cd4_below_200_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.ontx_positive_tb_screened_cd4_below_200_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.ontx_positive_tb_screened_cd4_below_200_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.ontx_positive_tb_screened_cd4_below_200_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.ontx_positive_tb_screened_cd4_below_200)" + } + }, + + { + "type": "derived_column", + "alias": "delayed_art_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.delayed_art_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.delayed_art_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.delayed_art_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.delayed_art_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "delayed_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.delayed_art)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_done_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_done_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_done_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_done_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_done)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_positive_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_positive_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_positive_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_positive_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.crag_test_positive)" + } + }, + + { + "type": "derived_column", + "alias": "on_cm_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_cm_treatment_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_cm_treatment_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_cm_treatment_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_cm_treatment_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_cm_treatment)" + } + }, + + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_toxoplasmosis_treatment_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_toxoplasmosis_treatment_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_toxoplasmosis_treatment_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_toxoplasmosis_treatment_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_toxoplasmosis_treatment)" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_pcp_treatment_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_pcp_treatment_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_pcp_treatment_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_pcp_treatment_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_pcp_treatment)" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_ks_treatment_female_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_ks_treatment_male_less_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_ks_treatment_female_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_ks_treatment_male_more_than_15)" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(ahd_base.on_ks_treatment)" + } + } + ], + "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": "<> = <>", + "baseColumn": "person_id", + "templateColumn": "person_id" + } + } + } + } +} diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-dataset-base.json b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-dataset-base.json new file mode 100644 index 000000000..db1c1c57a --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-dataset-base.json @@ -0,0 +1,787 @@ +{ + "name": "ahdMonthlyDataSetBase", + "version": "1.0", + "tag": "", + "description": "", + "uses": [], + "sources": [ + { + "table": "etl.hiv_monthly_report_dataset_frozen", + "alias": "hmd" + }, + + { + "table": "etl.flat_hiv_summary_v15b", + "alias": "fhs", + "join": { + "type": "left", + "joinCondition": "hmd.person_id = fhs.person_id AND fhs.is_clinical_encounter = 1" + } + }, + { + "table": "etl.dates", + "alias": "dts", + "join": { + "type": "INNER", + "joinCondition": "fhs.encounter_datetime <= dts.endDate" + } + }, + { + "table": "etl.flat_hiv_summary_ext_v1", + "alias": "fhse", + "join": { + "type": "left", + "joinCondition": "fhs.encounter_id = fhse.encounter_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "INNER", + "joinCondition": "hmd.location_id = l.location_id" + } + }, + { + "table": "amrs.person", + "alias": "p", + "join": { + "type": "INNER", + "joinCondition": "p.person_id = hmd.person_id" + } + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "location", + "column": "l.name" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "l.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "hmd.location_id" + }, + { + "type": "simple_column", + "alias": "encounter_datetime", + "column": "fhs.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "month", + "column": "fhs.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "person_id", + "column": "p.person_id" + }, + { + "type": "simple_column", + "alias": "gender", + "column": "p.gender" + }, + { + "type": "simple_column", + "alias": "age", + "column": "hmd.age" + }, + { + "type": "simple_column", + "alias": "enrollment_date", + "column": "DATE_FORMAT(hmd.enrollment_date,'%Y-%m-%d')" + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 and (p.gender = 'F' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 and (p.gender = 'F' AND hmd.age > 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 and (p.gender = 'M' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "new_on_art_this_month_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 and (p.gender = 'M' AND hmd.age > 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 AND (fhs.cur_who_stage = 3 OR fhs.cur_who_stage = 4) AND (p.gender = 'F' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 AND (fhs.cur_who_stage = 3 OR fhs.cur_who_stage = 4) AND (p.gender = 'M' AND hmd.age <= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 AND (fhs.cur_who_stage = 3 OR fhs.cur_who_stage = 4) AND (p.gender = 'F' AND hmd.age >= 15) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 AND (fhs.cur_who_stage = 3 OR fhs.cur_who_stage = 4) AND (p.gender = 'M' AND hmd.age >= 15)THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "classified_as_who_stage_3_or_4", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month=1 AND (fhs.cur_who_stage = 3 OR fhs.cur_who_stage = 4) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH,fhs.cd4_1_date,DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL THEN 1 ELSE 0 END " + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "baseline_cd4_done_this_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL THEN 1 ELSE 0 END " + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1<200 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH,fhs.cd4_1_date,DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1<200 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1<200 THEN 1 ELSE 0 END " + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1<200 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1<200 THEN 1 ELSE 0 END " + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) and fhs.tb_screen=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "tb_screened_cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 THEN 1 ELSE 0 END" + } + }, + + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) and fhs.tb_screen=1 and fhs.tb_test_result=703 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "positive_tb_screened_cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 THEN 1 ELSE 0 END" + } + }, + + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "ontx_positive_tb_screened_cd4_below_200", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 and (fhs.tb_tx_start_date< fhs.arv_start_date) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 and (fhs.tb_tx_start_date< fhs.arv_start_date) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 and (fhs.tb_tx_start_date< fhs.arv_start_date) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 and (fhs.tb_tx_start_date< fhs.arv_start_date) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "delayed_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200 and fhs.tb_screen=1 and fhs.tb_test_result=703 and fhs.on_tb_tx =1 and (fhs.tb_tx_start_date< fhs.arv_start_date) THEN 1 ELSE 0 END" + } + }, + + { + "type": "derived_column", + "alias": "crag_test_done", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_done_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 THEN 1 ELSE 0 END" + } + }, + + { + "type": "derived_column", + "alias": "crag_test_positive", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'F' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "crag_test_positive_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (p.gender = 'M' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 and fhse.on_cm_treatment=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 and fhse.on_cm_treatment=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 and fhse.on_cm_treatment=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 and fhse.on_cm_treatment=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_cm_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) AND fhse.cm_test=1 and fhse.cm_result=2 and fhse.on_cm_treatment=1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (TIMESTAMPDIFF(MONTH, fhse.toxo_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhse.toxo_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhse.toxo_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhse.toxo_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_toxoplasmosis_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhse.toxo_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (TIMESTAMPDIFF(MONTH, fhse.pcp_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhse.pcp_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN ( hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhse.pcp_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhse.pcp_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_pcp_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhse.pcp_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + + { + "type": "derived_column", + "alias": "pregnant", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND fhs.is_pregnant = 1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "breastfeeding", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN hmd.started_art_this_month = 1 AND fhs.is_mother_breastfeeding = 1 THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "stf", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND fhs.vl_1 >1000 then 1 ELSE 0 end" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND TIMESTAMPDIFF(MONTH, fhse.ks_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_female_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhse.ks_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_male_less_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age <= 15) and (TIMESTAMPDIFF(MONTH, fhse.ks_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_female_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'F' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhse.ks_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "on_ks_treatment_male_more_than_15", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN (hmd.started_art_this_month = 1 AND p.gender = 'M' AND hmd.age >= 15) and (TIMESTAMPDIFF(MONTH, fhse.ks_tx_start_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL AND fhs.cd4_1 < 200) THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND fhs.cd4_1 < 200 then 1 ELSE 0 end" + } + }, + { + "type": "simple_column", + "alias": "art_start_date", + "column": "hmd.arv_start_date" + }, + { + "type": "simple_column", + "alias": "new_on_art_this_month", + "column": "hmd.started_art_this_month" + }, + { + "type": "derived_column", + "alias": "received_cd4_results", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN hmd.started_art_this_month = 1 AND (TIMESTAMPDIFF(MONTH, fhs.cd4_1_date, DATE(dts.endDate)) < 1 AND fhs.cd4_2_date IS NULL) AND fhs.cd4_1 IS NOT NULL THEN 1 ELSE 0 END" + } + }, + { + "type": "derived_column", + "alias": "age_range", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "extract(year from (from_days(datediff(now(),p.birthdate)))) >= 15", + "value": "15_and_above" + }, + { + "condition": "else", + "value": "below_15" + } + ] + } + }, + { + "type": "derived_column", + "alias": "encounter_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "MONTH(fhs.encounter_datetime)" + } + }, + { + "type": "derived_column", + "alias": "reporting_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "date_format(fhs.encounter_datetime, '%m/%Y')" + } + }, + { + "type": "derived_column", + "alias": "encounter_year", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "YEAR(fhs.encounter_datetime)" + } + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "hmd.endDate = ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.encounter_datetime >= ?", + "parameterName": "startDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.encounter_datetime <= ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "l.uuid in ?", + "parameterName": "locationUuids" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(fhs.encounter_datetime,p.birthdate)/365) >= 0" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(fhs.encounter_datetime,p.birthdate)/365) <= 120" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["hmd.person_id"], + "excludeParam": "excludeParam" + } +} diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-report-patient-list-cols.json b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-report-patient-list-cols.json new file mode 100644 index 000000000..f5c858f92 --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly-report-patient-list-cols.json @@ -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 + } + ] +} diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd-monthly.json b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly.json new file mode 100644 index 000000000..f47813720 --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd-monthly.json @@ -0,0 +1,3 @@ +{ + "reports": ["ahdMonthlyAggregate", "ahdCohortMonthlyAggregate"] +} diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template.json b/app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template.json new file mode 100644 index 000000000..8668d959f --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template.json @@ -0,0 +1,967 @@ +{ + "name": "ahd_monthly_report_patient_list_template", + "version": "1.0", + "tag": "ahd_monthly_report_patient_list_template", + "description": "AHD patient list template", + "uses": [], + "sources": [ + { + "table": "etl.hiv_monthly_report_dataset_frozen", + "alias": "hm" + }, + { + "table": "etl.hiv_monthly_report_dataset_frozen", + "alias": "n", + "join": { + "type": "LEFT", + "joinCondition": "hm.person_id = n.person_id" + } + }, + { + "table": "amrs.location", + "alias": "nl", + "join": { + "type": "LEFT", + "joinCondition": "nl.location_id = n.location_id" + } + }, + { + "table": "etl.flat_patient_identifiers_v1", + "alias": "flat_identifiers", + "join": { + "type": "LEFT", + "joinCondition": "hm.person_id = flat_identifiers.patient_id" + } + }, + { + "table": "amrs.location", + "alias": "cl", + "join": { + "type": "LEFT", + "joinCondition": "cl.location_id = hm.location_id" + } + }, + { + "table": "etl.flat_transfers", + "alias": "to", + "join": { + "type": "LEFT", + "joinCondition": "to.person_id = n.person_id AND DATE(to.encounter_datetime) = DATE(n.transfer_out_date)" + } + }, + { + "table": "etl.flat_death_reporting", + "alias": "d", + "join": { + "type": "LEFT", + "joinCondition": "d.person_id = n.person_id" + } + }, + { + "table": "amrs.person", + "alias": "t1", + "join": { + "type": "INNER", + "joinCondition": "hm.person_id = t1.person_id" + } + }, + { + "table": "amrs.person_name", + "alias": "person_name", + "join": { + "type": "LEFT", + "joinCondition": "t1.person_id = person_name.person_id AND (person_name.voided IS NULL || person_name.voided = 0) AND person_name.preferred = 1" + } + }, + { + "table": "amrs.patient_identifier", + "alias": "id", + "join": { + "type": "LEFT", + "joinCondition": "t1.person_id = id.patient_id AND (id.voided IS NULL || id.voided = 0) AND id.identifier_type not in(28,43,45)" + } + }, + { + "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 in (10, 48)" + } + }, + { + "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 " + } + }, + { + "table": "amrs.encounter_type", + "alias": "et", + "join": { + "type": "LEFT", + "joinCondition": "fh.encounter_type = et.encounter_type_id" + } + }, + { + "table": "amrs.person_address", + "alias": "pa", + "join": { + "type": "LEFT", + "joinCondition": "t1.person_id = pa.person_id" + } + }, + { + "table": "etl.flat_covid_extract", + "alias": "ce", + "join": { + "type": "LEFT", + "joinCondition": "t1.person_id = ce.person_id AND ce.next_encounter_datetime IS NULL" + } + }, + { + "table": "etl.flat_consent", + "alias": "consent", + "join": { + "type": "LEFT", + "joinCondition": "consent.person_id = t1.person_id" + } + }, + { + "table": " etl.flat_cervical_cancer_screening_rc", + "alias": "cs", + "join": { + "type": "LEFT", + "joinCondition": "cs.person_id = t1.person_id AND cs.next_clinical_datetime_cervical_cancer_screening IS NULL" + } + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "person_id", + "column": "hm.person_id" + }, + { + "type": "simple_column", + "alias": "end_date", + "column": "DATE_FORMAT(n.endDate,'%Y-%m-%d')" + }, + { + "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": "start_month", + "column": "DATE_FORMAT(hm.endDate,'%Y-%m')" + }, + { + "type": "simple_column", + "alias": "end_month", + "column": "DATE_FORMAT(n.endDate,'%Y-%m')" + }, + { + "type": "simple_column", + "alias": "location", + "column": "cl.name" + }, + { + "type": "simple_column", + "alias": "enrollment_date", + "column": "DATE_FORMAT(hm.enrollment_date,'%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "transfer_out_date_v1", + "column": "DATE_FORMAT(hm.transfer_out_date,'%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "cl.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "hm.location_id" + }, + { + "type": "simple_column", + "alias": "prev_location_id", + "column": "hm.prev_location_id" + }, + { + "type": "derived_column", + "alias": "on_art_starting", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hm.on_art_this_month = 1, 1, NULL)" + } + }, + { + "type": "derived_column", + "alias": "not_on_art_starting", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hm.on_art_this_month = 0, 1, NULL)" + } + }, + { + "type": "derived_column", + "alias": "starting_active", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hm.status = 'active', 1, NULL)" + } + }, + { + "type": "derived_column", + "alias": "dead", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status = 'dead' AND hm.location_id = n.location_id, 1, NULL)" + } + }, + { + "type": "derived_column", + "alias": "dead_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status = 'dead' AND n.cur_arv_meds IS NOT NULL AND hm.location_id = n.location_id, 1, NULL)" + } + }, + { + "type": "derived_column", + "alias": "dead_not_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status = 'dead' AND hm.cur_arv_meds IS NULL AND hm.location_id = n.location_id, 1, NULL)" + } + }, + { + "type": "derived_column", + "alias": "death_report_date", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "DATE_FORMAT(d.encounter_datetime,'%Y-%m-%d')" + } + }, + { + "type": "derived_column", + "alias": "cause_of_death", + "expressionType": "simple_expression", + "expressionOptions": { + "caseOptions": [ + { + "condition": "d.cause_of_death = 1548", + "value": "HEALTH ISSUES" + }, + { + "condition": "d.cause_of_death = 5622", + "value": "OTHER NON-CODED" + }, + { + "condition": "d.cause_of_death = 84", + "value": "ACCIDENT" + }, + { + "condition": "d.cause_of_death = 1572", + "value": "MURDER" + }, + { + "condition": "d.cause_of_death = 1571", + "value": "SUICIDE" + }, + { + "condition": "d.cause_of_death = 1593", + "value": "PATIENT DIED" + }, + { + "condition": "d.cause_of_death = 7257", + "value": "MATERNAL DEATH" + }, + { + "condition": "d.cause_of_death = 1067", + "value": "UNKNOWN" + }, + { + "condition": "d.cause_of_death = 16", + "value": "DIARRHEA" + }, + { + "condition": "d.cause_of_death = 86", + "value": "ACCIDENT" + }, + { + "condition": "d.cause_of_death = 507", + "value": "KAPOSI SARCOMA" + }, + { + "condition": "d.cause_of_death = 5041", + "value": "HIV STAGING - LYMPHOMA" + }, + { + "condition": "d.cause_of_death = 123", + "value": "MALARIA" + }, + { + "condition": "d.cause_of_death = 60", + "value": "MENINGITIS" + }, + { + "condition": "d.cause_of_death = 43", + "value": "PNEUMONIA" + }, + { + "condition": "d.cause_of_death = 60", + "value": "MENINGITIS" + }, + { + "condition": "d.cause_of_death = 58", + "value": "TUBERCULOSIS" + }, + { + "condition": "d.cause_of_death = 102", + "value": "TOXICITY" + }, + { + "condition": "d.cause_of_death = 58", + "value": "TUBERCULOSIS" + }, + { + "condition": "d.cause_of_death = 10363", + "value": "HIV RESULTING IN CANCER DISEASE" + }, + { + "condition": "d.cause_of_death = 10364", + "value": "HIV RESULTING IN INFECTIOUS OR PARASITIC DISEASE" + }, + { + "condition": "d.cause_of_death = 10366", + "value": "NATURAL CAUSE" + }, + { + "condition": "d.cause_of_death = 10367", + "value": "DEATH DUE TO NON NATURAL CAUSE" + }, + { + "condition": "d.cause_of_death = 10365", + "value": "NON INFECTIOUS HIV RELATED DISEASE" + }, + { + "condition": "d.cause_of_death = 10367", + "value": "DEATH DUE TO NON NATURAL CAUSE" + }, + { + "condition": "d.cause_of_death = 6483", + "value": "CANCER" + }, + { + "condition": "d.cause_of_death = 903", + "value": "HYPERTENSION" + } + ] + } + }, + + { + "type": "derived_column", + "alias": "ltfu", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status IN ('ltfu') AND hm.location_id = n.location_id,1,NULL)" + } + }, + { + "type": "derived_column", + "alias": "ltfu_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status IN ('ltfu') AND n.cur_arv_meds IS NOT NULL AND hm.location_id = n.location_id,1,NULL)" + } + }, + { + "type": "derived_column", + "alias": "ltfu_not_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status IN ('ltfu') AND n.cur_arv_meds IS NULL AND hm.location_id = n.location_id,1,NULL)" + } + }, + { + "type": "derived_column", + "alias": "defaulter", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status IN ('defaulter') AND hm.location_id = n.location_id,1,NULL)" + } + }, + { + "type": "derived_column", + "alias": "defaulter_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status IN ('defaulter') AND n.cur_arv_meds IS NOT NULL AND hm.location_id = n.location_id,1,NULL)" + } + }, + { + "type": "derived_column", + "alias": "defaulter_not_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.status IN ('defaulter') AND n.cur_arv_meds IS NULL AND hm.location_id = n.location_id,1,NULL)" + } + }, + { + "type": "simple_column", + "alias": "days_since_rtc_date", + "column": "hm.days_since_rtc_date" + }, + { + "type": "simple_column", + "alias": "arv_first_regimen", + "column": "hm.arv_first_regimen" + }, + { + "type": "simple_column", + "alias": "cur_arv_line", + "column": "hm.cur_arv_line" + }, + { + "type": "simple_column", + "alias": "arv_first_regimen_start_date", + "column": "date_format(hm.arv_first_regimen_start_date, '%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "cur_status", + "column": "n.status" + }, + { + "type": "simple_column", + "alias": "death_date", + "column": "date_format(hm.death_date, '%Y-%m-%d')" + }, + { + "type": "derived_column", + "alias": "days_since_ltfu", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(n.days_since_rtc_date > 90,n.days_since_rtc_date - 90,NULL)" + } + }, + { + "type": "derived_column", + "alias": "loss", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN n.status = 'transfer_out' THEN 1 WHEN n.status != 'transfer_out' AND n.location_id != hm.location_id THEN 1 WHEN n.status = 'dead' AND hm.location_id = n.location_id THEN 1 WHEN n.status IN ('ltfu') AND hm.location_id = n.location_id THEN 1 WHEN n.status IN ('defaulter') AND hm.location_id = n.location_id THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "loss_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN n.status = 'transfer_out' AND n.cur_arv_meds IS NOT NULL THEN 1 WHEN n.status != 'transfer_out' AND n.cur_arv_meds IS NOT NULL AND n.location_id != hm.location_id THEN 1 WHEN n.status = 'dead' AND n.cur_arv_meds IS NOT NULL AND hm.location_id = n.location_id THEN 1 WHEN n.status IN ('ltfu') AND n.cur_arv_meds IS NOT NULL AND hm.location_id = n.location_id THEN 1 WHEN n.status IN ('defaulter') AND n.cur_arv_meds IS NOT NULL AND hm.location_id = n.location_id THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "loss_not_on_art", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN n.status = 'transfer_out' AND n.cur_arv_meds IS NULL THEN 1 WHEN n.status != 'transfer_out' AND n.cur_arv_meds IS NULL AND n.location_id != hm.location_id THEN 1 WHEN n.status = 'dead' AND n.cur_arv_meds IS NULL AND hm.location_id = n.location_id THEN 1 WHEN n.status IN ('ltfu') AND n.cur_arv_meds IS NULL AND hm.location_id = n.location_id THEN 1 WHEN n.status IN ('defaulter') AND n.cur_arv_meds IS NULL AND hm.location_id = n.location_id THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "loss_status", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN n.status = 'transfer_out' THEN 'Transfer Out' WHEN n.status != 'transfer_out' AND n.location_id != hm.location_id THEN 'Transfer Out' WHEN n.status = 'dead' AND hm.location_id = n.location_id THEN 'Dead' WHEN n.status IN ('ltfu') AND hm.location_id = n.location_id THEN 'Ltfu/IIT' WHEN n.status IN ('defaulter') AND hm.location_id = n.location_id THEN 'Ltfu/IIT' ELSE NULL END " + } + }, + { + "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": "gender", + "column": "t1.gender" + }, + { + "type": "simple_column", + "alias": "birthdate", + "column": "t1.birthdate" + }, + { + "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": "derived_column", + "alias": "identifiers", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " GROUP_CONCAT(DISTINCT id.identifier SEPARATOR ', ')" + } + }, + { + "type": "derived_column", + "alias": "phone_number_one", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " GROUP_CONCAT(DISTINCT contacts.value SEPARATOR ', ')" + } + }, + { + "type": "simple_column", + "alias": "latest_rtc_date", + "column": "date_format(fh.rtc_date, '%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "latest_vl", + "column": "fh.vl_1" + }, + { + "type": "derived_column", + "alias": "vl_category", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fh.vl_1 < 50", + "value": "LDL" + }, + { + "condition": "(fh.vl_1 >= 50 and fh.vl_1 < 200)", + "value": "Low Risk Low Level Viremia" + }, + { + "condition": "(fh.vl_1 >= 200 and fh.vl_1 < 1000)", + "value": "High Risk Low Level Viremia" + }, + { + "condition": "(fh.vl_1 > 1000)", + "value": "Suspected Treatment Failure" + } + ] + } + }, + { + "type": "simple_column", + "alias": "latest_vl_date", + "column": "date_format(fh.vl_1_date, '%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "last_appointment", + "column": "CONCAT(COALESCE(DATE_FORMAT(fh.encounter_datetime, '%Y-%m-%d'),''),' ',COALESCE(et.name, ''))" + }, + { + "type": "simple_column", + "alias": "cur_meds", + "column": "fh.cur_arv_meds" + }, + { + "type": "simple_column", + "alias": "arv_start_date", + "column": "date_format(fh.arv_first_regimen_start_date,'%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "previous_vl", + "column": "fh.vl_2" + }, + { + "type": "simple_column", + "alias": "previous_vl_date", + "column": "date_format(fh.vl_2_date, '%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "ipt_start_date", + "column": "date_format(fh.ipt_start_date, '%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "ipt_completion_date", + "column": "date_format(fh.ipt_completion_date, '%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "ipt_stop_date", + "column": "date_format(fh.ipt_stop_date, '%Y-%m-%d')" + }, + { + "type": "derived_column", + "alias": "discordant_status", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fh.discordant_status = 1", + "value": "DISCORDANT COUPLE" + }, + { + "condition": "fh.discordant_status = 2", + "value": "NOT A DISCORDANT COUPLE" + }, + { + "condition": "fh.discordant_status = 3", + "value": "UNKNOWN" + }, + { + "condition": "fh.discordant_status = 4", + "value": "NOT APPLICABLE" + }, + { + "condition": "fh.discordant_status = 5", + "value": "CONCORDANT COUPLE POSITIVE" + }, + { + "condition": "fh.discordant_status = 6", + "value": "CONCORDANT COUPLE NEGATIVE" + }, + { + "condition": "else", + "value": "null" + } + ] + } + }, + { + "type": "simple_column", + "alias": "tb_screening_date", + "column": "date_format(fh.tb_screening_datetime, '%Y-%m-%d')" + }, + { + "type": "derived_column", + "alias": "patient_category", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fh.patient_category= 9070", + "value": "Well" + }, + { + "condition": "fh.patient_category= 11550", + "value": "UnWell" + }, + { + "condition": "fh.patient_category = 0", + "value": "N/A" + }, + { + "condition": "fh.patient_category IS NULL", + "value": "N/A" + } + ] + } + }, + { + "type": "derived_column", + "alias": "tb_screening_result", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fh.tb_screening_result = 1107", + "value": "NONE" + }, + { + "condition": "fh.tb_screening_result = 6971", + "value": "POSSIBLE" + }, + { + "condition": "fh.tb_screening_result = 1118", + "value": "NOT DONE" + }, + { + "condition": "fh.tb_screening_result = 6176", + "value": "CURRENTLY ON TUBERCULOSIS TREATMENT" + }, + { + "condition": "fh.tb_screening_result = 6137", + "value": "CONFIRMED" + }, + { + "condition": "fh.tb_screening_result = 656", + "value": "ISONIAZID" + }, + { + "condition": "fh.tb_screening_result = 10678", + "value": "NO SIGNS OR SYMPTOMS OF DISEASE" + }, + { + "condition": "fh.tb_screening_result = 6621", + "value": "NOT ASSESSED" + }, + { + "condition": "fh.tb_screening_result = 10767", + "value": "ON TREATMENT FOR DISEASE" + }, + { + "condition": "fh.tb_screening_result = 10922", + "value": "ISONIAZID PREVENTIVE TREATMENT PROGRAM" + }, + { + "condition": "fh.tb_screening_result = 10974", + "value": "INH PROPHYLAXIS" + }, + { + "condition": "else", + "value": "null" + } + ] + } + }, + { + "type": "simple_column", + "alias": "nearest_center", + "column": "pa.address3" + }, + { + "type": "derived_column", + "alias": "covid_19_vaccination_status", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "ce.vaccination_status = 2208", + "value": "Fully Vaccinated" + }, + { + "condition": "ce.vaccination_status = 11907", + "value": "Partially Vaccinated" + }, + { + "condition": "ce.person_id IS NULL AND ce.second_dose_vaccine_administered IS NULL AND EXTRACT(YEAR FROM (FROM_DAYS(DATEDIFF(NOW(), t1.birthdate)))) >= 15", + "value": "Unknown Covid 19 Vaccination" + }, + { + "condition": "ce.received_covid_19_vaccine = 1066 AND EXTRACT(YEAR FROM (FROM_DAYS(DATEDIFF(NOW(), t1.birthdate)))) >= 15", + "value": "Not vaccinated" + } + ] + } + }, + { + "type": "derived_column", + "alias": "sms_consent_provided", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "consent.patient_sms_consent_provided = 1065", + "value": "YES" + }, + { + "condition": "consent.patient_sms_consent_provided = 1066", + "value": "NO" + } + ] + } + }, + { + "type": "simple_column", + "alias": "sms_receive_time", + "column": "consent.sms_receive_time" + }, + { + "type": "simple_column", + "alias": "cervical_screening_date", + "column": "date_format(cs.encounter_datetime, '%Y-%m-%d')" + }, + { + "type": "derived_column", + "alias": "cervical_screening_method", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "cs.screening_method = 9434", + "value": "VIA or VIA/VILI" + }, + { + "condition": "cs.screening_method = 885", + "value": "PAP SMEAR" + }, + { + "condition": "cs.screening_method = 2322", + "value": "HPV" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test IS NOT NULL", + "value": "VIA or VIA/VILI" + } + ] + } + }, + { + "type": "derived_column", + "alias": "cervical_screening_result", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "cs.via_or_via_vili_test_result = 1", + "value": "NEGATIVE" + }, + { + "condition": "cs.via_or_via_vili_test_result = 2", + "value": "POSITIVE" + }, + { + "condition": "cs.via_or_via_vili_test_result = 3", + "value": "SUSPICIOUS OF CANCER" + }, + { + "condition": "cs.hpv_test_result = 1", + "value": "NEGATIVE" + }, + { + "condition": "cs.hpv_test_result = 2", + "value": "POSITIVE" + }, + { + "condition": "cs.hpv_test_result = 3", + "value": "INDETERMINATE" + }, + { + "condition": "cs.pap_smear_test_result = 1", + "value": "NORMAL" + }, + { + "condition": "cs.pap_smear_test_result = 2", + "value": "ASCUS" + }, + { + "condition": "cs.pap_smear_test_result = 3", + "value": "LSIL" + }, + { + "condition": "cs.pap_smear_test_result = 4", + "value": "HSIL/CIS" + }, + { + "condition": "cs.pap_smear_test_result = 5", + "value": "AGUS" + }, + { + "condition": "cs.pap_smear_test_result = 6", + "value": "INVASIVE CANCER" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 1115", + "value": "NORMAL" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 7469", + "value": "ACETOWHITE LESION" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 5245", + "value": "PALLOR" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 7470", + "value": "PUNCTUATED CAPILLARIES" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 9591", + "value": "OYSTERWHITE LESION" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 9592", + "value": "BRIGHT WHITE LESION" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 7293", + "value": "ULCER" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 6497", + "value": "DYSFUNCTIONAL UTERINE BLEEDING" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 7472", + "value": "ATYPICAL BLOOD VESSELS" + }, + { + "condition": "cs.observations_from_positive_via_or_via_vili_test = 9593", + "value": "FRIABLE TISSUE" + } + ] + } + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "hm.endDate = ?", + "parameterName": "startingMonth" + }, + { + "filterType": "tableColumns", + "conditionExpression": "hm.location_id in ? ", + "parameterName": "locations" + }, + { + "filterType": "tableColumns", + "conditionExpression": "hm.status = 'active'" + }, + { + "filterType": "expressionColumns", + "conditionExpression": "1 = (CASE when n.status = 'transfer_out' AND n.cur_arv_meds IS NOT NULL then 1 when n.status != 'transfer_out' AND n.cur_arv_meds IS NOT NULL AND n.location_id != hm.location_id then 1 ELSE NULL END)", + "parameterName": "", + "dynamicallyGenerated": true + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["person_id", "t1.person_id"] + } +} diff --git a/app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template_post.json b/app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template_post.json new file mode 100644 index 000000000..95691e900 --- /dev/null +++ b/app/reporting-framework/json-reports/ahd_reports/ahd_monthly_patient_list_template_post.json @@ -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"] + } +} diff --git a/app/reporting-framework/json-reports/rri/pmtct_rri_patient_list_template.json b/app/reporting-framework/json-reports/rri/pmtct_rri_patient_list_template.json index aa4c95288..e9f69c70e 100644 --- a/app/reporting-framework/json-reports/rri/pmtct_rri_patient_list_template.json +++ b/app/reporting-framework/json-reports/rri/pmtct_rri_patient_list_template.json @@ -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": [ { diff --git a/app/reporting-framework/multi-dataset-patientlist.report.js b/app/reporting-framework/multi-dataset-patientlist.report.js index d06f5e13c..6b3582831 100755 --- a/app/reporting-framework/multi-dataset-patientlist.report.js +++ b/app/reporting-framework/multi-dataset-patientlist.report.js @@ -55,6 +55,7 @@ export class MultiDatasetPatientlistReport extends MultiDatasetReport { super(reportName, params); } // interprate + generatePatientListReport(indicators) { let additionalParams = { type: 'patient-list', diff --git a/app/routes/ahd-monthly-summary.route.js b/app/routes/ahd-monthly-summary.route.js new file mode 100644 index 000000000..d5f57d999 --- /dev/null +++ b/app/routes/ahd-monthly-summary.route.js @@ -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); diff --git a/service/ahd-indicator-definitions.json b/service/ahd-indicator-definitions.json new file mode 100644 index 000000000..be61f69c0 --- /dev/null +++ b/service/ahd-indicator-definitions.json @@ -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" + ] + } + ] + } +] diff --git a/service/ahd-monthly-summary.service.js b/service/ahd-monthly-summary.service.js new file mode 100644 index 000000000..b8add2815 --- /dev/null +++ b/service/ahd-monthly-summary.service.js @@ -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); + }); + }); + } +}