<?xml version="1.0" encoding="UTF-8"?>

<Measure xmlns="http://hl7.org/fhir">
  <id value="age-stratified-example"/>
  <meta>
    <profile value="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-computablemeasure"/>
  </meta>
  <language value="en"/>
  <text>
    <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml">
  <table class="narrative-table">
    <tbody>
<tr>


<th colspan="2" scope="row" class="row-header">Metadata</th>


</tr>

<tr>


<th scope="row" class="row-header">Title</th>



<td class="content-container">Measure Age Stratified Example</td>


</tr>



<tr>


<th scope="row" class="row-header">Version</th>



<td class="content-container">2.0.0-cibuild</td>


</tr>







  
<tr>


<th scope="row" class="row-header">Identifier</th>



<td class="content-container">urn:oid:2.16.840.1.113883.4.642.40.61.29.20</td>


</tr>








<tr>


<th scope="row" class="row-header">Experimental</th>



<td class="content-container">true</td>


</tr>





<tr>


<th scope="row" class="row-header">Jurisdiction</th>



<td class="content-container">
    001 from <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">http://unstats.un.org/unsd/methods/m49/m49.htm</a> 


</td>


</tr>








<tr>


<th scope="row" class="row-header">Steward (Publisher)</th>



<td class="content-container">HL7 International / Clinical Quality Information</td>


</tr>









<tr>


<th scope="row" class="row-header">Description</th>



<td class="content-container"><div><p>A sample measure demonstrating age stratification using  age ranges represented as ISO-8601-Derived periods.</p>
</div></td>


</tr>






  
<tr>


<th scope="row" class="row-header">Measure Basis</th>



<td class="content-container">boolean</td>


</tr>



<tr>


<th scope="row" class="row-header">Measure Scoring</th>



<td class="content-container">
    cohort from <a href="http://terminology.hl7.org/7.2.0/CodeSystem-measure-scoring.html">http://terminology.hl7.org/CodeSystem/measure-scoring</a> 


</td>


</tr>



















  
  
  
    
    <tr>


<th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: primary)</th>


</tr>
  
  
  











  

  

<tr>
  

<th scope="row" class="row-header">Stratifier</th>


  <td class="content-container">
    
    
      
        <em>Code</em>: <span title="Codes:">Age Group</span>
      
      
        <br/>
      
    
    
      <em>Description</em>: Stratification by age groups represented as ISO-8601-Derived periods.
    
  </td>
</tr>

















<tr>


<th colspan="2" scope="row" class="row-header">Measure Logic</th>


</tr>

<tr>


<th scope="row" class="row-header">Primary Library</th>



<td class="content-container"><a href="Library-AgeStratificationExample.html">Age Stratification Example</a></td>


</tr>




<tr>
  <th scope="row" class="row-header">Contents</th>
  <td class="content-container">
    <em><a href="#population-criteria">Population Criteria</a></em>
    <br/>
    <em><a href="#definitions">Logic Definitions</a></em>
    <br/>
    <em><a href="#terminology">Terminology</a></em>
    <br/>
    <em><a href="#dependencies">Dependencies</a></em>
    <br/>
    <em><a href="#data-requirements">Data Requirements</a></em>
    <br/>
    <em><a href="#parameters">Parameters</a></em>
    <br/>
  </td>
</tr>


  <tr>


<th colspan="2" scope="row" class="row-header"><a name="population-criteria"> </a>Population Criteria</th>


</tr>
  
  
  

  
  
  
    
    <tr>


<th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: primary)</th>


</tr>
  
  
  

  

  
    
        
          
        
          
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
    Stratifier
    
  </th>
</tr>
<tr>

  <td>
    
    
    
    
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
By Patient Age as of the start of the Measurement Period
Age (10-14, 15-19, 20+)
*/
define &quot;By Age&quot;:
  case
    when AgeInYearsAt(start of &quot;Measurement Period&quot;) in Interval[10, 14] then &quot;P10Y--P15Y&quot;
    when AgeInYearsAt(start of &quot;Measurement Period&quot;) in Interval[15, 19] then &quot;P15Y--P20Y&quot;
    when AgeInYearsAt(start of &quot;Measurement Period&quot;) &gt;= 20 then &quot;P20Y--P9999Y&quot;
    else null
  end</code></pre>
    
      
      <a href="#agestratificationexample-by-age"><em>Definition</em></a>
    
  </td>

