eCQM QICore Content Implementation Guide
2024.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 2024.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-2024/ and changes regularly. See the Directory of published versions

: Hospital Harm - Postoperative Respiratory FailureFHIR - XML Representation

Active as of 2026-03-13

Raw xml | Download


<Measure xmlns="http://hl7.org/fhir">
  <id value="CMS1218HHRFFHIR"/>
  <meta>
    <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"/>
  </meta>
  <text>
    <status value="extensions"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
    <table class="grid dict">
        
            <tr>
                <th scope="row"><b>Title: </b></th>
                <td style="padding-left: 4px;">Hospital Harm - Postoperative Respiratory FailureFHIR</td>
            </tr>
        

        

        
            <tr>
                <th scope="row"><b>Id: </b></th>
                <td style="padding-left: 4px;">CMS1218HHRFFHIR</td>
            </tr>
        

        
            <tr>
                <th scope="row"><b>Version: </b></th>
                <td style="padding-left: 4px;">0.0.003</td>
            </tr>
        

        
            <tr>
                <th scope="row"><b>Url: </b></th>
                <td style="padding-left: 4px;"><a href="Measure-CMS1218HHRFFHIR.html">Hospital Harm - Postoperative Respiratory FailureFHIR</a></td>
            </tr>
        

        
            <tr>
                <th scope="row">
                    <b>
                        
                            
                                Short Name Identifier:
                            
                        
                    </b>
                </th>

                <td style="padding-left: 4px;">
                    
                        <p style="margin-bottom: 5px;">
                            <span>CMS1218FHIR</span>
                        </p>
                    
                </td>
            </tr>
        
            <tr>
                <th scope="row">
                    <b>
                        
                            
                                Version Independent Identifier:
                            
                        
                    </b>
                </th>

                <td style="padding-left: 4px;">
                    
                        <p style="margin-bottom: 5px;">
                            <span>urn:uuid:b6857e46-6412-432d-abc8-0508efc0d2d7</span>
                        </p>
                    
                </td>
            </tr>
        
            <tr>
                <th scope="row">
                    <b>
                        
                            
                                Version Specific Identifier:
                            
                        
                    </b>
                </th>

                <td style="padding-left: 4px;">
                    
                        <p style="margin-bottom: 5px;">
                            <span>urn:uuid:447f5c0f-f39c-4a27-a0bc-d5ae918bef10</span>
                        </p>
                    
                </td>
            </tr>
        
            <tr>
                <th scope="row">
                    <b>
                        
                            
                                Endorser (CMS Consensus Based Entity) Identifier:
                            
                        
                    </b>
                </th>

                <td style="padding-left: 4px;">
                    
                        <p style="margin-bottom: 5px;">
                            <span>4130e</span>
                        </p>
                    
                </td>
            </tr>
        
            <tr>
                <th scope="row">
                    <b>
                        
                            
                                Publisher (CMS) Identifier:
                            
                        
                    </b>
                </th>

                <td style="padding-left: 4px;">
                    
                        <p style="margin-bottom: 5px;">
                            <span>1218FHIR</span>
                        </p>
                    
                </td>
            </tr>
        

        
            <tr>
                <th scope="row"><b>Effective Period: </b></th>
                <td style="padding-left: 4px;">2026-01-01..2026-12-31</td>
            </tr>
        

        

        

        
            <tr>
                <th scope="row"><b>Publisher: </b></th>
                <td style="padding-left: 4px;">Centers for Medicare &amp; Medicaid Services (CMS)</td>
            </tr>
        

        
        <tr>
            <th scope="row"><b>Author: </b></th>
            <td style="padding-left: 4px;">Mathematica</td>
        </tr>
        

        

        
            <tr>
                <th scope="row"><b>Description: </b></th>
                <td style="padding-left: 4px;"><div><p>This measure assesses the number of elective inpatient hospitalizations for patients aged 18 years and older without an obstetrical condition who have a procedure resulting in postoperative respiratory failure (PRF)</p>
</div></td>
            </tr>
        

        

        

        

        

        

        
            <tr>
                <th scope="row"><b>Purpose: </b></th>
                <td style="padding-left: 4px;"><div><p>UNKNOWN</p>
</div></td>
            </tr>
        

        
            <tr>
                <th scope="row"><b>Copyright: </b></th>
                <td style="padding-left: 4px;"><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. Mathematica disclaims all liability for use or accuracy of any third-party codes contained in the specifications. LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc.</p>
<p>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"><b>Disclaimer: </b></th>
                <td style="padding-left: 4px;"><div><p>This performance measure is not a clinical guideline, 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 “AS IS” 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"><b>Rationale: </b></th>
            <td style="padding-left: 4px;"><div><p>Postoperative respiratory failure (PRF), defined as unplanned endotracheal reintubation, prolonged inability to wean from mechanical ventilation, or inadequate oxygenation and/or ventilation, is the most common serious postoperative pulmonary complication, with an incidence of up to 7.5% (the incidence of any postoperative pulmonary complication ranges from 10-40%) (Arozullah et al., 2000; Canet et al., 2015; Gupta et al., 2011; Kor et al., 2014). This measure addresses the prevalence of PRF and the variance between hospitals in the incidence of PRF. PRF is a serious complication that can increase the risk of morbidity and mortality, with in-hospital mortality resulting from PRF estimated at 25% to 40% (Arozullah et al., 2000; Canet &amp; Gallart, 2014). Surgical procedures complicated by PRF have 3.74 times higher adjusted odds of death than those not complicated by respiratory failure, 1.47 times higher odds of 90-day readmission, and 1.86 times higher odds of an outpatient visit with one of 44 postoperative conditions (e.g., bacterial infection, fluid and electrolyte disorder, abdominal hernia) within 90 days of hospital discharge (Miller et al., 2001; Romano et al, 2009). PRF is additionally associated with prolonged mechanical ventilation and the need for rehabilitation or skilled nursing facility placement upon discharge (Thompson &amp; Lisco, 2018).</p>
<p>The incidence of PRF varies by hospital, with higher reported rates of PRF in nonteaching hospitals than teaching hospitals (Rahman et al., 2013). Additionally, one study found that the odds of developing PRF increased by 6% for each level increase in hospital size from small to large (Rahman et al., 2013). This suggests that there remains room for improvement in hospitals reporting higher rates of PRF.</p>
<p>The most widely used current measures of PRF are based on either claims data (CMS Patient Safety Indicator (PSI) 11) or proprietary registry data (National Surgical Quality Improvement Program (NSQIP) of the American College of Surgeons). The eCQM is closely modeled after the NSQIP measure of PRF, which has been widely adopted across American hospitals, and is intended to complement and eventually supplant CMS PSI 11.</p>
</div></td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Clinical recommendation statement: </b></th>
            <td style="padding-left: 4px;"><div><p>Recent studies and current clinical practice guidelines for PRF have identified enhanced recovery pathways, prophylactic mucolytics, postoperative continuous positive airway pressure ventilation, lung protective intraoperative ventilation, prophylactic respiratory physiotherapy, epidural analgesia, and goal directed hemodynamic therapy as evidence-based interventions to reduce the incidence of PRF. Yet, progress in reducing the incidence of PRF has been stymied by lack of consensus regarding the definition of PRF, which patients are most at-risk, which risk factors are potentially modifiable, and which patients are more likely to benefit from targeted interventions of a health care system’s limited resources. This measure would address this gap in data.</p>
