Search in sources :

Example 1 with EncounterDataSetDefinition

use of org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition in project openmrs-module-pihcore by PIH.

the class BaseEncounterDataSetManager method constructDataSetDefinition.

@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File baseConfigDir) {
    EncounterDataSetDefinition dsd = new EncounterDataSetDefinition();
    dsd.addParameter(new Parameter("startDate", "mirebalaisreports.parameter.startDate", Date.class));
    dsd.addParameter(new Parameter("endDate", "mirebalaisreports.parameter.endDate", Date.class));
    // Rows defined as patients who had an encounter of the configured types during the given period
    dsd.addRowFilter(Mapped.mapStraightThrough(new PatientEncounterQuery(cohortQueries.getExcludeTestPatients())));
    dsd.addRowFilter(Mapped.mapStraightThrough(encounterQueries.getEncountersDuringPeriodAtLocation(getEncounterTypes())));
    // Define columns
    addPrimaryIdentifierColumns(dsd);
    addPatientNameColumns(dsd);
    addBirthDateAndAgeColumns(dsd);
    addGenderColumns(dsd);
    addOtherIdentifierColumns(dsd);
    addCoreEncounterColumns(dsd);
    addCoreVisitColumns(dsd);
    addAddressColumns(dsd);
    addPersonAttributeColumns(dsd);
    addObsColumns(dsd);
    addAuditColumns(dsd);
    return dsd;
}
Also used : PatientEncounterQuery(org.openmrs.module.reporting.query.encounter.definition.PatientEncounterQuery) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EncounterDataSetDefinition(org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition) Date(java.util.Date)

Example 2 with EncounterDataSetDefinition

use of org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition in project openmrs-module-pihcore by PIH.

the class HaitiEncounterDataSetManager method constructDataSetDefinition.

@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File baseConfigDir) {
    EncounterDataSetDefinition dsd = new EncounterDataSetDefinition();
    dsd.addParameter(getStartDateParameter());
    dsd.addParameter(getEndDateParameter());
    BasicEncounterQuery query = new BasicEncounterQuery();
    query.addParameter(new Parameter("onOrAfter", "On or after", Date.class));
    query.addParameter(new Parameter("onOrBefore", "On or before", Date.class));
    dsd.addRowFilter(query, "onOrAfter=${startDate},onOrBefore=${endDate}");
    dsd.addColumn("zlEmrId", patientData(pihPatientData.getPreferredZlEmrIdIdentifier()), null);
    dsd.addColumn("patientId", builtInEncounterData.getPatientId(), null);
    dsd.addColumn("age", pihEncounterData.getPatientAgeAtEncounter(), null, new AgeConverter(AgeConverter.YEARS_TO_ONE_DECIMAL_PLACE));
    dsd.addColumn("gender", patientData(builtInPatientData.getGender()), null);
    dsd.addColumn("visitId", builtInEncounterData.getEncounterVisit(), null, new PropertyConverter(Visit.class, "visitId"));
    dsd.addColumn("visitStart", builtInEncounterData.getEncounterVisit(), null, new PropertyConverter(Visit.class, "startDatetime"));
    dsd.addColumn("visitStop", builtInEncounterData.getEncounterVisit(), null, new PropertyConverter(Visit.class, "stopDatetime"));
    dsd.addColumn("encounterId", builtInEncounterData.getEncounterId(), null);
    dsd.addColumn("encounterType", builtInEncounterData.getEncounterTypeName(), null);
    // the "encounterLocation.name" converter is very inefficent
    dsd.addColumn("encounterLocation", new ConvertedEncounterDataDefinition(new EncounterLocationDataDefinition(), new PropertyConverter(String.class, "name")), null);
    dsd.addColumn("encounterDatetime", builtInEncounterData.getEncounterDatetime(), null);
    dsd.addColumn("disposition", pihEncounterData.getDisposition(), null, converterLibrary.getObsValueCodedNameConverterInLocale(Locale.FRENCH));
    dsd.addColumn("enteredBy", pihEncounterData.getCreatorName(), null);
    dsd.addColumn("allProviders", pihEncounterData.getAllProviders(), null);
    dsd.addColumn("numberOfProviders", pihEncounterData.getNumberOfProviders(), null);
    dsd.addColumn("administrativeClerk", pihEncounterData.getClerk(), null);
    dsd.addColumn("nurse", pihEncounterData.getNurse(), null);
    dsd.addColumn("consultingClinician", pihEncounterData.getConsultingClinician(), null);
    dsd.addColumn("dispenser", pihEncounterData.getDispenser(), null);
    dsd.addColumn("radiologyTech", pihEncounterData.getRadiologyTechnician(), null);
    dsd.addColumn("orderingProvider", pihEncounterData.getOrderingProvider(), null);
    dsd.addColumn("principalResultsInterpreter", pihEncounterData.getPrincipalResultsInterpreter(), null);
    dsd.addColumn("attendingSurgeon", pihEncounterData.getAttendingSurgeonName(), null);
    dsd.addColumn("assistingSurgeon", pihEncounterData.getAssistingSurgeon(), null);
    dsd.addColumn("anesthesiologist", pihEncounterData.getAnesthesiologist(), null);
    dsd.addColumn("birthdate", patientData(builtInPatientData.getBirthdate()), null);
    dsd.addColumn("birthdate_estimated", patientData(builtInPatientData.getBirthdateEstimated()), null);
    dsd.addColumn("admissionStatus", pihEncounterData.getAdmissionStatus(), null);
    dsd.addColumn("requestedAdmissionLocation", pihEncounterData.getRequestedAdmissionLocationName(), null);
    dsd.addColumn("requestedTransferLocation", pihEncounterData.getRequestedTransferLocationName(), null);
    dsd.addColumn("department", patientData(pihPatientData.getPreferredAddressDepartment()), "");
    dsd.addColumn("commune", patientData(pihPatientData.getPreferredAddressCommune()), "");
    dsd.addColumn("section", patientData(pihPatientData.getPreferredAddressSection()), "");
    dsd.addColumn("locality", patientData(pihPatientData.getPreferredAddressLocality()), "");
    dsd.addColumn("street_landmark", patientData(pihPatientData.getPreferredAddressStreetLandmark()), "");
    return dsd;
}
Also used : EncounterLocationDataDefinition(org.openmrs.module.reporting.data.encounter.definition.EncounterLocationDataDefinition) AgeConverter(org.openmrs.module.reporting.data.converter.AgeConverter) ConvertedEncounterDataDefinition(org.openmrs.module.reporting.data.encounter.definition.ConvertedEncounterDataDefinition) Visit(org.openmrs.Visit) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EncounterDataSetDefinition(org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition) Date(java.util.Date) BasicEncounterQuery(org.openmrs.module.reporting.query.encounter.definition.BasicEncounterQuery)

