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);
}
Aggregations