eCQM QICore Content Implementation Guide
2025.0.0 - CI Build

eCQM QICore Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/ecqm-content-qicore-2025/ and changes regularly. See the Directory of published versions

: Hospital Harm - Severe HyperglycemiaFHIR - XML Representation

Active as of 2025-05-23

Raw xml | Download


<Measure xmlns="http://hl7.org/fhir">
  <id value="CMS871HHHyperFHIR"/>
  <meta>
    <profile
             value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablemeasure"/>
    <profile
             value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm"/>
    <profile
             value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/publishable-measure-cqfm"/>
    <profile
             value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/executable-measure-cqfm"/>
    <profile
             value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cql-measure-cqfm"/>
    <profile
             value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/elm-measure-cqfm"/>
    <profile
             value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/ratio-measure-cqfm"/>
  </meta>
  <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">Hospital Harm - Severe HyperglycemiaFHIR</td>
</tr>



<tr>


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


<td class="content-container">0.3.000</td>
</tr>


  
<tr>


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


<td class="content-container">CMS871FHIR</td>
</tr>



  
<tr>


<th scope="row" class="row-header">GUID (Version Independent)</th>


<td class="content-container">urn:uuid:c44ca609-d795-4715-a8fc-1b0b30e46048</td>
</tr>



  
<tr>


<th scope="row" class="row-header">GUID (Version Specific)</th>


<td class="content-container">urn:uuid:b85cda48-6920-482f-aa2f-16efa09efe3f</td>
</tr>



  
    
    
<tr>


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


<td class="content-container">871FHIR</td>
</tr>

  


  
    
    
<tr>


<th scope="row" class="row-header">CMS Consensus Based Entity Identifier</th>


<td class="content-container">3533e</td>
</tr>

  



  
    
    
<tr>


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


<td class="content-container">2026-01-01 through 2026-12-31</td>
</tr>

  















<tr>


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


<td class="content-container">Centers for Medicare &amp; Medicaid Services (CMS)</td>
</tr>






<tr>


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


<td class="content-container">Mathematica</td>
</tr>






<tr>


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


<td class="content-container"><div><p>This measure assesses the number of inpatient hospital days for patients age 18 and older with a hyperglycemic event (harm) per the total qualifying inpatient hospital days for that encounter</p>
</div></td>
</tr>



<tr>


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


<td class="content-container"><div><p>Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets. American Institutes for Research(R), formerly IMPAQ International, disclaims all liability for use or accuracy of any third party codes contained in the specifications.</p>
<p>LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved.</p>
</div></td>
</tr>


<tr>


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


<td class="content-container"><div><p>This performance measure is not a clinical guideline and does not establish a standard of medical care, and has not been tested for all potential applications.</p>
<p>THE MEASURES AND SPECIFICATIONS ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.</p>
<p>Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].</p>
</div></td>
</tr>











<tr>


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


<td class="content-container"><div><p>Hyperglycemia, i.e., elevated glucose level, is common among hospitalized patients, especially those with preexisting diabetes (Umpierrez et al., 2012) and accounts for over 30% of noncritically ill hospitalized patients (Korytkowski, 2022). Hyperglycemia can also affect individuals with no prior history of diabetes and may be induced by medications such as steroids or by parenteral (intravenous) or enteral (tube) feeding.</p>
<p>Severe hyperglycemia, i.e., an extremely elevated glucose level, is significantly associated with a range of harms, including increased in-hospital mortality, infection rates, and hospital length of stay (Pasquel, et al., 2021; Umpierrez et al., 2012, 2015). Lower rates of inpatient severe hyperglycemia may not only improve care for patients but also may reduce costs for healthcare payers (Krinsley et al., 2016). The rate of hyperglycemia varies across hospitals, suggesting opportunities for improvement in inpatient glycemic management (Bersoux et al., 2013; Seisa et al., 2022). The rate of inpatient hyperglycemia can be considered a marker for quality of hospital care, since inpatient hyperglycemia is largely avoidable with proper glycemic management. The use of evidence-based standardized protocols and insulin management protocols have been shown to improve glycemic control and safety (Leroy et al., 2020; Maynard et al., 2015).</p>
<p>It should be noted that this measure does not aim to measure overall glucose control in hospitalized patients; rather, its goal is to assess the occurrence and extent of severe hyperglycemia. This measure is also intended to be used in combination with its companion measure of hypoglycemia (Hospital Harm – Hypoglycemia) to reduce unintended consequences of measurement.</p>
</div></td>
</tr>


<tr>


<th scope="row" class="row-header">Clinical Recommendation Statement</th>


<td class="content-container"><div><p>Multiple guidelines address recommended levels of glycemic control, though these do not define severe hyperglycemia:</p>
<p>From Section 16, Diabetes Care in the Hospital, in the Standards of Care in Diabetes by the American Diabetes Association (American Diabetes Association Professional Practice Committee, 2024):</p>
<p>16.4 Insulin and/or other therapies should be initiated or intensified for treatment of persistent hyperglycemia starting at a threshold of ≥180 mg/dL (10.0 mmol/L) (confirmed on two occasions within 24 hours) for noncritically ill (non-ICU) individuals.</p>
<p>16.5a Once therapy is initiated, a glycemic goal of 140–180 mg/dL (7.8–10.0 mmol/L) is recommended for most critically ill (ICU) individuals with hyperglycemia.</p>
<p>16.5 More stringent glycemic goals, such as 110–140 mg/dL (6.1–7.8 mmol/L), may be appropriate for selected critically ill individuals and are acceptable if they can be achieved without significant hypoglycemia.</p>
<p>From Management of Hyperglycemia in Hospitalized Adult Patients in Non-Critical Care Settings: An Endocrine Society Clinical Practice Guideline (Korytkowski et al., 2022):</p>
<p>Recommendation 1.1
In adults with insulin-treated diabetes hospitalized for noncritical illness who are at high risk of hypoglycemia, we suggest the use of real-time continuous glucose monitoring (CGM) with confirmatory bedside point-of-care blood glucose (POC-BG) monitoring for adjustments in insulin dosing rather than point-of-care blood glucose (POC-BG) testing alone in hospital settings where resources and training are available.</p>
<p>Recommendation 10.1
In adults with no prior history of diabetes hospitalized for noncritical illness with hyperglycemia [defined as blood glucose (BG) &gt; 140 mg/dL (7.8 mmol/L)] during hospitalization, we suggest initial therapy with correctional insulin over scheduled insulin therapy (defined as basal or basal/bolus insulin) to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L). For patients with persistent hyperglycemia [≥2 point-of-care blood glucose (POC-BG) measurements ≥ 180 mg/dL (≥10.0 mmol/L) in a 24-hour period on correctional insulin alone], we suggest the addition of scheduled insulin therapy.</p>
<p>Recommendation 10.2
In adults with diabetes treated with diet or noninsulin diabetes medications prior to admission, we suggest initial therapy with correctional insulin or scheduled insulin therapy to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L). For hospitalized adults started on correctional insulin alone and with persistent hyperglycemia [≥2 point-of-care blood glucose (POC-BG) measurements ≥ 180 mg/dL in a 24-hour period (≥10.0 mmol/L)], we suggest addition of scheduled insulin therapy. We suggest initiation of scheduled insulin therapy for patients with confirmed admission blood glucose (BG) ≥ 180 mg/dL (≥10.0 mmol/L).</p>
<p>Recommendation 10.3
In adults with insulin-treated diabetes prior to admission who are hospitalized for noncritical illness, we recommend continuation of the scheduled insulin regimen modified for nutritional status and severity of illness to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L).</p>
<p>Remarks
Reductions in the dose of basal insulin (by 10% to 20%) at time of hospitalization may be required for patients on basal heavy insulin regimens (defined as doses of basal insulin ≥ 0.6 to 1.0 units/kg/day), in which basal insulin is being used inappropriately to cover meal-related excursions in BG.</p>
<p>There is no clinically accepted cutoff for severe hyperglycemia. Studies have used thresholds of &gt;140, &gt;180, &gt;300, &gt;350 and &gt;400 mg/dL, among other values (American Diabetes Association Professional Practice Committee, 2024; Umpierrez et al, 2012, 2015; Jamesen et al., 2015; Donihi et al., 2011; Mendez et al, 2015; Seisa et al., 2022). Blood glucose level &lt;180 mg/dL is associated with lower rates of mortality and stroke compared with a target glucose &lt;200 mg/dL (Sathya et al., 2013). Glycemic goals may also differ among hospitalized patients. For inpatient management of hyperglycemia in noncritical care, the expert consensus recommends a target range of 100–180 mg/dL (5.6–10.0 mmol/L) for noncritically ill patients with “new” hyperglycemia as well as people with known diabetes prior to admission. Glycemic levels up to 250 mg/dL (13.9 mmol/L) may be acceptable in terminally ill patients with short life expectancy, patients with advanced kidney failure and/or on dialysis, patients at high risk for hypoglycemia, and/or patients with labile glycemic excursions. In these individuals, less aggressive treatment goals that would help avoid symptomatic hypoglycemia and/or hyperglycemia are often more appropriate (American Diabetes Association Professional Practice Committee, 2024). In an older patient with a prior history of severe hypoglycemia, some degree of hyperglycemia may be tolerated to maximize safety. Intensive insulin therapy to target glucose of 100 and 140mg/dL in the ICU did not significantly reduce perioperative complications compared with target glucose of 141 and 180mg/dL after coronary artery bypass surgery (Umpierrez et al., 2015). The current recommendation is to maintain a blood glucose level between 140-180 mg/dL (7.8-10.0 mmol/L) in both cardiac and non-cardiac ICU patients (Sreedharan et al., 2022).</p>
<p>For patients who present with hyperglycemic crises, neurologic status must be monitored closely, with frequent re-examination. Care should be taken to prevent over-correction of hyperglycemia and hyperosmolarity following initial fluid resuscitation of these patients to prevent cerebral edema, which carries a high mortality rate (Gosmanov et al., 2021).</p>
</div></td>
</tr>




<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - American Diabetes Association Professional Practice Committee; 16. (2022). Diabetes Care in the Hospital: Standards of Medical Care in Diabetes—2022. Diabetes Care 1 January 2022; 45 (Supplement_1): S244–S253.  https://doi.org/10.2337/dc22-S016</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Bersoux, S., Cook, C.B., Kongable, G.L., Shu, J. (2013). Trends in glycemic control over a 2-year period in 126 US hospitals. J Hosp Med. 2013;8(3):121-125. doi:10.1002/jhm.1997</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Donihi, A.C., Gibson, J.M., Noschese, M.L., et al. (2011). Effect of targeted glycemic management program on provider response to inpatient hyperglycemia. Endocr Pract. 2011; (4)552-557</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Gosmanov, A.R., Gosmanova, E.O., Kitabchi, A.E. (2021). Hyperglycemic Crises: Diabetic Ketoacidosis and Hyperglycemic Hyperosmolar State. [Updated 2021 May 9]. In: Feingold KR, Anawalt B, Boyce A, et al., editors. Endotext [Internet]. South Dartmouth (MA): MDText.com, Inc.; 2000-. Available from: https://www.ncbi.nlm.nih.gov/books/NBK279052/</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Jamesen, E., Nevalainen, P.L., Eskelinen, A., et al. (2015). Risk factors for perioperative hyperglycemia in primary hip and knee replacements. Acta Orthop. 2015; 86(2):175-182</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Korytkowski, M.T., Muniyappa, R., Antinori-Lent, K., Donihi, A.C., Drincic, A.T, Hirsch, I.B., Luger, A., McDonnell, M.E., Murad, M.H., Nielsen, C., Pegg, C., Rushakoff, R.J., Santesso, N., Umpierrez, G.E. (2022). Management of Hyperglycemia in Hospitalized Adult Patients in Non-Critical Care Settings: An Endocrine Society Clinical Practice Guideline, The Journal of Clinical Endocrinology &amp; Metabolism, Volume 107, Issue 8, August 2022, Pages 2101–2128,  https://doi.org/10.1210/clinem/dgac278</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Krinsley, J.S., Jones, R.L. (2016). Cost analysis of intensive glycemic control in critically ill adult patients. Chest. 2016;129(3)644-650</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - LeRoy, L.,  Richard, S. (2020). Harms Due to Diabetic Agents (Chapter 8), Making Healthcare Safer III: A Critical Analysis of Existing and Emerging Patient Safety Practices. Retrieved from: https://www.ahrq.gov/sites/default/files/wysiwyg/research/findings/making-healthcare-safer/mhs3/diabetes-1.pdf</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Maynard, G., Kulasa, K., Ramos, P., et al. (2015). Impact of a hypoglycemic reduction bundle and a systems approach to inpatient glycemic management. Endocr Pract. 2015;21(4):355-367</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Mendez, C.E., Ata, A., Rourke, J.M., et al. (2015). Daily inpatient glycemic survey (DINGS): A process to remotely identify and assist in the management of hospitalized patients with diabetes and hyperglycemia. Endocr Pract. 2015;21(8):927-935</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Pasquel, F.J., Lansang, M.C., Dhatariya, K., Umpierrez, G.E. (2021). Management of diabetes and hyperglycaemia in the hospital. The Lancet Diabetes &amp; Endocrinology. 2021; 9: 174–88</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Sathya, B., Davis, R., Taveira, T., et al. (2013). Intensity of peri-operative glycemic control and postoperative outcomes in patients with diabetes: a meta-analysis. Diabetes Res Clin Pract. 2013;102(1):815.10.1016/j.diabres.2013.05.003</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Umpierrez, G., Cardona, S., Pasquel, F., et al. (2015). Randomized controlled trial of intensive versus conservative glucose control in patients undergoing coronary artery bypass graft surgery: gluco-CABG trial. Diabetes Care. 2015;38(9):1665-1672</p>
</div>
    
    
    
    
    
  </td>
