Search in sources :

Example 1 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-coreapps by openmrs.

the class VisitDetailsFragmentControllerTest method generateMockEncounterTemplateExtensions.

private List<Extension> generateMockEncounterTemplateExtensions() {
    Extension extension = new Extension();
    Map<String, Object> encounterTypeParams = new HashMap<String, Object>();
    encounterTypeParams.put("primaryEncounterRole", primaryEncounterRoleUuid);
    Map<String, Object> supportedEncounterTypes = new HashMap<String, Object>();
    supportedEncounterTypes.put(encounterTypeUuid, encounterTypeParams);
    Map<String, Object> extensionParams = new HashMap<String, Object>();
    extensionParams.put("supportedEncounterTypes", supportedEncounterTypes);
    extension.setExtensionParams(extensionParams);
    return Collections.singletonList(extension);
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) HashMap(java.util.HashMap) SimpleObject(org.openmrs.ui.framework.SimpleObject)

Example 2 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-coreapps by openmrs.

the class PatientPageController method controller.

public Object controller(@RequestParam("patientId") Patient patient, PageModel model, @RequestParam(required = false, value = "app") AppDescriptor app, @RequestParam(required = false, value = "dashboard") String dashboard, @InjectBeans PatientDomainWrapper patientDomainWrapper, @SpringBean("adtService") AdtService adtService, @SpringBean("visitService") VisitService visitService, @SpringBean("encounterService") EncounterService encounterService, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @SpringBean("applicationEventService") ApplicationEventService applicationEventService, @SpringBean("coreAppsProperties") CoreAppsProperties coreAppsProperties, UiSessionContext sessionContext) {
    if (!Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_DASHBOARD)) {
        return new Redirect("coreapps", "noAccess", "");
    } else if (patient.isVoided() || patient.isPersonVoided()) {
        return new Redirect("coreapps", "patientdashboard/deletedPatient", "patientId=" + patient.getId());
    }
    if (StringUtils.isEmpty(dashboard)) {
        dashboard = "patientDashboard";
    }
    patientDomainWrapper.setPatient(patient);
    model.addAttribute("patient", patientDomainWrapper);
    model.addAttribute("app", app);
    Location visitLocation = null;
    try {
        visitLocation = adtService.getLocationThatSupportsVisits(sessionContext.getSessionLocation());
    } catch (IllegalArgumentException ex) {
    // location does not support visits
    }
    VisitDomainWrapper activeVisit = null;
    if (visitLocation != null) {
        activeVisit = adtService.getActiveVisit(patient, visitLocation);
    }
    model.addAttribute("activeVisit", activeVisit);
    AppContextModel contextModel = sessionContext.generateAppContextModel();
    contextModel.put("patient", new PatientContextModel(patient));
    contextModel.put("visit", activeVisit == null ? null : new VisitContextModel(activeVisit));
    model.addAttribute("appContextModel", contextModel);
    List<Extension> overallActions = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".overallActions", contextModel);
    Collections.sort(overallActions);
    model.addAttribute("overallActions", overallActions);
    List<Extension> visitActions;
    if (activeVisit == null) {
        visitActions = new ArrayList<Extension>();
    } else {
        visitActions = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".visitActions", contextModel);
        Collections.sort(visitActions);
    }
    model.addAttribute("visitActions", visitActions);
    List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".includeFragments", contextModel);
    Collections.sort(includeFragments);
    model.addAttribute("includeFragments", includeFragments);
    List<Extension> firstColumnFragments = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".firstColumnFragments", contextModel);
    Collections.sort(firstColumnFragments);
    model.addAttribute("firstColumnFragments", firstColumnFragments);
    List<Extension> secondColumnFragments = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".secondColumnFragments", contextModel);
    Collections.sort(secondColumnFragments);
    model.addAttribute("secondColumnFragments", secondColumnFragments);
    List<Extension> otherActions = appFrameworkService.getExtensionsForCurrentUser((dashboard == "patientDashboard" ? "clinicianFacingPatientDashboard" : dashboard) + ".otherActions", contextModel);
    Collections.sort(otherActions);
    model.addAttribute("otherActions", otherActions);
    // used for breadcrumbs to link back to the base dashboard in the case when this is used to render a context-specific dashboard
    model.addAttribute("baseDashboardUrl", coreAppsProperties.getDashboardUrl());
    model.addAttribute("dashboard", dashboard);
    applicationEventService.patientViewed(patient, sessionContext.getCurrentUser());
    return null;
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) PatientContextModel(org.openmrs.module.coreapps.contextmodel.PatientContextModel) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Redirect(org.openmrs.ui.framework.page.Redirect) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Location(org.openmrs.Location) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel)

Example 3 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-coreapps by openmrs.

the class PatientDashboardPageController method controller.

