Update Clinical Reasoning plugin (#692)
* Reproducing issues with CR/HAPI cds-hooks processing * Add new $questionnaire operation * Update StarterIpsConfig.java * Update pom.xml * Fixes for configuration properties * Update VS Code launch properties * Fixes for CQL logging * Update pom.xml * Remove unused threaded option * Update to 7.1.7 * Fix some CR defaults * Update to new snapshot * Update pom.xml * Fix test settings * Do not make prefetch calls if all items are present * Add alternative application.yaml for CDS settings. * Add CdsHook tests and documentation * Comment out custom prefetch until it is more mature * Removal of DataEndpoint parameter is not longer needed * Fix debug logging setting being overwritten * Revert change * Remove unused class * Adding Rec10 Test * Disable test until fixed * fix tests --------- Co-authored-by: c-schuler <hoofschu@gmail.com> Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -3,10 +3,6 @@ package ca.uhn.fhir.jpa.starter.cdshooks;
|
||||
import ca.uhn.fhir.jpa.starter.cr.CrProperties;
|
||||
|
||||
public class ProviderConfiguration {
|
||||
|
||||
public static final ProviderConfiguration DEFAULT_PROVIDER_CONFIGURATION =
|
||||
new ProviderConfiguration(false, "client_id");
|
||||
|
||||
private final String clientIdHeaderName;
|
||||
private final boolean cqlLoggingEnabled;
|
||||
|
||||
@@ -16,8 +12,7 @@ public class ProviderConfiguration {
|
||||
}
|
||||
|
||||
public ProviderConfiguration(CdsHooksProperties cdsProperties, CrProperties crProperties) {
|
||||
this.clientIdHeaderName = cdsProperties.getClientIdHeaderName();
|
||||
this.cqlLoggingEnabled = crProperties.isCqlRuntimeDebugLoggingEnabled();
|
||||
this(crProperties.getCql().getRuntime().isDebugLoggingEnabled(), cdsProperties.getClientIdHeaderName());
|
||||
}
|
||||
|
||||
public String getClientIdHeaderName() {
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
package ca.uhn.fhir.jpa.starter.cdshooks;
|
||||
|
||||
import ca.uhn.fhir.jpa.starter.cr.CrCommonConfig;
|
||||
import ca.uhn.fhir.jpa.starter.cr.CrConfigCondition;
|
||||
import ca.uhn.fhir.jpa.starter.cr.CrProperties;
|
||||
import ca.uhn.hapi.fhir.cdshooks.api.ICdsHooksDaoAuthorizationSvc;
|
||||
import ca.uhn.hapi.fhir.cdshooks.config.CdsHooksConfig;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.CdsHooksContextBooter;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrSettings;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrServiceRegistry;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.cr.ICdsCrServiceRegistry;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.CdsCrDiscoveryServiceRegistry;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.ICdsCrDiscoveryServiceRegistry;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchDaoSvc;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchFhirClientSvc;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchSvc;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsResolutionStrategySvc;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
@@ -16,8 +26,38 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
@Configuration
|
||||
@Conditional({CdsHooksConfigCondition.class, CrConfigCondition.class})
|
||||
@Import(CdsHooksConfig.class)
|
||||
@Import({CdsHooksConfig.class, CrCommonConfig.class})
|
||||
public class StarterCdsHooksConfig {
|
||||
|
||||
// @Bean
|
||||
// CdsPrefetchSvc cdsPrefetchSvc(
|
||||
// CdsResolutionStrategySvc theCdsResolutionStrategySvc,
|
||||
// CdsPrefetchDaoSvc theResourcePrefetchDao,
|
||||
// CdsPrefetchFhirClientSvc theResourcePrefetchFhirClient,
|
||||
// ICdsHooksDaoAuthorizationSvc theCdsHooksDaoAuthorizationSvc) {
|
||||
// return new ModuleConfigurationPrefetchSvc(
|
||||
// theCdsResolutionStrategySvc,
|
||||
// theResourcePrefetchDao,
|
||||
// theResourcePrefetchFhirClient,
|
||||
// theCdsHooksDaoAuthorizationSvc);
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public ICdsCrDiscoveryServiceRegistry cdsCrDiscoveryServiceRegistry() {
|
||||
CdsCrDiscoveryServiceRegistry registry = new CdsCrDiscoveryServiceRegistry();
|
||||
registry.unregister(FhirVersionEnum.R4);
|
||||
registry.register(FhirVersionEnum.R4, UpdatedCrDiscoveryServiceR4.class);
|
||||
return registry;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ICdsCrServiceRegistry cdsCrServiceRegistry() {
|
||||
CdsCrServiceRegistry registry = new CdsCrServiceRegistry();
|
||||
registry.unregister(FhirVersionEnum.R4);
|
||||
registry.register(FhirVersionEnum.R4, UpdatedCdsCrServiceR4.class);
|
||||
return registry;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CdsHooksProperties cdsHooksProperties() {
|
||||
return new CdsHooksProperties();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package ca.uhn.fhir.jpa.starter.cdshooks;
|
||||
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService;
|
||||
import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestJson;
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrServiceR4;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.opencds.cqf.fhir.api.Repository;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrConstants.APPLY_PARAMETER_DATA;
|
||||
import static ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrConstants.APPLY_PARAMETER_DATA_ENDPOINT;
|
||||
import static org.opencds.cqf.fhir.utility.r4.Parameters.part;
|
||||
|
||||
public class UpdatedCdsCrServiceR4 extends CdsCrServiceR4 {
|
||||
public UpdatedCdsCrServiceR4(RequestDetails theRequestDetails, Repository theRepository, ICdsConfigService theCdsConfigService) {
|
||||
super(theRequestDetails, theRepository, theCdsConfigService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parameters encodeParams(CdsServiceRequestJson theJson) {
|
||||
Parameters parameters = super.encodeParams(theJson);
|
||||
if (parameters.hasParameter(APPLY_PARAMETER_DATA)) {
|
||||
parameters.addParameter(part("useServerData", new BooleanType(false)));
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package ca.uhn.fhir.jpa.starter.cdshooks;
|
||||
|
||||
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.CrDiscoveryServiceR4;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.opencds.cqf.fhir.api.Repository;
|
||||
|
||||
public class UpdatedCrDiscoveryServiceR4 extends CrDiscoveryServiceR4 {
|
||||
public UpdatedCrDiscoveryServiceR4(IIdType thePlanDefinitionId, Repository theRepository) {
|
||||
super(thePlanDefinitionId, theRepository);
|
||||
myMaxUriLength = 6000;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package ca.uhn.fhir.jpa.starter.cr;
|
||||
|
||||
public class CareGapsProperties {
|
||||
private String reporter = "default";
|
||||
private String section_author = "default";
|
||||
|
||||
public String getReporter() {
|
||||
return reporter;
|
||||
}
|
||||
|
||||
public void setReporter(String reporter) {
|
||||
this.reporter = reporter;
|
||||
}
|
||||
|
||||
public String getSection_author() {
|
||||
return section_author;
|
||||
}
|
||||
|
||||
public void setSection_author(String section_author) {
|
||||
this.section_author = section_author;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package ca.uhn.fhir.jpa.starter.cr;
|
||||
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerException;
|
||||
import org.cqframework.cql.cql2elm.CqlTranslator;
|
||||
import org.cqframework.cql.cql2elm.LibraryBuilder;
|
||||
|
||||
public class CqlCompilerProperties {
|
||||
private Boolean validate_units = true;
|
||||
private Boolean verify_only = false;
|
||||
private String compatibility_level = "1.5";
|
||||
private CqlCompilerException.ErrorSeverity error_level = CqlCompilerException.ErrorSeverity.Info;
|
||||
private LibraryBuilder.SignatureLevel signature_level = LibraryBuilder.SignatureLevel.All;
|
||||
private Boolean analyze_data_requirements = false;
|
||||
private Boolean collapse_data_requirements = false;
|
||||
private CqlTranslator.Format translator_format = CqlTranslator.Format.JSON;
|
||||
private Boolean enable_date_range_optimization = true;
|
||||
private Boolean enable_annotations = true;
|
||||
private Boolean enable_locators = true;
|
||||
private Boolean enable_results_type = true;
|
||||
private Boolean enable_detailed_errors = true;
|
||||
private Boolean disable_list_traversal = false;
|
||||
private Boolean disable_list_demotion = false;
|
||||
private Boolean disable_list_promotion = false;
|
||||
private Boolean enable_interval_demotion = false;
|
||||
private Boolean enable_interval_promotion = false;
|
||||
private Boolean disable_method_invocation = false;
|
||||
private Boolean require_from_keyword = false;
|
||||
private Boolean disable_default_model_info_load = false;
|
||||
|
||||
|
||||
public boolean isValidateUnits() {
|
||||
return validate_units;
|
||||
}
|
||||
|
||||
public void setValidateUnits(boolean validateUnits) {
|
||||
this.validate_units = validateUnits;
|
||||
}
|
||||
|
||||
public boolean isVerifyOnly() {
|
||||
return verify_only;
|
||||
}
|
||||
|
||||
public void setVerifyOnly(boolean verifyOnly) {
|
||||
this.verify_only = verifyOnly;
|
||||
}
|
||||
|
||||
public String getCompatibilityLevel() {
|
||||
return compatibility_level;
|
||||
}
|
||||
|
||||
public void setCompatibilityLevel(String compatibilityLevel) {
|
||||
this.compatibility_level = compatibilityLevel;
|
||||
}
|
||||
|
||||
public CqlCompilerException.ErrorSeverity getErrorSeverityLevel() {
|
||||
return error_level;
|
||||
}
|
||||
|
||||
public void setErrorSeverityLevel(CqlCompilerException.ErrorSeverity errorSeverityLevel) {
|
||||
this.error_level = errorSeverityLevel;
|
||||
}
|
||||
|
||||
public LibraryBuilder.SignatureLevel getSignatureLevel() {
|
||||
return signature_level;
|
||||
}
|
||||
|
||||
public void setSignatureLevel(LibraryBuilder.SignatureLevel signatureLevel) {
|
||||
this.signature_level = signatureLevel;
|
||||
}
|
||||
|
||||
public boolean isAnalyzeDataRequirements() {
|
||||
return analyze_data_requirements;
|
||||
}
|
||||
|
||||
public void setAnalyzeDataRequirements(boolean analyzeDataRequirements) {
|
||||
this.analyze_data_requirements = analyzeDataRequirements;
|
||||
}
|
||||
|
||||
public boolean isCollapseDataRequirements() {
|
||||
return collapse_data_requirements;
|
||||
}
|
||||
|
||||
public void setCollapseDataRequirements(boolean collapseDataRequirements) {
|
||||
this.collapse_data_requirements = collapseDataRequirements;
|
||||
}
|
||||
|
||||
public boolean isEnableDateRangeOptimization() {
|
||||
return enable_date_range_optimization;
|
||||
}
|
||||
|
||||
public void setEnableDateRangeOptimization(boolean enableDateRangeOptimization) {
|
||||
this.enable_date_range_optimization = enableDateRangeOptimization;
|
||||
}
|
||||
|
||||
public boolean isEnableAnnotations() {
|
||||
return enable_annotations;
|
||||
}
|
||||
|
||||
public void setEnableAnnotations(boolean enableAnnotations) {
|
||||
this.enable_annotations = enableAnnotations;
|
||||
}
|
||||
|
||||
public boolean isEnableLocators() {
|
||||
return enable_locators;
|
||||
}
|
||||
|
||||
public void setEnableLocators(boolean enableLocators) {
|
||||
this.enable_locators = enableLocators;
|
||||
}
|
||||
|
||||
public boolean isEnableResultsType() {
|
||||
return enable_results_type;
|
||||
}
|
||||
|
||||
public void setEnableResultsType(boolean enableResultsType) {
|
||||
this.enable_results_type = enableResultsType;
|
||||
}
|
||||
|
||||
public boolean isEnableDetailedErrors() {
|
||||
return enable_detailed_errors;
|
||||
}
|
||||
|
||||
public void setEnableDetailedErrors(boolean enableDetailedErrors) {
|
||||
this.enable_detailed_errors = enableDetailedErrors;
|
||||
}
|
||||
|
||||
public boolean isDisableListTraversal() {
|
||||
return disable_list_traversal;
|
||||
}
|
||||
|
||||
public void setDisableListTraversal(boolean disableListTraversal) {
|
||||
this.disable_list_traversal = disableListTraversal;
|
||||
}
|
||||
|
||||
public boolean isDisableListDemotion() {
|
||||
return disable_list_demotion;
|
||||
}
|
||||
|
||||
public void setDisableListDemotion(boolean disableListDemotion) {
|
||||
this.disable_list_demotion = disableListDemotion;
|
||||
}
|
||||
|
||||
public boolean isDisableListPromotion() {
|
||||
return disable_list_promotion;
|
||||
}
|
||||
|
||||
public void setDisableListPromotion(boolean disableListPromotion) {
|
||||
this.disable_list_promotion = disableListPromotion;
|
||||
}
|
||||
|
||||
public boolean isEnableIntervalPromotion() {
|
||||
return enable_interval_promotion;
|
||||
}
|
||||
|
||||
public void setEnableIntervalPromotion(boolean enableIntervalPromotion) {
|
||||
this.enable_interval_promotion = enableIntervalPromotion;
|
||||
}
|
||||
|
||||
public boolean isEnableIntervalDemotion() {
|
||||
return enable_interval_demotion;
|
||||
}
|
||||
|
||||
public void setEnableIntervalDemotion(boolean enableIntervalDemotion) {
|
||||
this.enable_interval_demotion = enableIntervalDemotion;
|
||||
}
|
||||
|
||||
public boolean isDisableMethodInvocation() {
|
||||
return disable_method_invocation;
|
||||
}
|
||||
|
||||
public void setDisableMethodInvocation(boolean disableMethodInvocation) {
|
||||
this.disable_method_invocation = disableMethodInvocation;
|
||||
}
|
||||
|
||||
public boolean isRequireFromKeyword() {
|
||||
return require_from_keyword;
|
||||
}
|
||||
|
||||
public void setRequireFromKeyword(boolean requireFromKeyword) {
|
||||
this.require_from_keyword = requireFromKeyword;
|
||||
}
|
||||
|
||||
public boolean isDisableDefaultModelInfoLoad() {
|
||||
return disable_default_model_info_load;
|
||||
}
|
||||
|
||||
public void setDisableDefaultModelInfoLoad(boolean disableDefaultModelInfoLoad) {
|
||||
this.disable_default_model_info_load = disableDefaultModelInfoLoad;
|
||||
}
|
||||
|
||||
public CqlTranslator.Format getTranslatorFormat() {
|
||||
return translator_format;
|
||||
}
|
||||
|
||||
public void setTranslatorFormat(CqlTranslator.Format translatorFormat) {
|
||||
this.translator_format = translatorFormat;
|
||||
}
|
||||
}
|
||||
53
src/main/java/ca/uhn/fhir/jpa/starter/cr/CqlProperties.java
Normal file
53
src/main/java/ca/uhn/fhir/jpa/starter/cr/CqlProperties.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package ca.uhn.fhir.jpa.starter.cr;
|
||||
|
||||
import org.opencds.cqf.fhir.cql.engine.retrieve.RetrieveSettings;
|
||||
import org.opencds.cqf.fhir.cql.engine.terminology.TerminologySettings;
|
||||
|
||||
public class CqlProperties {
|
||||
|
||||
private Boolean use_embedded_libraries = true;
|
||||
private CqlCompilerProperties compiler = new CqlCompilerProperties();
|
||||
private CqlRuntimeProperties runtime = new CqlRuntimeProperties();
|
||||
private TerminologySettings terminology = new TerminologySettings();
|
||||
private RetrieveSettings data = new RetrieveSettings();
|
||||
|
||||
public Boolean getUse_embedded_libraries() {
|
||||
return use_embedded_libraries;
|
||||
}
|
||||
|
||||
public void setUse_embedded_libraries(Boolean use_embedded_libraries) {
|
||||
this.use_embedded_libraries = use_embedded_libraries;
|
||||
}
|
||||
|
||||
public CqlCompilerProperties getCompiler() {
|
||||
return compiler;
|
||||
}
|
||||
|
||||
public void setCompiler(CqlCompilerProperties compiler) {
|
||||
this.compiler = compiler;
|
||||
}
|
||||
|
||||
public CqlRuntimeProperties getRuntime() {
|
||||
return runtime;
|
||||
}
|
||||
|
||||
public void setRuntime(CqlRuntimeProperties runtime) {
|
||||
this.runtime = runtime;
|
||||
}
|
||||
|
||||
public TerminologySettings getTerminology() {
|
||||
return terminology;
|
||||
}
|
||||
|
||||
public void setTerminology(TerminologySettings terminology) {
|
||||
this.terminology = terminology;
|
||||
}
|
||||
|
||||
public RetrieveSettings getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(RetrieveSettings data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package ca.uhn.fhir.jpa.starter.cr;
|
||||
|
||||
public class CqlRuntimeProperties {
|
||||
|
||||
private Boolean debug_logging_enabled = false;
|
||||
private Boolean enable_validation = false;
|
||||
private Boolean enable_expression_caching = true;
|
||||
|
||||
public boolean isDebugLoggingEnabled() {
|
||||
return debug_logging_enabled;
|
||||
}
|
||||
|
||||
public void setDebugLoggingEnabled(boolean debug_logging_enabled) {
|
||||
this.debug_logging_enabled = debug_logging_enabled;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnableExpressionCaching() {
|
||||
return enable_expression_caching;
|
||||
}
|
||||
|
||||
public void setEnableExpressionCaching(boolean enable_expression_caching) {
|
||||
this.enable_expression_caching = enable_expression_caching;
|
||||
}
|
||||
|
||||
public boolean isEnableValidation() {
|
||||
return enable_validation;
|
||||
}
|
||||
|
||||
public void EnableValidation(boolean enable_validation) {
|
||||
this.enable_validation = enable_validation;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
228
src/main/java/ca/uhn/fhir/jpa/starter/cr/CrCommonConfig.java
Normal file
228
src/main/java/ca/uhn/fhir/jpa/starter/cr/CrCommonConfig.java
Normal file
@@ -0,0 +1,228 @@
|
||||
package ca.uhn.fhir.jpa.starter.cr;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
|
||||
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
|
||||
import org.cqframework.cql.cql2elm.model.Model;
|
||||
import org.hl7.cql.model.ModelIdentifier;
|
||||
import org.hl7.elm.r1.VersionedIdentifier;
|
||||
import org.opencds.cqf.cql.engine.execution.CqlEngine;
|
||||
import org.opencds.cqf.cql.engine.runtime.Code;
|
||||
import org.opencds.cqf.fhir.cql.EvaluationSettings;
|
||||
import org.opencds.cqf.fhir.cql.engine.retrieve.RetrieveSettings;
|
||||
import org.opencds.cqf.fhir.cql.engine.terminology.TerminologySettings;
|
||||
import org.opencds.cqf.fhir.cr.measure.CareGapsProperties;
|
||||
import org.opencds.cqf.fhir.cr.measure.MeasureEvaluationOptions;
|
||||
import org.opencds.cqf.fhir.utility.ValidationProfile;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
|
||||
|
||||
import ca.uhn.fhir.cr.common.CodeCacheResourceChangeListener;
|
||||
import ca.uhn.fhir.cr.common.CqlThreadFactory;
|
||||
import ca.uhn.fhir.cr.common.ElmCacheResourceChangeListener;
|
||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
|
||||
import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryInterceptor;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
||||
|
||||
@Configuration
|
||||
@Conditional({CrConfigCondition.class})
|
||||
public class CrCommonConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "hapi.fhir.cr")
|
||||
CrProperties crProperties() {
|
||||
return new CrProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
RetrieveSettings retrieveSettings(CrProperties theCrProperties) {
|
||||
return theCrProperties.getCql().getData();
|
||||
}
|
||||
|
||||
@Bean
|
||||
TerminologySettings terminologySettings(CrProperties theCrProperties) {
|
||||
return theCrProperties.getCql().getTerminology();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EvaluationSettings evaluationSettings(
|
||||
CrProperties theCrProperties,
|
||||
RetrieveSettings theRetrieveSettings,
|
||||
TerminologySettings theTerminologySettings,
|
||||
Map<VersionedIdentifier, CompiledLibrary> theGlobalLibraryCache,
|
||||
Map<ModelIdentifier, Model> theGlobalModelCache,
|
||||
Map<String, List<Code>> theGlobalValueSetCache) {
|
||||
var evaluationSettings = EvaluationSettings.getDefault();
|
||||
var cqlOptions = evaluationSettings.getCqlOptions();
|
||||
|
||||
var cqlEngineOptions = cqlOptions.getCqlEngineOptions();
|
||||
Set<CqlEngine.Options> options = EnumSet.noneOf(CqlEngine.Options.class);
|
||||
var cqlRuntimeProperties = theCrProperties.getCql().getRuntime();
|
||||
if (cqlRuntimeProperties.isEnableExpressionCaching()) {
|
||||
options.add(CqlEngine.Options.EnableExpressionCaching);
|
||||
}
|
||||
if (cqlRuntimeProperties.isEnableValidation()) {
|
||||
options.add(CqlEngine.Options.EnableValidation);
|
||||
}
|
||||
cqlEngineOptions.setOptions(options);
|
||||
if (cqlRuntimeProperties.isDebugLoggingEnabled()) {
|
||||
cqlEngineOptions.setDebugLoggingEnabled(true);
|
||||
}
|
||||
cqlOptions.setCqlEngineOptions(cqlEngineOptions);
|
||||
|
||||
var cqlCompilerOptions = new CqlCompilerOptions();
|
||||
|
||||
var cqlCompilerProperties = theCrProperties.getCql().getCompiler();
|
||||
|
||||
if (cqlCompilerProperties.isEnableDateRangeOptimization()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableDateRangeOptimization);
|
||||
}
|
||||
if (cqlCompilerProperties.isEnableAnnotations()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableAnnotations);
|
||||
}
|
||||
if (cqlCompilerProperties.isEnableLocators()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableLocators);
|
||||
}
|
||||
if (cqlCompilerProperties.isEnableResultsType()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableResultTypes);
|
||||
}
|
||||
cqlCompilerOptions.setVerifyOnly(cqlCompilerProperties.isVerifyOnly());
|
||||
if (cqlCompilerProperties.isEnableDetailedErrors()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableDetailedErrors);
|
||||
}
|
||||
cqlCompilerOptions.setErrorLevel(cqlCompilerProperties.getErrorSeverityLevel());
|
||||
if (cqlCompilerProperties.isDisableListTraversal()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListTraversal);
|
||||
}
|
||||
if (cqlCompilerProperties.isDisableListDemotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListDemotion);
|
||||
}
|
||||
if (cqlCompilerProperties.isDisableListPromotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListPromotion);
|
||||
}
|
||||
if (cqlCompilerProperties.isEnableIntervalDemotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableIntervalDemotion);
|
||||
}
|
||||
if (cqlCompilerProperties.isEnableIntervalPromotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableIntervalPromotion);
|
||||
}
|
||||
if (cqlCompilerProperties.isDisableMethodInvocation()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableMethodInvocation);
|
||||
}
|
||||
if (cqlCompilerProperties.isRequireFromKeyword()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.RequireFromKeyword);
|
||||
}
|
||||
cqlCompilerOptions.setValidateUnits(cqlCompilerProperties.isValidateUnits());
|
||||
if (cqlCompilerProperties.isDisableDefaultModelInfoLoad()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableDefaultModelInfoLoad);
|
||||
}
|
||||
cqlCompilerOptions.setSignatureLevel(cqlCompilerProperties.getSignatureLevel());
|
||||
cqlCompilerOptions.setCompatibilityLevel(cqlCompilerProperties.getCompatibilityLevel());
|
||||
cqlCompilerOptions.setAnalyzeDataRequirements(cqlCompilerProperties.isAnalyzeDataRequirements());
|
||||
cqlCompilerOptions.setCollapseDataRequirements(cqlCompilerProperties.isCollapseDataRequirements());
|
||||
|
||||
cqlOptions.setCqlCompilerOptions(cqlCompilerOptions);
|
||||
evaluationSettings.setLibraryCache(theGlobalLibraryCache);
|
||||
evaluationSettings.setModelCache(theGlobalModelCache);
|
||||
evaluationSettings.setValueSetCache(theGlobalValueSetCache);
|
||||
evaluationSettings.setRetrieveSettings(theRetrieveSettings);
|
||||
evaluationSettings.setTerminologySettings(theTerminologySettings);
|
||||
return evaluationSettings;
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public ExecutorService cqlExecutor() {
|
||||
CqlThreadFactory factory = new CqlThreadFactory();
|
||||
ExecutorService executor = Executors.newFixedThreadPool(2, factory);
|
||||
executor = new DelegatingSecurityContextExecutorService(executor);
|
||||
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
CareGapsProperties careGapsProperties(CrProperties theCrProperties) {
|
||||
var careGapsProperties = new CareGapsProperties();
|
||||
careGapsProperties.setCareGapsReporter(theCrProperties.getCareGaps().getReporter());
|
||||
careGapsProperties.setCareGapsCompositionSectionAuthor(theCrProperties.getCareGaps().getSection_author());
|
||||
return careGapsProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
MeasureEvaluationOptions measureEvaluationOptions(
|
||||
EvaluationSettings theEvaluationSettings, Map<String, ValidationProfile> theValidationProfiles) {
|
||||
MeasureEvaluationOptions measureEvalOptions = new MeasureEvaluationOptions();
|
||||
measureEvalOptions.setEvaluationSettings(theEvaluationSettings);
|
||||
if (measureEvalOptions.isValidationEnabled()) {
|
||||
measureEvalOptions.setValidationProfiles(theValidationProfiles);
|
||||
}
|
||||
return measureEvalOptions;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PostInitProviderRegisterer postInitProviderRegisterer(
|
||||
RestfulServer theRestfulServer, ResourceProviderFactory theResourceProviderFactory) {
|
||||
return new PostInitProviderRegisterer(theRestfulServer, theResourceProviderFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<VersionedIdentifier, CompiledLibrary> globalLibraryCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<ModelIdentifier, Model> globalModelCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<String, List<Code>> globalValueSetCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ElmCacheResourceChangeListener elmCacheResourceChangeListener(
|
||||
IResourceChangeListenerRegistry theResourceChangeListenerRegistry,
|
||||
DaoRegistry theDaoRegistry,
|
||||
EvaluationSettings theEvaluationSettings) {
|
||||
ElmCacheResourceChangeListener listener =
|
||||
new ElmCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getLibraryCache());
|
||||
theResourceChangeListenerRegistry.registerResourceResourceChangeListener(
|
||||
"Library", SearchParameterMap.newSynchronous(), listener, 1000);
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CodeCacheResourceChangeListener codeCacheResourceChangeListener(
|
||||
IResourceChangeListenerRegistry theResourceChangeListenerRegistry,
|
||||
EvaluationSettings theEvaluationSettings,
|
||||
DaoRegistry theDaoRegistry) {
|
||||
|
||||
CodeCacheResourceChangeListener listener =
|
||||
new CodeCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getValueSetCache());
|
||||
// registry
|
||||
theResourceChangeListenerRegistry.registerResourceResourceChangeListener(
|
||||
"ValueSet", SearchParameterMap.newSynchronous(), listener, 1000);
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResourceChangeListenerRegistryInterceptor resourceChangeListenerRegistryInterceptor() {
|
||||
return new ResourceChangeListenerRegistryInterceptor();
|
||||
}
|
||||
}
|
||||
@@ -3,40 +3,12 @@ package ca.uhn.fhir.jpa.starter.cr;
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerException;
|
||||
import org.cqframework.cql.cql2elm.CqlTranslator;
|
||||
import org.cqframework.cql.cql2elm.LibraryBuilder;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "hapi.fhir.cr")
|
||||
public class CrProperties {
|
||||
private Boolean enabled;
|
||||
// cql settings
|
||||
private Boolean cql_use_embedded_libraries = true;
|
||||
private Boolean cql_runtime_debug_logging_enabled = false;
|
||||
private Boolean cql_runtime_enable_validation = false;
|
||||
private Boolean cql_runtime_enable_expression_caching = false;
|
||||
private Boolean cql_compiler_validate_units = true;
|
||||
private Boolean cql_compiler_verify_only = false;
|
||||
private String cql_compiler_compatibility_level = "1.5";
|
||||
private CqlCompilerException.ErrorSeverity cql_compiler_error_level = CqlCompilerException.ErrorSeverity.Info;
|
||||
private LibraryBuilder.SignatureLevel cql_compiler_signature_level = LibraryBuilder.SignatureLevel.All;
|
||||
private Boolean cql_compiler_analyze_data_requirements = false;
|
||||
private Boolean cql_compiler_collapse_data_requirements = false;
|
||||
private CqlTranslator.Format cql_compiler_translator_format = CqlTranslator.Format.JSON;
|
||||
private Boolean cql_compiler_enable_date_range_optimization = false;
|
||||
private Boolean cql_compiler_enable_annotations = false;
|
||||
private Boolean cql_compiler_enable_locators = false;
|
||||
private Boolean cql_compiler_enable_results_type = false;
|
||||
private Boolean cql_compiler_enable_detailed_errors = false;
|
||||
private Boolean cql_compiler_disable_list_traversal = false;
|
||||
private Boolean cql_compiler_disable_list_demotion = false;
|
||||
private Boolean cql_compiler_disable_list_promotion = false;
|
||||
private Boolean cql_compiler_enable_interval_demotion = false;
|
||||
private Boolean cql_compiler_enable_interval_promotion = false;
|
||||
private Boolean cql_compiler_disable_method_invocation = false;
|
||||
private Boolean cql_compiler_require_from_keyword = false;
|
||||
private Boolean cql_compiler_disable_default_model_info_load = false;
|
||||
// Care-gaps Settings
|
||||
private String caregaps_reporter = "default";
|
||||
private String caregaps_section_author = "default";
|
||||
|
||||
private CareGapsProperties careGaps = new CareGapsProperties();
|
||||
private CqlProperties cql = new CqlProperties();
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
@@ -46,219 +18,19 @@ public class CrProperties {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isCqlUseEmbeddedLibraries() {
|
||||
return cql_use_embedded_libraries;
|
||||
public CareGapsProperties getCareGaps() {
|
||||
return careGaps;
|
||||
}
|
||||
|
||||
public void setCqlUseEmbeddedLibraries(boolean cql_use_embedded_libraries) {
|
||||
this.cql_use_embedded_libraries = cql_use_embedded_libraries;
|
||||
public void setCareGaps(CareGapsProperties careGaps) {
|
||||
this.careGaps = careGaps;
|
||||
}
|
||||
|
||||
public boolean isCqlRuntimeDebugLoggingEnabled() {
|
||||
return cql_runtime_debug_logging_enabled;
|
||||
public CqlProperties getCql() {
|
||||
return cql;
|
||||
}
|
||||
|
||||
public void setCqlRuntimeDebugLoggingEnabled(boolean cqlRuntimeDebugLoggingEnabled) {
|
||||
this.cql_runtime_debug_logging_enabled = cqlRuntimeDebugLoggingEnabled;
|
||||
}
|
||||
|
||||
public boolean isCqlCompilerValidateUnits() {
|
||||
return cql_compiler_validate_units;
|
||||
}
|
||||
|
||||
public void setCqlCompilerValidateUnits(boolean cqlCompilerValidateUnits) {
|
||||
this.cql_compiler_validate_units = cqlCompilerValidateUnits;
|
||||
}
|
||||
|
||||
public boolean isCqlCompilerVerifyOnly() {
|
||||
return cql_compiler_verify_only;
|
||||
}
|
||||
|
||||
public void setCqlCompilerVerifyOnly(boolean cqlCompilerVerifyOnly) {
|
||||
this.cql_compiler_verify_only = cqlCompilerVerifyOnly;
|
||||
}
|
||||
|
||||
public String getCqlCompilerCompatibilityLevel() {
|
||||
return cql_compiler_compatibility_level;
|
||||
}
|
||||
|
||||
public void setCqlCompilerCompatibilityLevel(String cqlCompilerCompatibilityLevel) {
|
||||
this.cql_compiler_compatibility_level = cqlCompilerCompatibilityLevel;
|
||||
}
|
||||
|
||||
public CqlCompilerException.ErrorSeverity getCqlCompilerErrorSeverityLevel() {
|
||||
return cql_compiler_error_level;
|
||||
}
|
||||
|
||||
public void setCqlCompilerErrorSeverityLevel(CqlCompilerException.ErrorSeverity cqlCompilerErrorSeverityLevel) {
|
||||
this.cql_compiler_error_level = cqlCompilerErrorSeverityLevel;
|
||||
}
|
||||
|
||||
public LibraryBuilder.SignatureLevel getCqlCompilerSignatureLevel() {
|
||||
return cql_compiler_signature_level;
|
||||
}
|
||||
|
||||
public void setCqlCompilerSignatureLevel(LibraryBuilder.SignatureLevel cqlCompilerSignatureLevel) {
|
||||
this.cql_compiler_signature_level = cqlCompilerSignatureLevel;
|
||||
}
|
||||
|
||||
public boolean isCqlCompilerAnalyzeDataRequirements() {
|
||||
return cql_compiler_analyze_data_requirements;
|
||||
}
|
||||
|
||||
public void setCqlCompilerAnalyzeDataRequirements(boolean cqlCompilerAnalyzeDataRequirements) {
|
||||
this.cql_compiler_analyze_data_requirements = cqlCompilerAnalyzeDataRequirements;
|
||||
}
|
||||
|
||||
public boolean isCqlCompilerCollapseDataRequirements() {
|
||||
return cql_compiler_collapse_data_requirements;
|
||||
}
|
||||
|
||||
public void setCqlCompilerCollapseDataRequirements(boolean cqlCompilerCollapseDataRequirements) {
|
||||
this.cql_compiler_collapse_data_requirements = cqlCompilerCollapseDataRequirements;
|
||||
}
|
||||
|
||||
public boolean isEnableDateRangeOptimization() {
|
||||
return cql_compiler_enable_date_range_optimization;
|
||||
}
|
||||
|
||||
public void setEnableDateRangeOptimization(boolean enableDateRangeOptimization) {
|
||||
this.cql_compiler_enable_date_range_optimization = enableDateRangeOptimization;
|
||||
}
|
||||
|
||||
public boolean isEnableAnnotations() {
|
||||
return cql_compiler_enable_annotations;
|
||||
}
|
||||
|
||||
public void setEnableAnnotations(boolean enableAnnotations) {
|
||||
this.cql_compiler_enable_annotations = enableAnnotations;
|
||||
}
|
||||
|
||||
public boolean isEnableLocators() {
|
||||
return cql_compiler_enable_locators;
|
||||
}
|
||||
|
||||
public void setEnableLocators(boolean enableLocators) {
|
||||
this.cql_compiler_enable_locators = enableLocators;
|
||||
}
|
||||
|
||||
public boolean isEnableResultsType() {
|
||||
return cql_compiler_enable_results_type;
|
||||
}
|
||||
|
||||
public void setEnableResultsType(boolean enableResultsType) {
|
||||
this.cql_compiler_enable_results_type = enableResultsType;
|
||||
}
|
||||
|
||||
public boolean isEnableDetailedErrors() {
|
||||
return cql_compiler_enable_detailed_errors;
|
||||
}
|
||||
|
||||
public void setEnableDetailedErrors(boolean enableDetailedErrors) {
|
||||
this.cql_compiler_enable_detailed_errors = enableDetailedErrors;
|
||||
}
|
||||
|
||||
public boolean isDisableListTraversal() {
|
||||
return cql_compiler_disable_list_traversal;
|
||||
}
|
||||
|
||||
public void setDisableListTraversal(boolean disableListTraversal) {
|
||||
this.cql_compiler_disable_list_traversal = disableListTraversal;
|
||||
}
|
||||
|
||||
public boolean isDisableListDemotion() {
|
||||
return cql_compiler_disable_list_demotion;
|
||||
}
|
||||
|
||||
public void setDisableListDemotion(boolean disableListDemotion) {
|
||||
this.cql_compiler_disable_list_demotion = disableListDemotion;
|
||||
}
|
||||
|
||||
public boolean isDisableListPromotion() {
|
||||
return cql_compiler_disable_list_promotion;
|
||||
}
|
||||
|
||||
public void setDisableListPromotion(boolean disableListPromotion) {
|
||||
this.cql_compiler_disable_list_promotion = disableListPromotion;
|
||||
}
|
||||
|
||||
public boolean isEnableIntervalPromotion() {
|
||||
return cql_compiler_enable_interval_promotion;
|
||||
}
|
||||
|
||||
public void setEnableIntervalPromotion(boolean enableIntervalPromotion) {
|
||||
this.cql_compiler_enable_interval_promotion = enableIntervalPromotion;
|
||||
}
|
||||
|
||||
public boolean isEnableIntervalDemotion() {
|
||||
return cql_compiler_enable_interval_demotion;
|
||||
}
|
||||
|
||||
public void setEnableIntervalDemotion(boolean enableIntervalDemotion) {
|
||||
this.cql_compiler_enable_interval_demotion = enableIntervalDemotion;
|
||||
}
|
||||
|
||||
public boolean isDisableMethodInvocation() {
|
||||
return cql_compiler_disable_method_invocation;
|
||||
}
|
||||
|
||||
public void setDisableMethodInvocation(boolean disableMethodInvocation) {
|
||||
this.cql_compiler_disable_method_invocation = disableMethodInvocation;
|
||||
}
|
||||
|
||||
public boolean isRequireFromKeyword() {
|
||||
return cql_compiler_require_from_keyword;
|
||||
}
|
||||
|
||||
public void setRequireFromKeyword(boolean requireFromKeyword) {
|
||||
this.cql_compiler_require_from_keyword = requireFromKeyword;
|
||||
}
|
||||
|
||||
public boolean isDisableDefaultModelInfoLoad() {
|
||||
return cql_compiler_disable_default_model_info_load;
|
||||
}
|
||||
|
||||
public void setDisableDefaultModelInfoLoad(boolean disableDefaultModelInfoLoad) {
|
||||
this.cql_compiler_disable_default_model_info_load = disableDefaultModelInfoLoad;
|
||||
}
|
||||
|
||||
public boolean isCqlRuntimeEnableExpressionCaching() {
|
||||
return cql_runtime_enable_expression_caching;
|
||||
}
|
||||
|
||||
public void setCqlRuntimeEnableExpressionCaching(boolean cqlRuntimeEnableExpressionCaching) {
|
||||
this.cql_runtime_enable_expression_caching = cqlRuntimeEnableExpressionCaching;
|
||||
}
|
||||
|
||||
public boolean isCqlRuntimeEnableValidation() {
|
||||
return cql_runtime_enable_validation;
|
||||
}
|
||||
|
||||
public void setCqlRuntimeEnableValidation(boolean cqlRuntimeEnableValidation) {
|
||||
this.cql_runtime_enable_validation = cqlRuntimeEnableValidation;
|
||||
}
|
||||
|
||||
public CqlTranslator.Format getCqlTranslatorFormat() {
|
||||
return cql_compiler_translator_format;
|
||||
}
|
||||
|
||||
public void setCqlTranslatorFormat(CqlTranslator.Format cqlTranslatorFormat) {
|
||||
this.cql_compiler_translator_format = cqlTranslatorFormat;
|
||||
}
|
||||
|
||||
public String getCareGapsReporter() {
|
||||
return caregaps_reporter;
|
||||
}
|
||||
|
||||
public String getCareGapsSectionAuthor() {
|
||||
return caregaps_section_author;
|
||||
}
|
||||
|
||||
public void setCareGapsSectionAuthor(String theCareGapsSectionAuthor) {
|
||||
this.caregaps_section_author = theCareGapsSectionAuthor;
|
||||
}
|
||||
|
||||
public void setCareGapsReporter(String theCareGapsReporter) {
|
||||
this.caregaps_reporter = theCareGapsReporter;
|
||||
public void setCql(CqlProperties cql) {
|
||||
this.cql = cql;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,195 +1,25 @@
|
||||
package ca.uhn.fhir.jpa.starter.cr;
|
||||
|
||||
import ca.uhn.fhir.cr.common.CodeCacheResourceChangeListener;
|
||||
import ca.uhn.fhir.cr.common.ElmCacheResourceChangeListener;
|
||||
import ca.uhn.fhir.cr.config.dstu3.ApplyOperationConfig;
|
||||
import ca.uhn.fhir.cr.config.dstu3.CrDstu3Config;
|
||||
import ca.uhn.fhir.cr.config.dstu3.ExtractOperationConfig;
|
||||
import ca.uhn.fhir.cr.config.dstu3.PackageOperationConfig;
|
||||
import ca.uhn.fhir.cr.config.dstu3.PopulateOperationConfig;
|
||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
|
||||
import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryInterceptor;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.cr.config.dstu3.QuestionnaireOperationConfig;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnDSTU3Condition;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
|
||||
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
|
||||
import org.cqframework.cql.cql2elm.model.Model;
|
||||
import org.hl7.cql.model.ModelIdentifier;
|
||||
import org.hl7.elm.r1.VersionedIdentifier;
|
||||
import org.opencds.cqf.cql.engine.execution.CqlEngine;
|
||||
import org.opencds.cqf.cql.engine.runtime.Code;
|
||||
import org.opencds.cqf.fhir.cql.EvaluationSettings;
|
||||
import org.opencds.cqf.fhir.cr.measure.MeasureEvaluationOptions;
|
||||
import org.opencds.cqf.fhir.utility.ValidationProfile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.*;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Configuration
|
||||
@Conditional({OnDSTU3Condition.class, CrConfigCondition.class})
|
||||
@Import({
|
||||
// BaseCrConfig.class,
|
||||
CrCommonConfig.class,
|
||||
CrDstu3Config.class,
|
||||
ApplyOperationConfig.class,
|
||||
ExtractOperationConfig.class,
|
||||
PackageOperationConfig.class,
|
||||
PopulateOperationConfig.class
|
||||
PopulateOperationConfig.class,
|
||||
QuestionnaireOperationConfig.class
|
||||
})
|
||||
public class StarterCrDstu3Config {
|
||||
private static final Logger ourLogger = LoggerFactory.getLogger(StarterCrDstu3Config.class);
|
||||
|
||||
@Bean
|
||||
MeasureEvaluationOptions measureEvaluationOptions(
|
||||
EvaluationSettings theEvaluationSettings, Map<String, ValidationProfile> theValidationProfiles) {
|
||||
MeasureEvaluationOptions measureEvalOptions = new MeasureEvaluationOptions();
|
||||
measureEvalOptions.setEvaluationSettings(theEvaluationSettings);
|
||||
|
||||
if (measureEvalOptions.isValidationEnabled()) {
|
||||
measureEvalOptions.setValidationProfiles(theValidationProfiles);
|
||||
}
|
||||
return measureEvalOptions;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EvaluationSettings evaluationSettings(
|
||||
CrProperties theCrProperties,
|
||||
Map<VersionedIdentifier, CompiledLibrary> theGlobalLibraryCache,
|
||||
Map<ModelIdentifier, Model> theGlobalModelCache,
|
||||
Map<String, List<Code>> theGlobalValueSetCache) {
|
||||
var evaluationSettings = EvaluationSettings.getDefault();
|
||||
var cqlOptions = evaluationSettings.getCqlOptions();
|
||||
|
||||
var cqlEngineOptions = cqlOptions.getCqlEngineOptions();
|
||||
Set<CqlEngine.Options> options = EnumSet.noneOf(CqlEngine.Options.class);
|
||||
if (theCrProperties.isCqlRuntimeEnableExpressionCaching()) {
|
||||
options.add(CqlEngine.Options.EnableExpressionCaching);
|
||||
}
|
||||
if (theCrProperties.isCqlRuntimeEnableValidation()) {
|
||||
options.add(CqlEngine.Options.EnableValidation);
|
||||
}
|
||||
cqlEngineOptions.setOptions(options);
|
||||
cqlOptions.setCqlEngineOptions(cqlEngineOptions);
|
||||
|
||||
var cqlCompilerOptions = new CqlCompilerOptions();
|
||||
|
||||
if (theCrProperties.isEnableDateRangeOptimization()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableDateRangeOptimization);
|
||||
}
|
||||
if (theCrProperties.isEnableAnnotations()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableAnnotations);
|
||||
}
|
||||
if (theCrProperties.isEnableLocators()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableLocators);
|
||||
}
|
||||
if (theCrProperties.isEnableResultsType()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableResultTypes);
|
||||
}
|
||||
cqlCompilerOptions.setVerifyOnly(theCrProperties.isCqlCompilerVerifyOnly());
|
||||
if (theCrProperties.isEnableDetailedErrors()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableDetailedErrors);
|
||||
}
|
||||
cqlCompilerOptions.setErrorLevel(theCrProperties.getCqlCompilerErrorSeverityLevel());
|
||||
if (theCrProperties.isDisableListTraversal()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListTraversal);
|
||||
}
|
||||
if (theCrProperties.isDisableListDemotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListDemotion);
|
||||
}
|
||||
if (theCrProperties.isDisableListPromotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListPromotion);
|
||||
}
|
||||
if (theCrProperties.isEnableIntervalDemotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableIntervalDemotion);
|
||||
}
|
||||
if (theCrProperties.isEnableIntervalPromotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableIntervalPromotion);
|
||||
}
|
||||
if (theCrProperties.isDisableMethodInvocation()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableMethodInvocation);
|
||||
}
|
||||
if (theCrProperties.isRequireFromKeyword()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.RequireFromKeyword);
|
||||
}
|
||||
cqlCompilerOptions.setValidateUnits(theCrProperties.isCqlCompilerValidateUnits());
|
||||
if (theCrProperties.isDisableDefaultModelInfoLoad()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableDefaultModelInfoLoad);
|
||||
}
|
||||
cqlCompilerOptions.setSignatureLevel(theCrProperties.getCqlCompilerSignatureLevel());
|
||||
cqlCompilerOptions.setCompatibilityLevel(theCrProperties.getCqlCompilerCompatibilityLevel());
|
||||
cqlCompilerOptions.setAnalyzeDataRequirements(theCrProperties.isCqlCompilerAnalyzeDataRequirements());
|
||||
cqlCompilerOptions.setCollapseDataRequirements(theCrProperties.isCqlCompilerCollapseDataRequirements());
|
||||
|
||||
cqlOptions.setCqlCompilerOptions(cqlCompilerOptions);
|
||||
evaluationSettings.setLibraryCache(theGlobalLibraryCache);
|
||||
evaluationSettings.setModelCache(theGlobalModelCache);
|
||||
evaluationSettings.setValueSetCache(theGlobalValueSetCache);
|
||||
return evaluationSettings;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PostInitProviderRegisterer postInitProviderRegisterer(
|
||||
RestfulServer theRestfulServer, ResourceProviderFactory theResourceProviderFactory) {
|
||||
return new PostInitProviderRegisterer(theRestfulServer, theResourceProviderFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CrProperties crProperties() {
|
||||
return new CrProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<VersionedIdentifier, CompiledLibrary> globalLibraryCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<ModelIdentifier, Model> globalModelCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<String, List<Code>> globalValueSetCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ElmCacheResourceChangeListener elmCacheResourceChangeListener(
|
||||
IResourceChangeListenerRegistry theResourceChangeListenerRegistry,
|
||||
DaoRegistry theDaoRegistry,
|
||||
EvaluationSettings theEvaluationSettings) {
|
||||
ElmCacheResourceChangeListener listener =
|
||||
new ElmCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getLibraryCache());
|
||||
theResourceChangeListenerRegistry.registerResourceResourceChangeListener(
|
||||
"Library", SearchParameterMap.newSynchronous(), listener, 1000);
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CodeCacheResourceChangeListener codeCacheResourceChangeListener(
|
||||
IResourceChangeListenerRegistry theResourceChangeListenerRegistry,
|
||||
EvaluationSettings theEvaluationSettings,
|
||||
DaoRegistry theDaoRegistry) {
|
||||
|
||||
CodeCacheResourceChangeListener listener =
|
||||
new CodeCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getValueSetCache());
|
||||
// registry
|
||||
theResourceChangeListenerRegistry.registerResourceResourceChangeListener(
|
||||
"ValueSet", SearchParameterMap.newSynchronous(), listener, 1000);
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResourceChangeListenerRegistryInterceptor resourceChangeListenerRegistryInterceptor() {
|
||||
return new ResourceChangeListenerRegistryInterceptor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,220 +1,27 @@
|
||||
package ca.uhn.fhir.jpa.starter.cr;
|
||||
|
||||
import ca.uhn.fhir.cr.common.CodeCacheResourceChangeListener;
|
||||
import ca.uhn.fhir.cr.common.CqlThreadFactory;
|
||||
import ca.uhn.fhir.cr.common.ElmCacheResourceChangeListener;
|
||||
import ca.uhn.fhir.cr.config.r4.ApplyOperationConfig;
|
||||
import ca.uhn.fhir.cr.config.r4.CrR4Config;
|
||||
import ca.uhn.fhir.cr.config.r4.ExtractOperationConfig;
|
||||
import ca.uhn.fhir.cr.config.r4.PackageOperationConfig;
|
||||
import ca.uhn.fhir.cr.config.r4.PopulateOperationConfig;
|
||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
|
||||
import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryInterceptor;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.cr.config.r4.QuestionnaireOperationConfig;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
|
||||
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
|
||||
import org.cqframework.cql.cql2elm.model.Model;
|
||||
import org.hl7.cql.model.ModelIdentifier;
|
||||
import org.hl7.elm.r1.VersionedIdentifier;
|
||||
import org.opencds.cqf.cql.engine.execution.CqlEngine;
|
||||
import org.opencds.cqf.cql.engine.runtime.Code;
|
||||
import org.opencds.cqf.fhir.cql.EvaluationSettings;
|
||||
import org.opencds.cqf.fhir.cr.measure.CareGapsProperties;
|
||||
import org.opencds.cqf.fhir.cr.measure.MeasureEvaluationOptions;
|
||||
import org.opencds.cqf.fhir.utility.ValidationProfile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Configuration
|
||||
@Conditional({OnR4Condition.class, CrConfigCondition.class})
|
||||
@Import({
|
||||
CrCommonConfig.class,
|
||||
CrR4Config.class,
|
||||
ApplyOperationConfig.class,
|
||||
ExtractOperationConfig.class,
|
||||
PackageOperationConfig.class,
|
||||
PopulateOperationConfig.class
|
||||
PopulateOperationConfig.class,
|
||||
QuestionnaireOperationConfig.class
|
||||
})
|
||||
public class StarterCrR4Config {
|
||||
private static final Logger ourLogger = LoggerFactory.getLogger(StarterCrR4Config.class);
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public ExecutorService cqlExecutor() {
|
||||
CqlThreadFactory factory = new CqlThreadFactory();
|
||||
ExecutorService executor = Executors.newFixedThreadPool(2, factory);
|
||||
executor = new DelegatingSecurityContextExecutorService(executor);
|
||||
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
CareGapsProperties careGapsProperties(CrProperties theCrProperties) {
|
||||
var careGapsProperties = new CareGapsProperties();
|
||||
careGapsProperties.setCareGapsReporter(theCrProperties.getCareGapsReporter());
|
||||
careGapsProperties.setCareGapsCompositionSectionAuthor(theCrProperties.getCareGapsSectionAuthor());
|
||||
return careGapsProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
MeasureEvaluationOptions measureEvaluationOptions(
|
||||
EvaluationSettings theEvaluationSettings, Map<String, ValidationProfile> theValidationProfiles) {
|
||||
MeasureEvaluationOptions measureEvalOptions = new MeasureEvaluationOptions();
|
||||
measureEvalOptions.setEvaluationSettings(theEvaluationSettings);
|
||||
if (measureEvalOptions.isValidationEnabled()) {
|
||||
measureEvalOptions.setValidationProfiles(theValidationProfiles);
|
||||
}
|
||||
return measureEvalOptions;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EvaluationSettings evaluationSettings(
|
||||
CrProperties theCrProperties,
|
||||
Map<VersionedIdentifier, CompiledLibrary> theGlobalLibraryCache,
|
||||
Map<ModelIdentifier, Model> theGlobalModelCache,
|
||||
Map<String, List<Code>> theGlobalValueSetCache) {
|
||||
var evaluationSettings = EvaluationSettings.getDefault();
|
||||
var cqlOptions = evaluationSettings.getCqlOptions();
|
||||
|
||||
var cqlEngineOptions = cqlOptions.getCqlEngineOptions();
|
||||
Set<CqlEngine.Options> options = EnumSet.noneOf(CqlEngine.Options.class);
|
||||
if (theCrProperties.isCqlRuntimeEnableExpressionCaching()) {
|
||||
options.add(CqlEngine.Options.EnableExpressionCaching);
|
||||
}
|
||||
if (theCrProperties.isCqlRuntimeEnableValidation()) {
|
||||
options.add(CqlEngine.Options.EnableValidation);
|
||||
}
|
||||
cqlEngineOptions.setOptions(options);
|
||||
cqlOptions.setCqlEngineOptions(cqlEngineOptions);
|
||||
|
||||
var cqlCompilerOptions = new CqlCompilerOptions();
|
||||
|
||||
if (theCrProperties.isEnableDateRangeOptimization()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableDateRangeOptimization);
|
||||
}
|
||||
if (theCrProperties.isEnableAnnotations()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableAnnotations);
|
||||
}
|
||||
if (theCrProperties.isEnableLocators()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableLocators);
|
||||
}
|
||||
if (theCrProperties.isEnableResultsType()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableResultTypes);
|
||||
}
|
||||
cqlCompilerOptions.setVerifyOnly(theCrProperties.isCqlCompilerVerifyOnly());
|
||||
if (theCrProperties.isEnableDetailedErrors()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableDetailedErrors);
|
||||
}
|
||||
cqlCompilerOptions.setErrorLevel(theCrProperties.getCqlCompilerErrorSeverityLevel());
|
||||
if (theCrProperties.isDisableListTraversal()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListTraversal);
|
||||
}
|
||||
if (theCrProperties.isDisableListDemotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListDemotion);
|
||||
}
|
||||
if (theCrProperties.isDisableListPromotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableListPromotion);
|
||||
}
|
||||
if (theCrProperties.isEnableIntervalDemotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableIntervalDemotion);
|
||||
}
|
||||
if (theCrProperties.isEnableIntervalPromotion()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.EnableIntervalPromotion);
|
||||
}
|
||||
if (theCrProperties.isDisableMethodInvocation()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableMethodInvocation);
|
||||
}
|
||||
if (theCrProperties.isRequireFromKeyword()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.RequireFromKeyword);
|
||||
}
|
||||
cqlCompilerOptions.setValidateUnits(theCrProperties.isCqlCompilerValidateUnits());
|
||||
if (theCrProperties.isDisableDefaultModelInfoLoad()) {
|
||||
cqlCompilerOptions.setOptions(CqlCompilerOptions.Options.DisableDefaultModelInfoLoad);
|
||||
}
|
||||
cqlCompilerOptions.setSignatureLevel(theCrProperties.getCqlCompilerSignatureLevel());
|
||||
cqlCompilerOptions.setCompatibilityLevel(theCrProperties.getCqlCompilerCompatibilityLevel());
|
||||
cqlCompilerOptions.setAnalyzeDataRequirements(theCrProperties.isCqlCompilerAnalyzeDataRequirements());
|
||||
cqlCompilerOptions.setCollapseDataRequirements(theCrProperties.isCqlCompilerCollapseDataRequirements());
|
||||
|
||||
cqlOptions.setCqlCompilerOptions(cqlCompilerOptions);
|
||||
evaluationSettings.setLibraryCache(theGlobalLibraryCache);
|
||||
evaluationSettings.setModelCache(theGlobalModelCache);
|
||||
evaluationSettings.setValueSetCache(theGlobalValueSetCache);
|
||||
return evaluationSettings;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PostInitProviderRegisterer postInitProviderRegisterer(
|
||||
RestfulServer theRestfulServer, ResourceProviderFactory theResourceProviderFactory) {
|
||||
return new PostInitProviderRegisterer(theRestfulServer, theResourceProviderFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CrProperties crProperties() {
|
||||
return new CrProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<VersionedIdentifier, CompiledLibrary> globalLibraryCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<ModelIdentifier, Model> globalModelCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<String, List<Code>> globalValueSetCache() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ElmCacheResourceChangeListener elmCacheResourceChangeListener(
|
||||
IResourceChangeListenerRegistry theResourceChangeListenerRegistry,
|
||||
DaoRegistry theDaoRegistry,
|
||||
EvaluationSettings theEvaluationSettings) {
|
||||
ElmCacheResourceChangeListener listener =
|
||||
new ElmCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getLibraryCache());
|
||||
theResourceChangeListenerRegistry.registerResourceResourceChangeListener(
|
||||
"Library", SearchParameterMap.newSynchronous(), listener, 1000);
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CodeCacheResourceChangeListener codeCacheResourceChangeListener(
|
||||
IResourceChangeListenerRegistry theResourceChangeListenerRegistry,
|
||||
EvaluationSettings theEvaluationSettings,
|
||||
DaoRegistry theDaoRegistry) {
|
||||
|
||||
CodeCacheResourceChangeListener listener =
|
||||
new CodeCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getValueSetCache());
|
||||
// registry
|
||||
theResourceChangeListenerRegistry.registerResourceResourceChangeListener(
|
||||
"ValueSet", SearchParameterMap.newSynchronous(), listener, 1000);
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResourceChangeListenerRegistryInterceptor resourceChangeListenerRegistryInterceptor() {
|
||||
return new ResourceChangeListenerRegistryInterceptor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import ca.uhn.fhir.jpa.ips.generator.IIpsGeneratorSvc;
|
||||
import ca.uhn.fhir.jpa.ips.generator.IpsGeneratorSvcImpl;
|
||||
import ca.uhn.fhir.jpa.ips.jpa.DefaultJpaIpsGenerationStrategy;
|
||||
import ca.uhn.fhir.jpa.ips.provider.IpsOperationProvider;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user