Search in sources :

Example 1 with DataSetRow

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

the class CheckInDataSetManagerTest method testDataSet.

@Test
public void testDataSet() throws Exception {
    DataSetDefinition dsd = checkInDataSetManager.constructDataSet();
    EvaluationContext context = new EvaluationContext();
    context.addParameterValue("startDate", DateUtil.getDateTime(2015, 1, 1));
    context.addParameterValue("endDate", DateUtil.getDateTime(2015, 12, 31));
    SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
    DataSetRow row = dataSet.getRows().get(0);
    Assert.assertEquals(1, dataSet.getRows().size());
    Assert.assertNull(row.getColumnValue("CHECK_IN_VISIT"));
    Assert.assertEquals(22, dataSet.getMetaData().getColumnCount());
    Assert.assertEquals("X3XK71", row.getColumnValue("EMR_ID"));
    Assert.assertEquals(DateUtil.getDateTime(1977, 11, 23), row.getColumnValue("BIRTHDATE"));
    Assert.assertEquals(false, row.getColumnValue("BIRTHDATE_ESTIMATED"));
    Assert.assertEquals(37.4, row.getColumnValue("AGE_AT_CHECK_IN"));
    Assert.assertEquals("M", row.getColumnValue("GENDER"));
    Assert.assertEquals(DateUtil.getDateTime(2015, 4, 15), row.getColumnValue("CHECK_IN_DATE"));
    Assert.assertEquals(MirebalaisLocations.OUTPATIENT_CLINIC.name(), row.getColumnValue("CHECK_IN_LOCATION"));
    Assert.assertEquals("Malnutrition program", row.getColumnValue("TYPE_OF_VISIT"));
    Assert.assertEquals("true", row.getColumnValue("CHECK_IN_RETROSPECTIVE"));
    Assert.assertEquals("true", row.getColumnValue("BIOMETRICS_COLLECTED"));
}
Also used : SimpleDataSet(org.openmrs.module.reporting.dataset.SimpleDataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DataSetDefinition(org.openmrs.module.reporting.dataset.definition.DataSetDefinition) DataSetRow(org.openmrs.module.reporting.dataset.DataSetRow) Test(org.junit.Test)

Example 2 with DataSetRow

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

the class RegistrationDataSetManagerTest method testDataSet.

@Test
public void testDataSet() throws Exception {
    DataSetDefinition dsd = registrationDataSetManager.constructDataSet();
    EvaluationContext context = new EvaluationContext();
    context.addParameterValue("startDate", DateUtil.getDateTime(2015, 1, 1));
    context.addParameterValue("endDate", DateUtil.getDateTime(2015, 12, 31));
    SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
    DataSetRow row = dataSet.getRows().get(0);
    Assert.assertEquals(1, dataSet.getRows().size());
    Assert.assertEquals(29, dataSet.getMetaData().getColumnCount());
    Assert.assertEquals("John", row.getColumnValue("GIVEN_NAME"));
    Assert.assertEquals("Smitty", row.getColumnValue("NICKNAME"));
    Assert.assertEquals("Smith", row.getColumnValue("FAMILY_NAME"));
    Assert.assertEquals(DateUtil.getDateTime(1977, 11, 23), row.getColumnValue("BIRTHDATE"));
    Assert.assertEquals(false, row.getColumnValue("BIRTHDATE_ESTIMATED"));
    Assert.assertEquals(37.4, row.getColumnValue("AGE_AT_REGISTRATION"));
    Assert.assertNull(row.getColumnValue("CHECK_IN_VISIT"));
    Assert.assertEquals("M", row.getColumnValue("GENDER"));
    Assert.assertEquals("555-1234", row.getColumnValue("TELEPHONE_NUMBER"));
    Assert.assertEquals("Wichita", row.getColumnValue("BIRTHPLACE"));
    Assert.assertEquals("Isabel", row.getColumnValue("MOTHERS_FIRST_NAME"));
    Assert.assertEquals("MA", row.getColumnValue("HAITICORE.ADDRESS.STATEPROVINCE"));
    Assert.assertEquals("Boston", row.getColumnValue("HAITICORE.ADDRESS.CITYVILLAGE"));
    Assert.assertEquals("JP", row.getColumnValue("HAITICORE.ADDRESS.NEIGHBORHOODCELL"));
    Assert.assertEquals("Pondside", row.getColumnValue("HAITICORE.ADDRESS.ADDRESS1"));
    Assert.assertNull(row.getColumnValue("HAITICORE.ADDRESS.ADDRESS2"));
    Assert.assertEquals("X3XK71", row.getColumnValue("EMR_ID"));
    Assert.assertEquals(DateUtil.getDateTime(2015, 4, 15), row.getColumnValue("REGISTRATION_DATE"));
    Assert.assertEquals(MirebalaisLocations.CLINIC_REGISTRATION.name(), row.getColumnValue("REGISTRATION_LOCATION"));
    Assert.assertEquals("Married", row.getColumnValue("CIVIL_STATUS"));
    Assert.assertEquals("true", row.getColumnValue("REGISTRATION_RETROSPECTIVE"));
    Assert.assertEquals("true", row.getColumnValue("BIOMETRICS_COLLECTED"));
}
Also used : SimpleDataSet(org.openmrs.module.reporting.dataset.SimpleDataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DataSetDefinition(org.openmrs.module.reporting.dataset.definition.DataSetDefinition) DataSetRow(org.openmrs.module.reporting.dataset.DataSetRow) Test(org.junit.Test)

Example 3 with DataSetRow

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

the class VitalsDataSetManagerTest method testDataSet.

@Test
public void testDataSet() throws Exception {
    DataSetDefinition dsd = vitalsDataSetManager.constructDataSet();
    EvaluationContext context = new EvaluationContext();
    context.addParameterValue("startDate", DateUtil.getDateTime(2015, 1, 1));
    Calendar c = Calendar.getInstance();
    context.addParameterValue("endDate", DateUtil.getDateTime(c.get(Calendar.YEAR) + 1, 12, 31));
    SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
    DataSetRow row = dataSet.getRows().get(0);
    Assert.assertEquals(1, dataSet.getRows().size());
    Assert.assertEquals(24, dataSet.getMetaData().getColumnCount());
    Assert.assertEquals(visit.getId(), row.getColumnValue("VITALS_VISIT"));
    Assert.assertEquals(DateUtil.getDateTime(1977, 11, 23), row.getColumnValue("BIRTHDATE"));
    Assert.assertEquals(false, row.getColumnValue("BIRTHDATE_ESTIMATED"));
    // Assert.assertEquals(37.4, row.getColumnValue("AGE_AT_VITALS"));  // we are testing real-time in this case, so ignore this parameter here
    Assert.assertEquals("M", row.getColumnValue("GENDER"));
    Assert.assertEquals(45.4, row.getColumnValue("WEIGHT_KG"));
    Assert.assertEquals(152.4, row.getColumnValue("HEIGHT_CM"));
    Assert.assertEquals(19.5, row.getColumnValue("BMI"));
    Assert.assertEquals(65.0, row.getColumnValue("MUAC"));
    Assert.assertEquals(35.5, row.getColumnValue("TEMP_C"));
    Assert.assertEquals(120.0, row.getColumnValue("HEART_RATE"));
    Assert.assertEquals(80.0, row.getColumnValue("RESP_RATE"));
    Assert.assertEquals(90.0, row.getColumnValue("SYS_BP"));
    Assert.assertEquals(110.0, row.getColumnValue("DIA_BP"));
    Assert.assertEquals(95.0, row.getColumnValue("O2_SAT"));
    Assert.assertEquals("headache", row.getColumnValue("CHIEF_COMPLAINT"));
    Assert.assertEquals("false", row.getColumnValue("VITALS_RETROSPECTIVE"));
    Assert.assertEquals("true", row.getColumnValue("BIOMETRICS_COLLECTED"));
}
Also used : Calendar(java.util.Calendar) SimpleDataSet(org.openmrs.module.reporting.dataset.SimpleDataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DataSetDefinition(org.openmrs.module.reporting.dataset.definition.DataSetDefinition) DataSetRow(org.openmrs.module.reporting.dataset.DataSetRow) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 DataSetRow (org.openmrs.module.reporting.dataset.DataSetRow)3 SimpleDataSet (org.openmrs.module.reporting.dataset.SimpleDataSet)3 DataSetDefinition (org.openmrs.module.reporting.dataset.definition.DataSetDefinition)3 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)3 Calendar (java.util.Calendar)1