<p>Relevant clinical guidelines for preventing postoperative respiratory failure can be found in the following:</p>
<ul>
<li>Mohanty, et al. Optimal Perioperative Management of the Geriatric Patient: Best Practices Guideline from ACS NSQIP/AGS, 2016</li>
<li>Piraino, et al. AARC Clinical Practice Guideline: Management of Adult Patients with Oxygen in the Acute Care Setting, 2022</li>
</ul>
</div></td>
        </tr>
        

        

        
            <tr>
                <th scope="row"><b>Guidance (Usage): </b></th>
                <td style="padding-left: 4px;">PRF is evaluated using mechanical ventilation (MV) documentation or intubation and extubation documentation to allow for hospital documentation variances. Therefore, if MV documentation is not available, intubation and extubation can serve as a proxy for determining if MV occurred and its duration. To determine that an unplanned initiation of MV occurred, the logic looks for evidence of a non-invasive oxygen therapy assessment such as oxygen via 'nasal canula' or 'breathing room air' prior to the MV occurrence to verify that MV was newly initiated. Additionally, facility location codes are used to determine if MV was initiated outside of a procedural area (e.g., medical floor). Conversely, to determine MV duration, the logic looks for evidence that a non-invasive oxygen therapy assessment or another operating room procedure does not exist prior to the MV occurrence to verify that MV was continued without interruption from a procedural area. 
	
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: CMS1218v2. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (https://hl7.org/fhir/us/qicore/STU4.1.1/qdm-to-qicore.html).</td>
            </tr>
        

        
            
                <tr>
                    <th scope="row"><b>Population Criteria: </b></th>
                    <td style="padding-left: 4px;">
                        
                            <table class="grid-dict">
                                
                                    <tr>
                                        <th><b>67520e47670f1c0879cef598</b></th>
                                    </tr>
                                
                                
                                    <tr>
                                        <td>Initial Population:</td>

                                        
                                            
                                                <td>Elective inpatient hospitalizations with no preceding emergency department visit that end during the measurement period for patients aged 18 and older without an obstetrical condition and at least one surgical procedure was performed within the first 3 days of the encounter</td>
                                            
                                        

                                    </tr>
                                
                                    <tr>
                                        <td>Denominator:</td>

                                        
                                            
                                                <td>Equals Initial Population</td>
                                            
                                        

                                    </tr>
                                
                                    <tr>
                                        <td>Denominator Exclusion:</td>

                                        
                                            
                                                <td>Inpatient hospitalizations for patients:

With a diagnosis for a degenerative neurological disorder

With any selected head, neck, and thoracic surgery involving significant risk of airway compromise or requiring airway protection

Who have mechanical ventilation that starts more than one hour prior to the start of the first operating room (OR) procedure

With a diagnosis for a neuromuscular disorder

With arterial partial pressure of carbon dioxide (PaCO2)&gt;50 mmHg combined with an arterial pH&lt;7.30 within 48 hours or less prior to the start of the first OR procedure

With arterial partial pressure of oxygen (PaO2)&lt;50 mmHg within 48 hours or less prior to the start of the first OR procedure

With a principal diagnosis for acute respiratory failure

With a diagnosis for acute respiratory failure present on admission

With any diagnosis present on admission for the existence of a tracheostomy

Where a tracheostomy is performed before or on the same day as the first OR procedure</td>
                                            
                                        

                                    </tr>
                                
                                    <tr>
                                        <td>Numerator:</td>

                                        
                                            
                                                <td>Elective inpatient hospitalizations for patients with postoperative respiratory failure as evidenced by any of the following:

Criterion A: Mechanical ventilation (MV) initiated within 30 days after first OR procedure, as evidenced by:

A.1. Intubation that occurs outside of a procedural area and within 30 days after the end of the first OR procedure of the encounter.

or

A.2. MV that occurs outside of a procedural area within 30 days after the end of the first OR procedure of the encounter and is preceded by a period of non-invasive oxygen therapy between the end of the OR procedure and the MV occurrence, and without a subsequent OR procedure between the non-invasive oxygen therapy and the MV occurrence.

or

Criterion B: MV with a duration of more than 48 hours after the first OR procedure, as evidenced by:

B.1. Extubation that occurs outside of a procedural area more than 48 hours after the end of an OR procedure and within 30 days after the end of the first OR procedure, and is not preceded by a period of non-invasive oxygen therapy or a subsequent OR procedure between the end of the OR procedure and the extubation occurrence.

or

B.2 Mechanical ventilation that occurs between 48 and 72 hours after the end of an OR procedure and within 30 days after the end of the first OR procedure, and is not preceded by a non-invasive oxygen therapy or a subsequent OR procedure between the end of the OR procedure and the MV occurrence. </td>
                                            
                                        

                                    </tr>
                                
                                
                            </table>
                        
                    </td>
                </tr>
            
        

        

        

        

        
            <tr>
                <th scope="row"><b>Libraries: </b></th>
                <td style="padding-left: 4px;">
                    <table class="grid-dict">
                        
                            <tr>
                                <td><a href="Library-CMS1218HHRFFHIR.html">CMS1218HHRFFHIR</a></td>
                            </tr>
                        
                    </table>
                </td>
            </tr>
        

        

        
            
                <tr>
                    <th scope="row"><b>Terminology and Other Dependencies: </b></th>
                    <td style="padding-left: 4px;">
                        
                            <li><code>Library/FHIRHelpers|4.4.000</code></li>
                        
                            <li><code>Library/CQMCommon|2.2.000</code></li>
                        
                            <li><code>Library/QICoreCommon|2.1.000</code></li>
                        
                            <li><code>Library/HospitalHarm|1.1.000</code></li>
                        
                            <li><a href="http://hl7.org/fhir/R4/codesystem-snomedct.html">SNOMED CT (all versions)</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.85/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.85</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion">Emergency Department Visit</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.263/expansion">Obstetrics</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.208/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.208</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1111.143/expansion">Observation Services</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1110.38/expansion">Outpatient Surgery Service</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.179/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.179</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.255/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.255</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.216/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.216</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.107/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.107</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.209/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.209</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.213/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.213</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.241/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.241</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.251/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.251</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.239/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.239</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.95/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.95</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.96/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.96</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.94/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.94</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.88/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.88</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1147.197/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.197</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.89/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.89</a></li>
                        
                            <li><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.181/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.181</a></li>
                        
                    </td>
                </tr>
                <tr>
                    <th scope="row"><b>Parameters:</b></th>
                    <td style="padding-left: 4px;">
                        <table class="grid-dict">
                            <tr>
                                <th><b>name</b></th>
                                <th><b>use</b></th>
                                <th><b>min</b></th>
                                <th><b>max</b></th>
                                <th><b>type</b></th>
                            </tr>
                            
                                <tr>
                                    <td>Measurement Period</td>
                                    <td>In</td>
                                    <td>0</td>
                                    <td>1</td>
                                    <td>Period</td>
                                </tr>
                            
                                <tr>
                                    <td>Numerator</td>
                                    <td>Out</td>
                                    <td>0</td>
                                    <td>*</td>
                                    <td>Resource</td>
                                </tr>
                            
                                <tr>
                                    <td>Denominator</td>
                                    <td>Out</td>
                                    <td>0</td>
                                    <td>*</td>
                                    <td>Resource</td>
                                </tr>
                            
                                <tr>
                                    <td>Initial Population</td>
                                    <td>Out</td>
                                    <td>0</td>
                                    <td>*</td>
                                    <td>Resource</td>
                                </tr>
                            
                                <tr>
                                    <td>Denominator Exclusions</td>
                                    <td>Out</td>
                                    <td>0</td>
                                    <td>*</td>
                                    <td>Resource</td>
                                </tr>
                            
                        </table>
                    </td>
                </tr>

                <tr>
                    <th scope="row"><b>DataRequirements:</b></th>
                    <td style="padding-left: 4px;">
                        <table class="grid-dict">
                            <tr>
                                <th><b>Resource Type</b></th>
                                <th><b>Resource Elements</b></th>
                                <th><b>Valueset Name</b></th>
                                <th><b>Valueset</b></th>
                            </tr>
                            
                                <tr>
                                    <td>Patient(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-patient.html">QICorePatient</a>)</td>
                                    <td>
                                        
                                    </td>
                                    <td>
                                        
                                    </td>
                                    <td/>
                                </tr>
                            
                                <tr>
                                    <td>Encounter(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-encounter.html">QICoreEncounter</a>)</td>
                                    <td>
                                        
                                            type
                                        
                                            period
                                        
                                            location
                                        
                                            location.type
                                        
                                            location.type.value
                                        
                                            id
                                        
                                            id.value
                                        
                                            diagnosis
                                        
                                            extension
                                        
                                            url
                                        
                                            url.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Emergency Department Visit
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion">Emergency Department Visit</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Encounter(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-encounter.html">QICoreEncounter</a>)</td>
                                    <td>
                                        
                                            type
                                        
                                            period
                                        
                                            priority
                                        
                                            location
                                        
                                            location.type
                                        
                                            location.type.value
                                        
                                            id
                                        
                                            id.value
                                        
                                            diagnosis
                                        
                                            extension
                                        
                                            url
                                        
                                            url.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Elective Inpatient Encounter
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.85/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.85</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Encounter(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-encounter.html">QICoreEncounter</a>)</td>
                                    <td>
                                        
                                            type
                                        
                                            period
                                        
                                            priority
                                        
                                            diagnosis
                                        
                                            location
                                        
                                            location.type
                                        
                                            location.type.value
                                        
                                            id
                                        
                                            id.value
                                        
                                            extension
                                        
                                            url
                                        
                                            url.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Elective Inpatient Encounter
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.85/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.85</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Encounter(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-encounter.html">QICoreEncounter</a>)</td>
                                    <td>
                                        
                                            type
                                        
                                            status
                                        
                                            status.value
                                        
                                            period
                                        
                                            location
                                        
                                            location.type
                                        
                                            location.type.value
                                        
                                            id
                                        
                                            id.value
                                        
                                            diagnosis
                                        
                                            extension
                                        
                                            url
                                        
                                            url.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Observation Services
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1111.143/expansion">Observation Services</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Encounter(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-encounter.html">QICoreEncounter</a>)</td>
                                    <td>
                                        
                                            type
                                        
                                            status
                                        
                                            status.value
                                        
                                            period
                                        
                                            location
                                        
                                            location.type
                                        
                                            location.type.value
                                        
                                            id
                                        
                                            id.value
                                        
                                            diagnosis
                                        
                                            extension
                                        
                                            url
                                        
                                            url.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Emergency Department Visit
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion">Emergency Department Visit</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Encounter(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-encounter.html">QICoreEncounter</a>)</td>
                                    <td>
                                        
                                            type
                                        
                                            period
                                        
                                            location
                                        
                                            location.type
                                        
                                            location.type.value
                                        
                                            id
                                        
                                            id.value
                                        
                                            diagnosis
                                        
                                            extension
                                        
                                            url
                                        
                                            url.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Outpatient Surgery Service
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1110.38/expansion">Outpatient Surgery Service</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Condition(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-condition.html">QICoreCondition</a>)</td>
                                    <td>
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                    </td>
                                    <td/>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Anesthesia Requiring Monitored Care
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.255/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.255</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            performed
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 General and Neuraxial Anesthesia
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.208/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.208</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            performed
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 General and Neuraxial Anesthesia
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.208/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.208</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Intubation
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.179/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.179</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Non Invasive Oxygen Therapy by Nasal Cannula or Mask
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.209/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.209</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                    </td>
                                    <td/>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Head, Neck, and Thoracic Surgeries with High Risk Airway Compromise
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.251/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.251</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Mechanical Ventilation
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.107/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.107</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Procedure(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-procedure.html">QICoreProcedure</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            id
                                        
                                            id.value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Tracheostomy Procedures
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.181/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.181</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Observation(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-observation.html">QICoreObservation</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Non Invasive Oxygen Therapy
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.213/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.213</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Observation(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-observation.html">QICoreObservation</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Carbon Dioxide Partial Pressure in Arterial Blood
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.95/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.95</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Observation(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-observation.html">QICoreObservation</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Arterial Blood pH
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.96/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.96</a></td>
                                </tr>
                            
                                <tr>
                                    <td>Observation(<a href="http://hl7.org/fhir/us/qicore/STU4.1.1/StructureDefinition-qicore-observation.html">QICoreObservation</a>)</td>
                                    <td>
                                        
                                            code
                                        
                                            value
                                        
                                    </td>
                                    <td>
                                        
                                            
                                                 Oxygen Partial Pressure in Arterial Blood
                                            
                                        
                                    </td>
                                    <td><a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1248.94/expansion">http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.94</a></td>
                                </tr>
                            
                        </table>
                    </td>
                </tr>

                
                    <tr>
                        <th scope="row"><b>Direct Reference Codes:</b></th>
                        <td style="padding-left: 4px;">
                            <table class="grid-dict">
                                <tr>
                                    <th><b>display</b></th>
                                    <th><b>code</b></th>
                                    <th><b>system</b></th>
                                </tr>
                                
                                    <tr>
                                        <td>Elective (qualifier value)</td>
                                        <td>103390000</td>
                                        <td><a href="https://browser.ihtsdotools.org/">http://snomed.info/sct</a></td>
                                    </tr>
                                
                                    <tr>
                                        <td>Removal of endotracheal tube (procedure)</td>
                                        <td>271280005</td>
                                        <td><a href="https://browser.ihtsdotools.org/">http://snomed.info/sct</a></td>
                                    </tr>
                                
                            </table>
                        </td>
                    </tr>
                

                
                <tr>
                    <th scope="row"><b>Logic Definitions:</b></th>
                    <td style="padding-left: 4px;">
                        
                        <table class="grid-dict">
                            <tr>
                                <th><b>Group</b></th>
                                <th><b>Scoring</b></th>
                                <th><b>Population Criteria</b></th>
                                <th><b>Expression</b></th>
                            </tr>
                            <tr>
                                
                                <td> 67520e47670f1c0879cef598 </td>
                                <td colspan="3" style="padding-left: 4px;">
                                    
                                        <b>Group scoring:</b>
                                        
                                            <span>  proportion </span>
                                        
                                    

                                    

                                    

                                    

                                    
                                        <tr>
                                        
                                            <th scope="row"><b>Type: </b></th>
                                            <td style="padding-left: 4px;">
                                                
                                                    
                                                        <p style="margin-bottom: 5px;">
                                                            <span>Outcome </span>
                                                        </p>
                                                    
                                                
                                                
                                            </td>
                                        
                                        </tr>
                                    

                                    

                                    
                                    <tr>
                                        <th scope="row"><b>Rate Aggregation: </b></th>
                                        <td colspan="3" style="padding-left: 4px;">None</td>
                                    </tr>
                                    

                                    
                                        <tr>
                                            <th scope="row"><b>Improvement Notation: </b></th>
                                            <td style="padding-left: 4px;">
                                            
                                                
                                                    
                                                        <p style="margin-bottom: 5px;">
                                                            <span>increase </span>
                                                        </p>
                                                    
                                                
                                                
                                            
                                            </td>
                                        </tr>
                                    

                                    

                                </td>
                                
                                <tr>
                                    <td/>
                                    <td/>
                                    <td>Initial Population</td>
                                    <td>
                                        
                                            <pre><code class="language-cql">//----------------------  Measure Population Definitions --------------------------------------------------//


define &quot;Initial Population&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot;</code></pre>
                                        
                                    </td>
                                </tr>
                                
                                <tr>
                                    <td/>
                                    <td/>
                                    <td>Denominator</td>
                                    <td>
                                        
                                            <pre><code class="language-cql">define &quot;Denominator&quot;:
  &quot;Initial Population&quot;</code></pre>
                                        
                                    </td>
                                </tr>
                                
                                <tr>
                                    <td/>
                                    <td/>
                                    <td>Denominator Exclusion</td>
                                    <td>
                                        
                                            <pre><code class="language-cql">define &quot;Denominator Exclusions&quot;:
  &quot;Encounter with Degenerative Neurological Disorder&quot;
    union &quot;Encounter with High Risk to Airway Head Neck and Thoracic Surgery&quot;
    union &quot;Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with Neuromuscular Disorder&quot;
    union &quot;Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with Principal Diagnosis of Acute Respiratory Failure&quot;
    union &quot;Encounter with Diagnosis of Acute Respiratory Failure Present on Admission&quot;
    union &quot;Encounter with Tracheostomy Present on Admission&quot;
    union &quot;Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure&quot;</code></pre>
                                        
                                    </td>
                                </tr>
                                
                                <tr>
                                    <td/>
                                    <td/>
                                    <td>Numerator</td>
                                    <td>
                                        
                                            <pre><code class="language-cql">define &quot;Numerator&quot;:
  &quot;Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure&quot;
    union &quot;Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy&quot;
    union &quot;Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia&quot;
    union &quot;Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia&quot;</code></pre>
                                        
                                    </td>
                                </tr>
                                
                                
                            
                            </tr>
                        </table>
                

                <table class="grid-dict">
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Elective Inpatient Encounter with Age 18 and Older without ED Visit</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//----------------------  Supporting definitions for Measure Population Definitions --------------------------------------------------//

// Note: defines that are not referenced elsewhere are at the bottom of this file.

// Supports:  Initial Population clause 1




define &quot;Elective Inpatient Encounter with Age 18 and Older without ED Visit&quot;:
  [&quot;Encounter&quot;: &quot;Elective Inpatient Encounter&quot;] ElectiveEncounter
    where ElectiveEncounter.period ends during day of &quot;Measurement Period&quot;
      and ElectiveEncounter.priority ~ &quot;Elective (qualifier value)&quot;
      and AgeInYearsAt(date from start of ElectiveEncounter.period) &gt;= 18
      and not exists ( [&quot;Encounter&quot;: &quot;Emergency Department Visit&quot;] EDVisit
          where EDVisit.period ends 1 hour or less before or on start of ElectiveEncounter.period
      )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Elective Inpatient Encounter with Age and without Obstetrical Condition</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Supports:  Initial Population clause 1


define &quot;Elective Inpatient Encounter with Age and without Obstetrical Condition&quot;:
  &quot;Elective Inpatient Encounter with Age 18 and Older without ED Visit&quot; ElectiveEncounter
    where not exists ElectiveEncounter.diagnosis EncounterDiagnoses
      where EncounterDiagnoses.condition.getCondition ( ).code in &quot;Obstetrical or Pregnancy Related Conditions&quot;</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Elective Inpatient Encounter with OR Procedure within 3 Days</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//----------------------  Initial Population Clauses --------------------------------------------------//

// Initial Population - clause 1  - (referenced throughout the measure definitions)



define &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot;:
  &quot;Elective Inpatient Encounter with Age and without Obstetrical Condition&quot; ElectiveEncounter
    with [&quot;Procedure&quot;: &quot;General and Neuraxial Anesthesia&quot;] SurgeryWithAnesthesia
      such that SurgeryWithAnesthesia.performed.earliest ( ) during ElectiveEncounter.hospitalizationInterval ( )
        and SurgeryWithAnesthesia.performed.earliest ( ) 3 days or less after start of ElectiveEncounter.hospitalizationInterval ( )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>General Anesthesia and MAC</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Referenced in numerator supporting clauses


define &quot;General Anesthesia and MAC&quot;:
  [&quot;Procedure&quot;: &quot;Anesthesia Requiring Monitored Care&quot;] MAC
    union [&quot;Procedure&quot;: &quot;General and Neuraxial Anesthesia&quot;] GA</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Anesthesia Procedure List</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//----------------------  End Risk Variable Accessory Functions -----------------------------//

//---------------------- Utility Functions --------------------------------------------------//

// Used exclusively in &quot;FirstProcedure&quot; function, below




define &quot;Anesthesia Procedure List&quot;:
  [&quot;Procedure&quot;: &quot;General and Neuraxial Anesthesia&quot;] AnesthesiaProcedures
    where AnesthesiaProcedures.performed.latest ( ) during day of &quot;Measurement Period&quot;</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Intubation During General Anesthesia and MAC</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Supports:  numerator clause 1


define &quot;Intubation During General Anesthesia and MAC&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Intubation&quot;] ProceduralIntubation,
    &quot;General Anesthesia and MAC&quot; ProcedureWithAnesthesia
    where ProceduralIntubation.startsDuringAnesthesia ( ProcedureWithAnesthesia, EncounterWithSurgery )
    return ProceduralIntubation</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//fix

//----------------------  Numerator Clauses --------------------------------------------------//

// Numerator - clause 1




define &quot;Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Intubation&quot;] EndotrachealTubeIn
    let IntubationInterval: EndotrachealTubeIn.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(EndotrachealTubeIn).interval ( )
    where EndotrachealTubeIn.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and EndotrachealTubeIn.startsDuringHospitalization ( EncounterWithSurgery )
      and IntubationInterval starts after end of LatestAnesthesiaInterval
      and EncounterWithSurgery.isNotAtProceduralHospitalLocationDuring ( IntubationInterval )
      and not ( &quot;Intubation During General Anesthesia and MAC&quot;.id contains EndotrachealTubeIn.id )
    return EncounterWithSurgery</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Noninvasive Oxygen Therapy</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Referenced in numerator supporting clauses


define &quot;Noninvasive Oxygen Therapy&quot;:
  [&quot;Procedure&quot;: &quot;Non Invasive Oxygen Therapy by Nasal Cannula or Mask&quot;]
    union [&quot;Observation&quot;: &quot;Non Invasive Oxygen Therapy&quot;]</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Numerator - clause 2


define &quot;Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Mechanical Ventilation&quot;] Ventilation,
    &quot;Noninvasive Oxygen Therapy&quot; OxygenSupport
    let VentilationInterval: Ventilation.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Ventilation).interval ( )
    where Ventilation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )
      and VentilationInterval starts after end of LatestAnesthesiaInterval
      and OxygenSupport.interval ( ) starts during Interval[end of LatestAnesthesiaInterval, start of VentilationInterval]
      and EncounterWithSurgery.isNotAtProceduralHospitalLocationDuring ( VentilationInterval )
    return EncounterWithSurgery</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Extubation with Preceding Noninvasive Oxygen</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Supports:  numerator clause 3


