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();
}
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();
}
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));
}
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()));
}
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"));
}
Aggregations