Skip to content

Commit 072a5b7

Browse files
emr external app launch (#6)
1 parent fbef28d commit 072a5b7

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

omod/src/main/java/org/openmrs/module/smartonfhir/web/filter/SmartForwardingFilter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
4242
req.getRequestDispatcher("/ms/smartPatientSelected").forward(req, res);
4343
return;
4444
}
45+
if (request.getRequestURI().contains("/ms/smartEhrLaunchServlet")) {
46+
req.getRequestDispatcher("/ms/smartEhrLaunchServlet").forward(req, res);
47+
return;
48+
}
49+
4550
}
4651
chain.doFilter(req, res);
4752
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public License,
3+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5+
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6+
*
7+
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8+
* graphic logo is a trademark of OpenMRS Inc.
9+
*/
10+
package org.openmrs.module.smartonfhir.web.servlet;
11+
12+
import javax.servlet.http.HttpServlet;
13+
import javax.servlet.http.HttpServletRequest;
14+
import javax.servlet.http.HttpServletResponse;
15+
16+
import java.io.IOException;
17+
18+
import org.apache.commons.lang3.StringUtils;
19+
import org.apache.http.HttpStatus;
20+
21+
public class SmartEhrLaunchServlet extends HttpServlet {
22+
23+
@Override
24+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
25+
String patientId = req.getParameter("patientId");
26+
String url = "http://127.0.0.1:9090/launch-standalone.html?iss=http://localhost:8080/openmrs/ws/fhir2/R4&launch="
27+
+ patientId;
28+
29+
if (StringUtils.isBlank(url)) {
30+
resp.sendError(HttpStatus.SC_BAD_REQUEST, "A url must be provided");
31+
return;
32+
}
33+
34+
resp.sendRedirect(resp.encodeRedirectURL(url));
35+
}
36+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"id": "coreapps.smartRedirect",
4+
"description": "Basic patient search, by ID or Name (using OpenMRS's standard patient search)",
5+
"order": 2,
6+
"extensions": [
7+
{
8+
"id": "coreapps.activeVisitsHomepageLink",
9+
"extensionPointId": "patientDashboard.overallActions",
10+
"type": "link",
11+
"label": "coreapps.findPatient.app.label",
12+
"url": "ms/smartEhrLaunchServlet?app=smart_client&patientId={{patient.uuid}}",
13+
"icon": "icon-search",
14+
"requiredPrivilege": "App: coreapps.findPatient"
15+
}
16+
]
17+
}
18+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[
2+
{
3+
"id": "coreapps.smartAppManagement",
4+
"description": "SMART Apps",
5+
"extensionPoints": [
6+
{
7+
"id": "smartAppManagement.apps",
8+
"description": "Apps on the SMART App Management Home Page"
9+
}
10+
],
11+
"extensions": [
12+
{
13+
"id": "coreapps.smartAppManagement.homepageLink",
14+
"extensionPointId": "org.openmrs.referenceapplication.homepageLink",
15+
"type": "link",
16+
"label": "SMART Apps",
17+
"url": "coreapps/datamanagement/dataManagement.page",
18+
"icon": "icon-hdd",
19+
"order": 89,
20+
"requiredPrivilege": "App: coreapps.dataManagement"
21+
}
22+
]
23+
}
24+
]

omod/src/main/resources/config.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
<servlet-class>org.openmrs.module.smartonfhir.web.servlet.SmartPatientSelected</servlet-class>
5151
</servlet>
5252

53+
<servlet>
54+
<servlet-name>smartEhrLaunchServlet</servlet-name>
55+
<servlet-class>org.openmrs.module.smartonfhir.web.servlet.SmartEhrLaunchServlet</servlet-class>
56+
</servlet>
57+
5358
<filter>
5459
<filter-name>smartCORSFilter</filter-name>
5560
<filter-class>org.openmrs.module.smartonfhir.web.filter.CORSFilter</filter-class>
@@ -96,6 +101,8 @@
96101
<filter-name>smartForwardingFilter</filter-name>
97102
<url-pattern>/ws/fhir2</url-pattern>
98103
<url-pattern>/ws/fhir2/*</url-pattern>
104+
<url-pattern>/ms/smartEhrLaunchServlet</url-pattern>
105+
<url-pattern>/ms/smartEhrLaunchServlet/*</url-pattern>
99106
</filter-mapping>
100107

101108
<!-- Internationalization -->

0 commit comments

Comments
 (0)