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

"Singleton From" and throwwing run time errors

XMLWordPrintable

    • Icon: Other Other
    • Resolution: Done
    • Icon: Moderate Moderate
    • None
    • Will cause unnecessary run time errors to be thrown for a small percentage of patients.

      For some of the global functions for EH eCQMs, the "Singleton From" function is used frequently, and I am concerned about this because the IG for CQL says (in section 9.10.21) that "If the list contains more than one element, a run-time error is thrown."

      Signature: singleton from(argument List<T>) T

      Description: The singleton from operator extracts a single element from the source list. If the source list is empty, the result is null. If the source list contains one element, that element is returned. *If the list contains more than one element, a run-time error is thrown. If the source list is null, the result is null.

      Here is an example of how it is used in the STK measures:

      Global.Hospitalization(Encounter "Encounter, Performed")

      ( singleton from ( ["Encounter, Performed": "Emergency Department Visit"] EDVisit

      where EDVisit.relevantPeriod ends 1 hour or less on or before start of Encounter.relevantPeriod ) ) X

      return if X is null then Encounter.relevantPeriod else Interval[start of X.relevantPeriod, end of Encounter.relevantPeriod]

      Now for this function, it could be possible that there are two or more ED encounters, in which case we ought to crash the evaluation with a run time error, but that doesn't seem right to me. I think that what this function wants to return is the interval between the start of the ED encounters (if there are any) and the end of the IP encounter. I'm sure there is a much better way to write this that avoids using "Singleon From"

      For example, make a list of start datetimes (Start) and a list of end datetimes (End) from ED encounter(s) and the IP encounter, and then make an interval using "Min(Start)" and "Max(End)"

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

              Created:
              Updated:
              Resolved: