Skip to content

Cooking with CQL Q&A Index Queries in CQL Category

rhondaschwartz edited this page Jun 15, 2020 · 23 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.

Cross-Context Query for a Related Person: Looking at the solution for the connection of the mother and baby, is the capability for a cross-context query for a related person new to CQL? (Session 33 - 3/28/19)
  • Yes, it is new. We would like feedback in order to gain further understanding of the "operator" and how it is being used.
'from' vs 'with' with 2 sources: Is 'from' required when setting up a relationship between more than two sources and 'with' when setting up a relationship with only two sources? (Session 32 - 2/28/19)
  • Yes, that’s correct, ‘from’ is used to set up a “multi-source” query where you want to be able to talk about more than two sources at once. If you have a “single-source” query, you can use ‘with’ and ‘without’ to establish relationships between the primary source of the query and one other source at a time.
Multiple Source Queries with No Attributes: In multi-source queries, if an attribute is not mentioned specifically in the query, like the "method" attribute, will it still be included in the return? (Session 35 - 5/23/19)
  • Yes, if it is defined as an attribute in that source. For example, “method” is one of the attributes for “Physical Exam, Performed”. So, for the default behavior (when no return is specified), each element will have the same structure as the source it came from.
Multiple Source Queries with No Return Statement: When setting up relationships between multiple sources of data at the same time, what should you expect to see as the return with multi-source queries without specifying a return statement? For example, in CMS144v7: Consecutive Heart Rates less than 50 Inpatients, what would you expect to see as the return if not using a return statement? (Session 35 - 5/23/19)
  • Without a return statement, you’ll get a couple of results that have elements for each of the sources. So, you’ll get heart rate and a moderate or severe LVSDHF (left ventricular systolic dysfunction heart failure) inpatient encounter:

// Result Type:
{
  { HeartRate: { id: 'obs-1', code: ... }, ModerateOrSevereLVSDHFInpatientEncounter: { id: 'enc-1', code: ... } }     
  { HeartRate: { id: 'obs-2', code: ... }, ModerateOrSevereLVSDHFInpatientEncounter: { id: 'enc-1', code: ... } }     
  { HeartRate: { id: 'obs-3', code: ... }, ModerateOrSevereLVSDHFInpatientEncounter: { id: 'enc-2', code: ... } }     
  { HeartRate: { id: 'obs-4', code: ... }, ModerateOrSevereLVSDHFInpatientEncounter: { id: 'enc-2', code: ... } }     
  ...
}

If you don’t specify a return, then for each of the items in your “from,” you’ll get a result. The actual result of the query will be a list where you’ll have every combination of heart rate and moderate or severe LVSDHF inpatient encounter for this patient. A return is typically used with a multi-source query to pick out particular elements to be returned. The “where” clause eliminates combinations of those encounters so it would pull out the rows that don’t match that criteria. In the end, you only end up with rows that match the criteria, but since you didn’t specify the return, you will still get this list. Typically, if the result is used elsewhere, then a return would be included. If you’re only using it in something like an “exists”, then you don’t need to include a return.

Multiple Source Queries with Specified Attributes Returned: In multi-source queries, is it feasible to specify the type of attributes we want returned? (Session 35 - 5/23/19)
  • Yes, you can use return, it’s an arbitrary expression. So whatever you want to return from the “from,” you can.
Related Person Query: Is the related person query included in the FHIR Quality Measure Implementation Guide? (Session 33 - 3/28/19)
  • In the FHIR Quality Measure Implementation Guide May 2019 ballot content there is an example of this use case and we are seeking comments. Terminology is also being worked on within this example. There is nothing specific about this type of query in the base FHIR Clinical Reasoning measure specification.
Running CQL Queries: I am new to CQL, how do we run CQL queries - is it against C-CDA documents? (Session 31 - 1/31/19)
  • CQL can be used with any data model. In the examples in this series we are focused on using the Quality Data Model (QDM), which has a serialization as Quality Reporting Document Architecture (QRDA). QRDA is similar to C-CDA (they are both HL7 V3 standards), but not the same.
Substance Use Disorder (SUD) Encounter During Identification with Patient Age at Start: How should we express the criteria that a Substance Use Disorder (SUD) encounter in the "identification period" (6 months before through the first 6 months of the measurement period) is considered new if there are no other SUD encounters in the 60 days prior to the encounter, and that for each new SUD encounter, there is a baseline Quality of Life (QOL) assessment in the 14 days on or before the new SUD encounter, and a corresponding follow up QOL using the same assessment tool within 3 to 6 months of the new SUD encounter, and having a SUD encounter within 60 days of the follow up QOL assessment? (Session 34 - 4/25/19)
  • For each SUD encounter, there should be a baseline QOL assessment 14 days on or before the new SUD encounter and a follow up QOL assessment using the same QOL tool within 3-6 months and that had a SUD encounter within 60 days before that follow up QOL assessment, which could take place on the same day as the SUD encounter. Please see the example below of how this query should be expressed.

define "New SUD Encounter":
  "SUD Encounters" S
    without "SUD Encounters" S2 such that S2.relevantPeriod ends 60 days or less before start of S.relevantPeriod
    where S.relevantPeriod starts during "Identification Period"

    
define "Follow Up QOL Assessment":
	from
		"SUD Encounter During Identification Period with Patient Age at Start" NewSUDEncounter,
		"QOL Assessment" BaselineAssessment,
		"QOL Assessment" FollowupAssessment
		where (BaselineAssessment.authorDatetime 14 days or less before or on start of 
NewSUDEncounter.relevantPeriod
      or BaselineAssessment.authorDatetime during NewSUDEncounter.relevantPeriod)
      and FollowupAssessment.authorDatetime 3 months or more after start of NewSUDEncounter.relevantPeriod
			and FollowupAssessment.authorDatetime 6 months or less after start of 
NewSUDEncounter.relevantPeriod
      and exists ("SUD Encounter" SUDEncounter where SUDEncounter.relevantPeriod starts 60 days or less before or on
 FollowupAssessment.authorDatetime)
      and BaselineAssessment.code ~ FollowupAssessment.code
    return FollowupAssessment

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