From 5eef970fbe87be0e8de99c2138cfac4ae9e49517 Mon Sep 17 00:00:00 2001 From: jvi Date: Tue, 8 Sep 2020 14:52:00 +0200 Subject: [PATCH] Added IG options --- pom.xml | 2 + .../uhn/fhir/jpa/starter/AppProperties.java | 50 +++++++++++++++++++ .../jpa/starter/BaseJpaRestfulServer.java | 20 +++++++- src/main/resources/application.yaml | 12 ++++- 4 files changed, 82 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 333a3ed..0e66d1c 100644 --- a/pom.xml +++ b/pom.xml @@ -487,6 +487,8 @@ + + boot diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index a18abf4..fd22023 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -10,6 +10,7 @@ import java.util.List; import com.google.common.collect.ImmutableList; import org.hl7.fhir.r4.model.Bundle; + import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; @@ -42,6 +43,7 @@ public class AppProperties { private Integer default_page_size = 20; private Integer max_binary_size = null; private Integer max_page_size = Integer.MAX_VALUE; + private Integer defer_indexing_for_codesystems_of_size = 100; private Long retain_cached_searches_mins = 60L; private Long reuse_cached_search_results_millis = 60000L; private String server_address = null; @@ -57,6 +59,23 @@ public class AppProperties { private Subscription subscription = new Subscription(); private Cors cors = null; private Partitioning partitioning = null; + private List implementationGuides = null; + + public Integer getDefer_indexing_for_codesystems_of_size() { + return defer_indexing_for_codesystems_of_size; + } + + public void setDefer_indexing_for_codesystems_of_size(Integer defer_indexing_for_codesystems_of_size) { + this.defer_indexing_for_codesystems_of_size = defer_indexing_for_codesystems_of_size; + } + + public List getImplementationGuides() { + return implementationGuides; + } + + public void setImplementationGuides(List implementationGuides) { + this.implementationGuides = implementationGuides; + } public Partitioning getPartitioning() { return partitioning; @@ -465,6 +484,37 @@ public class AppProperties { } } + public static class ImplementationGuide + { + private String url; + private String name; + private String version; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + } + public static class Validation { private Boolean requests_enabled = false; 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 616854b..814395f 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java @@ -10,6 +10,8 @@ import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor; import ca.uhn.fhir.jpa.bulk.provider.BulkDataExportProvider; import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; +import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; +import ca.uhn.fhir.jpa.packages.PackageInstallationSpec; import ca.uhn.fhir.jpa.partition.PartitionManagementProvider; import ca.uhn.fhir.jpa.provider.GraphQLProvider; import ca.uhn.fhir.jpa.provider.IJpaSystemProvider; @@ -87,6 +89,9 @@ public class BaseJpaRestfulServer extends RestfulServer { @Autowired BinaryStorageInterceptor binaryStorageInterceptor; + @Autowired + IPackageInstallerSvc packageInstallerSvc; + @Autowired AppProperties appProperties; @@ -162,7 +167,7 @@ public class BaseJpaRestfulServer extends RestfulServer { * ETag Support */ - if(appProperties.getEtag_support_enabled() == false) + if (appProperties.getEtag_support_enabled() == false) setETagSupport(ETagSupportEnum.DISABLED); @@ -320,6 +325,8 @@ public class BaseJpaRestfulServer extends RestfulServer { daoConfig.setBundleTypesAllowedForStorage(appProperties.getAllowed_bundle_types().stream().map(BundleType::toCode).collect(Collectors.toSet())); } + daoConfig.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size()); + // Bulk Export if (appProperties.getBulk_export_enabled()) { registerProvider(bulkDataExportProvider); @@ -336,6 +343,17 @@ public class BaseJpaRestfulServer extends RestfulServer { daoConfig.setResourceServerIdStrategy(DaoConfig.IdStrategyEnum.UUID); daoConfig.setResourceClientIdStrategy(appProperties.getClient_id_strategy()); } + + if (appProperties.getImplementationGuides() != null) { + List guides = appProperties.getImplementationGuides(); + for (AppProperties.ImplementationGuide guide : guides) { + packageInstallerSvc.install(new PackageInstallationSpec() + .setPackageUrl(guide.getUrl()) + .setName(guide.getName()) + .setVersion(guide.getVersion()) + .setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL)); + } + } } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b47792e..6841215 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -7,7 +7,7 @@ spring: max-active: 15 profiles: ### This is the FHIR version. Choose between, dstu2, dstu3, r4 or r5 - active: dstu2 + active: r4 jpa: properties: hibernate.dialect: org.hibernate.dialect.H2Dialect @@ -26,6 +26,16 @@ spring: hapi: fhir: + defer_indexing_for_codesystems_of_size: 101 + implementationguides: + - + url: https://build.fhir.org/ig/hl7dk/dk-medcom/branches/corrections/package.tgz + name: dk.fhir.ig.medcom-core + version: 0.8.0 + - + name: hl7.fhir.uv.ips + version: 0.3.0 + #supported_resource_types: # - Patient # - Observation