Search in sources :

Example 1 with ExternalFunctionProvider

use of org.opencds.cqf.cql.engine.data.ExternalFunctionProvider in project quality-measure-and-cohort-service by Alvearie.

the class SparkCqlEvaluator method evaluate.

/**
 * Evaluate the input CQL for a single context + data pair.
 *
 * @param contextName     Context name corresponding to the library context key
 *                        currently under evaluation.
 * @param resultsSchema   StructType containing the schema data for the output table
 *                        that will be created.
 * @param rowsByContext   Data for a single evaluation context
 * @param dataTypeAliases Mapping of data type to abstract type
 * @param perContextAccum Spark accumulator that tracks each individual context
 *                        evaluation
 * @param errorAccum Spark accumulator that tracks CQL evaluation errors
 * @param batchRunTime    Single unified timestamp for all contexts
 * @return Evaluation results for all expressions evaluated keyed by the context
 *         ID. Expression names are automatically namespaced according to the
 *         library name to avoid issues arising for expression names matching
 *         between libraries (e.g. LibraryName.ExpressionName).
 * @throws Exception if the model info or CQL libraries cannot be loaded for any
 *                   reason
 */
protected Iterator<Tuple2<Object, Row>> evaluate(String contextName, StructType resultsSchema, Tuple2<Object, List<Row>> rowsByContext, Map<String, String> dataTypeAliases, LongAccumulator perContextAccum, CollectionAccumulator<EvaluationError> errorAccum, ZonedDateTime batchRunTime) throws Exception {
    CqlLibraryProvider provider = libraryProvider.get();
    if (provider == null) {
        provider = createLibraryProvider();
        libraryProvider.set(provider);
    }
    CqlTerminologyProvider termProvider = terminologyProvider.get();
    if (termProvider == null) {
        termProvider = createTerminologyProvider();
        terminologyProvider.set(termProvider);
    }
    ExternalFunctionProvider funProvider = functionProvider.get();
    if (funProvider == null) {
        funProvider = createExternalFunctionProvider();
        functionProvider.set(funProvider);
    }
    return evaluate(provider, termProvider, funProvider, contextName, resultsSchema, rowsByContext, dataTypeAliases, perContextAccum, errorAccum, batchRunTime);
}
Also used : ExternalFunctionProvider(org.opencds.cqf.cql.engine.data.ExternalFunctionProvider) CohortExternalFunctionProvider(com.ibm.cohort.cql.functions.CohortExternalFunctionProvider) CqlLibraryProvider(com.ibm.cohort.cql.library.CqlLibraryProvider) PriorityCqlLibraryProvider(com.ibm.cohort.cql.library.PriorityCqlLibraryProvider) HadoopBasedCqlLibraryProvider(com.ibm.cohort.cql.library.HadoopBasedCqlLibraryProvider) TranslatingCqlLibraryProvider(com.ibm.cohort.cql.translation.TranslatingCqlLibraryProvider) ClasspathCqlLibraryProvider(com.ibm.cohort.cql.library.ClasspathCqlLibraryProvider) CqlTerminologyProvider(com.ibm.cohort.cql.terminology.CqlTerminologyProvider)

Aggregations

CohortExternalFunctionProvider (com.ibm.cohort.cql.functions.CohortExternalFunctionProvider)1 ClasspathCqlLibraryProvider (com.ibm.cohort.cql.library.ClasspathCqlLibraryProvider)1 CqlLibraryProvider (com.ibm.cohort.cql.library.CqlLibraryProvider)1 HadoopBasedCqlLibraryProvider (com.ibm.cohort.cql.library.HadoopBasedCqlLibraryProvider)1 PriorityCqlLibraryProvider (com.ibm.cohort.cql.library.PriorityCqlLibraryProvider)1 CqlTerminologyProvider (com.ibm.cohort.cql.terminology.CqlTerminologyProvider)1 TranslatingCqlLibraryProvider (com.ibm.cohort.cql.translation.TranslatingCqlLibraryProvider)1 ExternalFunctionProvider (org.opencds.cqf.cql.engine.data.ExternalFunctionProvider)1