</tr>

<tr>
  
  
  
  

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


  
  
  <td class="content-container">
    
    
    
    <div><p>CITATION - Umpierrez, G.E., Hellman, R., Korytkowski, M.T., et al. (2012). Management of Hyperglycemia in Hospitalized Patients in Non-critical Care Setting: An Endocrine Society Clinical Practice Guideline. J Clin Endocrinol Metab. 2012;97, 16-38</p>
</div>
    
    
    
    
    
  </td>
</tr>







<tr>


<th scope="row" class="row-header">Guidance (Usage)</th>


<td class="content-container">The measure is using mg/dL as the unit of measurement for glucose results. Millimoles per liter (mmol/L) should be converted to milligrams per deciliter (mg/dL) for reporting this measure. 

When evaluating for days with a glucose level &gt;300 mg/dL, the first 24-hour period after admission to the hospital is not evaluated to account for potentially poor glucose control outside of the hospital setting or that preceded the start of hospital care. The admission starts in the ED or observation when the transition between the ED encounter, observation encounter, and the inpatient encounter are within an hour or less of each other.

This measure evaluates the first 10 days of an eligible inpatient hospitalization in determining eligible days for the denominator and numerator (i.e., the length of stay is truncated to &lt;=10 days when the length exceeds 10 days). Patients admitted for longer length of stays are more likely to have more complex medical conditions.  

In determining eligible days for the denominator and numerator, this measure does not evaluate the last day if it was less than a 24-hour period.  

The “Days in Hospitalization” logic within Measure Observation 1 (associated with the denominator), in conjunction with other logic, returns the day number (e.g., day 1 to day 10) for each day within the hospitalization period to determine the eligible hospital days (e.g., from day 2 to day 10). 

The “Days in Hospitalization” logic within Measure Observation 2 (associated with the numerator), in conjunction with other logic, returns the day number (e.g., day 1 to day 10) for each day within the hospitalization period to determine the eligible hyperglycemic event days (e.g., from day 2 to day 10).

Since the measure does not count any hyperglycemic events that occur in the first 24 hours, day 1 is not considered an eligible hospital day for the Measure Observations. Eligible days range from day 2 up to day 10. However, the measure does allow day 1 to be counted for the Numerator as one of the preceding days for a day where no glucose result is found. In this instance, the measure could evaluate day 1 as one of the two days preceding the day with no glucose result to see if there was a glucose value &gt;=200 mg/dL on day 1. 

Multiple hyperglycemic events can occur during a ‘day,’ but this is still considered one hyperglycemic event day.

The numerator returns the first eligible encounter that meets the qualifying criteria: an inpatient hospitalization with a hyperglycemic event. Only one numerator is counted per encounter. Note that the Numerator returns the encounters, not days, that meet the criteria. 

This measure includes two measure observations used to calculate the ratio of the number of inpatient hospital days with a hyperglycemic (high blood glucose) event over the total number of eligible inpatient hospital days (&lt;= 10 days) for that encounter.  

In ratio measures, both the denominator and numerator populations flow separately from the same initial population. Therefore, the same exclusion criteria must be applied to both the denominator and numerator to prevent excluded cases from being considered. 

The specimen source for the glucose test is blood, serum, plasma, or interstitial fluid, and can be obtained by a laboratory test, a POC test, or a continuous glucose monitor (CGM). Glucose test results from urine specimens are not considered. 

This eCQM is an episode-based measure. An episode is defined as each inpatient hospitalization or encounter that ends during the measurement period.

This FHIR-based measure has been derived from the QDM-based measure: CMS871v5. Please refer to the HL7 QI-Core Implementation Guide https://hl7.org/fhir/us/qicore/STU6/) for more information on QI-Core and mapping recommendations from QDM to QI-Core STU 6 (https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html).</td>
</tr>



  
    
    <tr>


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


</tr>
  
  
  
  
<tr>


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


<td class="content-container">Encounter</td>
</tr>



  
<tr>


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


<td class="content-container"><span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-scoring ratio}">Ratio</span></td>
</tr>







  
<tr>


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


<td class="content-container"><span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-type outcome}">Outcome</span></td>
</tr>




  
<tr>


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


<td class="content-container">None</td>
</tr>



  
<tr>


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


<td class="content-container"><span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-improvement-notation decrease}">decrease</span></td>
</tr>


  
  
    <tr>
      
        

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


      
      <td class="content-container">
        
        <em>ID</em>: InitialPopulation_1
        <br/>
        
        
          <em>Description</em>:
          <p style="white-space: pre-line" class="tab-one">Inpatient hospitalizations for patients age 18 and older that end during the measurement period, as well as either: 

 - A diagnosis of diabetes that starts before or during the encounter; or 
 - Administration of at least one dose of insulin or any hypoglycemic medication during the encounter; or 
 - Presence of at least one glucose value &gt;=200 mg/dL at any time during the encounter</p>
        
        
          
            
            <em>Logic Definition</em>: <a href="#primary-cms871hhhyperfhir-initial-population">Initial Population</a> 
          
        
      </td>
    </tr>
  

  
    <tr>
      
        

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


      
      <td class="content-container">
        
        <em>ID</em>: Denominator_1
        <br/>
        
        
          <em>Description</em>:
          <p style="white-space: pre-line" class="tab-one">Equals Initial Population</p>
        
        
          
            
            <em>Logic Definition</em>: <a href="#primary-cms871hhhyperfhir-denominator">Denominator</a> 
          
        
      </td>
    </tr>
  

  
    <tr>
      
        

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


      
      <td class="content-container">
        
        <em>ID</em>: DenominatorExclusion_1
        <br/>
        
        
          <em>Description</em>:
          <p style="white-space: pre-line" class="tab-one">Inpatient hospitalizations for patients with a glucose result of &gt;600 mg/dL anytime between 1 hour prior to the start of the encounter to 6 hours after the start of the encounter.

-Inpatient hospitalizations for patients who have comfort care measures ordered or provided during the encounter.

-Inpatient hospitalizations for patients who have a discharge disposition to hospice care at home or in a health care facility. 
</p>
        
        
          
            
            <em>Logic Definition</em>: <a href="#primary-cms871hhhyperfhir-denominator-exclusions">Denominator Exclusions</a> 
          
        
      </td>
    </tr>
  

  
    <tr>
      
        

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


      
      <td class="content-container">
        
        <em>ID</em>: Numerator_1
        <br/>
        
        
          <em>Description</em>:
          <p style="white-space: pre-line" class="tab-one">Inpatient hospitalizations with a hyperglycemic event within the first 10 days of the encounter minus the first 24 hours, and minus the last period before discharge from the hospital if less than 24 hours

A hyperglycemic event is defined as: 

 - A day with at least one glucose value &gt;300 mg/dL; 
OR
 - A day where a glucose test and result was not found, and it was preceded by two consecutive days where at least one glucose value during each of the two days was &gt;=200 mg/dL</p>
        
        
          
            
            <em>Logic Definition</em>: <a href="#primary-cms871hhhyperfhir-numerator">Numerator</a> 
          
        
      </td>
    </tr>
  

  
    <tr>
      
        

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


      
      <td class="content-container">
        
        <em>ID</em>: NumeratorExclusion_1
        <br/>
        
        
          <em>Description</em>:
          <p style="white-space: pre-line" class="tab-one">Inpatient hospitalizations for patients with a glucose result of &gt;600 mg/dL anytime between 1 hour prior to the start of the encounter to 6 hours after the start of the encounter.

-Inpatient hospitalizations for patients who have comfort care measures ordered or provided during the encounter.

-Inpatient hospitalizations for patients who have a discharge disposition to hospice care at home or in a health care facility. </p>
        
        
          
            
            <em>Logic Definition</em>: <a href="#primary-cms871hhhyperfhir-numerator-exclusions">Numerator Exclusions</a> 
          
        
      </td>
    </tr>
  

  
    <tr>
      
        

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


      
      <td class="content-container">
        
        <em>ID</em>: MeasureObservation_1_1
        <br/>
        
        
          <em>Description</em>:
          <p style="white-space: pre-line" class="tab-one">Measure Observation 1, associated with the denominator of the ratio: The total number of eligible days of the inpatient hospitalization which match the initial population/denominator criteria and did not meet the denominator exclusion criteria.</p>
        
        
          
            
            <em>Logic Definition</em>: <a href="#primary-cms871hhhyperfhir-denominator-observations">Denominator Observations</a> 
          
        
      </td>
    </tr>
  

  
    <tr>
      
        

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


      
      <td class="content-container">
        
        <em>ID</em>: MeasureObservation_1_2
        <br/>
        
        
          <em>Description</em>:
          <p style="white-space: pre-line" class="tab-one">Measure Observation 2, associated with the numerator of the ratio: The total number of hyperglycemic days during the inpatient hospitalization that meet the numerator criteria and did not meet the numerator exclusion criteria. Days with a hyperglycemic event are defined as: 

- All days with a glucose level &gt;300 mg/dL (except those occurring in the first 24-hour period after admission to the hospital (including the emergency department and observation))
OR
- All days where a glucose was not measured, and it was immediately preceded by two contiguous, consecutive days where at least one glucose value during each of the two days was &gt;=200 mg/dL.</p>
        
        
          
            
            <em>Logic Definition</em>: <a href="#primary-cms871hhhyperfhir-numerator-observations">Numerator Observations</a> 
          
        
      </td>
    </tr>
  

  


  
    
<tr>


<th scope="row" class="row-header">Supplemental Data Guidance</th>


<td class="content-container">For every patient evaluated by this measure also identify payer, race, ethnicity and sex; SDE Ethnicity 
 SDE Payer 
 SDE Race 
 SDE Sex 
 </td>
</tr>

  


  <tr>


<th colspan="2" scope="row" class="row-header">Supplemental Data Elements</th>


</tr>


<tr>
  

<th scope="row" class="row-header">Supplemental Data Element</th>


  <td class="content-container">
    
      <em>ID</em>: sde-ethnicity
      
      <br/>
      
    
    
      
        
          <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>
        
        <br/>
      
    
    
      <em>Description</em>: SDE Ethnicity
    
    
      
        <br/>
        
        <em>Logic Definition</em>: <a href="#cms871hhhyperfhir-sde-ethnicity">SDE Ethnicity</a> 
      
    
  </td>
</tr>

<tr>
  

