Skip to content

Commit

Permalink
Merge pull request #228 from DBCG/feature-configurable-cds-callback
Browse files Browse the repository at this point in the history
Configurable cds-hooks options
  • Loading branch information
Adam Stevenson authored Jul 20, 2020
2 parents ee443d3 + c744557 commit 84e0aeb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
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=

0 comments on commit 84e0aeb

Please sign in to comment.