Search in sources :

Example 1 with CompositionCohortDefinition

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;
}
Also used : CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) CohortDefinition(org.openmrs.module.reporting.cohort.definition.CohortDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) EncounterType(org.openmrs.EncounterType) CohortsWithVaryingParametersDataSetDefinition(org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) Date(java.util.Date) Location(org.openmrs.Location)

Example 2 with CompositionCohortDefinition

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;
}
Also used : PatientDataSetDefinition(org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) EncounterType(org.openmrs.EncounterType) VisitCohortDefinition(org.openmrs.module.reporting.cohort.definition.VisitCohortDefinition) Date(java.util.Date) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition)

Example 3 with CompositionCohortDefinition

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;
}
Also used : CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) PersonAttributeCohortDefinition(org.openmrs.module.reporting.cohort.definition.PersonAttributeCohortDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) DiedSoonAfterEncounterCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiedSoonAfterEncounterCohortDefinition) LastDispositionBeforeExitCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.LastDispositionBeforeExitCohortDefinition) InpatientLocationCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition) DiagnosisCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition) MappedParametersCohortDefinition(org.openmrs.module.reporting.cohort.definition.MappedParametersCohortDefinition) CohortDefinition(org.openmrs.module.reporting.cohort.definition.CohortDefinition) EncounterWithCodedObsCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterWithCodedObsCohortDefinition) InpatientTransferCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition) CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) DocumentedDefinition(org.openmrs.module.reporting.definition.library.DocumentedDefinition)

Example 4 with CompositionCohortDefinition

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;
}
Also used : CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) PersonAttributeCohortDefinition(org.openmrs.module.reporting.cohort.definition.PersonAttributeCohortDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) DiedSoonAfterEncounterCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiedSoonAfterEncounterCohortDefinition) LastDispositionBeforeExitCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.LastDispositionBeforeExitCohortDefinition) InpatientLocationCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition) DiagnosisCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition) MappedParametersCohortDefinition(org.openmrs.module.reporting.cohort.definition.MappedParametersCohortDefinition) CohortDefinition(org.openmrs.module.reporting.cohort.definition.CohortDefinition) EncounterWithCodedObsCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterWithCodedObsCohortDefinition) InpatientTransferCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition) CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) Date(java.util.Date) Location(org.openmrs.Location) DocumentedDefinition(org.openmrs.module.reporting.definition.library.DocumentedDefinition)

Example 5 with CompositionCohortDefinition

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;
}
Also used : CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) PersonAttributeCohortDefinition(org.openmrs.module.reporting.cohort.definition.PersonAttributeCohortDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) DiedSoonAfterEncounterCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiedSoonAfterEncounterCohortDefinition) LastDispositionBeforeExitCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.LastDispositionBeforeExitCohortDefinition) InpatientLocationCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition) DiagnosisCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition) MappedParametersCohortDefinition(org.openmrs.module.reporting.cohort.definition.MappedParametersCohortDefinition) CohortDefinition(org.openmrs.module.reporting.cohort.definition.CohortDefinition) EncounterWithCodedObsCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterWithCodedObsCohortDefinition) InpatientTransferCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition) CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) Date(java.util.Date) Location(org.openmrs.Location) DocumentedDefinition(org.openmrs.module.reporting.definition.library.DocumentedDefinition)

Aggregations

CompositionCohortDefinition (org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition)6 EncounterCohortDefinition (org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition)5 Date (java.util.Date)4 CohortDefinition (org.openmrs.module.reporting.cohort.definition.CohortDefinition)4 Location (org.openmrs.Location)3 DiagnosisCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition)3 DiedSoonAfterEncounterCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.DiedSoonAfterEncounterCohortDefinition)3 InpatientLocationCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition)3 InpatientTransferCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition)3 LastDispositionBeforeExitCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.LastDispositionBeforeExitCohortDefinition)3 EncounterWithCodedObsCohortDefinition (org.openmrs.module.reporting.cohort.definition.EncounterWithCodedObsCohortDefinition)3 MappedParametersCohortDefinition (org.openmrs.module.reporting.cohort.definition.MappedParametersCohortDefinition)3 PersonAttributeCohortDefinition (org.openmrs.module.reporting.cohort.definition.PersonAttributeCohortDefinition)3 DocumentedDefinition (org.openmrs.module.reporting.definition.library.DocumentedDefinition)3 EncounterType (org.openmrs.EncounterType)2 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)2 VisitCohortDefinition (org.openmrs.module.reporting.cohort.definition.VisitCohortDefinition)1 CohortsWithVaryingParametersDataSetDefinition (org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition)1 PatientDataSetDefinition (org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition)1