Search in sources :

Example 1 with ListTypeSpecifier

use of org.cqframework.cql.elm.execution.ListTypeSpecifier 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());
}
Also used : SearchParameterResolver(org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver) RestFhirRetrieveProvider(org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider) ParameterDef(org.cqframework.cql.elm.execution.ParameterDef) PrefetchDataProviderStu3(org.opencds.cqf.ruler.cdshooks.providers.PrefetchDataProviderStu3) ListTypeSpecifier(org.cqframework.cql.elm.execution.ListTypeSpecifier) PriorityRetrieveProvider(org.opencds.cqf.cql.evaluator.engine.retrieve.PriorityRetrieveProvider) CompositeDataProvider(org.opencds.cqf.cql.engine.data.CompositeDataProvider) PrefetchDataProviderR4(org.opencds.cqf.ruler.cdshooks.providers.PrefetchDataProviderR4) TerminologyAwareRetrieveProvider(org.opencds.cqf.cql.engine.retrieve.TerminologyAwareRetrieveProvider) PrefetchDataProviderDstu2(org.opencds.cqf.ruler.cdshooks.providers.PrefetchDataProviderDstu2)

Aggregations

ListTypeSpecifier (org.cqframework.cql.elm.execution.ListTypeSpecifier)1 ParameterDef (org.cqframework.cql.elm.execution.ParameterDef)1 CompositeDataProvider (org.opencds.cqf.cql.engine.data.CompositeDataProvider)1 RestFhirRetrieveProvider (org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider)1 SearchParameterResolver (org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver)1 TerminologyAwareRetrieveProvider (org.opencds.cqf.cql.engine.retrieve.TerminologyAwareRetrieveProvider)1 PriorityRetrieveProvider (org.opencds.cqf.cql.evaluator.engine.retrieve.PriorityRetrieveProvider)1 PrefetchDataProviderDstu2 (org.opencds.cqf.ruler.cdshooks.providers.PrefetchDataProviderDstu2)1 PrefetchDataProviderR4 (org.opencds.cqf.ruler.cdshooks.providers.PrefetchDataProviderR4)1 PrefetchDataProviderStu3 (org.opencds.cqf.ruler.cdshooks.providers.PrefetchDataProviderStu3)1