Search in sources :

Example 1 with Dstu3FhirTerminologyProvider

use of org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider in project cqf-ruler by DBCG.

the class CqlExecutionProvider method setupEngine.

private CqlEngine setupEngine(String subject, Parameters parameters, Endpoint dataEndpoint, Endpoint terminologyEndpoint, Bundle data, boolean useServerData, LibraryLoader libraryLoader, VersionedIdentifier libraryIdentifier, RequestDetails theRequestDetails) {
    TerminologyProvider terminologyProvider;
    if (terminologyEndpoint != null) {
        IGenericClient client = Clients.forEndpoint(getFhirContext(), terminologyEndpoint);
        terminologyProvider = new Dstu3FhirTerminologyProvider(client);
    } else {
        terminologyProvider = jpaTerminologyProviderFactory.create(theRequestDetails);
    }
    DataProvider dataProvider;
    List<RetrieveProvider> retrieveProviderList = new ArrayList<>();
    if (useServerData) {
        JpaFhirRetrieveProvider jpaRetriever = new JpaFhirRetrieveProvider(getDaoRegistry(), new SearchParameterResolver(getFhirContext()));
        jpaRetriever.setTerminologyProvider(terminologyProvider);
        // Assume it's a different server, therefore need to expand.
        if (terminologyEndpoint != null) {
            jpaRetriever.setExpandValueSets(true);
        }
        retrieveProviderList.add(jpaRetriever);
    }
    if (dataEndpoint != null) {
        IGenericClient client = Clients.forEndpoint(dataEndpoint);
        RestFhirRetrieveProvider restRetriever = new RestFhirRetrieveProvider(new SearchParameterResolver(getFhirContext()), client);
        restRetriever.setTerminologyProvider(terminologyProvider);
        if (terminologyEndpoint == null || (terminologyEndpoint != null && !terminologyEndpoint.getAddress().equals(dataEndpoint.getAddress()))) {
            restRetriever.setExpandValueSets(true);
        }
        retrieveProviderList.add(restRetriever);
    }
    if (data != null) {
        BundleRetrieveProvider bundleRetriever = new BundleRetrieveProvider(getFhirContext(), data);
        bundleRetriever.setTerminologyProvider(terminologyProvider);
        retrieveProviderList.add(bundleRetriever);
    }
    PriorityRetrieveProvider priorityProvider = new PriorityRetrieveProvider(retrieveProviderList);
    dataProvider = new CompositeDataProvider(myModelResolver, priorityProvider);
    return new CqlEngine(libraryLoader, Collections.singletonMap("http://hl7.org/fhir", dataProvider), terminologyProvider);
}
Also used : JpaFhirRetrieveProvider(org.opencds.cqf.ruler.cql.JpaFhirRetrieveProvider) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) ArrayList(java.util.ArrayList) CqlEngine(org.opencds.cqf.cql.engine.execution.CqlEngine) CompositeDataProvider(org.opencds.cqf.cql.engine.data.CompositeDataProvider) DataProvider(org.opencds.cqf.cql.engine.data.DataProvider) SearchParameterResolver(org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver) BundleRetrieveProvider(org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider) TerminologyProvider(org.opencds.cqf.cql.engine.terminology.TerminologyProvider) Dstu3FhirTerminologyProvider(org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider) RestFhirRetrieveProvider(org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider) Dstu3FhirTerminologyProvider(org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider) PriorityRetrieveProvider(org.opencds.cqf.cql.evaluator.engine.retrieve.PriorityRetrieveProvider) CompositeDataProvider(org.opencds.cqf.cql.engine.data.CompositeDataProvider) RestFhirRetrieveProvider(org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider) JpaFhirRetrieveProvider(org.opencds.cqf.ruler.cql.JpaFhirRetrieveProvider) RetrieveProvider(org.opencds.cqf.cql.engine.retrieve.RetrieveProvider) BundleRetrieveProvider(org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider) PriorityRetrieveProvider(org.opencds.cqf.cql.evaluator.engine.retrieve.PriorityRetrieveProvider)

Example 2 with Dstu3FhirTerminologyProvider

use of org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider in project cqf-ruler by DBCG.

the class EvaluationContext method getDataProvider.

private DataProvider getDataProvider() {
    if (remoteProvider == null) {
        ModelResolver resolver = modelResolver;
        TerminologyProvider terminologyProvider;
        switch(fhirVersion) {
            case DSTU2:
                terminologyProvider = new Dstu3FhirTerminologyProvider(this.getSystemFhirClient());
                break;
            case DSTU3:
                terminologyProvider = new Dstu3FhirTerminologyProvider(this.getSystemFhirClient());
                break;
            case R4:
                terminologyProvider = new R4FhirTerminologyProvider(this.getSystemFhirClient());
                break;
            default:
                throw new NotImplementedException("This CDS Hooks implementation is not configured for FHIR version: " + fhirVersion.getFhirVersionString());
        }
        RestFhirRetrieveProvider provider = new RestFhirRetrieveProvider(new SearchParameterResolver(this.fhirContext), this.getHookFhirClient());
        provider.setTerminologyProvider(terminologyProvider);
        provider.setExpandValueSets(this.providerConfiguration.getExpandValueSets());
        provider.setMaxCodesPerQuery(this.providerConfiguration.getMaxCodesPerQuery());
        provider.setSearchStyle(this.providerConfiguration.getSearchStyle());
        this.remoteProvider = new CompositeDataProvider(resolver, provider);
    }
    return remoteProvider;
}
Also used : SearchParameterResolver(org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver) TerminologyProvider(org.opencds.cqf.cql.engine.terminology.TerminologyProvider) R4FhirTerminologyProvider(org.opencds.cqf.cql.engine.fhir.terminology.R4FhirTerminologyProvider) Dstu3FhirTerminologyProvider(org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider) RestFhirRetrieveProvider(org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider) NotImplementedException(org.opencds.cqf.ruler.cdshooks.exceptions.NotImplementedException) Dstu3FhirTerminologyProvider(org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider) CompositeDataProvider(org.opencds.cqf.cql.engine.data.CompositeDataProvider) R4FhirTerminologyProvider(org.opencds.cqf.cql.engine.fhir.terminology.R4FhirTerminologyProvider) ModelResolver(org.opencds.cqf.cql.engine.model.ModelResolver)

Aggregations

CompositeDataProvider (org.opencds.cqf.cql.engine.data.CompositeDataProvider)2 RestFhirRetrieveProvider (org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider)2 SearchParameterResolver (org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver)2 Dstu3FhirTerminologyProvider (org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider)2 TerminologyProvider (org.opencds.cqf.cql.engine.terminology.TerminologyProvider)2 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)1 ArrayList (java.util.ArrayList)1 DataProvider (org.opencds.cqf.cql.engine.data.DataProvider)1 CqlEngine (org.opencds.cqf.cql.engine.execution.CqlEngine)1 R4FhirTerminologyProvider (org.opencds.cqf.cql.engine.fhir.terminology.R4FhirTerminologyProvider)1 ModelResolver (org.opencds.cqf.cql.engine.model.ModelResolver)1 RetrieveProvider (org.opencds.cqf.cql.engine.retrieve.RetrieveProvider)1 BundleRetrieveProvider (org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider)1 PriorityRetrieveProvider (org.opencds.cqf.cql.evaluator.engine.retrieve.PriorityRetrieveProvider)1 NotImplementedException (org.opencds.cqf.ruler.cdshooks.exceptions.NotImplementedException)1 JpaFhirRetrieveProvider (org.opencds.cqf.ruler.cql.JpaFhirRetrieveProvider)1