[SOLVED] /openmrs Webapp Hard coded in Paths

I have run into an issue where the /openmrs webapp path is hard coded in JS paths in coreapps - which leads to breakages in all installations that use different web app names. This seems common in webservice calls too

@raff I know its so close to 2.6 release … but it seems like need for a mass cleanup across modules

Do you mind giving an example of where this mistake is being done?

Yeah, for what it’s worth, one of our instances uses a difference webapp name than OpenMRS, but so far we haven’t noticed any problems… I wonder if we just aren’t using the features where this is an issue? Is it in the new dashboard widgets?

Take care, Mark

Here’s an example:

There is a couple of areas where it’s hard coded to ‘/openmrs’, in a GSP if you use ui.contextPath(), you should be fine, I think we need to expose a global variable for the contextPath in one of the core JS files in the uicommons module.

1 Like

For JS that’s included in a UI Framework-backed page, this is already done: https://github.com/openmrs/openmrs-module-appui/blob/1.8.0/omod/src/main/webapp/fragments/decorator/standardEmrPage.gsp#L22

For purely Angular or React apps there’s no way for us to set a global variable from “core” code. So we should just document a preferred way to get the context path (e.g. some utility function that parses window.location).

@darius @raff suggested using openmrsRest.getServerUrl() in JS functions

If you’re already using the openmrs-contrib-uicommons angular framework, then yes, you should use that openmrsRest.getServerUrl() function.

Okay, I am JS handicapped but I have a case of <a href="/openmrs/coreapps/patientdashboard/patientDashboard.page?patientId={{ctrl.config.patientUuid}}&visitId={{visit.uuid}}">{{visit.startDatetime | date:'yyyy-MM-dd'}}</a>

In an Angular template file, what would be the recommended approach for replacing the /openmrs/ with the context path? I have seen:

  1. EMR navigate emr.navigateTo({ provider: "htmlformentryui", page: "htmlform/viewEncounterWithHtmlForm", query: { patient: patientId, encounter: encounterId} });

  2. OpenMRSRest Base Path openmrsRest.setBaseAppPath("/coreapps");

  3. Handlebars with a ctrl.patientPage parameter defined somwehere in the script file Handlebars.compile(ctrl.patientPage)({ patientUuid: patientId });

FYI, Stephen created an issue at https://issues.openmrs.org/browse/RA-1355

1 Like