Search in sources :

Example 6 with EvaluatedCohort

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

the class DiagnosisCohortDefinitionEvaluatorTest method testEvaluateByOrder.

@Test
public void testEvaluateByOrder() throws Exception {
    createDiagnosisObs();
    DiagnosisCohortDefinition cd = new DiagnosisCohortDefinition();
    cd.setDiagnosisOrder(Diagnosis.Order.SECONDARY);
    EvaluatedCohort cohort = evaluator.evaluate(cd, new EvaluationContext());
    assertThat(cohort, hasExactlyIds(2));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DiagnosisCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition) Test(org.junit.Test) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest)

Example 7 with EvaluatedCohort

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

the class DiagnosisCohortDefinitionEvaluatorTest method testEvaluateSimple.

@Test
public void testEvaluateSimple() throws Exception {
    DiagnosisCohortDefinition cd = new DiagnosisCohortDefinition();
    EvaluatedCohort cohort = evaluator.evaluate(cd, new EvaluationContext());
    assertThat(cohort.size(), is(0));
    assertThat((DiagnosisCohortDefinition) cohort.getDefinition(), is(cd));
    createDiagnosisObs();
    cd = new DiagnosisCohortDefinition();
    cohort = evaluator.evaluate(cd, new EvaluationContext());
    assertThat(cohort, hasExactlyIds(2, 6, 7));
    cd.setOnOrAfter(DateUtil.parseDate("2013-01-02", "yyyy-MM-dd"));
    cd.setOnOrBefore(DateUtil.parseDate("2013-01-02", "yyyy-MM-dd"));
    cohort = evaluator.evaluate(cd, new EvaluationContext());
    assertThat(cohort, hasExactlyIds(2));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DiagnosisCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition) Test(org.junit.Test) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest)

Example 8 with EvaluatedCohort

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

the class DiagnosisCohortDefinitionEvaluatorTest method testEvaluateByCertainty.

@Test
public void testEvaluateByCertainty() throws Exception {
    createDiagnosisObs();
    DiagnosisCohortDefinition cd = new DiagnosisCohortDefinition();
    cd.setCertainty(Diagnosis.Certainty.CONFIRMED);
    cd.setCodedDiagnoses(Arrays.asList(conceptService.getConcept(9)));
    EvaluatedCohort cohort = evaluator.evaluate(cd, new EvaluationContext());
    assertThat(cohort, hasExactlyIds(6));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) DiagnosisCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition) Test(org.junit.Test) PihCoreContextSensitiveTest(org.openmrs.module.pihcore.PihCoreContextSensitiveTest)

Example 9 with EvaluatedCohort

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

the class InpatientTransferCohortDefinitionEvaluatorTest method testEvaluateTransferIn.

@Test
public void testEvaluateTransferIn() throws Exception {
    Location surgicalWard = locationService.getLocation("Sal Aprè Operasyon");
    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");
    InpatientTransferCohortDefinition definition = new InpatientTransferCohortDefinition();
    definition.setOnOrAfter(startDate);
    definition.setOnOrBefore(endDate);
    definition.setInToWard(surgicalWard);
    EvaluatedCohort result = cohortDefinitionService.evaluate(definition, new EvaluationContext());
    assertThat(result, isCohortWithExactlyIds(patient5.getId()));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) InpatientTransferCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition) Location(org.openmrs.Location) BaseInpatientReportTest(org.openmrs.module.pihcore.reporting.BaseInpatientReportTest) Test(org.junit.Test)

Example 10 with EvaluatedCohort

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

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