Correct interval extraction from FHIR Range and Period - #130
Open
bryantaustin13 wants to merge 1 commit into
Open
bryantaustin13 wants to merge 1 commit into
bryantaustin13 wants to merge 1 commit into
Conversation
The extractors that map FHIR.Range and FHIR.Period back to CQL intervals — the
representation the "Using CQL with FHIR" IG specifies for Interval in
Conformance Requirement 4.3 — had four defects:
- DateTimeIntervalExtractor hardcoded `highClosed: true`, so a Period with no
`end` extracted as `{highClosed: true, high: null}`. An absent boundary is
unbounded and therefore open; NumericIntervalExtractor already treated it that
way, so the two disagreed on the same shape.
- A null `valuePeriod`, a null `valueRange`, or a null Range boundary each threw
a TypeError out of the extractor, which turns a test into an error rather than
a comparison.
- A Range boundary carrying `unit` but no `code` lost its unit, silently
reducing a dimensioned boundary to a unitless one.
Adds tests covering all seven interval point types the IG maps (Integer, Long,
Decimal and Quantity onto Range; Date, DateTime and Time onto Period) plus the
boundary and null cases above.
One behaviour is pinned deliberately rather than changed: a Period carrying no
cqf-cqlType is read as Interval<DateTime>. The point type cannot be recovered in
that case — a boundary of 2012-01-01T00:00:00-07:00 is indistinguishable from a
DateTime interval starting at midnight — and the IG states that a value without
cqf-cqlType is the FHIR type. Inferring a Date would be a guess, so the test
asserts the mismatch instead, keeping the missing extension visible as a server
defect.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The extractors that map FHIR.Range and FHIR.Period back to CQL intervals — the representation the "Using CQL with FHIR" IG specifies for Interval in Conformance Requirement 4.3 — had four defects:
highClosed: true, so a Period with noendextracted as{highClosed: true, high: null}. An absent boundary is unbounded and therefore open; NumericIntervalExtractor already treated it that way, so the two disagreed on the same shape.valuePeriod, a nullvalueRange, or a null Range boundary each threw a TypeError out of the extractor, which turns a test into an error rather than a comparison.unitbut nocodelost its unit, silently reducing a dimensioned boundary to a unitless one.Adds tests covering all seven interval point types the IG maps (Integer, Long, Decimal and Quantity onto Range; Date, DateTime and Time onto Period) plus the boundary and null cases above.
One behaviour is pinned deliberately rather than changed: a Period carrying no cqf-cqlType is read as Interval. The point type cannot be recovered in that case — a boundary of 2012-01-01T00:00:00-07:00 is indistinguishable from a DateTime interval starting at midnight — and the IG states that a value without cqf-cqlType is the FHIR type. Inferring a Date would be a guess, so the test asserts the mismatch instead, keeping the missing extension visible as a server defect.