Made MDM loading work properly

This commit is contained in:
jkv
2021-06-27 19:21:53 +02:00
parent 7387d131b9
commit 2b3ed04703
3 changed files with 34 additions and 18 deletions

View File

@@ -24,6 +24,7 @@ import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor; 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.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator; import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.narrative2.NullNarrativeGenerator; import ca.uhn.fhir.narrative2.NullNarrativeGenerator;
@@ -46,19 +47,18 @@ import ca.uhn.fhir.validation.IValidatorModule;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; 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.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; 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 { public class BaseJpaRestfulServer extends RestfulServer {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaRestfulServer.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaRestfulServer.class);
@@ -73,7 +73,7 @@ public class BaseJpaRestfulServer extends RestfulServer {
@Autowired @Autowired
IFhirSystemDao fhirSystemDao; IFhirSystemDao fhirSystemDao;
@Autowired @Autowired
ResourceProviderFactory resourceProviders; ResourceProviderFactory resourceProviderFactory;
@Autowired @Autowired
IJpaSystemProvider jpaSystemProvider; IJpaSystemProvider jpaSystemProvider;
@Autowired @Autowired
@@ -101,9 +101,13 @@ public class BaseJpaRestfulServer extends RestfulServer {
@Autowired(required = false) @Autowired(required = false)
IRepositoryValidationInterceptorFactory factory; IRepositoryValidationInterceptorFactory factory;
// These are set only if the features are enabled // These are set only if the features are enabled
private CqlProviderLoader cqlProviderLoader; @Autowired
@Autowired Optional<CqlProviderLoader> cqlProviderLoader;
private IValidationSupport myValidationSupport; @Autowired
Optional<MdmProviderLoader> mdmProviderProvider;
@Autowired
private IValidationSupport myValidationSupport;
public BaseJpaRestfulServer() { public BaseJpaRestfulServer() {
} }
@@ -127,7 +131,14 @@ public class BaseJpaRestfulServer extends RestfulServer {
setFhirContext(fhirSystemDao.getContext()); 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); registerProvider(jpaSystemProvider);
/* /*

View File

@@ -5,18 +5,23 @@ import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl; import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
import ca.uhn.fhir.jpa.starter.annotations.OnDSTU3Condition; 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.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.core.env.ConfigurableEnvironment;
import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import javax.annotation.PostConstruct;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration @Configuration
@Conditional(OnDSTU3Condition.class) @Conditional(OnDSTU3Condition.class)
@Import(StarterCqlDstu3Config.class)
public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 { public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 {
@Autowired @Autowired

View File

@@ -126,7 +126,7 @@ hapi:
# binary_storage_enabled: true # binary_storage_enabled: true
# bulk_export_enabled: true # bulk_export_enabled: true
# subscription: # subscription:
# resthook_enabled: false # resthook_enabled: true
# websocket_enabled: false # websocket_enabled: false
# email: # email:
# from: some@test.com # from: some@test.com