From a1f7df822147bdf0d34619221f966778418a4edd Mon Sep 17 00:00:00 2001 From: JP Date: Wed, 16 Oct 2024 13:04:40 -0600 Subject: [PATCH] Copy constructors for settings classes (#564) * clone() for EvaluationSettins, RetrieveSetttings, and TerminologySettings * Clean up * Add copy constructors --- .../opencds/cqf/fhir/benchmark/Measures.java | 22 +- .../benchmark/MeasuresAdditionalData.java | 22 +- .../org/opencds/cqf/fhir/cql/Engines.java | 3 +- .../cqf/fhir/cql/EvaluationSettings.java | 227 +++++++++--------- .../opencds/cqf/fhir/cql/LibraryEngine.java | 11 +- .../cql/engine/retrieve/RetrieveSettings.java | 17 ++ .../terminology/TerminologySettings.java | 18 ++ .../org/opencds/cqf/fhir/cql/EnginesTest.java | 8 +- .../cqf/fhir/cql/LibraryEngineTests.java | 4 +- .../cqf/fhir/cr/cli/command/CqlCommand.java | 12 +- .../r4/MeasureProcessorEvaluateTest.java | 42 ++-- 11 files changed, 189 insertions(+), 197 deletions(-) diff --git a/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/Measures.java b/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/Measures.java index 0efd3304a..24ac7c6c5 100644 --- a/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/Measures.java +++ b/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/Measures.java @@ -32,22 +32,16 @@ public class Measures { @Setup(Level.Trial) public void setupTrial() throws Exception { var evaluationOptions = MeasureEvaluationOptions.defaultOptions(); - - var retrieveSettings = evaluationOptions.getEvaluationSettings().getRetrieveSettings(); - retrieveSettings + evaluationOptions.getEvaluationSettings().setLibraryCache(new HashMap<>()); + evaluationOptions + .getEvaluationSettings() + .getRetrieveSettings() .setSearchParameterMode(SEARCH_FILTER_MODE.FILTER_IN_MEMORY) .setTerminologyParameterMode(TERMINOLOGY_FILTER_MODE.FILTER_IN_MEMORY); - - var terminologySettings = evaluationOptions.getEvaluationSettings().getTerminologySettings(); - terminologySettings.setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); - - var settingsBuilder = evaluationOptions.getEvaluationSettings().toBuilder(); - - settingsBuilder.libraryCache(new HashMap<>()); - settingsBuilder.retrieveSettings(retrieveSettings); - settingsBuilder.terminologySettings(terminologySettings); - - evaluationOptions.setEvaluationSettings(settingsBuilder.build()); + evaluationOptions + .getEvaluationSettings() + .getTerminologySettings() + .setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); this.when = Measure.given() .repositoryFor("CaseRepresentation101") diff --git a/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/MeasuresAdditionalData.java b/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/MeasuresAdditionalData.java index aa6b0e572..1fc8fa192 100644 --- a/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/MeasuresAdditionalData.java +++ b/cqf-fhir-benchmark/src/test/java/org/opencds/cqf/fhir/benchmark/MeasuresAdditionalData.java @@ -34,22 +34,16 @@ public class MeasuresAdditionalData { @Setup(Level.Trial) public void setupTrial() throws Exception { var evaluationOptions = MeasureEvaluationOptions.defaultOptions(); - - var retrieveSettings = evaluationOptions.getEvaluationSettings().getRetrieveSettings(); - retrieveSettings + evaluationOptions.getEvaluationSettings().setLibraryCache(new HashMap<>()); + evaluationOptions + .getEvaluationSettings() + .getRetrieveSettings() .setSearchParameterMode(SEARCH_FILTER_MODE.FILTER_IN_MEMORY) .setTerminologyParameterMode(TERMINOLOGY_FILTER_MODE.FILTER_IN_MEMORY); - - var terminologySettings = evaluationOptions.getEvaluationSettings().getTerminologySettings(); - terminologySettings.setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); - - var settingsBuilder = evaluationOptions.getEvaluationSettings().toBuilder(); - - settingsBuilder.libraryCache(new HashMap<>()); - settingsBuilder.retrieveSettings(retrieveSettings); - settingsBuilder.terminologySettings(terminologySettings); - - evaluationOptions.setEvaluationSettings(settingsBuilder.build()); + evaluationOptions + .getEvaluationSettings() + .getTerminologySettings() + .setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); Bundle additionalData = (Bundle) FhirContext.forR4Cached() .newJsonParser() diff --git a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/Engines.java b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/Engines.java index 9e713f10a..7521063d4 100644 --- a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/Engines.java +++ b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/Engines.java @@ -150,8 +150,7 @@ private static Map buildDataProviders( var providers = new ArrayList(); var modelResolver = FhirModelResolverCache.resolverForVersion( repository.fhirContext().getVersion().getVersion()); - // TODO: Make a federated repository here once that is ready for sure - // var fedRepo = new FederatedRepository(repository, bundleRepo); + var retrieveProvider = new RepositoryRetrieveProvider(repository, terminologyProvider, retrieveSettings); providers.add(retrieveProvider); if (additionalData != null && modelResolver.resolvePath(additionalData, "entry") != null) { diff --git a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/EvaluationSettings.java b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/EvaluationSettings.java index 50fd6ac88..752cd3dbf 100644 --- a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/EvaluationSettings.java +++ b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/EvaluationSettings.java @@ -14,162 +14,151 @@ import org.opencds.cqf.fhir.cql.engine.retrieve.RetrieveSettings; import org.opencds.cqf.fhir.cql.engine.terminology.TerminologySettings; -/** - * This class contains settings used to set up CQL evaluation. This class is immutable once constructed. - * Use the Builder to create and instance of this class, and the "toBuilder()" function to create a - * new mutable builder to clone these settings if required. - */ public class EvaluationSettings { - private final Map modelCache; - private final Map libraryCache; - private final Map> valueSetCache; - private final List librarySourceProviders; - private final CqlOptions cqlOptions; - private final RetrieveSettings retrieveSettings; - private final TerminologySettings terminologySettings; - private final NpmProcessor npmProcessor; - - private EvaluationSettings( - Map modelCache, - Map libraryCache, - Map> valueSetCache, - List librarySourceProviders, - CqlOptions cqlOptions, - RetrieveSettings retrieveSettings, - TerminologySettings terminologySettings, - NpmProcessor npmProcessor) { - this.modelCache = modelCache; - this.libraryCache = libraryCache; - this.valueSetCache = valueSetCache; - this.librarySourceProviders = librarySourceProviders; - this.cqlOptions = cqlOptions; - this.retrieveSettings = retrieveSettings; - this.terminologySettings = terminologySettings; - this.npmProcessor = npmProcessor; - } + private Map modelCache; + private Map libraryCache; + private Map> valueSetCache; + private List librarySourceProviders; + + private CqlOptions cqlOptions; + + private RetrieveSettings retrieveSettings; + private TerminologySettings terminologySettings; + private NpmProcessor npmProcessor; - public static EvaluationSettings.Builder builder() { - return new Builder(); + public static EvaluationSettings getDefault() { + return new EvaluationSettings(); } - public EvaluationSettings.Builder toBuilder() { - return new EvaluationSettings.Builder() - .cqlOptions(this.cqlOptions) - .modelCache(this.modelCache) - .libraryCache(this.libraryCache) - .valueSetCache(this.valueSetCache) - .retrieveSettings(this.retrieveSettings) - .terminologySettings(this.terminologySettings) - .librarySourceProviders(new ArrayList<>(this.librarySourceProviders)) - .npmProcessor(this.npmProcessor); + EvaluationSettings() { + this.modelCache = new ConcurrentHashMap<>(); + this.libraryCache = new ConcurrentHashMap<>(); + this.valueSetCache = new ConcurrentHashMap<>(); + this.librarySourceProviders = new ArrayList<>(); + this.cqlOptions = CqlOptions.defaultOptions(); + this.retrieveSettings = new RetrieveSettings(); + this.terminologySettings = new TerminologySettings(); + this.npmProcessor = null; } - public static EvaluationSettings getDefault() { - var options = CqlOptions.defaultOptions(); - var builder = new EvaluationSettings.Builder() - .cqlOptions(options) - .modelCache(new ConcurrentHashMap<>()) - .libraryCache(new ConcurrentHashMap<>()) - .valueSetCache(new ConcurrentHashMap<>()) - .retrieveSettings(new RetrieveSettings()) - .terminologySettings(new TerminologySettings()) - .librarySourceProviders(new ArrayList<>()); - return builder.build(); + /** + * Copy constructor for EvaluationSettings + * @param settings + */ + public EvaluationSettings(EvaluationSettings settings) { + this.modelCache = new ConcurrentHashMap<>(settings.modelCache); + this.libraryCache = new ConcurrentHashMap<>(settings.libraryCache); + this.valueSetCache = new ConcurrentHashMap<>(settings.valueSetCache); + this.cqlOptions = settings.cqlOptions; + this.retrieveSettings = new RetrieveSettings(settings.retrieveSettings); + this.terminologySettings = new TerminologySettings(settings.terminologySettings); + this.librarySourceProviders = new ArrayList<>(settings.librarySourceProviders); + this.npmProcessor = + settings.npmProcessor != null ? new NpmProcessor(settings.npmProcessor.getIgContext()) : null; } public Map getModelCache() { return this.modelCache; } + public void setModelCache(Map modelCache) { + this.modelCache = modelCache; + } + + public EvaluationSettings withModelCache(Map modelCache) { + setModelCache(modelCache); + return this; + } + public Map getLibraryCache() { return this.libraryCache; } + public void setLibraryCache(Map libraryCache) { + this.libraryCache = libraryCache; + } + + public EvaluationSettings withLibraryCache(Map libraryCache) { + setLibraryCache(libraryCache); + return this; + } + public Map> getValueSetCache() { return this.valueSetCache; } + public void setValueSetCache(Map> valueSetCache) { + this.valueSetCache = valueSetCache; + } + + public EvaluationSettings withValueSetCache(Map> valueSetCache) { + setValueSetCache(valueSetCache); + return this; + } + public CqlOptions getCqlOptions() { return this.cqlOptions; } + public EvaluationSettings withCqlOptions(CqlOptions cqlOptions) { + setCqlOptions(cqlOptions); + return this; + } + + public void setCqlOptions(CqlOptions cqlOptions) { + this.cqlOptions = cqlOptions; + } + public RetrieveSettings getRetrieveSettings() { return this.retrieveSettings; } + public EvaluationSettings withRetrieveSettings(RetrieveSettings retrieveSettings) { + setRetrieveSettings(retrieveSettings); + return this; + } + + public void setRetrieveSettings(RetrieveSettings retrieveSettings) { + this.retrieveSettings = retrieveSettings; + } + public TerminologySettings getTerminologySettings() { return this.terminologySettings; } + public EvaluationSettings withTerminologySettings(TerminologySettings terminologySettings) { + setTerminologySettings(terminologySettings); + return this; + } + + public void setTerminologySettings(TerminologySettings terminologySettings) { + this.terminologySettings = terminologySettings; + } + public List getLibrarySourceProviders() { return librarySourceProviders; } + public void setLibrarySourceProviders(List librarySourceProviders) { + this.librarySourceProviders = librarySourceProviders; + } + + public EvaluationSettings withLibrarySourceProviders(List librarySourceProviders) { + setLibrarySourceProviders(librarySourceProviders); + return this; + } + public NpmProcessor getNpmProcessor() { - return this.npmProcessor; - } - - public static class Builder { - private Map modelCache; - private Map libraryCache; - private Map> valueSetCache; - private List librarySourceProviders; - private CqlOptions cqlOptions; - private RetrieveSettings retrieveSettings; - private TerminologySettings terminologySettings; - private NpmProcessor npmProcessor; - - public Builder modelCache(Map modelCache) { - this.modelCache = modelCache; - return this; - } - - public Builder libraryCache(Map libraryCache) { - this.libraryCache = libraryCache; - return this; - } - - public Builder valueSetCache(Map> valueSetCache) { - this.valueSetCache = valueSetCache; - return this; - } - - public Builder librarySourceProviders(List librarySourceProviders) { - this.librarySourceProviders = librarySourceProviders; - return this; - } - - public Builder cqlOptions(CqlOptions cqlOptions) { - this.cqlOptions = cqlOptions; - return this; - } - - public Builder retrieveSettings(RetrieveSettings retrieveSettings) { - this.retrieveSettings = retrieveSettings; - return this; - } - - public Builder terminologySettings(TerminologySettings terminologySettings) { - this.terminologySettings = terminologySettings; - return this; - } - - public Builder npmProcessor(NpmProcessor npmProcessor) { - this.npmProcessor = npmProcessor; - return this; - } - - public EvaluationSettings build() { - return new EvaluationSettings( - this.modelCache, - this.libraryCache, - this.valueSetCache, - this.librarySourceProviders, - this.cqlOptions, - this.retrieveSettings, - this.terminologySettings, - this.npmProcessor); - } + return npmProcessor; + } + + public void setNpmProcessor(NpmProcessor npmProcessor) { + this.npmProcessor = npmProcessor; + } + + public EvaluationSettings withNpmProcessor(NpmProcessor npmProcessor) { + setNpmProcessor(npmProcessor); + return this; } } diff --git a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/LibraryEngine.java b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/LibraryEngine.java index 1e20293fc..91064b0c1 100644 --- a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/LibraryEngine.java +++ b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/LibraryEngine.java @@ -15,7 +15,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.cqframework.cql.cql2elm.LibrarySourceProvider; import org.cqframework.cql.cql2elm.StringLibrarySourceProvider; import org.hl7.elm.r1.VersionedIdentifier; import org.hl7.fhir.instance.model.api.IBase; @@ -129,16 +128,12 @@ public IBaseParameters evaluateExpression( Set expressions = new HashSet<>(); expressions.add("return"); - List librarySourceProviders = new ArrayList<>(); - librarySourceProviders.add(new StringLibrarySourceProvider(Lists.newArrayList(cql))); + var requestSettings = new EvaluationSettings(settings); - var requestSettings = settings.toBuilder().libraryCache(null).build(); + requestSettings.getLibrarySourceProviders().add(new StringLibrarySourceProvider(Lists.newArrayList(cql))); var engine = Engines.forRepository(repository, requestSettings, bundle); - var providers = engine.getEnvironment().getLibraryManager().getLibrarySourceLoader(); - for (var source : librarySourceProviders) { - providers.registerProvider(source); - } + var evaluationParameters = cqlFhirParametersConverter.toCqlParameters(parameters); if (contextParameter != null) { evaluationParameters.put("%fhirpathcontext", contextParameter); diff --git a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/retrieve/RetrieveSettings.java b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/retrieve/RetrieveSettings.java index bc21977cf..9a3e66db0 100644 --- a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/retrieve/RetrieveSettings.java +++ b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/retrieve/RetrieveSettings.java @@ -6,6 +6,23 @@ public class RetrieveSettings { private PROFILE_MODE profileMode = PROFILE_MODE.OFF; private TERMINOLOGY_FILTER_MODE terminologyParameterMode = TERMINOLOGY_FILTER_MODE.AUTO; + /** + * Default constructor for RetrieveSettings + */ + public RetrieveSettings() { + // intentionally empty + } + + /** + * Copy constructor for RetrieveSettings + * @param retrieveSettings + */ + public RetrieveSettings(RetrieveSettings retrieveSettings) { + this.searchParameterMode = retrieveSettings.searchParameterMode; + this.profileMode = retrieveSettings.profileMode; + this.terminologyParameterMode = retrieveSettings.terminologyParameterMode; + } + // Decreasing order of performance // Applies to all search parameters // EXCEPT terminology search parameters, which are controlled by the terminology settings. diff --git a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/terminology/TerminologySettings.java b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/terminology/TerminologySettings.java index 4fa4ca26e..1bad0fd96 100644 --- a/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/terminology/TerminologySettings.java +++ b/cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/terminology/TerminologySettings.java @@ -60,6 +60,24 @@ public enum CODE_LOOKUP_MODE { private CODE_LOOKUP_MODE codeLookupMode = CODE_LOOKUP_MODE.AUTO; private VALUESET_PRE_EXPANSION_MODE valueSetPreExpansionMode = VALUESET_PRE_EXPANSION_MODE.USE_IF_PRESENT; + /* + * Default constructor for TerminologySettings + */ + public TerminologySettings() { + // intentionally empty + } + + /** + * Copy constructor for TerminologySettings + * @param terminologySettings + */ + public TerminologySettings(TerminologySettings terminologySettings) { + this.valuesetExpansionMode = terminologySettings.valuesetExpansionMode; + this.valuesetMembershipMode = terminologySettings.valuesetMembershipMode; + this.codeLookupMode = terminologySettings.codeLookupMode; + this.valueSetPreExpansionMode = terminologySettings.valueSetPreExpansionMode; + } + public VALUESET_EXPANSION_MODE getValuesetExpansionMode() { return valuesetExpansionMode; } diff --git a/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/EnginesTest.java b/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/EnginesTest.java index 0ddcce415..4b5fd991f 100644 --- a/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/EnginesTest.java +++ b/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/EnginesTest.java @@ -45,14 +45,12 @@ void npmProcessor() { var repository = mock(Repository.class); when(repository.fhirContext()).thenReturn(FhirContext.forR4Cached()); - var igContext = new IGContext(new LoggerAdapter(log)); - var resourceDirectory = ResourceDirectoryResolver.getResourceDirectory(); var ini = resourceDirectory.resolve("org/opencds/cqf/fhir/cql/npm/ig.ini"); + + var igContext = new IGContext(new LoggerAdapter(log)); igContext.initializeFromIni(ini.toString()); - var settings = EvaluationSettings.getDefault().toBuilder() - .npmProcessor(new NpmProcessor(igContext)) - .build(); + var settings = EvaluationSettings.getDefault().withNpmProcessor(new NpmProcessor(igContext)); var engine = Engines.forRepository(repository, settings); var lm = engine.getEnvironment().getLibraryManager(); diff --git a/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/LibraryEngineTests.java b/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/LibraryEngineTests.java index dbc65fa5e..c78ca9f35 100644 --- a/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/LibraryEngineTests.java +++ b/cqf-fhir-cql/src/test/java/org/opencds/cqf/fhir/cql/LibraryEngineTests.java @@ -142,9 +142,7 @@ public InputStream getLibraryContent(VersionedIdentifier libraryIdentifier, Libr else return LibrarySourceProvider.super.getLibraryContent(libraryIdentifier, type); } }); - var evaluationSettings = EvaluationSettings.getDefault().toBuilder() - .librarySourceProviders(libraryResourceProvider) - .build(); + var evaluationSettings = EvaluationSettings.getDefault().withLibrarySourceProviders(libraryResourceProvider); libraryEngine = new LibraryEngine(repository, evaluationSettings); repository.create(new Patient().addName(new HumanName().addGiven("me")).setId("Patient/Patient1")); diff --git a/cqf-fhir-cr-cli/src/main/java/org/opencds/cqf/fhir/cr/cli/command/CqlCommand.java b/cqf-fhir-cr-cli/src/main/java/org/opencds/cqf/fhir/cr/cli/command/CqlCommand.java index 524f92bd4..dd92ea29a 100644 --- a/cqf-fhir-cr-cli/src/main/java/org/opencds/cqf/fhir/cr/cli/command/CqlCommand.java +++ b/cqf-fhir-cr-cli/src/main/java/org/opencds/cqf/fhir/cr/cli/command/CqlCommand.java @@ -189,16 +189,16 @@ public Integer call() throws Exception { retrieveSettings.setSearchParameterMode(SEARCH_FILTER_MODE.FILTER_IN_MEMORY); retrieveSettings.setProfileMode(PROFILE_MODE.DECLARED); - var settingsBuilder = EvaluationSettings.getDefault().toBuilder() - .cqlOptions(cqlOptions) - .terminologySettings(terminologySettings) - .retrieveSettings(retrieveSettings) - .npmProcessor(new NpmProcessor(igContext)); + var evaluationSettings = EvaluationSettings.getDefault(); + evaluationSettings.setCqlOptions(cqlOptions); + evaluationSettings.setTerminologySettings(terminologySettings); + evaluationSettings.setRetrieveSettings(retrieveSettings); + evaluationSettings.setNpmProcessor(new NpmProcessor(igContext)); for (LibraryParameter library : libraries) { var repository = createRepository( fhirContext, library.terminologyUrl, library.model.modelUrl, library.context.contextValue); - var engine = Engines.forRepository(repository, settingsBuilder.build()); + var engine = Engines.forRepository(repository, evaluationSettings); if (library.libraryUrl != null) { var provider = new DefaultLibrarySourceProvider(Path.of(library.libraryUrl)); diff --git a/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java b/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java index 79e1a5e00..e9cafd700 100644 --- a/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java +++ b/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java @@ -157,22 +157,17 @@ void measure_eval_with_parameters_ip_den_num() { @Test void with_custom_options() { var evaluationOptions = MeasureEvaluationOptions.defaultOptions(); - - var retrieveSettings = evaluationOptions.getEvaluationSettings().getRetrieveSettings(); - retrieveSettings + evaluationOptions.getEvaluationSettings().setLibraryCache(new HashMap<>()); + evaluationOptions + .getEvaluationSettings() + .getRetrieveSettings() .setSearchParameterMode(SEARCH_FILTER_MODE.FILTER_IN_MEMORY) .setTerminologyParameterMode(TERMINOLOGY_FILTER_MODE.FILTER_IN_MEMORY); - var terminologySettings = evaluationOptions.getEvaluationSettings().getTerminologySettings(); - terminologySettings.setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); - - var settingsBuilder = evaluationOptions.getEvaluationSettings().toBuilder(); - - settingsBuilder.libraryCache(new HashMap<>()); - settingsBuilder.retrieveSettings(retrieveSettings); - settingsBuilder.terminologySettings(terminologySettings); - - evaluationOptions.setEvaluationSettings(settingsBuilder.build()); + evaluationOptions + .getEvaluationSettings() + .getTerminologySettings() + .setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); var when = Measure.given() .repositoryFor("CaseRepresentation101") @@ -194,22 +189,17 @@ void with_custom_options() { @Test void additional_data_with_custom_options() { var evaluationOptions = MeasureEvaluationOptions.defaultOptions(); - - var retrieveSettings = evaluationOptions.getEvaluationSettings().getRetrieveSettings(); - retrieveSettings + evaluationOptions.getEvaluationSettings().setLibraryCache(new HashMap<>()); + evaluationOptions + .getEvaluationSettings() + .getRetrieveSettings() .setSearchParameterMode(SEARCH_FILTER_MODE.FILTER_IN_MEMORY) .setTerminologyParameterMode(TERMINOLOGY_FILTER_MODE.FILTER_IN_MEMORY); - var terminologySettings = evaluationOptions.getEvaluationSettings().getTerminologySettings(); - terminologySettings.setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); - - var settingsBuilder = evaluationOptions.getEvaluationSettings().toBuilder(); - - settingsBuilder.libraryCache(new HashMap<>()); - settingsBuilder.retrieveSettings(retrieveSettings); - settingsBuilder.terminologySettings(terminologySettings); - - evaluationOptions.setEvaluationSettings(settingsBuilder.build()); + evaluationOptions + .getEvaluationSettings() + .getTerminologySettings() + .setValuesetExpansionMode(VALUESET_EXPANSION_MODE.PERFORM_NAIVE_EXPANSION); Bundle additionalData = (Bundle) FhirContext.forR4Cached() .newJsonParser()