Search in sources :

Example 1 with PersonAuditInfoCohortDefinition

use of org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition in project openmrs-module-pihcore by PIH.

the class PersonAuditInfoCohortDefinitionEvaluatorTest method testEvaluateWithNoParameters.

@Test
public void testEvaluateWithNoParameters() throws Exception {
    PersonAuditInfoCohortDefinition cd = new PersonAuditInfoCohortDefinition();
    EvaluatedCohort actual = evaluator.evaluate((CohortDefinition) cd, new EvaluationContext());
    assertThat(actual, hasExactlyIds(2, 6, 7, 8));
}
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 2 with PersonAuditInfoCohortDefinition

use of org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition 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 3 with PersonAuditInfoCohortDefinition

use of org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition 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 4 with PersonAuditInfoCohortDefinition

use of org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition 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 5 with PersonAuditInfoCohortDefinition

use of org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition 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)

Aggregations

PersonAuditInfoCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition)6 EvaluatedCohort (org.openmrs.module.reporting.cohort.EvaluatedCohort)6 Test (org.junit.Test)5 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)5 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)5 Date (java.util.Date)1 List (java.util.List)1 Criteria (org.hibernate.Criteria)1 Cohort (org.openmrs.Cohort)1 Patient (org.openmrs.Patient)1 PersonName (org.openmrs.PersonName)1