diff --git a/omod/pom.xml b/omod/pom.xml
index 849bc16..e0d6c64 100644
--- a/omod/pom.xml
+++ b/omod/pom.xml
@@ -31,6 +31,19 @@
openmrs-web
${openmrsPlatformVersion}
provided
+
+
+ javax.servlet
+ servlet-api
+
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.0.1
+ provided
diff --git a/omod/src/main/java/org/openmrs/module/fhirproxy/web/FhirProxyFilterRegistrar.java b/omod/src/main/java/org/openmrs/module/fhirproxy/web/FhirProxyFilterRegistrar.java
new file mode 100644
index 0000000..3920d8a
--- /dev/null
+++ b/omod/src/main/java/org/openmrs/module/fhirproxy/web/FhirProxyFilterRegistrar.java
@@ -0,0 +1,44 @@
+/**
+ * This Source Code Form is subject to the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
+ * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
+ *
+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
+ * graphic logo is a trademark of OpenMRS Inc.
+ */
+package org.openmrs.module.fhirproxy.web;
+
+import java.util.EnumSet;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterRegistration.Dynamic;
+import javax.servlet.ServletContext;
+
+import org.openmrs.module.fhirproxy.web.filter.FhirProxyFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.ServletContextAware;
+
+@Component
+public class FhirProxyFilterRegistrar implements ServletContextAware {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FhirProxyFilterRegistrar.class);
+
+ private static final String[] MAPPINGS = { "/ws/fhir2/R4/ChargeItemDefinition/*", "/ws/fhir2/R4/InventoryItem/*" };
+
+ @Override
+ public void setServletContext(ServletContext servletContext) {
+ LOG.info("Adding FHIR Proxy Filter");
+
+ try {
+ Dynamic filter = servletContext.addFilter("FHIR Proxy", new FhirProxyFilter());
+ filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, MAPPINGS);
+ }
+ catch (Exception ex) {
+ //Ignore known issue, this happens when running openmrs the first time.
+ }
+ }
+
+}
diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml
index 8788559..31543e3 100644
--- a/omod/src/main/resources/config.xml
+++ b/omod/src/main/resources/config.xml
@@ -15,6 +15,9 @@
${project.parent.groupId}.${project.parent.artifactId}.FhirProxyActivator
+
+ fhir2
+
@@ -23,19 +26,5 @@
The base URL for the external API
-
-
- FHIR Proxy
- org.openmrs.module.fhirproxy.web.filter.FhirProxyFilter
-
-
-
- FHIR Proxy
- /ws/fhir2/R4/ChargeItemDefinition/*
-
-
- FHIR Proxy
- /ws/fhir2/R4/InventoryItem/*
-