Skip to content

Cooking with CQL Q&A Index Using Quality Data Model Category

Holly Stone edited this page Jan 20, 2022 · 18 revisions

Each Q&A has the Cooking with CQL session number and date. For the most current and accurate information, please check the CQL Qs&As for a more recent answer to your question.

Attributes for Organizations: When using the Quality Data Model (QDM) v.5.5 attributes for organizations, does this example make sense?

/*
This example shows how to check that the organization associated with a blood pressure is the same as the encounter:
*/

define "Qualifying Blood Pressures":
	  ["Physical Exam, Performed": "Blood Pressure"] BP
	    with ["Encounter, Performed": "Office Visit"] Encounter
	      such that BP.relevantPeriod during Encounter.relevantPeriod
	        and EINOf(Encounter.participant.identifier) = EINOf(BP.performer.identifier)
	

	define "EIN Identifier System": 'urn:oid:2.16.840.1.113883.4.4'
	

	define function EINOf(identifier Identifier):
	  identifier I where I.namingSystem = "EIN Identifier System" return I

(Session 46 - 7/30/2020)

  • Yes. For simplicity, we explicitly decided QDM would only represent one participant, performer, or organization within any given data element. This representation provides a little bit of flexibility in terms of how a submitting system populates that data element. There needs to be guidance associated with the use of the entity type to indicate that participants are expected to be the organization and the organization would have to use their own naming system identifier to run the string of code.
EHR and QDM Attributes: QDMs are not really used for interoperability like FHIR is, it defines the type of metadata that we call attributes. Is it true that EHRs have been implemented to be able to export the full QDM set of attributes every time you ask for something? That’s the ideal. (Session 35 - 5/23/19)
  • In typical implementation, that’s the structure seen. A typical scenario is a database with columns that match to attributes in QDM so the overall structure will look like that but not all of the columns will necessarily be filled. From an architectural perspective, this would be a straightforward and reasonable way to do the implementation.
Expand Operator: In the Quality Data Model (QDM) 5.5, what does the expand operator do? Can it be used to make a list of each day in the measurement period? (Session 43 - 4/23/20)
  • Yes. QDM 5.5 does not have an expand operator, QDM is the data model. The CQL expand operator is an operator that takes a list of intervals and returns the unit intervals in that input. As shown in Example 1, if you expand the interval from 1 to 10, the result would be a list of the intervals from 1 to 1, 2 to 2, and so on.

Example 1

expand { Interval[1, 10]} // { Interval[1, 1], Interval[2, 2] ...}

There is also a per clause, shown in Example 2. If you expand the measurement period, you can get intervals of milliseconds by saying per day then you get intervals of days. If you said per month, you would get 12 months and then you could count the encounters in that month.

Example 2


define "Measurement Period Days":
	  expand { "Measurement Period" } per day

Measurement Period is a calendar calculation. If you are using Measurement Period Days and the measurement period includes a leap year, that will be accounted for in the calculation. Similarly, if you said month, you will get the calendar month intervals. You could also ask for the months, the counts in the days, and the highest count of days in that month.

Glucocorticoid Dosage Expression: For the glucocorticoid dosage expression, is using Date appropriate in place of DateTime? Session 31 - (1/31/19)

https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/blob/master/Source/Cooking%20With%20CQL/31/87_GlucocorticoidDosage.cql#L128


define function "Glucocorticoids Dosage Per Day"(glucocorticoids List<Tuple {
  code Code,
  daysInPeriod List<DateTime>,
  dailyDosage Quantity
}>):

  • Yes, since version 1.3 of CQL, the Date type can be used for the daysInPeriod argument (i.e. List instead of List).
“is” vs ”as” operator in Bonnie uses in QDM v5.3: In QDM 5.5, we have reduced ability to talk about entity types and these are attributes that are patients, persons, or practitioners. In the examples we’ve used to illustrate these is using the ‘is’ operator in CQL by saying participant is an organization. However, there is an issue with Bonnie that it doesn’t support the ‘is’ operator, but it does support the ‘as’ operator. How do we work around this issue? (Session 40 - 12/5/19)
  • In the example below, it is using the ‘as’ operator to get to the same place by turning that into Org and saying it’s not null. Here we’re saying participant ‘as’ an organization. If the participant is not an organization, then the result of that is null so by saying that if Org1 is not null and Org2 is not null, then you can do the comparison between them.

