Search in sources :

Example 1 with AwaitingAdmissionVisitQuery

use of org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery 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)

Aggregations

AppDescriptor (org.openmrs.module.appframework.domain.AppDescriptor)1 Extension (org.openmrs.module.appframework.domain.Extension)1 AwaitingAdmissionVisitQuery (org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery)1 MapElementConverter (org.openmrs.module.reporting.data.converter.MapElementConverter)1 ObjectFormatter (org.openmrs.module.reporting.data.converter.ObjectFormatter)1 PropertyConverter (org.openmrs.module.reporting.data.converter.PropertyConverter)1 PatientDataDefinition (org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition)1 VisitDataDefinition (org.openmrs.module.reporting.data.visit.definition.VisitDataDefinition)1 DataSet (org.openmrs.module.reporting.dataset.DataSet)1 VisitDataSetDefinition (org.openmrs.module.reporting.dataset.definition.VisitDataSetDefinition)1 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)1