define &quot;Extubation with Preceding Noninvasive Oxygen&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Removal of endotracheal tube (procedure)&quot;] Extubation,
    &quot;Noninvasive Oxygen Therapy&quot; OxygenSupport
    let LatestAnesthesia: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Extubation)
    where Extubation.startsDuringHospitalization ( EncounterWithSurgery )
      and Extubation.startsAfterAnesthesia ( LatestAnesthesia, EncounterWithSurgery )
      and OxygenSupport.interval ( ) starts during Interval[end of LatestAnesthesia.interval ( ), start of Extubation.interval ( )]
    return Extubation</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Extubation During General Anesthesia</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Supports:  numerator clause 3


define &quot;Extubation During General Anesthesia&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Removal of endotracheal tube (procedure)&quot;] Extubation,
    &quot;General Anesthesia and MAC&quot; Anesthesia
    where Extubation.startsDuringAnesthesia ( Anesthesia, EncounterWithSurgery )
    return Extubation</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//fix


// Numerator - clause 3



define &quot;Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Removal of endotracheal tube (procedure)&quot;] Extubation
    let ExtubationInterval: Extubation.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Extubation).interval ( )
    where Extubation.isDuringHospitalization ( EncounterWithSurgery )
      and Extubation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and ExtubationInterval starts more than 48 hours after end of LatestAnesthesiaInterval
      and not ( ( &quot;Extubation with Preceding Noninvasive Oxygen&quot;.id contains Extubation.id )
          and not ( &quot;Extubation During General Anesthesia&quot;.id contains Extubation.id )
      )
      and EncounterWithSurgery.isNotAtProceduralHospitalLocation ( )
    return EncounterWithSurgery</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Numerator - clause 4


define &quot;Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Mechanical Ventilation&quot;] Ventilation
    let VentilationInterval: Ventilation.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Ventilation).interval ( )
    where VentilationInterval starts 48 hours or more after end of LatestAnesthesiaInterval
      and VentilationInterval starts 72 hours or less after end of LatestAnesthesiaInterval
      and Ventilation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )
      and not ( &quot;Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy&quot;.id contains EncounterWithSurgery.id )
      and EncounterWithSurgery.isNotAtProceduralHospitalLocation ( )
    return EncounterWithSurgery</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Numerator</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define &quot;Numerator&quot;:
  &quot;Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure&quot;
    union &quot;Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy&quot;
    union &quot;Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia&quot;
    union &quot;Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia&quot;</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Initial Population</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//----------------------  Measure Population Definitions --------------------------------------------------//


define &quot;Initial Population&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot;</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Denominator</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define &quot;Denominator&quot;:
  &quot;Initial Population&quot;</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Degenerative Neurological Disorder</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//----------------------  Denominator Exclusion Clauses------------------------------------------------//

// Denominator Exclusions - clause 1



define &quot;Encounter with Degenerative Neurological Disorder&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where exists ( EncounterWithSurgery.diagnosis EncounterDiagnosis
        where EncounterDiagnosis.condition.getCondition ( ).code in &quot;Degenerative Neurological Disorder&quot;
    )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with High Risk to Airway Head Neck and Thoracic Surgery</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Denominator Exclusions - clause 2