</tr>

          
        
          
        
    
  


  

  
  


  <tr>


<th colspan="2" scope="row" class="row-header"><a name="definitions"> </a>Logic Definitions</th>


</tr>
  
  
          
        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    Logic Definition
  </th>

  <td class="content-container"><em>Library Name:</em> AgeStratificationExample</td>

</tr>
<tr>

  <td>
    
    
    
    
      <a name="agestratificationexample-initial-population"> </a>
    
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Initial Population&quot;:
  exists (
    [Encounter] E
      where E.period during &quot;Measurement Period&quot;
  )</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    Logic Definition
  </th>

  <td class="content-container"><em>Library Name:</em> AgeStratificationExample</td>

</tr>
<tr>

  <td>
    
    
    
    
      <a name="agestratificationexample-by-age"> </a>
    
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
By Patient Age as of the start of the Measurement Period
Age (10-14, 15-19, 20+)
*/
define &quot;By Age&quot;:
  case
    when AgeInYearsAt(start of &quot;Measurement Period&quot;) in Interval[10, 14] then &quot;P10Y--P15Y&quot;
    when AgeInYearsAt(start of &quot;Measurement Period&quot;) in Interval[15, 19] then &quot;P15Y--P20Y&quot;
    when AgeInYearsAt(start of &quot;Measurement Period&quot;) &gt;= 20 then &quot;P20Y--P9999Y&quot;
    else null
  end</code></pre>
  </td>

</tr>



        




        
        



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    Logic Definition
  </th>

  <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

</tr>
<tr>

  <td>
    
    
    
    
      <a name="fhirhelpers-tointerval"> </a>
    
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
value to a CQL DateTime Interval
@comment: If the start value of the given period is unspecified, the starting
boundary of the resulting interval will be open (meaning the start of the interval
is unknown, as opposed to interpreted as the beginning of time).
*/
define function ToInterval(period FHIR.Period):
    if period is null then
        null
    else
        if period.&quot;start&quot; is null then
            Interval(period.&quot;start&quot;.value, period.&quot;end&quot;.value]
        else
            Interval[period.&quot;start&quot;.value, period.&quot;end&quot;.value]</code></pre>
  </td>

</tr>





  
  


  <tr>


<th colspan="2" scope="row" class="row-header"><a name="terminology"> </a>Terminology</th>


</tr>
  
  
  

 

 


<tr>
  
  
  

<th scope="row" class="row-header">Code System</th>


  
  <td class="content-container">
    
    <em>Description</em>: Code system Time Period Ranges
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <a href="http://terminology.hl7.org/7.2.0/CodeSystem-time-period-ranges.html">Time Period Ranges</a>
    <br/>
    <em>Canonical URL</em>: <tt>http://terminology.hl7.org/CodeSystem/time-period-ranges</tt>
    
  </td>
</tr>
 


  
  <tr>
    <th scope="row" class="row-header">Direct Reference Code</th>
    <td class="content-container">
      
        <em>Display</em>: 10-14 years
        <br/>
      
      <em>Code</em>: P10Y--P15Y
      <br/>
      <em>System</em>: <tt>http://terminology.hl7.org/CodeSystem/time-period-ranges</tt>
    </td>
  </tr>

  <tr>
    <th scope="row" class="row-header">Direct Reference Code</th>
    <td class="content-container">
      
        <em>Display</em>: 15-19 years
        <br/>
      
      <em>Code</em>: P15Y--P20Y
      <br/>
      <em>System</em>: <tt>http://terminology.hl7.org/CodeSystem/time-period-ranges</tt>
    </td>
  </tr>

  <tr>
    <th scope="row" class="row-header">Direct Reference Code</th>
    <td class="content-container">
      
        <em>Display</em>: 20+ years
        <br/>
      
      <em>Code</em>: P20Y--P9999Y
      <br/>
      <em>System</em>: <tt>http://terminology.hl7.org/CodeSystem/time-period-ranges</tt>
    </td>
  </tr>

  
  


  <tr>


<th colspan="2" scope="row" class="row-header"><a name="dependencies"> </a>Dependencies</th>


</tr>
  
  
  


<tr>
  

<th scope="row" class="row-header">Dependency</th>


  <td class="content-container">
    
    <em>Description</em>: FHIR model information
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <a href="http://hl7.org/fhir/uv/cql/STU2/Library-FHIR-ModelInfo.html">http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1</a>
    <br/>
    <em>Canonical URL</em>: <tt>http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1</tt>
    
  </td>
