Search in sources :

Example 6 with EncounterBuilder

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

the class VitalsDataSetManagerTest method createVitalsEncounter.

private Encounter createVitalsEncounter(Patient p) {
    EncounterBuilder eb = data.encounter();
    eb.patient(p);
    eb.encounterDatetime(new Date());
    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);
    eb.obs(Metadata.getConcept("PIH:MIDDLE UPPER ARM CIRCUMFERENCE (MM)"), 65);
    eb.obs(Metadata.getConcept("PIH:TEMPERATURE (C)"), 35.5);
    eb.obs(Metadata.getConcept("PIH:PULSE"), 120);
    eb.obs(Metadata.getConcept("PIH:RESPIRATORY RATE"), 80);
    eb.obs(Metadata.getConcept("PIH:SYSTOLIC BLOOD PRESSURE"), 90);
    eb.obs(Metadata.getConcept("PIH:DIASTOLIC BLOOD PRESSURE"), 110);
    eb.obs(Metadata.getConcept("PIH:BLOOD OXYGEN SATURATION"), 95);
    eb.obs(Metadata.getConcept("CIEL:160531"), "headache");
    return eb.save();
}
Also used : EncounterBuilder(org.openmrs.contrib.testdata.builder.EncounterBuilder) Date(java.util.Date)

Example 7 with EncounterBuilder

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

the class EncounterDataSetManagerTest method createRegistrationEncounter.

protected Encounter createRegistrationEncounter(Patient p) {
    EncounterBuilder eb = data.encounter();
    eb.patient(p);
    eb.encounterDatetime(DateUtil.getDateTime(2015, 4, 15));
    eb.location(locationService.getLocation("Biwo Resepsyon"));
    eb.encounterType(getRegistrationEncounterType());
    // TODO: Add More Obs to test
    eb.obs(Metadata.getConcept(SocioEconomicConcepts.Concepts.CIVIL_STATUS), Metadata.getConcept(SocioEconomicConcepts.Concepts.MARRIED));
    eb.obs(Metadata.getConcept(SocioEconomicConcepts.Concepts.BIRTHPLACE), "Wichita");
    return eb.save();
}
Also used : EncounterBuilder(org.openmrs.contrib.testdata.builder.EncounterBuilder)

Example 8 with EncounterBuilder

use of org.openmrs.contrib.testdata.builder.EncounterBuilder 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(locationService.getLocation("CDI Klinik Ekstèn Jeneral"));
    eb.encounterType(getVitalsEncounterType());
    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 9 with EncounterBuilder

use of org.openmrs.contrib.testdata.builder.EncounterBuilder 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(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);
    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)

Example 10 with EncounterBuilder

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

the class MultipleObsForEncounterDataEvaluatorTest method shouldCalculateSymptomPresentAndAbsent.

@Test
public void shouldCalculateSymptomPresentAndAbsent() 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());
    // We'll simulate "symptom present" by using the diagnosis concept, "symptom absent" with "reason for visit" concept
    Concept diagnosisConcept = Metadata.getConcept("PIH:DIAGNOSIS");
    Concept reasonForVisitConcept = Metadata.getConcept("Reason for HUM visit");
    Concept malariaConcept = Metadata.getConcept("PIH:MALARIA");
    Concept dengueConcept = Metadata.getConcept("PIH:Dengue");
    Concept typhoidConcept = Metadata.getConcept("PIH:TYPHOID FEVER");
    Concept tbConcept = Metadata.getConcept("PIH:TUBERCULOSIS");
    eb.obs(diagnosisConcept, malariaConcept);
    eb.obs(diagnosisConcept, dengueConcept);
    eb.obs(reasonForVisitConcept, typhoidConcept);
    Encounter enc = eb.save();
    EvaluationContext context = new EvaluationContext();
    context.setBaseCohort(new PatientIdSet(enc.getPatient().getPatientId()));
    EncounterDataSetDefinition dsd = new EncounterDataSetDefinition();
    addSymptomPresentOrAbsentColumn(dsd, "malaria", "PIH:DIAGNOSIS", "PIH:Reason for HUM Visit", "PIH:MALARIA", "Diagnosis", "Reason");
    addSymptomPresentOrAbsentColumn(dsd, "dengue", "PIH:DIAGNOSIS", "PIH:Reason for HUM Visit", "PIH:Dengue", "Diagnosis", "Reason");
    addSymptomPresentOrAbsentColumn(dsd, "typhoid", "PIH:DIAGNOSIS", "PIH:Reason for HUM Visit", "PIH:TYPHOID FEVER", "Diagnosis", "Reason");
    addSymptomPresentOrAbsentColumn(dsd, "tb", "PIH:DIAGNOSIS", "PIH:Reason for HUM Visit", "PIH:TUBERCULOSIS", "Diagnosis", "Reason");
    SimpleDataSet ds = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
    DataSetRow row = ds.getRows().get(0);
    assertThat(row.getColumnValue("malaria"), is("Diagnosis"));
    assertThat(row.getColumnValue("dengue"), is("Diagnosis"));
    assertThat(row.getColumnValue("typhoid"), is("Reason"));
    assertNull(row.getColumnValue("tb"));
}
Also used : Concept(org.openmrs.Concept) EncounterBuilder(org.openmrs.contrib.testdata.builder.EncounterBuilder) Encounter(org.openmrs.Encounter) SimpleDataSet(org.openmrs.module.reporting.dataset.SimpleDataSet) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) EncounterDataSetDefinition(org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition) DataSetRow(org.openmrs.module.reporting.dataset.DataSetRow) PatientIdSet(org.openmrs.module.reporting.cohort.PatientIdSet) 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