define &quot;Encounter with High Risk to Airway Head Neck and Thoracic Surgery&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    with [&quot;Procedure&quot;: &quot;Head, Neck, and Thoracic Surgeries with High Risk Airway Compromise&quot;] HeadNeckProcedures
      such that HeadNeckProcedures.startsDuringHospitalization ( EncounterWithSurgery )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Denominator Exclusions - clause 3


define &quot;Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    with [&quot;Procedure&quot;: &quot;Mechanical Ventilation&quot;] Ventilation
      such that Ventilation.interval ( ) starts more than 1 hour before start of FirstAnesthesiaDuringHospitalization(EncounterWithSurgery).interval ( )
        and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Neuromuscular Disorder</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Denominator Exclusions - clause 4


define &quot;Encounter with Neuromuscular Disorder&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where exists ( EncounterWithSurgery.diagnosis EncounterDiagnosis
        where EncounterDiagnosis.condition.getCondition ( ).code in &quot;Neuromuscular Disorder&quot;
    )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Denominator Exclusions - clause 5


define &quot;Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Observation&quot;: &quot;Carbon Dioxide Partial Pressure in Arterial Blood&quot;] CarbonDioxide,
    [&quot;Observation&quot;: &quot;Arterial Blood pH&quot;] BloodpH
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery),
    FirstProcedureTime: FirstProcedure.interval ( )
    where CarbonDioxide.interval ( ) starts 48 hours or less before start of FirstProcedureTime
      and CarbonDioxide.value as Quantity &gt; 50 'mm[Hg]'
      and BloodpH.interval ( ) starts 48 hours or less before start of FirstProcedureTime
      and BloodpH.value as Quantity &lt; 7.30 '[pH]'
      and FirstProcedure is not null
    return EncounterWithSurgery</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//fix

// Denominator Exclusions - clause 6



define &quot;Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
    with [&quot;Observation&quot;: &quot;Oxygen Partial Pressure in Arterial Blood&quot;] Oxygen
      such that Oxygen.interval ( ) starts 48 hours or less before start of FirstProcedure.interval ( )
        and Oxygen.value as Quantity &lt; 50 'mm[Hg]'
        and FirstProcedure is not null
    return EncounterWithSurgery</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Principal Diagnosis of Acute Respiratory Failure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Denominator Exclusions - clause 7


define &quot;Encounter with Principal Diagnosis of Acute Respiratory Failure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where exists ( EncounterWithSurgery.diagnosis Diagnosis
        where Diagnosis.condition.getCondition ( ).code in &quot;Acute Respiratory Failure&quot;
          and Diagnosis.rank = 1
    )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Diagnosis of Acute Respiratory Failure Present on Admission</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Denominator Exclusions - clause 8


define &quot;Encounter with Diagnosis of Acute Respiratory Failure Present on Admission&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where EncounterWithSurgery.diagnosisPresentOnAdmission ( ) in &quot;Present on Admission or Clinically Undetermined&quot;
      and exists ( EncounterWithSurgery.diagnosis Diagnosis
          where Diagnosis.condition.getCondition ( ).code in &quot;Acute Respiratory Failure&quot;
      )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Tracheostomy Present on Admission</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">//fix

// Denominator Exclusions - clause 9



define &quot;Encounter with Tracheostomy Present on Admission&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where EncounterWithSurgery.diagnosisPresentOnAdmission ( ) in &quot;Present on Admission or Clinically Undetermined&quot;
      and exists ( EncounterWithSurgery.diagnosis Dx
          where Dx.condition.getCondition ( ).code in &quot;Tracheostomy Diagnoses&quot;
      )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Tracheostomy Before Day of First OR Procedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Supports:  denominator exclusions clause 10


define &quot;Encounter with Tracheostomy Before Day of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
    with [&quot;Procedure&quot;: &quot;Tracheostomy Procedures&quot;] TracheostomySurgery
      such that TracheostomySurgery.startsDuringHospitalization ( EncounterWithSurgery )
        and TracheostomySurgery.interval ( ) starts before day of FirstProcedure.interval ( )
        and FirstProcedure is not null</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Tracheostomy Same Day of First OR Procedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Supports:  denominator exclusions clause 10


define &quot;Encounter with Tracheostomy Same Day of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
    with [&quot;Procedure&quot;: &quot;Tracheostomy Procedures&quot;] TracheostomySurgery
      such that TracheostomySurgery.startsDuringHospitalization ( EncounterWithSurgery )
        and TracheostomySurgery.interval ( ) starts during day of FirstProcedure.interval ( )
        and FirstProcedure is not null</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Denominator Exclusions - clause 10


define &quot;Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure&quot;:
  &quot;Encounter with Tracheostomy Before Day of First OR Procedure&quot;
    union &quot;Encounter with Tracheostomy Same Day of First OR Procedure&quot;</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>Denominator Exclusions</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define &quot;Denominator Exclusions&quot;:
  &quot;Encounter with Degenerative Neurological Disorder&quot;
    union &quot;Encounter with High Risk to Airway Head Neck and Thoracic Surgery&quot;
    union &quot;Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with Neuromuscular Disorder&quot;
    union &quot;Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with Principal Diagnosis of Acute Respiratory Failure&quot;
    union &quot;Encounter with Diagnosis of Acute Respiratory Failure Present on Admission&quot;
    union &quot;Encounter with Tracheostomy Present on Admission&quot;
    union &quot;Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure&quot;</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>FHIRHelpers</td>
                            
                            
                                <td>ToInterval</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="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><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CQMCommon</td>
                            
                            
                                <td>getCondition</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">/*
@description: Returns the Condition resource for the given reference
*/
define fluent function getCondition(reference Reference):
  singleton from ([Condition] C where C.id = reference.reference.getId())</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>QICoreCommon</td>
                            
                            
                                <td>getId</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">/*
@description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
@comment: This function can be used to determine the logical id of a given resource. It can be used in
a single-server environment to trace references. However, this function does not attempt to resolve
or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
*/
define fluent function getId(uri String):
  Last(Split(uri, '/'))</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>hospitalizationInterval</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define fluent function hospitalizationInterval(enc Encounter):
  enc.hospitalizationWithObservationAndOutpatientSurgeryService ( )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CQMCommon</td>
                            
                            
                                <td>hospitalizationWithObservationAndOutpatientSurgeryService</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">/*
@description: Hospitalization with Observation and Outpatient Surgery Service returns the total interval from the start of any immediately prior emergency department visit, outpatient surgery visit or observation visit to the discharge of the given encounter.
*/
define fluent function hospitalizationWithObservationAndOutpatientSurgeryService(TheEncounter &quot;Encounter&quot; ):
  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
    	),
    	VisitStartWithED: Coalesce(start of EDVisit.period, VisitStart),
    	OutpatientSurgeryVisit: Last([Encounter: &quot;Outpatient Surgery Service&quot;] LastSurgeryOP
			  where LastSurgeryOP.period ends 1 hour or less on or before VisitStartWithED
			  sort by	end of period
    	)
  	return Interval[Coalesce(start of OutpatientSurgeryVisit.period, VisitStartWithED), end of Visit.period]</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>HospitalHarm</td>
                            
                            
                                <td>interval</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// interval
// Given an encounter, procedure or observation resource, returns a normalized Interval object, calculated using QICoreCommon.ToInterval for the given type of resource. 
// Usage:   theEncounter.interval()


define fluent function interval(choice Choice&lt;Procedure,Observation,Encounter&gt;):
   case
      when choice is Procedure   then QICoreCommon.ToInterval ( (choice as Procedure).performed ) 
      when choice is Observation then QICoreCommon.ToInterval ( (choice as Observation).effective ) 
      when choice is Encounter   then QICoreCommon.ToInterval ( (choice as Encounter).period ) 
  else null as Interval&lt;DateTime&gt;
    end</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>QICoreCommon</td>
                            
                            
                                <td>ToInterval</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="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
@deprecated: This function is deprecated. Use the fluent function `toInterval()` instead
*/
define 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><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>LatestGeneralAnesthesiaOrMAC</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define function &quot;LatestGeneralAnesthesiaOrMAC&quot;(event Procedure):
  Last(&quot;General Anesthesia and MAC&quot; ProcedureList
      where ProcedureList.interval() ends before start of event.interval()
      sort by start of QICoreCommon.ToInterval(performed)
  )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>starts30DaysOrLessAfterFirstProcedure</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define fluent function starts30DaysOrLessAfterFirstProcedure(procedure Procedure, encounter Encounter):
  procedure.interval ( ) starts 30 days or less after end of FirstAnesthesiaDuringHospitalization(encounter).interval ( )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>FirstAnesthesiaDuringHospitalization</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// Returns the first anesthesia procedure that starts during the hospitalization encounter.


define function &quot;FirstAnesthesiaDuringHospitalization&quot;(QualifyingEncounter Encounter):
  First(&quot;Anesthesia Procedure List&quot; anesthesia
      where anesthesia.startsDuringHospitalization(QualifyingEncounter)
      sort by start of performed
  )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>HospitalHarm</td>
                            
                            
                                <td>startsDuringHospitalization</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// startsDuringHospitalization
// Given an encounter, returns true if the calling observation effective time or procedure performed starts during that encounter. 
// The interval of the encounter is
// determined by calling the CQCommon function 'HospitalizationWithObservationAndOutpatientSurgeryService'wth the encounter as the argument.
// Usage:   theObservation.startsDuringHospitalization(anEncounter)


define fluent function startsDuringHospitalization(choice Choice&lt;Procedure,Observation&gt;, enc Encounter):
   case
      when choice is Procedure then QICoreCommon.ToInterval ( (choice as Procedure).performed ) starts during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
      when choice is Observation then QICoreCommon.ToInterval ( (choice as Observation).effective ) starts during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
else false
    end</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CQMCommon</td>
                            
                            
                                <td>HospitalizationWithObservationAndOutpatientSurgeryService</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">/*
