From 73c8623afe07e1805d08b57ca7fb1c38b1bf29b2 Mon Sep 17 00:00:00 2001 From: c-schuler Date: Wed, 12 Apr 2023 21:36:10 -0600 Subject: [PATCH] Added client_id configuration to Cds Hooks properties --- .../ruler/cdshooks/CdsHooksProperties.java | 14 ++++++++-- .../ruler/cdshooks/dstu3/CdsHooksServlet.java | 8 ++++-- .../providers/ProviderConfiguration.java | 27 ++++++++++++------- .../ruler/cdshooks/r4/CdsHooksServlet.java | 8 ++++-- .../src/main/resources/application.yaml | 1 + server/src/main/resources/application.yaml | 7 ++--- 6 files changed, 46 insertions(+), 19 deletions(-) diff --git a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/CdsHooksProperties.java b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/CdsHooksProperties.java index b56031eed..e18adf615 100644 --- a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/CdsHooksProperties.java +++ b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/CdsHooksProperties.java @@ -17,6 +17,16 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } + private String clientIdHeaderName; + + public String getClientIdHeaderName() { + return clientIdHeaderName; + } + + public void setClientIdHeaderName(String clientIdHeaderName) { + this.clientIdHeaderName = clientIdHeaderName; + } + private FhirServer fhirServer = new FhirServer(); public FhirServer getFhirServer() { @@ -27,7 +37,7 @@ public void setFhirServer(FhirServer fhirServer) { this.fhirServer = fhirServer; } - public class FhirServer { + public static class FhirServer { private Integer maxCodesPerQuery; public Integer getMaxCodesPerQuery() { @@ -79,7 +89,7 @@ public void setPrefetch(Prefetch prefetch) { this.prefetch = prefetch; } - public class Prefetch { + public static class Prefetch { private Integer maxUriLength; public Integer getMaxUriLength() { diff --git a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/dstu3/CdsHooksServlet.java b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/dstu3/CdsHooksServlet.java index 6bc7f3780..955db6c94 100644 --- a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/dstu3/CdsHooksServlet.java +++ b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/dstu3/CdsHooksServlet.java @@ -154,8 +154,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) useServerData = new BooleanType(false); remoteDataEndpoint = new Endpoint().setAddress(cdsHooksRequest.fhirServer); if (cdsHooksRequest.fhirAuthorization != null) { - remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType + ": " - + cdsHooksRequest.fhirAuthorization.accessToken); + remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType + + ": " + cdsHooksRequest.fhirAuthorization.accessToken); + if (cdsHooksRequest.fhirAuthorization.subject != null) { + remoteDataEndpoint.addHeader(this.getProviderConfiguration().getClientIdHeaderName() + + ": " + cdsHooksRequest.fhirAuthorization.subject); + } } } Bundle data = CdsHooksUtil.getPrefetchResources(cdsHooksRequest); diff --git a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/providers/ProviderConfiguration.java b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/providers/ProviderConfiguration.java index deda0f4da..5a64c1b44 100644 --- a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/providers/ProviderConfiguration.java +++ b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/providers/ProviderConfiguration.java @@ -7,24 +7,26 @@ public class ProviderConfiguration { - public static final ProviderConfiguration DEFAULT_PROVIDER_CONFIGURATION = new ProviderConfiguration(true, null, - SearchStyleEnum.GET, 8000, false, null); + public static final ProviderConfiguration DEFAULT_PROVIDER_CONFIGURATION = new ProviderConfiguration(true, 64, + SearchStyleEnum.GET, 8000, false, 5, "client_id"); - private Integer maxCodesPerQuery; - private SearchStyleEnum searchStyle; - private boolean expandValueSets; - private Integer queryBatchThreshold; - private int maxUriLength; - private boolean cqlLoggingEnabled; + private final Integer maxCodesPerQuery; + private final SearchStyleEnum searchStyle; + private final boolean expandValueSets; + private final Integer queryBatchThreshold; + private final Integer maxUriLength; + private final String clientIdHeaderName; + private final boolean cqlLoggingEnabled; public ProviderConfiguration(boolean expandValueSets, Integer maxCodesPerQuery, SearchStyleEnum searchStyle, - int maxUriLength, boolean cqlLoggingEnabled, Integer queryBatchThreshold) { + Integer maxUriLength, boolean cqlLoggingEnabled, Integer queryBatchThreshold, String clientIdHeaderName) { this.maxCodesPerQuery = maxCodesPerQuery; this.searchStyle = searchStyle; this.expandValueSets = expandValueSets; this.maxUriLength = maxUriLength; this.cqlLoggingEnabled = cqlLoggingEnabled; this.queryBatchThreshold = queryBatchThreshold; + this.clientIdHeaderName = clientIdHeaderName; } public ProviderConfiguration(CdsHooksProperties cdsProperties, CqlProperties cqlProperties) { @@ -33,6 +35,7 @@ public ProviderConfiguration(CdsHooksProperties cdsProperties, CqlProperties cql this.searchStyle = cdsProperties.getFhirServer().getSearchStyle(); this.maxUriLength = cdsProperties.getPrefetch().getMaxUriLength(); this.queryBatchThreshold = cdsProperties.getFhirServer().getQueryBatchThreshold(); + this.clientIdHeaderName = cdsProperties.getClientIdHeaderName(); this.cqlLoggingEnabled = cqlProperties.getOptions().getCqlEngineOptions().isDebugLoggingEnabled(); } @@ -50,10 +53,14 @@ public boolean getExpandValueSets() { public Integer getQueryBatchThreshold() { return this.queryBatchThreshold; } - public int getMaxUriLength() { + public Integer getMaxUriLength() { return this.maxUriLength; } + public String getClientIdHeaderName() { + return this.clientIdHeaderName; + } + public boolean getCqlLoggingEnabled() { return this.cqlLoggingEnabled; } diff --git a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/r4/CdsHooksServlet.java b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/r4/CdsHooksServlet.java index afd62cd5e..f10dd1e7a 100644 --- a/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/r4/CdsHooksServlet.java +++ b/plugin/cds-hooks/src/main/java/org/opencds/cqf/ruler/cdshooks/r4/CdsHooksServlet.java @@ -158,8 +158,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) useServerData = new BooleanType(false); remoteDataEndpoint = new Endpoint().setAddress(cdsHooksRequest.fhirServer); if (cdsHooksRequest.fhirAuthorization != null) { - remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType + ": " - + cdsHooksRequest.fhirAuthorization.accessToken); + remoteDataEndpoint.addHeader(cdsHooksRequest.fhirAuthorization.tokenType + + ": " + cdsHooksRequest.fhirAuthorization.accessToken); + if (cdsHooksRequest.fhirAuthorization.subject != null) { + remoteDataEndpoint.addHeader(this.getProviderConfiguration().getClientIdHeaderName() + + ": " + cdsHooksRequest.fhirAuthorization.subject); + } } } Bundle data = CdsHooksUtil.getPrefetchResources(cdsHooksRequest); diff --git a/plugin/cds-hooks/src/main/resources/application.yaml b/plugin/cds-hooks/src/main/resources/application.yaml index 4e06a467b..04e9919bc 100644 --- a/plugin/cds-hooks/src/main/resources/application.yaml +++ b/plugin/cds-hooks/src/main/resources/application.yaml @@ -2,6 +2,7 @@ hapi: fhir: cdshooks: enabled: true + clientIdHeaderName: client_id fhirserver: expandValueSets: true maxCodesPerQuery: 64 diff --git a/server/src/main/resources/application.yaml b/server/src/main/resources/application.yaml index 3e729202e..711270d69 100644 --- a/server/src/main/resources/application.yaml +++ b/server/src/main/resources/application.yaml @@ -99,10 +99,11 @@ hapi: ## CDS Hook Settings cdshooks: enabled: true + clientIdHeaderName: client_id fhirserver: -# expandValueSets: true -# maxCodesPerQuery: 64 -# queryBatchThreshold: 10 + expandValueSets: true + maxCodesPerQuery: 64 + queryBatchThreshold: 5 searchStyle: GET prefetch: maxUriLength: 8000