use of org.openmrs.module.reporting.cohort.PatientIdSet 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