@description: Hospitalization with Observation and Outpatient Surgery Service returns the total interval from the start of any immediately prior emergency department visit, outpatient surgery visit or observation visit to the discharge of the given encounter.
@deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservationAndOutpatientSurgeryService()` instead.
*/
define function &quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot;(TheEncounter &quot;Encounter&quot; ):
  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
    	),
    	VisitStartWithED: Coalesce(start of EDVisit.period, VisitStart),
    	OutpatientSurgeryVisit: Last([Encounter: &quot;Outpatient Surgery Service&quot;] LastSurgeryOP
			  where LastSurgeryOP.period ends 1 hour or less on or before VisitStartWithED
			  sort by	end of period
    	)
  	return Interval[Coalesce(start of OutpatientSurgeryVisit.period, VisitStartWithED), end of Visit.period]</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>isNotAtProceduralHospitalLocationDuring</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define fluent function isNotAtProceduralHospitalLocationDuring(encounter Encounter, intrvl Interval&lt;DateTime&gt;):
  ( not exists ( encounter.location EncounterLocation
        where EncounterLocation.location.type in &quot;Procedural Hospital Locations&quot;
          and EncounterLocation.period starts during intrvl
    )
  )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>startsDuringAnesthesia</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// and procedure.startsDuringHospitalization(EncounterWithSurgery)


define fluent function startsDuringAnesthesia(procedure Procedure, anesthesia Procedure, encounterWithSurgery Encounter):
  procedure.interval ( ) starts during anesthesia.interval ( )
    and procedure.startsDuringHospitalization ( encounterWithSurgery )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>HospitalHarm</td>
                            
                            
                                <td>isDuringHospitalization</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// isDuringHospitalization
// Given an encounter, returns true if the calling observation effective time or procedure performed occurs during that encounter. 
// The interval of the encounter is
// determined by calling the CQCommon function 'HospitalizationWithObservationAndOutpatientSurgeryService'wth the encounter as the argument.
// Usage:   theProcedure.isDuringHospitalization(anEncounter)


define fluent function isDuringHospitalization(choice Choice&lt;Procedure,Observation&gt;, enc Encounter):
   case
      when choice is Procedure then  
        QICoreCommon.ToInterval ( (choice as Procedure).performed )  during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
      when choice is Observation then  
         QICoreCommon.ToInterval ((choice as Observation).effective ) during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
else false
    end</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>startsAfterAnesthesia</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define fluent function startsAfterAnesthesia(procedure Procedure, anesthesia Procedure, encounterWithSurgery Encounter):
  procedure.interval ( ) starts after anesthesia.interval ( )
    and procedure.startsDuringHospitalization ( encounterWithSurgery )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>CMS1218HHRFFHIR</td>
                            
                            
                                <td>isNotAtProceduralHospitalLocation</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">define fluent function isNotAtProceduralHospitalLocation(encounter Encounter):
  ( not exists ( encounter.location EncounterLocation
        where EncounterLocation.location.type in &quot;Procedural Hospital Locations&quot;
    )
  )</code></pre>
                                </td>
                            
                        </tr>
                    
                        <tr>
                            <th><b>Library Name</b></th>
                            <th><b>Name</b></th>
                        </tr>
                        <tr>
                            
                                <td>HospitalHarm</td>
                            
                            
                                <td>diagnosisPresentOnAdmission</td>
                            
                        </tr>
                        <tr>
                            
                                <td/>
                                <td>
                                    <pre class="highlight language-cql"><code class="language-cql">// diagnosisPresentOnAdmission
// Given an Encounter, this function returns the Present On Admission code of encounter's diagnosis, if present. Returns null otherwiese. 
// Usage: anEncouner.diagnosisPresentOnAdmission()

define fluent function diagnosisPresentOnAdmission(enc Encounter):
  (singleton from (
    enc.diagnosis.extension E where E.url = 'http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-diagnosisPresentOnAdmission'
  )).value as Concept</code></pre>
                                </td>
                            
                        </tr>
                    
                    </table>
                </td>
            </tr>
            
        
    

    </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="103390000"/>
          <display value="Elective (qualifier value)"/>
        </valueCoding>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode">
        <valueCoding>
          <system value="http://snomed.info/sct"/>
          <code value="271280005"/>
          <display value="Removal of endotracheal tube (procedure)"/>
        </valueCoding>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Elective Inpatient Encounter with Age 18 and Older without ED Visit"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//----------------------  Supporting definitions for Measure Population Definitions --------------------------------------------------//

// Note: defines that are not referenced elsewhere are at the bottom of this file.

// Supports:  Initial Population clause 1




define &quot;Elective Inpatient Encounter with Age 18 and Older without ED Visit&quot;:
  [&quot;Encounter&quot;: &quot;Elective Inpatient Encounter&quot;] ElectiveEncounter
    where ElectiveEncounter.period ends during day of &quot;Measurement Period&quot;
      and ElectiveEncounter.priority ~ &quot;Elective (qualifier value)&quot;
      and AgeInYearsAt(date from start of ElectiveEncounter.period) &gt;= 18
      and not exists ( [&quot;Encounter&quot;: &quot;Emergency Department Visit&quot;] EDVisit
          where EDVisit.period ends 1 hour or less before or on start of ElectiveEncounter.period
      )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="0"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Elective Inpatient Encounter with Age and without Obstetrical Condition"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Supports:  Initial Population clause 1


define &quot;Elective Inpatient Encounter with Age and without Obstetrical Condition&quot;:
  &quot;Elective Inpatient Encounter with Age 18 and Older without ED Visit&quot; ElectiveEncounter
    where not exists ElectiveEncounter.diagnosis EncounterDiagnoses
      where EncounterDiagnoses.condition.getCondition ( ).code in &quot;Obstetrical or Pregnancy Related Conditions&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="1"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Elective Inpatient Encounter with OR Procedure within 3 Days"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//----------------------  Initial Population Clauses --------------------------------------------------//

// Initial Population - clause 1  - (referenced throughout the measure definitions)



define &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot;:
  &quot;Elective Inpatient Encounter with Age and without Obstetrical Condition&quot; ElectiveEncounter
    with [&quot;Procedure&quot;: &quot;General and Neuraxial Anesthesia&quot;] SurgeryWithAnesthesia
      such that SurgeryWithAnesthesia.performed.earliest ( ) during ElectiveEncounter.hospitalizationInterval ( )
        and SurgeryWithAnesthesia.performed.earliest ( ) 3 days or less after start of ElectiveEncounter.hospitalizationInterval ( )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="2"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="General Anesthesia and MAC"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Referenced in numerator supporting clauses


define &quot;General Anesthesia and MAC&quot;:
  [&quot;Procedure&quot;: &quot;Anesthesia Requiring Monitored Care&quot;] MAC
    union [&quot;Procedure&quot;: &quot;General and Neuraxial Anesthesia&quot;] GA"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="3"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Anesthesia Procedure List"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//----------------------  End Risk Variable Accessory Functions -----------------------------//

//---------------------- Utility Functions --------------------------------------------------//

// Used exclusively in &quot;FirstProcedure&quot; function, below




define &quot;Anesthesia Procedure List&quot;:
  [&quot;Procedure&quot;: &quot;General and Neuraxial Anesthesia&quot;] AnesthesiaProcedures
    where AnesthesiaProcedures.performed.latest ( ) during day of &quot;Measurement Period&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="4"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Intubation During General Anesthesia and MAC"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Supports:  numerator clause 1


define &quot;Intubation During General Anesthesia and MAC&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Intubation&quot;] ProceduralIntubation,
    &quot;General Anesthesia and MAC&quot; ProcedureWithAnesthesia
    where ProceduralIntubation.startsDuringAnesthesia ( ProcedureWithAnesthesia, EncounterWithSurgery )
    return ProceduralIntubation"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="5"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//fix

//----------------------  Numerator Clauses --------------------------------------------------//

// Numerator - clause 1




define &quot;Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Intubation&quot;] EndotrachealTubeIn
    let IntubationInterval: EndotrachealTubeIn.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(EndotrachealTubeIn).interval ( )
    where EndotrachealTubeIn.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and EndotrachealTubeIn.startsDuringHospitalization ( EncounterWithSurgery )
      and IntubationInterval starts after end of LatestAnesthesiaInterval
      and EncounterWithSurgery.isNotAtProceduralHospitalLocationDuring ( IntubationInterval )
      and not ( &quot;Intubation During General Anesthesia and MAC&quot;.id contains EndotrachealTubeIn.id )
    return EncounterWithSurgery"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="6"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Noninvasive Oxygen Therapy"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Referenced in numerator supporting clauses


define &quot;Noninvasive Oxygen Therapy&quot;:
  [&quot;Procedure&quot;: &quot;Non Invasive Oxygen Therapy by Nasal Cannula or Mask&quot;]
    union [&quot;Observation&quot;: &quot;Non Invasive Oxygen Therapy&quot;]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="7"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Numerator - clause 2


define &quot;Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Mechanical Ventilation&quot;] Ventilation,
    &quot;Noninvasive Oxygen Therapy&quot; OxygenSupport
    let VentilationInterval: Ventilation.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Ventilation).interval ( )
    where Ventilation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )
      and VentilationInterval starts after end of LatestAnesthesiaInterval
      and OxygenSupport.interval ( ) starts during Interval[end of LatestAnesthesiaInterval, start of VentilationInterval]
      and EncounterWithSurgery.isNotAtProceduralHospitalLocationDuring ( VentilationInterval )
    return EncounterWithSurgery"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="8"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Extubation with Preceding Noninvasive Oxygen"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Supports:  numerator clause 3


define &quot;Extubation with Preceding Noninvasive Oxygen&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Removal of endotracheal tube (procedure)&quot;] Extubation,
    &quot;Noninvasive Oxygen Therapy&quot; OxygenSupport
    let LatestAnesthesia: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Extubation)
    where Extubation.startsDuringHospitalization ( EncounterWithSurgery )
      and Extubation.startsAfterAnesthesia ( LatestAnesthesia, EncounterWithSurgery )
      and OxygenSupport.interval ( ) starts during Interval[end of LatestAnesthesia.interval ( ), start of Extubation.interval ( )]
    return Extubation"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="9"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Extubation During General Anesthesia"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Supports:  numerator clause 3


define &quot;Extubation During General Anesthesia&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Removal of endotracheal tube (procedure)&quot;] Extubation,
    &quot;General Anesthesia and MAC&quot; Anesthesia
    where Extubation.startsDuringAnesthesia ( Anesthesia, EncounterWithSurgery )
    return Extubation"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="10"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//fix


// Numerator - clause 3



define &quot;Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Removal of endotracheal tube (procedure)&quot;] Extubation
    let ExtubationInterval: Extubation.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Extubation).interval ( )
    where Extubation.isDuringHospitalization ( EncounterWithSurgery )
      and Extubation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and ExtubationInterval starts more than 48 hours after end of LatestAnesthesiaInterval
      and not ( ( &quot;Extubation with Preceding Noninvasive Oxygen&quot;.id contains Extubation.id )
          and not ( &quot;Extubation During General Anesthesia&quot;.id contains Extubation.id )
      )
      and EncounterWithSurgery.isNotAtProceduralHospitalLocation ( )
    return EncounterWithSurgery"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="11"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Numerator - clause 4


define &quot;Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Procedure&quot;: &quot;Mechanical Ventilation&quot;] Ventilation
    let VentilationInterval: Ventilation.interval ( ),
    LatestAnesthesiaInterval: &quot;LatestGeneralAnesthesiaOrMAC&quot;(Ventilation).interval ( )
    where VentilationInterval starts 48 hours or more after end of LatestAnesthesiaInterval
      and VentilationInterval starts 72 hours or less after end of LatestAnesthesiaInterval
      and Ventilation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
      and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )
      and not ( &quot;Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy&quot;.id contains EncounterWithSurgery.id )
      and EncounterWithSurgery.isNotAtProceduralHospitalLocation ( )
    return EncounterWithSurgery"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="12"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Numerator"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Numerator&quot;:
  &quot;Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure&quot;
    union &quot;Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy&quot;
    union &quot;Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia&quot;
    union &quot;Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="13"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Initial Population"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//----------------------  Measure Population Definitions --------------------------------------------------//


define &quot;Initial Population&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="14"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </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="15"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Degenerative Neurological Disorder"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//----------------------  Denominator Exclusion Clauses------------------------------------------------//

// Denominator Exclusions - clause 1



define &quot;Encounter with Degenerative Neurological Disorder&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where exists ( EncounterWithSurgery.diagnosis EncounterDiagnosis
        where EncounterDiagnosis.condition.getCondition ( ).code in &quot;Degenerative Neurological Disorder&quot;
    )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="16"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with High Risk to Airway Head Neck and Thoracic Surgery"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Denominator Exclusions - clause 2


define &quot;Encounter with High Risk to Airway Head Neck and Thoracic Surgery&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    with [&quot;Procedure&quot;: &quot;Head, Neck, and Thoracic Surgeries with High Risk Airway Compromise&quot;] HeadNeckProcedures
      such that HeadNeckProcedures.startsDuringHospitalization ( EncounterWithSurgery )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="17"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Denominator Exclusions - clause 3


define &quot;Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    with [&quot;Procedure&quot;: &quot;Mechanical Ventilation&quot;] Ventilation
      such that Ventilation.interval ( ) starts more than 1 hour before start of FirstAnesthesiaDuringHospitalization(EncounterWithSurgery).interval ( )
        and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="18"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Encounter with Neuromuscular Disorder"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Denominator Exclusions - clause 4


define &quot;Encounter with Neuromuscular Disorder&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where exists ( EncounterWithSurgery.diagnosis EncounterDiagnosis
        where EncounterDiagnosis.condition.getCondition ( ).code in &quot;Neuromuscular Disorder&quot;
    )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="19"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Denominator Exclusions - clause 5


define &quot;Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure&quot;:
  from
    &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery,
    [&quot;Observation&quot;: &quot;Carbon Dioxide Partial Pressure in Arterial Blood&quot;] CarbonDioxide,
    [&quot;Observation&quot;: &quot;Arterial Blood pH&quot;] BloodpH
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery),
    FirstProcedureTime: FirstProcedure.interval ( )
    where CarbonDioxide.interval ( ) starts 48 hours or less before start of FirstProcedureTime
      and CarbonDioxide.value as Quantity &gt; 50 'mm[Hg]'
      and BloodpH.interval ( ) starts 48 hours or less before start of FirstProcedureTime
      and BloodpH.value as Quantity &lt; 7.30 '[pH]'
      and FirstProcedure is not null
    return EncounterWithSurgery"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="20"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//fix

// Denominator Exclusions - clause 6



define &quot;Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
    with [&quot;Observation&quot;: &quot;Oxygen Partial Pressure in Arterial Blood&quot;] Oxygen
      such that Oxygen.interval ( ) starts 48 hours or less before start of FirstProcedure.interval ( )
        and Oxygen.value as Quantity &lt; 50 'mm[Hg]'
        and FirstProcedure is not null
    return EncounterWithSurgery"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="21"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Principal Diagnosis of Acute Respiratory Failure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Denominator Exclusions - clause 7


define &quot;Encounter with Principal Diagnosis of Acute Respiratory Failure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where exists ( EncounterWithSurgery.diagnosis Diagnosis
        where Diagnosis.condition.getCondition ( ).code in &quot;Acute Respiratory Failure&quot;
          and Diagnosis.rank = 1
    )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="22"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Diagnosis of Acute Respiratory Failure Present on Admission"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Denominator Exclusions - clause 8


define &quot;Encounter with Diagnosis of Acute Respiratory Failure Present on Admission&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where EncounterWithSurgery.diagnosisPresentOnAdmission ( ) in &quot;Present on Admission or Clinically Undetermined&quot;
      and exists ( EncounterWithSurgery.diagnosis Diagnosis
          where Diagnosis.condition.getCondition ( ).code in &quot;Acute Respiratory Failure&quot;
      )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="23"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Tracheostomy Present on Admission"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="//fix

// Denominator Exclusions - clause 9



define &quot;Encounter with Tracheostomy Present on Admission&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    where EncounterWithSurgery.diagnosisPresentOnAdmission ( ) in &quot;Present on Admission or Clinically Undetermined&quot;
      and exists ( EncounterWithSurgery.diagnosis Dx
          where Dx.condition.getCondition ( ).code in &quot;Tracheostomy Diagnoses&quot;
      )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="24"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Tracheostomy Before Day of First OR Procedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Supports:  denominator exclusions clause 10


define &quot;Encounter with Tracheostomy Before Day of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
    with [&quot;Procedure&quot;: &quot;Tracheostomy Procedures&quot;] TracheostomySurgery
      such that TracheostomySurgery.startsDuringHospitalization ( EncounterWithSurgery )
        and TracheostomySurgery.interval ( ) starts before day of FirstProcedure.interval ( )
        and FirstProcedure is not null"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="25"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Tracheostomy Same Day of First OR Procedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Supports:  denominator exclusions clause 10


define &quot;Encounter with Tracheostomy Same Day of First OR Procedure&quot;:
  &quot;Elective Inpatient Encounter with OR Procedure within 3 Days&quot; EncounterWithSurgery
    let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
    with [&quot;Procedure&quot;: &quot;Tracheostomy Procedures&quot;] TracheostomySurgery
      such that TracheostomySurgery.startsDuringHospitalization ( EncounterWithSurgery )
        and TracheostomySurgery.interval ( ) starts during day of FirstProcedure.interval ( )
        and FirstProcedure is not null"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="26"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString
                       value="Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Denominator Exclusions - clause 10


define &quot;Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure&quot;:
  &quot;Encounter with Tracheostomy Before Day of First OR Procedure&quot;
    union &quot;Encounter with Tracheostomy Same Day of First OR Procedure&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="27"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="Denominator Exclusions"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define &quot;Denominator Exclusions&quot;:
  &quot;Encounter with Degenerative Neurological Disorder&quot;
    union &quot;Encounter with High Risk to Airway Head Neck and Thoracic Surgery&quot;
    union &quot;Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with Neuromuscular Disorder&quot;
    union &quot;Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure&quot;
    union &quot;Encounter with Principal Diagnosis of Acute Respiratory Failure&quot;
    union &quot;Encounter with Diagnosis of Acute Respiratory Failure Present on Admission&quot;
    union &quot;Encounter with Tracheostomy Present on Admission&quot;
    union &quot;Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure&quot;"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="28"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-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="29"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CQMCommon"/>
        </extension>
        <extension url="name">
          <valueString value="getCondition"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Returns the Condition resource for the given reference
*/
define fluent function getCondition(reference Reference):
  singleton from ([Condition] C where C.id = reference.reference.getId())"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="30"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="QICoreCommon"/>
        </extension>
        <extension url="name">
          <valueString value="getId"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
@comment: This function can be used to determine the logical id of a given resource. It can be used in
a single-server environment to trace references. However, this function does not attempt to resolve
or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
*/
define fluent function getId(uri String):
  Last(Split(uri, '/'))"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="31"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="hospitalizationInterval"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define fluent function hospitalizationInterval(enc Encounter):
  enc.hospitalizationWithObservationAndOutpatientSurgeryService ( )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="32"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CQMCommon"/>
        </extension>
        <extension url="name">
          <valueString
                       value="hospitalizationWithObservationAndOutpatientSurgeryService"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Hospitalization with Observation and Outpatient Surgery Service returns the total interval from the start of any immediately prior emergency department visit, outpatient surgery visit or observation visit to the discharge of the given encounter.
*/
define fluent function hospitalizationWithObservationAndOutpatientSurgeryService(TheEncounter &quot;Encounter&quot; ):
  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
    	),
    	VisitStartWithED: Coalesce(start of EDVisit.period, VisitStart),
    	OutpatientSurgeryVisit: Last([Encounter: &quot;Outpatient Surgery Service&quot;] LastSurgeryOP
			  where LastSurgeryOP.period ends 1 hour or less on or before VisitStartWithED
			  sort by	end of period
    	)
  	return Interval[Coalesce(start of OutpatientSurgeryVisit.period, VisitStartWithED), end of Visit.period]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="33"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="HospitalHarm"/>
        </extension>
        <extension url="name">
          <valueString value="interval"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// interval
// Given an encounter, procedure or observation resource, returns a normalized Interval object, calculated using QICoreCommon.ToInterval for the given type of resource. 
// Usage:   theEncounter.interval()


define fluent function interval(choice Choice&lt;Procedure,Observation,Encounter&gt;):
   case
      when choice is Procedure   then QICoreCommon.ToInterval ( (choice as Procedure).performed ) 
      when choice is Observation then QICoreCommon.ToInterval ( (choice as Observation).effective ) 
      when choice is Encounter   then QICoreCommon.ToInterval ( (choice as Encounter).period ) 
  else null as Interval&lt;DateTime&gt;
    end"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="34"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-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
@deprecated: This function is deprecated. Use the fluent function `toInterval()` instead
*/
define 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="35"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="LatestGeneralAnesthesiaOrMAC"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define function &quot;LatestGeneralAnesthesiaOrMAC&quot;(event Procedure):
  Last(&quot;General Anesthesia and MAC&quot; ProcedureList
      where ProcedureList.interval() ends before start of event.interval()
      sort by start of QICoreCommon.ToInterval(performed)
  )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="36"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="starts30DaysOrLessAfterFirstProcedure"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define fluent function starts30DaysOrLessAfterFirstProcedure(procedure Procedure, encounter Encounter):
  procedure.interval ( ) starts 30 days or less after end of FirstAnesthesiaDuringHospitalization(encounter).interval ( )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="37"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="FirstAnesthesiaDuringHospitalization"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// Returns the first anesthesia procedure that starts during the hospitalization encounter.


define function &quot;FirstAnesthesiaDuringHospitalization&quot;(QualifyingEncounter Encounter):
  First(&quot;Anesthesia Procedure List&quot; anesthesia
      where anesthesia.startsDuringHospitalization(QualifyingEncounter)
      sort by start of performed
  )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="38"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="HospitalHarm"/>
        </extension>
        <extension url="name">
          <valueString value="startsDuringHospitalization"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// startsDuringHospitalization
// Given an encounter, returns true if the calling observation effective time or procedure performed starts during that encounter. 
// The interval of the encounter is
// determined by calling the CQCommon function 'HospitalizationWithObservationAndOutpatientSurgeryService'wth the encounter as the argument.
// Usage:   theObservation.startsDuringHospitalization(anEncounter)


define fluent function startsDuringHospitalization(choice Choice&lt;Procedure,Observation&gt;, enc Encounter):
   case
      when choice is Procedure then QICoreCommon.ToInterval ( (choice as Procedure).performed ) starts during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
      when choice is Observation then QICoreCommon.ToInterval ( (choice as Observation).effective ) starts during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
else false
    end"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="39"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CQMCommon"/>
        </extension>
        <extension url="name">
          <valueString
                       value="HospitalizationWithObservationAndOutpatientSurgeryService"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="/*
@description: Hospitalization with Observation and Outpatient Surgery Service returns the total interval from the start of any immediately prior emergency department visit, outpatient surgery visit or observation visit to the discharge of the given encounter.
@deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservationAndOutpatientSurgeryService()` instead.
*/
define function &quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot;(TheEncounter &quot;Encounter&quot; ):
  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
    	),
    	VisitStartWithED: Coalesce(start of EDVisit.period, VisitStart),
    	OutpatientSurgeryVisit: Last([Encounter: &quot;Outpatient Surgery Service&quot;] LastSurgeryOP
			  where LastSurgeryOP.period ends 1 hour or less on or before VisitStartWithED
			  sort by	end of period
    	)
  	return Interval[Coalesce(start of OutpatientSurgeryVisit.period, VisitStartWithED), end of Visit.period]"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="40"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="isNotAtProceduralHospitalLocationDuring"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define fluent function isNotAtProceduralHospitalLocationDuring(encounter Encounter, intrvl Interval&lt;DateTime&gt;):
  ( not exists ( encounter.location EncounterLocation
        where EncounterLocation.location.type in &quot;Procedural Hospital Locations&quot;
          and EncounterLocation.period starts during intrvl
    )
  )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="41"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="startsDuringAnesthesia"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// and procedure.startsDuringHospitalization(EncounterWithSurgery)


