Merge pull request #255 from hapifhir/bugfix/mdm-fix

Bugfix/mdm fix
This commit is contained in:
Jens Kristian Villadsen
2021-06-30 10:50:02 +02:00
committed by GitHub
7 changed files with 49 additions and 27 deletions

View File

@@ -20,6 +20,7 @@
<artifactId>hapi-fhir-jpaserver-starter</artifactId>
<properties>
<spring_boot_version>2.5.2</spring_boot_version>
<java.version>8</java.version>
</properties>

View File

@@ -1,6 +1,6 @@
package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.jpa.mdm.MdmConfig;
import ca.uhn.fhir.jpa.starter.mdm.MdmConfig;
import ca.uhn.fhir.jpa.starter.annotations.OnEitherVersion;
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
@@ -29,6 +29,15 @@ public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
/*
* https://github.com/hapifhir/hapi-fhir-jpaserver-starter/issues/246
* This will be allowed for a short period until we know how MDM should be configured
* or don't have multiple equal bean instantiations.
*
* This will require changes in the main project as stated in the Github comment
* */
System.setProperty("spring.main.allow-bean-definition-overriding","true");
System.setProperty("spring.batch.job.enabled", "false");
SpringApplication.run(Application.class, args);

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.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,7 +101,11 @@ public class BaseJpaRestfulServer extends RestfulServer {
@Autowired(required = false)
IRepositoryValidationInterceptorFactory factory;
// These are set only if the features are enabled
private CqlProviderLoader cqlProviderLoader;
@Autowired
Optional<CqlProviderLoader> cqlProviderLoader;
@Autowired
Optional<MdmProviderLoader> mdmProviderProvider;
@Autowired
private IValidationSupport myValidationSupport;
@@ -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);
/*

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.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

View File

@@ -1,4 +1,4 @@
package ca.uhn.fhir.jpa.mdm;
package ca.uhn.fhir.jpa.starter.mdm;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.mdm.config.MdmConsumerConfig;
@@ -9,6 +9,7 @@ import ca.uhn.fhir.mdm.rules.config.MdmRuleValidator;
import ca.uhn.fhir.mdm.rules.config.MdmSettings;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
import com.google.common.base.Charsets;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -18,12 +19,6 @@ import org.springframework.context.annotation.Import;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import java.io.IOException;
/**
* TODO: Move this to package "ca.uhn.fhir.jpa.starter" in HAPI FHIR 5.2.0+. The lousy component scan
* in 5.1.0 picks this up even if MDM is disabled currently.
*/
@Configuration
@Conditional(MdmConfigCondition.class)
@Import({MdmConsumerConfig.class, MdmSubmitterConfig.class})

View File

@@ -1,4 +1,4 @@
package ca.uhn.fhir.jpa.mdm;
package ca.uhn.fhir.jpa.starter.mdm;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;

View File

@@ -81,6 +81,7 @@ hapi:
# filter_search_enabled: true
# graphql_enabled: true
# narrative_enabled: true
# mdm_enabled: true
# partitioning:
# allow_references_across_partitions: false
# partitioning_include_in_search_hashes: false
@@ -125,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