use of org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition in project openmrs-module-pihcore by PIH.
the class DailyClinicalEncountersDataSetManager method constructDataSetDefinition.
@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File file) {
String messagePrefix = "mirebalaisreports.dailyClinicalEncounters.";
EncounterType vitalsEncounterType = encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_VITALS_UUID);
EncounterType consultEncounterType = encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_CONSULTATION_UUID);
CohortDefinition clinicalCheckIns = pihCohorts.getClinicalCheckInAtLocation();
clinicalCheckIns.setName("clinicalCheckIns");
clinicalCheckIns.setDescription(messagePrefix + "clinicalCheckIns");
Mapped<CohortDefinition> mappedClinicalCheckIns = Mapped.map(clinicalCheckIns, "startDate=${day},endDate=${day+1d-1ms},location=${location}");
EncounterCohortDefinition vitals = new EncounterCohortDefinition();
vitals.setName("vitals");
vitals.setDescription("ui.i18n.EncounterType.name." + vitalsEncounterType.getUuid());
vitals.addParameter(new Parameter("locationList", "Location", Location.class));
vitals.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
vitals.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
vitals.addEncounterType(vitalsEncounterType);
Mapped<CohortDefinition> mappedVitals = Mapped.map(vitals, "onOrAfter=${day},onOrBefore=${day+1d-1ms},locationList=${location}");
EncounterCohortDefinition consults = new EncounterCohortDefinition();
consults.setName("consults");
consults.setDescription("ui.i18n.EncounterType.name." + consultEncounterType.getUuid());
consults.addParameter(new Parameter("locationList", "Location", Location.class));
consults.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
consults.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
consults.addEncounterType(consultEncounterType);
Mapped<CohortDefinition> mappedConsults = Mapped.map(consults, "onOrAfter=${day},onOrBefore=${day+1d-1ms},locationList=${location}");
CompositionCohortDefinition consultWithoutVitals = new CompositionCohortDefinition();
consultWithoutVitals.setName("consultWithoutVitals");
consultWithoutVitals.setDescription(messagePrefix + "consultWithoutVitals");
consultWithoutVitals.addParameter(getDayParameter());
consultWithoutVitals.addParameter(getLocationParameter());
consultWithoutVitals.addSearch("consult", mappedConsults);
consultWithoutVitals.addSearch("vitals", mappedVitals);
consultWithoutVitals.setCompositionString("consult AND NOT vitals");
CohortsWithVaryingParametersDataSetDefinition byLocationDsd = new CohortsWithVaryingParametersDataSetDefinition();
byLocationDsd.setName("byLocation");
byLocationDsd.addParameter(getDayParameter());
byLocationDsd.addColumn(mappedClinicalCheckIns);
byLocationDsd.addColumn(mappedVitals);
byLocationDsd.addColumn(mappedConsults);
byLocationDsd.addColumn(Mapped.mapStraightThrough(consultWithoutVitals));
byLocationDsd.setVaryingParameters(getParameterOptions());
byLocationDsd.setRowLabelTemplate("{{ location.name }}");
return byLocationDsd;
}
use of org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition in project openmrs-module-pihcore by PIH.
the class MirebalaisPatientDataSetManager method constructDataSetDefinition.
@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File baseConfigDir) {
PatientDataSetDefinition dsd = new PatientDataSetDefinition();
dsd.addParameter(getStartDateParameter());
dsd.addParameter(getEndDateParameter());
CompositionCohortDefinition baseCohortDefinition = new CompositionCohortDefinition();
baseCohortDefinition.addParameter(getStartDateParameter());
baseCohortDefinition.addParameter(getEndDateParameter());
VisitCohortDefinition visitDuringPeriod = new VisitCohortDefinition();
visitDuringPeriod.addParameter(new Parameter("activeOnOrAfter", "", Date.class));
visitDuringPeriod.addParameter(new Parameter("activeOnOrBefore", "", Date.class));
baseCohortDefinition.addSearch("visitDuringPeriod", this.<CohortDefinition>map(visitDuringPeriod, "activeOnOrAfter=${startDate},activeOnOrBefore=${endDate}"));
EncounterType registrationEncounterType = Metadata.lookupEncounterType(PihEmrConfigConstants.ENCOUNTERTYPE_PATIENT_REGISTRATION_UUID);
EncounterCohortDefinition registrationEncounterDuringPeriod = new EncounterCohortDefinition();
registrationEncounterDuringPeriod.addEncounterType(registrationEncounterType);
registrationEncounterDuringPeriod.addParameter(new Parameter("onOrAfter", "", Date.class));
registrationEncounterDuringPeriod.addParameter(new Parameter("onOrBefore", "", Date.class));
baseCohortDefinition.addSearch("registrationEncounterDuringPeriod", this.<CohortDefinition>map(registrationEncounterDuringPeriod, "onOrAfter=${startDate},onOrBefore=${endDate}"));
baseCohortDefinition.setCompositionString("(visitDuringPeriod OR registrationEncounterDuringPeriod)");
dsd.addRowFilter(this.<CohortDefinition>map(baseCohortDefinition, "startDate=${startDate},endDate=${endDate}"));
dsd.addColumn("patient_id", builtInPatientData.getPatientId(), "");
dsd.addColumn("zlemr", pihPatientData.getPreferredZlEmrIdIdentifier(), "");
dsd.addColumn("loc_registered", pihPatientData.getMostRecentZlEmrIdLocation(), "");
dsd.addColumn("unknown_patient", pihPatientData.getUnknownPatient(), "");
dsd.addColumn("numzlemr", pihPatientData.getNumberOfZlEmrIds(), "");
dsd.addColumn("numero_dossier", pihPatientData.getAllDossierNumberIdentifiers(), "");
dsd.addColumn("num_nd", pihPatientData.getNumberOfDossierNumbers(), "");
dsd.addColumn("hivemr", pihPatientData.getMostRecentHivEmrIdIdentifier(), "");
dsd.addColumn("num_hiv", pihPatientData.getNumberOfHivEmrIds(), "");
dsd.addColumn("birthdate", builtInPatientData.getBirthdateYmd(), "");
dsd.addColumn("birthdate_estimated", builtInPatientData.getBirthdateEstimated(), "");
dsd.addColumn("gender", builtInPatientData.getGender(), "");
dsd.addColumn("dead", builtInPatientData.getVitalStatusDead(), "");
dsd.addColumn("death_date", builtInPatientData.getVitalStatusDeathDate(), "");
dsd.addColumn("department", pihPatientData.getPreferredAddressDepartment(), "");
dsd.addColumn("commune", pihPatientData.getPreferredAddressCommune(), "");
dsd.addColumn("section", pihPatientData.getPreferredAddressSection(), "");
dsd.addColumn("locality", pihPatientData.getPreferredAddressLocality(), "");
dsd.addColumn("street_landmark", pihPatientData.getPreferredAddressStreetLandmark(), "");
dsd.addColumn("date_registered", pihPatientData.getRegistrationDatetime(), "");
dsd.addColumn("reg_location", pihPatientData.getRegistrationLocation(), "");
dsd.addColumn("reg_by", pihPatientData.getRegistrationCreatorName(), "");
dsd.addColumn("age_at_reg", pihPatientData.getRegistrationAge(), "");
return dsd;
}
use of org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition in project openmrs-module-pihcore by PIH.
the class PihCohortDefinitionLibrary method getExcludeTestPatients.
@DocumentedDefinition(value = "excludeTestPatients")
public CohortDefinition getExcludeTestPatients() {
CohortDefinition test = getTestPatients();
CompositionCohortDefinition excludeTestPatientsCohortDefinition = new CompositionCohortDefinition();
excludeTestPatientsCohortDefinition.addSearch("test", map(test, ""));
excludeTestPatientsCohortDefinition.setCompositionString("NOT test");
return excludeTestPatientsCohortDefinition;
}
use of org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition in project openmrs-module-pihcore by PIH.
the class PihCohortDefinitionLibrary method getDiedExitFromLocationDuringPeriodSoonAfterAdmission.
@DocumentedDefinition(value = "diedExitFromLocationDuringPeriodSoonAfterAdmission")
public CohortDefinition getDiedExitFromLocationDuringPeriodSoonAfterAdmission() {
CohortDefinition diedSoonAfterAdmission = getDiedSoonAfterAdmissionDuringPeriod();
CohortDefinition diedExit = getDiedExitFromLocationDuringPeriod();
CompositionCohortDefinition deathsEarly = new CompositionCohortDefinition();
deathsEarly.addParameter(parameter(Date.class, "startDate"));
deathsEarly.addParameter(parameter(Date.class, "endDate"));
deathsEarly.addParameter(parameter(Location.class, "location"));
deathsEarly.addSearch("died", Mapped.mapStraightThrough(diedExit));
deathsEarly.addSearch("diedSoon", Mapped.mapStraightThrough(diedSoonAfterAdmission));
deathsEarly.setCompositionString("died AND diedSoon");
return diedExit;
}
use of org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition in project openmrs-module-pihcore by PIH.
the class PihCohortDefinitionLibrary method getDiedExitFromLocationDuringPeriodNotSoonAfterAdmission.
@DocumentedDefinition(value = "diedExitFromLocationDuringPeriodNotSoonAfterAdmission")
public CohortDefinition getDiedExitFromLocationDuringPeriodNotSoonAfterAdmission() {
CohortDefinition diedSoonAfterAdmission = getDiedSoonAfterAdmissionDuringPeriod();
CohortDefinition diedExit = getDiedExitFromLocationDuringPeriod();
CompositionCohortDefinition deathsEarly = new CompositionCohortDefinition();
deathsEarly.addParameter(parameter(Date.class, "startDate"));
deathsEarly.addParameter(parameter(Date.class, "endDate"));
deathsEarly.addParameter(parameter(Location.class, "location"));
deathsEarly.addSearch("died", Mapped.mapStraightThrough(diedExit));
deathsEarly.addSearch("diedSoon", Mapped.mapStraightThrough(diedSoonAfterAdmission));
deathsEarly.setCompositionString("died AND NOT diedSoon");
return diedExit;
}
Aggregations