Skip to content

Commit

Permalink
Merge branch 'master' into br-1475-mapping-signaturelevel
Browse files Browse the repository at this point in the history
  • Loading branch information
JPercival authored Dec 17, 2024
2 parents 4542157 + 10af73a commit 390a643
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
public class AnyInValueSetEvaluator {

public static Object internalEvaluate(Object codes, ValueSetRef valueSetRef, Object valueset, State state) {
if (codes == null) {
return false;
}

Object vs = null;
if (valueSetRef != null) {
vs = ValueSetRefEvaluator.toValueSet(state, valueSetRef);
} else if (valueset != null) {
vs = valueset;
}

if (codes == null || vs == null) return null;
if (vs == null) {
return null;
}

if (codes instanceof Iterable) {
Object result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ The in (Valueset) operators determine whether or not a given code is in a partic

public class InValueSetEvaluator {
public static Object inValueSet(Object code, Object valueset, State state) {

if (code == null || valueset == null) {
if (code == null) {
return false;
}
if (valueset == null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.opencds.cqf.cql.engine.elm.executing;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;

import org.hl7.elm.r1.ValueSetRef;
import org.junit.jupiter.api.Test;
import org.opencds.cqf.cql.engine.execution.Environment;
import org.opencds.cqf.cql.engine.execution.State;
import org.opencds.cqf.cql.engine.runtime.ValueSet;

public class AnyInValueSetEvaluatorTest {

@Test
void issue1469FalseOnNullCode() {
var env = new Environment(null);
var state = new State(env);
var valueSet = new ValueSet();
var valueSetRef = new ValueSetRef();

Object actual = AnyInValueSetEvaluator.internalEvaluate(null, valueSetRef, valueSet, state);
assertInstanceOf(Boolean.class, actual);
assertFalse((Boolean) actual);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.opencds.cqf.cql.engine.elm.executing;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;

import org.junit.jupiter.api.Test;
import org.opencds.cqf.cql.engine.execution.Environment;
import org.opencds.cqf.cql.engine.execution.State;
import org.opencds.cqf.cql.engine.runtime.ValueSet;

public class InValueSetEvaluatorTest {

@Test
void issue1469FalseOnNullCode() {
var env = new Environment(null);
var state = new State(env);
var valueSet = new ValueSet();

Object actual = InValueSetEvaluator.inValueSet(null, valueSet, state);
assertInstanceOf(Boolean.class, actual);
assertFalse((Boolean) actual);
}
}

0 comments on commit 390a643

Please sign in to comment.