Search in sources :

Example 6 with EvaluatedEncounterData

use of org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData in project openmrs-module-pihcore by PIH.

the class BmiEncounterDataEvaluatorTest method shouldCalculateBmi.

@Test
public void shouldCalculateBmi() throws Exception {
    EncounterBuilder eb = data.encounter();
    eb.patient(createPatient());
    eb.encounterDatetime(DateUtil.getDateTime(2015, 4, 15));
    eb.location(Metadata.lookup(MirebalaisLocations.CDI_KLINIK_EKSTEN_JENERAL));
    eb.encounterType(Metadata.lookup(EncounterTypes.VITALS));
    eb.obs(Metadata.getConcept("PIH:WEIGHT (KG)"), 45.4);
    eb.obs(Metadata.getConcept("PIH:HEIGHT (CM)"), 152.4);
    Encounter enc = eb.save();
    EncounterEvaluationContext context = new EncounterEvaluationContext();
    context.setBaseEncounters(new EncounterIdSet(enc.getEncounterId()));
    EvaluatedEncounterData res = encounterDataService.evaluate(new BmiEncounterDataDefinition(), context);
    assertThat((Double) res.getData().get(enc.getEncounterId()), is(19.5));
}
Also used : EncounterBuilder(org.openmrs.contrib.testdata.builder.EncounterBuilder) EncounterEvaluationContext(org.openmrs.module.reporting.evaluation.context.EncounterEvaluationContext) EncounterIdSet(org.openmrs.module.reporting.query.encounter.EncounterIdSet) Encounter(org.openmrs.Encounter) EvaluatedEncounterData(org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData) BmiEncounterDataDefinition(org.openmrs.module.pihcore.reporting.encounter.definition.BmiEncounterDataDefinition) Test(org.junit.Test) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest)

Example 7 with EvaluatedEncounterData

use of org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData in project openmrs-module-pihcore by PIH.

the class RetrospectiveEncounterDataEvaluatorTest method shouldFindEncounterNotToBeRetrospective.

@Test
public void shouldFindEncounterNotToBeRetrospective() throws Exception {
    EncounterBuilder eb = data.encounter();
    eb.patient(createPatient());
    eb.encounterDatetime(new Date());
    eb.location(Metadata.lookup(MirebalaisLocations.CDI_KLINIK_EKSTEN_JENERAL));
    eb.encounterType(1);
    Encounter enc = eb.save();
    EncounterEvaluationContext context = new EncounterEvaluationContext();
    context.setBaseEncounters(new EncounterIdSet(enc.getEncounterId()));
    EvaluatedEncounterData res = encounterDataService.evaluate(new RetrospectiveEncounterDataDefinition(), context);
    assertFalse((Boolean) res.getData().get(enc.getEncounterId()));
}
Also used : EncounterBuilder(org.openmrs.contrib.testdata.builder.EncounterBuilder) EncounterEvaluationContext(org.openmrs.module.reporting.evaluation.context.EncounterEvaluationContext) EncounterIdSet(org.openmrs.module.reporting.query.encounter.EncounterIdSet) Encounter(org.openmrs.Encounter) EvaluatedEncounterData(org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData) RetrospectiveEncounterDataDefinition(org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition) Date(java.util.Date) Test(org.junit.Test) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest)

Aggregations

EvaluatedEncounterData (org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData)7 Test (org.junit.Test)5 Encounter (org.openmrs.Encounter)5 EncounterBuilder (org.openmrs.contrib.testdata.builder.EncounterBuilder)5 BaseReportTest (org.openmrs.module.pihcore.reporting.BaseReportTest)5 EncounterEvaluationContext (org.openmrs.module.reporting.evaluation.context.EncounterEvaluationContext)5 EncounterIdSet (org.openmrs.module.reporting.query.encounter.EncounterIdSet)5 BmiEncounterDataDefinition (org.openmrs.module.pihcore.reporting.encounter.definition.BmiEncounterDataDefinition)3 Map (java.util.Map)2 RetrospectiveEncounterDataDefinition (org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition)2 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 Obs (org.openmrs.Obs)1 ObsForEncounterDataDefinition (org.openmrs.module.reporting.data.encounter.definition.ObsForEncounterDataDefinition)1