use of org.opencds.cqf.cql.engine.retrieve.TerminologyAwareRetrieveProvider in project cqf-ruler by DBCG.
the class BaseHookEvaluator method evaluate.
public List<CdsCard> evaluate(EvaluationContext<P> context) throws IOException {
// TODO - this will need some work for libraries with multiple parameters
if (context.getLibrary().getParameters() != null && !(context.getHook() instanceof PatientViewHook)) {
for (ParameterDef params : context.getLibrary().getParameters().getDef()) {
if (params.getParameterTypeSpecifier() instanceof ListTypeSpecifier) {
context.getContext().setParameter(null, params.getName(), context.getContextResources());
}
}
}
// Remote data retriever
RestFhirRetrieveProvider remoteRetriever = new RestFhirRetrieveProvider(new SearchParameterResolver(context.getFhirContext()), context.getHookFhirClient());
remoteRetriever.setTerminologyProvider(context.getContext().resolveTerminologyProvider());
remoteRetriever.setExpandValueSets(context.getProviderConfiguration().getExpandValueSets());
remoteRetriever.setMaxCodesPerQuery(context.getProviderConfiguration().getMaxCodesPerQuery());
remoteRetriever.setSearchStyle(context.getProviderConfiguration().getSearchStyle());
TerminologyAwareRetrieveProvider prefetchRetriever;
if (context.getFhirVersion() == FhirVersionEnum.DSTU3) {
prefetchRetriever = new PrefetchDataProviderStu3(context.getPrefetchResources(), modelResolver);
} else if (context.getFhirVersion() == FhirVersionEnum.DSTU2) {
prefetchRetriever = new PrefetchDataProviderDstu2(context.getPrefetchResources(), modelResolver);
} else {
prefetchRetriever = new PrefetchDataProviderR4(context.getPrefetchResources(), modelResolver);
}
// TODO: Get the "system" terminology provider.
prefetchRetriever.setTerminologyProvider(context.getContext().resolveTerminologyProvider());
PriorityRetrieveProvider priorityRetrieveProvider = new PriorityRetrieveProvider(Arrays.asList(prefetchRetriever, remoteRetriever));
context.getContext().registerDataProvider("http://hl7.org/fhir", new CompositeDataProvider(this.modelResolver, priorityRetrieveProvider));
context.getContext().registerTerminologyProvider(prefetchRetriever.getTerminologyProvider());
return evaluateCdsHooksPlanDefinition(context.getContext(), context.getPlanDefinition(), context.getHook().getRequest().getContext().getPatientId(), context.getSystemFhirClient());
}
Aggregations