Search in sources :

Example 11 with EvaluationContext

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));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) PersonAuditInfoCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 12 with EvaluationContext

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));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) PersonAuditInfoCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 13 with EvaluationContext

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));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) PersonAuditInfoCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 14 with EvaluationContext

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));
}
Also used : PersonName(org.openmrs.PersonName) Patient(org.openmrs.Patient) EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) PersonAuditInfoCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 15 with EvaluationContext

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"));
}
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)

Aggregations

EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)25 Test (org.junit.Test)22 EvaluatedCohort (org.openmrs.module.reporting.cohort.EvaluatedCohort)18 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12 Date (java.util.Date)7 DiagnosisCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition)7 BaseInpatientReportTest (org.openmrs.module.pihcore.reporting.BaseInpatientReportTest)6 Location (org.openmrs.Location)5 PersonAuditInfoCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition)5 SimpleDataSet (org.openmrs.module.reporting.dataset.SimpleDataSet)4 DataSetDefinition (org.openmrs.module.reporting.dataset.definition.DataSetDefinition)4 DataSetRow (org.openmrs.module.reporting.dataset.DataSetRow)3 InpatientLocationCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition)2 InpatientTransferCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition)2 PatientDataDefinition (org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition)2 DataSet (org.openmrs.module.reporting.dataset.DataSet)2 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)2 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1