Skip to content

Commit e24dde6

Browse files
Merge pull request #1 from openmrs/master
update
2 parents 94a107c + 995f2f4 commit e24dde6

File tree

7 files changed

+142
-5
lines changed

7 files changed

+142
-5
lines changed
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.page.controller;
11+
12+
import java.util.Collections;
13+
import java.util.List;
14+
15+
import org.openmrs.module.appframework.domain.Extension;
16+
import org.openmrs.module.appframework.service.AppFrameworkService;
17+
import org.openmrs.module.appui.UiSessionContext;
18+
import org.openmrs.ui.framework.annotation.SpringBean;
19+
import org.openmrs.ui.framework.page.PageModel;
20+
21+
public class SmartAppsPageController {
22+
23+
public static final String SMART_APPS_EXTENSION_POINT = "smartAppManagement.apps";
24+
25+
public void get(PageModel model, UiSessionContext sessionContext,
26+
@SpringBean("appFrameworkService") AppFrameworkService appFrameworkService) {
27+
28+
sessionContext.requireAuthentication();
29+
30+
List<Extension> extensions = appFrameworkService.getExtensionsForCurrentUser(SMART_APPS_EXTENSION_POINT);
31+
32+
Collections.sort(extensions);
33+
model.addAttribute("extensions", extensions);
34+
}
35+
36+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
4646
req.getRequestDispatcher("/ms/smartEhrLaunchServlet").forward(req, res);
4747
return;
4848
}
49-
49+
if (request.getRequestURI().contains("/ms/smartAppSelectorServlet")) {
50+
req.getRequestDispatcher("/ms/smartAppSelectorServlet").forward(req, res);
51+
return;
52+
}
5053
}
5154
chain.doFilter(req, res);
5255
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 SmartAppSelectorServlet extends HttpServlet {
22+
23+
@Override
24+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
25+
String smartAppLaunchURL = req.getParameter("smartApp");
26+
String url = smartAppLaunchURL + "?iss=http://localhost:8080/openmrs/ws/fhir2/R4&launch=";
27+
28+
if (StringUtils.isBlank(url)) {
29+
resp.sendError(HttpStatus.SC_BAD_REQUEST, "A url must be provided");
30+
return;
31+
}
32+
33+
resp.sendRedirect(resp.encodeRedirectURL(url));
34+
}
35+
}

omod/src/main/resources/apps/smart_app.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"id": "coreapps.smartAppManagement",
3+
"id": "smartonfhir.smartAppManagement",
44
"description": "SMART Apps",
55
"extensionPoints": [
66
{
@@ -10,14 +10,14 @@
1010
],
1111
"extensions": [
1212
{
13-
"id": "coreapps.smartAppManagement.homepageLink",
13+
"id": "smartonfhir.smartAppManagement.homepageLink",
1414
"extensionPointId": "org.openmrs.referenceapplication.homepageLink",
1515
"type": "link",
1616
"label": "SMART Apps",
17-
"url": "coreapps/datamanagement/dataManagement.page",
17+
"url": "smartonfhir/smartApps.page",
1818
"icon": "icon-hdd",
1919
"order": 89,
20-
"requiredPrivilege": "App: coreapps.dataManagement"
20+
"requiredPrivilege": "App: smartonfhir.smartapps"
2121
}
2222
]
2323
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"id": "smartapps.demoapp",
4+
"description": "First smart app",
5+
"order": 1,
6+
"extensions": [
7+
{
8+
"id": "smartapps.demoappHomepageLink",
9+
"extensionPointId": "smartAppManagement.apps",
10+
"type": "link",
11+
"label": "Demo App",
12+
"url": "ms/smartAppSelectorServlet?smartApp=http://127.0.0.1:9090/launch-standalone.html",
13+
"icon": "icon-hdd",
14+
"requiredPrivilege": "App: smartonfhir.demoappHomepageLink"
15+
}
16+
]
17+
}
18+
]

omod/src/main/resources/config.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
<servlet-class>org.openmrs.module.smartonfhir.web.servlet.SmartEhrLaunchServlet</servlet-class>
5656
</servlet>
5757

58+
<servlet>
59+
<servlet-name>smartAppSelectorServlet</servlet-name>
60+
<servlet-class>org.openmrs.module.smartonfhir.web.servlet.SmartAppSelectorServlet</servlet-class>
61+
</servlet>
62+
5863
<filter>
5964
<filter-name>smartCORSFilter</filter-name>
6065
<filter-class>org.openmrs.module.smartonfhir.web.filter.CORSFilter</filter-class>
@@ -103,6 +108,8 @@
103108
<url-pattern>/ws/fhir2/*</url-pattern>
104109
<url-pattern>/ms/smartEhrLaunchServlet</url-pattern>
105110
<url-pattern>/ms/smartEhrLaunchServlet/*</url-pattern>
111+
<url-pattern>/ms/smartAppSelectorServlet/</url-pattern>
112+
<url-pattern>/ms/smartAppSelectorServlet/*</url-pattern>
106113
</filter-mapping>
107114

108115
<!-- Internationalization -->
@@ -120,5 +127,15 @@
120127
<file>messages_es.properties</file>
121128
</messages>
122129
<!-- /Internationalization -->
130+
131+
<privilege>
132+
<name>App: smartonfhir.smartapps</name>
133+
<description>Able to access smart apps</description>
134+
</privilege>
135+
136+
<privilege>
137+
<name>App: smartonfhir.demoappHomepageLink</name>
138+
<description>Demo smart app</description>
139+
</privilege>
123140
</module>
124141

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<%
2+
ui.decorateWith("appui", "standardEmrPage")
3+
ui.includeCss("smartonfhir", "smartAppsHome.css")
4+
5+
def htmlSafeId = { extension ->
6+
"${ extension.id.replace(".", "-") }-app"
7+
}
8+
%>
9+
10+
<script type="text/javascript">
11+
var breadcrumbs = [
12+
{ icon: "icon-home", link: '/' + OPENMRS_CONTEXT_PATH + '/index.htm' },
13+
{ label: "${ ui.message("Smart Apps")}"}
14+
];
15+
</script>
16+
17+
<div id="smartApps" class="rows">
18+
<% extensions.each { extension -> %>
19+
<div class="col-6 col-sm-2 col-md-3 col-lg-2 homeList schedulingList">
20+
<a id="${ htmlSafeId(extension) }" href="/${ contextPath }/${ extension.url }" class="btn btn-default btn-lg button app big align-self-center" type="button">
21+
<% if (extension.icon) { %>
22+
<i class="${ extension.icon }"></i>
23+
<% } %>
24+
${ ui.message(extension.label) }
25+
</a>
26+
</div>
27+
<% } %>
28+
</div>

0 commit comments

Comments
 (0)