Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ In order for the CQL execution framework to determine if a code is in a valueset

### MessageListener

The CQL specification defines a [Message](https://cql.hl7.org/09-b-cqlreference.html#message) operator that "provides a run-time mechanism for returning messages, warnings, traces, and errors to the calling environment." To support this, the CQL execution framework supports a "MessageListener" API. A MessageListener class must contain an `onMessage` function which will be called by the CQL execution framework if the `condition` passed to the `Message` operator is `true`:
The CQL specification defines a [Message](https://cql.hl7.org/R2/09-b-cqlreference.html#message) operator that "provides a run-time mechanism for returning messages, warnings, traces, and errors to the calling environment." To support this, the CQL execution framework supports a "MessageListener" API. A MessageListener class must contain an `onMessage` function which will be called by the CQL execution framework if the `condition` passed to the `Message` operator is `true`:
```typescript
onMessage(source: any, code: string, severity: string, message: string) {
// do something with the message
Expand Down
58 changes: 28 additions & 30 deletions src/datatypes/interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
import { MIN_FLOAT_VALUE } from '../util/limits';
import { Quantity } from './quantity';

// TODO: Replace all build.fhir.org URL references with stable references once CQL 2.0 is pulished

export class Interval {
constructor(
public low: any,
Expand Down Expand Up @@ -78,7 +76,7 @@ export class Interval {
return new Interval(newLow, newHigh, this.lowClosed, this.highClosed, this.pointType);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#contains
// https://cql.hl7.org/R2/09-b-cqlreference.html#contains
contains(item: any, precision?: any) {
if (item != null && item.isInterval) {
throw new Error('Argument to contains must be a point');
Expand All @@ -93,7 +91,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#properly-includes
// https://cql.hl7.org/R2/09-b-cqlreference.html#properly-includes
properContains(item: any, precision?: any) {
// From contains: "If the second argument is null, the result is null."
if (item == null) {
Expand All @@ -110,7 +108,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#properly-includes
// https://cql.hl7.org/R2/09-b-cqlreference.html#properly-includes
properlyIncludes(other: any, precision?: any) {
// "For the interval-interval overload, if either argument is null, the result is null."
if (other == null) {
Expand All @@ -130,7 +128,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#includes
// https://cql.hl7.org/R2/09-b-cqlreference.html#includes
includes(other: any, precision?: any) {
// "For the interval-interval overload, if either argument is null, the result is null."
if (other == null) {
Expand All @@ -151,7 +149,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#included-in
// https://cql.hl7.org/R2/09-b-cqlreference.html#included-in
includedIn(other: any, precision?: any) {
// "For the interval-interval overload, if either argument is null, the result is null."
if (other == null) {
Expand All @@ -170,7 +168,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#overlaps
// https://cql.hl7.org/R2/09-b-cqlreference.html#overlaps
overlaps(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -187,7 +185,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#overlaps
// https://cql.hl7.org/R2/09-b-cqlreference.html#overlaps
overlapsAfter(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -201,7 +199,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#overlaps
// https://cql.hl7.org/R2/09-b-cqlreference.html#overlaps
overlapsBefore(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -215,7 +213,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#union
// https://cql.hl7.org/R2/09-b-cqlreference.html#union
union(other: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand Down Expand Up @@ -253,7 +251,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#intersect
// https://cql.hl7.org/R2/09-b-cqlreference.html#intersect
intersect(other: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand Down Expand Up @@ -292,7 +290,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#except
// https://cql.hl7.org/R2/09-b-cqlreference.html#except
except(other: any) {
// "If either argument is null, the result is null."
if (other === null) {
Expand Down Expand Up @@ -339,7 +337,7 @@ export class Interval {
return null;
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#same-as-2
// https://cql.hl7.org/R2/09-b-cqlreference.html#same-as-2
sameAs(other: any, precision?: any) {
// "If either or both arguments are null, the result is null."
if (other === null) {
Expand Down Expand Up @@ -373,7 +371,7 @@ export class Interval {
}
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#same-or-after-2
// https://cql.hl7.org/R2/09-b-cqlreference.html#same-or-after-2
sameOrBefore(other: any, precision?: any) {
// "If either or both arguments are null, the result is null."
if (other === null) {
Expand Down Expand Up @@ -401,7 +399,7 @@ export class Interval {
return cmp.lessThanOrEquals(left.end(), right.start(), precision);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#same-or-after-2
// https://cql.hl7.org/R2/09-b-cqlreference.html#same-or-after-2
sameOrAfter(other: any, precision?: any) {
// "If either or both arguments are null, the result is null."
if (other === null) {
Expand Down Expand Up @@ -429,7 +427,7 @@ export class Interval {
return cmp.greaterThanOrEquals(left.start(), right.end(), precision);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#equal-1
// https://cql.hl7.org/R2/09-b-cqlreference.html#equal-1
equals(other: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -449,7 +447,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#after-1
// https://cql.hl7.org/R2/09-b-cqlreference.html#after-1
after(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -467,7 +465,7 @@ export class Interval {
return cmp.greaterThan(this.start(), other.end(), precision);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#before-1
// https://cql.hl7.org/R2/09-b-cqlreference.html#before-1
before(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -485,7 +483,7 @@ export class Interval {
return cmp.lessThan(this.end(), other.start(), precision);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#meets
// https://cql.hl7.org/R2/09-b-cqlreference.html#meets
meets(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -503,7 +501,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#meets
// https://cql.hl7.org/R2/09-b-cqlreference.html#meets
meetsAfter(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand All @@ -528,7 +526,7 @@ export class Interval {
}
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#meets
// https://cql.hl7.org/R2/09-b-cqlreference.html#meets
meetsBefore(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand Down Expand Up @@ -556,7 +554,7 @@ export class Interval {
}
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#start
// https://cql.hl7.org/R2/09-b-cqlreference.html#start
start() {
// "If the low boundary of the interval is closed and null, this operator returns the minimum
// value for the point type of the interval."
Expand All @@ -581,7 +579,7 @@ export class Interval {
return this.lowClosed ? this.low : successor(this.low, this.pointType);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#end
// https://cql.hl7.org/R2/09-b-cqlreference.html#end
end() {
// "If the high boundary of the interval is closed and null, this operator returns the maximum
// value for the point type of the interval."
Expand All @@ -606,7 +604,7 @@ export class Interval {
return this.highClosed ? this.high : predecessor(this.high, this.pointType);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#starts
// https://cql.hl7.org/R2/09-b-cqlreference.html#starts
starts(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand Down Expand Up @@ -634,7 +632,7 @@ export class Interval {
}
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#ends
// https://cql.hl7.org/R2/09-b-cqlreference.html#ends
ends(other: any, precision?: any) {
// "If either argument is null, the result is null."
if (other == null) {
Expand Down Expand Up @@ -662,7 +660,7 @@ export class Interval {
}
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#width
// https://cql.hl7.org/R2/09-b-cqlreference.html#width
width() {
// "Note that because CQL defines duration and difference operations for date and time valued
// intervals, width is not defined for intervals of these types."
Expand All @@ -680,7 +678,7 @@ export class Interval {
return limitDecimalPrecision(subtract(end, start, this.pointType));
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#size
// https://cql.hl7.org/R2/09-b-cqlreference.html#size
size() {
// "Note that because CQL defines duration and difference operations for date and time valued
// intervals, size is not defined for intervals of these types."
Expand All @@ -700,7 +698,7 @@ export class Interval {
);
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#size
// https://cql.hl7.org/R2/09-b-cqlreference.html#size
getPointSize() {
// "... point-size is determined by successor of minimum T - minimum T"
let minValue = minValueForType(this.pointType, getQuantityInstanceForMinMax(this));
Expand All @@ -726,7 +724,7 @@ export class Interval {
throw new Error('Point type of interval cannot be determined.');
}

// https://build.fhir.org/ig/HL7/cql/09-b-cqlreference.html#point-from
// https://cql.hl7.org/R2/09-b-cqlreference.html#point-from
pointFrom() {
// "The point from operator extracts the single point from a unit interval."
const start = this.start();
Expand Down
2 changes: 1 addition & 1 deletion src/elm/clinical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class CalculateAge extends Expression {
// From the spec: "Note that for AgeInYears and AgeInMonths, the birthDate is specified as a
// Date and Today() is used to obtain the current date; whereas with the other precisions,
// birthDate is specified as a DateTime, and Now() is used to obtain the current DateTime."
// See: https://cql.hl7.org/09-b-cqlreference.html#age
// See: https://cql.hl7.org/R2/09-b-cqlreference.html#age
let asOf: dt.Date | dt.DateTime;
if (
this.precision.toLowerCase() === dt.DateTime.Unit.YEAR ||
Expand Down
2 changes: 1 addition & 1 deletion src/elm/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class Query extends Expression {
});

// Iterate over the cartesian product of the sources.
// See: https://cql.hl7.org/03-developersguide.html#multi-source-queries
// See: https://cql.hl7.org/R2/03-developersguide.html#multi-source-queries
const cartesian = cartesianProductOf(sourceResults);
let returnedValues: any[] = [];
for (const combo of cartesian) {
Expand Down
2 changes: 1 addition & 1 deletion src/types/type-specifiers.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ELM_CHOICE_TYPE_SPECIFIER
} from '../util/elmTypes';

// Types derived from http://cql.hl7.org/04-logicalspecification.html#typespecifier
// Types derived from http://cql.hl7.org/R2/04-logicalspecification.html#typespecifier

/*
* Utility type for any possible TypeSpecifier
Expand Down
Loading