Skip to content

Commit

Permalink
Merge branch 'master' into POC-560
Browse files Browse the repository at this point in the history
  • Loading branch information
drizzentic authored Nov 29, 2023
2 parents 66538cc + d562816 commit 6be8b9f
Show file tree
Hide file tree
Showing 25 changed files with 2,349 additions and 354 deletions.
69 changes: 65 additions & 4 deletions app/reporting-framework/base-mysql.report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand All @@ -1757,7 +1819,6 @@ export class BaseMysqlReport {
}

executeReportQuery(sqlQuery) {
// console.log('Executing Query', sqlQuery);
let runner = this.getSqlRunner();
return new Promise((resolve, reject) => {
runner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
],
Expand Down Expand Up @@ -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",
Expand All @@ -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"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{
"type": "simple_column",
"alias": "ccc_number",
"column": "fi.ccc"
"column": "IFNULL(fi.ccc, 'No CCC')"
},
{
"type": "simple_column",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Loading

0 comments on commit 6be8b9f

Please sign in to comment.