From a29321386940e9c3756a3437dda2d6ed7eda1375 Mon Sep 17 00:00:00 2001 From: JP Date: Mon, 8 Jan 2024 09:45:58 -0700 Subject: [PATCH] Bug half time zone (#1313) * Fix fractional timezone offsets * Enable relevant FHIRPath tests --- .../java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java | 2 +- .../test/java/org/cqframework/cql/cql2elm/LiteralTests.java | 5 +++++ .../org/cqframework/cql/cql2elm/DateTimeLiteralTest.cql | 3 +++ .../src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java | 2 -- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java index 74c0d12ba..ae92342b5 100755 --- a/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java +++ b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.java @@ -976,7 +976,7 @@ private Expression parseDateTimeLiteral(String input) { } result.setTimezoneOffset(libraryBuilder.createLiteral( - (double) (hourOffset + (minuteOffset / 60)) * offsetPolarity)); + (double) (hourOffset + ((double) minuteOffset / 60)) * offsetPolarity)); } else { if (matcher.group(26) != null) { int hourOffset = Integer.parseInt(matcher.group(26)); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java index 1cd9d95e9..d35eb4863 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java @@ -67,6 +67,11 @@ public void dateTimeLiteralTests() throws IOException { def = defs.get("UTCDateLiteral"); assertThat(def, hasTypeAndResult(DateTime.class, "System.DateTime")); + + def = defs.get("TimeZoneHalfHourLiteral"); + assertThat(def, hasTypeAndResult(DateTime.class, "System.DateTime")); + dateTime = (DateTime) def.getExpression(); + assertThat(dateTime.getTimezoneOffset(), literalFor(1.5)); } @Test diff --git a/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/DateTimeLiteralTest.cql b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/DateTimeLiteralTest.cql index 12f35e876..627840cc9 100644 --- a/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/DateTimeLiteralTest.cql +++ b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/DateTimeLiteralTest.cql @@ -28,6 +28,9 @@ define UTCDateTimeLiteral: @2014-02-12T10:30:15.0000Z define TimeZoneDateTimeLiteral: @2014-02-12T10:30:15.0000-07:00 define TimeZonePositiveDateTimeLiteral: @2014-02-12T10:30:15.0000+07:00 +// Test for https://github.com/cqframework/clinical_quality_language/issues/1298 +define TimeZoneHalfHourLiteral: @2014-01-01T12:05:05.955+01:30 + define YearExpression: 1 year define YearsExpression: 10 years define MonthExpression: 1 month diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java index de77af4d0..ec3dd1b79 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java @@ -142,8 +142,6 @@ public static Object[][] dataMethod() { "cql/CqlTypeOperatorsTest/As/CastAsQuantity", "cql/CqlTypeOperatorsTest/Convert/StringToDateTimeMalformed", "cql/CqlTypeOperatorsTest/Convert/StringToIntegerError", - "cql/CqlTypeOperatorsTest/ToDateTime/ToDateTime4", - "cql/CqlTypeOperatorsTest/ToDateTime/ToDateTime5", "cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeMalformed", "cql/CqlTypeOperatorsTest/ToTime/ToTime2", "cql/CqlTypeOperatorsTest/ToTime/ToTime3",