forked from AMPATH/etl-rest-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HIV-851: Clinic Flow Provider Statistics to Generate Patient List (AM…
- Loading branch information
1 parent
3faacda
commit d442bd5
Showing
7 changed files
with
339 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
app/reporting-framework/json-reports/clinic-flow-provider-statistics-aggregate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "clinicFlowProviderStatisticsAggregate", | ||
"version": "1.0", | ||
"tag": "", | ||
"description": "", | ||
"uses": [ | ||
{ | ||
"name": "clinicFlowProviderStatisticsBase", | ||
"version": "1.0", | ||
"type": "dataset_def" | ||
} | ||
], | ||
"sources": [ | ||
{ | ||
"dataSet": "clinicFlowProviderStatisticsBase", | ||
"alias": "b" | ||
} | ||
], | ||
"columns": [ | ||
{ | ||
"type": "simple_column", | ||
"alias": "location_id", | ||
"column": "b.location_id" | ||
}, | ||
{ | ||
"type": "simple_column", | ||
"alias": "person_id", | ||
"column": "b.person_id" | ||
}, | ||
{ | ||
"type": "simple_column", | ||
"alias": "seen", | ||
"column": "COUNT(b.seen)" | ||
}, | ||
{ | ||
"type": "simple_column", | ||
"alias": "visit_started", | ||
"column": "COUNT(b.visit_started)" | ||
} | ||
], | ||
"groupBy": { | ||
"groupParam": "groupByParam", | ||
"columns": ["location_id"], | ||
"excludeParam": "excludeParam" | ||
}, | ||
"dynamicJsonQueryGenerationDirectives": { | ||
"patientListGenerator": { | ||
"useTemplate": "patient-list-schedules-template", | ||
"useTemplateVersion": "1.0", | ||
"generatingDirectives": { | ||
"joinDirectives": { | ||
"joinType": "INNER", | ||
"joinCondition": "<<base_column>> = <<template_column>>", | ||
"baseColumn": "person_id", | ||
"templateColumn": "person_id" | ||
} | ||
} | ||
} | ||
} | ||
} |
174 changes: 174 additions & 0 deletions
174
app/reporting-framework/json-reports/clinic-flow-provider-statistics-base.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
{ | ||
"name": "clinicFlowProviderStatisticsBase", | ||
"version": "1.0", | ||
"tag": "", | ||
"description": "", | ||
"uses": [], | ||
"sources": [ | ||
{ | ||
"table": "etl.flat_appointment", | ||
"alias": "t2" | ||
}, | ||
{ | ||
"table": "amrs.encounter", | ||
"alias": "ae", | ||
"join": { | ||
"type": "LEFT", | ||
"joinCondition": "ae.encounter_id = t2.encounter_id" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.visit", | ||
"alias": "v", | ||
"join": { | ||
"type": "LEFT", | ||
"joinCondition": "ae.visit_id = v.visit_id" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.users", | ||
"alias": "t10", | ||
"join": { | ||
"type": "LEFT", | ||
"joinCondition": "v.creator = t10.user_id" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.person", | ||
"alias": "t11", | ||
"join": { | ||
"type": "LEFT", | ||
"joinCondition": "t10.person_id = t11.person_id" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.encounter_provider", | ||
"alias": "t6", | ||
"join": { | ||
"type": "INNER", | ||
"joinCondition": "t2.encounter_id = t6.encounter_id" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.provider", | ||
"alias": "t7", | ||
"join": { | ||
"type": "INNER", | ||
"joinCondition": "t7.provider_id = t6.provider_id" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.person", | ||
"alias": "pp", | ||
"join": { | ||
"type": "INNER", | ||
"joinCondition": "t7.person_id = pp.person_id AND pp.voided = 0" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.person_name", | ||
"alias": "provider_name", | ||
"join": { | ||
"type": "INNER", | ||
"joinCondition": "provider_name.person_id = pp.person_id AND provider_name.voided = 0" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.encounter_type", | ||
"alias": "t9", | ||
"join": { | ||
"type": "INNER", | ||
"joinCondition": "t9.encounter_type_id = t2.encounter_type" | ||
} | ||
}, | ||
{ | ||
"table": "amrs.location", | ||
"alias": "l", | ||
"join": { | ||
"type": "INNER", | ||
"joinCondition": "t2.location_id = l.location_id" | ||
} | ||
} | ||
], | ||
"columns": [ | ||
{ | ||
"type": "simple_column", | ||
"alias": "visit_start", | ||
"column": "v.date_started" | ||
}, | ||
{ | ||
"type": "simple_column", | ||
"alias": "person_id", | ||
"column": "t2.person_id" | ||
}, | ||
{ | ||
"type": "simple_column", | ||
"alias": "visit_person_id", | ||
"column": "t10.person_id" | ||
}, | ||
{ | ||
"type": "simple_column", | ||
"alias": "Encounter Type", | ||
"column": "t9.name" | ||
}, | ||
{ | ||
"type": "simple_column", | ||
"alias": "location", | ||
"column": "l.name" | ||
}, | ||
{ | ||
"type": "derived_column", | ||
"alias": "provider", | ||
"expressionType": "simple_expression", | ||
"expressionOptions": { | ||
"expression": " CONCAT(COALESCE(provider_name.given_name, ''), ' ', COALESCE(provider_name.middle_name, ''), ' ', COALESCE(provider_name.family_name, ''))" | ||
} | ||
}, | ||
{ | ||
"type": "derived_column", | ||
"alias": "seen", | ||
"expressionType": "simple_expression", | ||
"expressionOptions": { | ||
"expression": "IF(t2.encounter_id IS NOT NULL,1,NULL)" | ||
} | ||
}, | ||
{ | ||
"type": "derived_column", | ||
"alias": "visit_started", | ||
"expressionType": "case_statement", | ||
"expressionOptions": { | ||
"caseOptions": [ | ||
{ | ||
"condition": "t7.person_id = t11.person_id", | ||
"value": 1 | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"filters": { | ||
"conditionJoinOperator": "and", | ||
"conditions": [ | ||
{ | ||
"filterType": "tableColumns", | ||
"conditionExpression": "t7.uuid = ?", | ||
"parameterName": "providerUuid" | ||
}, | ||
{ | ||
"filterType": "tableColumns", | ||
"conditionExpression": "DATE(t2.encounter_datetime) = ?", | ||
"parameterName": "encounterDate" | ||
}, | ||
{ | ||
"filterType": "tableColumns", | ||
"conditionExpression": "t2.encounter_type in (?)", | ||
"parameterName": "encounterTypeId" | ||
}, | ||
{ | ||
"filterType": "tableColumns", | ||
"conditionExpression": "l.uuid in (?)", | ||
"parameterName": "locationUuid" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { PatientlistMysqlReport } from '../app/reporting-framework/patientlist-mysql.report'; | ||
const helpers = require('../etl-helpers'); | ||
|
||
export class ClinicFlowService { | ||
getAggregateReport(reportParams) {} | ||
|
||
getPatientListReport(reportParams) { | ||
let indicators = reportParams.indicators | ||
? reportParams.indicators.split(',') | ||
: []; | ||
|
||
let report = new PatientlistMysqlReport( | ||
'clinicFlowProviderStatisticsAggregate', | ||
reportParams | ||
); | ||
|
||
return new Promise(function (resolve, reject) { | ||
report | ||
.generatePatientListReport(indicators) | ||
.then((results) => { | ||
results.results.results.forEach((element) => { | ||
if (element.cur_meds) { | ||
element.cur_meds = helpers.getARVNames(element.cur_meds); | ||
} | ||
if (element.arv_first_regimen) { | ||
element.arv_first_regimen = helpers.getARVNames( | ||
element.arv_first_regimen | ||
); | ||
} | ||
}); | ||
|
||
results['results'] = results.results.results; | ||
delete [results.results]; | ||
resolve(results); | ||
}) | ||
.catch((errors) => { | ||
console.error('Error', errors); | ||
reject(errors); | ||
}); | ||
}); | ||
} | ||
} |