Search in sources :

Example 1 with DataSet

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

the class DailyClinicalEncountersDataSetManagerTest method testReport.

@Test
public void testReport() throws Exception {
    EvaluationContext context = new EvaluationContext();
    context.addParameterValue("day", DateUtil.parseDate("2013-10-01", "yyyy-MM-dd"));
    DataSetDescriptor byLocationDescriptor = new DataSetDescriptor();
    byLocationDescriptor.setKey("byLocation");
    DataSetDefinition dataSetDefinition = manager.constructDataSetDefinition(byLocationDescriptor, null);
    DataSet byLocation = dataSetDefinitionService.evaluate(dataSetDefinition, context);
    for (DataSetRow row : byLocation) {
        if (row.getColumnValue("rowLabel").equals("Klinik Ekstèn")) {
            assertThat((Cohort) row.getColumnValue("clinicalCheckIns"), isCohortWithExactlyMembers(p2, p4));
            assertThat((Cohort) row.getColumnValue("vitals"), isCohortWithExactlyMembers(p2, p3));
            assertThat((Cohort) row.getColumnValue("consults"), isCohortWithExactlyMembers(p2, p4));
            assertThat((Cohort) row.getColumnValue("consultWithoutVitals"), isCohortWithExactlyMembers(p4));
        } else {
            assertThat((Cohort) row.getColumnValue("clinicalCheckIns"), isCohortWithExactlyMembers());
            assertThat((Cohort) row.getColumnValue("vitals"), isCohortWithExactlyMembers());
            assertThat((Cohort) row.getColumnValue("consults"), isCohortWithExactlyMembers());
            assertThat((Cohort) row.getColumnValue("consultWithoutVitals"), isCohortWithExactlyMembers());
        }
    }
}
Also used : DataSetDescriptor(org.openmrs.module.reporting.config.DataSetDescriptor) DataSet(org.openmrs.module.reporting.dataset.DataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DataSetDefinition(org.openmrs.module.reporting.dataset.definition.DataSetDefinition) DataSetRow(org.openmrs.module.reporting.dataset.DataSetRow) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest) Test(org.junit.Test)

Example 2 with DataSet

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

the class InpatientListPageController method get.