<th scope="row" class="row-header">Supplemental Data Element</th>


  <td class="content-container">
    
      <em>ID</em>: sde-payer
      
      <br/>
      
    
    
      
        
          <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>
        
        <br/>
      
    
    
      <em>Description</em>: SDE Payer
    
    
      
        <br/>
        
        <em>Logic Definition</em>: <a href="#cms871hhhyperfhir-sde-payer">SDE Payer</a> 
      
    
  </td>
</tr>

<tr>
  

<th scope="row" class="row-header">Supplemental Data Element</th>


  <td class="content-container">
    
      <em>ID</em>: sde-race
      
      <br/>
      
    
    
      
        
          <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>
        
        <br/>
      
    
    
      <em>Description</em>: SDE Race
    
    
      
        <br/>
        
        <em>Logic Definition</em>: <a href="#cms871hhhyperfhir-sde-race">SDE Race</a> 
      
    
  </td>
</tr>

<tr>
  

<th scope="row" class="row-header">Supplemental Data Element</th>


  <td class="content-container">
    
      <em>ID</em>: sde-sex
      
      <br/>
      
    
    
      
        
          <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>
        
        <br/>
      
    
    
      <em>Description</em>: SDE Sex
    
    
      
        <br/>
        
        <em>Logic Definition</em>: <a href="#cms871hhhyperfhir-sde-sex">SDE Sex</a> 
      
    
  </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-CMS871HHHyperFHIR.html">CMS871HHHyperFHIR</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/>
  </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: Group_1)</th>


</tr>
  
  
  
  
    
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
              
            
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="primary-cms871hhhyperfhir-initial-population"> </a>
    
    
    Initial Population
    
  </th>
</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Initial Population&quot;:
  &quot;Encounter with Existing Diabetes Diagnosis&quot;
    union &quot;Encounter with Hypoglycemic Medication&quot;
    union &quot;Encounter with Elevated Glucose Greater Than or Equal to 200&quot;</code></pre>
  </td>

</tr>

          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
      
    
  

  
    
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
              
            
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="primary-cms871hhhyperfhir-denominator"> </a>
    
    
    Denominator
    
  </th>
</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Denominator&quot;:
  &quot;Initial Population&quot;</code></pre>
  </td>

</tr>

          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
      
    
  

  
    
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
              
            
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="primary-cms871hhhyperfhir-denominator-exclusions"> </a>
    
    
    Denominator Exclusion
    
  </th>
</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Denominator Exclusions&quot;:
  &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;</code></pre>
  </td>

</tr>

          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
      
    
  

  
    
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
              
            
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="primary-cms871hhhyperfhir-numerator"> </a>
    
    
    Numerator
    
  </th>
</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Numerator&quot;:
  &quot;Encounter with Hyperglycemic Events&quot;</code></pre>
  </td>

</tr>

          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
      
    
  

  
    
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
              
            
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="primary-cms871hhhyperfhir-numerator-exclusions"> </a>
    
    
    Numerator Exclusion
    
  </th>
</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Numerator Exclusions&quot;:
  &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;</code></pre>
  </td>

</tr>

          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
      
    
  

  
    
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
              
            
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="primary-cms871hhhyperfhir-denominator-observations"> </a>
    
    
    Measure Observation
    
  </th>
</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Counts the number of eligible days in an encounter. This simply filters and counts the data built in
 * &quot;Relevant Encounters With Hyperglycemic Event Days&quot;.*/


define function &quot;Denominator Observations&quot;(QualifyingEncounter Encounter):
  if QualifyingEncounter.id in &quot;Denominator Exclusions&quot;.id then singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return 0
  ) 
    else singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return Count(EncounterWithEventDays.eligibleEventDays)
  )</code></pre>
  </td>

</tr>

          
        
          
        
          
        
      
    
  

  
    
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
              
            
            <tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="primary-cms871hhhyperfhir-numerator-observations"> </a>
    
    
    Measure Observation
    
  </th>
</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Counts the number of eligible days with a hyperglycemic event in an encounter. This simply filters and counts the data built in
 * &quot;Relevant Encounters With Hyperglycemic Event Days&quot;.*/


define function &quot;Numerator Observations&quot;(QualifyingEncounter Encounter):
  if QualifyingEncounter.id in &quot;Denominator Exclusions&quot;.id then singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return 0
  ) 
    else singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return Count(EncounterWithEventDays.eligibleEventDays EligibleEventDay
          where EligibleEventDay.hasHyperglycemicEvent
      )
  )</code></pre>
  </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">
    
      
      <a name="supplementaldataelements-sde-sex"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Sex&quot;:
  case
    when Patient.sex = '248153007' then &quot;Male (finding)&quot;
    when Patient.sex = '248152002' then &quot;Female (finding)&quot;
    else null
  end</code></pre>
  </td>

</tr>



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="supplementaldataelements-sde-payer"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Payer&quot;:
  [Coverage: type in &quot;Payer Type&quot;] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }</code></pre>
  </td>

</tr>



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="supplementaldataelements-sde-ethnicity"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Ethnicity&quot;:
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }</code></pre>
  </td>

</tr>



        



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="supplementaldataelements-sde-race"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Race&quot;:
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }</code></pre>
  </td>

</tr>



        



        



        



        



        



        



        



        



        



        



        



        



        




        
        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        


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

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
@deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservation()` instead.
*/
define function &quot;HospitalizationWithObservation&quot;(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: &quot;Observation Services&quot;] LastObs
  				where LastObs.status = 'finished'
            and LastObs.period ends 1 hour or less on or before start of Visit.period
  				sort by end of period
  			),
  			VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
  			EDVisit: Last([Encounter: &quot;Emergency Department Visit&quot;] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]</code></pre>
  </td>

</tr>



        



        



        



        



        



        



        



        



        




        
        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        


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

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
@deprecated: This function is deprecated. Use the `prevalenceInterval()` fluent function instead
*/
define function ToPrevalenceInterval(condition Choice&lt;&quot;ConditionEncounterDiagnosis&quot;, &quot;ConditionProblemsHealthConcerns&quot;&gt;):
if condition.clinicalStatus ~ &quot;active&quot;
  or condition.clinicalStatus ~ &quot;recurrence&quot;
  or condition.clinicalStatus ~ &quot;relapse&quot; then
  Interval[start of ToInterval(condition.onset), end of ToAbatementInterval(condition)]
else
   (end of ToAbatementInterval(condition)) abatementDate
    return if abatementDate is null then
      Interval[start of ToInterval(condition.onset), abatementDate)
    else
      Interval[start of ToInterval(condition.onset), abatementDate]</code></pre>
  </td>

</tr>



        


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

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Given an interval, return the starting point if the interval has a starting boundary specified,
otherwise, return the ending point
@deprecated: This function is deprecated. Use the fluent function `earliest()` instead
*/
define function &quot;Earliest&quot;(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (HasStart(period)) then start of period
      else end of period</code></pre>
  </td>

</tr>



        



        



        



        


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

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of DateTime, Quanitty, Interval&lt;DateTime&gt;, or Interval&lt;Quantity&gt; types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in QICore, allowing this function to be used across any resource.
The input can be provided as a DateTime, Quantity, Interval&lt;DateTime&gt; or Interval&lt;Quantity&gt;.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
If the input is a DateTime Interval, the result is the input.
If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
*/
define fluent function toInterval(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;, Timing&gt;):
  case
	  when choice is DateTime then
    	Interval[choice as DateTime, choice as DateTime]
		when choice is Interval&lt;DateTime&gt; then
  		choice as Interval&lt;DateTime&gt;
		when choice is Quantity then
		  Interval[Patient.birthDate + (choice as Quantity),
			  Patient.birthDate + (choice as Quantity) + 1 year)
		when choice is Interval&lt;Quantity&gt; then
		  Interval[Patient.birthDate + (choice.low as Quantity),
			  Patient.birthDate + (choice.high as Quantity) + 1 year)
		when choice is Timing then
      Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval&lt;DateTime&gt;
		else
			null as Interval&lt;DateTime&gt;
	end</code></pre>
  </td>

</tr>



        



        



        




        
        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        



        


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

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToString(value uri): value.value</code></pre>
  </td>

</tr>



        


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

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

</tr>
<tr>

  <td>
    <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 scope="row" rowspan="2" class="row-header">
    
      
      <a name="fhirhelpers-tocode"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }</code></pre>
  </td>

</tr>



        




        
        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-sde-sex"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Sex&quot;:
  SDE.&quot;SDE Sex&quot;</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-qualifying-encounter"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Qualifying Encounter&quot;:
  [&quot;Encounter&quot;: &quot;Encounter Inpatient&quot;] InpatientEncounter
    where AgeInYearsAt(date from start of InpatientEncounter.period) &gt;= 18
      and InpatientEncounter.period ends during day of &quot;Measurement Period&quot;
      and InpatientEncounter.status = 'finished'</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-hospitalization-period"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Create paring of encounters to hospitalization period so this calculation can be inspected and the result 
 * can be reused, making the logic faster.*/


define &quot;Encounter with Hospitalization Period&quot;:
  &quot;Qualifying Encounter&quot; QualifyingHospitalization
    return Tuple {
      encounter: QualifyingHospitalization,
      hospitalizationPeriod: CQMCommon.&quot;HospitalizationWithObservation&quot; ( QualifyingHospitalization )
    }</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-existing-diabetes-diagnosis"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Using the already calculated pairing of hospitalization periods with encounters, filter on ones with 
 * diabetes and return the encounter.*/


define &quot;Encounter with Existing Diabetes Diagnosis&quot;:
  &quot;Encounter with Hospitalization Period&quot; Hospitalization
    with [&quot;ConditionEncounterDiagnosis&quot;: &quot;Diabetes&quot;] Diabetes
      such that ( QICoreCommon.&quot;ToPrevalenceInterval&quot; ( Diabetes ) starts before end of Hospitalization.hospitalizationPeriod )
    return Hospitalization.encounter</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-hypoglycemic-medication"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Using the already calculated pairing of hospitalization periods with encounters, filter on ones with 
 * hypoglycemic medicatons and return the encounter.*/


define &quot;Encounter with Hypoglycemic Medication&quot;:
  from
    &quot;Encounter with Hospitalization Period&quot; Hospitalization,
    [&quot;MedicationAdministration&quot;: &quot;Hypoglycemics Treatment Medications&quot;] HypoglycemicMed
    where HypoglycemicMed.status in { 'completed', 'in-progress' }
          //and HypoglycemicMed.status != 'not-done'
      
      and QICoreCommon.&quot;ToInterval&quot; ( HypoglycemicMed.effective ) during Hospitalization.hospitalizationPeriod
    return Hospitalization.encounter</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-elevated-glucose-greater-than-or-equal-to-200"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Using the already calculated pairing of hospitalization periods with encounters, filter on ones with 
 * any elevated (&gt;= 200) blood glucose reading during the hospitalization*/


define &quot;Encounter with Elevated Glucose Greater Than or Equal to 200&quot;:
  &quot;Encounter with Hospitalization Period&quot; Hospitalization
    with [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
      such that QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during Hospitalization.hospitalizationPeriod
        and GlucoseTest.status in { 'final', 'amended', 'corrected' }
            //and GlucoseTest.status != 'cancelled'
        
        and GlucoseTest.value &gt;= 200 'mg/dL'
    return Hospitalization.encounter</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-initial-population"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Initial Population&quot;:
  &quot;Encounter with Existing Diabetes Diagnosis&quot;
    union &quot;Encounter with Hypoglycemic Medication&quot;
    union &quot;Encounter with Elevated Glucose Greater Than or Equal to 200&quot;</code></pre>
  </td>

</tr>



        


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

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Denominator&quot;:
  &quot;Initial Population&quot;</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-measurement-population"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Measurement Population&quot;:
  &quot;Denominator&quot;</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-days-in-hospitalization"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Days in Hospitalization&quot;:
  &quot;Measurement Population&quot; EligibleInpatientHospitalization
    let period: CQMCommon.&quot;HospitalizationWithObservation&quot; ( EligibleInpatientHospitalization ),
    relevantPeriod: &quot;Hospital Days Max 10&quot;(period)
    return Tuple {
      encounter: EligibleInpatientHospitalization,
      hospitalizationPeriod: period,
      relevantPeriod: relevantPeriod,
      relevantDays: &quot;Days In Period&quot;(relevantPeriod)
    }</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-days-with-glucose-results"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Days with Glucose Results&quot;:
  &quot;Days in Hospitalization&quot; InpatientHospitalDays
    return Tuple {
      encounter: InpatientHospitalDays.encounter,
      relevantPeriod: InpatientHospitalDays.relevantPeriod,
      relevantDays: ( InpatientHospitalDays.relevantDays EncounterDay
          return Tuple {
            dayNumber: EncounterDay.dayNumber,
            dayPeriod: EncounterDay.dayPeriod,
            hasSevereResult: exists ( [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
                where GlucoseTest.status in { 'final', 'amended', 'corrected' }
                  and GlucoseTest.value &gt; 300 'mg/dL'
                  and QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during EncounterDay.dayPeriod
            ),
            hasElevatedResult: exists ( [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
                where GlucoseTest.status in { 'final', 'amended', 'corrected' }
                  and GlucoseTest.value &gt;= 200 'mg/dL'
                  and QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during EncounterDay.dayPeriod
            ),
            hasNoGlucoseTest: not exists ( [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
                where GlucoseTest.status in { 'final', 'amended', 'corrected' }
                  and QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during EncounterDay.dayPeriod
            )
          }
      )
    }</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-days-with-hyperglycemic-events"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*# hyper days uses &quot;Relevant Encounters With Glucose Result Days&quot; to find if hyper event on each day. Skips 1st day in 'RelevantDays`. Returns boolean based on: Today high result OR Today no result AND Yesterday high result AND 2 days ago high result*/


