Search in sources :

Example 6 with EvaluationContext

use of org.openmrs.module.reporting.evaluation.EvaluationContext 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) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 7 with EvaluationContext

use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.

the class InpatientLocationCohortDefinitionEvaluatorTest method testEvaluate.

@Test
public void testEvaluate() throws Exception {
    InpatientLocationCohortDefinition definition = new InpatientLocationCohortDefinition();
    definition.addParameter(new Parameter("ward", "Ward", Location.class));
    definition.addParameter(new Parameter("effectiveDate", "Date", Date.class));
    Location womensInternalMedicine = Metadata.lookup(MirebalaisLocations.WOMENS_INTERNAL_MEDICINE);
    EvaluationContext ec = new EvaluationContext();
    ec.addParameterValue("ward", womensInternalMedicine);
    ec.addParameterValue("effectiveDate", DateUtil.parseDate("2013-10-03", "yyyy-MM-dd"));
    EvaluatedCohort result = cohortDefinitionService.evaluate(definition, ec);
    assertThat(result, isCohortWithExactlyIds(patient1.getId(), patient5.getId()));
}
Also used : InpatientLocationCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) Location(org.openmrs.Location) BaseInpatientReportTest(org.openmrs.module.pihcore.reporting.BaseInpatientReportTest) Test(org.junit.Test)

Example 8 with EvaluationContext

use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.

the class InpatientLocationCohortDefinitionEvaluatorTest method testThatTransferOutsAreNotIncluded.

@Test
public void testThatTransferOutsAreNotIncluded() throws Exception {
    InpatientLocationCohortDefinition definition = new InpatientLocationCohortDefinition();
    definition.addParameter(new Parameter("ward", "Ward", Location.class));
    definition.addParameter(new Parameter("effectiveDate", "Date", Date.class));
    Location womensInternalMedicine = Metadata.lookup(MirebalaisLocations.WOMENS_INTERNAL_MEDICINE);
    EvaluationContext ec = new EvaluationContext();
    ec.addParameterValue("ward", womensInternalMedicine);
    Date endOfDay = DateUtil.parseDate("2013-10-03 23:59:59", "yyyy-MM-dd HH:mm:ss");
    ec.addParameterValue("effectiveDate", endOfDay);
    EvaluatedCohort result = cohortDefinitionService.evaluate(definition, ec);
    assertThat(result, isCohortWithExactlyIds(patient1.getId()));
}
Also used : InpatientLocationCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) Location(org.openmrs.Location) BaseInpatientReportTest(org.openmrs.module.pihcore.reporting.BaseInpatientReportTest) Test(org.junit.Test)

Example 9 with EvaluationContext

use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.

the class InpatientTransferCohortDefinitionEvaluatorTest method testEvaluateTransferIn.

@Test
public void testEvaluateTransferIn() throws Exception {
    Location surgicalWard = Metadata.lookup(MirebalaisLocations.SURGICAL_WARD);
    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 EvaluationContext

use of org.openmrs.module.reporting.evaluation.EvaluationContext 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)

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