Search in sources :

Example 1 with EncounterBuilder

use of org.openmrs.contrib.testdata.builder.EncounterBuilder in project openmrs-module-pihcore by PIH.

the class EncounterDataSetManagerTest method createCheckInEncounter.

protected Encounter createCheckInEncounter(Patient p) {
    EncounterBuilder eb = data.encounter();
    eb.patient(p);
    eb.encounterDatetime(DateUtil.getDateTime(2015, 4, 15));
    eb.location(locationService.getLocation("Klinik Ekstèn"));
    eb.encounterType(getCheckInEncounterType());
    eb.obs("REASON FOR VISIT", "PIH", Metadata.getConcept("PIH:MALNUTRITION PROGRAM"));
    return eb.save();
}
Also used : EncounterBuilder(org.openmrs.contrib.testdata.builder.EncounterBuilder)

Example 2 with EncounterBuilder

use of org.openmrs.contrib.testdata.builder.EncounterBuilder in project openmrs-module-pihcore by PIH.

the class ObsDataSetManagerTest method createConsultEncounter.

protected Encounter createConsultEncounter(Patient p) {
    EncounterBuilder eb = data.encounter();
    eb.patient(p);
    eb.encounterDatetime(DateUtil.getDateTime(2015, 4, 15));
    eb.location(locationService.getLocation("Klinik Ekstèn"));
    eb.encounterType(getConsultationEncounterType());
    eb.obs("DIAGNOSIS", "PIH", Metadata.getConcept("PIH:ASTHMA"));
    return eb.save();
}
Also used : EncounterBuilder(org.openmrs.contrib.testdata.builder.EncounterBuilder)

Example 3 with EncounterBuilder

use of org.openmrs.contrib.testdata.builder.EncounterBuilder in project openmrs-module-pihcore by PIH.

the class BmiEncounterDataEvaluatorTest method shouldReturnNullIfNoHeight.

@Test
public void shouldReturnNullIfNoHeight() throws Exception {
    EncounterBuilder eb = data.encounter();
    eb.patient(createPatient());
    eb.encounterDatetime(DateUtil.getDateTime(2015, 4, 15));
    eb.location(locationService.getLocation("CDI Klinik Ekstèn Jeneral"));
    eb.encounterType(getVitalsEncounterType());
    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);
    assertNull(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) BmiEncounterDataDefinition(org.openmrs.module.pihcore.reporting.encounter.definition.BmiEncounterDataDefinition) Test(org.junit.Test) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest)

Example 4 with EncounterBuilder

use of org.openmrs.contrib.testdata.builder.EncounterBuilder in project openmrs-module-pihcore by PIH.

the class BmiEncounterDataEvaluatorTest method shouldReturnNullIfNoWeight.

@Test
public void shouldReturnNullIfNoWeight() throws Exception {
    EncounterBuilder eb = data.encounter();
    eb.patient(createPatient());
    eb.encounterDatetime(DateUtil.getDateTime(2015, 4, 15));
    eb.location(locationService.getLocation("CDI Klinik Ekstèn Jeneral"));
    eb.encounterType(getVitalsEncounterType());
    eb.obs(Metadata.getConcept("PIH:WEIGHT (KG)"), 45.4);
    Encounter enc = eb.save();
    EncounterEvaluationContext context = new EncounterEvaluationContext();
    context.setBaseEncounters(new EncounterIdSet(enc.getEncounterId()));
    EvaluatedEncounterData res = encounterDataService.evaluate(new BmiEncounterDataDefinition(), context);
    assertNull(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) BmiEncounterDataDefinition(org.openmrs.module.pihcore.reporting.encounter.definition.BmiEncounterDataDefinition) Test(org.junit.Test) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest)

Example 5 with EncounterBuilder

use of org.openmrs.contrib.testdata.builder.EncounterBuilder in project openmrs-module-pihcore by PIH.

the class RetrospectiveEncounterDataEvaluatorTest method shouldFindEncounterToBeRetrospective.

@Test
public void shouldFindEncounterToBeRetrospective() throws Exception {
    EncounterBuilder eb = data.encounter();
    eb.patient(createPatient());
    eb.encounterDatetime(DateUtil.getDateTime(2015, 4, 15));
    eb.location(locationService.getLocation("CDI Klinik Ekstèn Jeneral"));
    eb.encounterType(encounterService.getAllEncounterTypes().get(0));
    Encounter enc = eb.save();
    EncounterEvaluationContext context = new EncounterEvaluationContext();
    context.setBaseEncounters(new EncounterIdSet(enc.getEncounterId()));
    EvaluatedEncounterData res = encounterDataService.evaluate(new RetrospectiveEncounterDataDefinition(), context);
    assertTrue((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) Test(org.junit.Test) BaseReportTest(org.openmrs.module.pihcore.reporting.BaseReportTest)

Aggregations

EncounterBuilder (org.openmrs.contrib.testdata.builder.EncounterBuilder)10 Test (org.junit.Test)6 Encounter (org.openmrs.Encounter)6 BaseReportTest (org.openmrs.module.pihcore.reporting.BaseReportTest)6 EvaluatedEncounterData (org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData)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 Date (java.util.Date)2 RetrospectiveEncounterDataDefinition (org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition)2 Concept (org.openmrs.Concept)1 PatientIdSet (org.openmrs.module.reporting.cohort.PatientIdSet)1 DataSetRow (org.openmrs.module.reporting.dataset.DataSetRow)1 SimpleDataSet (org.openmrs.module.reporting.dataset.SimpleDataSet)1 EncounterDataSetDefinition (org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition)1 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)1