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 58c5bac..cfbf8b6 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -100,6 +100,11 @@ public class AppProperties { private boolean userRequestRetryVersionConflictsInterceptorEnabled = false; private List search_prefetch_thresholds = new ArrayList<>(); + private Boolean pre_expand_value_sets = true; + private Boolean enable_task_pre_expand_value_sets = true; + private Integer pre_expand_value_sets_default_count = 1000; + private Integer pre_expand_value_sets_max_count = 1000; + private Integer maximum_expansion_size = 1000; public List getCustomInterceptorClasses() { return custom_interceptor_classes; @@ -678,6 +683,46 @@ public class AppProperties { this.resource_dbhistory_enabled = resource_dbhistory_enabled; } + public Boolean getPre_expand_value_sets() { + return this.pre_expand_value_sets; + } + + public void setPre_expand_value_sets(Boolean pre_expand_value_sets) { + this.pre_expand_value_sets = pre_expand_value_sets; + } + + public Boolean getEnable_task_pre_expand_value_sets() { + return this.enable_task_pre_expand_value_sets; + } + + public void setEnable_task_pre_expand_value_setss(Boolean enable_task_pre_expand_value_sets) { + this.enable_task_pre_expand_value_sets = enable_task_pre_expand_value_sets; + } + + public Integer getPre_expand_value_sets_default_count() { + return pre_expand_value_sets_default_count; + } + + public void setPre_expand_value_sets_default_count(Integer pre_expand_value_sets_default_count) { + this.pre_expand_value_sets_default_count = pre_expand_value_sets_default_count; + } + + public Integer getPre_expand_value_sets_max_count() { + return pre_expand_value_sets_max_count; + } + + public void setPre_expand_value_sets_max_count(Integer pre_expand_value_sets_max_count) { + this.pre_expand_value_sets_max_count = pre_expand_value_sets_max_count; + } + + public Integer getMaximum_expansion_size() { + return maximum_expansion_size; + } + + public void setMaximum_expansion_size(Integer maximum_expansion_size) { + this.maximum_expansion_size = maximum_expansion_size; + } + public static class Cors { private Boolean allow_Credentials = true; private List allowed_origin = List.of("*"); @@ -879,6 +924,8 @@ public class AppProperties { private Boolean resthook_enabled = false; private Boolean websocket_enabled = false; private Email email = null; + private Integer polling_interval_ms = null; + private Boolean immediately_queued = false; public Boolean getResthook_enabled() { return resthook_enabled; @@ -904,6 +951,22 @@ public class AppProperties { this.email = email; } + public Integer getPolling_interval_ms() { + return polling_interval_ms; + } + + public void setPolling_interval_ms(Integer polling_interval_ms) { + this.polling_interval_ms = polling_interval_ms; + } + + public Boolean getImmediately_queued() { + return immediately_queued; + } + + public void setImmediately_queued(Boolean immediately_queued) { + this.immediately_queued = immediately_queued; + } + public static class Email { private String from; private String host; 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 f77d3b2..3abbed5 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 @@ -88,6 +88,18 @@ public class FhirServerConfigCommon { if (appProperties.getEnable_index_contained_resource() == Boolean.TRUE) { ourLog.info("Indexed on contained resource enabled"); } + + ourLog.info("Server configured to " + (appProperties.getPre_expand_value_sets() ? "enable" : "disable") + + " value set pre-expansion"); + ourLog.info( + "Server configured to " + (appProperties.getEnable_task_pre_expand_value_sets() ? "enable" : "disable") + + " value set pre-expansion task"); + ourLog.info("Server configured for pre-expand value set default count of " + + (appProperties.getPre_expand_value_sets_default_count().toString())); + ourLog.info("Server configured for pre-expand value set max count of " + + (appProperties.getPre_expand_value_sets_default_count().toString())); + ourLog.info("Server configured for maximum expansion size of " + + (appProperties.getPre_expand_value_sets_default_count().toString())); } @Bean @@ -114,6 +126,18 @@ public class FhirServerConfigCommon { subscriptionSettings.addSupportedSubscriptionType( org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET); } + if (appProperties.getSubscription().getPolling_interval_ms() != null) { + ourLog.info( + "Setting subscription polling interval to {} ms", + appProperties.getSubscription().getPolling_interval_ms()); + subscriptionSettings.setSubscriptionIntervalInMs( + appProperties.getSubscription().getPolling_interval_ms()); + } + if (appProperties.getSubscription().getImmediately_queued()) { + ourLog.info("Subscription update will be queued immediately"); + subscriptionSettings.setSubscriptionChangeQueuedImmediately( + appProperties.getSubscription().getImmediately_queued()); + } } if (appProperties.getMdm_enabled()) { // MDM requires the subscription of type message @@ -130,6 +154,12 @@ public class FhirServerConfigCommon { public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) { JpaStorageSettings jpaStorageSettings = new JpaStorageSettings(); + jpaStorageSettings.setPreExpandValueSets(appProperties.getPre_expand_value_sets()); + jpaStorageSettings.setEnableTaskPreExpandValueSets(appProperties.getEnable_task_pre_expand_value_sets()); + jpaStorageSettings.setPreExpandValueSetsDefaultCount(appProperties.getPre_expand_value_sets_default_count()); + jpaStorageSettings.setPreExpandValueSetsMaxCount(appProperties.getPre_expand_value_sets_max_count()); + jpaStorageSettings.setMaximumExpansionSize(appProperties.getMaximum_expansion_size()); + jpaStorageSettings.setIndexMissingFields( appProperties.getEnable_index_missing_fields() ? StorageSettings.IndexEnabledEnum.ENABLED diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java index 167dc77..386c503 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java @@ -32,6 +32,7 @@ import ca.uhn.fhir.jpa.model.config.SubscriptionSettings; import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; import ca.uhn.fhir.jpa.packages.PackageInstallationSpec; import ca.uhn.fhir.jpa.provider.DaoRegistryResourceSupportedSvc; +import ca.uhn.fhir.jpa.provider.DiffProvider; import ca.uhn.fhir.jpa.provider.IJpaSystemProvider; import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider; import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; @@ -289,7 +290,8 @@ public class StarterJpaConfig { ThreadSafeResourceDeleterSvc theThreadSafeResourceDeleterSvc, ApplicationContext appContext, Optional theIpsOperationProvider, - Optional implementationGuideOperationProvider) { + Optional implementationGuideOperationProvider, + DiffProvider diffProvider) { RestfulServer fhirServer = new RestfulServer(fhirSystemDao.getContext()); List supportedResourceTypes = appProperties.getSupported_resource_types(); @@ -458,6 +460,9 @@ public class StarterJpaConfig { // Validation repositoryValidatingInterceptor.ifPresent(fhirServer::registerInterceptor); + // Diff Provider + fhirServer.registerProvider(diffProvider); + // register custom interceptors registerCustomInterceptors(fhirServer, appContext, appProperties.getCustomInterceptorClasses()); diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 5165d9c..a0756d6 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -218,6 +218,12 @@ hapi: # userRequestRetryVersionConflictsInterceptorEnabled : false # local_base_urls: # - https://hapi.fhir.org/baseR4 + # pre_expand_value_sets: true + # enable_task_pre_expand_value_sets: true + # pre_expand_value_sets_default_count: 1000 + # pre_expand_value_sets_max_count: 1000 + # maximum_expansion_size: 1000 + logical_urls: - http://terminology.hl7.org/* - https://terminology.hl7.org/* @@ -303,6 +309,8 @@ hapi: # subscription: # resthook_enabled: true # websocket_enabled: false +# polling_interval_ms: 5000 +# immediately_queued: false # email: # from: some@test.com # host: google.com diff --git a/src/main/resources/cds.application.yaml b/src/main/resources/cds.application.yaml index e94030c..90d4da7 100644 --- a/src/main/resources/cds.application.yaml +++ b/src/main/resources/cds.application.yaml @@ -215,6 +215,13 @@ hapi: mdm_rules_json_location: "mdm-rules.json" # local_base_urls: # - https://hapi.fhir.org/baseR4 + + # pre_expand_value_sets: true + # enable_task_pre_expand_value_sets: true + # pre_expand_value_sets_default_count: 1000 + # pre_expand_value_sets_max_count: 1000 + # maximum_expansion_size: 1000 + logical_urls: - http://terminology.hl7.org/* - https://terminology.hl7.org/* diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java index b33dc74..d8044d8 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java @@ -325,6 +325,39 @@ class ExampleServerR4IT implements IServerSupport { } + @Test + void testDiffOperationIsRegistered() { + String methodName = "testDiff"; + ourLog.info("Entering " + methodName + "()..."); + + Patient pt = new Patient(); + pt.setActive(true); + pt.getBirthDateElement().setValueAsString("2020-01-01"); + pt.addIdentifier().setSystem("http://foo").setValue("12345"); + pt.addName().setFamily(methodName); + IIdType id = ourClient.create().resource(pt).execute().getId(); + + //now update the patient + pt.setId(id); + pt.getBirthDateElement().setValueAsString("2025-01-01"); + ourClient.update().resource(pt).execute(); + + //now try a diff + Parameters outParams = ourClient.operation().onInstance(id).named("$diff").withNoParameters(Parameters.class).execute(); + ourLog.trace("Params->\n{}", ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outParams)); + boolean foundDobChange = false; + //really, if we get a response at all, then the Diff worked, but we'll check the contents here anyway for good measure to see that our change is reflected + for(Parameters.ParametersParameterComponent ppc : outParams.getParameter() ) { + for(Parameters.ParametersParameterComponent ppc2 : ppc.getPart() ) { + if( "Patient.birthDate".equals(ppc2.getValue().toString()) ){ + foundDobChange = true; + break; + } + } + } + assertTrue(foundDobChange); + } + @BeforeEach void beforeEach() { @@ -338,4 +371,5 @@ class ExampleServerR4IT implements IServerSupport { // return activeSubscriptionCount() == 2; // 2 subscription based on mdm-rules.json //}); } + }