public void get(PageModel model, @SpringBean CoreAppsProperties coreAppsProperties, @SpringBean AllDefinitionLibraries libraries, @SpringBean DataSetDefinitionService dsdService) throws EvaluationException {
    EvaluationContext context = new EvaluationContext();
    Date today = new Date();
    context.addParameterValue("day", today);
    DataSet result = null;
    PatientDataSetDefinition dsd = new PatientDataSetDefinition();
    InpatientLocationCohortDefinition inpatientLocationCohortDefinition = new InpatientLocationCohortDefinition();
    dsd.addRowFilter(inpatientLocationCohortDefinition, null);
    dsd.addColumn("patientId", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.patientId"), "");
    dsd.addColumn("familyName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.familyName"), "");
    dsd.addColumn("givenName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.givenName"), "");
    dsd.addColumn("zlEmrId", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.preferredZlEmrId.identifier"), "");
    dsd.addColumn("dossierNumber", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.mostRecentDossierNumber.identifier"), "");
    dsd.addColumn("firstAdmittedLocation", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.admission.location"), "");
    dsd.addColumn("admissionDateTime", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.admission.encounterDatetime"), "");
    dsd.addColumn("inpatientLocation", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.inpatient.location"), "");
    dsd.addColumn("inpatientDateTime", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.inpatient.encounterDatetime"), "");
    result = dsdService.evaluate(dsd, context);
    model.addAttribute("inpatientsList", DataSetUtil.simplify(result));
    model.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());
    // used to determine if we display links to patient dashboard)
    model.put("privilegePatientDashboard", PihEmrConfigConstants.PRIVILEGE_APP_COREAPPS_PATIENT_DASHBOARD);
}
Also used : InpatientLocationCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition) DataSet(org.openmrs.module.reporting.dataset.DataSet) PatientDataDefinition(org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition) PatientDataSetDefinition(org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date)

Example 3 with DataSet

use of org.openmrs.module.reporting.dataset.DataSet in project openmrs-module-coreapps by openmrs.

the class AwaitingAdmissionPageController method get.

public void get(PageModel model, @SpringBean AllDefinitionLibraries libraries, @SpringBean DataSetDefinitionService dsdService, @SpringBean CoreAppsProperties coreAppsProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService) throws EvaluationException {
    EvaluationContext context = new EvaluationContext();
    List<Extension> admissionActions = appFrameworkService.getExtensionsForCurrentUser("coreapps.app.awaitingAdmissionActions");
    Collections.sort(admissionActions);
    model.addAttribute("admissionActions", admissionActions);
    DataSet dataSet = null;
    VisitDataSetDefinition dsd = new VisitDataSetDefinition();
    AwaitingAdmissionVisitQuery query = new AwaitingAdmissionVisitQuery();
    dsd.addRowFilter(query, null);
    dsd.addColumn("visitId", libraries.getDefinition(VisitDataDefinition.class, "reporting.library.visitDataDefinition.builtIn.visitId"), "");
    dsd.addColumn("patientId", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.patientId"), "");
    dsd.addColumn("patientLastName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.familyName"), "");
    dsd.addColumn("patientFirstName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.givenName"), "");
    dsd.addColumn("primaryIdentifier", libraries.getDefinition(PatientDataDefinition.class, "emrapi.patientDataDefinition.primaryIdentifier"), "", new PropertyConverter(String.class, "identifier"));
    dsd.addColumn("mostRecentAdmissionRequestFromLocation", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("fromLocation", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestToLocation", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("toLocation", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestDatetime", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("datetime", null));
    dsd.addColumn("mostRecentAdmissionRequestProvider", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("provider", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestDiagnoses", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("diagnoses", new AwaitingAdmissionDiagnosisFormatter()));
    // add the paper record identifier, if the definition is available (provided by the paper record module)
    PatientDataDefinition paperRecordIdentifierDefinition = libraries.getDefinition(PatientDataDefinition.class, "paperrecord.patientDataDefinition.paperRecordIdentifier");
    if (paperRecordIdentifierDefinition != null) {
        model.addAttribute("paperRecordIdentifierDefinitionAvailable", true);
        dsd.addColumn("paperRecordIdentifier", paperRecordIdentifierDefinition, "", new PropertyConverter(String.class, "identifier"));
    } else {
        model.addAttribute("paperRecordIdentifierDefinitionAvailable", false);
    }
    dsd.addSortCriteria("mostRecentAdmissionRequestDatetime", SortCriteria.SortDirection.ASC);
    dataSet = dsdService.evaluate(dsd, context);
    model.addAttribute("awaitingAdmissionList", DataSetUtil.simplify(dataSet));
    // add location tag constants
    model.addAttribute("supportsAdmissionLocationTag", EmrApiConstants.LOCATION_TAG_SUPPORTS_ADMISSION);
    model.addAttribute("supportsLoginLocationTag", EmrApiConstants.LOCATION_TAG_SUPPORTS_LOGIN);
    // used to determine whether or not we display a link to the patient in the results list
    model.addAttribute("privilegePatientDashboard", CoreAppsConstants.PRIVILEGE_PATIENT_DASHBOARD);
    AppDescriptor app = appFrameworkService.getApp(CoreAppsConstants.AWAITING_ADMISSION);
    String patientPageUrl = app.getConfig().get("patientPageUrl") != null ? app.getConfig().get("patientPageUrl").getTextValue() : coreAppsProperties.getDashboardUrl();
    model.addAttribute("patientPageUrl", patientPageUrl);
}
Also used : VisitDataSetDefinition(org.openmrs.module.reporting.dataset.definition.VisitDataSetDefinition) DataSet(org.openmrs.module.reporting.dataset.DataSet) Extension(org.openmrs.module.appframework.domain.Extension) AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) AwaitingAdmissionVisitQuery(org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery) ObjectFormatter(org.openmrs.module.reporting.data.converter.ObjectFormatter) PatientDataDefinition(org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) VisitDataDefinition(org.openmrs.module.reporting.data.visit.definition.VisitDataDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) MapElementConverter(org.openmrs.module.reporting.data.converter.MapElementConverter)

Example 4 with DataSet

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

the class DailyRegistrationsDataSetManagerTest method testReport.

@Test
public void testReport() throws Exception {
    EvaluationContext context = new EvaluationContext();
    context.addParameterValue("day", DateUtil.parseDate("2013-10-01", "yyyy-MM-dd"));
    DataSetDescriptor byLocationDescriptor = new DataSetDescriptor();
    byLocationDescriptor.setKey("byLocation");
    DataSetDefinition byLocationDsd = manager.constructDataSetDefinition(byLocationDescriptor, null);
    DataSet byLocation = dataSetDefinitionService.evaluate(byLocationDsd, context);
    for (DataSetRow row : byLocation) {
        if (row.getColumnValue("rowLabel").equals("Biwo Resepsyon")) {
            assertThat((Cohort) row.getColumnValue("registrations"), isCohortWithExactlyMembers(p1));
        } else {
            assertThat((Cohort) row.getColumnValue("registrations"), isCohortWithExactlyMembers());
        }
    }
    DataSetDescriptor overallDescriptor = new DataSetDescriptor();
    overallDescriptor.setKey("overall");
    DataSetDefinition overallDsd = manager.constructDataSetDefinition(overallDescriptor, null);
    DataSet overall = dataSetDefinitionService.evaluate(overallDsd, context);
    assertThat(overall.getMetaData().getColumnCount(), is(1));
    DataSetRow overallRow = overall.iterator().next();
    assertThat((Cohort) overallRow.getColumnValue("mirebalaisreports.dailyRegistrations.overall"), isCohortWithExactlyMembers(p1));
}
Also used : DataSetDescriptor(org.openmrs.module.reporting.config.DataSetDescriptor) DataSet(org.openmrs.module.reporting.dataset.DataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DataSetDefinition(org.openmrs.module.reporting.dataset.definition.DataSetDefinition) DataSetRow(org.openmrs.module.reporting.dataset.DataSetRow) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest) Test(org.junit.Test)

Example 5 with DataSet

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

the class DailyCheckInsDataSetManagerTest method testReport.

@Test
public void testReport() throws Exception {
    EvaluationContext context = new EvaluationContext();
    context.addParameterValue("day", DateUtil.parseDate("2013-10-01", "yyyy-MM-dd"));
    DataSetDescriptor byLocationDescriptor = new DataSetDescriptor();
    byLocationDescriptor.setKey("byLocation");
    DataSetDefinition byLocationDsd = manager.constructDataSetDefinition(byLocationDescriptor, null);
    DataSet byLocation = dataSetDefinitionService.evaluate(byLocationDsd, context);
    for (DataSetRow row : byLocation) {
        if (row.getColumnValue("rowLabel").equals("Klinik Ekstèn")) {
            for (Map.Entry<String, Object> e : row.getColumnValuesByKey().entrySet()) {
                if ("mirebalaisreports.dailyCheckInEncounters.CLINICAL_new".equals(e.getKey())) {
                    assertThat((Cohort) e.getValue(), isCohortWithExactlyMembers(p2));
                } else if ("mirebalaisreports.dailyCheckInEncounters.CLINICAL_return".equals(e.getKey())) {
                    assertThat((Cohort) e.getValue(), isCohortWithExactlyMembers(p4));
                } else if ("Pharmacy only".equals(e.getKey())) {
                    assertThat((Cohort) e.getValue(), isCohortWithExactlyMembers(p3));
                } else if (!"rowLabel".equals(e.getKey())) {
                    assertThat((Cohort) e.getValue(), isCohortWithExactlyIds());
                }
            }
        } else {
            // everything else should be empty
            for (Map.Entry<String, Object> e : row.getColumnValuesByKey().entrySet()) {
                if (!"rowLabel".equals(e.getKey())) {
                    assertThat((Cohort) e.getValue(), isCohortWithExactlyIds());
                }
            }
        }
    }
}
Also used : Cohort(org.openmrs.Cohort) DataSetDescriptor(org.openmrs.module.reporting.config.DataSetDescriptor) DataSet(org.openmrs.module.reporting.dataset.DataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DataSetDefinition(org.openmrs.module.reporting.dataset.definition.DataSetDefinition) Map(java.util.Map) DataSetRow(org.openmrs.module.reporting.dataset.DataSetRow) Test(org.junit.Test) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest)

Aggregations

DataSet (org.openmrs.module.reporting.dataset.DataSet)8 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)8 PatientDataDefinition (org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition)4 DataSetRow (org.openmrs.module.reporting.dataset.DataSetRow)4 Test (org.junit.Test)3 Cohort (org.openmrs.Cohort)3 BaseReportTest (org.openmrs.module.pihcore.reporting.BaseReportTest)3 DataSetDescriptor (org.openmrs.module.reporting.config.DataSetDescriptor)3 DataSetDefinition (org.openmrs.module.reporting.dataset.definition.DataSetDefinition)3 PatientDataSetDefinition (org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition)3 Map (java.util.Map)2 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 VelocityContext (org.apache.velocity.VelocityContext)1 AppDescriptor (org.openmrs.module.appframework.domain.AppDescriptor)1 Extension (org.openmrs.module.appframework.domain.Extension)1 AwaitingAdmissionVisitQuery (org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery)1 InpatientLocationCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition)1