diff --git a/app/reporting-framework/base-mysql.report.js b/app/reporting-framework/base-mysql.report.js index 005bf2c4e..6961f2216 100755 --- a/app/reporting-framework/base-mysql.report.js +++ b/app/reporting-framework/base-mysql.report.js @@ -38,6 +38,19 @@ import * as starting_art_aggregation_age15 from './json-reports/starting-art-agg import * as starting_art_base_age15 from './json-reports/starting-art-base-age15.json'; import * as starting_art_disaggregation_age15 from './json-reports/starting-art-disaggregation-age15.json'; +//PMTC RRI +// import * as pmtc_rri_dataset_base from './json-reports/rri/pmtct-rri-dataset-base.json'; +import * as pmtct_rri from './json-reports/rri/pmtct-rri.json'; +import * as pmtct_rri_cal_hiv_aggregate from './json-reports/rri/pmtct-rri-cal-hiv-aggregate.json'; +import * as pmtct_rri_pbfw_aggregate from './json-reports/rri/pmtct-rri-pbfw-aggregate.json'; +import * as pmtct_rri_wra_aggregate from './json-reports/rri/pmtct-rri-wra-aggregate.json'; +import * as pmtct_rri_hei_aggregate from './json-reports/rri/hei-infant-rri-testing-aggregate.json'; +import * as pmtc_rri_hei_dataset_base from './json-reports/rri/hei-infant-rri-testing-base.json'; +import * as pmtc_rri_calhiv_dataset_base from './json-reports/rri/pmtct-rri-calhiv-dataset-base.json'; +import * as pmtc_rri__pbfw_dataset_base from './json-reports/rri/pmtct-rri-pbfw-dataset-base.json'; +import * as pmtct_rri_patient_list_template from './json-reports/rri/pmtct_rri_patient_list_template.json'; +import * as pmtc_rri_wra_dataset_base from './json-reports/rri/pmtct-rri-wra-dataset-base.json'; + import * as starting_art_aggregation_age_green from './json-reports/starting-art-aggregation-age-green.json'; import * as starting_art_base_age_green from './json-reports/starting-art-base-age-green.json'; import * as starting_art_disaggregation_age_green from './json-reports/starting-art-disaggregation-age-green.json'; @@ -142,6 +155,7 @@ import * as prep_dataset_report from './json-reports/prep-dataset-report.json'; import * as ltfu_surge_baseline_report from './json-reports/ltfus-surge-baseline-base.json'; import * as ltfu_surge_baseline_aggregate_report from './json-reports/ltfus-surge-baseline-aggregate.json'; import * as prep_report_patient_list_template from './json-reports/prep-report-patient-list-template.json'; +import * as pmtct_rri_report_patient_list_template from './json-reports/rri/pmtct_rri_patient_list_template.json'; import * as hiv_latest_clinical_encounter_date_base from './json-reports/hiv-latest-clinical-encounter-date-base.json'; import * as prep_monthly_summary from './json-reports/prep-monthly-summary.json'; @@ -396,7 +410,7 @@ export class BaseMysqlReport { that.reportQuery = sqlQuery; // run query - // console.log('Query', sqlQuery); + console.log('Query', sqlQuery); that .executeReportQuery(that.reportQuery) .then((result) => { @@ -468,6 +482,11 @@ export class BaseMysqlReport { main: this.cloneJsonSchema(prep_report_patient_list_template) }); break; + case 'pmtct-rri-report-patient-list-template': + resolve({ + main: this.cloneJsonSchema(pmtct_rri_report_patient_list_template) + }); + break; case 'mainDatasetAggregate': resolve({ main: this.cloneJsonSchema(main_dataset_aggregate), @@ -850,6 +869,51 @@ export class BaseMysqlReport { main: this.cloneJsonSchema(cdm_dataset_base) }); break; + // PMTCT-RRI + case 'pmtct_rri_aggregate_summary': + resolve({ + main: this.cloneJsonSchema(pmtct_rri) + }); + break; + case 'pmtctrripatientlisttemplate': + resolve({ + main: this.cloneJsonSchema(pmtct_rri_patient_list_template) + }); + break; + case 'pmtctRriCalhivAggregate': + resolve({ + main: this.cloneJsonSchema(pmtct_rri_cal_hiv_aggregate), + pmtctRriCalhivDataSetBase: this.cloneJsonSchema( + pmtc_rri_calhiv_dataset_base + ) + }); + break; + + case 'pmtctRriPbfwAggregate': + resolve({ + main: this.cloneJsonSchema(pmtct_rri_pbfw_aggregate), + pmtctRriPbfwDataSetBase: this.cloneJsonSchema( + pmtc_rri__pbfw_dataset_base + ) + }); + break; + + case 'pmtctRriWraAggregate': + resolve({ + main: this.cloneJsonSchema(pmtct_rri_wra_aggregate), + pmtctRriWraDataSetBase: this.cloneJsonSchema( + pmtc_rri_wra_dataset_base + ) + }); + break; + case 'pmtctRriHeiAggregate': + resolve({ + main: this.cloneJsonSchema(pmtct_rri_hei_aggregate), + heiInfantRriTestingBase: this.cloneJsonSchema( + pmtc_rri_hei_dataset_base + ) + }); + break; case 'clinicalReminderReport': resolve({ main: this.cloneJsonSchema(clinical_reminders_report), @@ -1739,8 +1803,6 @@ export class BaseMysqlReport { } generateReportQuery(reportSchemas, params) { - // console.log('Passed params', params) - // console.log('report schemas', JSON.stringify(reportSchemas, null, 4)); let jSql = this.getJson2Sql(reportSchemas, params); return new Promise((resolve, reject) => { try { @@ -1757,7 +1819,6 @@ export class BaseMysqlReport { } executeReportQuery(sqlQuery) { - // console.log('Executing Query', sqlQuery); let runner = this.getSqlRunner(); return new Promise((resolve, reject) => { runner diff --git a/app/reporting-framework/json-reports/clinical-reminder-report.json b/app/reporting-framework/json-reports/clinical-reminder-report.json index af46abd99..c5e0f3be0 100644 --- a/app/reporting-framework/json-reports/clinical-reminder-report.json +++ b/app/reporting-framework/json-reports/clinical-reminder-report.json @@ -222,13 +222,43 @@ { "type": "simple_column", "alias": "last_encounter_date", - "column": "ls.encounter_datetime" + "column": "t1.encounter_datetime" }, { "type": "simple_column", "alias": "latest_CD4_Date", "column": "ls.cd4_1_date" }, + { + "type": "simple_column", + "alias": "ipt_start_date", + "column": "ls.ipt_start_date" + }, + { + "type": "simple_column", + "alias": "ipt_stop_date", + "column": "ls.ipt_stop_date" + }, + { + "type": "simple_column", + "alias": "on_ipt", + "column": "ls.on_ipt" + }, + { + "type": "simple_column", + "alias": "ipt_completion_date", + "column": "ls.ipt_completion_date" + }, + { + "type": "simple_column", + "alias": "tb_tx_start_date", + "column": "ls.tb_tx_start_date" + }, + { + "type": "simple_column", + "alias": "tb_tx_end_date", + "column": "ls.tb_tx_end_date" + }, { "type": "simple_column", "alias": "on_tb_tx", diff --git a/app/reporting-framework/json-reports/ml-predictions/ml-weekly-predictions-base.json b/app/reporting-framework/json-reports/ml-predictions/ml-weekly-predictions-base.json index f2fa4b3a7..39d5293e8 100644 --- a/app/reporting-framework/json-reports/ml-predictions/ml-weekly-predictions-base.json +++ b/app/reporting-framework/json-reports/ml-predictions/ml-weekly-predictions-base.json @@ -46,7 +46,23 @@ "alias": "pre", "join": { "type": "LEFT", - "joinCondition": "pre.person_id = ml.person_id" + "joinCondition": "pre.person_id = ml.person_id and(DATEDIFF(ml.start_date, pre.encounter_datetime) <= 7)" + } + }, + { + "table": "( select max(is_successful_phone_follow_up) as latest_phone_follow_up, person_id, follow_up_type from etl.pre_appointment_summary group by person_id )", + "alias": "s", + "join": { + "type": "LEFT", + "joinCondition": "pre.person_id = s.person_id" + } + }, + { + "table": "(SELECT et.person_id, SUM(CASE WHEN et.is_successful_phone_follow_up = 'YES' THEN 0 WHEN et.is_successful_phone_follow_up = 'NO' THEN 1 ELSE 0 END) AS counter FROM etl.pre_appointment_summary et left join predictions.ml_weekly_predictions mwl on et.person_id = mwl.person_id WHERE et.encounter_datetime BETWEEN mwl.prediction_generated_date AND DATE_ADD(mwl.prediction_generated_date, INTERVAL 14 DAY) GROUP BY et.person_id)", + "alias": "etc", + "join": { + "type": "LEFT", + "joinCondition": "ml.person_id = etc.person_id" } } ], @@ -156,9 +172,14 @@ "alias": "was_follow_up_successful", "expressionType": "simple_expression", "expressionOptions": { - "expression": "if((pre.is_successful_phone_follow_up = 'YES' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'YES')), 1, 0)" + "expression": "if((latest_phone_follow_up = 'YES' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'YES')), 1, 0)" } }, + { + "type": "simple_column", + "alias": "number_of_failed_phone_attempts", + "column": "etc.counter" + }, { "type": "simple_column", "alias": "comments", @@ -180,12 +201,12 @@ }, { "filterType": "tableColumns", - "conditionExpression": "(if((pre.is_successful_phone_follow_up = 'YES' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'YES')), 1, 0)) = ?", + "conditionExpression": "(if((latest_phone_follow_up = 'YES' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'YES')), 1, 0)) = ?", "parameterName": "successfulOutcome" }, { "filterType": "tableColumns", - "conditionExpression": "(if((pre.is_successful_phone_follow_up = 'NO' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'NO')), 1, 0)) = ?", + "conditionExpression": "(if((latest_phone_follow_up = 'NO' OR (pre.attempted_home_visit = 'YES' AND pre.was_client_found = 'NO')), 1, 0)) = ?", "parameterName": "failedOutcome" }, { diff --git a/app/reporting-framework/json-reports/patient-list-with-contacts-template.json b/app/reporting-framework/json-reports/patient-list-with-contacts-template.json index f7ac08f90..0dc61d894 100755 --- a/app/reporting-framework/json-reports/patient-list-with-contacts-template.json +++ b/app/reporting-framework/json-reports/patient-list-with-contacts-template.json @@ -103,6 +103,14 @@ "type": "LEFT", "joinCondition": "delivery_report.person_id = t1.person_id and DATE_FORMAT(delivery_report.date_created, '%Y-%m-%d')='{startDate}'" } + }, + { + "table": "etl.flat_prep_summary_v1_1", + "alias": "fps", + "join": { + "type": "LEFT", + "joinCondition": "t1.person_id = fps.person_id AND fps.next_encounter_datetime IS NULL AND fps.encounter_type NOT IN (99999)" + } } ], "columns": [ @@ -142,6 +150,112 @@ "expression": "extract(year from (from_days(datediff(now(),t1.birthdate))))" } }, + { + "type": "simple_column", + "alias": "prev_rtc_date", + "column": "date_format(fps.prev_rtc_date, '%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "cur_prep_meds_names", + "column": "fps.cur_prep_meds_names" + }, + { + "type": "simple_column", + "alias": "rapid_test_date", + "column": "date_format(fps.hiv_rapid_test_date, '%Y-%m-%d')" + }, + { + "type": "derived_column", + "alias": "hiv_rapid_test", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fps.hiv_rapid_test_result = 703", + "value": "Positive" + }, + { + "condition": "fps.hiv_rapid_test_result = 664", + "value": "Negative" + }, + { + "condition": "fps.hiv_rapid_test_result = 1138", + "value": "Indeterminate" + }, + { + "condition": "fps.hiv_rapid_test_result = 1304", + "value": "Poor sample quality" + }, + { + "condition": "fps.hiv_rapid_test_result = 1067", + "value": "Unknown" + } + ] + } + }, + { + "type": "derived_column", + "alias": "population_type_category", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fps.sub_population_type = 1", + "value": "MSM" + }, + { + "condition": "fps.sub_population_type = 2", + "value": "MSW" + }, + { + "condition": "fps.sub_population_type = 3", + "value": "FSW" + }, + { + "condition": "fps.sub_population_type = 4", + "value": "IDU" + }, + { + "condition": "fps.sub_population_type = 5", + "value": "TRANS WOMAN" + }, + { + "condition": "fps.sub_population_type = 6", + "value": "TRANS MAN" + }, + { + "condition": "fps.sub_population_type = 7", + "value": "FISHER FOLK" + }, + { + "condition": "fps.sub_population_type = 8", + "value": "CSW" + }, + { + "condition": "fps.sub_population_type = 9", + "value": "DISPLACED PERSONS" + }, + { + "condition": "fps.sub_population_type = 10", + "value": "Military and other" + }, + { + "condition": "fps.sub_population_type = 12", + "value": "TRUCK/LORRY DRIVER" + }, + { + "condition": "fps.sub_population_type = 13", + "value": "NIDU" + } + ] + } + }, + { + "type": "simple_column", + "alias": "enrollment_date", + "column": "date_format(fps.enrollment_date, '%Y-%m-%d')" + }, { "type": "derived_column", "alias": "person_name", diff --git a/app/reporting-framework/json-reports/prep-monthly/disaggregations/new/new-for-prep-base.json b/app/reporting-framework/json-reports/prep-monthly/disaggregations/new/new-for-prep-base.json index b0880c767..aa31e79ce 100644 --- a/app/reporting-framework/json-reports/prep-monthly/disaggregations/new/new-for-prep-base.json +++ b/app/reporting-framework/json-reports/prep-monthly/disaggregations/new/new-for-prep-base.json @@ -43,7 +43,7 @@ { "type": "simple_column", "alias": "ccc_number", - "column": "fi.ccc" + "column": "IFNULL(fi.ccc, 'No CCC')" }, { "type": "simple_column", @@ -60,6 +60,11 @@ "alias": "age", "column": "pd.age" }, + { + "type": "simple_column", + "alias": "latest_rtc_date", + "column": "date_format(pd.rtc_date, '%Y-%m-%d')" + }, { "type": "simple_column", "alias": "location_id", @@ -76,9 +81,29 @@ "column": "l.uuid" }, { - "type": "simple_column", + "type": "derived_column", "alias": "population_type", - "column": "pd.population_type" + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "pd.population_type = 1", + "value": "discordant" + }, + { + "condition": "pd.population_type = 2", + "value": "priority" + }, + { + "condition": "pd.population_type = 3 or pd.population_type is null", + "value": "general" + }, + { + "condition": "pd.population_type = 4", + "value": "key" + } + ] + } }, { "type": "derived_column", diff --git a/app/reporting-framework/json-reports/rri/hei-infant-rri-testing-aggregate.json b/app/reporting-framework/json-reports/rri/hei-infant-rri-testing-aggregate.json new file mode 100644 index 000000000..f9c929f94 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/hei-infant-rri-testing-aggregate.json @@ -0,0 +1,122 @@ +{ + "name": "heiInfantRriTestingAggregate", + "version": "1.0", + "tag": "", + "description": "", + "uses": [ + { + "name": "heiInfantRriTestingBase", + "version": "1.0", + "type": "dataset_def" + } + ], + "sources": [ + { + "dataSet": "heiInfantRriTestingBase", + "alias": "hmds" + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "reporting_month", + "column": "hmds.reporting_month" + }, + { + "type": "simple_column", + "alias": "location", + "column": "hmds.location" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "hmds.location_id" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "hmds.location_uuid" + }, + { + "type": "derived_column", + "alias": "initial_pcr_less_than_8_wks", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(hmds.initial_pcr_less_than_8_wks)" + } + }, + { + "type": "derived_column", + "alias": "initial_pcr_8_wks_to_12_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(hmds.initial_pcr_8_wks_to_12_months)" + } + }, + { + "type": "derived_column", + "alias": "initial_pcr_less_than_12_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(hmds.initial_pcr_less_than_12_months)" + } + }, + { + "type": "derived_column", + "alias": "second_pcr_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(hmds.second_pcr_6_months)" + } + }, + { + "type": "derived_column", + "alias": "third_pcr_12_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(hmds.third_pcr_12_months)" + } + }, + { + "type": "derived_column", + "alias": "antibody_at_18_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(hmds.antibody_at_18_months)" + } + }, + { + "type": "derived_column", + "alias": "antibody_post_18_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(hmds.antibody_post_18_months)" + } + } + ], + "groupBy": { + "groupParam": "groupByParam", + "columns": ["hmds.reporting_month", "hmds.location_id"], + "excludeParam": "excludeParam" + }, + "transFormDirectives": { + "joinColumn": "location_id", + "skipColumns": [], + "disaggregationColumns": [] + }, + "dynamicJsonQueryGenerationDirectives": { + "patientListGenerator": { + "useTemplate": "hei-report-patient-list-template", + "useTemplateVersion": "1.0", + "generatingDirectives": { + "joinDirectives": { + "joinType": "INNER", + "joinCondition": "<> = <>", + "baseColumn": "person_id", + "templateColumn": "person_id" + } + }, + "skipParams": [] + } + } +} diff --git a/app/reporting-framework/json-reports/rri/hei-infant-rri-testing-base.json b/app/reporting-framework/json-reports/rri/hei-infant-rri-testing-base.json new file mode 100644 index 000000000..8351baff2 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/hei-infant-rri-testing-base.json @@ -0,0 +1,168 @@ +{ + "name": "heiInfantRriTestingBase", + "version": "1.0", + "tag": "hei_infant_rri_testing_base", + "description": "", + "uses": [], + "sources": [ + { + "table": "etl.pmtct_rri_dataset", + "alias": "prd" + }, + { + "table": "etl.hei_monthly_report_dataset", + "alias": "hmd", + "join": { + "type": "inner", + "joinCondition": "prd.person_id = hmd.person_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "inner", + "joinCondition": "hmd.location_id = l.location_id" + } + }, + { + "table": "etl.flat_hei_summary", + "alias": "fhs", + "join": { + "type": "LEFT", + "joinCondition": "hmd.person_id = fhs.person_id AND fhs.next_clinical_datetime_hiv IS NULL" + } + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "person_id", + "column": "hmd.person_id" + }, + { + "type": "simple_column", + "alias": "age", + "column": "prd.age" + }, + { + "type": "simple_column", + "alias": "location", + "column": "hmd.clinic" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "l.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "hmd.location_id" + }, + { + "type": "simple_column", + "alias": "reporting_month", + "column": "DATE_FORMAT(hmd.endDate,'%Y-%m')" + }, + { + "type": "simple_column", + "alias": "month", + "column": "DATE_FORMAT(hmd.endDate,'%Y-%m')" + }, + { + "type": "derived_column", + "alias": "initial_pcr_less_than_8_wks", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hmd.initial_pcr_this_month is null AND hmd.age_in_months < 2 ,NULL,1)" + } + }, + { + "type": "derived_column", + "alias": "initial_pcr_8_wks_to_12_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hmd.initial_pcr_this_month is null AND hmd.age_in_months between 2 and 12,NULL,1)" + } + }, + { + "type": "derived_column", + "alias": "initial_pcr_less_than_12_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hmd.initial_pcr_this_month is null AND hmd.age_in_months < 12,NULL,1)" + } + }, + { + "type": "derived_column", + "alias": "second_pcr_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hmd.second_pcr_this_month is null AND hmd.age_in_months = 6,NULL,1)" + } + }, + { + "type": "derived_column", + "alias": "third_pcr_12_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hmd.third_pcr_this_month is null AND hmd.age_in_months = 12,NULL,1)" + } + }, + { + "type": "derived_column", + "alias": "antibody_at_18_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hmd.initial_antibody_screening_this_month is null AND hmd.age_in_months = 18,NULL,1)" + } + }, + { + "type": "derived_column", + "alias": "antibody_post_18_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "IF(hmd.initial_antibody_screening_this_month is null AND hmd.age_in_months > 18,NULL,1)" + } + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime >= ?", + "parameterName": "startDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime <= ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_type in (115)" + }, + { + "filterType": "tableColumns", + "conditionExpression": "hmd.endDate=?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.age <=20" + }, + { + "filterType": "tableColumns", + "conditionExpression": "hmd.location_id in (?)", + "parameterName": "locations" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd.person_id"], + "excludeParam": "excludeParam" + } +} diff --git a/app/reporting-framework/json-reports/rri/pmtct-rri-cal-hiv-aggregate.json b/app/reporting-framework/json-reports/rri/pmtct-rri-cal-hiv-aggregate.json new file mode 100644 index 000000000..0610e66c3 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-cal-hiv-aggregate.json @@ -0,0 +1,84 @@ +{ + "name": "pmtctRriCalhivAggregate", + "version": "1.0", + "tag": "pmtct_rri_cal_hiv_aggregate", + "uses": [ + { + "name": "pmtctRriCalhivDataSetBase", + "version": "1.0", + "type": "dataset_def" + } + ], + "sources": [ + { + "dataSet": "pmtctRriCalhivDataSetBase", + "alias": "prd_base" + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "Reporting_Month", + "column": "prd_base.reporting_month" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "prd_base.location_id" + }, + { + "type": "simple_column", + "alias": "location_Name", + "column": "prd_base.location" + }, + { + "type": "derived_column", + "alias": "all_calhiv", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(prd_base.person_id)" + } + }, + { + "type": "derived_column", + "alias": "calhiv_vl_done_past_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(prd_base.calhiv_vl_done_past_6_months)" + } + }, + { + "type": "derived_column", + "alias": "calhiv_virally_unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(prd_base.calhiv_virally_unsuppressed)" + } + } + ], + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd_base.location_id", "prd_base.reporting_month"], + "excludeParam": "excludeParam" + }, + "transFormDirectives": { + "joinColumn": "location_id", + "joinColumnParam": "", + "skipColumns": [""], + "disaggregationColumns": [] + }, + "dynamicJsonQueryGenerationDirectives": { + "patientListGenerator": { + "useTemplate": "pmtct-rri-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/rri/pmtct-rri-calhiv-dataset-base.json b/app/reporting-framework/json-reports/rri/pmtct-rri-calhiv-dataset-base.json new file mode 100644 index 000000000..c5b5deb60 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-calhiv-dataset-base.json @@ -0,0 +1,191 @@ +{ + "name": "pmtctRriCalhivDataSetBase", + "version": "1.0", + "tag": "pmtct_rri_calhiv_dataset_base", + "description": "", + "uses": [], + "sources": [ + { + "table": "etl.pmtct_rri_dataset", + "alias": "prd" + }, + { + "table": "etl.dates", + "alias": "dts", + "join": { + "type": "INNER", + "joinCondition": "prd.encounter_datetime <= dts.endDate and coalesce(prd.death_date, out_of_care) is null" + } + }, + { + "table": "etl.hiv_monthly_report_dataset_v1_2", + "alias": "fhs", + "join": { + "type": "inner", + "joinCondition": "prd.person_id = fhs.person_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "INNER", + "joinCondition": "prd.location_id = l.location_id" + } + }, + { + "table": "amrs.person", + "alias": "p", + "join": { + "type": "INNER", + "joinCondition": "p.person_id = prd.person_id" + } + } + ], + "columns": [ + { + "type": "derived_column", + "alias": "calhiv_vl_done_past_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN prd.cur_arv_meds IS NOT NULL AND (prd.latest_vl_test_date IS NULL OR TIMESTAMPDIFF(MONTH, prd.latest_vl_test_date, prd.encounter_datetime) >= 6) THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "calhiv_virally_unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN TIMESTAMPDIFF(MONTH, DATE(prd.latest_vl_test_date), DATE(dts.endDate)) <= 6 AND prd.latest_viral_load >= 200 THEN 1 ELSE NULL 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(prd.encounter_datetime)" + } + }, + { + "type": "derived_column", + "alias": "reporting_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "date_format(prd.encounter_datetime, '%m/%Y')" + } + }, + { + "type": "derived_column", + "alias": "encounter_year", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "YEAR(prd.encounter_datetime)" + } + }, + { + "type": "simple_column", + "alias": "location", + "column": "l.name" + }, + { + "type": "simple_column", + "alias": "regimen", + "column": "prd.cur_arv_meds" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "l.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "prd.location_id" + }, + { + "type": "simple_column", + "alias": "encounter_datetime", + "column": "prd.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "month", + "column": "prd.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": "prd.age" + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "prd.age BETWEEN 0 AND 20" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime >= ?", + "parameterName": "startDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime <= ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.endDate=?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "l.uuid in (?)", + "parameterName": "locationUuids" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) >= 0" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) <= 120" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd.person_id"], + "excludeParam": "excludeParam" + } +} diff --git a/app/reporting-framework/json-reports/rri/pmtct-rri-dataset-base.json b/app/reporting-framework/json-reports/rri/pmtct-rri-dataset-base.json new file mode 100644 index 000000000..13de87955 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-dataset-base.json @@ -0,0 +1,214 @@ +{ + "name": "pmtctRriDataSetBase", + "version": "1.0", + "tag": "pmtct_rri_dataset_base", + "description": "", + "uses": [], + "sources": [ + { + "table": "etl.pmtct_rri_dataset", + "alias": "prd" + }, + { + "table": "etl.dates", + "alias": "dts", + "join": { + "type": "INNER", + "joinCondition": "prd.encounter_datetime <= dts.endDate and coalesce(prd.death_date, out_of_care) is null" + } + }, + { + "table": "etl.hiv_monthly_report_dataset_v1_2", + "alias": "fhs", + "join": { + "type": "inner", + "joinCondition": "prd.person_id = fhs.person_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "INNER", + "joinCondition": "prd.location_id = l.location_id" + } + }, + { + "table": "amrs.person", + "alias": "p", + "join": { + "type": "INNER", + "joinCondition": "p.person_id = prd.person_id" + } + } + ], + "columns": [ + { + "type": "derived_column", + "alias": "vl_done_past_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN prd.cur_arv_meds IS NOT NULL AND (prd.latest_vl_test_date IS NULL OR TIMESTAMPDIFF(MONTH, prd.latest_vl_test_date, prd.encounter_datetime) >= 6) THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "pregnant", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_pregnant = 1 THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "breastfeeding", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN prd.is_mother_breastfeeding = 1 THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "pregnant_and_on_arvs", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_pregnant = 1 AND prd.cur_arv_meds IS NOT NULL THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "breastfeeding_and_on_arvs", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_mother_breastfeeding = 1 AND prd.cur_arv_meds IS NOT NULL THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "virally_unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN TIMESTAMPDIFF(MONTH, DATE(prd.latest_vl_test_date), DATE(dts.endDate)) <= 6 AND prd.latest_viral_load >= 200 THEN 1 ELSE NULL 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(prd.encounter_datetime)" + } + }, + { + "type": "derived_column", + "alias": "reporting_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "date_format(prd.encounter_datetime, '%m/%Y')" + } + }, + { + "type": "derived_column", + "alias": "encounter_year", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "YEAR(prd.encounter_datetime)" + } + }, + { + "type": "simple_column", + "alias": "location", + "column": "l.name" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "l.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "prd.location_id" + }, + { + "type": "simple_column", + "alias": "encounter_datetime", + "column": "prd.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "month", + "column": "prd.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": "prd.age" + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime >= ?", + "parameterName": "startDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime <= ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.endDate=?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "l.uuid in (?)", + "parameterName": "locationUuids" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) >= 0" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) <= 120" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd.person_id"], + "excludeParam": "excludeParam" + } +} diff --git a/app/reporting-framework/json-reports/rri/pmtct-rri-framework.json b/app/reporting-framework/json-reports/rri/pmtct-rri-framework.json new file mode 100644 index 000000000..72987825b --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-framework.json @@ -0,0 +1,92 @@ +[ + { + "sectionTitle": "HEI Infant Missed PCR Testing", + "indicators": [ + { + "label": "Initial PCR < 8wks", + "ref": "HV02-44", + "indicator": "initial_pcr_less_than_8_wks" + }, + { + "label": "Initial PCR >= 8wks-12mnths", + "ref": "HV02-45", + "indicator": "initial_pcr_8_wks_to_12_months" + }, + { + "label": "Initial PCR < 12 mnths_Total", + "ref": "HV02-46", + "indicator": "initial_pcr_less_than_12_months" + }, + { + "label": "Second PCR at 6 months", + "ref": "", + "indicator": "second_pcr_6_months" + }, + { + "label": "Third PCR at 12 months", + "ref": "", + "indicator": "third_pcr_12_months" + } + ] + }, + { + "sectionTitle": "CALHIV Missed Viral Load Test", + "indicators": [ + { + "label": "Total CALHIV", + "ref": "", + "indicator": "all_calhiv" + }, + { + "label": "CALHIV Without Valid VL", + "ref": "", + "indicator": "calhiv_vl_done_past_6_months" + }, + { + "label": "CALHIV With Unsuppressed VL", + "ref": "", + "indicator": "calhiv_virally_unsuppressed" + }, + { + "label": "CALHIV Without DTG Based Regimen", + "ref": "", + "indicator": "regimen" + } + ] + }, + { + "sectionTitle": "PBFW Missed Viral Load Test", + "indicators": [ + { + "label": "Total Positive PBFW", + "ref": "", + "indicator": "all_pbfw" + }, + { + "label": "PBFW Without Valid VL", + "ref": "", + "indicator": "pbfw_vl_done_past_6_months" + }, + { + "label": "PBFW With Unsuppressed VL", + "ref": "", + "indicator": "pbfw_virally_unsuppressed" + } + ] + }, + { + "sectionTitle": "WRA Missed Viral Load Test", + "indicators": [ + { + "label": "Total WRA", + "ref": "", + "indicator": "all_wra" + }, + { + "label": "WRA Without contact", + "ref": "", + "indicator": "wra_vl_done_past_6_months" + } + ] + } +] diff --git a/app/reporting-framework/json-reports/rri/pmtct-rri-pbfw-aggregate.json b/app/reporting-framework/json-reports/rri/pmtct-rri-pbfw-aggregate.json new file mode 100644 index 000000000..57c7b2153 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-pbfw-aggregate.json @@ -0,0 +1,84 @@ +{ + "name": "pmtctRriPbfwAggregate", + "version": "1.0", + "tag": "pmtct_rri_pbfw_aggregate", + "uses": [ + { + "name": "pmtctRriPbfwDataSetBase", + "version": "1.0", + "type": "dataset_def" + } + ], + "sources": [ + { + "dataSet": "pmtctRriPbfwDataSetBase", + "alias": "prd_base" + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "Reporting_Month", + "column": "reporting_month" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "location_id" + }, + { + "type": "simple_column", + "alias": "location_Name", + "column": "location" + }, + { + "type": "derived_column", + "alias": "all_pbfw", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(prd_base.person_id)" + } + }, + { + "type": "derived_column", + "alias": "pbfw_vl_done_past_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(prd_base.pbfw_vl_done_past_6_months)" + } + }, + { + "type": "derived_column", + "alias": "pbfw_virally_unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(prd_base.pbfw_virally_unsuppressed)" + } + } + ], + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd_base.location_id", "prd_base.reporting_month"], + "excludeParam": "excludeParam" + }, + "transFormDirectives": { + "joinColumn": "location_id", + "joinColumnParam": "", + "skipColumns": [""], + "disaggregationColumns": [] + }, + "dynamicJsonQueryGenerationDirectives": { + "patientListGenerator": { + "useTemplate": "pmtct-rri-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/rri/pmtct-rri-pbfw-dataset-base.json b/app/reporting-framework/json-reports/rri/pmtct-rri-pbfw-dataset-base.json new file mode 100644 index 000000000..34d56663c --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-pbfw-dataset-base.json @@ -0,0 +1,218 @@ +{ + "name": "pmtctRriPbfwDataSetBase", + "version": "1.0", + "tag": "pmtct_rri_pbfw_dataset_base", + "description": "", + "uses": [], + "sources": [ + { + "table": "etl.pmtct_rri_dataset", + "alias": "prd" + }, + { + "table": "etl.dates", + "alias": "dts", + "join": { + "type": "INNER", + "joinCondition": "prd.encounter_datetime <= dts.endDate and coalesce(prd.death_date, out_of_care) is null" + } + }, + { + "table": "etl.hiv_monthly_report_dataset_v1_2", + "alias": "fhs", + "join": { + "type": "inner", + "joinCondition": "prd.person_id = fhs.person_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "INNER", + "joinCondition": "prd.location_id = l.location_id" + } + }, + { + "table": "amrs.person", + "alias": "p", + "join": { + "type": "INNER", + "joinCondition": "p.person_id = prd.person_id" + } + } + ], + "columns": [ + { + "type": "derived_column", + "alias": "pbfw_vl_done_past_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN prd.cur_arv_meds IS NOT NULL AND (prd.latest_vl_test_date IS NULL OR TIMESTAMPDIFF(MONTH, prd.latest_vl_test_date, prd.encounter_datetime) >= 6) THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "pregnant", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_pregnant = 1 THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "breastfeeding", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN prd.is_mother_breastfeeding = 1 THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "pregnant_and_on_arvs", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_pregnant = 1 AND prd.cur_arv_meds IS NOT NULL THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "breastfeeding_and_on_arvs", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_mother_breastfeeding = 1 AND prd.cur_arv_meds IS NOT NULL THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "pbfw_virally_unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN TIMESTAMPDIFF(MONTH, DATE(prd.latest_vl_test_date), DATE(dts.endDate)) <= 6 AND prd.latest_viral_load >= 200 THEN 1 ELSE NULL 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(prd.encounter_datetime)" + } + }, + { + "type": "derived_column", + "alias": "reporting_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "date_format(prd.encounter_datetime, '%m/%Y')" + } + }, + { + "type": "derived_column", + "alias": "encounter_year", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "YEAR(prd.encounter_datetime)" + } + }, + { + "type": "simple_column", + "alias": "location", + "column": "l.name" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "l.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "prd.location_id" + }, + { + "type": "simple_column", + "alias": "encounter_datetime", + "column": "prd.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "month", + "column": "prd.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": "prd.age" + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "prd.is_pregnant = 1 OR prd.is_mother_breastfeeding = 1" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime >= ?", + "parameterName": "startDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime <= ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.endDate=?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "l.uuid in (?)", + "parameterName": "locationUuids" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) >= 0" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) <= 120" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd.person_id"], + "excludeParam": "excludeParam" + } +} diff --git a/app/reporting-framework/json-reports/rri/pmtct-rri-wra-aggregate.json b/app/reporting-framework/json-reports/rri/pmtct-rri-wra-aggregate.json new file mode 100644 index 000000000..9d4677246 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-wra-aggregate.json @@ -0,0 +1,84 @@ +{ + "name": "pmtctRriWraAggregate", + "version": "1.0", + "tag": "pmtct_rri_wra_aggregate", + "uses": [ + { + "name": "pmtctRriWraDataSetBase", + "version": "1.0", + "type": "dataset_def" + } + ], + "sources": [ + { + "dataSet": "pmtctRriWraDataSetBase", + "alias": "prd_base" + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "Reporting_Month", + "column": "reporting_month" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "location_id" + }, + { + "type": "simple_column", + "alias": "location_Name", + "column": "location" + }, + { + "type": "derived_column", + "alias": "all_wra", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "COUNT(prd_base.person_id)" + } + }, + { + "type": "derived_column", + "alias": "wra_vl_done_past_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(prd_base.wra_vl_done_past_6_months)" + } + }, + { + "type": "derived_column", + "alias": "wra_virally_unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "SUM(prd_base.wra_virally_unsuppressed)" + } + } + ], + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd_base.location_id", "prd_base.reporting_month"], + "excludeParam": "excludeParam" + }, + "transFormDirectives": { + "joinColumn": "location_id", + "joinColumnParam": "", + "skipColumns": [""], + "disaggregationColumns": [] + }, + "dynamicJsonQueryGenerationDirectives": { + "patientListGenerator": { + "useTemplate": "pmtct-rri-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/rri/pmtct-rri-wra-dataset-base.json b/app/reporting-framework/json-reports/rri/pmtct-rri-wra-dataset-base.json new file mode 100644 index 000000000..0f7b5c498 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri-wra-dataset-base.json @@ -0,0 +1,222 @@ +{ + "name": "pmtctRriWraDataSetBase", + "version": "1.0", + "tag": "pmtct_rri_wra_dataset_base", + "description": "", + "uses": [], + "sources": [ + { + "table": "etl.pmtct_rri_dataset", + "alias": "prd" + }, + { + "table": "etl.dates", + "alias": "dts", + "join": { + "type": "INNER", + "joinCondition": "prd.encounter_datetime <= dts.endDate and coalesce(prd.death_date, out_of_care) is null" + } + }, + { + "table": "etl.hiv_monthly_report_dataset_v1_2", + "alias": "fhs", + "join": { + "type": "inner", + "joinCondition": "prd.person_id = fhs.person_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "INNER", + "joinCondition": "prd.location_id = l.location_id" + } + }, + { + "table": "amrs.person", + "alias": "p", + "join": { + "type": "INNER", + "joinCondition": "p.person_id = prd.person_id" + } + } + ], + "columns": [ + { + "type": "derived_column", + "alias": "wra_vl_done_past_6_months", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN prd.cur_arv_meds IS NOT NULL AND (prd.latest_vl_test_date IS NULL OR TIMESTAMPDIFF(MONTH, prd.latest_vl_test_date, prd.encounter_datetime) >= 6) THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "pregnant", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_pregnant = 1 THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "breastfeeding", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " CASE WHEN prd.is_mother_breastfeeding = 1 THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "pregnant_and_on_arvs", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_pregnant = 1 AND prd.cur_arv_meds IS NOT NULL THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "breastfeeding_and_on_arvs", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN prd.is_mother_breastfeeding = 1 AND prd.cur_arv_meds IS NOT NULL THEN 1 ELSE NULL END" + } + }, + { + "type": "derived_column", + "alias": "wra_virally_unsuppressed", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "CASE WHEN TIMESTAMPDIFF(MONTH, DATE(prd.latest_vl_test_date), DATE(dts.endDate)) <= 6 AND prd.latest_viral_load >= 200 THEN 1 ELSE NULL 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(prd.encounter_datetime)" + } + }, + { + "type": "derived_column", + "alias": "reporting_month", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "date_format(prd.encounter_datetime, '%m/%Y')" + } + }, + { + "type": "derived_column", + "alias": "encounter_year", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "YEAR(prd.encounter_datetime)" + } + }, + { + "type": "simple_column", + "alias": "location", + "column": "l.name" + }, + { + "type": "simple_column", + "alias": "location_uuid", + "column": "l.uuid" + }, + { + "type": "simple_column", + "alias": "location_id", + "column": "prd.location_id" + }, + { + "type": "simple_column", + "alias": "encounter_datetime", + "column": "prd.encounter_datetime" + }, + { + "type": "simple_column", + "alias": "month", + "column": "prd.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": "prd.age" + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "prd.age BETWEEN 15 AND 49" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.gender IN ('F')" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime >= ?", + "parameterName": "startDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "prd.encounter_datetime <= ?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "fhs.endDate=?", + "parameterName": "endDate" + }, + { + "filterType": "tableColumns", + "conditionExpression": "l.uuid in (?)", + "parameterName": "locationUuids" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) >= 0" + }, + { + "filterType": "tableColumns", + "conditionExpression": "round(datediff(prd.encounter_datetime,p.birthdate)/365) <= 120" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["prd.person_id"], + "excludeParam": "excludeParam" + } +} diff --git a/app/reporting-framework/json-reports/rri/pmtct-rri.json b/app/reporting-framework/json-reports/rri/pmtct-rri.json new file mode 100644 index 000000000..0f42d4592 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct-rri.json @@ -0,0 +1,8 @@ +{ + "reports": [ + "pmtctRriHeiAggregate", + "pmtctRriCalhivAggregate", + "pmtctRriPbfwAggregate", + "pmtctRriWraAggregate" + ] +} 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 new file mode 100644 index 000000000..aa4c95288 --- /dev/null +++ b/app/reporting-framework/json-reports/rri/pmtct_rri_patient_list_template.json @@ -0,0 +1,116 @@ +{ + "name": "pmtct-rri-report-patient-list-template", + "version": "1.0", + "tag": "pmtct-rri-report-patient-list-template", + "description": "PMTCT patient list template", + "sources": [ + { + "table": "amrs.person", + "alias": "t1" + }, + { + "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)" + } + }, + { + "table": "etl.flat_patient_identifiers_v1", + "alias": "flat_identifiers", + "join": { + "type": "LEFT", + "joinCondition": "t1.person_id = flat_identifiers.patient_id" + } + }, + { + "table": "amrs.person_address", + "alias": "pa", + "join": { + "type": "LEFT", + "joinCondition": "t1.person_id = pa.person_id" + } + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "patient_uuid", + "column": "t1.uuid" + }, + { + "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": "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": "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 ', ')" + } + } + ], + "groupBy": { + "columns": ["t1.person_id"] + } +} diff --git a/app/reporting-framework/multi-dataset-patientlist.report.js b/app/reporting-framework/multi-dataset-patientlist.report.js index 01c8e29ea..d06f5e13c 100755 --- a/app/reporting-framework/multi-dataset-patientlist.report.js +++ b/app/reporting-framework/multi-dataset-patientlist.report.js @@ -60,7 +60,6 @@ export class MultiDatasetPatientlistReport extends MultiDatasetReport { type: 'patient-list', indicators: indicators }; - let that = this; return new Promise((resolve, reject) => { this.generateReport(additionalParams) diff --git a/app/routes/pmtct-rri-report.route.js b/app/routes/pmtct-rri-report.route.js new file mode 100644 index 000000000..f4d7c23dd --- /dev/null +++ b/app/routes/pmtct-rri-report.route.js @@ -0,0 +1,142 @@ +var authorizer = require('../../authorization/etl-authorizer'); +import { PMTCTRRIReportingService } from '../../service/rri/pmtct_rri_reporting.service.js'; +import { PmtctRriSummaryService } from '../../service/rri/pmtct-rri-service.js'; +var etlHelpers = require('../../etl-helpers'); +var privileges = authorizer.getAllPrivileges(); +var preRequest = require('../../pre-request-processing'); +const routes = [ + { + method: 'GET', + + path: '/etl/pmtct_rri_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( + 'pmtct_rri_aggregate_summary', + ['startDate', 'endDate', 'locationUuids'], + requestParams + ); + + let service = new PmtctRriSummaryService( + 'pmtct_rri_aggregate_summary', + reportParams.requestParams + ); + service + .generateReport() + .then((result) => { + reply(result); + }) + .catch((error) => { + console.error('Error: ', error); + reply(error); + }); + }); + }, + description: 'PMTCT, HEI, CALHIV and WRA RRI reports', + notes: 'PMTCT, HEI, CALHIV and WRA RRI reports', + tags: ['api'], + validate: { + options: { + allowUnknown: true + }, + params: {} + } + } + }, + { + method: 'GET', + path: '/etl/pmtct_rri_summary/patient-list', + config: { + plugins: { + hapiAuthorization: { + role: privileges.canViewClinicDashBoard + } + }, + handler: function (request, reply) { + if (request.query.locationUuids) { + preRequest.resolveLocationIdsToLocationUuids(request, function () { + let requestParams = Object.assign( + {}, + request.query, + request.params + ); + let reportParams = etlHelpers.getReportParams( + 'pmtct_rri_aggregate_summary', + ['endDate', 'locationUuids'], + requestParams + ); + delete reportParams.requestParams['gender']; + const pmtctrriService = new PmtctRriSummaryService( + 'pmtct_rri_aggregate_summary', + reportParams.requestParams + ); + pmtctrriService + .generatePatientListReport(reportParams.requestParams) + .then((result) => { + reply(result); + }) + .catch((error) => { + reply(error); + }); + }); + } + }, + description: + 'Get patient list for txnew summary report of the location and month provided', + notes: 'Returns patient list of txnew summary indicators', + tags: ['api'] + } + }, + + { + method: 'GET', + + path: '/etl/pmtct_rri_aggregate', + 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( + 'pmtct_rri_summary', + ['startDate', 'endDate', 'locationUuids'], + requestParams + ); + let service = new PMTCTRRIReportingService( + 'pmtctRriSummary', + reportParams.requestParams + ); + service + .getPmtctRriSummaryReport(reportParams.requestParams) + .then((result) => { + reply(result); + }) + .catch((error) => { + reply(error); + }); + }); + }, + description: 'PMTCT, HEI, CALHIV and WRA RRI reports', + notes: 'PMTCT, HEI, CALHIV and WRA RRI reports', + tags: ['api'], + validate: { + options: { + allowUnknown: true + }, + params: {} + } + } + } +]; +exports.routes = (server) => server.route(routes); diff --git a/programs/patient-program-config.json b/programs/patient-program-config.json index f48107fe6..0a04af3f0 100755 --- a/programs/patient-program-config.json +++ b/programs/patient-program-config.json @@ -73,13 +73,13 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "8d5b27bc-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTINITIAL" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -144,11 +144,7 @@ }, { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTRETURN" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -203,33 +199,25 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", "display": "TRANSFERENCOUNTER" }, { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTRETURN" }, { "uuid": "238625fc-8a25-44b2-aa5a-8bf48fa0e18d", @@ -288,17 +276,17 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", "display": "TRANSFERENCOUNTER" }, { "uuid": "8d5b2dde-c2cc-11de-8d13-0010c6dffd0f", - "display": "PEDSINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEDSINITIAL" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -353,11 +341,7 @@ }, { "uuid": "8d5b3108-c2cc-11de-8d13-0010c6dffd0f", - "display": "PEDSRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEDSRETURN" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -407,17 +391,17 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", "display": "TRANSFERENCOUNTER" }, { "uuid": "8d5b3108-c2cc-11de-8d13-0010c6dffd0f", - "display": "PEDSRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEDSRETURN" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -471,17 +455,17 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", "display": "TRANSFERENCOUNTER" }, { "uuid": "fc8c1694-90fc-46a8-962b-73ce9a99a78f", - "display": "YOUTHINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "YOUTHINITIAL" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -541,11 +525,7 @@ }, { "uuid": "4e7553b4-373d-452f-bc89-3f4ad9a01ce7", - "display": "YOUTHRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "YOUTHRETURN" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -595,17 +575,17 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", "display": "TRANSFERENCOUNTER" }, { "uuid": "4e7553b4-373d-452f-bc89-3f4ad9a01ce7", - "display": "YOUTHRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "YOUTHRETURN" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -686,11 +666,7 @@ }, { "uuid": "987009c6-6f24-43f7-9640-c285d6553c63", - "display": "DRUGPICKUP", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "DRUGPICKUP" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -761,19 +737,11 @@ "encounterTypes": [ { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -791,11 +759,7 @@ "encounterTypes": [ { "uuid": "10a86a62-b771-44d1-b1ad-3b8496c7bc47", - "display": "INPATIENTPEER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "INPATIENTPEER" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -1382,19 +1346,11 @@ }, { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTRETURN" }, { "uuid": "8e942fd1-135d-42bd-9701-04560f180ec5", - "display": "MOH257BLUECARD", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "MOH257BLUECARD" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -1448,6 +1404,10 @@ { "uuid": "37770eca-8a2f-48d6-b3c8-54af0fa989c2", "display": "MENTALHEALTHSCREENING" + }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ENHANCEDADHERENCE" } ] }, @@ -1463,19 +1423,11 @@ }, { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTRETURN" }, { "uuid": "8e942fd1-135d-42bd-9701-04560f180ec5", - "display": "MOH257BLUECARD", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "MOH257BLUECARD" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -1529,6 +1481,10 @@ { "uuid": "37770eca-8a2f-48d6-b3c8-54af0fa989c2", "display": "MENTALHEALTHSCREENING" + }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ENHANCEDADHERENCE" } ] }, @@ -1540,16 +1496,16 @@ "encounterTypes": [ { "uuid": "8d5b27bc-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTINITIAL" }, { "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", "display": "TRANSFERENCOUNTER" @@ -1594,6 +1550,10 @@ { "uuid": "37770eca-8a2f-48d6-b3c8-54af0fa989c2", "display": "MENTALHEALTHSCREENING" + }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ENHANCEDADHERENCE" } ] }, @@ -1605,23 +1565,19 @@ "encounterTypes": [ { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTRETURN" }, { "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "8e942fd1-135d-42bd-9701-04560f180ec5", - "display": "MOH257BLUECARD", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "MOH257BLUECARD" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -1671,6 +1627,10 @@ { "uuid": "37770eca-8a2f-48d6-b3c8-54af0fa989c2", "display": "MENTALHEALTHSCREENING" + }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ENHANCEDADHERENCE" } ] }, @@ -1682,23 +1642,19 @@ "encounterTypes": [ { "uuid": "8d5b27bc-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTINITIAL" }, { "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "8d5b2dde-c2cc-11de-8d13-0010c6dffd0f", - "display": "PEDSINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEDSINITIAL" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -1759,23 +1715,19 @@ "encounterTypes": [ { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTRETURN" }, { "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "8e942fd1-135d-42bd-9701-04560f180ec5", - "display": "MOH257BLUECARD", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "MOH257BLUECARD" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -1832,11 +1784,7 @@ "encounterTypes": [ { "uuid": "8d5b2dde-c2cc-11de-8d13-0010c6dffd0f", - "display": "PEDSINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEDSINITIAL" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -1905,19 +1853,11 @@ }, { "uuid": "693559d3-4e44-4d33-83f9-bc70ca56fe34", - "display": "TXSUPPORTERMEDREFILL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "TXSUPPORTERMEDREFILL" }, { "uuid": "987009c6-6f24-43f7-9640-c285d6553c63", - "display": "DRUGPICKUP", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "DRUGPICKUP" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -1973,11 +1913,7 @@ "encounterTypes": [ { "uuid": "10a86a62-b771-44d1-b1ad-3b8496c7bc47", - "display": "INPATIENTPEER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "INPATIENTPEER" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -1995,19 +1931,11 @@ "encounterTypes": [ { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -2285,11 +2213,7 @@ "encounterTypes": [ { "uuid": "c3a78744-f94a-4a25-ac9d-1c48df887895", - "display": "PEPINITIAL", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEPINITIAL" }, { "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", @@ -2325,11 +2249,7 @@ "encounterTypes": [ { "uuid": "f091b833-9e1a-4eef-8364-fc289095a832", - "display": "PEPRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEPRETURN" }, { "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", @@ -2363,19 +2283,11 @@ "encounterTypes": [ { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -2393,11 +2305,7 @@ "encounterTypes": [ { "uuid": "10a86a62-b771-44d1-b1ad-3b8496c7bc47", - "display": "INPATIENTPEER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "INPATIENTPEER" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -2733,27 +2641,15 @@ }, { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", - "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "ADULTRETURN" }, { "uuid": "b690e24a-6dc7-40a8-8cbd-0924dd507dca", - "display": "YOUTHTHIRDLINE", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "YOUTHTHIRDLINE" }, { "uuid": "fed9ffa5-da88-484a-8259-bee7daa6d6f2", - "display": "PEDSTHIRDLINE", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "PEDSTHIRDLINE" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -2799,6 +2695,10 @@ { "uuid": "37770eca-8a2f-48d6-b3c8-54af0fa989c2", "display": "MENTALHEALTHSCREENING" + }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" } ] }, @@ -2808,19 +2708,11 @@ "encounterTypes": [ { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -2838,11 +2730,7 @@ "encounterTypes": [ { "uuid": "10a86a62-b771-44d1-b1ad-3b8496c7bc47", - "display": "INPATIENTPEER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "INPATIENTPEER" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -3030,11 +2918,7 @@ "encounterTypes": [ { "uuid": "987009c6-6f24-43f7-9640-c285d6553c63", - "display": "DRUGPICKUP", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "DRUGPICKUP" }, { "uuid": "238625fc-8a25-44b2-aa5a-8bf48fa0e18d", @@ -3043,11 +2927,7 @@ }, { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -3055,11 +2935,7 @@ }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "cb5c0abd-0817-40e3-9413-8669561fadb9", @@ -3107,26 +2983,18 @@ { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", "display": "ADULTRETURN", - "allowedIf": "screenedForCovidToday && age > 24", + "allowedIf": " age > 24", "errors": { "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" } }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "cbe2d31d-2201-44ce-b52e-fbd5dc7cff33", @@ -3136,13 +3004,17 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", "display": "DEATHREPORT" }, { "uuid": "4e7553b4-373d-452f-bc89-3f4ad9a01ce7", - "allowedIf": "age >= 10 && age <= 24 && screenedForCovidToday", + "allowedIf": "age >= 10 && age <= 24", "display": "YOUTHRETURN" }, { @@ -3218,11 +3090,7 @@ }, { "uuid": "987009c6-6f24-43f7-9640-c285d6553c63", - "display": "DRUGPICKUP", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "DRUGPICKUP" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -3298,11 +3166,7 @@ }, { "uuid": "987009c6-6f24-43f7-9640-c285d6553c63", - "display": "DRUGPICKUP", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "DRUGPICKUP" }, { "uuid": "cb5c0abd-0817-40e3-9413-8669561fadb9", @@ -3332,19 +3196,11 @@ "encounterTypes": [ { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -3454,11 +3310,7 @@ }, { "uuid": "95f5847a-8952-4a3a-8610-caee271d351a", - "display": "TRANSITMEDICATION", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "TRANSITMEDICATION" }, { "uuid": "df55584c-1350-11df-a1f1-0026b9348838", @@ -3475,11 +3327,7 @@ }, { "uuid": "987009c6-6f24-43f7-9640-c285d6553c63", - "display": "DRUGPICKUP", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "DRUGPICKUP" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -3497,19 +3345,11 @@ "encounterTypes": [ { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -3527,11 +3367,7 @@ "encounterTypes": [ { "uuid": "10a86a62-b771-44d1-b1ad-3b8496c7bc47", - "display": "INPATIENTPEER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "INPATIENTPEER" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -4613,10 +4449,14 @@ "uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7", "display": "HIVTRIAGE" }, + { + "uuid": "2226e81f-38fc-4672-a615-1d37e1c8e637", + "display": "ADHERENCE" + }, { "uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f", "display": "ADULTRETURN", - "allowedIf": "!isViremicHighVL && age > 24", + "allowedIf": "age > 24", "errors": { "viremiaError": "To access clinical forms kindly fill Enhanced Adherence Encounter Form" } @@ -4624,7 +4464,7 @@ { "uuid": "4e7553b4-373d-452f-bc89-3f4ad9a01ce7", "display": "YOUTHRETURN", - "allowedIf": "!isViremicHighVL && age >= 10 && age <= 24", + "allowedIf": "age >= 10 && age <= 24", "errors": { "viremiaError": "To access clinical forms kindly fill Enhanced Adherence Encounter Form" } @@ -4632,7 +4472,7 @@ { "uuid": "8d5b3108-c2cc-11de-8d13-0010c6dffd0f", "display": "PEDSRETURN", - "allowedIf": "!isViremicHighVL && age <= 14", + "allowedIf": "age <= 14", "errors": { "viremiaError": "To access clinical forms kindly fill Enhanced Adherence Encounter Form" } @@ -4684,7 +4524,7 @@ }, { "uuid": "c4efb6ba-e286-4933-8854-cd3af8e1ebef", - "allowedIf": "screenedForCovidToday && age >= 10 && age <= 24", + "allowedIf": " age >= 10 && age <= 24", "display": "YOUTHCOUNSELING" }, { @@ -4726,11 +4566,7 @@ }, { "uuid": "987009c6-6f24-43f7-9640-c285d6553c63", - "display": "DRUGPICKUP", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "DRUGPICKUP" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", @@ -4779,19 +4615,11 @@ "encounterTypes": [ { "uuid": "5ef97eed-18f5-40f6-9fbf-a11b1f06484a", - "display": "LABORDERENCOUNTER", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "LABORDERENCOUNTER" }, { "uuid": "5544894d-8add-4521-a0ea-c124c5886c8b", - "display": "POCLAB", - "allowedIf": "screenedForCovidToday", - "errors": { - "covidError": "To access clinical forms kindly fill Covid 19 Assessment Form" - } + "display": "POCLAB" }, { "uuid": "466d6707-8429-4e61-b5a0-d63444f5ad35", diff --git a/programs/scope-builder.service.js b/programs/scope-builder.service.js index c9e8f4dfb..60e7c3101 100755 --- a/programs/scope-builder.service.js +++ b/programs/scope-builder.service.js @@ -29,7 +29,13 @@ function buildScope(dataDictionary) { 'db2bdd7c-5fe6-4ea3-adc1-d2d8dfb3d658', '17c97881-90e5-43c8-b8a3-cc0322f89a89', 'e9f515c2-7c48-4099-ac76-41db9977f96f', - 'f7aabb83-7915-4c24-88b2-bcde8b3a9977' + 'f7aabb83-7915-4c24-88b2-bcde8b3a9977', + '08feae7c-1352-11df-a1f1-0026b9348838', + '1ce5034b-f05d-46b6-910f-fc959e091641', + '29124daf-6422-4896-b70e-daad3b252c9d', + '08fec42a-1352-11df-a1f1-0026b9348838', + 'a36c86bb-7ca3-4319-8674-28c66ba14deb', + '345514ae-8f37-42fc-9bbe-993828c2910d' ].includes(dataDictionary.intendedVisitLocationUuid); if (dataDictionary.patient) { buildPatientScopeMembers(scope, dataDictionary.patient); @@ -93,7 +99,13 @@ function buildScope(dataDictionary) { 'db2bdd7c-5fe6-4ea3-adc1-d2d8dfb3d658', '17c97881-90e5-43c8-b8a3-cc0322f89a89', 'e9f515c2-7c48-4099-ac76-41db9977f96f', - 'f7aabb83-7915-4c24-88b2-bcde8b3a9977' + 'f7aabb83-7915-4c24-88b2-bcde8b3a9977', + '08feae7c-1352-11df-a1f1-0026b9348838', + '1ce5034b-f05d-46b6-910f-fc959e091641', + '29124daf-6422-4896-b70e-daad3b252c9d', + '08fec42a-1352-11df-a1f1-0026b9348838', + 'a36c86bb-7ca3-4319-8674-28c66ba14deb', + '345514ae-8f37-42fc-9bbe-993828c2910d' ].includes(dataDictionary.intendedVisitLocationUuid); } diff --git a/service/eid/eid-facility-mappings.json b/service/eid/eid-facility-mappings.json index 5c46b9a0b..719daf228 100755 --- a/service/eid/eid-facility-mappings.json +++ b/service/eid/eid-facility-mappings.json @@ -2834,6 +2834,33 @@ "cityVillage": "", "eidDisplay": "" }, + "0cc1e6c8-69a5-4b78-932d-6170fcfb98fe": { + "mrsId": 496, + "mrsDisplay": "Bravo Module-Turbo", + "description": "Bravo Module-Turbo", + "mflCode": "15753", + "county": "Uasin Gishu County", + "cityVillage": "", + "eidDisplay": "" + }, + "a844aa95-e9a6-416b-942b-ac07c1ef84fe": { + "mrsId": 497, + "mrsDisplay": "Maisha Module-Turbo", + "description": "Maisha Module-Turbo", + "mflCode": "15753", + "county": "Uasin Gishu County", + "cityVillage": "", + "eidDisplay": "" + }, + "c22318da-d854-43fa-bd1e-8cb7d1d16ebf": { + "mrsId": 498, + "mrsDisplay": "Victor's Module-Turbo", + "description": "Victor's Module-Turbo", + "mflCode": "15753", + "county": "Uasin Gishu County", + "cityVillage": "", + "eidDisplay": "" + }, "469bb74e-18a4-4d74-872e-55fcebe12dc7": { "mrsId": 328, "mrsDisplay": "Soy MCH", diff --git a/service/patient-reminder.service.js b/service/patient-reminder.service.js index f52fd9f7b..74498f2b2 100755 --- a/service/patient-reminder.service.js +++ b/service/patient-reminder.service.js @@ -424,6 +424,12 @@ function TPTReminders(data) { data.inh_treatment_days_remaining < 150 ) { showReminder = true; + } else if ( + data.is_on_inh_treatment && + data.inh_treatment_days_remaining <= 30 && + data.inh_treatment_days_remaining > 0 + ) { + showReminder = true; } // INH Treatment Reminder - last month try { @@ -432,7 +438,7 @@ function TPTReminders(data) { message: 'Patient started ' + months + - ' months' + + ' months ' + treatment + ' treatment on (' + Moment(data.ipt_start_date).format('DD-MM-YYYY') + @@ -442,7 +448,7 @@ function TPTReminders(data) { '). ' + data.inh_treatment_days_remaining + ' days remaining.', - title: 'INH Treatment Reminder', + title: 'TPT Treatment Reminder', type: 'danger', display: { banner: true, @@ -453,37 +459,12 @@ function TPTReminders(data) { } catch (e) { console.log(e); } - // INH Treatment Reminder - last month - if ( - data.is_on_inh_treatment && - data.inh_treatment_days_remaining <= 30 && - data.inh_treatment_days_remaining > 0 - ) { - reminders.push({ - message: - 'Patient started ' + - months + - ' month ' + - treatment + - 'treatment since (' + - Moment(data.ipt_start_date).format('DD-MM-YYYY') + - '). Expected to end on (' + - Moment(data.ipt_completion_date).format('DD-MM-YYYY') + - ') ', - title: 'INH Treatment Reminder', - type: 'danger', - display: { - banner: true, - toast: true - } - }); - } - // TPT Reminders if ( calculateAge(data.birth_date) >= 1 && !data.ipt_start_date && - !data.on_tb_tx + !data.on_tb_tx && + !(data.tb_tx_start_date && !data.tb_tx_end_date) ) { reminders.push({ message: @@ -761,11 +742,11 @@ function getIptCompletionReminder(data) { message: 'Patient started ' + months + - ' month IPT on ' + + ' month TPT on ' + Moment(data.ipt_start_date).format('DD-MM-YYYY') + ' and was supposed to be completed on ' + Moment(data.ipt_start_date).add(months, 'months').format('DD-MM-YYYY'), - title: 'IPT Completion Reminder', + title: 'TPT Completion Reminder', type: 'danger', display: { banner: true, @@ -773,7 +754,7 @@ function getIptCompletionReminder(data) { } }); } else { - console.info.call('No IPT Completion Reminder For Selected Patient'); + console.info.call('No TPT Completion Reminder For Selected Patient'); } return reminders; @@ -964,7 +945,10 @@ function getFPExpiryDate(data) { function generateAppointmentNoShowUpRiskReminder(data) { let reminders = []; const predicted_score = (data.predicted_prob_disengage * 100).toFixed(2); - if (data.predicted_risk) { + if ( + data.predicted_risk && + data.last_encounter_date < data.prediction_generated_date + ) { if (data.predicted_risk === 'Medium Risk') { reminders.push({ message: diff --git a/service/rri/pmtct-rri-service.js b/service/rri/pmtct-rri-service.js new file mode 100644 index 000000000..d8d4bba1d --- /dev/null +++ b/service/rri/pmtct-rri-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 pmtctrriReportSections = require('../../app/reporting-framework/json-reports/rri/pmtct-rri-framework.json'); +const pmtctrriReportPatientListCols = require('../../app/reporting-framework/json-reports/rri/pmtct_rri_patient_list_template.json'); + +const etlHelpers = require('../../etl-helpers.js'); + +export class PmtctRriSummaryService 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: pmtctrriReportSections, + 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'] = pmtctrriReportPatientListCols; + delete results['result']; + _.each(results.results.results, (row) => { + row.cur_meds = etlHelpers.getARVNames(row.cur_meds); + }); + resolve(results); + }) + .catch((err) => { + reject(err); + }); + }); + } +} diff --git a/service/rri/pmtct_rri_reporting.service.js b/service/rri/pmtct_rri_reporting.service.js new file mode 100644 index 000000000..66493a43f --- /dev/null +++ b/service/rri/pmtct_rri_reporting.service.js @@ -0,0 +1,24 @@ +const Promise = require('bluebird'); +const Moment = require('moment'); +const _ = require('lodash'); +var processors = require('../../etl-processors.js'); +import { BaseMysqlReport } from '../../app/reporting-framework/base-mysql.report'; +export class PMTCTRRIReportingService { + getPmtctRriSummaryReport(reportParams) { + let self = this; + return new Promise(function (resolve, reject) { + let report = new BaseMysqlReport('pmtctRriSummary', reportParams); + console.log(report); + Promise.join(report.generateReport(), (results) => { + let result = results.results.results; + results.size = result ? result.length : 0; + results.result = result; + delete results['results']; + resolve(results); + // TODO Do some post processing + }).catch((errors) => { + reject(errors); + }); + }); + } +}