Search in sources :

Example 1 with CohortCrossTabDataSetDefinition

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

use of org.openmrs.module.reporting.dataset.definition.CohortCrossTabDataSetDefinition 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)2 EncounterCohortDefinition (org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition)2 CohortCrossTabDataSetDefinition (org.openmrs.module.reporting.dataset.definition.CohortCrossTabDataSetDefinition)2 CohortsWithVaryingParametersDataSetDefinition (org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition)2 Mapped (org.openmrs.module.reporting.evaluation.parameter.Mapped)2 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)2