diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java index 68f84e8..dc16873 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java @@ -24,6 +24,7 @@ import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor; +import ca.uhn.fhir.mdm.provider.MdmProviderLoader; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.narrative.INarrativeGenerator; import ca.uhn.fhir.narrative2.NullNarrativeGenerator; @@ -46,19 +47,18 @@ import ca.uhn.fhir.validation.IValidatorModule; import ca.uhn.fhir.validation.ResultSeverityEnum; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; -import org.hl7.fhir.r4.model.Bundle.BundleType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.http.HttpHeaders; -import org.springframework.web.cors.CorsConfiguration; - -import javax.servlet.ServletException; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import javax.servlet.ServletException; +import org.hl7.fhir.r4.model.Bundle.BundleType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.http.HttpHeaders; +import org.springframework.web.cors.CorsConfiguration; public class BaseJpaRestfulServer extends RestfulServer { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaRestfulServer.class); @@ -73,7 +73,7 @@ public class BaseJpaRestfulServer extends RestfulServer { @Autowired IFhirSystemDao fhirSystemDao; @Autowired - ResourceProviderFactory resourceProviders; + ResourceProviderFactory resourceProviderFactory; @Autowired IJpaSystemProvider jpaSystemProvider; @Autowired @@ -101,9 +101,13 @@ public class BaseJpaRestfulServer extends RestfulServer { @Autowired(required = false) IRepositoryValidationInterceptorFactory factory; // These are set only if the features are enabled - private CqlProviderLoader cqlProviderLoader; - @Autowired - private IValidationSupport myValidationSupport; + @Autowired + Optional cqlProviderLoader; + @Autowired + Optional mdmProviderProvider; + + @Autowired + private IValidationSupport myValidationSupport; public BaseJpaRestfulServer() { } @@ -127,7 +131,14 @@ public class BaseJpaRestfulServer extends RestfulServer { setFhirContext(fhirSystemDao.getContext()); - registerProviders(resourceProviders.createProviders()); + /* + * Order matters - the MDM provider registers itself on the resourceProviderFactory - hence the loading must be done + * ahead of provider registration + */ + if(appProperties.getMdm_enabled()) + mdmProviderProvider.get().loadProvider(); + + registerProviders(resourceProviderFactory.createProviders()); registerProvider(jpaSystemProvider); /* diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigDstu3.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigDstu3.java index a10ecb4..367c0ec 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigDstu3.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigDstu3.java @@ -5,18 +5,23 @@ import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl; import ca.uhn.fhir.jpa.starter.annotations.OnDSTU3Condition; +import ca.uhn.fhir.jpa.starter.cql.StarterCqlDstu3Config; +import javax.annotation.PostConstruct; +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Primary; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import javax.annotation.PostConstruct; -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - @Configuration @Conditional(OnDSTU3Condition.class) +@Import(StarterCqlDstu3Config.class) public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 { @Autowired diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ae34a0c..1ff811a 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -126,7 +126,7 @@ hapi: # binary_storage_enabled: true # bulk_export_enabled: true # subscription: -# resthook_enabled: false +# resthook_enabled: true # websocket_enabled: false # email: # from: some@test.com