define &quot;Days with Hyperglycemic Events&quot;:
  &quot;Days with Glucose Results&quot; EncounterWithResultDays
    let eligibleEventDays: EncounterWithResultDays.relevantDays EncounterDay
      where EncounterDay.dayNumber &gt; 1
      return Tuple {
        dayIndex: EncounterDay.dayNumber,
        dayPeriod: EncounterDay.dayPeriod,
        hasHyperglycemicEvent: ( EncounterDay.hasSevereResult
            or ( EncounterDay.hasNoGlucoseTest
                and EncounterWithResultDays.relevantDays[EncounterDay.dayNumber - 2].hasElevatedResult
                and EncounterWithResultDays.relevantDays[EncounterDay.dayNumber - 3].hasElevatedResult
            )
        )
      }
    return Tuple {
      encounter: EncounterWithResultDays.encounter,
      relevantPeriod: EncounterWithResultDays.relevantPeriod,
      eligibleEventDays: eligibleEventDays
    }</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-hyperglycemic-events"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/***/


define &quot;Encounter with Hyperglycemic Events&quot;:
  &quot;Days with Hyperglycemic Events&quot; HyperglycemicEventDays
    where exists ( HyperglycemicEventDays.eligibleEventDays EligibleEventDay
        where EligibleEventDay.hasHyperglycemicEvent
    )
    return HyperglycemicEventDays.encounter</code></pre>
  </td>

</tr>



        


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

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Numerator&quot;:
  &quot;Encounter with Hyperglycemic Events&quot;</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-glucose-greater-than-600-within-1-hour-prior-to-and-6-hours-after-encounter-start"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  from
    &quot;Initial Population&quot; InpatientHospitalization,
    [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
    let HospitalizationInterval: CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ),
    GlucoseTestTime: QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective )
    where GlucoseTest.value as Quantity &gt; 600 'mg/dL'
      and GlucoseTest.status in { 'final', 'amended', 'corrected' }
      and GlucoseTestTime during Interval[( start of HospitalizationInterval - 1 hour ), ( start of HospitalizationInterval + 6 hours )]
    return GlucoseTest</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-glucose-tests-earlier-than-glucose-greater-than-600-within-1-hour-prior-to-and-6-hours-after-encounter-start"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Glucose Tests Earlier Than Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  from
    &quot;Initial Population&quot; InpatientHospitalization,
    &quot;Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot; GlucoseResult600,
    [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] EarlierGlucoseTest
    let HospitalizationInterval: CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ),
    GlucoseTest600Time: QICoreCommon.&quot;Earliest&quot; ( GlucoseResult600.effective ),
    EarlierGlucoseTestTime: QICoreCommon.&quot;Earliest&quot; ( EarlierGlucoseTest.effective )
    where GlucoseTest600Time during Interval[( start of HospitalizationInterval - 1 hour ), ( start of HospitalizationInterval + 6 hour )]
      and EarlierGlucoseTestTime during Interval[( start of HospitalizationInterval - 1 hour ), GlucoseTest600Time )
      and EarlierGlucoseTest.id !~ GlucoseResult600.id
    return GlucoseResult600</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-initial-glucose-greater-than-600-within-1-hour-prior-to-and-6-hours-after-encounter-start"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Initial Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  &quot;Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot; GlucoseResult600
    where not ( GlucoseResult600.id in &quot;Glucose Tests Earlier Than Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;.id )</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-glucose-greater-than-600-within-1-hour-prior-to-and-6-hours-after-encounter-start"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Encounter with Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  from
    &quot;Initial Population&quot; InpatientHospitalization,
    &quot;Initial Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot; EarlyGlucoseResult
    where EarlyGlucoseResult.value as Quantity &gt; 600 'mg/dL'
      and EarlyGlucoseResult.status in { 'final', 'amended', 'corrected' }
      and QICoreCommon.&quot;Earliest&quot; ( EarlyGlucoseResult.effective ) during Interval[( start of CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ) - 1 hour ), ( start of CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ) + 6 hours )]
    return InpatientHospitalization</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-comfort-measures-care"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/***/


define &quot;Comfort Measures Care&quot;:
  [&quot;ServiceRequest&quot;: &quot;Comfort Measures&quot;]
    union [&quot;Procedure&quot;: &quot;Comfort Measures&quot;]</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-comfort-measures-during-hospitalization"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Encounter with Comfort Measures during Hospitalization&quot;:
  &quot;Initial Population&quot; InpatientHospitalization
    with &quot;Comfort Measures Care&quot; ComfortCare
      such that Coalesce(ComfortCare.performed.toInterval(), ComfortCare.authoredOn.toInterval()) during CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization )</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-discharge-for-hospice-care"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Encounter with Discharge for Hospice Care&quot;:
  &quot;Initial Population&quot; InpatientHospitalization
    where InpatientHospitalization.hospitalization.dischargeDisposition in &quot;Discharged to Home for Hospice Care&quot;
      or InpatientHospitalization.hospitalization.dischargeDisposition in &quot;Discharged to Health Care Facility for Hospice Care&quot;</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-encounter-with-early-glucose-greater-than-600-or-with-comfort-or-hospice-care"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;:
  &quot;Encounter with Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;
    union &quot;Encounter with Comfort Measures during Hospitalization&quot;
    union &quot;Encounter with Discharge for Hospice Care&quot;</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-numerator-exclusions"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Numerator Exclusions&quot;:
  &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;</code></pre>
  </td>

</tr>



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-sde-payer"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Payer&quot;:
  SDE.&quot;SDE Payer&quot;</code></pre>
  </td>

</tr>



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-sde-ethnicity"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Ethnicity&quot;:
  SDE.&quot;SDE Ethnicity&quot;</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-denominator-exclusions"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Denominator Exclusions&quot;:
  &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;</code></pre>
  </td>

</tr>



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-sde-race"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Race&quot;:
  SDE.&quot;SDE Race&quot;</code></pre>
  </td>

</tr>



        



        



        



        



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-hospital-days-max-10"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Crops an interval to a maximum length of 10 days.*/


define function &quot;Hospital Days Max 10&quot;(Period Interval&lt;DateTime&gt;):
  Interval[start of Period, Min({ 
    end of Period, start of Period + 10 days }
  )]</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-days-in-period"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Creates a list of 24 hour long intervals in an interval paired with the index (1 indexed) to which 24 hour interval it is.*/


define function &quot;Days In Period&quot;(Period Interval&lt;DateTime&gt;):
  ( &quot;Interval To Day Numbers&quot;(Period) ) DayNumber
    let startPeriod: start of Period + ( 24 hours * ( DayNumber - 1 ) ),
    endPeriod: if ( hours between startPeriod and end of Period &lt; 24 ) then startPeriod 
      else start of Period + ( 24 hours * DayNumber )
    return Tuple {
      dayNumber: DayNumber,
      dayPeriod: Interval[startPeriod, endPeriod )
    }</code></pre>
  </td>

</tr>



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-interval-to-day-numbers"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Creates a list of integers from 1 to how many days are in the interval. Note, this wont create an index for
 * the final day if it is less than 24 hours. This also includes the first 24 hour period.*/


define function &quot;Interval To Day Numbers&quot;(Period Interval&lt;DateTime&gt;):
  ( expand { Interval[1, duration in days between start of Period and end of Period]} ) DayExpand
    return end of DayExpand</code></pre>
  </td>

</tr>



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-denominator-observations"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Counts the number of eligible days in an encounter. This simply filters and counts the data built in
 * &quot;Relevant Encounters With Hyperglycemic Event Days&quot;.*/


define function &quot;Denominator Observations&quot;(QualifyingEncounter Encounter):
  if QualifyingEncounter.id in &quot;Denominator Exclusions&quot;.id then singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return 0
  ) 
    else singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return Count(EncounterWithEventDays.eligibleEventDays)
  )</code></pre>
  </td>

</tr>



        



        


<tr>
  <th scope="row" rowspan="2" class="row-header">
    
      
      <a name="cms871hhhyperfhir-numerator-observations"> </a>
    
    Logic Definition
  </th>

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

</tr>
<tr>

  <td>
    <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/**
 * Counts the number of eligible days with a hyperglycemic event in an encounter. This simply filters and counts the data built in
 * &quot;Relevant Encounters With Hyperglycemic Event Days&quot;.*/


define function &quot;Numerator Observations&quot;(QualifyingEncounter Encounter):
  if QualifyingEncounter.id in &quot;Denominator Exclusions&quot;.id then singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return 0
  ) 
    else singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return Count(EncounterWithEventDays.eligibleEventDays EligibleEventDay
          where EligibleEventDay.hasHyperglycemicEvent
      )
  )</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 SNOMEDCT
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <a href="http://hl7.org/fhir/R4/codesystem-snomedct.html">SNOMED CT (all versions)</a>
    <br/>
    <em>Canonical URL</em>: <tt>http://snomed.info/sct</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Encounter Inpatient
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Observation Services
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Emergency Department Visit
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Diabetes
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.103.12.1001</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.103.12.1001</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Hypoglycemics Treatment Medications
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1196.394</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1196.394</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Glucose Lab Test Mass Per Volume
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.34</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.34</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Comfort Measures
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Discharged to Home for Hospice Care
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.209</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.209</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Discharged to Health Care Facility for Hospice Care
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.207</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.207</tt>
    
  </td>
</tr>
 


<tr>
  
  

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


  
  
  <td class="content-container">
    
    <em>Description</em>: Value set Payer Type
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591</tt>
    
  </td>
</tr>
 


  
  <tr>
    <th scope="row" class="row-header">Direct Reference Code</th>
    <td class="content-container">
      
        <em>Display</em>: Male (finding)
        <br/>
      
      <em>Code</em>: 248153007
      <br/>
      <em>System</em>: <tt>http://snomed.info/sct</tt>
    </td>
  </tr>

  <tr>
    <th scope="row" class="row-header">Direct Reference Code</th>
    <td class="content-container">
      
        <em>Display</em>: Female (finding)
        <br/>
      
      <em>Code</em>: 248152002
      <br/>
      <em>System</em>: <tt>http://snomed.info/sct</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>: Library SDE
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <a href="Library-SupplementalDataElements.html">SupplementalDataElementsversion: null5.1.000)</a>
    <br/>
    <em>Canonical URL</em>: <tt>https://madie.cms.gov/Library/SupplementalDataElements|5.1.000</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="Library-FHIRHelpers.html">FHIRHelpersversion: null4.4.000)</a>
    <br/>
    <em>Canonical URL</em>: <tt>https://madie.cms.gov/Library/FHIRHelpers|4.4.000</tt>
    
  </td>
