Uploaded image for project: 'CQL Issue Tracker'
  1. CQL Issue Tracker
  2. CQLIT-101

Function Data Type Mismatch

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • None
    • The impact is critical because it means that this measure ought to technically crash itself because it does not conform to the CQL language specifications.
    • Other

      There is a data type mismatch in CMS #32, and probably other measures. The Median function is defined to return the median for a list of decimal data type or a list of the quantity data type, but NOT the Integer data type. From the HL7 CQL Specification document:

      “9.11.7 Median

      Signature:

      Median(argument List<Decimal>) Decimal

      Median(argument List<Quantity>) Quantity

      Description:

      The Median operator returns the median of the elements in source.

      If the source contains no non-null elements, null is returned.

      If the source is null, the result is null.”

      Now the code below will pass a list of type Integer to the Median function. To me, this indicates a fundamental problem with data type checking for the measure authoring tool. If there was secure data type checking then this would have been caught, but it was not. Therefore I deduce that this same problem will be present in other measures.

      The intention seems to be to pass a list of type Quantity to the Median function. However that is simply not what occurs here. The “Duration” function always returns an Integer, never a quantity. I think this is a poor design of the Duration (and the Difference) function where the function takes time values as inputs and takes the “precision” as an input, but returns an integer instead of a Quantity. Instead of this function returning an integer, this function ought to return a Quantity where the “value” is the integer value that the function normally returns and the “unit” is the same unit as the precision unit that was passed in.
      Measure Observation

      Median (

      /Time from ED visit arrival to ED departure for patients not admitted to inpatient/

      "Arrival to Observation Order or Departure Time"(Encounter)

      )

      Arrival to Observation Order or Departure Time(Encounter "Encounter, Performed")

      duration in minutes of Interval ["Arrival Time"(Encounter), Coalesce("Observation Services Order"(Encounter).authorDatetime, "Departure Time"(Encounter))]

      For this instance, I think it can be fixed by rewriting the function something like this:

      Arrival to Observation Order or Departure Time(Encounter "Encounter, Performed")

      ToQuantity(ToString(duration in minutes of Interval ["Arrival Time"(Encounter), Coalesce("Observation Services Order"(Encounter).authorDatetime, "Departure Time"(Encounter))])+”<minutes>”)

            bryn_rhodes Bryn Rhodes
            cquinlan Carsten (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: