Quality Measure Implementation Guide (STU3)
3.0.0 - STU 3 US

This page is part of the Quality Measure STU2 for FHIR R4 Implementation Guide (v3.0.0: STU3) based on FHIR R4. This is the current published version in its permanent home (it will always be available at this URL). For a full list of available versions, see the Directory of published versions

Example Library: Supplemental Data Elements Library

Active as of 2019-09-03
Id: SupplementalDataElements
Url: http://hl7.org/fhir/us/cqfmeasures/Library/SupplementalDataElements
Version: 2.0.0

value: SupplementalDataElements

Name: SupplementalDataElements
Title: Supplemental Data Elements Library
Status: active
Experimental: true

system: http://terminology.hl7.org/CodeSystem/library-type

code: logic-library

Date: 2019-09-03
Publisher: Clinical Quality Information WG
Description: This library is used as an example in the FHIR Quality Measure Implementation Guide
Jurisdiction: US
Approval Date: 2019-08-03
Last Review Date: 2019-08-03
Related Artifacts:


  • http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
  • http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836
SDE EthnicityCoding0*out
SDE PayerAny0*out
SDE RaceCoding0*out
SDE SexCoding01out
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/StructureDefinition/Patient
Coverage http://hl7.org/fhir/StructureDefinition/Coverage code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Content: text/cql
This example is a work in progress and should not be considered a final specification
or recommendation for guidance. This example will help guide and direct the process
of finding conventions and usage patterns that meet the needs of the various stakeholders
in the measure development community.

@update: BTR 2020-03-31 ->
Incremented version to 2.0.0
Updated FHIR version to 4.0.1
library SupplementalDataElements version '2.0.000'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1' called FHIRHelpers

valueset "Ethnicity": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837'
valueset "ONC Administrative Sex": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1'
valueset "Payer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591'
valueset "Race": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836'

context Patient

define "SDE Ethnicity":
  (flatten (
      Patient.extension Extension
        where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity'
          return Extension.extension
    )) E
      where E.url = 'ombCategory'
        or E.url = 'detailed'
      return E.value as Coding

define "SDE Payer":
  [Coverage: type in "Payer"] Payer
        return {
          code: Payer.type,
          period: Payer.period

define "SDE Race":
  (flatten (
      Patient.extension Extension
        where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'
          return Extension.extension
    )) E
      where E.url = 'ombCategory'
        or E.url = 'detailed'
      return E.value as Coding

define "SDE Sex":
      when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' }
      when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' }
      else null
Content: application/elm+xml
Encoded data (42752 characters)
Content: application/elm+json
Encoded data (76876 characters)