Skip to content

QA Validation Error Due to Aliases in Sort By

Darren Duncan edited this page Oct 12, 2017 · 1 revision

Questions and Answers


Q&A - Validation Error Due to Aliases in Sort-By

Question

The following definition is returning a validation error which was not showing up prior to the most recent MAT staging update.

  define "Most Recent Adult Depression Screening":
    Last (
      ["Assessment, Performed": "Adult Depression Screening"] Adultscreen 
        with "Depression Screening Encounter" Enc
          such that Adultscreen.authorDatetime during Enc.relevantPeriod and Adultscreen.result is not null
        sort by Adultscreen.authorDatetime
    )

If I remove "sort by Adultscreen.authorDatetime" the definition saves without error:

  define "Depression Screening Encounter":
    ["Encounter, Performed": "Depression Screening Encounter Codes"] Enc
      where Enc.relevantPeriod during "Measurement Period"

Answer

Your sort clause is incorrect because it is evaluated on the result of the query. Aliases are used in the calculation of the results. Consider a query with a return clause, or a multi-source query, the aliases no longer have meaning once the results are produced.

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