use of org.openmrs.module.reporting.cohort.definition.CohortDefinition 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.CohortDefinition 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.CohortDefinition 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.CohortDefinition 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