</tr>
 


<tr>
  

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


  <td class="content-container">
    
    <em>Description</em>: Library CQMCommon
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <a href="Library-CQMCommon.html">CQMCommonversion: null4.1.000)</a>
    <br/>
    <em>Canonical URL</em>: <tt>https://madie.cms.gov/Library/CQMCommon|4.1.000</tt>
    
  </td>
</tr>
 


<tr>
  

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


  <td class="content-container">
    
    <em>Description</em>: Library QICoreCommon
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <a href="Library-QICoreCommon.html">QICoreCommonversion: null4.0.000)</a>
    <br/>
    <em>Canonical URL</em>: <tt>https://madie.cms.gov/Library/QICoreCommon|4.0.000</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>: Patient
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: extension, birthDate, birthDate.value, url
    <br/>
   
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Encounter
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: type, status, status.value, period, hospitalization, hospitalization.dischargeDisposition
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: type</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Encounter
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: type, status, status.value, period, hospitalization, hospitalization.dischargeDisposition
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: type</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Encounter
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: type, period, status, status.value, hospitalization, hospitalization.dischargeDisposition, hospitalizationPeriod, encounter
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: type</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Condition
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: code
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: code</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.103.12.1001</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: MedicationAdministration
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: medication, status, status.value, effective
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: medication</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1196.394</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: MedicationAdministration
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: medication.reference.value, status, status.value, effective
    <br/>
   
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Medication
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: id.value, code
    <br/>
   
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Observation
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: code, effective, status, status.value, value, id, id.value
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: code</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.34</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: ServiceRequest
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: code
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: code</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Procedure
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: code
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: code</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45</code>
    <br/> 
  
  
  
   
  </td>
</tr>

<tr>
  <th scope="row" class="row-header">Data Requirement</th>
  <td class="content-container">
    <em>Type</em>: Coverage
    <br/>
  
    <em>Profile(s)</em>: 
  
    <code>http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage</code>
    <br/>        
  
   
   
    <em>Must Support Elements</em>: type, period
    <br/>
   
  
    <em>Code Filter(s)</em>: 
    <br/>
  
  
    <span class="tab-one"><em>Path</em>: type</span>
    <br/>
  
  
  
    <span class="tab-one"><em>ValueSet</em>:</span> <code>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591</code>
    <br/> 
  
  
  
   
  </td>
</tr>

  
  

<tr>
  <th colspan="2" scope="row" class="row-header">Generated using version 0.4.8 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/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode">
        <valueCoding>
          <system value="http://snomed.info/sct"/>
          <code value="248153007"/>
          <display value="Male (finding)"/>
        </valueCoding>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode">
        <valueCoding>
          <system value="http://snomed.info/sct"/>
          <code value="248152002"/>
          <display value="Female (finding)"/>
        </valueCoding>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="SupplementalDataElements"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Sex"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Sex&quot;:
  case
    when Patient.sex = '248153007' then &quot;Male (finding)&quot;
    when Patient.sex = '248152002' then &quot;Female (finding)&quot;
    else null
  end"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="0"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Sex"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Sex&quot;:
  SDE.&quot;SDE Sex&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="1"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Qualifying Encounter"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Qualifying Encounter&quot;:
  [&quot;Encounter&quot;: &quot;Encounter Inpatient&quot;] InpatientEncounter
    where AgeInYearsAt(date from start of InpatientEncounter.period) &gt;= 18
      and InpatientEncounter.period ends during day of &quot;Measurement Period&quot;
      and InpatientEncounter.status = 'finished'"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="2"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Encounter with Hospitalization Period"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Create paring of encounters to hospitalization period so this calculation can be inspected and the result 
 * can be reused, making the logic faster.*/


