Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 4821 back to master #4825

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
type: add
issue: 4821
title: "Update the clinical reasoning module version to the latest release of 3.0.0-PRE2"
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,20 @@
import ca.uhn.fhir.cr.common.IDataProviderFactory;
import ca.uhn.fhir.cr.common.IFhirDalFactory;
import ca.uhn.fhir.cr.common.ILibraryLoaderFactory;
import ca.uhn.fhir.cr.common.ILibraryManagerFactory;
import ca.uhn.fhir.cr.common.ILibrarySourceProviderFactory;
import ca.uhn.fhir.cr.common.ITerminologyProviderFactory;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet;
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
import org.cqframework.cql.cql2elm.CqlTranslatorOptions;
import org.cqframework.cql.cql2elm.LibraryManager;
import org.cqframework.cql.cql2elm.LibrarySourceProvider;
import org.cqframework.cql.cql2elm.ModelManager;
import org.cqframework.cql.cql2elm.model.Model;
import org.cqframework.cql.cql2elm.quick.FhirLibrarySourceProvider;
import org.hl7.cql.model.ModelIdentifier;
import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.opencds.cqf.cql.engine.data.CompositeDataProvider;
import org.opencds.cqf.cql.engine.fhir.model.Dstu3FhirModelResolver;
import org.opencds.cqf.cql.engine.fhir.model.R4FhirModelResolver;
Expand All @@ -61,14 +56,14 @@
import org.opencds.cqf.cql.evaluator.CqlOptions;
import org.opencds.cqf.cql.evaluator.builder.DataProviderComponents;
import org.opencds.cqf.cql.evaluator.builder.EndpointInfo;
import org.opencds.cqf.cql.evaluator.cql2elm.model.CacheAwareModelManager;
import org.opencds.cqf.cql.evaluator.cql2elm.util.LibraryVersionSelector;
import org.opencds.cqf.cql.evaluator.engine.execution.CacheAwareLibraryLoaderDecorator;
import org.opencds.cqf.cql.evaluator.engine.execution.TranslatingLibraryLoader;
import org.opencds.cqf.cql.evaluator.engine.model.CachingModelResolverDecorator;
import org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider;
import org.opencds.cqf.cql.evaluator.fhir.Constants;
import org.opencds.cqf.cql.evaluator.fhir.adapter.AdapterFactory;
import org.opencds.cqf.cql.evaluator.library.EvaluationSettings;
import org.opencds.cqf.cql.evaluator.measure.MeasureEvaluationOptions;
import org.opencds.cqf.cql.evaluator.spring.fhir.adapter.AdapterConfiguration;
import org.slf4j.Logger;
Expand All @@ -87,13 +82,22 @@
import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;

@Import(AdapterConfiguration.class)

@Configuration
public abstract class BaseClinicalReasoningConfig extends BaseRepositoryConfig {
@Import({AdapterConfiguration.class, BaseRepositoryConfig.class})
public abstract class BaseClinicalReasoningConfig {

private static final Logger ourLogger = LoggerFactory.getLogger(BaseClinicalReasoningConfig.class);

@Bean
EvaluationSettings evaluationSettings(CqlOptions theCqlOptions, Map<ModelIdentifier, Model> theGlobalModelCache, Map<org.cqframework.cql.elm.execution.VersionedIdentifier, org.cqframework.cql.elm.execution.Library> theGlobalLibraryCache) {
var evaluationSettings = new EvaluationSettings();
evaluationSettings.setCqlOptions(theCqlOptions);
evaluationSettings.setModelCache(theGlobalModelCache);
evaluationSettings.setLibraryCache(theGlobalLibraryCache);

return evaluationSettings;
}
@Bean
CrProviderFactory cqlProviderFactory() {
return new CrProviderFactory();
Expand Down Expand Up @@ -153,7 +157,7 @@ public CqlTranslatorOptions cqlTranslatorOptions(FhirContext theFhirContext, CrP
@Scope("prototype")
public ModelManager modelManager(
Map<ModelIdentifier, Model> theGlobalModelCache) {
return new CacheAwareModelManager(theGlobalModelCache);
return new ModelManager(theGlobalModelCache);
}

@Bean
Expand Down Expand Up @@ -229,15 +233,7 @@ ILibraryLoaderFactory libraryLoaderFactory(
lcp.add(new FhirLibrarySourceProvider());
}

return new CacheAwareLibraryLoaderDecorator(
new TranslatingLibraryLoader(theModelManager, lcp, theCqlTranslatorOptions, null), theGlobalLibraryCache) {
// TODO: This is due to a bug with the ELM annotations which prevent options
// from matching the way they should
@Override
protected Boolean translatorOptionsMatch(org.cqframework.cql.elm.execution.Library library) {
return true;
}
};
return new TranslatingLibraryLoader(theModelManager, lcp, theCqlTranslatorOptions, theGlobalLibraryCache);
};
}

Expand Down Expand Up @@ -296,7 +292,7 @@ public LibraryVersionSelector libraryVersionSelector(AdapterFactory theAdapterFa
return new LibraryVersionSelector(theAdapterFactory);
}

@Bean(name = "cqlExecutor")
@Bean
public Executor cqlExecutor() {
CqlForkJoinWorkerThreadFactory factory = new CqlForkJoinWorkerThreadFactory();
ForkJoinPool myCommonPool = new ForkJoinPool(Math.min(32767, Runtime.getRuntime().availableProcessors()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Import(AdapterConfiguration.class)
@Configuration
public abstract class BaseRepositoryConfig {
@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Scope;

import java.util.function.Function;

@Configuration
public class CrDstu3Config extends BaseClinicalReasoningConfig {
@Import(BaseClinicalReasoningConfig.class)
public class CrDstu3Config {

@Bean
public Function<RequestDetails, MeasureService> dstu3MeasureServiceFactory(ApplicationContext theApplicationContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Scope;

import java.util.concurrent.Executor;
import java.util.function.Function;

@Configuration
public class CrR4Config extends BaseClinicalReasoningConfig {
@Import(BaseClinicalReasoningConfig.class)
public class CrR4Config {

@Bean
public Function<RequestDetails, MeasureService> r4MeasureServiceFactory(ApplicationContext theApplicationContext) {
Expand All @@ -61,10 +64,10 @@ public MeasureOperationsProvider r4measureOperationsProvider() {
@Bean
public Function<RequestDetails, CareGapsService> r4CareGapsServiceFactory(Function<RequestDetails, MeasureService> theR4MeasureServiceFactory,
CrProperties theCrProperties,
DaoRegistry theDaoRegistry) {
DaoRegistry theDaoRegistry, Executor cqlExecutor) {
return r -> {
var ms = theR4MeasureServiceFactory.apply(r);
var cs = new CareGapsService(theCrProperties, ms, theDaoRegistry, cqlExecutor(), r);
var cs = new CareGapsService(theCrProperties, ms, theDaoRegistry, cqlExecutor, r);
return cs;
};
}
Expand Down
Loading