Skip to content

Width allows Interval<Any> as a parameter #734

@EvanMachusakNCQA

Description

@EvanMachusakNCQA

From the official tests, this is an example:

define "IntervalTestWidthNull":
  ( width of ( null as Interval<Any>) ) = null as Integer

In appendix B for width (https://cql.hl7.org/09-b-cqlreference.html#width), width's signature is generic but we have two contrary statements:

Note that because CQL defines duration and difference operations for date and time valued intervals, width is not defined for intervals of these types.

and:

The width operator returns the width of an interval. The result of this operator is equivalent to invoking: (end of argument – start of argument).

In particular, if an engine implements Width as suggested by using end and start, then we look at the documentation for end (https://cql.hl7.org/09-b-cqlreference.html#end).

End's documentation says this:

If the high boundary of the interval is open, this operator returns the predecessor of the high value of the interval.

(ditto for Start and the successor operator).

Thus in order to implement end, you need to implement it through predecessor.

The documentation for predecessor (https://cql.hl7.org/09-b-cqlreference.html#predecessor) says this:

The predecessor operator is defined for the Integer, Long, Decimal, Quantity, Date, DateTime, and Time types.

So, peeling this backwards, we can see that Width could only be implemented on the types that Predecessor and Successor support. Of those, the Width documentation specifically discludes date and time values because of the custom operators (which use quantity units).

This leaves us with Width being only defined for Integer, Long, Decimal, and Quantity types.

Therefore I think CQL-to-ELM should raise an error on Width on any interval type except those 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcqlThe issue relates to or requires a change or clarification on the CQL specification

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions