-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DateTime initialization to always use offset from State and never…
… from null (#1269) * First commit. * More changes with experiments. * Small change to test. * Add logging to try to figure out why the test passes on the github pipeline. * More logging. * Even more logging. * Refactor DateTime constructor code to enable unit tests using custom timezones and default offset dates. * Get rid of all known code that relies on the default timezone and instead rely on either the default offsetdatetime. * Run CqlInternalTypeRepresentationSuiteTest with multiple current times and timezones. * Throw Exceptions for null offsets in DateTime. Pass in offsets from State whenever possible. Fix most units with non-null offsets. There are still test failures to investigate. Lots of cleanup needs to be done afterward. * All tests pass. Lots of code and TODOs to cleanup. Need to test on another machine on a DST date. * Add DST and non-DST "now" logic to TypeConverter tests to replicate test failures on machine set to DST date. * Try a fix for ***TypeConverter tests that I'm not sure about... * Fix one use case for DateTimeType conversion that failed on Nov 1st. * Try latest fix for fhir date time conversion. * Ensure tests work on Nov 1st. * Start cleaning up TODOs and commented out and abandoned code. * Enhanced some tests and clean up more TODOs. * Enhance more tests. * Enhance even more tests. * Enhance all TypeConverter tests. * More cleanup and refactoring and removing TODOs. * Last set of tweaks to simplify the implementation. * Add tests for equals --------- Co-authored-by: JP <jonathan.i.percival@gmail.com>
- Loading branch information
1 parent
2985f47
commit 75e55e9
Showing
29 changed files
with
841 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/Issue863.cql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
library Issue863 | ||
|
||
parameter "Measurement Period" Interval<DateTime> default Interval[@2021-01-01T00:00:00.000, @2022-01-01T00:00:00.000) | ||
|
||
define "the interval": //Interval[2020-07-01T00:00:00.000, 2021-07-01T00:00:00.000) | ||
Interval[start of "Measurement Period" - 6 months, start of "Measurement Period" + 6 months) | ||
|
||
define "in interval 1": //false | ||
@2020-07-01 in Interval[start of "Measurement Period" - 6 months, start of "Measurement Period" + 6 months) | ||
|
||
define "in interval 2": //true | ||
@2020-07-01T01:00:00.000 in Interval[start of "Measurement Period" - 6 months, start of "Measurement Period" + 6 months) | ||
|
||
define "in interval 3": //false | ||
@2020-07-01T00:59:59.999 in Interval[start of "Measurement Period" - 6 months, start of "Measurement Period" + 6 months) | ||
|
||
define "in interval 4": //true | ||
@2020-07-01 in Interval[@2020-07-01T00:00:00.000, @2021-07-01T00:00:00.000) | ||
|
||
define "in interval 5": //true | ||
@2020-07-01T00:00:00.000 in Interval[@2020-07-01T00:00:00.000, @2021-07-01T00:00:00.000) | ||
|
||
define "in interval 6": //false | ||
@2020-07-01 in "the interval" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...gine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/ConverterTestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.opencds.cqf.cql.engine.fhir.converter; | ||
|
||
import org.testng.annotations.DataProvider; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.Month; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class ConverterTestUtils { | ||
static final LocalDateTime DST_2022_11_01 = LocalDateTime.of(2022, Month.NOVEMBER, 1, 0, 0, 0); | ||
static final LocalDateTime DST_2023_11_01 = LocalDateTime.of(2023, Month.NOVEMBER, 1, 0, 0, 0); | ||
static final LocalDateTime DST_2023_11_03 = LocalDateTime.of(2023, Month.NOVEMBER, 3, 0, 0, 0); | ||
static final LocalDateTime NON_DST_2022_01_01 = LocalDateTime.of(2022, Month.JANUARY, 1, 0, 0, 0); | ||
static final LocalDateTime NON_DST_2023_01_01 = LocalDateTime.of(2023, Month.JANUARY, 1, 0, 0, 0); | ||
static final LocalDateTime NON_DST_2022_11_10 = LocalDateTime.of(2022, Month.NOVEMBER, 10, 0, 0, 0); | ||
static final LocalDateTime NON_DST_2023_11_10 = LocalDateTime.of(2023, Month.NOVEMBER, 10, 0, 0, 0); | ||
static final LocalDateTime NON_DST_2023_11_14 = LocalDateTime.of(2023, Month.NOVEMBER, 14, 0, 0, 0); | ||
static final DateTimeFormatter YYYY_MM_DD = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | ||
|
||
@DataProvider | ||
static Object[][] dateTimes() { | ||
return new Object[][] {{DST_2023_11_01, DST_2023_11_01, DST_2023_11_03}, {NON_DST_2023_11_14, NON_DST_2023_11_10, NON_DST_2023_11_14}, {NON_DST_2023_11_14, DST_2023_11_01, DST_2023_11_03}, {DST_2023_11_01, NON_DST_2023_11_10, NON_DST_2023_11_14}}; | ||
} | ||
|
||
@DataProvider | ||
static Object[][] startAndEndTimes() { | ||
return new Object[][] {{DST_2023_11_01, DST_2023_11_03}, {NON_DST_2023_11_10, NON_DST_2023_11_14}, {DST_2023_11_01, DST_2023_11_03}, {NON_DST_2023_11_10, NON_DST_2023_11_14}, {DST_2022_11_01, DST_2023_11_03}, {NON_DST_2022_11_10, NON_DST_2023_11_10}, {NON_DST_2022_01_01, NON_DST_2023_01_01}}; | ||
} | ||
|
||
@DataProvider | ||
static Object[][] startAndEndYears() { | ||
return new Object[][] {{DST_2022_11_01, 2019, 2020}, {NON_DST_2023_11_14, 2019, 2020},{DST_2022_11_01, 2018, 2022}, {NON_DST_2023_11_14, 2018, 2022}}; | ||
} | ||
@DataProvider | ||
static Object[][] nowsAndEvaluationTimes() { | ||
return new Object[][] {{NON_DST_2022_01_01, NON_DST_2023_01_01}, {DST_2022_11_01, NON_DST_2023_01_01}, {NON_DST_2022_11_10, NON_DST_2023_01_01}}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.