Example 3 with EncounterDataSetDefinition

use of org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition in project openmrs-module-pihcore by PIH.

the class BaseEncounterDataSetManager method constructDataSet.

public DataSetDefinition constructDataSet() {
    EncounterDataSetDefinition dsd = new EncounterDataSetDefinition();
    dsd.addParameter(new Parameter("startDate", "mirebalaisreports.parameter.startDate", Date.class));
    dsd.addParameter(new Parameter("endDate", "mirebalaisreports.parameter.endDate", Date.class));
    // Rows defined as patients who had an encounter of the configured types during the given period
    dsd.addRowFilter(Mapped.mapStraightThrough(new PatientEncounterQuery(cohortQueries.getExcludeTestPatients())));
    dsd.addRowFilter(Mapped.mapStraightThrough(encounterQueries.getEncountersDuringPeriodAtLocation(getEncounterTypes())));
    // Define columns
    addPrimaryIdentifierColumns(dsd);
    addPatientNameColumns(dsd);
    addBirthDateAndAgeColumns(dsd);
    addGenderColumns(dsd);
    addOtherIdentifierColumns(dsd);
    addCoreEncounterColumns(dsd);
    addCoreVisitColumns(dsd);
    addAddressColumns(dsd);
    addPersonAttributeColumns(dsd);
    addObsColumns(dsd);
    addAuditColumns(dsd);
    return dsd;
}
Also used : PatientEncounterQuery(org.openmrs.module.reporting.query.encounter.definition.PatientEncounterQuery) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EncounterDataSetDefinition(org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition) Date(java.util.Date)

Example 4 with EncounterDataSetDefinition

use of org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition 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

EncounterDataSetDefinition (org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition)4 Date (java.util.Date)3 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)3 PatientEncounterQuery (org.openmrs.module.reporting.query.encounter.definition.PatientEncounterQuery)2 Test (org.junit.Test)1 Concept (org.openmrs.Concept)1 Encounter (org.openmrs.Encounter)1 Visit (org.openmrs.Visit)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 AgeConverter (org.openmrs.module.reporting.data.converter.AgeConverter)1 PropertyConverter (org.openmrs.module.reporting.data.converter.PropertyConverter)1 ConvertedEncounterDataDefinition (org.openmrs.module.reporting.data.encounter.definition.ConvertedEncounterDataDefinition)1 EncounterLocationDataDefinition (org.openmrs.module.reporting.data.encounter.definition.EncounterLocationDataDefinition)1 DataSetRow (org.openmrs.module.reporting.dataset.DataSetRow)1 SimpleDataSet (org.openmrs.module.reporting.dataset.SimpleDataSet)1 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)1 BasicEncounterQuery (org.openmrs.module.reporting.query.encounter.definition.BasicEncounterQuery)1