diff --git a/common/src/main/java/org/opencds/cqf/common/config/HapiProperties.java b/common/src/main/java/org/opencds/cqf/common/config/HapiProperties.java index 5b1707dca..251a4a97b 100644 --- a/common/src/main/java/org/opencds/cqf/common/config/HapiProperties.java +++ b/common/src/main/java/org/opencds/cqf/common/config/HapiProperties.java @@ -9,6 +9,7 @@ import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.api.EncodingEnum; +import ca.uhn.fhir.rest.api.SearchStyleEnum; import ca.uhn.fhir.rest.server.ETagSupportEnum; public class HapiProperties { @@ -64,6 +65,10 @@ public class HapiProperties { static final String QUESTIONNAIRE_RESPONSE_USERNAME = "questionnaireResponseExtract.username"; static final String QUESTIONNAIRE_RESPONSE_PASSWORD = "questionnaireResponseExtract.password"; + static final String CDSHOOKS_FHIRSERVER_MAXCODESPERQUERY = "cds_hooks.fhirServer.maxCodesPerQuery"; + static final String CDSHOOKS_FHIRSERVER_EXPANDVALUESETS = "cds_hooks.fhirServer.expandValueSets"; + static final String CDSHOOKS_FHIRSERVER_SEARCHSTYLE= "cds_hooks.fhirServer.searchStyle"; + private static Properties properties; /* @@ -378,4 +383,17 @@ public static Long getReuseCachedSearchResultsMillis() { public static String getQuestionnaireResponseExtractEndpoint() {return HapiProperties.getProperty(QUESTIONNAIRE_RESPONSE_ENDPOINT);} public static String getQuestionnaireResponseExtractUserName(){return HapiProperties.getProperty(QUESTIONNAIRE_RESPONSE_USERNAME);}; public static String getQuestionnaireResponseExtractPassword(){return HapiProperties.getProperty(QUESTIONNAIRE_RESPONSE_PASSWORD);}; + + //************************* CDS_HOOKS **************** + public static Integer getCdsHooksFhirServerMaxCodesPerQuery() { return HapiProperties.getIntegerProperty(CDSHOOKS_FHIRSERVER_MAXCODESPERQUERY, 64);} + public static Boolean getCdsHooksFhirServerExpandValueSets() { return HapiProperties.getBooleanProperty(CDSHOOKS_FHIRSERVER_EXPANDVALUESETS, true);} + public static SearchStyleEnum getCdsHooksFhirServerSearchStyleEnum() { + String searchStyleEnumString = HapiProperties.getProperty(CDSHOOKS_FHIRSERVER_SEARCHSTYLE); + + if (searchStyleEnumString != null && searchStyleEnumString.length() > 0) { + return SearchStyleEnum.valueOf(searchStyleEnumString); + } + + return SearchStyleEnum.GET; + } } diff --git a/dstu3/src/main/java/org/opencds/cqf/dstu3/servlet/CdsHooksServlet.java b/dstu3/src/main/java/org/opencds/cqf/dstu3/servlet/CdsHooksServlet.java index 42e95b516..a86e47a5e 100644 --- a/dstu3/src/main/java/org/opencds/cqf/dstu3/servlet/CdsHooksServlet.java +++ b/dstu3/src/main/java/org/opencds/cqf/dstu3/servlet/CdsHooksServlet.java @@ -30,6 +30,7 @@ import org.opencds.cqf.cds.hooks.Hook; import org.opencds.cqf.cds.hooks.HookFactory; import org.opencds.cqf.cds.hooks.Stu3HookEvaluator; +import org.opencds.cqf.cds.providers.ProviderConfiguration; import org.opencds.cqf.cds.request.JsonHelper; import org.opencds.cqf.cds.request.Request; import org.opencds.cqf.cds.response.CdsCard; @@ -68,6 +69,19 @@ public class CdsHooksServlet extends HttpServlet { private static JpaTerminologyProvider jpaTerminologyProvider; + private ProviderConfiguration providerConfiguration; + + public ProviderConfiguration getProviderConfiguration() { + if (providerConfiguration == null) { + providerConfiguration = new ProviderConfiguration( + HapiProperties.getCdsHooksFhirServerExpandValueSets(), + HapiProperties.getCdsHooksFhirServerMaxCodesPerQuery(), + HapiProperties.getCdsHooksFhirServerSearchStyleEnum()); + } + + return providerConfiguration; + } + // TODO: There's probably a way to wire this all up using Spring public static void setPlanDefinitionProvider(PlanDefinitionApplyProvider planDefinitionProvider) { CdsHooksServlet.planDefinitionProvider = planDefinitionProvider; @@ -154,7 +168,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) context.setExpressionCaching(true); EvaluationContext evaluationContext = new Stu3EvaluationContext(hook, version, FhirContext.forDstu3().newRestfulGenericClient(baseUrl), - jpaTerminologyProvider, context, library, planDefinition); + jpaTerminologyProvider, context, library, + planDefinition, this.getProviderConfiguration()); this.setAccessControlHeaders(response); diff --git a/dstu3/src/main/resources/hapi.properties b/dstu3/src/main/resources/hapi.properties index afa53b1d5..5a8938812 100644 --- a/dstu3/src/main/resources/hapi.properties +++ b/dstu3/src/main/resources/hapi.properties @@ -168,4 +168,11 @@ oauth.serviceText=OAuth2 using SMART-on-FHIR profile (see http://docs.smarthealt questionnaireResponseExtract.enabled=false questionnaireResponseExtract.endpoint=https://cds4cpm-develop.sandbox.alphora.com/cqf-ruler-r4/fhir questionnaireResponseExtract.username= -questionnaireResponseExtract.password= \ No newline at end of file +questionnaireResponseExtract.password= + +################################################## +# CDS-Hooks Settings +################################################## +cds_hooks.fhirServer.maxCodesPerQuery= +cds_hooks.fhirServer.expandValueSets= +cds_hooks.fhirServer.searchStyle= \ No newline at end of file diff --git a/r4/src/main/java/org/opencds/cqf/r4/servlet/CdsHooksServlet.java b/r4/src/main/java/org/opencds/cqf/r4/servlet/CdsHooksServlet.java index 478b23776..3a1bef603 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/servlet/CdsHooksServlet.java +++ b/r4/src/main/java/org/opencds/cqf/r4/servlet/CdsHooksServlet.java @@ -30,6 +30,7 @@ import org.opencds.cqf.cds.hooks.Hook; import org.opencds.cqf.cds.hooks.HookFactory; import org.opencds.cqf.cds.hooks.R4HookEvaluator; +import org.opencds.cqf.cds.providers.ProviderConfiguration; import org.opencds.cqf.cds.request.JsonHelper; import org.opencds.cqf.cds.request.Request; import org.opencds.cqf.cds.response.CdsCard; @@ -68,6 +69,19 @@ public class CdsHooksServlet extends HttpServlet { private static JpaTerminologyProvider jpaTerminologyProvider; + private ProviderConfiguration providerConfiguration; + + public ProviderConfiguration getProviderConfiguration() { + if (providerConfiguration == null) { + providerConfiguration = new ProviderConfiguration( + HapiProperties.getCdsHooksFhirServerExpandValueSets() , + HapiProperties.getCdsHooksFhirServerMaxCodesPerQuery(), + HapiProperties.getCdsHooksFhirServerSearchStyleEnum()); + } + + return providerConfiguration; + } + // TODO: There's probably a way to wire this all up using Spring public static void setPlanDefinitionProvider(PlanDefinitionApplyProvider planDefinitionProvider) { CdsHooksServlet.planDefinitionProvider = planDefinitionProvider; @@ -159,7 +173,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) EvaluationContext evaluationContext = new R4EvaluationContext(hook, version, FhirContext.forR4().newRestfulGenericClient(baseUrl), jpaTerminologyProvider, context, library, - planDefinition); + planDefinition, this.getProviderConfiguration()); this.setAccessControlHeaders(response); diff --git a/r4/src/main/resources/hapi.properties b/r4/src/main/resources/hapi.properties index 5338239e4..5e64ed20b 100644 --- a/r4/src/main/resources/hapi.properties +++ b/r4/src/main/resources/hapi.properties @@ -168,4 +168,11 @@ oauth.serviceText=OAuth2 using SMART-on-FHIR profile (see http://docs.smarthealt questionnaireResponseExtract.enabled=false questionnaireResponseExtract.endpoint=https://cds4cpm-develop.sandbox.alphora.com/cqf-ruler-r4/fhir questionnaireResponseExtract.username= -questionnaireResponseExtract.password= \ No newline at end of file +questionnaireResponseExtract.password= + +################################################## +# CDS-Hooks Settings +################################################## +cds_hooks.fhirServer.maxCodesPerQuery= +cds_hooks.fhirServer.expandValueSets= +cds_hooks.fhirServer.searchStyle= \ No newline at end of file