use of org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition in project openmrs-module-pihcore by PIH.
the class InpatientStatsDailyDataSetManager method constructDataSetDefinition.
@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File file) {
List<Location> inpatientLocations = adtService.getInpatientLocations();
EncounterType admissionEncounterType = encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_ADMISSION_UUID);
Concept dischargedDisposition = conceptService.getConceptByMapping("DISCHARGED", "PIH");
Concept deathDisposition = conceptService.getConceptByMapping("DEATH", "PIH");
Concept transferOutDisposition = conceptService.getConceptByMapping("Transfer out of hospital", "PIH");
Concept leftWithoutCompletionOfTreatmentDisposition = conceptService.getConceptByMapping("Departed without medical discharge", "PIH");
Concept leftWithoutSeeingClinicianDisposition = conceptService.getConceptByMapping("Left without seeing a clinician", "PIH");
List<Concept> dispositionsToConsider = Arrays.asList(dischargedDisposition, deathDisposition, transferOutDisposition, leftWithoutCompletionOfTreatmentDisposition, leftWithoutSeeingClinicianDisposition);
// Dispositions we're currently ignoring: "Transfer within hospital", "Admit to hospital", "Discharged", "Emergency Department observation", "Home"
CohortIndicatorDataSetDefinition cohortDsd = new CohortIndicatorDataSetDefinition();
cohortDsd.addParameter(getStartDateParameter());
cohortDsd.addParameter(getEndDateParameter());
DiedSoonAfterEncounterCohortDefinition diedSoonAfterAdmission = new DiedSoonAfterEncounterCohortDefinition();
diedSoonAfterAdmission.setEncounterType(admissionEncounterType);
diedSoonAfterAdmission.addParameter(new Parameter("diedOnOrAfter", "Died on or after", Date.class));
diedSoonAfterAdmission.addParameter(new Parameter("diedOnOrBefore", "Died on or before", Date.class));
for (Location location : inpatientLocations) {
addIndicator(cohortDsd, "censusAtStart", "Census at start", location, Mapped.map(pihCohorts.getInpatientAtLocationOnDate(), "date=${startDate}"));
addIndicator(cohortDsd, "censusAtEnd", "Census at end", location, Mapped.map(pihCohorts.getInpatientAtLocationOnDate(), "date=${endDate}"));
addIndicator(cohortDsd, "admissions", "Admission", location, Mapped.mapStraightThrough(pihCohorts.getAdmissionAtLocationDuringPeriod()));
addIndicator(cohortDsd, "transfersIn", "Transfer In", location, Mapped.mapStraightThrough(pihCohorts.getTransferInToLocationDuringPeriod()));
addIndicator(cohortDsd, "transfersOut", "Transfer Out", location, Mapped.mapStraightThrough(pihCohorts.getTransferOutOfLocationDuringPeriod()));
addIndicator(cohortDsd, "discharged", "Discharged", location, Mapped.mapStraightThrough(pihCohorts.getDischargeExitFromLocationDuringPeriod()));
addIndicator(cohortDsd, "deathsWithin48", "Deaths within 48h", location, Mapped.mapStraightThrough(pihCohorts.getDiedExitFromLocationDuringPeriodSoonAfterAdmission()));
addIndicator(cohortDsd, "deathsAfter48", "Deaths after 48h", location, Mapped.mapStraightThrough(pihCohorts.getDiedExitFromLocationDuringPeriodNotSoonAfterAdmission()));
addIndicator(cohortDsd, "transfersOutOfHUM", "Transfer Outs", location, Mapped.mapStraightThrough(pihCohorts.getTransferOutOfHumExitFromLocationDuringPeriod()));
// number left without completing treatment
LastDispositionBeforeExitCohortDefinition leftWithoutCompletingTreatment = new LastDispositionBeforeExitCohortDefinition();
leftWithoutCompletingTreatment.addParameter(new Parameter("exitOnOrAfter", "Exit on or after", Date.class));
leftWithoutCompletingTreatment.addParameter(new Parameter("exitOnOrBefore", "Exit on or before", Date.class));
leftWithoutCompletingTreatment.setExitFromWard(location);
leftWithoutCompletingTreatment.setDispositionsToConsider(dispositionsToConsider);
leftWithoutCompletingTreatment.addDisposition(leftWithoutCompletionOfTreatmentDisposition);
addIndicator(cohortDsd, "leftWithoutCompletingTx", "Left Without Completing Treatment", location, Mapped.map(leftWithoutCompletingTreatment, "exitOnOrAfter=${startDate},exitOnOrBefore=${endDate}"));
LastDispositionBeforeExitCohortDefinition leftWithoutSeeingClinician = new LastDispositionBeforeExitCohortDefinition();
leftWithoutSeeingClinician.addParameter(new Parameter("exitOnOrAfter", "Exit on or after", Date.class));
leftWithoutSeeingClinician.addParameter(new Parameter("exitOnOrBefore", "Exit on or before", Date.class));
leftWithoutSeeingClinician.setExitFromWard(location);
leftWithoutSeeingClinician.setDispositionsToConsider(dispositionsToConsider);
leftWithoutSeeingClinician.addDisposition(leftWithoutSeeingClinicianDisposition);
addIndicator(cohortDsd, "leftWithoutSeeingClinician", "Left Without Seeing Clinician", location, Mapped.map(leftWithoutSeeingClinician, "exitOnOrAfter=${startDate},exitOnOrBefore=${endDate}"));
}
// number of ED check-ins
// TODO change this to count by visits or by encounters, instead of by patients
EncounterCohortDefinition edCheckIn = new EncounterCohortDefinition();
edCheckIn.addParameter(new Parameter("onOrAfter", "On or after", Date.class));
edCheckIn.addParameter(new Parameter("onOrBefore", "On or before", Date.class));
edCheckIn.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_CHECK_IN_UUID));
edCheckIn.addLocation(locationService.getLocationByUuid(EMERGENCY_DEPARTMENT_UUID));
edCheckIn.addLocation(locationService.getLocationByUuid(EMERGENCY_RECEPTION_UUID));
addIndicator(cohortDsd, "edcheckin", "ED Check In", Mapped.map(edCheckIn, "onOrAfter=${startDate},onOrBefore=${endDate}"));
// number of surgical op-notes entered
EncounterCohortDefinition surgicalNotes = new EncounterCohortDefinition();
surgicalNotes.addParameter(new Parameter("onOrAfter", "On or after", Date.class));
surgicalNotes.addParameter(new Parameter("onOrBefore", "On or before", Date.class));
surgicalNotes.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_POST_OPERATIVE_NOTE_UUID));
addIndicator(cohortDsd, "orvolume", "OR Volume", Mapped.map(surgicalNotes, "onOrAfter=${startDate},onOrBefore=${endDate}"));
// potential readmissions
AdmissionSoonAfterExitCohortDefinition readmission = new AdmissionSoonAfterExitCohortDefinition();
readmission.addParameter(new Parameter("onOrAfter", "On or after", Date.class));
readmission.addParameter(new Parameter("onOrBefore", "On or before", Date.class));
addIndicator(cohortDsd, "possiblereadmission", "Possible Readmission", Mapped.map(readmission, "onOrAfter=${startDate},onOrBefore=${endDate}"));
return cohortDsd;
}
Aggregations