From b41c96f2594001ca2ac5280cb8f161487bf562ce Mon Sep 17 00:00:00 2001 From: "justin.mckelvy" Date: Mon, 15 May 2023 21:46:49 -0600 Subject: [PATCH] add executorService config --- .../fhir/cr/config/BaseClinicalReasoningConfig.java | 10 ++++++++++ .../java/ca/uhn/fhir/cr/r4/measure/MeasureService.java | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/BaseClinicalReasoningConfig.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/BaseClinicalReasoningConfig.java index ffc3a8725ed..f8c3b1c4fe4 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/BaseClinicalReasoningConfig.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/BaseClinicalReasoningConfig.java @@ -74,12 +74,15 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Scope; import org.springframework.security.concurrent.DelegatingSecurityContextExecutor; +import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService; import org.springframework.security.core.context.SecurityContextHolder; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.ForkJoinPool; @@ -303,6 +306,13 @@ public abstract class BaseClinicalReasoningConfig { SecurityContextHolder.getContext()); } + @Bean + public ExecutorService measureExecutor() { + ExecutorService executor = Executors.newFixedThreadPool(CrProperties.MeasureProperties.DEFAULT_THREADS_BATCH_SIZE); + executor = new DelegatingSecurityContextExecutorService(executor); + + return executor; + } @Bean public PreExpandedValidationSupportLoader preExpandedValidationSupportLoader(ValidationSupportChain theSupportChain, FhirContext theFhirContext) { diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java index 0d29c97768a..7258260b393 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java @@ -63,6 +63,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutorService; import static ca.uhn.fhir.cr.constant.MeasureReportConstants.COUNTRY_CODING_SYSTEM_CODE; import static ca.uhn.fhir.cr.constant.MeasureReportConstants.MEASUREREPORT_MEASURE_SUPPLEMENTALDATA_EXTENSION; @@ -141,6 +142,9 @@ public class MeasureService implements IDaoRegistryUser { @Autowired protected DaoRegistry myDaoRegistry; + @Autowired + private ExecutorService myMeasureExecutor; + protected RequestDetails myRequestDetails; public RequestDetails getRequestDetails() { @@ -194,6 +198,8 @@ public class MeasureService implements IDaoRegistryUser { TerminologyProvider terminologyProvider; + myMeasureEvaluationOptions.setMeasureExecutor(myMeasureExecutor); + if (theTerminologyEndpoint != null) { IGenericClient client = Clients.forEndpoint(getFhirContext(), theTerminologyEndpoint); terminologyProvider = new R4FhirTerminologyProvider(client);