Search in sources :

Example 1 with CohortsWithVaryingParametersDataSetDefinition

use of org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition in project openmrs-module-pihcore by PIH.

the class DailyCheckInsDataSetManager method constructDataSetDefinition.

@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File file) {
    String messagePrefix = "mirebalaisreports.dailyCheckInEncounters.";
    if ("overall".equalsIgnoreCase(dataSetDescriptor.getKey())) {
        CohortCrossTabDataSetDefinition overallDsd = new CohortCrossTabDataSetDefinition();
        overallDsd.setName("overall");
        overallDsd.addParameter(getDayParameter());
        EncounterCohortDefinition overall = new EncounterCohortDefinition();
        overall.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_CHECK_IN_UUID));
        overall.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
        overall.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
        overallDsd.addColumn(messagePrefix + "overall", Mapped.map(overall, "onOrAfter=${day},onOrBefore=${day+1d-1ms}"));
        EncounterCohortDefinition multipleCheckIns = new EncounterCohortDefinition();
        multipleCheckIns.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_CHECK_IN_UUID));
        multipleCheckIns.setAtLeastCount(2);
        multipleCheckIns.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
        multipleCheckIns.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
        overallDsd.addColumn(messagePrefix + "dataQuality.multipleCheckins", Mapped.map(multipleCheckIns, "onOrAfter=${day},onOrBefore=${day+1d-1ms}"));
        return overallDsd;
    } else if ("byLocation".equalsIgnoreCase(dataSetDescriptor.getKey())) {
        CohortsWithVaryingParametersDataSetDefinition byLocationDsd = new CohortsWithVaryingParametersDataSetDefinition();
        byLocationDsd.setName("byLocation");
        byLocationDsd.addParameter(getDayParameter());
        EncounterCohortDefinition priorConsultAtLocation = new EncounterCohortDefinition();
        priorConsultAtLocation.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_CONSULTATION_UUID));
        priorConsultAtLocation.addParameter(new Parameter("locationList", "Location List", Location.class));
        priorConsultAtLocation.addParameter(new Parameter("onOrBefore", "On or before", Date.class));
        Mapped<CohortDefinition> mappedPriorConsultAtLocation = Mapped.map(priorConsultAtLocation, "onOrBefore=${day-1ms},locationList=${location}");
        byLocationDsd.addColumn(checkInSplitByPriorConsultation(messagePrefix + "CLINICAL_new", checkInWithReason("PIH", "CLINICAL"), mappedPriorConsultAtLocation, false));
        byLocationDsd.addColumn(checkInSplitByPriorConsultation(messagePrefix + "CLINICAL_return", checkInWithReason("PIH", "CLINICAL"), mappedPriorConsultAtLocation, true));
        byLocationDsd.addColumn(checkInWithReason("PIH", "Lab only"));
        byLocationDsd.addColumn(checkInWithReason("PIH", "Pharmacy only"));
        byLocationDsd.addColumn(checkInWithReason("PIH", "Procedure only"));
        byLocationDsd.addColumn(checkInWithReason("PIH", "Social assistance and psychosocial support"));
        byLocationDsd.addColumn(checkInWithReason("PIH", "Request scheduled appointment"));
        byLocationDsd.addColumn(checkInWithReason("PIH", "ID card only"));
        byLocationDsd.addColumn(checkInWithOtherOrMissingReasons("CLINICAL", "Lab only", "Pharmacy only", "Procedure only", "Social assistance and psychosocial support", "Request scheduled appointment", "ID card only"));
        byLocationDsd.setVaryingParameters(getParameterOptions());
        byLocationDsd.setRowLabelTemplate("{{ location.name }}");
        return byLocationDsd;
    } else {
        throw new IllegalArgumentException("You must configure this DataSet with either 'overall' or 'byLocation'");
    }
}
Also used : Mapped(org.openmrs.module.reporting.evaluation.parameter.Mapped) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) CohortsWithVaryingParametersDataSetDefinition(org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) Date(java.util.Date) CohortCrossTabDataSetDefinition(org.openmrs.module.reporting.dataset.definition.CohortCrossTabDataSetDefinition)

Example 2 with CohortsWithVaryingParametersDataSetDefinition

use of org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition 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 3 with CohortsWithVaryingParametersDataSetDefinition

use of org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition in project openmrs-module-pihcore by PIH.

the class DailyRegistrationsDataSetManager method constructDataSetDefinition.

@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File file) {
    String messagePrefix = "mirebalaisreports.dailyRegistrations.";
    if ("overall".equalsIgnoreCase(dataSetDescriptor.getKey())) {
        CohortCrossTabDataSetDefinition overallDsd = new CohortCrossTabDataSetDefinition();
        overallDsd.setName("overall");
        overallDsd.addParameter(getDayParameter());
        EncounterCohortDefinition overall = new EncounterCohortDefinition();
        overall.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_PATIENT_REGISTRATION_UUID));
        overall.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
        overall.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
        overallDsd.addColumn(messagePrefix + "overall", Mapped.map(overall, "onOrAfter=${day},onOrBefore=${day+1d-1ms}"));
        return overallDsd;
    } else if ("byLocation".equalsIgnoreCase(dataSetDescriptor.getKey())) {
        CohortsWithVaryingParametersDataSetDefinition byLocationDsd = new CohortsWithVaryingParametersDataSetDefinition();
        byLocationDsd.setName("byLocation");
        byLocationDsd.addParameter(getDayParameter());
        byLocationDsd.setVaryingParameters(getParameterOptions());
        byLocationDsd.setRowLabelTemplate("{{ location.name }}");
        EncounterCohortDefinition regByLocation = new EncounterCohortDefinition();
        regByLocation.setName("registrations");
        regByLocation.setDescription("ui.i18n.EncounterType.name.873f968a-73a8-4f9c-ac78-9f4778b751b6");
        regByLocation.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_PATIENT_REGISTRATION_UUID));
        regByLocation.addParameter(new Parameter("locationList", "Location", Location.class));
        regByLocation.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
        regByLocation.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
        Mapped<CohortDefinition> mappedRegByLocation = Mapped.map(regByLocation, "onOrAfter=${day},onOrBefore=${day+1d-1ms},locationList=${location}");
        byLocationDsd.addColumn(mappedRegByLocation);
        return byLocationDsd;
    } else {
        throw new IllegalArgumentException("You must configure this DataSet with either 'overall' or 'byLocation'");
    }
}
Also used : Mapped(org.openmrs.module.reporting.evaluation.parameter.Mapped) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) CohortsWithVaryingParametersDataSetDefinition(org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) Date(java.util.Date) CohortCrossTabDataSetDefinition(org.openmrs.module.reporting.dataset.definition.CohortCrossTabDataSetDefinition)

Aggregations

Date (java.util.Date)3 EncounterCohortDefinition (org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition)3 CohortsWithVaryingParametersDataSetDefinition (org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition)3 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)3 CohortCrossTabDataSetDefinition (org.openmrs.module.reporting.dataset.definition.CohortCrossTabDataSetDefinition)2 Mapped (org.openmrs.module.reporting.evaluation.parameter.Mapped)2 EncounterType (org.openmrs.EncounterType)1 Location (org.openmrs.Location)1 CohortDefinition (org.openmrs.module.reporting.cohort.definition.CohortDefinition)1 CompositionCohortDefinition (org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition)1