define fluent function startsDuringAnesthesia(procedure Procedure, anesthesia Procedure, encounterWithSurgery Encounter):
  procedure.interval ( ) starts during anesthesia.interval ( )
    and procedure.startsDuringHospitalization ( encounterWithSurgery )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="42"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="HospitalHarm"/>
        </extension>
        <extension url="name">
          <valueString value="isDuringHospitalization"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// isDuringHospitalization
// Given an encounter, returns true if the calling observation effective time or procedure performed occurs during that encounter. 
// The interval of the encounter is
// determined by calling the CQCommon function 'HospitalizationWithObservationAndOutpatientSurgeryService'wth the encounter as the argument.
// Usage:   theProcedure.isDuringHospitalization(anEncounter)


define fluent function isDuringHospitalization(choice Choice&lt;Procedure,Observation&gt;, enc Encounter):
   case
      when choice is Procedure then  
        QICoreCommon.ToInterval ( (choice as Procedure).performed )  during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
      when choice is Observation then  
         QICoreCommon.ToInterval ((choice as Observation).effective ) during CQMCommon.&quot;HospitalizationWithObservationAndOutpatientSurgeryService&quot; ( enc )
else false
    end"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="43"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="startsAfterAnesthesia"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define fluent function startsAfterAnesthesia(procedure Procedure, anesthesia Procedure, encounterWithSurgery Encounter):
  procedure.interval ( ) starts after anesthesia.interval ( )
    and procedure.startsDuringHospitalization ( encounterWithSurgery )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="44"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="CMS1218HHRFFHIR"/>
        </extension>
        <extension url="name">
          <valueString value="isNotAtProceduralHospitalLocation"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="define fluent function isNotAtProceduralHospitalLocation(encounter Encounter):
  ( not exists ( encounter.location EncounterLocation
        where EncounterLocation.location.type in &quot;Procedural Hospital Locations&quot;
    )
  )"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="45"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition">
        <extension url="libraryName">
          <valueString value="HospitalHarm"/>
        </extension>
        <extension url="name">
          <valueString value="diagnosisPresentOnAdmission"/>
        </extension>
        <extension url="statement">
          <valueString
                       value="// diagnosisPresentOnAdmission