define "My Qualifying Encounters":
	   ( distinct ( flatten ( from
	           "Dementia Encounter" Enc1,
	           "Dementia Encounter" Enc2
	           let Org1: ( Enc1.participant as "Organization" ),
	           Org2: ( Enc2.participant as "Organization" )
	           where Org1 is not null
	             and Org2 is not null
	             and start of Enc2.relevantPeriod 1 day or more after start
	of Enc1.relevantPeriod
	             and Org1.identifier ~ Org2.identifier
	           return all { Enc1, Enc2 }
	       )
	     )
	   )

Medical Coverage in QDM: Is the type of coverage, e.g., commercial, Medicare, Medicaid considered in the QDM participation logic? (Session 32 - 2/28/19)
  • The participation logic determines coverage in a QDM measure using the QDM participation type. The logic starts with whether the patient is enrolled and it is particular to each product line, commercial, Medicare or Medicaid. However, in calculating the participation period and the enrollment periods, coverage type is usually ignored.
MedicationDispensePeriod: In the QDM (Quality Data Model) library related to medication dispense period, is a relevant date and time allowed to be used as a starting point when other data points are absent? (Session 59 - 12/09/21)
  • The Dispense.relevantDatetime attribute means the date and time the prescription dispensing event occurred (the whenHandedOver if mapped to FHIR). Dispense.relevantPeriod is the time period for which the dispensed supply is to be administered/taken, not including refills. The QDM data type allows for either to be specified, but not both. So, either an instance of a Dispense gives the period over which it is to be taken, or it gives a date and time the event occurred. Because the logic is looking for a starting point, it will take whichever element is specified as the starting point.

If Dispense.relevantdatetime is specified, it may be used as a starting point for the medication dispense period. The order of the attributes within the Coalesce operator expression determines the relative priority of Dispense.relevantdatetime, Dispense.relevantperiod.low, and Dispense.authorDatetime data elements.

Any given instance should not have both a Dispense.relevantdatetime and a Dispense.relevantperiod.low, so whichever dispense information is present will be given priority. If neither Dispense.relevantdatetime or Dispense.relevantperiod.low is available, then the Dispense.authorDatetime will be used to calculate the medication dispense startDate.

Similarly, totalDaysSupplied uses a Coalesce of Dispense.daysSupplied if available, otherwise calculates it from the Dispense.supply.value divided by the Dispense.dosage.value times the frequency. For example, Rx of 1 tab twice a day #60, totalDaysSupplied = 60 tabs /(1 tab/dose x 2 dose/day) = 30 day supply

define function "MedicationDispensedPeriod"(Dispense "Medication, Dispensed" ):
  Dispense Dispense
    let
      startDate: date from Coalesce(Dispense.relevantDatetime, Dispense.relevantPeriod.low, Dispense.authorDatetime),
      totalDaysSupplied:
        Coalesce(
          Dispense.daysSupplied,
          Dispense.supply.value / (Dispense.dosage.value * ToDaily(Dispense.frequency))
        )
QDM 5.5 and the RatioExample library: Using Quality Data Model (QDM) 5.5 and the RatioExample library, we want to calculate the number of inpatient falls with major injury per 1,000 patient days. We can represent the measure as an encounter-based ratio measure, but there is not a mechanism in the current Clinical Quality Language (CQL)-based Health Quality Measure Format (HQMF) to specify that the ratio should be “per 1,000 days.” How can we build this in CQL so we can express in the Measure Authoring Tool (MAT)? (Session 50 - 1/21/21)
  • When we try to express the measure as a continuous variable measure, it results in the calculation happening per case rather than at the population level, e.g., per 1,000 days. Therefore, it does not combine the fractions properly. This question is in reference to the measure Qualifying Encounters and Falls with Major Injury.

