Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #371 +/- ##
==========================================
+ Coverage 88.24% 88.27% +0.02%
==========================================
Files 54 54
Lines 4867 4877 +10
Branches 1372 1374 +2
==========================================
+ Hits 4295 4305 +10
Misses 377 377
Partials 195 195 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lmd59
left a comment
There was a problem hiding this comment.
Generally, this seems to work well, test well, and cover edge cases well. I had one question about a comparison of edge cases that I would think would have the same output but do not. Interested in thoughts on that!
| skipped: 'PointFrom not implemented' | ||
| /* | ||
| expression: point from Interval[null, null], | ||
| output: null |
There was a problem hiding this comment.
I see that this is a spec test, but do we think it's inconsistent that this output is null, whereas output point from Interval[1, null] is error? Is this worth a clarification to make sure the spec test is correct (or to make sure the Interval[1, null] case is correct)?
There was a problem hiding this comment.
So it looks like the latest build version of the spec has a new line in it that was not in the 2.0.0-ballot version (nor in the current 1.5.3):
https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#point-from (latest)
The point from operator extracts the single point from a unit interval. If the argument is not a unit interval, a run-time error is thrown. In particular, attempting to extract a point from the maximum interval
(Interval[null, null])will result in an error.
https://cql.hl7.org/2025Sep/09-b-cqlreference.html#point-from
The point from operator extracts the single point from a unit interval. If the argument is not a unit interval, a run-time error is thrown.
I'm not sure when this was added, I can do more looking, but this would take away that inconsistency and make anything with a null be an error. But, that's only a build version so I'm not sure if we want to implement to that version yet or not. I would read that as a "clarification" not a "change" and so it feels ok to me to implement that now, but I think we should double check with @cmoesel .
There was a problem hiding this comment.
Great find! Would also welcome thoughts from @cmoesel!
There was a problem hiding this comment.
I agree with @lmd59's hunch that the spec test for point from Interval[null, null] should result in an error. I think the new language that @dehall found is just a clarification; it doesn't actually change anything because Interval[null, null] is definitely not a unit interval, so it should throw an error anyway. That said, the new language makes it very difficult for anyone to defend that test's current behavior (so I guess that's good).
There was a problem hiding this comment.
Updated in the latest, note this specific cql-test is now skipped again. There is an open PR that updates that (# 128 over there) but it's one of many that says "add and update tests as suggested by Claude" so I'm not sure what the status of those is
cmoesel
left a comment
There was a problem hiding this comment.
Thanks for working on this. It's looking good, but I've added one suggestion and one question (that might require clarification from the CQL community). Depending on the answer to the question, further changes may be needed.
| const start = interval.start(); | ||
| const end = interval.end(); | ||
|
|
||
| if (start == end || equals(start, end)) { | ||
| return start; | ||
| } | ||
|
|
||
| throw new Error( | ||
| 'PointFrom operator may only be used on an interval containing a single point.' | ||
| ); |
There was a problem hiding this comment.
We've implemented almost all of the other operators in the src/datatypes/interval.ts Interval class (with the exception of expand / collapse, for some reason). I'd suggest we do the same for this one and keep the ELM layer light.
cmoesel
left a comment
There was a problem hiding this comment.
I'm approving this because I'd accept it as-is, but I also noted one additional test for you to consider adding.
| it('should throw for an interval with null high bound', function () { | ||
| const ivl = new Interval(DateTime.parse('2012-01-01T00:00:00.0+00'), null); | ||
| should(() => ivl.pointFrom()).throw(Error); | ||
| }); |
There was a problem hiding this comment.
It might be good to test this for both closed null (max value) and open null (unknown value).
I'd be willing to accept the PR without this, but if you have time, then it might be good to add it just for completeness.
| it('should throw for an interval with undefined width', function () { | ||
| const ivl = new Interval(0, 0, false, false); | ||
| should(() => ivl.pointFrom()).throw(Error); | ||
| }); |
There was a problem hiding this comment.
I'm not sure if this is even a valid interval, but throwing seems like the right thing to do.
lmd59
left a comment
There was a problem hiding this comment.
Looks like this is reflecting spec intention and expected future changes to spec tests!
This PR implements the point from interval operator. (closes #163)
If the given interval is a "unit interval", aka it only contains a single point, this operator returns that point. Otherwise, it throws a runtime error.
To get that single point, it just checks if start() is equal to end(). If both bounds of the interval are null, it returns null, hence checking with both
==andequals.Pull requests into cql-execution require the following.
Submitter and reviewer should ✔ when done.
For items that are not-applicable, mark "N/A" and ✔.
Submitter:
npm run test:plusto run tests, lint, and prettier)cql4browsers.jsbuilt withnpm run build:browserifyif source changed.Reviewer:
Name: