Search in sources :

Example 1 with RetrospectiveEncounterDataDefinition

use of org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition 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)

Example 2 with RetrospectiveEncounterDataDefinition

use of org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition in project openmrs-module-pihcore by PIH.

the class BaseEncounterDataSetManager method addCoreEncounterColumns.

/**
 * Add columns that describe the common elements of encounters
 */
protected void addCoreEncounterColumns(EncounterDataSetDefinition dsd) {
    addColumn(dsd, getEncounterColumnPrefix() + "_date", builtInEncounterData.getEncounterDatetime());
    addColumn(dsd, getEncounterColumnPrefix() + "_location", builtInEncounterData.getLocationName());
    addColumn(dsd, getEncounterColumnPrefix() + "_provider", pihEncounterData.getEncounterProvider());
    addColumn(dsd, getEncounterColumnPrefix() + "_retrospective", new RetrospectiveEncounterDataDefinition(), new BooleanConverter());
}
Also used : RetrospectiveEncounterDataDefinition(org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition) BooleanConverter(org.openmrs.module.reporting.data.converter.BooleanConverter)

Example 3 with RetrospectiveEncounterDataDefinition

use of org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition 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)

Aggregations

RetrospectiveEncounterDataDefinition (org.openmrs.module.pihcore.reporting.encounter.definition.RetrospectiveEncounterDataDefinition)3 Test (org.junit.Test)2 Encounter (org.openmrs.Encounter)2 EncounterBuilder (org.openmrs.contrib.testdata.builder.EncounterBuilder)2 BaseReportTest (org.openmrs.module.pihcore.reporting.BaseReportTest)2 EvaluatedEncounterData (org.openmrs.module.reporting.data.encounter.EvaluatedEncounterData)2 EncounterEvaluationContext (org.openmrs.module.reporting.evaluation.context.EncounterEvaluationContext)2 EncounterIdSet (org.openmrs.module.reporting.query.encounter.EncounterIdSet)2 Date (java.util.Date)1 BooleanConverter (org.openmrs.module.reporting.data.converter.BooleanConverter)1