Skip to content

Commit dba9632

Browse files
committed
browserify
1 parent af4da33 commit dba9632

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

examples/browser/cql4browsers.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,6 +1775,7 @@ const cmp = __importStar(require("../util/comparison"));
17751775
const elmTypes_1 = require("../util/elmTypes");
17761776
const limits_1 = require("../util/limits");
17771777
const quantity_1 = require("./quantity");
1778+
// TODO: Replace all build.fhir.org URL references with stable references once CQL 2.0 is pulished
17781779
class Interval {
17791780
constructor(low, high, lowClosed, highClosed, pointType = elmTypes_1.ELM_ANY_TYPE) {
17801781
this.low = low;
@@ -2020,8 +2021,10 @@ class Interval {
20202021
if (this.pointType === elmTypes_1.ELM_DATE_TYPE ||
20212022
this.pointType === elmTypes_1.ELM_DATETIME_TYPE ||
20222023
this.pointType === elmTypes_1.ELM_TIME_TYPE) {
2023-
const boundaries = [this.low, this.high, other.low, other.high];
2024-
const leastPreciseBoundary = boundaries.reduce((least, boundary) => boundary?.isLessPrecise(least) ? boundary : least);
2024+
const boundaries = [this.low, this.high, other.low, other.high].flatMap(boundary => boundary?.isUncertainty ? [boundary.low, boundary.high] : [boundary]);
2025+
const leastPreciseBoundary = boundaries
2026+
.filter(boundary => boundary != null)
2027+
.reduce((least, boundary) => (least == null || boundary.isLessPrecise(least) ? boundary : least), null);
20252028
precision = leastPreciseBoundary?.getPrecision();
20262029
}
20272030
if (this.overlaps(other, precision) === false) {
@@ -2468,13 +2471,20 @@ function getQuantityInstanceForMinMax(ivl) {
24682471
}
24692472
function performConversionIfNecessary(left, right) {
24702473
if (left.pointType === elmTypes_1.ELM_DATE_TYPE && right.pointType === elmTypes_1.ELM_DATETIME_TYPE) {
2471-
left = new Interval(left.low?.getDateTime(), left.high?.getDateTime(), left.lowClosed, left.highClosed, elmTypes_1.ELM_DATETIME_TYPE);
2474+
left = new Interval(convertDateBoundaryToDateTime(left.low), convertDateBoundaryToDateTime(left.high), left.lowClosed, left.highClosed, elmTypes_1.ELM_DATETIME_TYPE);
24722475
}
24732476
else if (left.pointType === elmTypes_1.ELM_DATETIME_TYPE && right.pointType === elmTypes_1.ELM_DATE_TYPE) {
2474-
right = new Interval(right.low?.getDateTime(), right.high?.getDateTime(), right.lowClosed, right.highClosed, elmTypes_1.ELM_DATETIME_TYPE);
2477+
right = new Interval(convertDateBoundaryToDateTime(right.low), convertDateBoundaryToDateTime(right.high), right.lowClosed, right.highClosed, elmTypes_1.ELM_DATETIME_TYPE);
24752478
}
24762479
return [left, right];
24772480
}
2481+
function convertDateBoundaryToDateTime(boundary) {
2482+
const convert = (value) => value?.getDateTime() ?? value;
2483+
if (boundary?.isUncertainty) {
2484+
return new uncertainty_1.Uncertainty(convert(boundary.low), convert(boundary.high));
2485+
}
2486+
return convert(boundary);
2487+
}
24782488
function lowestUncertainty(x, y) {
24792489
if (!x?.isUncertainty) {
24802490
x = new uncertainty_1.Uncertainty(x);

0 commit comments

Comments
 (0)