</tr>
 


<tr>
  

<th scope="row" class="row-header">Dependency</th>


  <td class="content-container">
    
    <em>Description</em>: Library FHIRHelpers
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <a href="http://hl7.org/fhir/uv/cql/STU2/Library-FHIRHelpers.html">http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1</a>
    <br/>
    <em>Canonical URL</em>: <tt>http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1</tt>
    
  </td>
</tr>
 

 


  
  






  <tr>


<th colspan="2" scope="row" class="row-header"><a name="data-requirements"> </a>Data Requirements</th>


</tr>
  
  
  
<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Encounter
    <br/>
  
    <em>Profile(s)</em>: 
  
    <a href="http://hl7.org/fhir/R4/encounter.html">Encounter</a>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: period
    <br/>
   
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Patient
    <br/>
  
    <em>Profile(s)</em>: 
  
    <a href="http://hl7.org/fhir/R4/patient.html">Patient</a>
    <br/>        
  
   
   
   
  </td>
</tr>

  
  


  <tr>


<th colspan="2" scope="row" class="row-header"><a name="parameters"> </a>Parameters</th>


</tr>
  
  
  <tr>
  

<th scope="row" class="row-header"/>


  <td class="content-container">
    <table>
      <thead>
        <tr>
          <td><em>Name</em></td>
          <td><em>Use</em></td>
          <td><em>Card.</em></td>
          <td><em>Type</em></td>
          <td><em>Documentation</em></td>
        </tr>
      </thead>
      <tbody>
      
        <tr>
          <td>Measurement Period</td>
          <td>In</td>
          <td>0..1</td>
          <td>Period</td>
          <td/>
        </tr>
      
        <tr>
          <td>Initial Population</td>
          <td>Out</td>
          <td>0..1</td>
          <td>boolean</td>
          <td/>
        </tr>
      
        <tr>
          <td>By Age</td>
          <td>Out</td>
          <td>0..1</td>
          <td>Coding</td>
          <td/>
        </tr>
      
      </tbody>
    </table>
  </td>
</tr>

  
  

<tr>
  <th colspan="2" scope="row" class="row-header">Generated using version 0.5.4 of the sample-content-ig Liquid templates</th>
</tr>

    </tbody>
  </table>
