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 69abd21..3c53719 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.starter; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings.ClientIdStrategyEnum; +import ca.uhn.fhir.jpa.api.config.JpaStorageSettings.IdStrategyEnum; import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; import ca.uhn.fhir.jpa.packages.PackageInstallationSpec; import ca.uhn.fhir.rest.api.EncodingEnum; @@ -65,6 +66,7 @@ public class AppProperties { private EncodingEnum default_encoding = EncodingEnum.JSON; private FhirVersionEnum fhir_version = FhirVersionEnum.R4; private ClientIdStrategyEnum client_id_strategy = ClientIdStrategyEnum.ALPHANUMERIC; + private IdStrategyEnum server_id_strategy = null; private List supported_resource_types = new ArrayList<>(); private List allowed_bundle_types = null; private Boolean narrative_enabled = true; @@ -263,7 +265,15 @@ public Cors getCors() { this.client_id_strategy = client_id_strategy; } - public boolean getAdvanced_lucene_indexing() { + public IdStrategyEnum getServer_id_strategy() { + return server_id_strategy; + } + + public void setServer_id_strategy(IdStrategyEnum server_id_strategy) { + this.server_id_strategy = server_id_strategy; + } + + public boolean getAdvanced_lucene_indexing() { return this.advanced_lucene_indexing; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java index 3d9206e..1347028 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java @@ -174,10 +174,27 @@ public class FhirServerConfigCommon { jpaStorageSettings.setDeferIndexingForCodesystemsOfSize( appProperties.getDefer_indexing_for_codesystems_of_size()); + jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy()); + ourLog.info("Server configured to use '" + appProperties.getClient_id_strategy() + "' Client ID Strategy"); + + // Set and/or recommend default Server ID Strategy of UUID when using the ANY Client ID Strategy if (appProperties.getClient_id_strategy() == JpaStorageSettings.ClientIdStrategyEnum.ANY) { - jpaStorageSettings.setResourceServerIdStrategy(JpaStorageSettings.IdStrategyEnum.UUID); - jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy()); + if (appProperties.getServer_id_strategy() == null) { + ourLog.info("Defaulting server to use '" + JpaStorageSettings.IdStrategyEnum.UUID + + "' Server ID Strategy when using the '" + JpaStorageSettings.ClientIdStrategyEnum.ANY + + "' Client ID Strategy"); + appProperties.setServer_id_strategy(JpaStorageSettings.IdStrategyEnum.UUID); + } else if (appProperties.getServer_id_strategy() != JpaStorageSettings.IdStrategyEnum.UUID) { + ourLog.warn("WARNING: '" + JpaStorageSettings.IdStrategyEnum.UUID + + "' Server ID Strategy is highly recommended when using the '" + + JpaStorageSettings.ClientIdStrategyEnum.ANY + "' Client ID Strategy"); + } } + if (appProperties.getServer_id_strategy() != null) { + jpaStorageSettings.setResourceServerIdStrategy(appProperties.getServer_id_strategy()); + ourLog.info("Server configured to use '" + appProperties.getServer_id_strategy() + "' Server ID Strategy"); + } + // Parallel Batch GET execution settings jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size()); jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size()); diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 353815a..e59c338 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -139,6 +139,7 @@ hapi: # etag_support_enabled: true # expunge_enabled: true # client_id_strategy: ALPHANUMERIC + # server_id_strategy: SEQUENTIAL_NUMERIC # fhirpath_interceptor_enabled: false # filter_search_enabled: true # graphql_enabled: true