Skip to content

Commit

Permalink
Add settings for CDS Hooks and use latest hapi-fhir-cr configs
Browse files Browse the repository at this point in the history
  • Loading branch information
barhodes committed Oct 19, 2023
1 parent 6d10c0b commit 408da72
Show file tree
Hide file tree
Showing 15 changed files with 474 additions and 538 deletions.
250 changes: 0 additions & 250 deletions src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,6 @@
@EnableConfigurationProperties
public class AppProperties {

private Boolean cr_enabled = false;
//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 Boolean ips_enabled = false;
private Boolean openapi_enabled = false;
private Boolean mdm_enabled = false;
Expand Down Expand Up @@ -197,226 +167,6 @@ public void setPartitioning(Partitioning partitioning) {
this.partitioning = partitioning;
}

public Boolean getCr_enabled() {
return cr_enabled;
}

public void setCr_enabled(Boolean cr_enabled) {
this.cr_enabled = cr_enabled;
}

public boolean isCqlUseEmbeddedLibraries() {
return cql_use_embedded_libraries;
}

public void setCqlUseEmbeddedLibraries(boolean cql_use_embedded_libraries) {
this.cql_use_embedded_libraries = cql_use_embedded_libraries;
}

public boolean isCqlRuntimeDebugLoggingEnabled() {
return cql_runtime_debug_logging_enabled;
}

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 Boolean getIps_enabled() {
return ips_enabled;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/ca/uhn/fhir/jpa/starter/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public ServletRegistrationBean overlayRegistrationBean() {

}

@Bean
IRepositoryFactory repositoryFactory(DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) {
return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer);
}
// @Bean
// IRepositoryFactory repositoryFactory(DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) {
// return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer);
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ca.uhn.fhir.jpa.starter.cdshooks;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class CdsHooksConfigCondition implements Condition {

@Override
public boolean matches(ConditionContext theConditionContext, AnnotatedTypeMetadata theAnnotatedTypeMetadata) {
String property = theConditionContext.getEnvironment().getProperty("hapi.fhir.cdshooks.enabled");
return Boolean.parseBoolean(property);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ca.uhn.fhir.jpa.starter.cdshooks;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "hapi.fhir.cdshooks")
public class CdsHooksProperties {

private boolean enabled;

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

private String clientIdHeaderName;

public String getClientIdHeaderName() {
return clientIdHeaderName;
}

public void setClientIdHeaderName(String clientIdHeaderName) {
this.clientIdHeaderName = clientIdHeaderName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ public class CdsHooksServlet extends HttpServlet {
@Autowired
private AppProperties appProperties;
@Autowired
private ProviderConfiguration providerConfiguration;
@Autowired
ICdsServiceRegistry cdsServiceRegistry;
@Autowired
RestfulServer restfulServer;
@Autowired
@Qualifier(CDS_HOOKS_OBJECT_MAPPER_FACTORY)
ObjectMapper objectMapper;

protected ProviderConfiguration getProviderConfiguration() {
return this.providerConfiguration;
}

// CORS Pre-flight
@Override
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) {
Expand Down Expand Up @@ -103,26 +109,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
private void logRequestInfo(CdsServiceRequestJson request, String jsonRequest) {
logger.info(jsonRequest);
logger.info("cds-hooks hook instance: {}", request.getHookInstance());
// logger.info("cds-hooks maxCodesPerQuery: {}", this.getProviderConfiguration().getMaxCodesPerQuery());
// logger.info("cds-hooks expandValueSets: {}", this.getProviderConfiguration().getExpandValueSets());
// logger.info("cds-hooks queryBatchThreshold: {}", this.getProviderConfiguration().getQueryBatchThreshold());
// logger.info("cds-hooks searchStyle: {}", this.getProviderConfiguration().getSearchStyle());
// logger.info("cds-hooks prefetch maxUriLength: {}", this.getProviderConfiguration().getMaxUriLength());
logger.info("cds-hooks local server address: {}", appProperties.getServer_address());
logger.info("cds-hooks fhir server address: {}", request.getFhirServer());
// logger.info("cds-hooks cql_logging_enabled: {}", this.getProviderConfiguration().getCqlLoggingEnabled());
logger.info("cds-hooks cql_logging_enabled: {}", this.getProviderConfiguration().getCqlLoggingEnabled());
}

private CdsServicesJson getServices() {
return cdsServiceRegistry.getCdsServicesJson();
}

// public DebugMap getDebugMap() {
// DebugMap debugMap = new DebugMap();
// if (cqlProperties.getCqlRuntimeOptions().isDebugLoggingEnabled()) {
// // getOptions().getCqlEngineOptions().isDebugLoggingEnabled()) {
// debugMap.setIsLoggingEnabled(true);
// }
// return debugMap;
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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;

public ProviderConfiguration(boolean cqlLoggingEnabled, String clientIdHeaderName) {
this.cqlLoggingEnabled = cqlLoggingEnabled;
this.clientIdHeaderName = clientIdHeaderName;
}

public ProviderConfiguration(CdsHooksProperties cdsProperties, CrProperties crProperties) {
this.clientIdHeaderName = cdsProperties.getClientIdHeaderName();
this.cqlLoggingEnabled = crProperties.isCqlRuntimeDebugLoggingEnabled();
}

public String getClientIdHeaderName() {
return this.clientIdHeaderName;
}

public boolean getCqlLoggingEnabled() {
return this.cqlLoggingEnabled;
}
}
Loading

0 comments on commit 408da72

Please sign in to comment.