// Given an Encounter, this function returns the Present On Admission code of encounter's diagnosis, if present. Returns null otherwiese. 
// Usage: anEncouner.diagnosisPresentOnAdmission()

define fluent function diagnosisPresentOnAdmission(enc Encounter):
  (singleton from (
    enc.diagnosis.extension E where E.url = 'http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-diagnosisPresentOnAdmission'
  )).value as Concept"/>
        </extension>
        <extension url="displaySequence">
          <valueInteger value="46"/>
        </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 FHIRHelpers"/>
        <resource value="Library/FHIRHelpers|4.4.000"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library CQMCommon"/>
        <resource value="Library/CQMCommon|2.2.000"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library QICoreCommon"/>
        <resource value="Library/QICoreCommon|2.1.000"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library HospitalHarm"/>
        <resource value="Library/HospitalHarm|1.1.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 Elective Inpatient Encounter"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.85"/>
      </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 Obstetrical or Pregnancy Related Conditions"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.263"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set General and Neuraxial Anesthesia"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.208"/>
      </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 Outpatient Surgery Service"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Intubation"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.179"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Anesthesia Requiring Monitored Care"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.255"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Procedural Hospital Locations"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.216"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Mechanical Ventilation"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.107"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display
                 value="Value set Non Invasive Oxygen Therapy by Nasal Cannula or Mask"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.209"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Non Invasive Oxygen Therapy"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.213"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Degenerative Neurological Disorder"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.241"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display
                 value="Value set Head, Neck, and Thoracic Surgeries with High Risk Airway Compromise"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.251"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Neuromuscular Disorder"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.239"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display
                 value="Value set Carbon Dioxide Partial Pressure in Arterial Blood"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.95"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Arterial Blood pH"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.96"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Oxygen Partial Pressure in Arterial Blood"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.94"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Acute Respiratory Failure"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.88"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display
                 value="Value set Present on Admission or Clinically Undetermined"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.197"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Tracheostomy Diagnoses"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.89"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Value set Tracheostomy Procedures"/>
        <resource
                  value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.181"/>
      </relatedArtifact>
      <parameter>
        <name value="Measurement Period"/>
        <use value="in"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Period"/>
      </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="Initial Population"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <parameter>
        <name value="Denominator Exclusions"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Resource"/>
      </parameter>
      <dataRequirement>
        <type value="Patient"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient"/>
      </dataRequirement>
      <dataRequirement>
        <type value="Encounter"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"/>
        <mustSupport value="type"/>
        <mustSupport value="period"/>
        <mustSupport value="location"/>
        <mustSupport value="location.type"/>
        <mustSupport value="location.type.value"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <mustSupport value="diagnosis"/>
        <mustSupport value="extension"/>
        <mustSupport value="url"/>
        <mustSupport value="url.value"/>
        <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="priority"/>
        <mustSupport value="location"/>
        <mustSupport value="location.type"/>
        <mustSupport value="location.type.value"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <mustSupport value="diagnosis"/>
        <mustSupport value="extension"/>
        <mustSupport value="url"/>
        <mustSupport value="url.value"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.85"/>
        </codeFilter>
        <codeFilter>
          <path value="priority"/>
        </codeFilter>
        <dateFilter>
          <path value="period"/>
          <valuePeriod>
            <extension
                       url="http://hl7.org/fhir/StructureDefinition/cqf-expression">
              <valueExpression>
                <language value="text/cql-identifier"/>
                <expression value="Measurement Period"/>
              </valueExpression>
            </extension>
          </valuePeriod>
        </dateFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Encounter"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"/>
        <mustSupport value="type"/>
        <mustSupport value="period"/>
        <mustSupport value="priority"/>
        <mustSupport value="diagnosis"/>
        <mustSupport value="location"/>
        <mustSupport value="location.type"/>
        <mustSupport value="location.type.value"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <mustSupport value="extension"/>
        <mustSupport value="url"/>
        <mustSupport value="url.value"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.85"/>
        </codeFilter>
        <codeFilter>
          <path value="priority"/>
        </codeFilter>
        <codeFilter>
          <path value="diagnosis.condition.code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.263"/>
        </codeFilter>
        <dateFilter>
          <path value="period"/>
          <valuePeriod>
            <extension
                       url="http://hl7.org/fhir/StructureDefinition/cqf-expression">
              <valueExpression>
                <language value="text/cql-identifier"/>
                <expression value="Measurement Period"/>
              </valueExpression>
            </extension>
          </valuePeriod>
        </dateFilter>
      </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="location"/>
        <mustSupport value="location.type"/>
        <mustSupport value="location.type.value"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <mustSupport value="diagnosis"/>
        <mustSupport value="extension"/>
        <mustSupport value="url"/>
        <mustSupport value="url.value"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"/>
        </codeFilter>
        <codeFilter>
          <path value="status.value"/>
          <code>
            <code value="finished"/>
          </code>
        </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="location"/>
        <mustSupport value="location.type"/>
        <mustSupport value="location.type.value"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <mustSupport value="diagnosis"/>
        <mustSupport value="extension"/>
        <mustSupport value="url"/>
        <mustSupport value="url.value"/>
        <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>
        <codeFilter>
          <path value="status.value"/>
          <code>
            <code value="finished"/>
          </code>
        </codeFilter>
        <dateFilter>
          <path value="period"/>
          <valuePeriod>
            <extension url="http://hl7.org/fhir/uv/crmi-analysisException">
              <valueString
                           value="Error attempting to determine filter value: toFhirValue not implemented for Subtract"/>
            </extension>
          </valuePeriod>
        </dateFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Encounter"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"/>
        <mustSupport value="type"/>
        <mustSupport value="period"/>
        <mustSupport value="location"/>
        <mustSupport value="location.type"/>
        <mustSupport value="location.type.value"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <mustSupport value="diagnosis"/>
        <mustSupport value="extension"/>
        <mustSupport value="url"/>
        <mustSupport value="url.value"/>
        <codeFilter>
          <path value="type"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38"/>
        </codeFilter>
        <dateFilter>
          <path value="period"/>
          <valuePeriod>
            <extension url="http://hl7.org/fhir/uv/crmi-analysisException">
              <valueString
                           value="Error attempting to determine filter value: toFhirValue not implemented for Subtract"/>
            </extension>
          </valuePeriod>
        </dateFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Condition"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <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.255"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <mustSupport value="performed"/>
        <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.208"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <mustSupport value="performed"/>
        <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.208"/>
        </codeFilter>
        <dateFilter>
          <path value="performed"/>
          <valuePeriod>
            <extension
                       url="http://hl7.org/fhir/StructureDefinition/cqf-expression">
              <valueExpression>
                <language value="text/cql-identifier"/>
                <expression value="Measurement Period"/>
              </valueExpression>
            </extension>
          </valuePeriod>
        </dateFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <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.179"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <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.209"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <mustSupport value="id"/>
        <mustSupport value="id.value"/>
        <codeFilter>
          <path value="code"/>
          <code>
            <system value="http://snomed.info/sct"/>
            <code value="271280005"/>
            <display value="Removal of endotracheal tube (procedure)"/>
          </code>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <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.251"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <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.107"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Procedure"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"/>
        <mustSupport value="code"/>
        <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.181"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Observation"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation"/>
        <mustSupport value="code"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.213"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Observation"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation"/>
        <mustSupport value="code"/>
        <mustSupport value="value"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.95"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Observation"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation"/>
        <mustSupport value="code"/>
        <mustSupport value="value"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.96"/>
        </codeFilter>
      </dataRequirement>
      <dataRequirement>
        <type value="Observation"/>
        <profile
                 value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation"/>
        <mustSupport value="code"/>
        <mustSupport value="value"/>
        <codeFilter>
          <path value="code"/>
          <valueSet
                    value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.94"/>
        </codeFilter>
      </dataRequirement>
    </Library>
  </contained>
  <extension
             url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-softwaresystem">
    <valueReference>
      <reference value="Device/cqf-tooling"/>
    </valueReference>
  </extension>
  <extension
             url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-effectiveDataRequirements" id="effective-data-requirements">
    <valueReference>
      <reference value="#effective-data-requirements"/>
    </valueReference>
  </extension>
  <url value="https://madie.cms.gov/Measure/CMS1218HHRFFHIR"/>
  <identifier>
    <use value="usual"/>
    <type>
      <coding>
        <system
                value="http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type"/>
        <code value="short-name"/>
        <display value="Short Name"/>
      </coding>
    </type>
    <system value="https://madie.cms.gov/measure/shortName"/>
    <value value="CMS1218FHIR"/>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type"/>
        <code value="version-independent"/>
        <display value="Version Independent"/>
      </coding>
    </type>
    <system value="urn:ietf:rfc:3986"/>
    <value value="urn:uuid:b6857e46-6412-432d-abc8-0508efc0d2d7"/>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type"/>
        <code value="version-specific"/>
        <display value="Version Specific"/>
      </coding>
    </type>
    <system value="urn:ietf:rfc:3986"/>
    <value value="urn:uuid:447f5c0f-f39c-4a27-a0bc-d5ae918bef10"/>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type"/>
        <code value="endorser"/>
        <display value="Endorser"/>
      </coding>
    </type>
    <system value="https://madie.cms.gov/measure/cbeId"/>
    <value value="4130e"/>
    <assigner>
      <display value="CMS Consensus Based Entity"/>
    </assigner>
  </identifier>
  <identifier>
    <use value="official"/>
    <type>
      <coding>
        <system
                value="http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type"/>
        <code value="publisher"/>
        <display value="Publisher"/>
      </coding>
    </type>
    <system value="https://madie.cms.gov/measure/cmsId"/>
    <value value="1218FHIR"/>
    <assigner>
      <display value="CMS"/>
    </assigner>
  </identifier>
  <version value="0.0.003"/>
  <name value="CMS1218HHRFFHIR"/>
  <title value="Hospital Harm - Postoperative Respiratory FailureFHIR"/>
  <status value="active"/>
  <experimental value="false"/>
  <date value="2026-03-13T01:50:40+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 elective inpatient hospitalizations for patients aged 18 years and older without an obstetrical condition who have a procedure resulting in postoperative respiratory failure (PRF)"/>
  <purpose value="UNKNOWN"/>
  <usage
         value="PRF is evaluated using mechanical ventilation (MV) documentation or intubation and extubation documentation to allow for hospital documentation variances. Therefore, if MV documentation is not available, intubation and extubation can serve as a proxy for determining if MV occurred and its duration. To determine that an unplanned initiation of MV occurred, the logic looks for evidence of a non-invasive oxygen therapy assessment such as oxygen via 'nasal canula' or 'breathing room air' prior to the MV occurrence to verify that MV was newly initiated. Additionally, facility location codes are used to determine if MV was initiated outside of a procedural area (e.g., medical floor). Conversely, to determine MV duration, the logic looks for evidence that a non-invasive oxygen therapy assessment or another operating room procedure does not exist prior to the MV occurrence to verify that MV was continued without interruption from a procedural area. 
	
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: CMS1218v2. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (https://hl7.org/fhir/us/qicore/STU4.1.1/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. Mathematica 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>
  <library value="https://madie.cms.gov/Library/CMS1218HHRFFHIR"/>
  <disclaimer
              value="This performance measure is not a clinical guideline, does not establish a standard of medical care, and has not been tested for all potential applications. 

THE MEASURES AND SPECIFICATIONS ARE PROVIDED “AS IS” 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="Postoperative respiratory failure (PRF), defined as unplanned endotracheal reintubation, prolonged inability to wean from mechanical ventilation, or inadequate oxygenation and/or ventilation, is the most common serious postoperative pulmonary complication, with an incidence of up to 7.5% (the incidence of any postoperative pulmonary complication ranges from 10-40%) (Arozullah et al., 2000; Canet et al., 2015; Gupta et al., 2011; Kor et al., 2014). This measure addresses the prevalence of PRF and the variance between hospitals in the incidence of PRF. PRF is a serious complication that can increase the risk of morbidity and mortality, with in-hospital mortality resulting from PRF estimated at 25% to 40% (Arozullah et al., 2000; Canet &amp; Gallart, 2014). Surgical procedures complicated by PRF have 3.74 times higher adjusted odds of death than those not complicated by respiratory failure, 1.47 times higher odds of 90-day readmission, and 1.86 times higher odds of an outpatient visit with one of 44 postoperative conditions (e.g., bacterial infection, fluid and electrolyte disorder, abdominal hernia) within 90 days of hospital discharge (Miller et al., 2001; Romano et al, 2009). PRF is additionally associated with prolonged mechanical ventilation and the need for rehabilitation or skilled nursing facility placement upon discharge (Thompson &amp; Lisco, 2018).

The incidence of PRF varies by hospital, with higher reported rates of PRF in nonteaching hospitals than teaching hospitals (Rahman et al., 2013). Additionally, one study found that the odds of developing PRF increased by 6% for each level increase in hospital size from small to large (Rahman et al., 2013). This suggests that there remains room for improvement in hospitals reporting higher rates of PRF.

The most widely used current measures of PRF are based on either claims data (CMS Patient Safety Indicator (PSI) 11) or proprietary registry data (National Surgical Quality Improvement Program (NSQIP) of the American College of Surgeons). The eCQM is closely modeled after the NSQIP measure of PRF, which has been widely adopted across American hospitals, and is intended to complement and eventually supplant CMS PSI 11."/>
  <clinicalRecommendationStatement
                                   value="Recent studies and current clinical practice guidelines for PRF have identified enhanced recovery pathways, prophylactic mucolytics, postoperative continuous positive airway pressure ventilation, lung protective intraoperative ventilation, prophylactic respiratory physiotherapy, epidural analgesia, and goal directed hemodynamic therapy as evidence-based interventions to reduce the incidence of PRF. Yet, progress in reducing the incidence of PRF has been stymied by lack of consensus regarding the definition of PRF, which patients are most at-risk, which risk factors are potentially modifiable, and which patients are more likely to benefit from targeted interventions of a health care system’s limited resources. This measure would address this gap in data.

Relevant clinical guidelines for preventing postoperative respiratory failure can be found in the following:

- Mohanty, et al. Optimal Perioperative Management of the Geriatric Patient: Best Practices Guideline from ACS NSQIP/AGS, 2016
- Piraino, et al. AARC Clinical Practice Guideline: Management of Adult Patients with Oxygen in the Acute Care Setting, 2022"/>
  <guidance
            value="PRF is evaluated using mechanical ventilation (MV) documentation or intubation and extubation documentation to allow for hospital documentation variances. Therefore, if MV documentation is not available, intubation and extubation can serve as a proxy for determining if MV occurred and its duration. To determine that an unplanned initiation of MV occurred, the logic looks for evidence of a non-invasive oxygen therapy assessment such as oxygen via 'nasal canula' or 'breathing room air' prior to the MV occurrence to verify that MV was newly initiated. Additionally, facility location codes are used to determine if MV was initiated outside of a procedural area (e.g., medical floor). Conversely, to determine MV duration, the logic looks for evidence that a non-invasive oxygen therapy assessment or another operating room procedure does not exist prior to the MV occurrence to verify that MV was continued without interruption from a procedural area. 
	
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: CMS1218v2. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (https://hl7.org/fhir/us/qicore/STU4.1.1/qdm-to-qicore.html)."/>
  <group id="67520e47670f1c0879cef598">
    <extension
               url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
      <valueCodeableConcept>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-scoring"/>
          <code value="proportion"/>
          <display value="Proportion"/>
        </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="increase"/>
        </coding>
      </valueCodeableConcept>
    </extension>
    <population id="EBD61368-EDA1-4A7F-B134-48A501C47028">
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="initial-population"/>
          <display value="Initial Population"/>
        </coding>
      </code>
      <description
                   value="Elective inpatient hospitalizations with no preceding emergency department visit that end during the measurement period for patients aged 18 and older without an obstetrical condition and at least one surgical procedure was performed within the first 3 days of the encounter"/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Initial Population"/>
      </criteria>
    </population>
    <population id="A15EB430-6645-42AC-8FCE-0FF0BF0B4749">
      <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="1389AFF6-741D-47CB-BED0-62D858980EE4">
      <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 diagnosis for a degenerative neurological disorder

With any selected head, neck, and thoracic surgery involving significant risk of airway compromise or requiring airway protection

Who have mechanical ventilation that starts more than one hour prior to the start of the first operating room (OR) procedure

With a diagnosis for a neuromuscular disorder

With arterial partial pressure of carbon dioxide (PaCO2)&gt;50 mmHg combined with an arterial pH&lt;7.30 within 48 hours or less prior to the start of the first OR procedure

With arterial partial pressure of oxygen (PaO2)&lt;50 mmHg within 48 hours or less prior to the start of the first OR procedure

With a principal diagnosis for acute respiratory failure

With a diagnosis for acute respiratory failure present on admission

With any diagnosis present on admission for the existence of a tracheostomy

Where a tracheostomy is performed before or on the same day as the first OR procedure"/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Denominator Exclusions"/>
      </criteria>
    </population>
    <population id="F1D273B8-1513-4C6E-B65F-22FD939174E6">
      <code>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-population"/>
          <code value="numerator"/>
          <display value="Numerator"/>
        </coding>
      </code>
      <description
                   value="Elective inpatient hospitalizations for patients with postoperative respiratory failure as evidenced by any of the following:

Criterion A: Mechanical ventilation (MV) initiated within 30 days after first OR procedure, as evidenced by:

A.1. Intubation that occurs outside of a procedural area and within 30 days after the end of the first OR procedure of the encounter.

or

A.2. MV that occurs outside of a procedural area within 30 days after the end of the first OR procedure of the encounter and is preceded by a period of non-invasive oxygen therapy between the end of the OR procedure and the MV occurrence, and without a subsequent OR procedure between the non-invasive oxygen therapy and the MV occurrence.

or

Criterion B: MV with a duration of more than 48 hours after the first OR procedure, as evidenced by:

B.1. Extubation that occurs outside of a procedural area more than 48 hours after the end of an OR procedure and within 30 days after the end of the first OR procedure, and is not preceded by a period of non-invasive oxygen therapy or a subsequent OR procedure between the end of the OR procedure and the extubation occurrence.

or

B.2 Mechanical ventilation that occurs between 48 and 72 hours after the end of an OR procedure and within 30 days after the end of the first OR procedure, and is not preceded by a non-invasive oxygen therapy or a subsequent OR procedure between the end of the OR procedure and the MV occurrence. "/>
      <criteria>
        <language value="text/cql-identifier"/>
        <expression value="Numerator"/>
      </criteria>
    </population>
  </group>
</Measure>