Search in sources :

Example 1 with DataSetDescriptor

use of org.openmrs.module.reporting.config.DataSetDescriptor in project openmrs-module-pihcore by PIH.

the class InpatientStatsDailyDataSetManagerTest method testRunningReport.

@Test
public void testRunningReport() throws Exception {
    EvaluationContext context = new EvaluationContext();
    context.addParameterValue("day", DateUtil.parseDate("2013-10-03", "yyyy-MM-dd"));
    DataSetDescriptor descriptor = new DataSetDescriptor();
    DataSetDefinition dsd = manager.constructDataSetDefinition(descriptor, null);
    MapDataSet mds = (MapDataSet) dataSetDefinitionService.evaluate(dsd, context);
    Map<String, Integer> results = new HashMap<>();
    for (DataSetColumn column : mds.getMetaData().getColumns()) {
        CohortIndicatorAndDimensionResult val = (CohortIndicatorAndDimensionResult) mds.getData(column);
        results.put(column.getName(), val.getValue().intValue());
    }
    // Men's Internal Medicine
    assertAndRemove(results, "censusAtStart:e5db0599-89e8-44fa-bfa2-07e47d63546f", 1);
    assertAndRemove(results, "admissions:e5db0599-89e8-44fa-bfa2-07e47d63546f", 1);
    assertAndRemove(results, "discharged:e5db0599-89e8-44fa-bfa2-07e47d63546f", 1);
    assertAndRemove(results, "censusAtEnd:e5db0599-89e8-44fa-bfa2-07e47d63546f", 1);
    // Surgical Ward
    assertAndRemove(results, "transfersIn:7d6cc39d-a600-496f-a320-fd4985f07f0b", 1);
    assertAndRemove(results, "censusAtEnd:7d6cc39d-a600-496f-a320-fd4985f07f0b", 1);
    // Women's Internal Medicine
    assertAndRemove(results, "censusAtStart:2c93919d-7fc6-406d-a057-c0b640104790", 2);
    assertAndRemove(results, "transfersOut:2c93919d-7fc6-406d-a057-c0b640104790", 1);
    assertAndRemove(results, "censusAtEnd:2c93919d-7fc6-406d-a057-c0b640104790", 1);
    assertAndRemove(results, "edcheckin", 1);
    assertAndRemove(results, "orvolume", 1);
    assertAndRemove(results, "possiblereadmission", 1);
    // everything else should be 0
    for (Integer actual : results.values()) {
        assertThat(actual, is(0));
    }
}
Also used : DataSetColumn(org.openmrs.module.reporting.dataset.DataSetColumn) DataSetDescriptor(org.openmrs.module.reporting.config.DataSetDescriptor) HashMap(java.util.HashMap) MapDataSet(org.openmrs.module.reporting.dataset.MapDataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DataSetDefinition(org.openmrs.module.reporting.dataset.definition.DataSetDefinition) CohortIndicatorAndDimensionResult(org.openmrs.module.reporting.indicator.dimension.CohortIndicatorAndDimensionResult) BaseInpatientReportTest(org.openmrs.module.pihcore.reporting.BaseInpatientReportTest) Test(org.junit.Test)

Example 2 with DataSetDescriptor

use of org.openmrs.module.reporting.config.DataSetDescriptor 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 3 with DataSetDescriptor

use of org.openmrs.module.reporting.config.DataSetDescriptor 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 4 with DataSetDescriptor

use of org.openmrs.module.reporting.config.DataSetDescriptor 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

Test (org.junit.Test)4 DataSetDescriptor (org.openmrs.module.reporting.config.DataSetDescriptor)4 DataSetDefinition (org.openmrs.module.reporting.dataset.definition.DataSetDefinition)4 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)4 BaseReportTest (org.openmrs.module.pihcore.reporting.BaseReportTest)3 DataSet (org.openmrs.module.reporting.dataset.DataSet)3 DataSetRow (org.openmrs.module.reporting.dataset.DataSetRow)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Cohort (org.openmrs.Cohort)1 BaseInpatientReportTest (org.openmrs.module.pihcore.reporting.BaseInpatientReportTest)1 DataSetColumn (org.openmrs.module.reporting.dataset.DataSetColumn)1 MapDataSet (org.openmrs.module.reporting.dataset.MapDataSet)1 CohortIndicatorAndDimensionResult (org.openmrs.module.reporting.indicator.dimension.CohortIndicatorAndDimensionResult)1