Search in sources :

Example 6 with PropertyConverter

use of org.openmrs.module.reporting.data.converter.PropertyConverter in project openmrs-module-mirebalais by PIH.

the class AppointmentSchedulingSetup method customizeDailyAppointmentsDataSet.

public static void customizeDailyAppointmentsDataSet() {
    DataSetDefinitionService dataSetDefinitionService = Context.getService(DataSetDefinitionService.class);
    PaperRecordProperties paperRecordProperties = Context.getRegisteredComponents(PaperRecordProperties.class).get(0);
    AppointmentDataSetDefinition dsd = (AppointmentDataSetDefinition) dataSetDefinitionService.getDefinition(AppointmentSchedulingUIConstants.DAILY_SCHEDULED_APPOINTMENT_DATA_SET_DEFINITION_UUID, AppointmentDataSetDefinition.class);
    if (dsd == null || dsd.getId() == null) {
        throw new RuntimeException("Daily scheduled appointment data set definition not found");
    }
    // swap out the identifier column to show dossier number instead of primary identifier
    dsd.removeColumnDefinition("identifier");
    PatientIdentifierDataDefinition dd = new PatientIdentifierDataDefinition(null, paperRecordProperties.getPaperRecordIdentifierType());
    dd.setIncludeFirstNonNullOnly(true);
    dsd.addColumn("identifier", dd, "", new PropertyConverter(PatientIdentifier.class, "identifier"));
    dataSetDefinitionService.saveDefinition(dsd);
}
Also used : AppointmentDataSetDefinition(org.openmrs.module.appointmentscheduling.reporting.dataset.definition.AppointmentDataSetDefinition) PatientIdentifierDataDefinition(org.openmrs.module.reporting.data.patient.definition.PatientIdentifierDataDefinition) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) DataSetDefinitionService(org.openmrs.module.reporting.dataset.definition.service.DataSetDefinitionService) PaperRecordProperties(org.openmrs.module.paperrecord.PaperRecordProperties) PatientIdentifier(org.openmrs.PatientIdentifier)

Example 7 with PropertyConverter

use of org.openmrs.module.reporting.data.converter.PropertyConverter 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)

Example 8 with PropertyConverter

use of org.openmrs.module.reporting.data.converter.PropertyConverter in project openmrs-module-pihcore by PIH.

the class PihEncounterDataLibrary method getAdmissionStatus.

@DocumentedDefinition
public EncounterDataDefinition getAdmissionStatus() {
    ObsForEncounterDataDefinition dd = new ObsForEncounterDataDefinition();
    // concept with synonyms "Type of Patient" and "Admission Status", possible answers are Ambulatory and Hospitalized
    dd.setQuestion(conceptService.getConceptByMapping("3289", "PIH"));
    return new ConvertedEncounterDataDefinition(dd, new PropertyConverter(Obs.class, "valueCoded"), new ObjectFormatter());
}
Also used : ObsForEncounterDataDefinition(org.openmrs.module.reporting.data.encounter.definition.ObsForEncounterDataDefinition) Obs(org.openmrs.Obs) ObjectFormatter(org.openmrs.module.reporting.data.converter.ObjectFormatter) ConvertedEncounterDataDefinition(org.openmrs.module.reporting.data.encounter.definition.ConvertedEncounterDataDefinition) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) DocumentedDefinition(org.openmrs.module.reporting.definition.library.DocumentedDefinition)

Example 9 with PropertyConverter

use of org.openmrs.module.reporting.data.converter.PropertyConverter in project openmrs-module-pihcore by PIH.

the class PihPatientDataLibrary method getAllDossierNumberIdentifiers.

@DocumentedDefinition("allDossierNumbers.identifier")
public PatientDataDefinition getAllDossierNumberIdentifiers() {
    PatientIdentifierDataDefinition pdd = new PatientIdentifierDataDefinition();
    pdd.setTypes(Arrays.asList(getDossierNumberType()));
    CollectionConverter cc = new CollectionConverter(new PropertyConverter(PatientIdentifier.class, "identifier"), false, new ComparableComparator());
    return new ConvertedPatientDataDefinition(pdd, cc);
}
Also used : PatientIdentifierDataDefinition(org.openmrs.module.reporting.data.patient.definition.PatientIdentifierDataDefinition) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) ComparableComparator(org.apache.commons.collections.comparators.ComparableComparator) CollectionConverter(org.openmrs.module.reporting.data.converter.CollectionConverter) PatientIdentifier(org.openmrs.PatientIdentifier) ConvertedPatientDataDefinition(org.openmrs.module.reporting.data.patient.definition.ConvertedPatientDataDefinition) DocumentedDefinition(org.openmrs.module.reporting.definition.library.DocumentedDefinition)

Aggregations

PropertyConverter (org.openmrs.module.reporting.data.converter.PropertyConverter)9 ObjectFormatter (org.openmrs.module.reporting.data.converter.ObjectFormatter)5 ConvertedEncounterDataDefinition (org.openmrs.module.reporting.data.encounter.definition.ConvertedEncounterDataDefinition)4 PatientIdentifier (org.openmrs.PatientIdentifier)3 EncounterProviderDataDefinition (org.openmrs.module.reporting.data.encounter.definition.EncounterProviderDataDefinition)3 PatientIdentifierDataDefinition (org.openmrs.module.reporting.data.patient.definition.PatientIdentifierDataDefinition)3 DocumentedDefinition (org.openmrs.module.reporting.definition.library.DocumentedDefinition)3 Date (java.util.Date)2 Person (org.openmrs.Person)2 Provider (org.openmrs.Provider)2 AppointmentDataSetDefinition (org.openmrs.module.appointmentscheduling.reporting.dataset.definition.AppointmentDataSetDefinition)2 PaperRecordProperties (org.openmrs.module.paperrecord.PaperRecordProperties)2 CollectionConverter (org.openmrs.module.reporting.data.converter.CollectionConverter)2 EncounterLocationDataDefinition (org.openmrs.module.reporting.data.encounter.definition.EncounterLocationDataDefinition)2 ObsForEncounterDataDefinition (org.openmrs.module.reporting.data.encounter.definition.ObsForEncounterDataDefinition)2 DataSetDefinitionService (org.openmrs.module.reporting.dataset.definition.service.DataSetDefinitionService)2 Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)2 ComparableComparator (org.apache.commons.collections.comparators.ComparableComparator)1 Drug (org.openmrs.Drug)1 Location (org.openmrs.Location)1