cqframework / cql-engine

Clinical Quality Language Evaluation Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Equivalence/Equal Evaluation issues

c-schuler opened this issue · comments

The spec dictates that the equivalence operation always returns true or false. However, there are several places in the EquivalenceEvaluator logic where null is returned.
The following example illustrates the invalid behavior:
define EquivalenceTest: Today() ~ Now() // returns null - should be false

Additionally, the EquivalenceEvaluator is not accounting for Code or Concept types.

I am including issues #70 and #89 as part of this issue as well.

As it happens I actually "fixed" one common case of this while working on the #90 refactor, but then I found that doing so changed the outcome of several tests so I backed out on that change as I wanted to keep #90 from changing any behaviours.

That fix was this in Value.similar():

// mismatched types not allowed
if (!left.getClass().equals(right.getClass())) {
    // Note: Either (or both) input Java Object might be invalid, not representing any CQL value.
    return mode.equals(SimilarityMode.EQUAL) ? null : false;
}

Also, pull request #88 fixed this for Code types, or at least it added the distinct Equivalent logic.

Fixed in #93