Quality Measure Implementation Guide
2.0.0-ballot - STU 2 Ballot International flag

Quality Measure Implementation Guide, published by HL7 International / Clinical Quality Information. This guide is not an authorized publication; it is the continuous build for version 2.0.0-ballot built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/fhir-cqm/ and changes regularly. See the Directory of published versions

Library: Age Stratification Example (Experimental)

Official URL: http://hl7.org/fhir/uv/cqm/Library/AgeStratificationExample Version: 1.0.0
Standards status: Informative Active as of 2026-04-03 Computable Name: AgeStratificationExample
Other Identifiers: OID:2.16.840.1.113883.4.642.40.61.28.3

This library provides an illustration of using the Time Period Ranges code system to construct computable age ranges as a stratification for measures.

Metadata
Title Age Stratification Example
Version 1.0.0
Identifier urn:oid:2.16.840.1.113883.4.642.40.61.28.3
Experimental true
Jurisdiction 001 from http://unstats.un.org/unsd/methods/m49/m49.htm
Topic FHIR
Topic CQL
Steward (Publisher) HL7 International / Clinical Quality Information
Description

This library provides an illustration of using the Time Period Ranges code system to construct computable age ranges as a stratification for measures.

Type logic-library from http://terminology.hl7.org/CodeSystem/library-type
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Code System Time Period Ranges
Resource: Time Period Ranges
Canonical URL: http://terminology.hl7.org/CodeSystem/time-period-ranges
Data Requirement Type: Encounter
Profile(s): Encounter
Parameters
Name Use Card. Type Documentation
Measurement Period In 0..1 Period
Patient Out 0..1 Patient
Initial Population Out 0..1 boolean
By Age Out 0..1 Coding
Library Content
CQL Content
library AgeStratificationExample version '1.0.0'

using FHIR version '4.0.1'

include hl7.fhir.uv.cql.FHIRHelpers version '4.0.1' called FHIRHelpers

codesystem "Time Period Ranges": 'http://terminology.hl7.org/CodeSystem/time-period-ranges' // { 'P0Y--P1Y', 'P1Y--P5Y', ... }

// Age Groups
code "P10Y--P15Y": 'P10Y--P15Y' from "Time Period Ranges" display '10-14 years'
code "P15Y--P20Y": 'P15Y--P20Y' from "Time Period Ranges" display '15-19 years'
code "P20Y--P9999Y": 'P20Y--P9999Y' from "Time Period Ranges" display '20+ years'

parameter "Measurement Period" Interval<Date> default Interval[@2020-01-01, @2020-12-31]

context Patient

define "Initial Population":
  exists (
    [Encounter] E
      where E.period during "Measurement Period"
  )
  
/*
By Patient Age as of the start of the Measurement Period
Age (10-14, 15-19, 20+)
*/
define "By Age":
  case
    when AgeInYearsAt(start of "Measurement Period") in Interval[10, 14] then "P10Y--P15Y"
    when AgeInYearsAt(start of "Measurement Period") in Interval[15, 19] then "P15Y--P20Y"
    when AgeInYearsAt(start of "Measurement Period") >= 20 then "P20Y--P9999Y"
    else null
  end

ELM XML Content
Encoded data 
ELM JSON Content
Encoded data 
Generated using version 0.5.4 of the sample-content-ig Liquid templates