public Object controller(@RequestParam("patientId") Patient patient, @RequestParam(value = "visitId", required = false) Visit visit, @RequestParam(value = "tab", defaultValue = "visits") String selectedTab, PageModel model, @InjectBeans PatientDomainWrapper patientDomainWrapper, @SpringBean("orderService") OrderService orderService, @SpringBean("adtService") AdtService adtService, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @SpringBean("coreAppsProperties") CoreAppsProperties coreAppsProperties, @SpringBean("applicationEventService") ApplicationEventService applicationEventService, UiSessionContext sessionContext) {
    if (!Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_VISITS)) {
        return new Redirect("coreapps", "noAccess", "");
    } else if (patient.isVoided() || patient.isPersonVoided()) {
        return new Redirect("coreapps", "patientdashboard/deletedPatient", "patientId=" + patient.getId());
    }
    patientDomainWrapper.setPatient(patient);
    model.addAttribute("patient", patientDomainWrapper);
    model.addAttribute("selectedTab", selectedTab);
    model.addAttribute("selectedVisit", visit);
    Location visitLocation = null;
    try {
        visitLocation = adtService.getLocationThatSupportsVisits(sessionContext.getSessionLocation());
    } catch (IllegalArgumentException ex) {
    // location does not support visits
    }
    VisitDomainWrapper activeVisit = null;
    if (visitLocation != null) {
        activeVisit = adtService.getActiveVisit(patient, visitLocation);
    }
    model.addAttribute("activeVisit", activeVisit);
    List<Extension> encounterTemplateExtensions = appFrameworkService.getExtensionsForCurrentUser(CoreAppsConstants.ENCOUNTER_TEMPLATE_EXTENSION);
    model.addAttribute("encounterTemplateExtensions", encounterTemplateExtensions);
    AppContextModel contextModel = sessionContext.generateAppContextModel();
    contextModel.put("patient", new PatientContextModel(patient));
    contextModel.put("visit", activeVisit == null ? null : new VisitContextModel(activeVisit));
    model.addAttribute("appContextModel", contextModel);
    List<Extension> overallActions = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.overallActions", contextModel);
    Collections.sort(overallActions);
    model.addAttribute("overallActions", overallActions);
    List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.includeFragments");
    Collections.sort(includeFragments);
    model.addAttribute("includeFragments", includeFragments);
    List<Extension> visitActions = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.visitActions");
    Collections.sort(visitActions);
    model.addAttribute("visitActions", visitActions);
    model.addAttribute("patientTabs", appFrameworkService.getExtensionsForCurrentUser("patientDashboard.tabs"));
    model.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());
    model.addAttribute("encounterCount", coreAppsProperties.getPatientDashboardEncounterCount());
    applicationEventService.patientViewed(patient, sessionContext.getCurrentUser());
    return null;
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) PatientContextModel(org.openmrs.module.coreapps.contextmodel.PatientContextModel) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Redirect(org.openmrs.ui.framework.page.Redirect) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Location(org.openmrs.Location) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel)

Example 4 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-coreapps by openmrs.

the class SummaryDashboardPageController method controller.

public Object controller(@RequestParam("app") AppDescriptor app, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, PageModel model, UiSessionContext sessionContext) {
    if (!Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_SUMMARY_DASHBOARD)) {
        return new Redirect("coreapps", "noAccess", "");
    }
    model.addAttribute("app", app);
    AppContextModel contextModel = sessionContext.generateAppContextModel();
    model.addAttribute("appContextModel", contextModel);
    List<Extension> actions = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".actions", contextModel);
    Collections.sort(actions);
    model.addAttribute("actions", actions);
    List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".includeFragments", contextModel);
    Collections.sort(includeFragments);
    model.addAttribute("includeFragments", includeFragments);
    List<Extension> firstColumnFragments = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".firstColumnFragments", contextModel);
    Collections.sort(firstColumnFragments);
    model.addAttribute("firstColumnFragments", firstColumnFragments);
    List<Extension> secondColumnFragments = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".secondColumnFragments", contextModel);
    Collections.sort(secondColumnFragments);
    model.addAttribute("secondColumnFragments", secondColumnFragments);
    return null;
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Redirect(org.openmrs.ui.framework.page.Redirect)

Example 5 with Extension

use of org.openmrs.module.appframework.domain.Extension 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

Extension (org.openmrs.module.appframework.domain.Extension)23 Test (org.junit.Test)10 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)6 PatientContextModel (org.openmrs.module.coreapps.contextmodel.PatientContextModel)4 ArrayList (java.util.ArrayList)3 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)3 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)3 Redirect (org.openmrs.ui.framework.page.Redirect)3 Map (java.util.Map)2 Location (org.openmrs.Location)2 Patient (org.openmrs.Patient)2 SimpleObject (org.openmrs.ui.framework.SimpleObject)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 PatientIdentifierType (org.openmrs.PatientIdentifierType)1 User (org.openmrs.User)1 AppDescriptor (org.openmrs.module.appframework.domain.AppDescriptor)1 ParseEncounterToJson (org.openmrs.module.coreapps.parser.ParseEncounterToJson)1