Search in sources :

Example 1 with EncounterLocationDataDefinition

use of org.openmrs.module.reporting.data.encounter.definition.EncounterLocationDataDefinition 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 2 with EncounterLocationDataDefinition

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

the class DispensingDataSetManager method constructDataSetDefinition.

@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File baseConfigDir) {
    ObsDataSetDefinition dsd = new ObsDataSetDefinition();
    dsd.addParameter(getStartDateParameter());
    dsd.addParameter(getEndDateParameter());
    BasicObsQuery query = new BasicObsQuery();
    query.addParameter(new Parameter("onOrAfter", "On or after", Date.class));
    query.addParameter(new Parameter("onOrBefore", "On or before", Date.class));
    query.addConcept(dispensingProperties.getDispensingConstructConcept());
    dsd.addRowFilter(query, "onOrAfter=${startDate},onOrBefore=${endDate}");
    dsd.addColumn("visitId", pihObsData.getVisitId(), null);
    dsd.addColumn("encounterId", pihObsData.getEncounterId(), null);
    dsd.addColumn("medication", constructGroupMemberObsDataDefinition(dispensingProperties.getMedicationConcept()), "", new PropertyConverter(Drug.class, "valueDrug"), new ObjectFormatter());
    dsd.addColumn("dosage", constructGroupMemberObsDataDefinition(dispensingProperties.getDosageConcept()), "", new ObjectFormatter());
    dsd.addColumn("dosageUnits", constructGroupMemberObsDataDefinition(dispensingProperties.getDosageUnitsConcept()), "", new ObjectFormatter());
    dsd.addColumn("frequency", constructGroupMemberObsDataDefinition(dispensingProperties.getMedicationFrequencyConcept()), "", new ObjectFormatter());
    dsd.addColumn("duration", constructGroupMemberObsDataDefinition(dispensingProperties.getMedicationDurationConcept()), "", new ObjectFormatter());
    dsd.addColumn("durationUnits", constructGroupMemberObsDataDefinition(dispensingProperties.getMedicationDurationUnitsConcept()), "", new ObjectFormatter());
    dsd.addColumn("amount", constructGroupMemberObsDataDefinition(dispensingProperties.getDispensedAmountConcept()), "", new ObjectFormatter());
    dsd.addColumn("instructions", constructGroupMemberObsDataDefinition(dispensingProperties.getAdministrationInstructions()), "", new ObjectFormatter());
    dsd.addColumn("patientIdentifier", constructPatientIdentifierDataDefinition(emrApiProperties.getPrimaryIdentifierType()), "", new ObjectFormatter());
    dsd.addColumn("dispensedLocation", new EncounterLocationDataDefinition(), "", new ObjectFormatter());
    dsd.addColumn("dispensedDatetime", new EncounterDatetimeDataDefinition(), "", new DateConverter("dd MMM yyyy hh:mm aa"));
    EncounterProviderDataDefinition dispensedByDef = new EncounterProviderDataDefinition();
    dispensedByDef.setEncounterRole(encounterService.getEncounterRoleByUuid(PihEmrConfigConstants.ENCOUNTERROLE_DISPENSER_UUID));
    dsd.addColumn("dispensedBy", dispensedByDef, "", new ObjectFormatter());
    EncounterProviderDataDefinition prescribedByDef = new EncounterProviderDataDefinition();
    prescribedByDef.setEncounterRole(encounterService.getEncounterRoleByUuid(PihEmrConfigConstants.ENCOUNTERROLE_ORDERINGPROVIDER_UUID));
    dsd.addColumn("prescribedBy", prescribedByDef, "", new ObjectFormatter());
    ObsForEncounterDataDefinition typeOfPrescriptionDef = new ObsForEncounterDataDefinition();
    typeOfPrescriptionDef.setQuestion(conceptService.getConceptByMapping("9292", "PIH"));
    dsd.addColumn("typeOfPrescription", typeOfPrescriptionDef, "", new ObjectFormatter());
    ObsForEncounterDataDefinition locationOfPrescriptionDef = new ObsForEncounterDataDefinition();
    locationOfPrescriptionDef.setQuestion(conceptService.getConceptByMapping("9293", "PIH"));
    dsd.addColumn("locationOfPrescription", locationOfPrescriptionDef, "", new ObsValueTextAsCodedConverter<>(Location.class), new ObjectFormatter());
    return dsd;
}
Also used : Drug(org.openmrs.Drug) EncounterLocationDataDefinition(org.openmrs.module.reporting.data.encounter.definition.EncounterLocationDataDefinition) ObsForEncounterDataDefinition(org.openmrs.module.reporting.data.encounter.definition.ObsForEncounterDataDefinition) EncounterDatetimeDataDefinition(org.openmrs.module.reporting.data.encounter.definition.EncounterDatetimeDataDefinition) DateConverter(org.openmrs.module.reporting.data.converter.DateConverter) BasicObsQuery(org.openmrs.module.reporting.query.obs.definition.BasicObsQuery) Date(java.util.Date) ObsDataSetDefinition(org.openmrs.module.reporting.dataset.definition.ObsDataSetDefinition) ObjectFormatter(org.openmrs.module.reporting.data.converter.ObjectFormatter) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EncounterProviderDataDefinition(org.openmrs.module.reporting.data.encounter.definition.EncounterProviderDataDefinition) Location(org.openmrs.Location)

Aggregations

Date (java.util.Date)2 PropertyConverter (org.openmrs.module.reporting.data.converter.PropertyConverter)2 EncounterLocationDataDefinition (org.openmrs.module.reporting.data.encounter.definition.EncounterLocationDataDefinition)2 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)2 Drug (org.openmrs.Drug)1 Location (org.openmrs.Location)1 Visit (org.openmrs.Visit)1 AgeConverter (org.openmrs.module.reporting.data.converter.AgeConverter)1 DateConverter (org.openmrs.module.reporting.data.converter.DateConverter)1 ObjectFormatter (org.openmrs.module.reporting.data.converter.ObjectFormatter)1 ConvertedEncounterDataDefinition (org.openmrs.module.reporting.data.encounter.definition.ConvertedEncounterDataDefinition)1 EncounterDatetimeDataDefinition (org.openmrs.module.reporting.data.encounter.definition.EncounterDatetimeDataDefinition)1 EncounterProviderDataDefinition (org.openmrs.module.reporting.data.encounter.definition.EncounterProviderDataDefinition)1 ObsForEncounterDataDefinition (org.openmrs.module.reporting.data.encounter.definition.ObsForEncounterDataDefinition)1 EncounterDataSetDefinition (org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition)1 ObsDataSetDefinition (org.openmrs.module.reporting.dataset.definition.ObsDataSetDefinition)1 BasicEncounterQuery (org.openmrs.module.reporting.query.encounter.definition.BasicEncounterQuery)1 BasicObsQuery (org.openmrs.module.reporting.query.obs.definition.BasicObsQuery)1