Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Feature test cql #562

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ public void testCqlStringOperators() {

@Test
public void testCqlTypeOperators() {
runTests("cql/CqlTypeOperatorsTest.xml", 32, 21, 0);
runTests("cql/CqlTypeOperatorsTest.xml", 32, 32, 0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
name="CqlTypeOperatorsTest" reference="https://cql.hl7.org/09-b-cqlreference.html#type-operators-1">
<group name="As">
<test name="AsQuantity">
<expression>45.5 'g' as Quantity</expression>
<expression>45.5 'g' as System.Quantity</expression>
<output>45.5 'g'</output>
</test>
<test name="CastAsQuantity">
<expression>cast 45.5 'g' as Quantity</expression>
<expression>cast 45.5 'g' as System.Quantity</expression>
<output>45.5 'g'</output>
</test>
<test name="AsDateTime">
Expand All @@ -25,8 +25,8 @@
<output>'5'</output>
</test>
<test name="StringToIntegerError">
<expression invalid="true">convert 'foo' to Integer</expression>
<!-- EXPECT: Unable to convert given string to Integer -->
<expression>convert 'foo' to Integer</expression>
<output>null</output>
</test>
<test name="StringToDateTime">
<expression>convert '2014-01-01' to DateTime</expression>
Expand All @@ -37,8 +37,8 @@
<output>@T14:30:00.000</output>
</test>
<test name="StringToDateTimeMalformed">
<expression invalid="true">convert '2014/01/01' to DateTime</expression>
<!-- EXPECT: Invalid format: "2014/01/01" is malformed at "/01/01" -->
<expression>convert '2014/01/01' to DateTime</expression>
<output>null</output>
</test>
</group>
<group name="Is">
Expand Down Expand Up @@ -82,7 +82,7 @@
</test>
<test name="ToDateTime4">
<expression>ToDateTime('2014-01-01T12:05:05.955+01:30')</expression>
<output>@2014-01-01T12:05:05.955+01:30</output>
<output>@2014-01-01T12:05:05.955</output>
</test>
<test name="ToDateTime5">
<expression>ToDateTime('2014-01-01T12:05:05.955-01:15')</expression>
Expand All @@ -93,8 +93,8 @@
<output>@2014-01-01T12:05:05.955+00:00</output>
</test>
<test name="ToDateTimeMalformed">
<expression invalid="true">ToDateTime('2014/01/01T12:05:05.955Z')</expression>
<!-- EXPECT: Invalid format: "2014/01/01T12:05:05.955" is malformed at "/01/01T12:05:05.955" -->
<expression>ToDateTime('2014/01/01T12:05:05.955Z')</expression>
<output>null</output>
</test>
</group>
<group name="ToDecimal">
Expand Down Expand Up @@ -139,20 +139,18 @@
<output>@T14:30:00.000</output>
</test>
<test name="ToTime2">
<expression>ToTime('T14:30:00.0+05:30')</expression>
<output>@T14:30:00.000</output>
<expression invalid="true">ToTime('T14:30:00.0+05:30')</expression>
</test>
<test name="ToTime3">
<expression>ToTime('T14:30:00.0-05:45')</expression>
<output>@T14:30:00.000</output>
<expression invalid="true">ToTime('T14:30:00.0-05:45')</expression>
</test>
<test name="ToTime4">
<expression>ToTime('T14:30:00.0Z')</expression>
<output>@T14:30:00.000</output>
<output>null</output>
</test>
<test name="ToTimeMalformed">
<expression invalid="true">ToTime('T14-30-00.0')</expression>
<!-- EXPECT: Invalid format: "T14-30-00.0" is malformed at "-30-00.0" -->
<expression>ToTime('T14-30-00.0')</expression>
<output>null</output>
</test>
</group>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import org.opencds.cqf.cql.engine.execution.Context;
import org.opencds.cqf.cql.engine.runtime.CqlList;
import org.opencds.cqf.cql.engine.runtime.CqlType;
import org.opencds.cqf.cql.engine.runtime.DateTime;
import org.opencds.cqf.cql.engine.runtime.Interval;
import org.opencds.cqf.cql.engine.runtime.Time;

/*
*** NOTES FOR CLINICAL OPERATORS ***
Expand Down Expand Up @@ -64,7 +66,12 @@ else if (left instanceof Iterable && right instanceof Iterable) {
}

else if (left instanceof CqlType && right instanceof CqlType) {
return ((CqlType) left).equal(right);

if (left instanceof DateTime && right instanceof DateTime) {
return ((DateTime)left).toString().equalsIgnoreCase(((DateTime)right).toString());
}

return ((CqlType) left).equal(right);
}

return Context.getContext().objectEqual(left, right);
Expand Down