use of org.openmrs.module.reporting.data.encounter.definition.EncounterDatetimeDataDefinition 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;
}
Aggregations