</div>
  </text>
  <contained>
    <Library>
      <id value="effective-data-requirements"/>
      <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
        <valueCoding>
          <system value="http://terminology.hl7.org/CodeSystem/time-period-ranges"/>
          <code value="P10Y--P15Y"/>
          <display value="10-14 years"/>
        </valueCoding>
      </extension>
      <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
        <valueCoding>
          <system value="http://terminology.hl7.org/CodeSystem/time-period-ranges"/>
          <code value="P15Y--P20Y"/>
          <display value="15-19 years"/>
        </valueCoding>
      </extension>
      <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
        <valueCoding>
          <system value="http://terminology.hl7.org/CodeSystem/time-period-ranges"/>
          <code value="P20Y--P9999Y"/>
          <display value="20+ years"/>
        </valueCoding>
      </extension>
      <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="AgeStratificationExample"/>
        </extension>
        <extension url="name">
          <valueString value="Initial Population"/>
        </extension>
        <extension url="statement">
          <valueString value="define &quot;Initial Population&quot;:&#xA;  exists (&#xA;    [Encounter] E&#xA;      where E.period during &quot;Measurement Period&quot;&#xA;  )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="0"/>
        </extension>
      </extension>
      <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="AgeStratificationExample"/>
        </extension>
        <extension url="name">
          <valueString value="By Age"/>
        </extension>
        <extension url="statement">
          <valueString value="/*&#xA;By Patient Age as of the start of the Measurement Period&#xA;Age (10-14, 15-19, 20+)&#xA;*/&#xA;define &quot;By Age&quot;:&#xA;  case&#xA;    when AgeInYearsAt(start of &quot;Measurement Period&quot;) in Interval[10, 14] then &quot;P10Y--P15Y&quot;&#xA;    when AgeInYearsAt(start of &quot;Measurement Period&quot;) in Interval[15, 19] then &quot;P15Y--P20Y&quot;&#xA;    when AgeInYearsAt(start of &quot;Measurement Period&quot;) &gt;= 20 then &quot;P20Y--P9999Y&quot;&#xA;    else null&#xA;  end"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="1"/>
        </extension>
      </extension>
      <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="FHIRHelpers"/>
        </extension>
        <extension url="name">
          <valueString value="ToInterval"/>
        </extension>
        <extension url="statement">
          <valueString value="/*&#xA;@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)&#xA;value to a CQL DateTime Interval&#xA;@comment: If the start value of the given period is unspecified, the starting&#xA;boundary of the resulting interval will be open (meaning the start of the interval&#xA;is unknown, as opposed to interpreted as the beginning of time).&#xA;*/&#xA;define function ToInterval(period FHIR.Period):&#xA;    if period is null then&#xA;        null&#xA;    else&#xA;        if period.&quot;start&quot; is null then&#xA;            Interval(period.&quot;start&quot;.value, period.&quot;end&quot;.value]&#xA;        else&#xA;            Interval[period.&quot;start&quot;.value, period.&quot;end&quot;.value]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="2"/>
        </extension>
      </extension>
      <name value="EffectiveDataRequirements"/>
      <status value="active"/>
      <type>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/library-type"/>
          <code value="module-definition"/>
        </coding>
      </type>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="FHIR model information"/>
        <resource value="http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library FHIRHelpers"/>
        <resource value="http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Code system Time Period Ranges"/>
        <resource value="http://terminology.hl7.org/CodeSystem/time-period-ranges"/>
      </relatedArtifact>
      <parameter>
        <name value="Measurement Period"/>
        <use value="in"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Period"/>
      </parameter>
      <parameter>
        <name value="Initial Population"/>
        <use value="out"/>
        <min value="0"/>
        <max value="1"/>
        <type value="boolean"/>
      </parameter>
      <parameter>
        <name value="By Age"/>
        <use value="out"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Coding"/>
      </parameter>
      <dataRequirement>
        <type value="Encounter"/>
        <profile value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
        <mustSupport value="period"/>
      </dataRequirement>
      <dataRequirement>
        <type value="Patient"/>
        <profile value="http://hl7.org/fhir/StructureDefinition/Patient"/>
      </dataRequirement>
    </Library>
  </contained>
  <extension url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-populationBasis">
    <valueCode value="boolean"/>
  </extension>
  <extension url="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements">
    <valueCanonical value="#effective-data-requirements"/>
  </extension>
  <url value="http://hl7.org/fhir/uv/cqm/Measure/age-stratified-example"/>
  <identifier>
    <system value="urn:ietf:rfc:3986"/>
    <value value="urn:oid:2.16.840.1.113883.4.642.40.61.29.20"/>
  </identifier>
  <version value="2.0.0-cibuild"/>
  <name value="MeasureAgeStratifiedExample"/>
  <title value="Measure Age Stratified Example"/>
  <status value="active"/>
  <experimental value="true"/>
  <date value="2025-08-13"/>
  <publisher value="HL7 International / Clinical Quality Information"/>
  <contact>
    <telecom>
      <system value="url"/>
      <value value="http://www.hl7.org/Special/committees/cqi"/>
    </telecom>
  </contact>
  <description value="A sample measure demonstrating age stratification using  age ranges represented as ISO-8601-Derived periods."/>
  <jurisdiction>
    <coding>
      <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
      <code value="001"/>
    </coding>
  </jurisdiction>
  <library value="http://hl7.org/fhir/uv/cqm/Library/AgeStratificationExample"/>
  <scoring>
    <coding>
      <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"/>
      <code value="cohort"/>
    </coding>
  </scoring>
  <group>
    <extension url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.linkId">
      <valueString value="primary"/>
    </extension>
    <population>
      <extension url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
        <valueString value="primary-age-stratified-example-initial-population"/>
      </extension>
      <code>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="initial-population"/>
        </coding>
      </code>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Initial Population"/>
      </criteria>
    </population>
    <stratifier>
      <extension url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId">
        <valueString value="primary-age-stratified-example-stratification-1"/>
      </extension>
      <extension url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-valueSet">
        <valueCanonical value="http://hl7.org/fhir/uv/cqm/ValueSet/age-stratified-example"/>
      </extension>
      <code>
        <text value="Age Group"/>
      </code>
      <description value="Stratification by age groups represented as ISO-8601-Derived periods."/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="By Age"/>
      </criteria>
    </stratifier>
  </group>
</Measure>