define "Qualifying Encounters":
	  ["Encounter, Performed": "Inpatient"]

define "Falls with Major Injury":
	  ["Assessment, Performed": "Fall"]

The Denominator Observation for an Encounter is the duration in hours of the Hospitalization Encounter divided by 24. The Numerator Observation is the count of Falls with Major Injury during that Encounter. You set this up as a ratio measure where the observation for the denominator uses Function 1 and the observation for the numerator uses Function 2.


Function 1:
define function "Denominator Observation"(Encounter "Encounter, Performed"):
	  duration in hours of Global.Hospitalization(Encounter) / 24

Function 2:
define function "Numerator Observation"(Encounter "Encounter, Performed"):
	  Count(
	    "Falls with Major Injury" Falls
	      where Falls.relevantDatetime during Encounter.relevantPeriod
	        or Falls.relevantPeriod during Encounter.relevantPeriod
	  )

We are able to express this ratio measure in the Measure Authoring Tool (MAT) and get a successful export, but the last piece of the performance rate is to express per 1,000 patient days. To allow the measure to express the “rate per 1000” requirement, we are proposing an extension to the Clinical Quality Language (CQL)-based Health Quality Measure Format (HQMF) Implementation Guide (IG) that serves as a post-production calculation in implementation:

Proposed Extension


<component typeCode="COMP">
	        <cql-ext:measureValue nullFlavor="DER" xsi:type="PQ">
	            <unit value="/1000d"/>
	        </cql-ext:measureValue>
	    </component>

Related Person QDM datatype: Does the new Related Person QDM datatype allow an eCQM specification to reference information about a related person that is already present in the patient’s record? As an example, instead of a direct context query, maternal information may be shared in a C-CDA and incorporated into an infant’s record. (Session 33 - 3/28/19)
  • Yes, the new QDM datatype Related Person will allow reference to information that is already present in the patient’s record yet represents information about the related person.
Specifying an Individual Actor is a Member of an Organization: The example as seen below relates to Specifying an Individual Actor is a Member of an Organization. The expression defines an Organization as the Quality Data Model (QDM) Entity used for the encounter participant. Further, it indicates that the individual who orders an eye examination (Intervention, Order) using the QDM Entity Practitioner and that the practitioner identifier is within the organization identified as the performer of the qualifying encounter. The expression also assures the individual who performs the eye examination (Intervention, Performed) is also a practitioner whose identifier is within the organization identified as the performer of the qualifying encounter. Note that this is a hypothetical example. All the actor identification requirements are optional at the discretion of the measure developer and all require validation that seeking such detail is feasible for implementation.

define "Eye Exam Complete":

  ["Intervention, Performed": "Diabetic Eye Exam"] EyeExam
    with "Qualifying Encounters (4)" Encounter
      such that exists (
        EyeExam.performer Performer
          where Performer is Organization
            and Performer.id in Encounter.participant.id
      )
        and exists (
          EyeExam.performer Performer
            where Performer is "Practitioner"
              and Performer.specialty in "Ophthalmology"
        )

In this example, will the expression work in Bonnie? (Session 50 - 1/21/21)

  • The solution will work in Bonnie FHIR (since it is using the latest version of the JavaScript engine that supports the is/as operators), but will not work in Bonnie QDM.

Wiki Index

Home

Authoring Patterns - QICore v4.1.1

Authoring Patterns - QICore v5.0.0

Authoring Patterns - QICore v6.0.0

Authoring Measures in CQL

Composite Measure Development

Cooking with CQL Examples

Cooking with CQL Q&A All Categories
Additional Q&A Examples

CQL 1.3 Impact Guidance

CQL Error Messages

Developers Introduction to CQL

Discussion Items

Example Measures

Formatting and Usage Topics

Formatting Conventions

Library Versioning

Negation in QDM

QDM Known Issues

Specific Occurrences

Specifying Population Criteria

Supplemental Data Elements

Terminology in CQL

Translator Options For Measure Development

Unions in CQL

Clone this wiki locally