Skip to content

added tests for timezone offset tests - #88

Open
bryantaustin13 wants to merge 9 commits into
cqframework:mainfrom
bryantaustin13:issue81_Timezoneoffset-policy-tests
Open

bryantaustin13 wants to merge 9 commits into
cqframework:mainfrom
bryantaustin13:issue81_Timezoneoffset-policy-tests

Conversation

@bryantaustin13

@bryantaustin13 bryantaustin13 commented Nov 5, 2025 •

Copy link
Copy Markdown
Contributor

uses codes from HL7/cql#103 (comment)

Answers this issue
#81 -- Timezoneoffset policy tests

Use this version of cql-tests-runner:
cqframework/cql-tests-runner#77 (comment)

@raleigh-g-thompson raleigh-g-thompson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Incorrect outputs on the three "NullWhen..." tests in the "No default offset" group — shouldn't these be null rather than true?
  2. Missing version attribute — why is there no version attribute on the Policy: Default to server offset (normalize offset-less to server) group?
  3. {{SERVER_OFFSET_ISO}} placeholder — could you add a comment explaining the runtime substitution mechanism to help future maintainers?
  4. New capability codes — are timezone-offset-policy.no-default-offset and timezone-offset-policy.default-server-offset documented somewhere, or is that planned as a follow-up?

Comment thread tests/cql/CQLTimeZoneOffsetTest.xml Resolved
Comment thread tests/cql/CQLTimeZoneOffsetTest.xml Resolved
Comment thread tests/cql/CQLTimeZoneOffsetTest.xml Resolved
Comment thread tests/cql/CQLTimeZoneOffsetTest.xml Resolved
An offset-less DateTime takes the evaluation request's timezone offset,
so a "no default offset" policy is not something an engine can choose.

- Remove the two policy groups, the timezone-offset-policy.* capability
  codes and the {{SERVER_OFFSET_ISO}} placeholder.
- Keep one group of explicit-offset tests instead of two copies.
- Add default-offset tests that compare offset-less values against
  Now(), so they hold whatever offset the evaluation request uses.
- Revert the DateTimeDifferenceWeeks3 change: weeks count Sunday
  boundaries, and 2012-03-10 to 2012-03-24 crosses two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-request

The "Default timezone offset (evaluation request)" group tests that an
offset-less DateTime takes the evaluation request's timezone offset.
Tag the group and its six tests with the capability code for that rule,
default-timezone-offset-to-request, which HL7/cql#103 adds to the CQL
Language Capabilities CodeSystem (cql-tests#81).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryantaustin13

Copy link
Copy Markdown
Contributor Author

@brynrhodes @raleigh-g-thompson I've reworked this PR around Bryn's comment. When a DateTime has no offset, it takes the evaluation request's offset (Author's Guide, Date, DateTime, and Time). Extracting the offset from such a value returns that offset, "not null" (Extracting Date and Time Components). So a "no default offset" policy isn't something an engine can choose, and the policy framing is gone:

  • I removed both policy groups and the timezone-offset-policy.* capability codes. In their place, the "Default timezone offset" group and its tests are tagged default-timezone-offset-to-request, the single capability Bryn suggested on Add the default-timezone-offset-to-request language capability HL7/cql#103. I've reworked that PR to add just that code to the capabilities CodeSystem (Timezoneoffset policy tests #81).
  • I removed the {{SERVER_OFFSET_ISO}} placeholder, so the runner doesn't need to substitute anything.
  • The explicit-offset tests are now one group instead of two copies.
  • A new "Default timezone offset" group compares offset-less values against Now(). Now() returns the evaluation request timestamp, so it carries the same offset, and the expected results hold whatever offset the request uses:
    • (timezoneoffset from @2012-04-01T00:00) = (timezoneoffset from Now()) → true
    • (timezoneoffset from DateTime(2012, 4, 1, 0, 0)) = (timezoneoffset from Now()) → true
    • @2012-04-01T00:00:00.000 = DateTime(2012, 4, 1, 0, 0, 0, 0, timezoneoffset from Now()) → true, plus < in both directions
  • I reverted the DateTimeDifferenceWeeks3 change. Weeks count Sunday boundaries (difference). 2012-03-10 and 2012-03-24 are both Saturdays, so the operator crosses Mar 11 and Mar 18, and the existing 2 is correct.

Raleigh, this also covers your points. The NullWhen… tests, the server-offset group, the placeholder and the policy capability codes are all gone.

Checked on the cqframework Java engine (CQL engine 5.5.0 via clinical-reasoning 4.13.0 on HAPI FHIR 8.12.0): all 23 tests pass at an evaluation offset of -06:00, and again after adding the capability tags.

Checked on cql-execution 4.0.0-beta.1 (test-server): all 23 tests pass at an evaluation offset of +00:00. With the test server's evaluation offset set to +05:30, three of the default-offset tests fail. The engine gives offset-less values +05:00. src/elm/datetime.ts passes the context offset as an Integer literal, so the half hour is dropped. I filed that as cqframework/cql-execution#395, and it's fixed by cqframework/cql-execution#396, which has since merged.

Matches the fix cqframework#156 made on main for the other test files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants