Skip to content

Commit b75ad37

Browse files
committed
Post-Rebase Tweaks
- Move pointFrom to be with other spec-defined operations - Add documentation links and quotes to pointFrom
1 parent 5cf3405 commit b75ad37

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

examples/browser/cql4browsers.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,16 @@ class Interval {
23922392
}
23932393
throw new Error('Point type of interval cannot be determined.');
23942394
}
2395+
// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#point-from
2396+
pointFrom() {
2397+
// "The point from operator extracts the single point from a unit interval."
2398+
const start = this.start();
2399+
if (cmp.equals(start, this.end())) {
2400+
return start;
2401+
}
2402+
// "If the argument is not a unit interval, a run-time error is thrown."
2403+
throw new Error('PointFrom operator may only be used on an interval containing a single point.');
2404+
}
23952405
toClosed() {
23962406
// Calculate the closed flags. Despite the name of this function, if a boundary is null open,
23972407
// we cannot close the boundary because that changes its meaning from "unknown" to "max/min value"
@@ -2430,13 +2440,6 @@ class Interval {
24302440
return new Interval(this.low, this.high, lowClosed, highClosed);
24312441
}
24322442
}
2433-
pointFrom() {
2434-
const start = this.start();
2435-
if (cmp.equals(start, this.end())) {
2436-
return start;
2437-
}
2438-
throw new Error('PointFrom operator may only be used on an interval containing a single point.');
2439-
}
24402443
toString() {
24412444
const start = this.lowClosed ? '[' : '(';
24422445
const end = this.highClosed ? ']' : ')';

src/datatypes/interval.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,20 @@ export class Interval {
731731
throw new Error('Point type of interval cannot be determined.');
732732
}
733733

734+
// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#point-from
735+
pointFrom() {
736+
// "The point from operator extracts the single point from a unit interval."
737+
const start = this.start();
738+
if (cmp.equals(start, this.end())) {
739+
return start;
740+
}
741+
742+
// "If the argument is not a unit interval, a run-time error is thrown."
743+
throw new Error(
744+
'PointFrom operator may only be used on an interval containing a single point.'
745+
);
746+
}
747+
734748
toClosed() {
735749
// Calculate the closed flags. Despite the name of this function, if a boundary is null open,
736750
// we cannot close the boundary because that changes its meaning from "unknown" to "max/min value"
@@ -765,17 +779,6 @@ export class Interval {
765779
}
766780
}
767781

768-
pointFrom() {
769-
const start = this.start();
770-
if (cmp.equals(start, this.end())) {
771-
return start;
772-
}
773-
774-
throw new Error(
775-
'PointFrom operator may only be used on an interval containing a single point.'
776-
);
777-
}
778-
779782
toString() {
780783
const start = this.lowClosed ? '[' : '(';
781784
const end = this.highClosed ? ']' : ')';

0 commit comments

Comments
 (0)