Search in sources :

Example 11 with EvaluatedCohort

use of org.openmrs.module.reporting.cohort.EvaluatedCohort 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) Test(org.junit.Test) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest)

Example 12 with EvaluatedCohort

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

the class PersonAuditInfoCohortDefinitionEvaluatorTest method testEvaluateByChangedDetails.

// ignoring this pending resolution of: https://issues.openmrs.org/browse/TRUNK-5691
@Test
@Ignore
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) Ignore(org.junit.Ignore) Test(org.junit.Test) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest)

Example 13 with EvaluatedCohort

use of org.openmrs.module.reporting.cohort.EvaluatedCohort 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) Test(org.junit.Test) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest)

Example 14 with EvaluatedCohort

use of org.openmrs.module.reporting.cohort.EvaluatedCohort 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) Test(org.junit.Test) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest)

Example 15 with EvaluatedCohort

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

the class AdmissionSoonAfterExitCohortDefinitionEvaluatorTest method testEvaluate.

@Test
public void testEvaluate() throws Exception {
    Date startDate = DateUtil.parseDate("2013-10-03 00:00:00", "yyyy-MM-dd HH:mm:ss");
    Date endDate = DateUtil.parseDate("2013-10-03 23:59:59", "yyyy-MM-dd HH:mm:ss");
    AdmissionSoonAfterExitCohortDefinition definition = new AdmissionSoonAfterExitCohortDefinition();
    definition.setOnOrAfter(startDate);
    definition.setOnOrBefore(endDate);
    EvaluatedCohort result = cohortDefinitionService.evaluate(definition, new EvaluationContext());
    assertThat(result, isCohortWithExactlyIds(patient3.getId()));
}
Also used : AdmissionSoonAfterExitCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.AdmissionSoonAfterExitCohortDefinition) EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) BaseInpatientReportTest(org.openmrs.module.pihcore.reporting.BaseInpatientReportTest) Test(org.junit.Test)

Aggregations

EvaluatedCohort (org.openmrs.module.reporting.cohort.EvaluatedCohort)26 Test (org.junit.Test)18 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)18 PihCoreContextSensitiveTest (org.openmrs.module.pihcore.PihCoreContextSensitiveTest)12 Date (java.util.Date)8 Cohort (org.openmrs.Cohort)8 Location (org.openmrs.Location)8 DiagnosisCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition)8 List (java.util.List)7 BaseInpatientReportTest (org.openmrs.module.pihcore.reporting.BaseInpatientReportTest)6 PersonAuditInfoCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.PersonAuditInfoCohortDefinition)6 SQLQuery (org.hibernate.SQLQuery)5 InpatientLocationCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition)3 InpatientTransferCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition)3 Criteria (org.hibernate.Criteria)2 Concept (org.openmrs.Concept)2 EncounterType (org.openmrs.EncounterType)2 AdmissionSoonAfterExitCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.AdmissionSoonAfterExitCohortDefinition)2 LastDispositionBeforeExitCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.LastDispositionBeforeExitCohortDefinition)2 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)2