use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class PersonAuditInfoCohortDefinitionEvaluatorTest method testEvaluateIncludingVoided.
@Test
public void testEvaluateIncludingVoided() throws Exception {
PersonAuditInfoCohortDefinition cd = new PersonAuditInfoCohortDefinition();
cd.setIncludeVoided(true);
EvaluatedCohort actual = evaluator.evaluate((CohortDefinition) cd, new EvaluationContext());
assertThat(actual, hasExactlyIds(2, 6, 7, 8, 432, 999));
}
use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class PersonAuditInfoCohortDefinitionEvaluatorTest method testEvaluateByChangedDetails.
@Test
public void testEvaluateByChangedDetails() throws Exception {
PersonAuditInfoCohortDefinition cd = new PersonAuditInfoCohortDefinition();
cd.setChangedOnOrAfter(DateUtil.parseDate("2008-08-18 12:25", "yyyy-MM-dd HH:mm"));
cd.setChangedOnOrBefore(DateUtil.parseDate("2008-08-18 12:26", "yyyy-MM-dd HH:mm"));
EvaluatedCohort actual = evaluator.evaluate((CohortDefinition) cd, new EvaluationContext());
assertThat(actual, hasExactlyIds(6, 7));
}
use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class PersonAuditInfoCohortDefinitionEvaluatorTest method testEvaluateByCreationDetails.
@Test
public void testEvaluateByCreationDetails() throws Exception {
PersonAuditInfoCohortDefinition cd = new PersonAuditInfoCohortDefinition();
cd.setCreatedOnOrAfter(DateUtil.parseDate("2005-09-22", "yyyy-MM-dd"));
cd.setCreatedOnOrBefore(DateUtil.parseDate("2005-09-22", "yyyy-MM-dd"));
cd.setCreatedByUsers(Arrays.asList(userService.getUser(1)));
EvaluatedCohort actual = evaluator.evaluate((CohortDefinition) cd, new EvaluationContext());
assertThat(actual, hasExactlyIds(2));
}
use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class PersonAuditInfoCohortDefinitionEvaluatorTest method testEvaluateByVoidedDetails.
@Test
public void testEvaluateByVoidedDetails() throws Exception {
Date today = DateUtil.getStartOfDay(new Date());
// in standardTestDataset.xml patient 999 is voided, but has no dateVoided. Fix this
Patient voidedPatient = patientService.getPatient(999);
voidedPatient.addName(new PersonName("A", "Non-voided", "Name"));
patientService.voidPatient(voidedPatient, "testing");
PersonAuditInfoCohortDefinition cd = new PersonAuditInfoCohortDefinition();
cd.setIncludeVoided(true);
cd.setVoidedOnOrAfter(today);
cd.setVoidedOnOrBefore(today);
EvaluatedCohort actual = evaluator.evaluate((CohortDefinition) cd, new EvaluationContext());
assertThat(actual, hasExactlyIds(999));
}
use of org.openmrs.module.reporting.evaluation.EvaluationContext 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"));
}
Aggregations