From 4f8d34cbb45baf2317018c2d6d07620a18823612 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Mon, 27 Apr 2020 12:49:15 -0400 Subject: [PATCH] updated to match 5.0.0 --- pom.xml | 16 ++++++--- .../fhir/jpa/starter/ApplicationContext.java | 3 +- .../ca/uhn/fhir/jpa/starter/EmpiConfig.java | 27 +++++++++++++++ .../jpa/starter/FhirServerConfigCommon.java | 14 ++++---- .../uhn/fhir/jpa/starter/HapiProperties.java | 5 +++ .../fhir/jpa/starter/JpaRestfulServer.java | 33 +++++++++++-------- src/main/resources/empi-rules.json | 32 ++++++++++++++++++ 7 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java create mode 100644 src/main/resources/empi-rules.json diff --git a/pom.xml b/pom.xml index 3ad764d..7cc8094 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-empi + ${project.version} + ca.uhn.hapi.fhir @@ -276,7 +282,7 @@ org.eclipse.jetty jetty-maven-plugin - ${jetty_version} + ${jetty_version} /hapi-fhir-jpaserver diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/ApplicationContext.java b/src/main/java/ca/uhn/fhir/jpa/starter/ApplicationContext.java index 24b4f79..3770e1a 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/ApplicationContext.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/ApplicationContext.java @@ -1,6 +1,7 @@ package ca.uhn.fhir.jpa.starter; import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; public class ApplicationContext extends AnnotationConfigWebApplicationContext { @@ -20,7 +21,7 @@ public class ApplicationContext extends AnnotationConfigWebApplicationContext { } if (HapiProperties.getSubscriptionWebsocketEnabled()) { - register(ca.uhn.fhir.jpa.config.WebsocketDispatcherConfig.class); + register(WebsocketDispatcherConfig.class); } } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java new file mode 100644 index 0000000..3617036 --- /dev/null +++ b/src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java @@ -0,0 +1,27 @@ +package ca.uhn.fhir.jpa.starter; + +import ca.uhn.fhir.empi.api.IEmpiSettings; +import ca.uhn.fhir.empi.rules.config.EmpiSettingsImpl; +import ca.uhn.fhir.jpa.empi.config.EmpiConsumerConfig; +import ca.uhn.fhir.jpa.empi.config.EmpiSubmitterConfig; +import com.google.common.base.Charsets; +import org.apache.commons.io.IOUtils; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; + +import java.io.IOException; + +@Configuration +@Import({EmpiSubmitterConfig.class, EmpiConsumerConfig.class}) +public class EmpiConfig { + @Bean + IEmpiSettings empiProperties() throws IOException { + DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); + Resource resource = resourceLoader.getResource("empi-rules.json"); + String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8); + return new EmpiSettingsImpl().setEnabled(HapiProperties.getEmpiEnabled()).setScriptText(json); + } +} diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java index 70bfb4d..5647d03 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java @@ -1,17 +1,18 @@ package ca.uhn.fhir.jpa.starter; +import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.binstore.DatabaseBlobBinaryStorageSvcImpl; import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; -import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.model.entity.ModelConfig; -import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionDeliveryHandlerFactory; -import ca.uhn.fhir.jpa.subscription.module.subscriber.email.IEmailSender; -import ca.uhn.fhir.jpa.subscription.module.subscriber.email.JavaMailEmailSender; +import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryHandlerFactory; +import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender; +import ca.uhn.fhir.jpa.subscription.match.deliver.email.JavaMailEmailSender; import org.apache.commons.dbcp2.BasicDataSource; import org.hl7.fhir.dstu2.model.Subscription; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.thymeleaf.util.Validate; @@ -23,7 +24,8 @@ import java.sql.Driver; * This is the primary configuration file for the example server */ @Configuration -@EnableTransactionManagement() +@EnableTransactionManagement +@Import(EmpiConfig.class) public class FhirServerConfigCommon { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class); @@ -191,7 +193,7 @@ public class FhirServerConfigCommon { retVal.setSmtpServerPort(this.emailPort); retVal.setSmtpServerUsername(this.emailUsername); retVal.setSmtpServerPassword(this.emailPassword); - // TODO KHS add these when HAPI 4.2.0 is released + // FIXME KHS add these once this has merged in hapi // retVal.setAuth(this.emailAuth); // retVal.setStartTlsEnable(this.emailStartTlsEnable); // retVal.setStartTlsRequired(this.emailStartTlsRequired); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java index 5be55f4..a159758 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java @@ -57,6 +57,7 @@ public class HapiProperties { static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled"; static final String SUBSCRIPTION_RESTHOOK_ENABLED = "subscription.resthook.enabled"; static final String SUBSCRIPTION_WEBSOCKET_ENABLED = "subscription.websocket.enabled"; + static final String EMPI_ENABLED = "empi.enabled"; static final String ALLOWED_BUNDLE_TYPES = "allowed_bundle_types"; static final String TEST_PORT = "test.port"; static final String TESTER_CONFIG_REFUSE_TO_FETCH_THIRD_PARTY_URLS = "tester.config.refuse_to_fetch_third_party_urls"; @@ -373,6 +374,10 @@ public class HapiProperties { return HapiProperties.getBooleanProperty(SUBSCRIPTION_WEBSOCKET_ENABLED, false); } + public static Boolean getEmpiEnabled() { + return HapiProperties.getBooleanProperty(EMPI_ENABLED, false); + } + public static Boolean getAllowContainsSearches() { return HapiProperties.getBooleanProperty(ALLOW_CONTAINS_SEARCHES, true); } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java index f5a47f6..e32148e 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java @@ -4,11 +4,11 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.interceptor.api.IInterceptorService; +import ca.uhn.fhir.jpa.api.config.DaoConfig; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; +import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor; import ca.uhn.fhir.jpa.bulk.BulkDataExportProvider; -import ca.uhn.fhir.jpa.dao.DaoConfig; -import ca.uhn.fhir.jpa.dao.DaoRegistry; -import ca.uhn.fhir.jpa.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; import ca.uhn.fhir.jpa.provider.GraphQLProvider; import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; @@ -22,9 +22,9 @@ import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4; import ca.uhn.fhir.jpa.provider.r5.JpaConformanceProviderR5; import ca.uhn.fhir.jpa.provider.r5.JpaSystemProviderR5; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; -import ca.uhn.fhir.jpa.subscription.SubscriptionInterceptorLoader; -import ca.uhn.fhir.jpa.subscription.module.interceptor.SubscriptionDebugLogInterceptor; -import ca.uhn.fhir.jpa.util.ResourceProviderFactory; +import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry; +import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionSubmitInterceptorLoader; +import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor; import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy; @@ -34,6 +34,7 @@ import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor; +import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; import ca.uhn.fhir.validation.IValidatorModule; import ca.uhn.fhir.validation.ResultSeverityEnum; import java.util.HashSet; @@ -123,21 +124,21 @@ public class JpaRestfulServer extends RestfulServer { IFhirSystemDao systemDao = appCtx .getBean("mySystemDaoDstu3", IFhirSystemDao.class); JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, - appCtx.getBean(DaoConfig.class)); + appCtx.getBean(DaoConfig.class), appCtx.getBean(ISearchParamRegistry.class)); confProvider.setImplementationDescription("HAPI FHIR DSTU3 Server"); setServerConformanceProvider(confProvider); } else if (fhirVersion == FhirVersionEnum.R4) { IFhirSystemDao systemDao = appCtx .getBean("mySystemDaoR4", IFhirSystemDao.class); JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao, - appCtx.getBean(DaoConfig.class)); + appCtx.getBean(DaoConfig.class), appCtx.getBean(ISearchParamRegistry.class)); confProvider.setImplementationDescription("HAPI FHIR R4 Server"); setServerConformanceProvider(confProvider); } else if (fhirVersion == FhirVersionEnum.R5) { IFhirSystemDao systemDao = appCtx .getBean("mySystemDaoR5", IFhirSystemDao.class); JpaConformanceProviderR5 confProvider = new JpaConformanceProviderR5(this, systemDao, - appCtx.getBean(DaoConfig.class)); + appCtx.getBean(DaoConfig.class), appCtx.getBean(ISearchParamRegistry.class)); confProvider.setImplementationDescription("HAPI FHIR R5 Server"); setServerConformanceProvider(confProvider); } else { @@ -259,9 +260,10 @@ public class JpaRestfulServer extends RestfulServer { HapiProperties.getSubscriptionRestHookEnabled()) { // Loads subscription interceptors (SubscriptionActivatingInterceptor, SubscriptionMatcherInterceptor) // with activation of scheduled subscription - SubscriptionInterceptorLoader subscriptionInterceptorLoader = appCtx - .getBean(SubscriptionInterceptorLoader.class); - subscriptionInterceptorLoader.registerInterceptors(); + + SubscriptionSubmitInterceptorLoader subscriptionInterceptorLoader = appCtx + .getBean(SubscriptionSubmitInterceptorLoader.class); + subscriptionInterceptorLoader.start(); // Subscription debug logging IInterceptorService interceptorService = appCtx.getBean(IInterceptorService.class); @@ -272,7 +274,7 @@ public class JpaRestfulServer extends RestfulServer { DaoRegistry daoRegistry = appCtx.getBean(DaoRegistry.class); IInterceptorBroadcaster interceptorBroadcaster = appCtx.getBean(IInterceptorBroadcaster.class); if (HapiProperties.getAllowCascadingDeletes()) { - CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor( + CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(getFhirContext(), daoRegistry, interceptorBroadcaster); getInterceptorService().registerInterceptor(cascadingDeleteInterceptor); } @@ -345,6 +347,11 @@ public class JpaRestfulServer extends RestfulServer { registerProvider(appCtx.getBean(BulkDataExportProvider.class)); } + + if (HapiProperties.getEmpiEnabled()) { + // FIXME KHS } + + } } diff --git a/src/main/resources/empi-rules.json b/src/main/resources/empi-rules.json new file mode 100644 index 0000000..c305c1c --- /dev/null +++ b/src/main/resources/empi-rules.json @@ -0,0 +1,32 @@ +{ + "resourceSearchParams" : [ { + "resourceType" : "Patient", + "searchParam" : "birthdate" + }, { + "resourceType" : "All", + "searchParam" : "identifier" + } ], + "filterSearchParams" : [ { + "resourceType" : "All", + "searchParam" : "active", + "fixedValue" : "true" + } ], + "matchFields" : [ { + "name" : "given-name", + "resourceType" : "All", + "resourcePath" : "name.given", + "metric" : "COSINE", + "matchThreshold" : 0.8 + }, { + "name" : "last-name", + "resourceType" : "All", + "resourcePath" : "name.family", + "metric" : "JARO_WINKLER", + "matchThreshold" : 0.8 + }], + "weightMap" : { + "given-name" : "POSSIBLE_MATCH", + "given-name,last-name" : "MATCH" + }, + "eidSystem": "http://company.io/fhir/NamingSystem/custom-eid-system" +}