define &quot;Encounter with Hospitalization Period&quot;:
  &quot;Qualifying Encounter&quot; QualifyingHospitalization
    return Tuple {
      encounter: QualifyingHospitalization,
      hospitalizationPeriod: CQMCommon.&quot;HospitalizationWithObservation&quot; ( QualifyingHospitalization )
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="3"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Encounter with Existing Diabetes Diagnosis"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Using the already calculated pairing of hospitalization periods with encounters, filter on ones with 
 * diabetes and return the encounter.*/


define &quot;Encounter with Existing Diabetes Diagnosis&quot;:
  &quot;Encounter with Hospitalization Period&quot; Hospitalization
    with [&quot;ConditionEncounterDiagnosis&quot;: &quot;Diabetes&quot;] Diabetes
      such that ( QICoreCommon.&quot;ToPrevalenceInterval&quot; ( Diabetes ) starts before end of Hospitalization.hospitalizationPeriod )
    return Hospitalization.encounter"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="4"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Encounter with Hypoglycemic Medication"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Using the already calculated pairing of hospitalization periods with encounters, filter on ones with 
 * hypoglycemic medicatons and return the encounter.*/


define &quot;Encounter with Hypoglycemic Medication&quot;:
  from
    &quot;Encounter with Hospitalization Period&quot; Hospitalization,
    [&quot;MedicationAdministration&quot;: &quot;Hypoglycemics Treatment Medications&quot;] HypoglycemicMed
    where HypoglycemicMed.status in { 'completed', 'in-progress' }
          //and HypoglycemicMed.status != 'not-done'
      
      and QICoreCommon.&quot;ToInterval&quot; ( HypoglycemicMed.effective ) during Hospitalization.hospitalizationPeriod
    return Hospitalization.encounter"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="5"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Elevated Glucose Greater Than or Equal to 200"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Using the already calculated pairing of hospitalization periods with encounters, filter on ones with 
 * any elevated (&gt;= 200) blood glucose reading during the hospitalization*/


define &quot;Encounter with Elevated Glucose Greater Than or Equal to 200&quot;:
  &quot;Encounter with Hospitalization Period&quot; Hospitalization
    with [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
      such that QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during Hospitalization.hospitalizationPeriod
        and GlucoseTest.status in { 'final', 'amended', 'corrected' }
            //and GlucoseTest.status != 'cancelled'
        
        and GlucoseTest.value &gt;= 200 'mg/dL'
    return Hospitalization.encounter"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="6"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Initial Population"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Initial Population&quot;:
  &quot;Encounter with Existing Diabetes Diagnosis&quot;
    union &quot;Encounter with Hypoglycemic Medication&quot;
    union &quot;Encounter with Elevated Glucose Greater Than or Equal to 200&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="7"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Denominator"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Denominator&quot;:
  &quot;Initial Population&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="8"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Measurement Population"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Measurement Population&quot;:
  &quot;Denominator&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="9"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Days in Hospitalization"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Days in Hospitalization&quot;:
  &quot;Measurement Population&quot; EligibleInpatientHospitalization
    let period: CQMCommon.&quot;HospitalizationWithObservation&quot; ( EligibleInpatientHospitalization ),
    relevantPeriod: &quot;Hospital Days Max 10&quot;(period)
    return Tuple {
      encounter: EligibleInpatientHospitalization,
      hospitalizationPeriod: period,
      relevantPeriod: relevantPeriod,
      relevantDays: &quot;Days In Period&quot;(relevantPeriod)
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="10"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Days with Glucose Results"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Days with Glucose Results&quot;:
  &quot;Days in Hospitalization&quot; InpatientHospitalDays
    return Tuple {
      encounter: InpatientHospitalDays.encounter,
      relevantPeriod: InpatientHospitalDays.relevantPeriod,
      relevantDays: ( InpatientHospitalDays.relevantDays EncounterDay
          return Tuple {
            dayNumber: EncounterDay.dayNumber,
            dayPeriod: EncounterDay.dayPeriod,
            hasSevereResult: exists ( [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
                where GlucoseTest.status in { 'final', 'amended', 'corrected' }
                  and GlucoseTest.value &gt; 300 'mg/dL'
                  and QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during EncounterDay.dayPeriod
            ),
            hasElevatedResult: exists ( [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
                where GlucoseTest.status in { 'final', 'amended', 'corrected' }
                  and GlucoseTest.value &gt;= 200 'mg/dL'
                  and QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during EncounterDay.dayPeriod
            ),
            hasNoGlucoseTest: not exists ( [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
                where GlucoseTest.status in { 'final', 'amended', 'corrected' }
                  and QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective ) during EncounterDay.dayPeriod
            )
          }
      )
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="11"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Days with Hyperglycemic Events"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*# hyper days uses &quot;Relevant Encounters With Glucose Result Days&quot; to find if hyper event on each day. Skips 1st day in 'RelevantDays`. Returns boolean based on: Today high result OR Today no result AND Yesterday high result AND 2 days ago high result*/


define &quot;Days with Hyperglycemic Events&quot;:
  &quot;Days with Glucose Results&quot; EncounterWithResultDays
    let eligibleEventDays: EncounterWithResultDays.relevantDays EncounterDay
      where EncounterDay.dayNumber &gt; 1
      return Tuple {
        dayIndex: EncounterDay.dayNumber,
        dayPeriod: EncounterDay.dayPeriod,
        hasHyperglycemicEvent: ( EncounterDay.hasSevereResult
            or ( EncounterDay.hasNoGlucoseTest
                and EncounterWithResultDays.relevantDays[EncounterDay.dayNumber - 2].hasElevatedResult
                and EncounterWithResultDays.relevantDays[EncounterDay.dayNumber - 3].hasElevatedResult
            )
        )
      }
    return Tuple {
      encounter: EncounterWithResultDays.encounter,
      relevantPeriod: EncounterWithResultDays.relevantPeriod,
      eligibleEventDays: eligibleEventDays
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="12"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Encounter with Hyperglycemic Events"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/***/


define &quot;Encounter with Hyperglycemic Events&quot;:
  &quot;Days with Hyperglycemic Events&quot; HyperglycemicEventDays
    where exists ( HyperglycemicEventDays.eligibleEventDays EligibleEventDay
        where EligibleEventDay.hasHyperglycemicEvent
    )
    return HyperglycemicEventDays.encounter"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="13"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Numerator"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Numerator&quot;:
  &quot;Encounter with Hyperglycemic Events&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="14"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  from
    &quot;Initial Population&quot; InpatientHospitalization,
    [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] GlucoseTest
    let HospitalizationInterval: CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ),
    GlucoseTestTime: QICoreCommon.&quot;Earliest&quot; ( GlucoseTest.effective )
    where GlucoseTest.value as Quantity &gt; 600 'mg/dL'
      and GlucoseTest.status in { 'final', 'amended', 'corrected' }
      and GlucoseTestTime during Interval[( start of HospitalizationInterval - 1 hour ), ( start of HospitalizationInterval + 6 hours )]
    return GlucoseTest"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="15"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Glucose Tests Earlier Than Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Glucose Tests Earlier Than Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  from
    &quot;Initial Population&quot; InpatientHospitalization,
    &quot;Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot; GlucoseResult600,
    [&quot;LaboratoryResultObservation&quot;: &quot;Glucose Lab Test Mass Per Volume&quot;] EarlierGlucoseTest
    let HospitalizationInterval: CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ),
    GlucoseTest600Time: QICoreCommon.&quot;Earliest&quot; ( GlucoseResult600.effective ),
    EarlierGlucoseTestTime: QICoreCommon.&quot;Earliest&quot; ( EarlierGlucoseTest.effective )
    where GlucoseTest600Time during Interval[( start of HospitalizationInterval - 1 hour ), ( start of HospitalizationInterval + 6 hour )]
      and EarlierGlucoseTestTime during Interval[( start of HospitalizationInterval - 1 hour ), GlucoseTest600Time )
      and EarlierGlucoseTest.id !~ GlucoseResult600.id
    return GlucoseResult600"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="16"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Initial Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Initial Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  &quot;Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot; GlucoseResult600
    where not ( GlucoseResult600.id in &quot;Glucose Tests Earlier Than Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;.id )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="17"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Encounter with Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;:
  from
    &quot;Initial Population&quot; InpatientHospitalization,
    &quot;Initial Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot; EarlyGlucoseResult
    where EarlyGlucoseResult.value as Quantity &gt; 600 'mg/dL'
      and EarlyGlucoseResult.status in { 'final', 'amended', 'corrected' }
      and QICoreCommon.&quot;Earliest&quot; ( EarlyGlucoseResult.effective ) during Interval[( start of CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ) - 1 hour ), ( start of CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization ) + 6 hours )]
    return InpatientHospitalization"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="18"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Comfort Measures Care"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/***/


define &quot;Comfort Measures Care&quot;:
  [&quot;ServiceRequest&quot;: &quot;Comfort Measures&quot;]
    union [&quot;Procedure&quot;: &quot;Comfort Measures&quot;]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="19"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Comfort Measures during Hospitalization"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Encounter with Comfort Measures during Hospitalization&quot;:
  &quot;Initial Population&quot; InpatientHospitalization
    with &quot;Comfort Measures Care&quot; ComfortCare
      such that Coalesce(ComfortCare.performed.toInterval(), ComfortCare.authoredOn.toInterval()) during CQMCommon.&quot;HospitalizationWithObservation&quot; ( InpatientHospitalization )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="20"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Encounter with Discharge for Hospice Care"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Encounter with Discharge for Hospice Care&quot;:
  &quot;Initial Population&quot; InpatientHospitalization
    where InpatientHospitalization.hospitalization.dischargeDisposition in &quot;Discharged to Home for Hospice Care&quot;
      or InpatientHospitalization.hospitalization.dischargeDisposition in &quot;Discharged to Health Care Facility for Hospice Care&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="21"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;:
  &quot;Encounter with Glucose Greater Than 600 within 1 Hour Prior To and 6 Hours After Encounter Start&quot;
    union &quot;Encounter with Comfort Measures during Hospitalization&quot;
    union &quot;Encounter with Discharge for Hospice Care&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="22"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Numerator Exclusions"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Numerator Exclusions&quot;:
  &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="23"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="SupplementalDataElements"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Payer"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Payer&quot;:
  [Coverage: type in &quot;Payer Type&quot;] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="24"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Payer"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Payer&quot;:
  SDE.&quot;SDE Payer&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="25"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="SupplementalDataElements"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Ethnicity"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Ethnicity&quot;:
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="26"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Ethnicity"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Ethnicity&quot;:
  SDE.&quot;SDE Ethnicity&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="27"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Denominator Exclusions"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Denominator Exclusions&quot;:
  &quot;Encounter with Early Glucose Greater Than 600 or with Comfort or Hospice Care&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="28"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="SupplementalDataElements"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Race"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Race&quot;:
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="29"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="SDE Race"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;SDE Race&quot;:
  SDE.&quot;SDE Race&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="30"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="FHIRHelpers"/>
        </extension>
        <extension url="name">
          <valueString value="ToString"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define function ToString(value uri): value.value"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="31"/>
        </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="/*
@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]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="32"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CQMCommon"/>
        </extension>
        <extension url="name">
          <valueString value="HospitalizationWithObservation"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
@deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservation()` instead.
*/
define function &quot;HospitalizationWithObservation&quot;(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: &quot;Observation Services&quot;] LastObs
  				where LastObs.status = 'finished'
            and LastObs.period ends 1 hour or less on or before start of Visit.period
  				sort by end of period
  			),
  			VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
  			EDVisit: Last([Encounter: &quot;Emergency Department Visit&quot;] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="33"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="QICoreCommon"/>
        </extension>
        <extension url="name">
          <valueString value="ToPrevalenceInterval"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
@deprecated: This function is deprecated. Use the `prevalenceInterval()` fluent function instead
*/
define function ToPrevalenceInterval(condition Choice&lt;&quot;ConditionEncounterDiagnosis&quot;, &quot;ConditionProblemsHealthConcerns&quot;&gt;):
if condition.clinicalStatus ~ &quot;active&quot;
  or condition.clinicalStatus ~ &quot;recurrence&quot;
  or condition.clinicalStatus ~ &quot;relapse&quot; then
  Interval[start of ToInterval(condition.onset), end of ToAbatementInterval(condition)]
else
   (end of ToAbatementInterval(condition)) abatementDate
    return if abatementDate is null then
      Interval[start of ToInterval(condition.onset), abatementDate)
    else
      Interval[start of ToInterval(condition.onset), abatementDate]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="34"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="QICoreCommon"/>
        </extension>
        <extension url="name">
          <valueString value="Earliest"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Given an interval, return the starting point if the interval has a starting boundary specified,
otherwise, return the ending point
@deprecated: This function is deprecated. Use the fluent function `earliest()` instead
*/
define function &quot;Earliest&quot;(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (HasStart(period)) then start of period
      else end of period"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="35"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Hospital Days Max 10"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Crops an interval to a maximum length of 10 days.*/


define function &quot;Hospital Days Max 10&quot;(Period Interval&lt;DateTime&gt;):
  Interval[start of Period, Min({ 
    end of Period, start of Period + 10 days }
  )]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="36"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Days In Period"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Creates a list of 24 hour long intervals in an interval paired with the index (1 indexed) to which 24 hour interval it is.*/


define function &quot;Days In Period&quot;(Period Interval&lt;DateTime&gt;):
  ( &quot;Interval To Day Numbers&quot;(Period) ) DayNumber
    let startPeriod: start of Period + ( 24 hours * ( DayNumber - 1 ) ),
    endPeriod: if ( hours between startPeriod and end of Period &lt; 24 ) then startPeriod 
      else start of Period + ( 24 hours * DayNumber )
    return Tuple {
      dayNumber: DayNumber,
      dayPeriod: Interval[startPeriod, endPeriod )
    }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="37"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Interval To Day Numbers"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Creates a list of integers from 1 to how many days are in the interval. Note, this wont create an index for
 * the final day if it is less than 24 hours. This also includes the first 24 hour period.*/


define function &quot;Interval To Day Numbers&quot;(Period Interval&lt;DateTime&gt;):
  ( expand { Interval[1, duration in days between start of Period and end of Period]} ) DayExpand
    return end of DayExpand"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="38"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="QICoreCommon"/>
        </extension>
        <extension url="name">
          <valueString value="toInterval"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of DateTime, Quanitty, Interval&lt;DateTime&gt;, or Interval&lt;Quantity&gt; types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in QICore, allowing this function to be used across any resource.
The input can be provided as a DateTime, Quantity, Interval&lt;DateTime&gt; or Interval&lt;Quantity&gt;.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
If the input is a DateTime Interval, the result is the input.
If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
*/
define fluent function toInterval(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;, Timing&gt;):
  case
	  when choice is DateTime then
    	Interval[choice as DateTime, choice as DateTime]
		when choice is Interval&lt;DateTime&gt; then
  		choice as Interval&lt;DateTime&gt;
		when choice is Quantity then
		  Interval[Patient.birthDate + (choice as Quantity),
			  Patient.birthDate + (choice as Quantity) + 1 year)
		when choice is Interval&lt;Quantity&gt; then
		  Interval[Patient.birthDate + (choice.low as Quantity),
			  Patient.birthDate + (choice.high as Quantity) + 1 year)
		when choice is Timing then
      Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval&lt;DateTime&gt;
		else
			null as Interval&lt;DateTime&gt;
	end"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="39"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Denominator Observations"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Counts the number of eligible days in an encounter. This simply filters and counts the data built in
 * &quot;Relevant Encounters With Hyperglycemic Event Days&quot;.*/


define function &quot;Denominator Observations&quot;(QualifyingEncounter Encounter):
  if QualifyingEncounter.id in &quot;Denominator Exclusions&quot;.id then singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return 0
  ) 
    else singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return Count(EncounterWithEventDays.eligibleEventDays)
  )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="40"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="FHIRHelpers"/>
        </extension>
        <extension url="name">
          <valueString value="ToCode"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="41"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS871HHHyperFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Numerator Observations"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/**
 * Counts the number of eligible days with a hyperglycemic event in an encounter. This simply filters and counts the data built in
 * &quot;Relevant Encounters With Hyperglycemic Event Days&quot;.*/


define function &quot;Numerator Observations&quot;(QualifyingEncounter Encounter):
  if QualifyingEncounter.id in &quot;Denominator Exclusions&quot;.id then singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return 0
  ) 
    else singleton from ( &quot;Days with Hyperglycemic Events&quot; EncounterWithEventDays
      where EncounterWithEventDays.encounter = QualifyingEncounter
      return Count(EncounterWithEventDays.eligibleEventDays EligibleEventDay
          where EligibleEventDay.hasHyperglycemicEvent
      )
  )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="42"/>
        </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="Library SDE"/>
        <resource
                  value="https://madie.cms.gov/Library/SupplementalDataElements|5.1.000"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library FHIRHelpers"/>
        <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library CQMCommon"/>
        <resource value="https://madie.cms.gov/Library/CQMCommon|4.1.000"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library QICoreCommon"/>
        <resource value="https://madie.cms.gov/Library/QICoreCommon|4.0.000"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Code system SNOMEDCT"/>
        <resource value="http://snomed.info/sct"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Encounter Inpatient"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Observation Services"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Emergency Department Visit"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Diabetes"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.103.12.1001"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Hypoglycemics Treatment Medications"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1196.394"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Glucose Lab Test Mass Per Volume"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.34"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Comfort Measures"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Discharged to Home for Hospice Care"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.209"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display
                 value="Value set Discharged to Health Care Facility for Hospice Care"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.207"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Payer Type"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"/>
      </relatedArtifact>
      <parameter>
        <name value="Measurement Period"/>
        <use value="in"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Period"/>
      </parameter>
      <parameter>
        <name value="SDE Sex"/>
        <use value="out"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Coding"/>
      </parameter>
      <parameter>
        <name value="Numerator"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="Denominator"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="Numerator Exclusions"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="SDE Payer"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="Initial Population"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="SDE Ethnicity"/>
        <use value="out"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="Denominator Exclusions"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="SDE Race"/>
        <use value="out"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Resource"/>
      </parameter>
      <dataRequirement>
        <type value="Patient"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient"/>
        <mustSupport value="extension"/>
        <mustSupport value="birthDate"/>
        <mustSupport value="birthDate.value"/>
        <mustSupport value="url"/>
      </dataRequirement>
      <dataRequirement>
        <type value="Encounter"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"/>
        <mustSupport value="type"/>
        <mustSupport value="status"/>
        <mustSupport value="status.value"/>
        <mustSupport value="period"/>
        <mustSupport value="hospitalization"/>
        <mustSupport value="hospitalization.dischargeDisposition"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Encounter"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"/>
        <mustSupport value="type"/>
        <mustSupport value="status"/>
        <mustSupport value="status.value"/>
        <mustSupport value="period"/>
        <mustSupport value="hospitalization"/>
        <mustSupport value="hospitalization.dischargeDisposition"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Encounter"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"/>
        <mustSupport value="type"/>
        <mustSupport value="period"/>
        <mustSupport value="status"/>
        <mustSupport value="status.value"/>
        <mustSupport value="hospitalization"/>
        <mustSupport value="hospitalization.dischargeDisposition"/>
        <mustSupport value="hospitalizationPeriod"/>
        <mustSupport value="encounter"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Condition"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis"/>
        <mustSupport value="code"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.103.12.1001"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="MedicationAdministration"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration"/>
        <mustSupport value="medication"/>
        <mustSupport value="status"/>
        <mustSupport value="status.value"/>
        <mustSupport value="effective"/>
        <codeFilter>
          <path value="medication"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1196.394"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="MedicationAdministration"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration"/>
        <mustSupport value="medication.reference.value"/>
        <mustSupport value="status"/>
        <mustSupport value="status.value"/>
        <mustSupport value="effective"/>
      </dataRequirement>
      <dataRequirement>
        <type value="Medication"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication"/>
        <mustSupport value="id.value"/>
        <mustSupport value="code"/>
      </dataRequirement>
      <dataRequirement>
        <type value="Observation"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab"/>
        <mustSupport value="code"/>
        <mustSupport value="effective"/>
        <mustSupport value="status"/>
        <mustSupport value="status.value"/>
        <mustSupport value="value"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.34"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="ServiceRequest"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest"/>
        <mustSupport value="code"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Coverage"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage"/>
        <mustSupport value="type"/>
        <mustSupport value="period"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"/>
        </codeFilter>
      </dataRequirement>
    </Library>
  </contained>
  <extension
             url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-supplementalDataGuidance" id="supplementalDataGuidance">
    <extension url="guidance">
      <valueString
                   value="For every patient evaluated by this measure also identify payer, race, ethnicity and sex; SDE Ethnicity 
 SDE Payer 
 SDE Race 
 SDE Sex 
 "/>
    </extension>
    <extension url="usage">
      <valueCodeableConcept>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
          <code value="supplemental-data"/>
          <display value="Supplemental Data"/>
        </coding>
        <text value="Supplemental Data Guidance"/>
      </valueCodeableConcept>
    </extension>
  </extension>
  <extension
             url="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements">
    <valueReference>
      <reference value="#effective-data-requirements"/>
    </valueReference>
  </extension>
  <url value="https://madie.cms.gov/Measure/CMS871HHHyperFHIR"/>
  <identifier>
    <use value="usual"/>
    <type>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"/>
        <code value="short-name"/>
        <display value="Short Name"/>
      </coding>
    </type>
    <system value="https://madie.cms.gov/measure/shortName"/>
    <value value="CMS871FHIR"/>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"/>
        <code value="version-independent"/>
        <display value="Version Independent"/>
      </coding>
    </type>
    <system value="urn:ietf:rfc:3986"/>
    <value value="urn:uuid:c44ca609-d795-4715-a8fc-1b0b30e46048"/>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"/>
        <code value="version-specific"/>
        <display value="Version Specific"/>
      </coding>
    </type>
    <system value="urn:ietf:rfc:3986"/>
    <value value="urn:uuid:b85cda48-6920-482f-aa2f-16efa09efe3f"/>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"/>
        <code value="endorser"/>
        <display value="Endorser"/>
      </coding>
    </type>
    <system value="https://madie.cms.gov/measure/cbeId"/>
    <value value="3533e"/>
    <assigner>
      <display value="CMS Consensus Based Entity"/>
    </assigner>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"/>
        <code value="publisher"/>
        <display value="Publisher"/>
      </coding>
    </type>
    <system value="https://madie.cms.gov/measure/cmsId"/>
    <value value="871FHIR"/>
    <assigner>
      <display value="CMS"/>
    </assigner>
  </identifier>
  <version value="0.3.000"/>
  <name value="CMS871HHHyperFHIR"/>
  <title value="Hospital Harm - Severe HyperglycemiaFHIR"/>
  <status value="active"/>
  <experimental value="false"/>
  <date value="2025-05-23T20:52:29+00:00"/>
  <publisher value="Centers for Medicare &amp; Medicaid Services (CMS)"/>
  <contact>
    <telecom>
      <system value="url"/>
      <value value="https://www.cms.gov/"/>
    </telecom>
  </contact>
  <description
               value="This measure assesses the number of inpatient hospital days for patients age 18 and older with a hyperglycemic event (harm) per the total qualifying inpatient hospital days for that encounter"/>
  <usage
         value="The measure is using mg/dL as the unit of measurement for glucose results. Millimoles per liter (mmol/L) should be converted to milligrams per deciliter (mg/dL) for reporting this measure. 

When evaluating for days with a glucose level &gt;300 mg/dL, the first 24-hour period after admission to the hospital is not evaluated to account for potentially poor glucose control outside of the hospital setting or that preceded the start of hospital care. The admission starts in the ED or observation when the transition between the ED encounter, observation encounter, and the inpatient encounter are within an hour or less of each other.

This measure evaluates the first 10 days of an eligible inpatient hospitalization in determining eligible days for the denominator and numerator (i.e., the length of stay is truncated to &lt;=10 days when the length exceeds 10 days). Patients admitted for longer length of stays are more likely to have more complex medical conditions.  

In determining eligible days for the denominator and numerator, this measure does not evaluate the last day if it was less than a 24-hour period.  

The “Days in Hospitalization” logic within Measure Observation 1 (associated with the denominator), in conjunction with other logic, returns the day number (e.g., day 1 to day 10) for each day within the hospitalization period to determine the eligible hospital days (e.g., from day 2 to day 10). 

The “Days in Hospitalization” logic within Measure Observation 2 (associated with the numerator), in conjunction with other logic, returns the day number (e.g., day 1 to day 10) for each day within the hospitalization period to determine the eligible hyperglycemic event days (e.g., from day 2 to day 10).

Since the measure does not count any hyperglycemic events that occur in the first 24 hours, day 1 is not considered an eligible hospital day for the Measure Observations. Eligible days range from day 2 up to day 10. However, the measure does allow day 1 to be counted for the Numerator as one of the preceding days for a day where no glucose result is found. In this instance, the measure could evaluate day 1 as one of the two days preceding the day with no glucose result to see if there was a glucose value &gt;=200 mg/dL on day 1. 

Multiple hyperglycemic events can occur during a ‘day,’ but this is still considered one hyperglycemic event day.

The numerator returns the first eligible encounter that meets the qualifying criteria: an inpatient hospitalization with a hyperglycemic event. Only one numerator is counted per encounter. Note that the Numerator returns the encounters, not days, that meet the criteria. 

This measure includes two measure observations used to calculate the ratio of the number of inpatient hospital days with a hyperglycemic (high blood glucose) event over the total number of eligible inpatient hospital days (&lt;= 10 days) for that encounter.  

In ratio measures, both the denominator and numerator populations flow separately from the same initial population. Therefore, the same exclusion criteria must be applied to both the denominator and numerator to prevent excluded cases from being considered. 

The specimen source for the glucose test is blood, serum, plasma, or interstitial fluid, and can be obtained by a laboratory test, a POC test, or a continuous glucose monitor (CGM). Glucose test results from urine specimens are not considered. 

This eCQM is an episode-based measure. An episode is defined as each inpatient hospitalization or encounter that ends during the measurement period.

This FHIR-based measure has been derived from the QDM-based measure: CMS871v5. Please refer to the HL7 QI-Core Implementation Guide https://hl7.org/fhir/us/qicore/STU6/) for more information on QI-Core and mapping recommendations from QDM to QI-Core STU 6 (https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html)."/>
  <copyright
             value="Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets. American Institutes for Research(R), formerly IMPAQ International, disclaims all liability for use or accuracy of any third party codes contained in the specifications.

LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved."/>
  <effectivePeriod>
    <start value="2026-01-01"/>
    <end value="2026-12-31"/>
  </effectivePeriod>
  <author>
    <name value="Mathematica"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.mathematica.org/"/>
    </telecom>
  </author>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - American Diabetes Association Professional Practice Committee; 16. (2022). Diabetes Care in the Hospital: Standards of Medical Care in Diabetes—2022. Diabetes Care 1 January 2022; 45 (Supplement_1): S244–S253.  https://doi.org/10.2337/dc22-S016
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Bersoux, S., Cook, C.B., Kongable, G.L., Shu, J. (2013). Trends in glycemic control over a 2-year period in 126 US hospitals. J Hosp Med. 2013;8(3):121-125. doi:10.1002/jhm.1997
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Donihi, A.C., Gibson, J.M., Noschese, M.L., et al. (2011). Effect of targeted glycemic management program on provider response to inpatient hyperglycemia. Endocr Pract. 2011; (4)552-557
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Gosmanov, A.R., Gosmanova, E.O., Kitabchi, A.E. (2021). Hyperglycemic Crises: Diabetic Ketoacidosis and Hyperglycemic Hyperosmolar State. [Updated 2021 May 9]. In: Feingold KR, Anawalt B, Boyce A, et al., editors. Endotext [Internet]. South Dartmouth (MA): MDText.com, Inc.; 2000-. Available from: https://www.ncbi.nlm.nih.gov/books/NBK279052/
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Jamesen, E., Nevalainen, P.L., Eskelinen, A., et al. (2015). Risk factors for perioperative hyperglycemia in primary hip and knee replacements. Acta Orthop. 2015; 86(2):175-182
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Korytkowski, M.T., Muniyappa, R., Antinori-Lent, K., Donihi, A.C., Drincic, A.T, Hirsch, I.B., Luger, A., McDonnell, M.E., Murad, M.H., Nielsen, C., Pegg, C., Rushakoff, R.J., Santesso, N., Umpierrez, G.E. (2022). Management of Hyperglycemia in Hospitalized Adult Patients in Non-Critical Care Settings: An Endocrine Society Clinical Practice Guideline, The Journal of Clinical Endocrinology &amp; Metabolism, Volume 107, Issue 8, August 2022, Pages 2101–2128,  https://doi.org/10.1210/clinem/dgac278
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Krinsley, J.S., Jones, R.L. (2016). Cost analysis of intensive glycemic control in critically ill adult patients. Chest. 2016;129(3)644-650
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - LeRoy, L.,  Richard, S. (2020). Harms Due to Diabetic Agents (Chapter 8), Making Healthcare Safer III: A Critical Analysis of Existing and Emerging Patient Safety Practices. Retrieved from: https://www.ahrq.gov/sites/default/files/wysiwyg/research/findings/making-healthcare-safer/mhs3/diabetes-1.pdf
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Maynard, G., Kulasa, K., Ramos, P., et al. (2015). Impact of a hypoglycemic reduction bundle and a systems approach to inpatient glycemic management. Endocr Pract. 2015;21(4):355-367
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Mendez, C.E., Ata, A., Rourke, J.M., et al. (2015). Daily inpatient glycemic survey (DINGS): A process to remotely identify and assist in the management of hospitalized patients with diabetes and hyperglycemia. Endocr Pract. 2015;21(8):927-935
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Pasquel, F.J., Lansang, M.C., Dhatariya, K., Umpierrez, G.E. (2021). Management of diabetes and hyperglycaemia in the hospital. The Lancet Diabetes &amp; Endocrinology. 2021; 9: 174–88
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Sathya, B., Davis, R., Taveira, T., et al. (2013). Intensity of peri-operative glycemic control and postoperative outcomes in patients with diabetes: a meta-analysis. Diabetes Res Clin Pract. 2013;102(1):815.10.1016/j.diabres.2013.05.003
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Umpierrez, G., Cardona, S., Pasquel, F., et al. (2015). Randomized controlled trial of intensive versus conservative glucose control in patients undergoing coronary artery bypass graft surgery: gluco-CABG trial. Diabetes Care. 2015;38(9):1665-1672
"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="citation"/>
    <citation
              value="CITATION - Umpierrez, G.E., Hellman, R., Korytkowski, M.T., et al. (2012). Management of Hyperglycemia in Hospitalized Patients in Non-critical Care Setting: An Endocrine Society Clinical Practice Guideline. J Clin Endocrinol Metab. 2012;97, 16-38
"/>
  </relatedArtifact>
  <library value="https://madie.cms.gov/Library/CMS871HHHyperFHIR"/>
  <disclaimer
              value="This performance measure is not a clinical guideline and does not establish a standard of medical care, and has not been tested for all potential applications.

THE MEASURES AND SPECIFICATIONS ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.

Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM]."/>
  <rationale
             value="Hyperglycemia, i.e., elevated glucose level, is common among hospitalized patients, especially those with preexisting diabetes (Umpierrez et al., 2012) and accounts for over 30% of noncritically ill hospitalized patients (Korytkowski, 2022). Hyperglycemia can also affect individuals with no prior history of diabetes and may be induced by medications such as steroids or by parenteral (intravenous) or enteral (tube) feeding.

Severe hyperglycemia, i.e., an extremely elevated glucose level, is significantly associated with a range of harms, including increased in-hospital mortality, infection rates, and hospital length of stay (Pasquel, et al., 2021; Umpierrez et al., 2012, 2015). Lower rates of inpatient severe hyperglycemia may not only improve care for patients but also may reduce costs for healthcare payers (Krinsley et al., 2016). The rate of hyperglycemia varies across hospitals, suggesting opportunities for improvement in inpatient glycemic management (Bersoux et al., 2013; Seisa et al., 2022). The rate of inpatient hyperglycemia can be considered a marker for quality of hospital care, since inpatient hyperglycemia is largely avoidable with proper glycemic management. The use of evidence-based standardized protocols and insulin management protocols have been shown to improve glycemic control and safety (Leroy et al., 2020; Maynard et al., 2015).

It should be noted that this measure does not aim to measure overall glucose control in hospitalized patients; rather, its goal is to assess the occurrence and extent of severe hyperglycemia. This measure is also intended to be used in combination with its companion measure of hypoglycemia (Hospital Harm – Hypoglycemia) to reduce unintended consequences of measurement."/>
  <clinicalRecommendationStatement
                                   value="Multiple guidelines address recommended levels of glycemic control, though these do not define severe hyperglycemia: 

From Section 16, Diabetes Care in the Hospital, in the Standards of Care in Diabetes by the American Diabetes Association (American Diabetes Association Professional Practice Committee, 2024): 

16.4 Insulin and/or other therapies should be initiated or intensified for treatment of persistent hyperglycemia starting at a threshold of ≥180 mg/dL (10.0 mmol/L) (confirmed on two occasions within 24 hours) for noncritically ill (non-ICU) individuals. 

16.5a Once therapy is initiated, a glycemic goal of 140–180 mg/dL (7.8–10.0 mmol/L) is recommended for most critically ill (ICU) individuals with hyperglycemia.

16.5 More stringent glycemic goals, such as 110–140 mg/dL (6.1–7.8 mmol/L), may be appropriate for selected critically ill individuals and are acceptable if they can be achieved without significant hypoglycemia.

From Management of Hyperglycemia in Hospitalized Adult Patients in Non-Critical Care Settings: An Endocrine Society Clinical Practice Guideline (Korytkowski et al., 2022): 

Recommendation 1.1
In adults with insulin-treated diabetes hospitalized for noncritical illness who are at high risk of hypoglycemia, we suggest the use of real-time continuous glucose monitoring (CGM) with confirmatory bedside point-of-care blood glucose (POC-BG) monitoring for adjustments in insulin dosing rather than point-of-care blood glucose (POC-BG) testing alone in hospital settings where resources and training are available.

Recommendation 10.1
In adults with no prior history of diabetes hospitalized for noncritical illness with hyperglycemia [defined as blood glucose (BG) &gt; 140 mg/dL (7.8 mmol/L)] during hospitalization, we suggest initial therapy with correctional insulin over scheduled insulin therapy (defined as basal or basal/bolus insulin) to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L). For patients with persistent hyperglycemia [≥2 point-of-care blood glucose (POC-BG) measurements ≥ 180 mg/dL (≥10.0 mmol/L) in a 24-hour period on correctional insulin alone], we suggest the addition of scheduled insulin therapy. 

Recommendation 10.2
In adults with diabetes treated with diet or noninsulin diabetes medications prior to admission, we suggest initial therapy with correctional insulin or scheduled insulin therapy to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L). For hospitalized adults started on correctional insulin alone and with persistent hyperglycemia [≥2 point-of-care blood glucose (POC-BG) measurements ≥ 180 mg/dL in a 24-hour period (≥10.0 mmol/L)], we suggest addition of scheduled insulin therapy. We suggest initiation of scheduled insulin therapy for patients with confirmed admission blood glucose (BG) ≥ 180 mg/dL (≥10.0 mmol/L). 

Recommendation 10.3
In adults with insulin-treated diabetes prior to admission who are hospitalized for noncritical illness, we recommend continuation of the scheduled insulin regimen modified for nutritional status and severity of illness to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L).

Remarks
Reductions in the dose of basal insulin (by 10% to 20%) at time of hospitalization may be required for patients on basal heavy insulin regimens (defined as doses of basal insulin ≥ 0.6 to 1.0 units/kg/day), in which basal insulin is being used inappropriately to cover meal-related excursions in BG.

There is no clinically accepted cutoff for severe hyperglycemia. Studies have used thresholds of &gt;140, &gt;180, &gt;300, &gt;350 and &gt;400 mg/dL, among other values (American Diabetes Association Professional Practice Committee, 2024; Umpierrez et al, 2012, 2015; Jamesen et al., 2015; Donihi et al., 2011; Mendez et al, 2015; Seisa et al., 2022). Blood glucose level &lt;180 mg/dL is associated with lower rates of mortality and stroke compared with a target glucose &lt;200 mg/dL (Sathya et al., 2013). Glycemic goals may also differ among hospitalized patients. For inpatient management of hyperglycemia in noncritical care, the expert consensus recommends a target range of 100–180 mg/dL (5.6–10.0 mmol/L) for noncritically ill patients with “new” hyperglycemia as well as people with known diabetes prior to admission. Glycemic levels up to 250 mg/dL (13.9 mmol/L) may be acceptable in terminally ill patients with short life expectancy, patients with advanced kidney failure and/or on dialysis, patients at high risk for hypoglycemia, and/or patients with labile glycemic excursions. In these individuals, less aggressive treatment goals that would help avoid symptomatic hypoglycemia and/or hyperglycemia are often more appropriate (American Diabetes Association Professional Practice Committee, 2024). In an older patient with a prior history of severe hypoglycemia, some degree of hyperglycemia may be tolerated to maximize safety. Intensive insulin therapy to target glucose of 100 and 140mg/dL in the ICU did not significantly reduce perioperative complications compared with target glucose of 141 and 180mg/dL after coronary artery bypass surgery (Umpierrez et al., 2015). The current recommendation is to maintain a blood glucose level between 140-180 mg/dL (7.8-10.0 mmol/L) in both cardiac and non-cardiac ICU patients (Sreedharan et al., 2022). 

For patients who present with hyperglycemic crises, neurologic status must be monitored closely, with frequent re-examination. Care should be taken to prevent over-correction of hyperglycemia and hyperosmolarity following initial fluid resuscitation of these patients to prevent cerebral edema, which carries a high mortality rate (Gosmanov et al., 2021)."/>
  <group id="Group_1">
    <extension
               url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
      <valueCodeableConcept>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-scoring"/>
          <code value="ratio"/>
          <display value="Ratio"/>
        </coding>
      </valueCodeableConcept>
    </extension>
    <extension
               url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis">
      <valueCode value="Encounter"/>
    </extension>
    <extension
               url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type">
      <valueCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/measure-type"/>
          <code value="outcome"/>
          <display value="Outcome"/>
        </coding>
      </valueCodeableConcept>
    </extension>
    <extension
               url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-rateAggregation">
      <valueCode value="None"/>
    </extension>
    <extension
               url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation">
      <valueCodeableConcept>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"/>
          <code value="decrease"/>
          <display value="decrease"/>
        </coding>
      </valueCodeableConcept>
    </extension>
    <population id="InitialPopulation_1">
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="initial-population"/>
          <display value="Initial Population"/>
        </coding>
      </code>
      <description
                   value="Inpatient hospitalizations for patients age 18 and older that end during the measurement period, as well as either: 

 - A diagnosis of diabetes that starts before or during the encounter; or 
 - Administration of at least one dose of insulin or any hypoglycemic medication during the encounter; or 
 - Presence of at least one glucose value &gt;=200 mg/dL at any time during the encounter"/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Initial Population"/>
      </criteria>
    </population>
    <population id="Denominator_1">
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="denominator"/>
          <display value="Denominator"/>
        </coding>
      </code>
      <description value="Equals Initial Population"/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Denominator"/>
      </criteria>
    </population>
    <population id="DenominatorExclusion_1">
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="denominator-exclusion"/>
          <display value="Denominator Exclusion"/>
        </coding>
      </code>
      <description
                   value="Inpatient hospitalizations for patients with a glucose result of &gt;600 mg/dL anytime between 1 hour prior to the start of the encounter to 6 hours after the start of the encounter.

-Inpatient hospitalizations for patients who have comfort care measures ordered or provided during the encounter.

-Inpatient hospitalizations for patients who have a discharge disposition to hospice care at home or in a health care facility. 
"/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Denominator Exclusions"/>
      </criteria>
    </population>
    <population id="Numerator_1">
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="numerator"/>
          <display value="Numerator"/>
        </coding>
      </code>
      <description
                   value="Inpatient hospitalizations with a hyperglycemic event within the first 10 days of the encounter minus the first 24 hours, and minus the last period before discharge from the hospital if less than 24 hours

A hyperglycemic event is defined as: 

 - A day with at least one glucose value &gt;300 mg/dL; 
OR
 - A day where a glucose test and result was not found, and it was preceded by two consecutive days where at least one glucose value during each of the two days was &gt;=200 mg/dL"/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Numerator"/>
      </criteria>
    </population>
    <population id="NumeratorExclusion_1">
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="numerator-exclusion"/>
          <display value="Numerator Exclusion"/>
        </coding>
      </code>
      <description
                   value="Inpatient hospitalizations for patients with a glucose result of &gt;600 mg/dL anytime between 1 hour prior to the start of the encounter to 6 hours after the start of the encounter.

-Inpatient hospitalizations for patients who have comfort care measures ordered or provided during the encounter.

-Inpatient hospitalizations for patients who have a discharge disposition to hospice care at home or in a health care facility. "/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Numerator Exclusions"/>
      </criteria>
    </population>
    <population id="MeasureObservation_1_1">
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
        <valueString value="Sum"/>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
        <valueString value="6402512C-2305-42DC-B5F6-A226B5057B89"/>
      </extension>
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="measure-observation"/>
          <display value="Measure Observation"/>
        </coding>
      </code>
      <description
                   value="Measure Observation 1, associated with the denominator of the ratio: The total number of eligible days of the inpatient hospitalization which match the initial population/denominator criteria and did not meet the denominator exclusion criteria."/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Denominator Observations"/>
      </criteria>
    </population>
    <population id="MeasureObservation_1_2">
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
        <valueString value="Sum"/>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
        <valueString value="340EA45E-2411-4192-9C9D-3DF8D89A1D97"/>
      </extension>
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="measure-observation"/>
          <display value="Measure Observation"/>
        </coding>
      </code>
      <description
                   value="Measure Observation 2, associated with the numerator of the ratio: The total number of hyperglycemic days during the inpatient hospitalization that meet the numerator criteria and did not meet the numerator exclusion criteria. Days with a hyperglycemic event are defined as: 

- All days with a glucose level &gt;300 mg/dL (except those occurring in the first 24-hour period after admission to the hospital (including the emergency department and observation))
OR
- All days where a glucose was not measured, and it was immediately preceded by two contiguous, consecutive days where at least one glucose value during each of the two days was &gt;=200 mg/dL."/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Numerator Observations"/>
      </criteria>
    </population>
  </group>
  <supplementalData id="sde-ethnicity">
    <usage>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
        <code value="supplemental-data"/>
      </coding>
    </usage>
    <description value="SDE Ethnicity"/>
    <criteria>
      <language value="text/cql-identifier"/>
      <expression value="SDE Ethnicity"/>
    </criteria>
  </supplementalData>
  <supplementalData id="sde-payer">
    <usage>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
        <code value="supplemental-data"/>
      </coding>
    </usage>
    <description value="SDE Payer"/>
    <criteria>
      <language value="text/cql-identifier"/>
      <expression value="SDE Payer"/>
    </criteria>
  </supplementalData>
  <supplementalData id="sde-race">
    <usage>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
        <code value="supplemental-data"/>
      </coding>
    </usage>
    <description value="SDE Race"/>
    <criteria>
      <language value="text/cql-identifier"/>
      <expression value="SDE Race"/>
    </criteria>
  </supplementalData>
  <supplementalData id="sde-sex">
    <usage>
      <coding>
        <system
                value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
        <code value="supplemental-data"/>
      </coding>
    </usage>
    <description value="SDE Sex"/>
    <criteria>
      <language value="text/cql-identifier"/>
      <expression value="SDE Sex"/>
    </criteria>
  </supplementalData>
</Measure>