Search in sources :

Example 1 with PropertyConverter

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

the class AwaitingAdmissionPageController method get.

public void get(PageModel model, @SpringBean AllDefinitionLibraries libraries, @SpringBean DataSetDefinitionService dsdService, @SpringBean CoreAppsProperties coreAppsProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService) throws EvaluationException {
    EvaluationContext context = new EvaluationContext();
    List<Extension> admissionActions = appFrameworkService.getExtensionsForCurrentUser("coreapps.app.awaitingAdmissionActions");
    Collections.sort(admissionActions);
    model.addAttribute("admissionActions", admissionActions);
    DataSet dataSet = null;
    VisitDataSetDefinition dsd = new VisitDataSetDefinition();
    AwaitingAdmissionVisitQuery query = new AwaitingAdmissionVisitQuery();
    dsd.addRowFilter(query, null);
    dsd.addColumn("visitId", libraries.getDefinition(VisitDataDefinition.class, "reporting.library.visitDataDefinition.builtIn.visitId"), "");
    dsd.addColumn("patientId", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.patientId"), "");
    dsd.addColumn("patientLastName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.familyName"), "");
    dsd.addColumn("patientFirstName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.givenName"), "");
    dsd.addColumn("primaryIdentifier", libraries.getDefinition(PatientDataDefinition.class, "emrapi.patientDataDefinition.primaryIdentifier"), "", new PropertyConverter(String.class, "identifier"));
    dsd.addColumn("mostRecentAdmissionRequestFromLocation", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("fromLocation", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestToLocation", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("toLocation", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestDatetime", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("datetime", null));
    dsd.addColumn("mostRecentAdmissionRequestProvider", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("provider", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestDiagnoses", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("diagnoses", new AwaitingAdmissionDiagnosisFormatter()));
    // add the paper record identifier, if the definition is available (provided by the paper record module)
    PatientDataDefinition paperRecordIdentifierDefinition = libraries.getDefinition(PatientDataDefinition.class, "paperrecord.patientDataDefinition.paperRecordIdentifier");
    if (paperRecordIdentifierDefinition != null) {
        model.addAttribute("paperRecordIdentifierDefinitionAvailable", true);
        dsd.addColumn("paperRecordIdentifier", paperRecordIdentifierDefinition, "", new PropertyConverter(String.class, "identifier"));
    } else {
        model.addAttribute("paperRecordIdentifierDefinitionAvailable", false);
    }
    dsd.addSortCriteria("mostRecentAdmissionRequestDatetime", SortCriteria.SortDirection.ASC);
    dataSet = dsdService.evaluate(dsd, context);
    model.addAttribute("awaitingAdmissionList", DataSetUtil.simplify(dataSet));
    // add location tag constants
    model.addAttribute("supportsAdmissionLocationTag", EmrApiConstants.LOCATION_TAG_SUPPORTS_ADMISSION);
    model.addAttribute("supportsLoginLocationTag", EmrApiConstants.LOCATION_TAG_SUPPORTS_LOGIN);
    // used to determine whether or not we display a link to the patient in the results list
    model.addAttribute("privilegePatientDashboard", CoreAppsConstants.PRIVILEGE_PATIENT_DASHBOARD);
    AppDescriptor app = appFrameworkService.getApp(CoreAppsConstants.AWAITING_ADMISSION);
    String patientPageUrl = app.getConfig().get("patientPageUrl") != null ? app.getConfig().get("patientPageUrl").getTextValue() : coreAppsProperties.getDashboardUrl();
    model.addAttribute("patientPageUrl", patientPageUrl);
}
Also used : VisitDataSetDefinition(org.openmrs.module.reporting.dataset.definition.VisitDataSetDefinition) DataSet(org.openmrs.module.reporting.dataset.DataSet) Extension(org.openmrs.module.appframework.domain.Extension) AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) AwaitingAdmissionVisitQuery(org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery) ObjectFormatter(org.openmrs.module.reporting.data.converter.ObjectFormatter) PatientDataDefinition(org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) VisitDataDefinition(org.openmrs.module.reporting.data.visit.definition.VisitDataDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) MapElementConverter(org.openmrs.module.reporting.data.converter.MapElementConverter)

Example 2 with PropertyConverter

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

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

the class PihEncounterDataLibrary method getAllProviders.

@DocumentedDefinition
public EncounterDataDefinition getAllProviders() {
    EncounterProviderDataDefinition dd = new EncounterProviderDataDefinition();
    dd.setSingleProvider(false);
    ChainedConverter itemConverter = new ChainedConverter(new PropertyConverter(Provider.class, "person"), new PropertyConverter(Person.class, "personName"), new ObjectFormatter("{givenName} {familyName}"));
    return new ConvertedEncounterDataDefinition(dd, new CollectionConverter(itemConverter, false, null), new ObjectFormatter(", "));
}
Also used : ChainedConverter(org.openmrs.module.reporting.data.converter.ChainedConverter) 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) EncounterProviderDataDefinition(org.openmrs.module.reporting.data.encounter.definition.EncounterProviderDataDefinition) Person(org.openmrs.Person) CollectionConverter(org.openmrs.module.reporting.data.converter.CollectionConverter) Provider(org.openmrs.Provider) DocumentedDefinition(org.openmrs.module.reporting.definition.library.DocumentedDefinition)

Example 4 with PropertyConverter

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

the class PihEncounterDataLibrary method getProvider.

private EncounterDataDefinition getProvider(String encounterRoleUuid) {
    EncounterProviderDataDefinition dd = new EncounterProviderDataDefinition();
    dd.setEncounterRole(encounterService.getEncounterRoleByUuid(encounterRoleUuid));
    return new ConvertedEncounterDataDefinition(dd, new PropertyConverter(Provider.class, "person"), new PropertyConverter(Person.class, "personName"), new ObjectFormatter("{givenName} {familyName}"));
}
Also used : 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) EncounterProviderDataDefinition(org.openmrs.module.reporting.data.encounter.definition.EncounterProviderDataDefinition) Person(org.openmrs.Person) Provider(org.openmrs.Provider)

Example 5 with PropertyConverter

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

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