Search in sources :

Example 1 with PatientIdSet

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

Test (org.junit.Test)1 Concept (org.openmrs.Concept)1 Encounter (org.openmrs.Encounter)1 EncounterBuilder (org.openmrs.contrib.testdata.builder.EncounterBuilder)1 BaseReportTest (org.openmrs.module.pihcore.reporting.BaseReportTest)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