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

Configurable cds-hooks options #228

Merged
merged 1 commit into from
Jul 20, 2020
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
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -154,7 +168,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
context.setExpressionCaching(true);

EvaluationContext<PlanDefinition> evaluationContext = new Stu3EvaluationContext(hook, version, FhirContext.forDstu3().newRestfulGenericClient(baseUrl),
jpaTerminologyProvider, context, library, planDefinition);
jpaTerminologyProvider, context, library,
planDefinition, this.getProviderConfiguration());

this.setAccessControlHeaders(response);

Expand Down
9 changes: 8 additions & 1 deletion dstu3/src/main/resources/hapi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
questionnaireResponseExtract.password=

##################################################
# CDS-Hooks Settings
##################################################
cds_hooks.fhirServer.maxCodesPerQuery=
cds_hooks.fhirServer.expandValueSets=
cds_hooks.fhirServer.searchStyle=
16 changes: 15 additions & 1 deletion r4/src/main/java/org/opencds/cqf/r4/servlet/CdsHooksServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -159,7 +173,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

EvaluationContext<PlanDefinition> evaluationContext = new R4EvaluationContext(hook, version,
FhirContext.forR4().newRestfulGenericClient(baseUrl), jpaTerminologyProvider, context, library,
planDefinition);
planDefinition, this.getProviderConfiguration());

this.setAccessControlHeaders(response);

Expand Down
9 changes: 8 additions & 1 deletion r4/src/main/resources/hapi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
questionnaireResponseExtract.password=

##################################################
# CDS-Hooks Settings
##################################################
cds_hooks.fhirServer.maxCodesPerQuery=
cds_hooks.fhirServer.expandValueSets=
cds_hooks.fhirServer.searchStyle=