cqframework / cql-engine

Clinical Quality Language Evaluation Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function signature with Tuple argument can't be invoked at runtime

duncand opened this issue · comments

Run the following CQL:

define e1: f1(Tuple { y: 3 });
define function f1(x Tuple { y Integer }) returns Integer: x.y

This successfully translates but the Engine throws a runtime exception:

>> Error: Could not resolve call to operator 'f1' in library 'null'.
>> f1 [2:1] Definition successfully validated

The exception is thrown in Context.resolveFunctionRef() due to the following line resulting in false:

isMatch = isType(resolveType(argument), resolveOperandType(operandDef));

Fundamentally the error is that isType() is asking this, which evaluates to false:

"class org.cqframework.cql.elm.execution.Tuple".isAssignableFrom("class org.opencds.cqf.cql.runtime.Tuple")

A workaround exists for the above CQL which can make it run successfully, by wrapping the Tuple in a singleton list:

define e1: f1(Tuple { y: 3 });
define function f1(x List<Tuple { y Integer }>) returns Integer: SingletonFrom(x).y

Then we get the expected result:

>> e1 [1:1] 3
>> f1 [2:1] Definition successfully validated

The task of this ticket is to fix the CQL Engine so that this workaround is not necessary.

Resolved in release 1.2.20