<Bundle xmlns="http://hl7.org/fhir">
   <type value="transaction"></type>
   <entry>
      <fullUrl value="https://madie.cms.gov/Measure/CMS986FHIRMalnutritionScore"></fullUrl>
      <resource>
         <Measure xmlns="http://hl7.org/fhir">
            <id value="CMS986FHIRMalnutritionScore"></id>
            <meta>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablemeasure"></profile>
               <profile value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm"></profile>
               <profile value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/publishable-measure-cqfm"></profile>
               <profile value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/executable-measure-cqfm"></profile>
               <profile value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cql-measure-cqfm"></profile>
               <profile value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/elm-measure-cqfm"></profile>
               <profile value="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cv-measure-cqfm"></profile>
            </meta>
            <text>
               <status value="extensions"></status>
               <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
                  <table class="narrative-table"> 
                     <tbody> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Metadata</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Title</th> 
                           <td class="content-container">Malnutrition Care ScoreFHIR</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Version</th> 
                           <td class="content-container">1.0.000</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Short Name</th> 
                           <td class="content-container">CMS986FHIR</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">GUID (Version Independent)</th> 
                           <td class="content-container">urn:uuid:eed68e80-b466-4369-be87-166ada45f7c5</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">GUID (Version Specific)</th> 
                           <td class="content-container">urn:uuid:c3828a9c-88b0-4a19-8b78-bb07f56ed929</td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">CMS Identifier</th> 
                           <td class="content-container">986FHIR</td> 
                        </tr>   
                        <tr> 
                           <th scope="row" class="row-header">CMS Consensus Based Entity Identifier</th> 
                           <td class="content-container">3592e</td> 
                        </tr>   
                        <tr> 
                           <th scope="row" class="row-header">Effective Period</th> 
                           <td class="content-container">2026-01-01 through 2026-12-31</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Steward (Publisher)</th> 
                           <td class="content-container">Academy of Nutrition and Dietetics</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Developer</th> 
                           <td class="content-container">Academy of Nutrition and Dietetics</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Description</th> 
                           <td class="content-container">This measure assesses the percentage of eligible encounters of adults aged 18 years and older at the start of the eligible encounter during the measurement period, with a length of stay equal to or greater than 24 hours, who received optimal malnutrition care where care performed was appropriate to the patient's level of malnutrition risk and severity. Malnutrition care best practices recommend that for each eligible encounter, adult inpatients are (1) screened for malnutrition risk or for a dietitian referral order to be placed, (2) assessed by a registered dietitian (RD) or registered dietitian nutritionist (RDN) to confirm findings of malnutrition risk, and if identified with a "moderate" or "severe" malnutrition status in the current performed nutrition assessment, (3) receive a "moderate" or "severe" malnutrition diagnosis by a physician or eligible clinician as defined by the Centers for Medicare &amp; Medicaid Services (CMS), and (4) have a current nutrition care plan performed by an RD/RDN.</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Purpose</th> 
                           <td class="content-container">Percentage of hospitalizations where a patient 18 years of age or older, admitted for 24-hours or more, received optimal malnutrition care</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Copyright</th> 
                           <td class="content-container">Copyright (C) Academy of Nutrition and Dietetics 2025 Limited proprietary coding is contained in the measure specifications for convenience. Users of the proprietary code sets should obtain all necessary licenses from the owners of these code sets. LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc. ICD-10 copyright 2024 World Health Organization. This material contains SNOMED Clinical Terms (R) (SNOMED CT [R]) copyright 2004-2024. International Health Terminology Standards Development Organisation. All Rights Reserved.</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Disclaimer</th> 
                           <td class="content-container">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 MEASURE AND SPECIFICATIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. Due to technical limitations, copyright is indicated by (C) or [C], registered trademarks are indicated by (R) or [R], and unregistered trademarks are indicated by (TM) or [TM].</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Rationale</th> 
                           <td class="content-container">
                              <p>Malnutrition has been documented in approximately one-third of patients in developed countries upon admission to the hospital, and, if left untreated, can significantly impact important clinical outcomes (Mogensen et al., 2019). Adult patients with malnutrition have a significantly longer hospital length of stay (LOS) and a significantly higher likelihood of 30-day readmission when compared to their well-nourished counterparts (Lengfelder et al., 2022). Furthermore, hospitalized adults with malnutrition have an increased likelihood of all-cause mortality within 2 years of diagnosis (Trollebo et al., 2024) and an increase in in-hospital death when compared to patients without a diagnosis of malnutrition (Compher et al., 2024). These consequences demonstrate the importance of addressing malnutrition in hospitalized patients to improve outcomes.</p> 
                              <p>The components of this measure are supported by clinical guidance which recommend 
                                 <strong>(1) malnutrition screening</strong> for patients admitted into the acute inpatient care setting; 
                                 <strong>(2) nutrition assessment </strong>for patients identified at risk for malnutrition or with a dietitian referral order to form the basis for appropriate nutrition interventions; 
                                 <strong>(3) appropriate recognition, diagnosis, and documentation</strong> of the nutrition status of a patient in order to 
                                 <strong>(4) address their condition with an appropriate plan of care</strong> and communicate patient needs to other care providers (Swan et al., 2019).
                              </p> 
                              <p>The process for risk identification, assessment, diagnosis, and treatment of malnutrition necessitates a multi-disciplinary care team that begins with the identification of an initial risk population for a more thorough assessment by the RD/RDN. The RD/RDN, in turn, provides the necessary treatment recommendations to address nutrition problems utilizing a nutrition diagnosis and care plan, along with the clinical indicators that inform a medical diagnosis of malnutrition completed by a physician or eligible clinician as defined by CMS. The four measure observations individually provide a portion of the necessary information on the quality of care for patients at risk for or with malnutrition. Therefore, the four components are summed and averaged according to a patient's degree of malnutrition and/or malnutrition risk to determine an encounter-level Malnutrition Care Score.</p> 
                              <p>High performance on this measure requires malnutrition risk screening and/or referral to RDNs for appropriate nutrition assessment for identified patients during the current hospitalization. For patients identified with moderate or severe malnutrition by nutrition assessment, best practice also recommends a medical diagnosis by a physician or other eligible clinician and the execution of the nutrition care plan by an RD/RDN. Evidence demonstrates that malnutrition pathways, which include a standardized protocol for screening, assessment, diagnosis, and care planning results in improved patient outcomes for malnourished patients (Pacetti et al., 2025).</p>
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Clinical Recommendation Statement</th> 
                           <td class="content-container">
                              <p>American Society for Parenteral and Enteral Nutrition (ASPEN) clinical guidelines on nutrition screening, assessment, and intervention in adults indicate that screening for nutrition risk is suggested for hospitalized patients (Mueller et al., 2011). This guideline places nutrition assessment and screening in the context of intervention as part of nutrition care. Screening those individuals at risk for malnutrition is the first step in nutrition care, as malnutrition risk, identified by nutrition screening, is associated with longer length of hospital stay, complications, and mortality. Malnutrition screening is also a predictor of mortality risk.</p> 
                              <p>Additionally, the Academy of Nutrition and Dietetics-ASPEN Indicators of Malnutrition (AAIM) provide a framework with significant validity in diagnosing malnutrition in hospitalized patients and supporting evidence that suggests that malnourished patients have more complications, longer hospitalizations, greater incidence of 30-day readmission, and higher incidence of mortality than patients with optimal nutrition status (Compher et al., 2024; Jimenez et al., 2024).</p> 
                              <p>Nutrition intervention is recommended for patients identified by assessment as at risk for malnutrition or malnourished. Nutrition intervention with associated monitoring and evaluation plans in patients identified as at risk for malnutrition or malnourished improves clinical outcomes. Nutrition interventions and their associated monitoring and evaluation plans in malnourished patients are associated with improved nutrition status, nutrient intake, physical function, and quality of life. Hospital readmissions, inpatient length of stay, and complications were reduced with increased nutrition support interventions.</p>
                           </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  
                              <p>Compher, C., Jensen, G. L., Malone, A., Morgan, S., Becker, S., Cresta, L., Paul, A. M., &amp; Steiber, A. (2024). Systematic Review of Content Validity and Meta-analysis of Predictive Validity for Clinical Outcomes Associated with Malnutrition Identified by The Academy of Nutrition and Dietetics and American Society for Parenteral and Enteral Nutrition Indicators of Malnutrition. 
                                 <em>Journal of the Academy of Nutrition and Dietetics</em>. https://doi.org/10.1016/j.jand.2024.02.002
                              </p>    
                           </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  
                              <p>Jimenez, E. Y., Lamers-Johnson, E., Long, J. M., Woodcock, L., Bliss, C., &amp; Steiber, A. L. (2024). Predictive Validity of the Academy of Nutrition and Dietetics/American Society for Parental Nutrition Indicators to Diagnose Malnutrition and the Screening Tool for Risk on Nutritional Status and Growth among Hospitalized Children Relative to Medical Outcomes. 
                                 <em>The Journal of Pediatrics</em>, 276, 114288. https://doi.org/10.1016/j.jpeds.2024.114288
                              </p>    
                           </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  
                              <p>Lengfelder, L., Mahlke, S., Moore, L., Zhang, X., Williams, G., &amp; Lee, J. (2022). Prevalence and Impact of Malnutrition on Length of stay, readmission, and Discharge Destination. 
                                 <em>Journal of Parenteral and Enteral Nutrition</em>, 46(6). https://doi.org/10.1002/jpen.2322
                              </p>    
                           </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  
                              <p>Pacetti, E. J., McMurray, D., &amp; Baca, J. (2025). Quality Improvement in Acute Care Malnutrition: Impact on Payment and Patient Outcomes. 
                                 <em>Journal of the Academy of Nutrition and Dietetics</em>, 125(9), S24-S35. https://doi.org/10.1016/j.jand.2025.05.018
                              </p>    
                           </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  
                              <p>Swan, W. I., Pertel, D. G., Hotson, B., Lloyd, L., Orrevall, Y., Trostler, N., Vivanti, A., Howarter, K. B., &amp; Papoutsakis, C. (2019). Nutrition Care Process (NCP) Update Part 2: Developing and Using the NCP Terminology to Demonstrate Efficacy of Nutrition Care and Related Outcomes. 
                                 <em>Journal of the Academy of Nutrition and Dietetics</em>, 119(5), 840-855. https://doi.org/10.1016/j.jand.2018.10.025
                              </p>    
                           </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  
                              <p>Trollebo, M. A., Tangvik, R. J., Skeie, E., Gronning, M. K., Nygard, O., Eagan, T. M. L., &amp; Dierkes, J. (2024). Malnutrition as a prognostic factor for 2-year mortality in hospitalized patients in Norway: A matched cohort study. 
                                 <em>Journal of Parenteral and Enteral Nutrition</em>, 48(3), 308-317. https://doi.org/10.1002/jpen.2619
                              </p>    
                           </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  Mogensen, K.M., Malone, A., Becker, P., Cutrell, S., Frank, L., Gonzales, K., Hudson, L., Miller, S., Guenter, P. (2019) Academy of Nutrition and Dietetics/American Society for Parenteral and Enteral Nutrition Consensus Malnutrition Characteristics: Usability and Association With Outcomes. Nutrition in Clinical Practice, 34 (5), 657-665. https://doi.org/10.1002/ncp.10310    </td> 
                        </tr> 
                        <tr>   
                           <th scope="row" class="row-header">Citation</th>  
                           <td class="content-container">  Mueller, C., Compher, C., Druyan, M.E., &amp; the ASPEN Board of Directors. (2011). ASPEN clinical guidelines on nutrition screening, assessment, and intervention in adults: Journal of Parenteral and Enteral Nutrition, 35(1), 16-24. https://doi.org/10.1177/0148607110389335     </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Definition</th> 
                           <td class="content-container">Malnutrition Diagnosis: A documented diagnosis that identifies and describes a specific nutrition problem(s) that can be resolved or improved through nutrition intervention(s), monitoring, and evaluation. For the inpatient or acute care setting, the Malnutrition Diagnosis is identified by the physician or other eligible clinician as defined by CMS based on the scope of practice regulations within the respective state, commonwealth, or territory of care delivery.</td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Definition</th> 
                           <td class="content-container">Malnutrition Risk Screening: The process of identifying and referring those individuals and populations who are at risk for nutrition-related problems, are appropriate for nutrition care services, and would benefit from nutrition interventions. For the inpatient or acute care setting, the Malnutrition Risk Screening can be completed by any eligible healthcare clinician as defined by local, state and federal guidelines.</td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Definition</th> 
                           <td class="content-container">Nutrition Assessment: A systematic approach for collecting, classifying, and synthesizing important and relevant data to describe nutritional status related nutritional problems, and their causes. This assessment includes review of the "whole" patient and evaluates the anthropometrics (i.e., body measurements and proportions), biochemical data (i.e., laboratory findings), clinical observations, and diet history (also known as 'ABCD'). For the inpatient or acute care setting, the Nutrition Assessment is performed by a RD or RDN.</td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Definition</th> 
                           <td class="content-container">Nutrition Care Plan: A documented plan based on information collected during the Nutrition Assessment of individualized nutrition recommendations, interventions, and monitoring and evaluation plans that are directed toward resolving the Malnutrition Diagnosis by altering or eliminating the nutrition etiology. The Nutrition Care Plan may encompass the interventions of Food and Nutrient Delivery, Nutrition Education, Nutrition Counseling, Coordination of Nutrition Care, and Population Based Nutrition Action, along with a plan for monitoring and evaluation, and is documented by the RD or RDN.</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Guidance (Usage)</th> 
                           <td class="content-container">
                              <p>This measure is constructed of four clinically eligible components that are aggregated as an arithmetic average of eligible encounters and expressed as a percentage. The four populations used to calculate the four components may differ and the measure observations for the four components do not need to be performed sequentially. This dQM is an episode-based measure. An episode is defined as each eligible encounter with a length of stay of greater than or equal to 24 hours among individuals 18 years of age and older at the start of the inpatient encounter. This FHIR-based measure has been derived from the QDM-based measure: CMS986v5. Please refer to the HL7 QI-Core Implementation Guide (
                                 <em>https://hl7.org/fhir/us/qicore/STU6/</em>) for more information on QI-Core and mapping recommendations from QDM to QI-Core STU 6. (
                                 <em>https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html</em>).
                              </p>
                           </td> 
                        </tr>   
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_1)</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Summary</th> 
                           <td class="content-container">
                              <p>Population Criteria 1</p>
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Basis</th> 
                           <td class="content-container">Encounter</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Scoring</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-scoring#continuous-variable: 'Continuous Variable']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-type#intermediate-outcome: 'Intermediate Outcome']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Improvement Notation</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-improvement-notation#increase: 'Increased score indicates improvement']</td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Initial Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: InitialPopulation_1 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_1-InitialPopulation_1">Initial Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulation_1 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Equals Initial Population</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_1-MeasurePopulation_1">Measure Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population Exclusion</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulationExclusion_1 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_1-MeasurePopulationExclusion_1">Measure Population Exclusion</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Observation</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasureObservation_1 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Component Measure 1: Eligible encounters for patients with a current "Malnutrition Risk Screening" performed by an eligible healthcare clinician or with a Dietitian Referral.</p> 
                                 <p>Measure Observation 1 is Encounters with Malnutrition Risk Screening or with a Dietitian Referral.</p> 
                                 <p>Measure Observation 1 identifies eligible encounters where a "Malnutrition Risk Screening" was performed during the encounter (including associated observation or emergency department encounters) with an identified Malnutrition Screening Finding of Not At Risk or At Risk Result. It also identifies an eligible encounter where there is a Dietitian Referral, whether there is a Malnutrition Risk Screening performed or not.</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_1-MeasureObservation_1">Measure Observation 1</a>    
                              <br></br>
                              <em>Input Population</em>: MeasurePopulation_1  
                              <em>AggregateMethod</em>: Sum  
                           </td> 
                        </tr>    
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_2)</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Summary</th> 
                           <td class="content-container">
                              <p>Nutrition Assessment</p>
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Basis</th> 
                           <td class="content-container">Encounter</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Scoring</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-scoring#continuous-variable: 'Continuous Variable']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-type#intermediate-outcome: 'Intermediate Outcome']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Improvement Notation</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-improvement-notation#increase: 'Increased score indicates improvement']</td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Initial Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: InitialPopulation_2 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_2-InitialPopulation_2">Initial Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulation_2 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Equals Initial Population</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_2-MeasurePopulation_2">Measure Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population Exclusion</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulationExclusion_2 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_2-MeasurePopulationExclusion_2">Measure Population Exclusion</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Observation</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasureObservation_2 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Component Measure 2: Eligible encounters for patients with a documented "Nutrition Assessment" performed by an RD/RDN, after a Malnutrition Screening Finding of At Risk Result or a Dietitian Referral order from a physician or eligible clinician during the current encounter. Measure Observation 2 includes Encounter With Most Recent Nutrition Assessment and Identified Status if the Encounter also contains Completed Malnutrition Risk Screening or Dietitian Referral Measure Observation 2 identifies eligible encounters in which a malnutrition risk screening with an At Risk result or a dietitian referral was completed during the encounter (or associated observation or emergency department encounters) and a Nutrition Assessment was subsequently completed with an identified Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished, Nutrition Assessment Status Finding of Moderately Malnourished, or Nutrition Assessment Status Finding of Severely Malnourished.</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_2-MeasureObservation_2">Measure Observation 2</a>    
                              <br></br>
                              <em>Input Population</em>: MeasurePopulation_2  
                              <em>AggregateMethod</em>: Sum  
                           </td> 
                        </tr>    
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_3)</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Summary</th> 
                           <td class="content-container">
                              <p>Malnutrition Diagnosis</p>
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Basis</th> 
                           <td class="content-container">Encounter</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Scoring</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-scoring#continuous-variable: 'Continuous Variable']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-type#intermediate-outcome: 'Intermediate Outcome']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Improvement Notation</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-improvement-notation#increase: 'Increased score indicates improvement']</td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Initial Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: InitialPopulation_3 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_3-InitialPopulation_3">Initial Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulation_3 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Equals Initial Population</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_3-MeasurePopulation_3">Measure Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population Exclusion</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulationExclusion_3 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_3-MeasurePopulationExclusion_3">Measure Population Exclusion</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Observation</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasureObservation_3 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Component Measure 3: Eligible encounters for patients with a documented "Malnutrition Diagnosis" based on the most recent Nutrition Assessment finding of Moderately Malnourished or Severely Malnourished. Measure Observation 3 includes Encounters with a most recent Nutrition Assessment and Identified Status of Moderately Malnourished or Severely Malnourished, that also identified an active medical malnutrition diagnosis during the encounter (including preceding observation or emergency department encounters) and a Malnutrition Risk Screening At Risk result or with a Dietitian Referral</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_3-MeasureObservation_3">Measure Observation 3</a>    
                              <br></br>
                              <em>Input Population</em>: MeasurePopulation_3  
                              <em>AggregateMethod</em>: Sum  
                           </td> 
                        </tr>    
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_4)</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Summary</th> 
                           <td class="content-container">
                              <p>Nutrition Care Plan</p>
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Basis</th> 
                           <td class="content-container">Encounter</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Scoring</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-scoring#continuous-variable: 'Continuous Variable']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-type#intermediate-outcome: 'Intermediate Outcome']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Improvement Notation</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-improvement-notation#increase: 'Increased score indicates improvement']</td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Initial Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: InitialPopulation_4 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_4-InitialPopulation_4">Initial Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulation_4 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Equals Initial Population</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_4-MeasurePopulation_4">Measure Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population Exclusion</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulationExclusion_4 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_4-MeasurePopulationExclusion_4">Measure Population Exclusion</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Observation</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasureObservation_4 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Component Measure 4: Eligible encounters for patients with a documented "Nutrition Care Plan" based on the most recent Nutrition Assessment finding of Moderately Malnourished or Severely Malnourished.</p> 
                                 <p>Measure Observation 4 identifies Encounters with a most recent Nutrition Assessment and Identified Status of Moderately Malnourished or Severely Malnourished, that also include a documented Nutrition Care Plan and a Malnutrition Risk Screening At Risk result or with a Dietitian Referral.</p> 
                                 <p>Measure Observation 4 identifies eligible encounters where a "Nutrition Care Plan" was performed during the encounter (including preceding observation or emergency department encounters).</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_4-MeasureObservation_4">Measure Observation 4</a>    
                              <br></br>
                              <em>Input Population</em>: MeasurePopulation_4  
                              <em>AggregateMethod</em>: Sum  
                           </td> 
                        </tr>    
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_5)</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Summary</th> 
                           <td class="content-container">
                              <p>Total Malnutrition Care Components</p>
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Basis</th> 
                           <td class="content-container">Encounter</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Scoring</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-scoring#continuous-variable: 'Continuous Variable']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-type#intermediate-outcome: 'Intermediate Outcome']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Improvement Notation</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-improvement-notation#increase: 'Increased score indicates improvement']</td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Initial Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: InitialPopulation_5 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_5-InitialPopulation_5">Initial Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulation_5 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Equals Initial Population</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_5-MeasurePopulation_5">Measure Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population Exclusion</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulationExclusion_5 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_5-MeasurePopulationExclusion_5">Measure Population Exclusion</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Observation</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasureObservation_5 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Population 5 "Measure Observation Total Malnutrition Components Score" Calculations-For each eligible encounter, Population Criteria 5 represents the subtotal of Measure Observations performed for Population Criteria 1, 2, 3, and 4. Possible values may be 0, 1, 2, 3, or 4. Population 5 "Measure Observation Total Malnutrition Components Score" is ("Measure Observation 1" plus "Measure Observation 2" plus "Measure Observation 3" plus "Measure Observation 4")</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_5-MeasureObservation_5">Measure Observation Total Malnutrition Components Score</a>    
                              <br></br>
                              <em>Input Population</em>: MeasurePopulation_5  
                              <em>AggregateMethod</em>: Count  
                           </td> 
                        </tr>    
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_6)</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Summary</th> 
                           <td class="content-container">
                              <p>Encounter Malnutrition Care Score</p>
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Basis</th> 
                           <td class="content-container">Encounter</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Scoring</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-scoring#continuous-variable: 'Continuous Variable']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-type#intermediate-outcome: 'Intermediate Outcome']</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Improvement Notation</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/measure-improvement-notation#increase: 'Increased score indicates improvement']</td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Initial Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: InitialPopulation_6 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_6-InitialPopulation_6">Initial Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulation_6 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Equals Initial Population</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_6-MeasurePopulation_6">Measure Population</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Population Exclusion</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasurePopulationExclusion_6 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_6-MeasurePopulationExclusion_6">Measure Population Exclusion</a>    
                           </td> 
                        </tr>   
                        <tr>  
                           <th scope="row" class="row-header">Measure Observation</th> 
                           <td class="content-container"> 
                              <em>ID</em>: MeasureObservation_6 
                              <br></br>  
                              <em>Description</em>: 
                              <p style="white-space: pre-line" class="tab-one">
                                 <p>Population 6 "Measure Observation Total Malnutrition Care Score as Percentage" Calculations:-For each eligible encounter, Population Criteria 6 represents the sum of performed Measure Observations 1, 2, 3, and 4 divided by the number of clinically eligible occurrences. Population 6 "Measure Observation Total Malnutrition Care Score as Percentage" is 100 multiplied by ("Measure Observation Total Malnutrition Components Score" divided by "Total Malnutrition Care Score Eligible Occurrences"). Possible values may be 0, 50, 75, or 100 percent. "Total Malnutrition Care Score Eligible Occurrences" is always 4 except in the following instances: -The "Total Malnutrition Care Score Eligible Occurrences" is 1 if ---A "Malnutrition Risk Screening" was performed and a Malnutrition Screening Finding of Not At Risk was identified and "Dietitian Referral" was not ordered. - The "Total Malnutrition Care Score Eligible Occurrences" is 2 ---If the most recent "Nutrition Assessment" performed has a result of Not or Mildly Malnourished. And, --- A "Malnutrition Risk Screening" was performed and a Malnutrition Screening Finding of At Risk was identified or a "Dietitian Referral" was ordered or a Dietitian Referral was ordered but a Nutrition Assessment was not performed.</p>
                              </p>   
                              <em>Criteria</em>: 
                              <a href="#Group_6-MeasureObservation_6">Measure Observation Total Malnutrition Care Score as Percentage</a>    
                              <br></br>
                              <em>Input Population</em>: MeasurePopulation_6  
                              <em>AggregateMethod</em>: Average  
                           </td> 
                        </tr>   
                        <tr> 
                           <th scope="row" class="row-header">Supplemental Data Guidance</th> 
                           <td class="content-container">For every patient evaluated by this measure also identify payer, race, ethnicity and sex</td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Supplemental Data Elements</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Supplemental Data Element</th> 
                           <td class="content-container"> 
                              <em>ID</em>: sde-payer-type  
                              <br></br>   
                              <em>Usage Code</em>: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]  
                              <br></br>  
                              <em>Description</em>: SDE Payer Type   
                              <br></br>  
                              <em>Logic Definition</em>: 
                              <a href="#cms986fhirmalnutritionscore-sde-payer-type">SDE Payer Type</a>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Supplemental Data Element</th> 
                           <td class="content-container"> 
                              <em>ID</em>: sde-race  
                              <br></br>   
                              <em>Usage Code</em>: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]  
                              <br></br>  
                              <em>Description</em>: SDE Race   
                              <br></br>  
                              <em>Logic Definition</em>: 
                              <a href="#cms986fhirmalnutritionscore-sde-race">SDE Race</a>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Supplemental Data Element</th> 
                           <td class="content-container"> 
                              <em>ID</em>: sde-ethnicity  
                              <br></br>   
                              <em>Usage Code</em>: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]  
                              <br></br>  
                              <em>Description</em>: SDE Ethnicity   
                              <br></br>  
                              <em>Logic Definition</em>: 
                              <a href="#cms986fhirmalnutritionscore-sde-ethnicity">SDE Ethnicity</a>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Supplemental Data Element</th> 
                           <td class="content-container"> 
                              <em>ID</em>: sde-sex  
                              <br></br>   
                              <em>Usage Code</em>: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]  
                              <br></br>  
                              <em>Description</em>: SDE Sex   
                              <br></br>  
                              <em>Logic Definition</em>: 
                              <a href="#cms986fhirmalnutritionscore-sde-sex">SDE Sex</a>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Logic</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Primary Library</th> 
                           <td class="content-container">https://madie.cms.gov/Library/CMS986FHIRMalnutritionScore</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Contents</th> 
                           <td class="content-container"> 
                              <em>
                                 <a href="#population-criteria">Population Criteria</a>
                              </em> 
                              <br></br> 
                              <em>
                                 <a href="#definitions">Logic Definitions</a>
                              </em> 
                              <br></br> 
                              <em>
                                 <a href="#terminology">Terminology</a>
                              </em> 
                              <br></br> 
                              <em>
                                 <a href="#dependencies">Dependencies</a>
                              </em> 
                              <br></br> 
                              <em>
                                 <a href="#data-requirements">Data Requirements</a>
                              </em> 
                              <br></br> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">
                              <a name="population-criteria"> </a>Population Criteria
                           </th> 
                        </tr>    
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_1)</th> 
                        </tr>       
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Initial Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_1-InitialPopulation_1"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-initial-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                             
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_1-MeasurePopulation_1"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population":
  "Initial Population"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population Exclusion </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_1-MeasurePopulationExclusion_1"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population-exclusion">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                                         
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Observation </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_1-MeasureObservation_1"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 1"(MalnutritionRiskScreening Encounter):
  if "Encounters with Malnutrition Risk Screening or with Dietitian Referral" contains MalnutritionRiskScreening then 1 
    else 0</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-observation-1">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                        
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_2)</th> 
                        </tr>       
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Initial Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_2-InitialPopulation_2"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-initial-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                             
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_2-MeasurePopulation_2"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population":
  "Initial Population"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population Exclusion </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_2-MeasurePopulationExclusion_2"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population-exclusion">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                                           
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Observation </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_2-MeasureObservation_2"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 2"(NutritionAssessment Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains NutritionAssessment then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains NutritionAssessment then if "Encounter With Most Recent Nutrition Assessment And Identified Status" contains NutritionAssessment then 1 
    else 0 
    else 0</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-observation-2">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                      
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_3)</th> 
                        </tr>       
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Initial Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_3-InitialPopulation_3"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-initial-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                             
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_3-MeasurePopulation_3"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population":
  "Initial Population"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population Exclusion </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_3-MeasurePopulationExclusion_3"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population-exclusion">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                                               
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Observation </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_3-MeasureObservation_3"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 3"(MalnutritionDiagnosis Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains MalnutritionDiagnosis then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains MalnutritionDiagnosis then if "Encounters with Malnutrition Diagnosis" contains MalnutritionDiagnosis then if "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains MalnutritionDiagnosis then 0 
    else if "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished" contains MalnutritionDiagnosis then 1 
    else 0 
    else 0 
    else 0</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-observation-3">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                  
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_4)</th> 
                        </tr>       
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Initial Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_4-InitialPopulation_4"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-initial-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                             
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_4-MeasurePopulation_4"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population":
  "Initial Population"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population Exclusion </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_4-MeasurePopulationExclusion_4"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population-exclusion">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                                                       
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Observation </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_4-MeasureObservation_4"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 4"(NutritionCarePlan Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains NutritionCarePlan then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains NutritionCarePlan then if "Encounters with Nutrition Care Plan" contains NutritionCarePlan then if "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains NutritionCarePlan then 0 
    else if "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished" contains NutritionCarePlan then 1 
    else 0 
    else 0 
    else 0</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-observation-4">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>          
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_5)</th> 
                        </tr>       
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Initial Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_5-InitialPopulation_5"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-initial-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                              
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_5-MeasurePopulation_5"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population":
  "Initial Population"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population Exclusion </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_5-MeasurePopulationExclusion_5"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population-exclusion">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                                          
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Observation </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_5-MeasureObservation_5"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation Total Malnutrition Components Score"(QualifyingEncounter Encounter):
  Sum({ "Measure Observation 1"(QualifyingEncounter), "Measure Observation 2"(QualifyingEncounter), "Measure Observation 3"(QualifyingEncounter), "Measure Observation 4"(QualifyingEncounter) })</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-observation-total-malnutrition-components-score">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                       
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: Group_6)</th> 
                        </tr>       
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Initial Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_6-InitialPopulation_6"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-initial-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                             
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_6-MeasurePopulation_6"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population":
  "Initial Population"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Population Exclusion </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_6-MeasurePopulationExclusion_6"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-population-exclusion">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>                                                                                                          
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Measure Observation </th> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="Group_6-MeasureObservation_6"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation Total Malnutrition Care Score as Percentage"(QualifyingEncounter Encounter):
  100 * ( "Measure Observation Total Malnutrition Components Score"(QualifyingEncounter) / "Total Malnutrition Care Score Eligible Occurrences"(QualifyingEncounter) )</code></pre>  
                              <a href="#cms986fhirmalnutritionscore-measure-observation-total-malnutrition-care-score-as-percentage">
                                 <em>Definition</em>
                              </a> 
                           </td> 
                        </tr>      
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">
                              <a name="definitions"> </a>Logic Definitions
                           </th> 
                        </tr>      
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> SupplementalDataElements
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="supplementaldataelements-sde-race"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Race":
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> SupplementalDataElements
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="supplementaldataelements-sde-sex"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Sex":
  case
    when Patient.sex = '248153007' then "Male (finding)"
    when Patient.sex = '248152002' then "Female (finding)"
    else null
  end</code></pre> 
                           </td> 
                        </tr>         
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> SupplementalDataElements
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="supplementaldataelements-sde-payer"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Payer":
  [Coverage: type in "Payer Type"] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> SupplementalDataElements
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="supplementaldataelements-sde-ethnicity"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Ethnicity":
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }</code></pre> 
                           </td> 
                        </tr>                             
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> FHIRHelpers
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="fhirhelpers-tointerval"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
value to a CQL DateTime Interval
@comment: If the start value of the given period is unspecified, the starting
boundary of the resulting interval will be open (meaning the start of the interval
is unknown, as opposed to interpreted as the beginning of time).
*/
define function ToInterval(period FHIR.Period):
    if period is null then
        null
    else
        if period."start" is null then
            Interval(period."start".value, period."end".value]
        else
            Interval[period."start".value, period."end".value]</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> FHIRHelpers
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="fhirhelpers-tostring"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToString(value uri): value.value</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> FHIRHelpers
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="fhirhelpers-tocode"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }</code></pre> 
                           </td> 
                        </tr>      
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> FHIRHelpers
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="fhirhelpers-toconcept"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
*/
define function ToConcept(concept FHIR.CodeableConcept):
    if concept is null then
        null
    else
        System.Concept {
            codes: concept.coding C return ToCode(C),
            display: concept.text.value
        }</code></pre> 
                           </td> 
                        </tr>                            
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> Status
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="status-verified"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">//This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA.

//Condition
//Returns conditions in the given list that either have no verification status or have a verification status of confirmed, unconfirmed, provisional, or differential
define fluent function verified(conditions List&lt;Choice&lt;ConditionProblemsHealthConcerns, ConditionEncounterDiagnosis&gt;&gt;):
  conditions C
    where C.verificationStatus is not null implies
      (C.verificationStatus ~ "confirmed"
        or C.verificationStatus ~ "unconfirmed"
        or C.verificationStatus ~ "provisional"
        or C.verificationStatus ~ "differential"
      )</code></pre> 
                           </td> 
                        </tr>                     
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CQMCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cqmcommon-hospitalizationwithobservation"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
*/
define fluent function hospitalizationWithObservation(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: "Observation Services"] 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: "Emergency Department Visit"] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]</code></pre> 
                           </td> 
                        </tr>        
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CQMCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cqmcommon-encounterdiagnosis"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*  
@description: Returns the Condition resources referenced by the diagnosis element of the Encounter  
*/
define fluent function encounterDiagnosis(Encounter Encounter ):
  Encounter.reasonReference D
    return singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where D.references(C.id))</code></pre> 
                           </td> 
                        </tr>                    
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-tointerval"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of DateTime, Quanitty, Interval&lt;DateTime&gt;, or Interval&lt;Quantity&gt; types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in QICore, allowing this function to be used across any resource.
The input can be provided as a DateTime, Quantity, Interval&lt;DateTime&gt; or Interval&lt;Quantity&gt;.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
If the input is a DateTime Interval, the result is the input.
If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
*/
define fluent function toInterval(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;, Timing&gt;):
  case
	  when choice is DateTime then
    	Interval[choice as DateTime, choice as DateTime]
		when choice is Interval&lt;DateTime&gt; then
  		choice as Interval&lt;DateTime&gt;
		when choice is Quantity then
		  Interval[Patient.birthDate + (choice as Quantity),
			  Patient.birthDate + (choice as Quantity) + 1 year)
		when choice is Interval&lt;Quantity&gt; then
		  Interval[Patient.birthDate + (choice.low as Quantity),
			  Patient.birthDate + (choice.high as Quantity) + 1 year)
		when choice is Timing then
      Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval&lt;DateTime&gt;
		else
			null as Interval&lt;DateTime&gt;
	end</code></pre> 
                           </td> 
                        </tr>    
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-latest"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Given an interval, returns the ending point if the interval has an ending boundary specified,
otherwise, returns the starting point
*/
define fluent function latest(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (period."hasEnd"()) then end of period
      else start of period</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-hasend"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Given an interval, returns true if the interval has an ending boundary specified
(i.e. the end of the interval is not null and not the maximum DateTime value)
*/
define fluent function hasEnd(period Interval&lt;DateTime&gt; ):
  not (
    end of period is null
      or end of period = maximum DateTime
  )</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-prevalenceinterval"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
*/
define fluent function prevalenceInterval(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
if condition.clinicalStatus ~ "active"
  or condition.clinicalStatus ~ "recurrence"
  or condition.clinicalStatus ~ "relapse" then
  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
else
    (end of condition.abatementInterval()) abatementDate
    return if abatementDate is null then
      Interval[start of condition.onset.toInterval(), abatementDate)
    else
      Interval[start of condition.onset.toInterval(), abatementDate]</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-abatementinterval"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
*/
define fluent function abatementInterval(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
	if condition.abatement is DateTime then
	  Interval[condition.abatement as DateTime, condition.abatement as DateTime]
	else if condition.abatement is Quantity then
		Interval[Patient.birthDate + (condition.abatement as Quantity),
			Patient.birthDate + (condition.abatement as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;Quantity&gt; then
	  Interval[Patient.birthDate + (condition.abatement.low as Quantity),
		  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;DateTime&gt; then
	  Interval[condition.abatement.low, condition.abatement.high)
	else null as Interval&lt;DateTime&gt;</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-references"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Returns true if the given reference is to the given resourceId
@comment: Returns true if the `resourceId` parameter exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resourceId String):
  resourceId = Last(Split(reference.reference, '/'))</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-earliest"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Given an interval, return the starting point if the interval has a starting boundary specified,
otherwise, return the ending point
*/
define fluent function earliest(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (period."hasStart"()) then start of period
      else end of period</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> QICoreCommon
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="qicorecommon-hasstart"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Given an interval, return true if the interval has a starting boundary specified
(i.e. the start of the interval is not null and not the minimum DateTime value)
*/
define fluent function hasStart(period Interval&lt;DateTime&gt; ):
  not ( start of period is null
      or start of period = minimum DateTime
  )</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-initial-population"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-population"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population":
  "Initial Population"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-discharge-for-hospice-care"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Discharge for Hospice Care":
  "Measure Population" QualifyingEncounter
    where QualifyingEncounter.hospitalization.dischargeDisposition in "Hospice Care Referral or Admission"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-intervention-hospice-care"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*define "Intervention Hospice Care":
    ( ["ServiceRequest": "Hospice Status"] HospiceStatusOrder
    where HospiceStatusOrder.status in { 'active', 'completed', 'on-hold' }
        and HospiceStatusOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
  )
    union ( ["Procedure": "Hospice Status"] HospiceStatusPerformed
            where HospiceStatusPerformed.status in { 'completed', 'in-progress' } 
           )

define "Encounters with Hospice during Eligible Encounter":
    "Measure Population" QualifyingEncounter
    with "Intervention Hospice Care" HospiceStatus
            such that Coalesce (start of HospiceStatus.performed.toInterval(), HospiceStatus.authoredOn) during day of QualifyingEncounter.hospitalizationWithObservation ( )
*/
//Testing definitions based on Codev comment



define "Intervention Hospice Care":
  ( ["ServiceRequest": "Hospice Status"] HospiceStatusOrder
      where HospiceStatusOrder.status in { 'active', 'completed', 'on-hold' }
        and HospiceStatusOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      return HospiceStatusOrder.authoredOn
  )
    union ( ["Procedure": "Hospice Status"] HospiceStatusPerformed
        where HospiceStatusPerformed.status in { 'completed', 'in-progress' }
        return start of HospiceStatusPerformed.performed.toInterval ( )
    )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-hospice-during-eligible-encounter"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Hospice during Eligible Encounter":
  "Measure Population" QualifyingEncounter
    with "Intervention Hospice Care" HospiceStatusDate
      such that HospiceStatusDate during day of QualifyingEncounter.hospitalizationWithObservation ( )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-population-exclusion"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-sde-race"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Race":
  SDE."SDE Race"</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-sde-sex"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Sex":
  SDE."SDE Sex"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-malnutrition-risk-screening-not-at-risk"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Malnutrition Risk Screening Not At Risk":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Malnutrition Risk Screening"] MalnutritionRiskScreening
      such that MalnutritionRiskScreening.status in { 'final', 'amended', 'corrected' }
        and MalnutritionRiskScreening.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( MalnutritionRiskScreening.value as Concept in "Malnutrition Screening Finding of Not At Risk Result" )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-malnutrition-risk-screening-at-risk"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Malnutrition Risk Screening At Risk":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Malnutrition Risk Screening"] MalnutritionRiskScreening
      such that MalnutritionRiskScreening.status in { 'final', 'amended', 'corrected' }
        and MalnutritionRiskScreening.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( MalnutritionRiskScreening.value as Concept in "Malnutrition Screening Finding of At Risk Result" )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-malnutrition-risk-screening"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Malnutrition Risk Screening":
  "Encounters with Malnutrition Risk Screening Not At Risk"
    union "Encounters with Malnutrition Risk Screening At Risk"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-intervention-dietitian-referral"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*define "Intervention Dietitian Referral":
( ["ServiceRequest": "Dietitian Referral"] DietitianReferralOrder
    where DietitianReferralOrder.status in { 'active', 'completed', 'on-hold' }
        and DietitianReferralOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
  
  )
    union ( ["Procedure": "Dietitian Referral"] DietitianReferralPerformed
            where DietitianReferralPerformed.status in { 'completed', 'in-progress' } 
           )

define "Encounters with Dietitian Referral":
    "Measure Population" QualifyingEncounter
    with "Intervention Dietitian Referral" DietitianReferral
            such that Coalesce (start of DietitianReferral.performed.toInterval(), DietitianReferral.authoredOn) during day of QualifyingEncounter.hospitalizationWithObservation ( )
*/
//New definition from Codev comments



define "Intervention Dietitian Referral":
  ( ["ServiceRequest": "Dietitian Referral"] DietitianReferralOrder
      where DietitianReferralOrder.status in { 'active', 'completed', 'on-hold' }
        and DietitianReferralOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      return DietitianReferralOrder.authoredOn
  )
    union ( ["Procedure": "Dietitian Referral"] DietitianReferralPerformed
        where DietitianReferralPerformed.status in { 'completed', 'in-progress' }
        return start of DietitianReferralPerformed.performed.toInterval ( )
    )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-dietitian-referral"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Dietitian Referral":
  "Measure Population" QualifyingEncounter
    with "Intervention Dietitian Referral" DietitianReferralDate
      such that DietitianReferralDate during day of QualifyingEncounter.hospitalizationWithObservation ( )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-malnutrition-risk-screening-or-with-dietitian-referral"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Malnutrition Risk Screening or with Dietitian Referral":
  "Encounters with Malnutrition Risk Screening"
    union "Encounters with Dietitian Referral"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-malnutrition-not-at-risk-screening-and-without-dietitian-referral"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral":
  "Encounters with Malnutrition Risk Screening Not At Risk"
    except "Encounters with Dietitian Referral"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-malnutrition-risk-screening-at-risk-or-with-dietitian-referral"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral":
  "Encounters with Malnutrition Risk Screening At Risk"
    union "Encounters with Dietitian Referral"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounter-with-most-recent-nutrition-assessment-and-identified-status"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounter With Most Recent Nutrition Assessment And Identified Status":
  "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      such that ( NutritionAssessment.status in { 'final', 'amended', 'corrected' }
          and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
          and ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished"
              or ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Moderately Malnourished" )
              or ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Severely Malnourished" )
          )
          and NutritionAssessment.effective.latest ( ) same day as "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter)
      )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-has-malnutrition-diagnosis"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Has Malnutrition Diagnosis":
  [ConditionProblemsHealthConcerns: "Malnutrition Diagnosis"] MalnutritionDiagnosis
    where MalnutritionDiagnosis.prevalenceInterval ( ) overlaps "Measurement Period"
      and MalnutritionDiagnosis.isVerified ( )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-encounter-diagnosis-of-malnutrition-diagnosis"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters With Encounter Diagnosis Of Malnutrition Diagnosis":
  "Measure Population" QualifyingEncounter
    where QualifyingEncounter.reasonCode in "Malnutrition Diagnosis"
      or QualifyingEncounter.encounterDiagnosis ( ).verified ( ).code in "Malnutrition Diagnosis"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-malnutrition-diagnosis"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Malnutrition Diagnosis":
  ( "Measure Population" QualifyingEncounter
      where exists ( "Has Malnutrition Diagnosis" MalnutritionDiagnosis
          where MalnutritionDiagnosis.prevalenceInterval ( ) overlaps day of QualifyingEncounter.hospitalizationWithObservation ( )
      )
  )
    union "Encounters With Encounter Diagnosis Of Malnutrition Diagnosis"</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounter-with-most-recent-nutrition-assessment-status-of-not-or-mildly-malnourished"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      such that ( NutritionAssessment.status in { 'final', 'amended', 'corrected' }
          and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
          and ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished" )
          and NutritionAssessment.effective.latest ( ) same day as "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter)
      )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounter-with-most-recent-nutrition-assessment-status-of-moderately-or-severely-malnourished"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      such that NutritionAssessment.status in { 'final', 'amended', 'corrected' }
        and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Moderately Malnourished"
            or NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Severely Malnourished"
        )
        and NutritionAssessment.effective.latest ( ) same day as "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter)</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-encounters-with-nutrition-care-plan"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounters with Nutrition Care Plan":
  "Measure Population" QualifyingEncounter
    with ["Procedure": "Nutrition Care Plan"] NutritionCarePlan
      such that NutritionCarePlan.status in { 'completed', 'in-progress' }
        and NutritionCarePlan.performed.earliest ( ) during QualifyingEncounter.hospitalizationWithObservation ( )</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-sde-payer-type"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Payer Type":
  SDE."SDE Payer"</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-sde-ethnicity"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "SDE Ethnicity":
  SDE."SDE Ethnicity"</code></pre> 
                           </td> 
                        </tr>    
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-observation-1"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 1"(MalnutritionRiskScreening Encounter):
  if "Encounters with Malnutrition Risk Screening or with Dietitian Referral" contains MalnutritionRiskScreening then 1 
    else 0</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-observation-total-malnutrition-components-score"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation Total Malnutrition Components Score"(QualifyingEncounter Encounter):
  Sum({ "Measure Observation 1"(QualifyingEncounter), "Measure Observation 2"(QualifyingEncounter), "Measure Observation 3"(QualifyingEncounter), "Measure Observation 4"(QualifyingEncounter) })</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-observation-2"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 2"(NutritionAssessment Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains NutritionAssessment then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains NutritionAssessment then if "Encounter With Most Recent Nutrition Assessment And Identified Status" contains NutritionAssessment then 1 
    else 0 
    else 0</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-last-nutrition-assessment-day-during-encounter"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*define function "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter Encounter):
  Max("Nutrition Assessment Performed" NutritionAssessmentTuple
    where NutritionAssessmentTuple.HospEncId = QualifyingEncounter.id
    return NutritionAssessmentTuple.NutrAssessTimingLatest
  )

define "Nutrition Assessment Performed":
    from
    "Measure Population" QualifyingEncounter,
    ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
        where NutritionAssessment.status in { 'final', 'amended', 'corrected' }
            and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
            and NutritionAssessment.value is not null
            return Tuple {
        HospEncId: QualifyingEncounter.id,
        NutrAssessTimingLatest: NutritionAssessment.effective.latest()
        }
*/
//Test definition per CODev feedback



define function "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter Encounter):
  Max(["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      where NutritionAssessment.status in { 'final', 'amended', 'corrected' }
        and NutritionAssessment.effective.toInterval() during QualifyingEncounter.hospitalizationWithObservation()
        and NutritionAssessment.value is not null
      return NutritionAssessment.effective.latest()
  )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-observation-3"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 3"(MalnutritionDiagnosis Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains MalnutritionDiagnosis then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains MalnutritionDiagnosis then if "Encounters with Malnutrition Diagnosis" contains MalnutritionDiagnosis then if "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains MalnutritionDiagnosis then 0 
    else if "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished" contains MalnutritionDiagnosis then 1 
    else 0 
    else 0 
    else 0</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-isverified"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define fluent function isVerified(condition Choice&lt;QICore.ConditionProblemsHealthConcerns, QICore.ConditionEncounterDiagnosis&gt;):
  condition.verificationStatus is not null implies ( condition.verificationStatus ~ QICoreCommon."confirmed"
      or condition.verificationStatus ~ QICoreCommon."unconfirmed"
      or condition.verificationStatus ~ QICoreCommon."provisional"
      or condition.verificationStatus ~ QICoreCommon."differential"
  )</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-observation-4"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation 4"(NutritionCarePlan Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains NutritionCarePlan then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains NutritionCarePlan then if "Encounters with Nutrition Care Plan" contains NutritionCarePlan then if "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains NutritionCarePlan then 0 
    else if "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished" contains NutritionCarePlan then 1 
    else 0 
    else 0 
    else 0</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-measure-observation-total-malnutrition-care-score-as-percentage"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Measure Observation Total Malnutrition Care Score as Percentage"(QualifyingEncounter Encounter):
  100 * ( "Measure Observation Total Malnutrition Components Score"(QualifyingEncounter) / "Total Malnutrition Care Score Eligible Occurrences"(QualifyingEncounter) )</code></pre> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" rowspan="2" class="row-header"> Logic Definition </th> 
                           <td class="content-container">
                              <em>Library Name:</em> CMS986FHIRMalnutritionScore
                           </td> 
                        </tr> 
                        <tr> 
                           <td>   
                              <a name="cms986fhirmalnutritionscore-total-malnutrition-care-score-eligible-occurrences"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Total Malnutrition Care Score Eligible Occurrences"(QualifyingEncounter Encounter):
  if "Encounters with Malnutrition Risk Screening or with Dietitian Referral" contains QualifyingEncounter
    and "Encounters with Malnutrition Risk Screening Not At Risk" contains QualifyingEncounter
    and not ( "Encounters with Dietitian Referral" contains QualifyingEncounter ) then 1 
    else if ( "Encounters with Malnutrition Risk Screening or with Dietitian Referral" contains QualifyingEncounter
      and "Encounters with Malnutrition Risk Screening At Risk" contains QualifyingEncounter
      or "Encounters with Dietitian Referral" contains QualifyingEncounter
  )
    and "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains QualifyingEncounter
    or not ( "Encounter With Most Recent Nutrition Assessment And Identified Status" contains QualifyingEncounter ) then 2 
    else 4</code></pre> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">
                              <a name="terminology"> </a>Terminology
                           </th> 
                        </tr>     
                        <tr>  
                           <th scope="row" class="row-header">Code System</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Code system SNOMEDCT  
                              <br></br>    
                              <em>Resource</em>: http://snomed.info/sct 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://snomed.info/sct</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Code System</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Code system ConditionClinicalStatusCodes  
                              <br></br>    
                              <em>Resource</em>: http://terminology.hl7.org/CodeSystem/condition-clinical 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-clinical</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Code System</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Code system ConditionVerificationStatusCodes  
                              <br></br>    
                              <em>Resource</em>: http://terminology.hl7.org/CodeSystem/condition-ver-status 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-ver-status</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Encounter Inpatient  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Hospice Care Referral or Admission  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Hospice Status  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Observation Services  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Emergency Department Visit  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Malnutrition Risk Screening  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.92 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.92</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Malnutrition Screening Finding of Not At Risk Result  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.34 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.34</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Malnutrition Screening Finding of At Risk Result  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.89 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.89</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Dietitian Referral  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Nutrition Assessment  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.21 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.21</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.96 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.96</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Nutrition Assessment Status Finding of Moderately Malnourished  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.47 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.47</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Nutrition Assessment Status Finding of Severely Malnourished  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.43 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.43</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Malnutrition Diagnosis  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Nutrition Care Plan  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.93 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.93</tt> 
                           </td> 
                        </tr> 
                        <tr>  
                           <th scope="row" class="row-header">Value Set</th>  
                           <td class="content-container"> 
                              <em>Description</em>: Value set Payer Type  
                              <br></br>    
                              <em>Resource</em>: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591</tt> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Male (finding) 
                              <br></br> 
                              <em>Code</em>: 248153007 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://snomed.info/sct</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Female (finding) 
                              <br></br> 
                              <em>Code</em>: 248152002 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://snomed.info/sct</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Active 
                              <br></br> 
                              <em>Code</em>: active 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-clinical</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Recurrence 
                              <br></br> 
                              <em>Code</em>: recurrence 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-clinical</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Relapse 
                              <br></br> 
                              <em>Code</em>: relapse 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-clinical</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Confirmed 
                              <br></br> 
                              <em>Code</em>: confirmed 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-ver-status</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Unconfirmed 
                              <br></br> 
                              <em>Code</em>: unconfirmed 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-ver-status</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Provisional 
                              <br></br> 
                              <em>Code</em>: provisional 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-ver-status</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Direct Reference Code</th> 
                           <td class="content-container"> 
                              <em>Display</em>: Differential 
                              <br></br> 
                              <em>Code</em>: differential 
                              <br></br> 
                              <em>System</em>: 
                              <tt>http://terminology.hl7.org/CodeSystem/condition-ver-status</tt> 
                           </td> 
                        </tr>  
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">
                              <a name="dependencies"> </a>Dependencies
                           </th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Dependency</th> 
                           <td class="content-container"> 
                              <em>Description</em>: QICore model information  
                              <br></br>    
                              <em>Resource</em>: http://hl7.org/fhir/Library/QICore-ModelInfo 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>http://hl7.org/fhir/Library/QICore-ModelInfo</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Dependency</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Library FHIRHelpers  
                              <br></br>    
                              <em>Resource</em>: https://madie.cms.gov/Library/FHIRHelpers|4.4.000 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>https://madie.cms.gov/Library/FHIRHelpers|4.4.000</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Dependency</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Library QICoreCommon  
                              <br></br>    
                              <em>Resource</em>: https://madie.cms.gov/Library/QICoreCommon|4.0.000 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>https://madie.cms.gov/Library/QICoreCommon|4.0.000</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Dependency</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Library CQMCommon  
                              <br></br>    
                              <em>Resource</em>: https://madie.cms.gov/Library/CQMCommon|4.1.000 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>https://madie.cms.gov/Library/CQMCommon|4.1.000</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Dependency</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Library SDE  
                              <br></br>    
                              <em>Resource</em>: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>https://madie.cms.gov/Library/SupplementalDataElements|5.1.000</tt> 
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Dependency</th> 
                           <td class="content-container"> 
                              <em>Description</em>: Library Status  
                              <br></br>    
                              <em>Resource</em>: https://madie.cms.gov/Library/Status|1.15.000 
                              <br></br> 
                              <em>Canonical URL</em>: 
                              <tt>https://madie.cms.gov/Library/Status|1.15.000</tt> 
                           </td> 
                        </tr>            
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">
                              <a name="data-requirements"> </a>Data Requirements
                           </th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Patient 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient 
                              <br></br>   
                              <em>Must Support Elements</em>: birthDate, birthDate.value, url, extension 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, status, status.value, period 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, status, status.value, period 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, period, status, status.value, hospitalization, hospitalization.dischargeDisposition, reasonCode 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: ServiceRequest 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, intent, intent.value, authoredOn, authoredOn.value 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: ServiceRequest 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, intent, intent.value, authoredOn, authoredOn.value 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Procedure 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, performed 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Procedure 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, performed 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Procedure 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, performed 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.93 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Observation 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, effective, value 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.92 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Observation 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, effective, value 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.21 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Condition 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Condition 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns 
                              <br></br>   
                              <em>Must Support Elements</em>: code 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Condition 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Coverage 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage 
                              <br></br>   
                              <em>Must Support Elements</em>: type, period 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591 
                              <br></br>   
                           </td> 
                        </tr>  
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Generated using version 0.4.9 of the sample-content-ig Liquid templates</th> 
                        </tr> 
                     </tbody> 
                  </table> 
               </div>
            </text>
            <contained>
               <Library xmlns="http://hl7.org/fhir">
                  <id value="effective-data-requirements"></id>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://snomed.info/sct"></system>
                        <code value="248153007"></code>
                        <display value="Male (finding)"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://snomed.info/sct"></system>
                        <code value="248152002"></code>
                        <display value="Female (finding)"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                        <code value="active"></code>
                        <display value="Active"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                        <code value="recurrence"></code>
                        <display value="Recurrence"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                        <code value="relapse"></code>
                        <display value="Relapse"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                        <code value="confirmed"></code>
                        <display value="Confirmed"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                        <code value="unconfirmed"></code>
                        <display value="Unconfirmed"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                        <code value="provisional"></code>
                        <display value="Provisional"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
                     <valueCoding>
                        <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                        <code value="differential"></code>
                        <display value="Differential"></display>
                     </valueCoding>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Initial Population"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Initial Population&quot;:
  [Encounter: &quot;Encounter Inpatient&quot;] EncounterInpatient
    where EncounterInpatient.period ends during day of &quot;Measurement Period&quot;
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="0"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Population"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Measure Population&quot;:
  &quot;Initial Population&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="1"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Discharge for Hospice Care"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Discharge for Hospice Care&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    where QualifyingEncounter.hospitalization.dischargeDisposition in &quot;Hospice Care Referral or Admission&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="2"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Intervention Hospice Care"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*define &quot;Intervention Hospice Care&quot;:
    ( [&quot;ServiceRequest&quot;: &quot;Hospice Status&quot;] HospiceStatusOrder
    where HospiceStatusOrder.status in { 'active', 'completed', 'on-hold' }
        and HospiceStatusOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
  )
    union ( [&quot;Procedure&quot;: &quot;Hospice Status&quot;] HospiceStatusPerformed
            where HospiceStatusPerformed.status in { 'completed', 'in-progress' } 
           )

define &quot;Encounters with Hospice during Eligible Encounter&quot;:
    &quot;Measure Population&quot; QualifyingEncounter
    with &quot;Intervention Hospice Care&quot; HospiceStatus
            such that Coalesce (start of HospiceStatus.performed.toInterval(), HospiceStatus.authoredOn) during day of QualifyingEncounter.hospitalizationWithObservation ( )
*/
//Testing definitions based on Codev comment



define &quot;Intervention Hospice Care&quot;:
  ( [&quot;ServiceRequest&quot;: &quot;Hospice Status&quot;] HospiceStatusOrder
      where HospiceStatusOrder.status in { 'active', 'completed', 'on-hold' }
        and HospiceStatusOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      return HospiceStatusOrder.authoredOn
  )
    union ( [&quot;Procedure&quot;: &quot;Hospice Status&quot;] HospiceStatusPerformed
        where HospiceStatusPerformed.status in { 'completed', 'in-progress' }
        return start of HospiceStatusPerformed.performed.toInterval ( )
    )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="3"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Hospice during Eligible Encounter"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Hospice during Eligible Encounter&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    with &quot;Intervention Hospice Care&quot; HospiceStatusDate
      such that HospiceStatusDate during day of QualifyingEncounter.hospitalizationWithObservation ( )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="4"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Population Exclusion"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Measure Population Exclusion&quot;:
  &quot;Encounters with Discharge for Hospice Care&quot;
    union &quot;Encounters with Hospice during Eligible Encounter&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="5"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="SupplementalDataElements"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Race"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Race&quot;:
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="6"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Race"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Race&quot;:
  SDE.&quot;SDE Race&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="7"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="SupplementalDataElements"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Sex"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Sex&quot;:
  case
    when Patient.sex = '248153007' then &quot;Male (finding)&quot;
    when Patient.sex = '248152002' then &quot;Female (finding)&quot;
    else null
  end"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="8"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Sex"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Sex&quot;:
  SDE.&quot;SDE Sex&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="9"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Malnutrition Risk Screening Not At Risk"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Malnutrition Risk Screening Not At Risk&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    with [&quot;ObservationScreeningAssessment&quot;: &quot;Malnutrition Risk Screening&quot;] MalnutritionRiskScreening
      such that MalnutritionRiskScreening.status in { 'final', 'amended', 'corrected' }
        and MalnutritionRiskScreening.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( MalnutritionRiskScreening.value as Concept in &quot;Malnutrition Screening Finding of Not At Risk Result&quot; )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="10"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Malnutrition Risk Screening At Risk"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Malnutrition Risk Screening At Risk&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    with [&quot;ObservationScreeningAssessment&quot;: &quot;Malnutrition Risk Screening&quot;] MalnutritionRiskScreening
      such that MalnutritionRiskScreening.status in { 'final', 'amended', 'corrected' }
        and MalnutritionRiskScreening.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( MalnutritionRiskScreening.value as Concept in &quot;Malnutrition Screening Finding of At Risk Result&quot; )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="11"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Malnutrition Risk Screening"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Malnutrition Risk Screening&quot;:
  &quot;Encounters with Malnutrition Risk Screening Not At Risk&quot;
    union &quot;Encounters with Malnutrition Risk Screening At Risk&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="12"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Intervention Dietitian Referral"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*define &quot;Intervention Dietitian Referral&quot;:
( [&quot;ServiceRequest&quot;: &quot;Dietitian Referral&quot;] DietitianReferralOrder
    where DietitianReferralOrder.status in { 'active', 'completed', 'on-hold' }
        and DietitianReferralOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
  
  )
    union ( [&quot;Procedure&quot;: &quot;Dietitian Referral&quot;] DietitianReferralPerformed
            where DietitianReferralPerformed.status in { 'completed', 'in-progress' } 
           )

define &quot;Encounters with Dietitian Referral&quot;:
    &quot;Measure Population&quot; QualifyingEncounter
    with &quot;Intervention Dietitian Referral&quot; DietitianReferral
            such that Coalesce (start of DietitianReferral.performed.toInterval(), DietitianReferral.authoredOn) during day of QualifyingEncounter.hospitalizationWithObservation ( )
*/
//New definition from Codev comments



define &quot;Intervention Dietitian Referral&quot;:
  ( [&quot;ServiceRequest&quot;: &quot;Dietitian Referral&quot;] DietitianReferralOrder
      where DietitianReferralOrder.status in { 'active', 'completed', 'on-hold' }
        and DietitianReferralOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      return DietitianReferralOrder.authoredOn
  )
    union ( [&quot;Procedure&quot;: &quot;Dietitian Referral&quot;] DietitianReferralPerformed
        where DietitianReferralPerformed.status in { 'completed', 'in-progress' }
        return start of DietitianReferralPerformed.performed.toInterval ( )
    )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="13"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Dietitian Referral"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Dietitian Referral&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    with &quot;Intervention Dietitian Referral&quot; DietitianReferralDate
      such that DietitianReferralDate during day of QualifyingEncounter.hospitalizationWithObservation ( )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="14"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Malnutrition Risk Screening or with Dietitian Referral"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Malnutrition Risk Screening or with Dietitian Referral&quot;:
  &quot;Encounters with Malnutrition Risk Screening&quot;
    union &quot;Encounters with Dietitian Referral&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="15"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral&quot;:
  &quot;Encounters with Malnutrition Risk Screening Not At Risk&quot;
    except &quot;Encounters with Dietitian Referral&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="16"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral&quot;:
  &quot;Encounters with Malnutrition Risk Screening At Risk&quot;
    union &quot;Encounters with Dietitian Referral&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="17"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounter With Most Recent Nutrition Assessment And Identified Status"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounter With Most Recent Nutrition Assessment And Identified Status&quot;:
  &quot;Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral&quot; QualifyingEncounter
    with [&quot;ObservationScreeningAssessment&quot;: &quot;Nutrition Assessment&quot;] NutritionAssessment
      such that ( NutritionAssessment.status in { 'final', 'amended', 'corrected' }
          and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
          and ( NutritionAssessment.value as Concept in &quot;Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished&quot;
              or ( NutritionAssessment.value as Concept in &quot;Nutrition Assessment Status Finding of Moderately Malnourished&quot; )
              or ( NutritionAssessment.value as Concept in &quot;Nutrition Assessment Status Finding of Severely Malnourished&quot; )
          )
          and NutritionAssessment.effective.latest ( ) same day as &quot;Last Nutrition Assessment Day During Encounter&quot;(QualifyingEncounter)
      )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="18"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Has Malnutrition Diagnosis"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Has Malnutrition Diagnosis&quot;:
  [ConditionProblemsHealthConcerns: &quot;Malnutrition Diagnosis&quot;] MalnutritionDiagnosis
    where MalnutritionDiagnosis.prevalenceInterval ( ) overlaps &quot;Measurement Period&quot;
      and MalnutritionDiagnosis.isVerified ( )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="19"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters With Encounter Diagnosis Of Malnutrition Diagnosis"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters With Encounter Diagnosis Of Malnutrition Diagnosis&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    where QualifyingEncounter.reasonCode in &quot;Malnutrition Diagnosis&quot;
      or QualifyingEncounter.encounterDiagnosis ( ).verified ( ).code in &quot;Malnutrition Diagnosis&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="20"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Malnutrition Diagnosis"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Malnutrition Diagnosis&quot;:
  ( &quot;Measure Population&quot; QualifyingEncounter
      where exists ( &quot;Has Malnutrition Diagnosis&quot; MalnutritionDiagnosis
          where MalnutritionDiagnosis.prevalenceInterval ( ) overlaps day of QualifyingEncounter.hospitalizationWithObservation ( )
      )
  )
    union &quot;Encounters With Encounter Diagnosis Of Malnutrition Diagnosis&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="21"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    with [&quot;ObservationScreeningAssessment&quot;: &quot;Nutrition Assessment&quot;] NutritionAssessment
      such that ( NutritionAssessment.status in { 'final', 'amended', 'corrected' }
          and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
          and ( NutritionAssessment.value as Concept in &quot;Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished&quot; )
          and NutritionAssessment.effective.latest ( ) same day as &quot;Last Nutrition Assessment Day During Encounter&quot;(QualifyingEncounter)
      )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="22"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    with [&quot;ObservationScreeningAssessment&quot;: &quot;Nutrition Assessment&quot;] NutritionAssessment
      such that NutritionAssessment.status in { 'final', 'amended', 'corrected' }
        and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( NutritionAssessment.value as Concept in &quot;Nutrition Assessment Status Finding of Moderately Malnourished&quot;
            or NutritionAssessment.value as Concept in &quot;Nutrition Assessment Status Finding of Severely Malnourished&quot;
        )
        and NutritionAssessment.effective.latest ( ) same day as &quot;Last Nutrition Assessment Day During Encounter&quot;(QualifyingEncounter)"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="23"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Encounters with Nutrition Care Plan"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;Encounters with Nutrition Care Plan&quot;:
  &quot;Measure Population&quot; QualifyingEncounter
    with [&quot;Procedure&quot;: &quot;Nutrition Care Plan&quot;] NutritionCarePlan
      such that NutritionCarePlan.status in { 'completed', 'in-progress' }
        and NutritionCarePlan.performed.earliest ( ) during QualifyingEncounter.hospitalizationWithObservation ( )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="24"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="SupplementalDataElements"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Payer"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Payer&quot;:
  [Coverage: type in &quot;Payer Type&quot;] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="25"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Payer Type"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Payer Type&quot;:
  SDE.&quot;SDE Payer&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="26"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="SupplementalDataElements"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Ethnicity"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Ethnicity&quot;:
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="27"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="SDE Ethnicity"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define &quot;SDE Ethnicity&quot;:
  SDE.&quot;SDE Ethnicity&quot;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="28"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="FHIRHelpers"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="ToInterval"></valueString>
                     </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]"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="29"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="toInterval"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of DateTime, Quanitty, Interval&lt;DateTime&gt;, or Interval&lt;Quantity&gt; types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in QICore, allowing this function to be used across any resource.
The input can be provided as a DateTime, Quantity, Interval&lt;DateTime&gt; or Interval&lt;Quantity&gt;.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
If the input is a DateTime Interval, the result is the input.
If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
*/
define fluent function toInterval(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;, Timing&gt;):
  case
	  when choice is DateTime then
    	Interval[choice as DateTime, choice as DateTime]
		when choice is Interval&lt;DateTime&gt; then
  		choice as Interval&lt;DateTime&gt;
		when choice is Quantity then
		  Interval[Patient.birthDate + (choice as Quantity),
			  Patient.birthDate + (choice as Quantity) + 1 year)
		when choice is Interval&lt;Quantity&gt; then
		  Interval[Patient.birthDate + (choice.low as Quantity),
			  Patient.birthDate + (choice.high as Quantity) + 1 year)
		when choice is Timing then
      Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval&lt;DateTime&gt;
		else
			null as Interval&lt;DateTime&gt;
	end"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="30"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CQMCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="hospitalizationWithObservation"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
*/
define fluent function hospitalizationWithObservation(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: &quot;Observation Services&quot;] LastObs
  				where LastObs.status = 'finished'
            and LastObs.period ends 1 hour or less on or before start of Visit.period
  				sort by end of period
  			),
  			VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
  			EDVisit: Last([Encounter: &quot;Emergency Department Visit&quot;] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="31"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="FHIRHelpers"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="ToString"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function ToString(value uri): value.value"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="32"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="FHIRHelpers"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="ToCode"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="33"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Observation 1"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function &quot;Measure Observation 1&quot;(MalnutritionRiskScreening Encounter):
  if &quot;Encounters with Malnutrition Risk Screening or with Dietitian Referral&quot; contains MalnutritionRiskScreening then 1 
    else 0"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="34"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Observation Total Malnutrition Components Score"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function &quot;Measure Observation Total Malnutrition Components Score&quot;(QualifyingEncounter Encounter):
  Sum({ &quot;Measure Observation 1&quot;(QualifyingEncounter), &quot;Measure Observation 2&quot;(QualifyingEncounter), &quot;Measure Observation 3&quot;(QualifyingEncounter), &quot;Measure Observation 4&quot;(QualifyingEncounter) })"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="35"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Observation 2"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function &quot;Measure Observation 2&quot;(NutritionAssessment Encounter):
  if &quot;Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral&quot; contains NutritionAssessment then 0 
    else if &quot;Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral&quot; contains NutritionAssessment then if &quot;Encounter With Most Recent Nutrition Assessment And Identified Status&quot; contains NutritionAssessment then 1 
    else 0 
    else 0"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="36"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="latest"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Given an interval, returns the ending point if the interval has an ending boundary specified,
otherwise, returns the starting point
*/
define fluent function latest(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (period.&quot;hasEnd&quot;()) then end of period
      else start of period"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="37"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="hasEnd"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Given an interval, returns true if the interval has an ending boundary specified
(i.e. the end of the interval is not null and not the maximum DateTime value)
*/
define fluent function hasEnd(period Interval&lt;DateTime&gt; ):
  not (
    end of period is null
      or end of period = maximum DateTime
  )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="38"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Last Nutrition Assessment Day During Encounter"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*define function &quot;Last Nutrition Assessment Day During Encounter&quot;(QualifyingEncounter Encounter):
  Max(&quot;Nutrition Assessment Performed&quot; NutritionAssessmentTuple
    where NutritionAssessmentTuple.HospEncId = QualifyingEncounter.id
    return NutritionAssessmentTuple.NutrAssessTimingLatest
  )

define &quot;Nutrition Assessment Performed&quot;:
    from
    &quot;Measure Population&quot; QualifyingEncounter,
    [&quot;ObservationScreeningAssessment&quot;: &quot;Nutrition Assessment&quot;] NutritionAssessment
        where NutritionAssessment.status in { 'final', 'amended', 'corrected' }
            and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
            and NutritionAssessment.value is not null
            return Tuple {
        HospEncId: QualifyingEncounter.id,
        NutrAssessTimingLatest: NutritionAssessment.effective.latest()
        }
*/
//Test definition per CODev feedback



define function &quot;Last Nutrition Assessment Day During Encounter&quot;(QualifyingEncounter Encounter):
  Max([&quot;ObservationScreeningAssessment&quot;: &quot;Nutrition Assessment&quot;] NutritionAssessment
      where NutritionAssessment.status in { 'final', 'amended', 'corrected' }
        and NutritionAssessment.effective.toInterval() during QualifyingEncounter.hospitalizationWithObservation()
        and NutritionAssessment.value is not null
      return NutritionAssessment.effective.latest()
  )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="39"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Observation 3"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function &quot;Measure Observation 3&quot;(MalnutritionDiagnosis Encounter):
  if &quot;Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral&quot; contains MalnutritionDiagnosis then 0 
    else if &quot;Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral&quot; contains MalnutritionDiagnosis then if &quot;Encounters with Malnutrition Diagnosis&quot; contains MalnutritionDiagnosis then if &quot;Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished&quot; contains MalnutritionDiagnosis then 0 
    else if &quot;Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished&quot; contains MalnutritionDiagnosis then 1 
    else 0 
    else 0 
    else 0"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="40"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="prevalenceInterval"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
*/
define fluent function prevalenceInterval(condition Choice&lt;&quot;ConditionEncounterDiagnosis&quot;, &quot;ConditionProblemsHealthConcerns&quot;&gt;):
if condition.clinicalStatus ~ &quot;active&quot;
  or condition.clinicalStatus ~ &quot;recurrence&quot;
  or condition.clinicalStatus ~ &quot;relapse&quot; then
  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
else
    (end of condition.abatementInterval()) abatementDate
    return if abatementDate is null then
      Interval[start of condition.onset.toInterval(), abatementDate)
    else
      Interval[start of condition.onset.toInterval(), abatementDate]"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="41"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="abatementInterval"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
*/
define fluent function abatementInterval(condition Choice&lt;&quot;ConditionEncounterDiagnosis&quot;, &quot;ConditionProblemsHealthConcerns&quot;&gt;):
	if condition.abatement is DateTime then
	  Interval[condition.abatement as DateTime, condition.abatement as DateTime]
	else if condition.abatement is Quantity then
		Interval[Patient.birthDate + (condition.abatement as Quantity),
			Patient.birthDate + (condition.abatement as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;Quantity&gt; then
	  Interval[Patient.birthDate + (condition.abatement.low as Quantity),
		  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;DateTime&gt; then
	  Interval[condition.abatement.low, condition.abatement.high)
	else null as Interval&lt;DateTime&gt;"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="42"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="isVerified"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define fluent function isVerified(condition Choice&lt;QICore.ConditionProblemsHealthConcerns, QICore.ConditionEncounterDiagnosis&gt;):
  condition.verificationStatus is not null implies ( condition.verificationStatus ~ QICoreCommon.&quot;confirmed&quot;
      or condition.verificationStatus ~ QICoreCommon.&quot;unconfirmed&quot;
      or condition.verificationStatus ~ QICoreCommon.&quot;provisional&quot;
      or condition.verificationStatus ~ QICoreCommon.&quot;differential&quot;
  )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="43"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="FHIRHelpers"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="ToConcept"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
*/
define function ToConcept(concept FHIR.CodeableConcept):
    if concept is null then
        null
    else
        System.Concept {
            codes: concept.coding C return ToCode(C),
            display: concept.text.value
        }"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="44"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="Status"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="verified"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="//This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA.

//Condition
//Returns conditions in the given list that either have no verification status or have a verification status of confirmed, unconfirmed, provisional, or differential
define fluent function verified(conditions List&lt;Choice&lt;ConditionProblemsHealthConcerns, ConditionEncounterDiagnosis&gt;&gt;):
  conditions C
    where C.verificationStatus is not null implies
      (C.verificationStatus ~ &quot;confirmed&quot;
        or C.verificationStatus ~ &quot;unconfirmed&quot;
        or C.verificationStatus ~ &quot;provisional&quot;
        or C.verificationStatus ~ &quot;differential&quot;
      )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="45"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CQMCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="encounterDiagnosis"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*  
@description: Returns the Condition resources referenced by the diagnosis element of the Encounter  
*/
define fluent function encounterDiagnosis(Encounter Encounter ):
  Encounter.reasonReference D
    return singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where D.references(C.id))"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="46"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="references"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Returns true if the given reference is to the given resourceId
@comment: Returns true if the `resourceId` parameter exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resourceId String):
  resourceId = Last(Split(reference.reference, '/'))"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="47"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Observation 4"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function &quot;Measure Observation 4&quot;(NutritionCarePlan Encounter):
  if &quot;Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral&quot; contains NutritionCarePlan then 0 
    else if &quot;Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral&quot; contains NutritionCarePlan then if &quot;Encounters with Nutrition Care Plan&quot; contains NutritionCarePlan then if &quot;Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished&quot; contains NutritionCarePlan then 0 
    else if &quot;Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished&quot; contains NutritionCarePlan then 1 
    else 0 
    else 0 
    else 0"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="48"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="earliest"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Given an interval, return the starting point if the interval has a starting boundary specified,
otherwise, return the ending point
*/
define fluent function earliest(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (period.&quot;hasStart&quot;()) then start of period
      else end of period"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="49"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="QICoreCommon"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="hasStart"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="/*
@description: Given an interval, return true if the interval has a starting boundary specified
(i.e. the start of the interval is not null and not the minimum DateTime value)
*/
define fluent function hasStart(period Interval&lt;DateTime&gt; ):
  not ( start of period is null
      or start of period = minimum DateTime
  )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="50"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Measure Observation Total Malnutrition Care Score as Percentage"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function &quot;Measure Observation Total Malnutrition Care Score as Percentage&quot;(QualifyingEncounter Encounter):
  100 * ( &quot;Measure Observation Total Malnutrition Components Score&quot;(QualifyingEncounter) / &quot;Total Malnutrition Care Score Eligible Occurrences&quot;(QualifyingEncounter) )"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="51"></valueInteger>
                     </extension>
                  </extension>
                  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
                     <extension url="libraryName">
                        <valueString value="CMS986FHIRMalnutritionScore"></valueString>
                     </extension>
                     <extension url="name">
                        <valueString value="Total Malnutrition Care Score Eligible Occurrences"></valueString>
                     </extension>
                     <extension url="statement">
                        <valueString value="define function &quot;Total Malnutrition Care Score Eligible Occurrences&quot;(QualifyingEncounter Encounter):
  if &quot;Encounters with Malnutrition Risk Screening or with Dietitian Referral&quot; contains QualifyingEncounter
    and &quot;Encounters with Malnutrition Risk Screening Not At Risk&quot; contains QualifyingEncounter
    and not ( &quot;Encounters with Dietitian Referral&quot; contains QualifyingEncounter ) then 1 
    else if ( &quot;Encounters with Malnutrition Risk Screening or with Dietitian Referral&quot; contains QualifyingEncounter
      and &quot;Encounters with Malnutrition Risk Screening At Risk&quot; contains QualifyingEncounter
      or &quot;Encounters with Dietitian Referral&quot; contains QualifyingEncounter
  )
    and &quot;Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished&quot; contains QualifyingEncounter
    or not ( &quot;Encounter With Most Recent Nutrition Assessment And Identified Status&quot; contains QualifyingEncounter ) then 2 
    else 4"></valueString>
                     </extension>
                     <extension url="displaySequence">
                        <valueInteger value="52"></valueInteger>
                     </extension>
                  </extension>
                  <name value="EffectiveDataRequirements"></name>
                  <status value="active"></status>
                  <type>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
                        <code value="module-definition"></code>
                     </coding>
                  </type>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="QICore model information"></display>
                     <resource value="http://hl7.org/fhir/Library/QICore-ModelInfo"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Library FHIRHelpers"></display>
                     <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Library QICoreCommon"></display>
                     <resource value="https://madie.cms.gov/Library/QICoreCommon|4.0.000"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Library CQMCommon"></display>
                     <resource value="https://madie.cms.gov/Library/CQMCommon|4.1.000"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Library SDE"></display>
                     <resource value="https://madie.cms.gov/Library/SupplementalDataElements|5.1.000"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Library Status"></display>
                     <resource value="https://madie.cms.gov/Library/Status|1.15.000"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Code system SNOMEDCT"></display>
                     <resource value="http://snomed.info/sct"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Code system ConditionClinicalStatusCodes"></display>
                     <resource value="http://terminology.hl7.org/CodeSystem/condition-clinical"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Code system ConditionVerificationStatusCodes"></display>
                     <resource value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Encounter Inpatient"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Hospice Care Referral or Admission"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Hospice Status"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Observation Services"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Emergency Department Visit"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Malnutrition Risk Screening"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.92"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Malnutrition Screening Finding of Not At Risk Result"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.34"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Malnutrition Screening Finding of At Risk Result"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.89"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Dietitian Referral"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Nutrition Assessment"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.21"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.96"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Nutrition Assessment Status Finding of Moderately Malnourished"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.47"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Nutrition Assessment Status Finding of Severely Malnourished"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.43"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Malnutrition Diagnosis"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Nutrition Care Plan"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.93"></resource>
                  </relatedArtifact>
                  <relatedArtifact>
                     <type value="depends-on"></type>
                     <display value="Value set Payer Type"></display>
                     <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"></resource>
                  </relatedArtifact>
                  <parameter>
                     <name value="Measurement Period"></name>
                     <use value="in"></use>
                     <min value="0"></min>
                     <max value="1"></max>
                     <type value="Period"></type>
                  </parameter>
                  <parameter>
                     <name value="Measure Population Exclusion"></name>
                     <use value="out"></use>
                     <min value="0"></min>
                     <max value="*"></max>
                     <type value="Resource"></type>
                  </parameter>
                  <parameter>
                     <name value="Initial Population"></name>
                     <use value="out"></use>
                     <min value="0"></min>
                     <max value="*"></max>
                     <type value="Resource"></type>
                  </parameter>
                  <parameter>
                     <name value="Measure Population"></name>
                     <use value="out"></use>
                     <min value="0"></min>
                     <max value="*"></max>
                     <type value="Resource"></type>
                  </parameter>
                  <parameter>
                     <name value="SDE Race"></name>
                     <use value="out"></use>
                     <min value="0"></min>
                     <max value="1"></max>
                     <type value="Resource"></type>
                  </parameter>
                  <parameter>
                     <name value="SDE Sex"></name>
                     <use value="out"></use>
                     <min value="0"></min>
                     <max value="1"></max>
                     <type value="Coding"></type>
                  </parameter>
                  <parameter>
                     <name value="SDE Payer Type"></name>
                     <use value="out"></use>
                     <min value="0"></min>
                     <max value="*"></max>
                     <type value="Resource"></type>
                  </parameter>
                  <parameter>
                     <name value="SDE Ethnicity"></name>
                     <use value="out"></use>
                     <min value="0"></min>
                     <max value="1"></max>
                     <type value="Resource"></type>
                  </parameter>
                  <dataRequirement>
                     <type value="Patient"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient"></profile>
                     <mustSupport value="birthDate"></mustSupport>
                     <mustSupport value="birthDate.value"></mustSupport>
                     <mustSupport value="url"></mustSupport>
                     <mustSupport value="extension"></mustSupport>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Encounter"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
                     <mustSupport value="type"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="period"></mustSupport>
                     <codeFilter>
                        <path value="type"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Encounter"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
                     <mustSupport value="type"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="period"></mustSupport>
                     <codeFilter>
                        <path value="type"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Encounter"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
                     <mustSupport value="type"></mustSupport>
                     <mustSupport value="period"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="hospitalization"></mustSupport>
                     <mustSupport value="hospitalization.dischargeDisposition"></mustSupport>
                     <mustSupport value="reasonCode"></mustSupport>
                     <codeFilter>
                        <path value="type"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="ServiceRequest"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest"></profile>
                     <mustSupport value="code"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="intent"></mustSupport>
                     <mustSupport value="intent.value"></mustSupport>
                     <mustSupport value="authoredOn"></mustSupport>
                     <mustSupport value="authoredOn.value"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="ServiceRequest"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest"></profile>
                     <mustSupport value="code"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="intent"></mustSupport>
                     <mustSupport value="intent.value"></mustSupport>
                     <mustSupport value="authoredOn"></mustSupport>
                     <mustSupport value="authoredOn.value"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Procedure"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"></profile>
                     <mustSupport value="code"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="performed"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Procedure"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"></profile>
                     <mustSupport value="code"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="performed"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Procedure"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"></profile>
                     <mustSupport value="code"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="performed"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.93"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Observation"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment"></profile>
                     <mustSupport value="code"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="effective"></mustSupport>
                     <mustSupport value="value"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.92"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Observation"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment"></profile>
                     <mustSupport value="code"></mustSupport>
                     <mustSupport value="status"></mustSupport>
                     <mustSupport value="status.value"></mustSupport>
                     <mustSupport value="effective"></mustSupport>
                     <mustSupport value="value"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.21"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Condition"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"></profile>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Condition"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"></profile>
                     <mustSupport value="code"></mustSupport>
                     <codeFilter>
                        <path value="code"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55"></valueSet>
                     </codeFilter>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Condition"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis"></profile>
                  </dataRequirement>
                  <dataRequirement>
                     <type value="Coverage"></type>
                     <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage"></profile>
                     <mustSupport value="type"></mustSupport>
                     <mustSupport value="period"></mustSupport>
                     <codeFilter>
                        <path value="type"></path>
                        <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"></valueSet>
                     </codeFilter>
                  </dataRequirement>
               </Library>
            </contained>
            <extension id="supplementalDataGuidance" url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-supplementalDataGuidance">
               <extension url="guidance">
                  <valueString value="For every patient evaluated by this measure also identify payer, race, ethnicity and sex"></valueString>
               </extension>
               <extension url="usage">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-data-usage"></system>
                        <code value="supplemental-data"></code>
                        <display value="Supplemental Data"></display>
                     </coding>
                     <text value="Supplemental Data Guidance"></text>
                  </valueCodeableConcept>
               </extension>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-definitionTerm">
               <extension url="term">
                  <valueString value="Malnutrition Diagnosis"></valueString>
               </extension>
               <extension url="definition">
                  <valueMarkdown value="A documented diagnosis that identifies and describes a specific nutrition problem(s) that can be resolved or improved through nutrition intervention(s), monitoring, and evaluation. For the inpatient or acute care setting, the Malnutrition Diagnosis is identified by the physician or other eligible clinician as defined by CMS based on the scope of practice regulations within the respective state, commonwealth, or territory of care delivery.
"></valueMarkdown>
               </extension>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-definitionTerm">
               <extension url="term">
                  <valueString value="Malnutrition Risk Screening"></valueString>
               </extension>
               <extension url="definition">
                  <valueMarkdown value="The process of identifying and referring those individuals and populations who are at risk for nutrition-related problems, are appropriate for nutrition care services, and would benefit from nutrition interventions. For the inpatient or acute care setting, the Malnutrition Risk Screening can be completed by any eligible healthcare clinician as defined by local, state and federal guidelines.
"></valueMarkdown>
               </extension>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-definitionTerm">
               <extension url="term">
                  <valueString value="Nutrition Assessment"></valueString>
               </extension>
               <extension url="definition">
                  <valueMarkdown value="A systematic approach for collecting, classifying, and synthesizing important and relevant data to describe nutritional status related nutritional problems, and their causes. This assessment includes review of the &quot;whole&quot; patient and evaluates the anthropometrics (i.e., body measurements and proportions), biochemical data (i.e., laboratory findings), clinical observations, and diet history (also known as 'ABCD'). For the inpatient or acute care setting, the Nutrition Assessment is performed by a RD or RDN.
"></valueMarkdown>
               </extension>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-definitionTerm">
               <extension url="term">
                  <valueString value="Nutrition Care Plan"></valueString>
               </extension>
               <extension url="definition">
                  <valueMarkdown value="A documented plan based on information collected during the Nutrition Assessment of individualized nutrition recommendations, interventions, and monitoring and evaluation plans that are directed toward resolving the Malnutrition Diagnosis by altering or eliminating the nutrition etiology. The Nutrition Care Plan may encompass the interventions of Food and Nutrient Delivery, Nutrition Education, Nutrition Counseling, Coordination of Nutrition Care, and Population Based Nutrition Action, along with a plan for monitoring and evaluation, and is documented by the RD or RDN.
"></valueMarkdown>
               </extension>
            </extension>
            <extension url="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements">
               <valueReference>
                  <reference value="#effective-data-requirements"></reference>
               </valueReference>
            </extension>
            <url value="https://madie.cms.gov/Measure/CMS986FHIRMalnutritionScore"></url>
            <identifier>
               <use value="usual"></use>
               <type>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"></system>
                     <code value="short-name"></code>
                     <display value="Short Name"></display>
                  </coding>
               </type>
               <system value="https://madie.cms.gov/measure/shortName"></system>
               <value value="CMS986FHIR"></value>
            </identifier>
            <identifier>
               <use value="official"></use>
               <type>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"></system>
                     <code value="version-independent"></code>
                     <display value="Version Independent"></display>
                  </coding>
               </type>
               <system value="urn:ietf:rfc:3986"></system>
               <value value="urn:uuid:eed68e80-b466-4369-be87-166ada45f7c5"></value>
            </identifier>
            <identifier>
               <use value="official"></use>
               <type>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"></system>
                     <code value="version-specific"></code>
                     <display value="Version Specific"></display>
                  </coding>
               </type>
               <system value="urn:ietf:rfc:3986"></system>
               <value value="urn:uuid:c3828a9c-88b0-4a19-8b78-bb07f56ed929"></value>
            </identifier>
            <identifier>
               <use value="official"></use>
               <type>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"></system>
                     <code value="endorser"></code>
                     <display value="Endorser"></display>
                  </coding>
               </type>
               <system value="https://madie.cms.gov/measure/cbeId"></system>
               <value value="3592e"></value>
               <assigner>
                  <display value="CMS Consensus Based Entity"></display>
               </assigner>
            </identifier>
            <identifier>
               <use value="official"></use>
               <type>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/artifact-identifier-type"></system>
                     <code value="publisher"></code>
                     <display value="Publisher"></display>
                  </coding>
               </type>
               <system value="https://madie.cms.gov/measure/cmsId"></system>
               <value value="986FHIR"></value>
               <assigner>
                  <display value="CMS"></display>
               </assigner>
            </identifier>
            <version value="1.0.000"></version>
            <name value="CMS986FHIRMalnutritionScore"></name>
            <title value="Malnutrition Care ScoreFHIR
"></title>
            <status value="active"></status>
            <experimental value="false"></experimental>
            <date value="2025-11-24T17:18:42+00:00"></date>
            <publisher value="Academy of Nutrition and Dietetics"></publisher>
            <contact>
               <telecom>
                  <system value="url"></system>
                  <value value="www.eatrightpro.org"></value>
               </telecom>
            </contact>
            <description value="This measure assesses the percentage of eligible encounters of adults aged 18 years and older at the start of the eligible encounter during the measurement period, with a length of stay equal to or greater than 24 hours, who received optimal malnutrition care where care performed was appropriate to the patient's level of malnutrition risk and severity. Malnutrition care best practices recommend that for each eligible encounter, adult inpatients are (1) screened for malnutrition risk or for a dietitian referral order to be placed, (2) assessed by a registered dietitian (RD) or registered dietitian nutritionist (RDN) to confirm findings of malnutrition risk, and if identified with a &quot;moderate&quot; or &quot;severe&quot; malnutrition status in the current performed nutrition assessment, (3) receive a &quot;moderate&quot; or &quot;severe&quot; malnutrition diagnosis by a physician or eligible clinician as defined by the Centers for Medicare \&amp; Medicaid Services (CMS), and (4) have a current nutrition care plan performed by an RD/RDN.
"></description>
            <purpose value="Percentage of hospitalizations where a patient 18 years of age or older, admitted for 24-hours or more, received optimal malnutrition care
"></purpose>
            <usage value="This measure is constructed of four clinically eligible components that are aggregated as an arithmetic average of eligible encounters and expressed as a percentage. The four populations used to calculate the four components may differ and the measure observations for the four components do not need to be performed sequentially. This dQM is an episode-based measure. An episode is defined as each eligible encounter with a length of stay of greater than or equal to 24 hours among individuals 18 years of age and older at the start of the inpatient encounter. This FHIR-based measure has been derived from the QDM-based measure: CMS986v5. Please refer to the HL7 QI-Core Implementation Guide (*https://hl7.org/fhir/us/qicore/STU6/* ) for more information on QI-Core and mapping recommendations from QDM to QI-Core STU 6. (*https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html*).
"></usage>
            <copyright value="Copyright (C) Academy of Nutrition and Dietetics 2025 Limited proprietary coding is contained in the measure specifications for convenience. Users of the proprietary code sets should obtain all necessary licenses from the owners of these code sets. LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc. ICD-10 copyright 2024 World Health Organization. This material contains SNOMED Clinical Terms (R) (SNOMED CT \[R\]) copyright 2004-2024. International Health Terminology Standards Development Organisation. All Rights Reserved.
"></copyright>
            <effectivePeriod>
               <start value="2026-01-01"></start>
               <end value="2026-12-31"></end>
            </effectivePeriod>
            <author>
               <name value="Academy of Nutrition and Dietetics"></name>
               <telecom>
                  <system value="url"></system>
                  <value value="www.eatrightpro.org"></value>
               </telecom>
            </author>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Compher, C., Jensen, G. L., Malone, A., Morgan, S., Becker, S., Cresta, L., Paul, A. M., \&amp; Steiber, A. (2024). Systematic Review of Content Validity and Meta-analysis of Predictive Validity for Clinical Outcomes Associated with Malnutrition Identified by The Academy of Nutrition and Dietetics and American Society for Parenteral and Enteral Nutrition Indicators of Malnutrition. *Journal of the Academy of Nutrition and Dietetics*. https://doi.org/10.1016/j.jand.2024.02.002
"></citation>
            </relatedArtifact>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Jimenez, E. Y., Lamers-Johnson, E., Long, J. M., Woodcock, L., Bliss, C., \&amp; Steiber, A. L. (2024). Predictive Validity of the Academy of Nutrition and Dietetics/American Society for Parental Nutrition Indicators to Diagnose Malnutrition and the Screening Tool for Risk on Nutritional Status and Growth among Hospitalized Children Relative to Medical Outcomes. *The Journal of Pediatrics*, 276, 114288. https://doi.org/10.1016/j.jpeds.2024.114288
"></citation>
            </relatedArtifact>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Lengfelder, L., Mahlke, S., Moore, L., Zhang, X., Williams, G., \&amp; Lee, J. (2022). Prevalence and Impact of Malnutrition on Length of stay, readmission, and Discharge Destination. *Journal of Parenteral and Enteral Nutrition*, 46(6). https://doi.org/10.1002/jpen.2322
"></citation>
            </relatedArtifact>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Pacetti, E. J., McMurray, D., \&amp; Baca, J. (2025). Quality Improvement in Acute Care Malnutrition: Impact on Payment and Patient Outcomes. *Journal of the Academy of Nutrition and Dietetics*, 125(9), S24-S35. https://doi.org/10.1016/j.jand.2025.05.018
"></citation>
            </relatedArtifact>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Swan, W. I., Pertel, D. G., Hotson, B., Lloyd, L., Orrevall, Y., Trostler, N., Vivanti, A., Howarter, K. B., \&amp; Papoutsakis, C. (2019). Nutrition Care Process (NCP) Update Part 2: Developing and Using the NCP Terminology to Demonstrate Efficacy of Nutrition Care and Related Outcomes. *Journal of the Academy of Nutrition and Dietetics*, 119(5), 840-855. https://doi.org/10.1016/j.jand.2018.10.025
"></citation>
            </relatedArtifact>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Trollebo, M. A., Tangvik, R. J., Skeie, E., Gronning, M. K., Nygard, O., Eagan, T. M. L., \&amp; Dierkes, J. (2024). Malnutrition as a prognostic factor for 2-year mortality in hospitalized patients in Norway: A matched cohort study. *Journal of Parenteral and Enteral Nutrition*, 48(3), 308-317. https://doi.org/10.1002/jpen.2619
"></citation>
            </relatedArtifact>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Mogensen, K.M., Malone, A., Becker, P., Cutrell, S., Frank, L., Gonzales, K., Hudson, L., Miller, S., Guenter, P. (2019) Academy of Nutrition and Dietetics/American Society for Parenteral and Enteral Nutrition Consensus Malnutrition Characteristics: Usability and Association With Outcomes. Nutrition in Clinical Practice, 34 (5), 657-665. https://doi.org/10.1002/ncp.10310
"></citation>
            </relatedArtifact>
            <relatedArtifact>
               <type value="citation"></type>
               <citation value="Mueller, C., Compher, C., Druyan, M.E., \&amp; the ASPEN Board of Directors. (2011). ASPEN clinical guidelines on nutrition screening, assessment, and intervention in adults: Journal of Parenteral and Enteral Nutrition, 35(1), 16-24. https://doi.org/10.1177/0148607110389335
"></citation>
            </relatedArtifact>
            <library value="https://madie.cms.gov/Library/CMS986FHIRMalnutritionScore"></library>
            <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 MEASURE AND SPECIFICATIONS ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND. Due to technical limitations, copyright is indicated by (C) or \[C\], registered trademarks are indicated by (R) or \[R\], and unregistered trademarks are indicated by (TM) or \[TM\].
"></disclaimer>
            <rationale value="Malnutrition has been documented in approximately one-third of patients in developed countries upon admission to the hospital, and, if left untreated, can significantly impact important clinical outcomes (Mogensen et al., 2019). Adult patients with malnutrition have a significantly longer hospital length of stay (LOS) and a significantly higher likelihood of 30-day readmission when compared to their well-nourished counterparts (Lengfelder et al., 2022). Furthermore, hospitalized adults with malnutrition have an increased likelihood of all-cause mortality within 2 years of diagnosis (Trollebo et al., 2024) and an increase in in-hospital death when compared to patients without a diagnosis of malnutrition (Compher et al., 2024). These consequences demonstrate the importance of addressing malnutrition in hospitalized patients to improve outcomes.

The components of this measure are supported by clinical guidance which recommend **(1) malnutrition screening** for patients admitted into the acute inpatient care setting; **(2) nutrition assessment** for patients identified at risk for malnutrition or with a dietitian referral order to form the basis for appropriate nutrition interventions; **(3) appropriate recognition, diagnosis, and documentation** of the nutrition status of a patient in order to **(4) address their condition with an appropriate plan of care** and communicate patient needs to other care providers (Swan et al., 2019).

The process for risk identification, assessment, diagnosis, and treatment of malnutrition necessitates a multi-disciplinary care team that begins with the identification of an initial risk population for a more thorough assessment by the RD/RDN. The RD/RDN, in turn, provides the necessary treatment recommendations to address nutrition problems utilizing a nutrition diagnosis and care plan, along with the clinical indicators that inform a medical diagnosis of malnutrition completed by a physician or eligible clinician as defined by CMS. The four measure observations individually provide a portion of the necessary information on the quality of care for patients at risk for or with malnutrition. Therefore, the four components are summed and averaged according to a patient's degree of malnutrition and/or malnutrition risk to determine an encounter-level Malnutrition Care Score.

High performance on this measure requires malnutrition risk screening and/or referral to RDNs for appropriate nutrition assessment for identified patients during the current hospitalization. For patients identified with moderate or severe malnutrition by nutrition assessment, best practice also recommends a medical diagnosis by a physician or other eligible clinician and the execution of the nutrition care plan by an RD/RDN. Evidence demonstrates that malnutrition pathways, which include a standardized protocol for screening, assessment, diagnosis, and care planning results in improved patient outcomes for malnourished patients (Pacetti et al., 2025).
"></rationale>
            <clinicalRecommendationStatement value="American Society for Parenteral and Enteral Nutrition (ASPEN) clinical guidelines on nutrition screening, assessment, and intervention in adults indicate that screening for nutrition risk is suggested for hospitalized patients (Mueller et al., 2011). This guideline places nutrition assessment and screening in the context of intervention as part of nutrition care. Screening those individuals at risk for malnutrition is the first step in nutrition care, as malnutrition risk, identified by nutrition screening, is associated with longer length of hospital stay, complications, and mortality. Malnutrition screening is also a predictor of mortality risk.

Additionally, the Academy of Nutrition and Dietetics-ASPEN Indicators of Malnutrition (AAIM) provide a framework with significant validity in diagnosing malnutrition in hospitalized patients and supporting evidence that suggests that malnourished patients have more complications, longer hospitalizations, greater incidence of 30-day readmission, and higher incidence of mortality than patients with optimal nutrition status (Compher et al., 2024; Jimenez et al., 2024).

Nutrition intervention is recommended for patients identified by assessment as at risk for malnutrition or malnourished. Nutrition intervention with associated monitoring and evaluation plans in patients identified as at risk for malnutrition or malnourished improves clinical outcomes. Nutrition interventions and their associated monitoring and evaluation plans in malnourished patients are associated with improved nutrition status, nutrient intake, physical function, and quality of life. Hospital readmissions, inpatient length of stay, and complications were reduced with increased nutrition support interventions.
"></clinicalRecommendationStatement>
            <group id="Group_1">
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"></system>
                        <code value="continuous-variable"></code>
                        <display value="Continuous Variable"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis">
                  <valueCode value="Encounter"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-type"></system>
                        <code value="intermediate-outcome"></code>
                        <display value="Intermediate Outcome"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"></system>
                        <code value="increase"></code>
                        <display value="Increased score indicates improvement"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <description value="Population Criteria 1
"></description>
               <population id="InitialPopulation_1">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="initial-population"></code>
                        <display value="Initial Population"></display>
                     </coding>
                  </code>
                  <description value="Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Initial Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulation_1">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population"></code>
                        <display value="Measure Population"></display>
                     </coding>
                  </code>
                  <description value="Equals Initial Population
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulationExclusion_1">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population-exclusion"></code>
                        <display value="Measure Population Exclusion"></display>
                     </coding>
                  </code>
                  <description value="Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population Exclusion"></expression>
                  </criteria>
               </population>
               <population id="MeasureObservation_1">
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
                     <valueCode value="Sum"></valueCode>
                  </extension>
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
                     <valueString value="MeasurePopulation_1"></valueString>
                  </extension>
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-observation"></code>
                        <display value="Measure Observation"></display>
                     </coding>
                  </code>
                  <description value="Component Measure 1: Eligible encounters for patients with a current &quot;Malnutrition Risk Screening&quot; performed by an eligible healthcare clinician or with a Dietitian Referral.

Measure Observation 1 is Encounters with Malnutrition Risk Screening or with a Dietitian Referral.

Measure Observation 1 identifies eligible encounters where a &quot;Malnutrition Risk Screening&quot; was performed during the encounter (including associated observation or emergency department encounters) with an identified Malnutrition Screening Finding of Not At Risk or At Risk Result. It also identifies an eligible encounter where there is a Dietitian Referral, whether there is a Malnutrition Risk Screening performed or not.
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Observation 1"></expression>
                  </criteria>
               </population>
            </group>
            <group id="Group_2">
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"></system>
                        <code value="continuous-variable"></code>
                        <display value="Continuous Variable"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis">
                  <valueCode value="Encounter"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-type"></system>
                        <code value="intermediate-outcome"></code>
                        <display value="Intermediate Outcome"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"></system>
                        <code value="increase"></code>
                        <display value="Increased score indicates improvement"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <description value="Nutrition Assessment
"></description>
               <population id="InitialPopulation_2">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="initial-population"></code>
                        <display value="Initial Population"></display>
                     </coding>
                  </code>
                  <description value="Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Initial Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulation_2">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population"></code>
                        <display value="Measure Population"></display>
                     </coding>
                  </code>
                  <description value="Equals Initial Population
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulationExclusion_2">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population-exclusion"></code>
                        <display value="Measure Population Exclusion"></display>
                     </coding>
                  </code>
                  <description value="Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population Exclusion"></expression>
                  </criteria>
               </population>
               <population id="MeasureObservation_2">
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
                     <valueCode value="Sum"></valueCode>
                  </extension>
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
                     <valueString value="MeasurePopulation_2"></valueString>
                  </extension>
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-observation"></code>
                        <display value="Measure Observation"></display>
                     </coding>
                  </code>
                  <description value="Component Measure 2: Eligible encounters for patients with a documented &quot;Nutrition Assessment&quot; performed by an RD/RDN, after a Malnutrition Screening Finding of At Risk Result or a Dietitian Referral order from a physician or eligible clinician during the current encounter. Measure Observation 2 includes Encounter With Most Recent Nutrition Assessment and Identified Status if the Encounter also contains Completed Malnutrition Risk Screening or Dietitian Referral Measure Observation 2 identifies eligible encounters in which a malnutrition risk screening with an At Risk result or a dietitian referral was completed during the encounter (or associated observation or emergency department encounters) and a Nutrition Assessment was subsequently completed with an identified Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished, Nutrition Assessment Status Finding of Moderately Malnourished, or Nutrition Assessment Status Finding of Severely Malnourished.
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Observation 2"></expression>
                  </criteria>
               </population>
            </group>
            <group id="Group_3">
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"></system>
                        <code value="continuous-variable"></code>
                        <display value="Continuous Variable"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis">
                  <valueCode value="Encounter"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-type"></system>
                        <code value="intermediate-outcome"></code>
                        <display value="Intermediate Outcome"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"></system>
                        <code value="increase"></code>
                        <display value="Increased score indicates improvement"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <description value="Malnutrition Diagnosis
"></description>
               <population id="InitialPopulation_3">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="initial-population"></code>
                        <display value="Initial Population"></display>
                     </coding>
                  </code>
                  <description value="Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Initial Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulation_3">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population"></code>
                        <display value="Measure Population"></display>
                     </coding>
                  </code>
                  <description value="Equals Initial Population
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulationExclusion_3">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population-exclusion"></code>
                        <display value="Measure Population Exclusion"></display>
                     </coding>
                  </code>
                  <description value="Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population Exclusion"></expression>
                  </criteria>
               </population>
               <population id="MeasureObservation_3">
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
                     <valueCode value="Sum"></valueCode>
                  </extension>
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
                     <valueString value="MeasurePopulation_3"></valueString>
                  </extension>
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-observation"></code>
                        <display value="Measure Observation"></display>
                     </coding>
                  </code>
                  <description value="Component Measure 3: Eligible encounters for patients with a documented &quot;Malnutrition Diagnosis&quot; based on the most recent Nutrition Assessment finding of Moderately Malnourished or Severely Malnourished. Measure Observation 3 includes Encounters with a most recent Nutrition Assessment and Identified Status of Moderately Malnourished or Severely Malnourished, that also identified an active medical malnutrition diagnosis during the encounter (including preceding observation or emergency department encounters) and a Malnutrition Risk Screening At Risk result or with a Dietitian Referral
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Observation 3"></expression>
                  </criteria>
               </population>
            </group>
            <group id="Group_4">
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"></system>
                        <code value="continuous-variable"></code>
                        <display value="Continuous Variable"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis">
                  <valueCode value="Encounter"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-type"></system>
                        <code value="intermediate-outcome"></code>
                        <display value="Intermediate Outcome"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"></system>
                        <code value="increase"></code>
                        <display value="Increased score indicates improvement"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <description value="Nutrition Care Plan
"></description>
               <population id="InitialPopulation_4">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="initial-population"></code>
                        <display value="Initial Population"></display>
                     </coding>
                  </code>
                  <description value="Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Initial Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulation_4">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population"></code>
                        <display value="Measure Population"></display>
                     </coding>
                  </code>
                  <description value="Equals Initial Population
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulationExclusion_4">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population-exclusion"></code>
                        <display value="Measure Population Exclusion"></display>
                     </coding>
                  </code>
                  <description value="Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population Exclusion"></expression>
                  </criteria>
               </population>
               <population id="MeasureObservation_4">
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
                     <valueCode value="Sum"></valueCode>
                  </extension>
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
                     <valueString value="MeasurePopulation_4"></valueString>
                  </extension>
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-observation"></code>
                        <display value="Measure Observation"></display>
                     </coding>
                  </code>
                  <description value="Component Measure 4: Eligible encounters for patients with a documented &quot;Nutrition Care Plan&quot; based on the most recent Nutrition Assessment finding of Moderately Malnourished or Severely Malnourished.

Measure Observation 4 identifies Encounters with a most recent Nutrition Assessment and Identified Status of Moderately Malnourished or Severely Malnourished, that also include a documented Nutrition Care Plan and a Malnutrition Risk Screening At Risk result or with a Dietitian Referral.

Measure Observation 4 identifies eligible encounters where a &quot;Nutrition Care Plan&quot; was performed during the encounter (including preceding observation or emergency department encounters).
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Observation 4"></expression>
                  </criteria>
               </population>
            </group>
            <group id="Group_5">
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"></system>
                        <code value="continuous-variable"></code>
                        <display value="Continuous Variable"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis">
                  <valueCode value="Encounter"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-type"></system>
                        <code value="intermediate-outcome"></code>
                        <display value="Intermediate Outcome"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"></system>
                        <code value="increase"></code>
                        <display value="Increased score indicates improvement"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <description value="Total Malnutrition Care Components
"></description>
               <population id="InitialPopulation_5">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="initial-population"></code>
                        <display value="Initial Population"></display>
                     </coding>
                  </code>
                  <description value="Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Initial Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulation_5">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population"></code>
                        <display value="Measure Population"></display>
                     </coding>
                  </code>
                  <description value="Equals Initial Population
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulationExclusion_5">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population-exclusion"></code>
                        <display value="Measure Population Exclusion"></display>
                     </coding>
                  </code>
                  <description value="Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population Exclusion"></expression>
                  </criteria>
               </population>
               <population id="MeasureObservation_5">
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
                     <valueCode value="Count"></valueCode>
                  </extension>
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
                     <valueString value="MeasurePopulation_5"></valueString>
                  </extension>
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-observation"></code>
                        <display value="Measure Observation"></display>
                     </coding>
                  </code>
                  <description value="Population 5 &quot;Measure Observation Total Malnutrition Components Score&quot; Calculations-For each eligible encounter, Population Criteria 5 represents the subtotal of Measure Observations performed for Population Criteria 1, 2, 3, and 4. Possible values may be 0, 1, 2, 3, or 4. Population 5 &quot;Measure Observation Total Malnutrition Components Score&quot; is (&quot;Measure Observation 1&quot; plus &quot;Measure Observation 2&quot; plus &quot;Measure Observation 3&quot; plus &quot;Measure Observation 4&quot;)
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Observation Total Malnutrition Components Score"></expression>
                  </criteria>
               </population>
            </group>
            <group id="Group_6">
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"></system>
                        <code value="continuous-variable"></code>
                        <display value="Continuous Variable"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis">
                  <valueCode value="Encounter"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-type"></system>
                        <code value="intermediate-outcome"></code>
                        <display value="Intermediate Outcome"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation">
                  <valueCodeableConcept>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"></system>
                        <code value="increase"></code>
                        <display value="Increased score indicates improvement"></display>
                     </coding>
                  </valueCodeableConcept>
               </extension>
               <description value="Encounter Malnutrition Care Score
"></description>
               <population id="InitialPopulation_6">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="initial-population"></code>
                        <display value="Initial Population"></display>
                     </coding>
                  </code>
                  <description value="Eligible encounters during the measurement period with length of stay of 24 hours or more among individuals 18 years of age and older at the start of the inpatient encounter
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Initial Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulation_6">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population"></code>
                        <display value="Measure Population"></display>
                     </coding>
                  </code>
                  <description value="Equals Initial Population
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population"></expression>
                  </criteria>
               </population>
               <population id="MeasurePopulationExclusion_6">
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-population-exclusion"></code>
                        <display value="Measure Population Exclusion"></display>
                     </coding>
                  </code>
                  <description value="Encounters with hospice care ordered during the inpatient qualifying encounter and encounters with a discharge disposition of hospice
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Population Exclusion"></expression>
                  </criteria>
               </population>
               <population id="MeasureObservation_6">
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-aggregateMethod">
                     <valueCode value="Average"></valueCode>
                  </extension>
                  <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-criteriaReference">
                     <valueString value="MeasurePopulation_6"></valueString>
                  </extension>
                  <code>
                     <coding>
                        <system value="http://terminology.hl7.org/CodeSystem/measure-population"></system>
                        <code value="measure-observation"></code>
                        <display value="Measure Observation"></display>
                     </coding>
                  </code>
                  <description value="Population 6 &quot;Measure Observation Total Malnutrition Care Score as Percentage&quot; Calculations:-For each eligible encounter, Population Criteria 6 represents the sum of performed Measure Observations 1, 2, 3, and 4 divided by the number of clinically eligible occurrences. Population 6 &quot;Measure Observation Total Malnutrition Care Score as Percentage&quot; is 100 multiplied by (&quot;Measure Observation Total Malnutrition Components Score&quot; divided by &quot;Total Malnutrition Care Score Eligible Occurrences&quot;). Possible values may be 0, 50, 75, or 100 percent. &quot;Total Malnutrition Care Score Eligible Occurrences&quot; is always 4 except in the following instances: -The &quot;Total Malnutrition Care Score Eligible Occurrences&quot; is 1 if ---A &quot;Malnutrition Risk Screening&quot; was performed and a Malnutrition Screening Finding of Not At Risk was identified and &quot;Dietitian Referral&quot; was not ordered. - The &quot;Total Malnutrition Care Score Eligible Occurrences&quot; is 2 ---If the most recent &quot;Nutrition Assessment&quot; performed has a result of Not or Mildly Malnourished. And, --- A &quot;Malnutrition Risk Screening&quot; was performed and a Malnutrition Screening Finding of At Risk was identified or a &quot;Dietitian Referral&quot; was ordered or a Dietitian Referral was ordered but a Nutrition Assessment was not performed.
"></description>
                  <criteria>
                     <language value="text/cql-identifier"></language>
                     <expression value="Measure Observation Total Malnutrition Care Score as Percentage"></expression>
                  </criteria>
               </population>
            </group>
            <supplementalData id="sde-payer-type">
               <usage>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/measure-data-usage"></system>
                     <code value="supplemental-data"></code>
                  </coding>
               </usage>
               <description value="SDE Payer Type
"></description>
               <criteria>
                  <language value="text/cql-identifier"></language>
                  <expression value="SDE Payer Type"></expression>
               </criteria>
            </supplementalData>
            <supplementalData id="sde-race">
               <usage>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/measure-data-usage"></system>
                     <code value="supplemental-data"></code>
                  </coding>
               </usage>
               <description value="SDE Race
"></description>
               <criteria>
                  <language value="text/cql-identifier"></language>
                  <expression value="SDE Race"></expression>
               </criteria>
            </supplementalData>
            <supplementalData id="sde-ethnicity">
               <usage>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/measure-data-usage"></system>
                     <code value="supplemental-data"></code>
                  </coding>
               </usage>
               <description value="SDE Ethnicity
"></description>
               <criteria>
                  <language value="text/cql-identifier"></language>
                  <expression value="SDE Ethnicity"></expression>
               </criteria>
            </supplementalData>
            <supplementalData id="sde-sex">
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-includeInReportType">
                  <valueCode value="individual"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-includeInReportType">
                  <valueCode value="subject-list"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-includeInReportType">
                  <valueCode value="summary"></valueCode>
               </extension>
               <extension url="http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-includeInReportType">
                  <valueCode value="data-collection"></valueCode>
               </extension>
               <usage>
                  <coding>
                     <system value="http://terminology.hl7.org/CodeSystem/measure-data-usage"></system>
                     <code value="supplemental-data"></code>
                  </coding>
               </usage>
               <description value="SDE Sex
"></description>
               <criteria>
                  <language value="text/cql-identifier"></language>
                  <expression value="SDE Sex"></expression>
               </criteria>
            </supplementalData>
         </Measure>
      </resource>
      <request>
         <method value="POST"></method>
         <url value="Measure/CMS986FHIRMalnutritionScore"></url>
      </request>
   </entry>
   <entry>
      <fullUrl value="https://madie.cms.gov/Library/CMS986FHIRMalnutritionScore"></fullUrl>
      <resource>
         <Library xmlns="http://hl7.org/fhir">
            <id value="CMS986FHIRMalnutritionScore"></id>
            <meta>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-executablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-json-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-xml-library"></profile>
            </meta>
            <language value="en"></language>
            <text>
               <status value="extensions"></status>
               <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
                  <table class="narrative-table"> 
                     <tbody> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Metadata</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Title</th> 
                           <td class="content-container">CMS986FHIRMalnutritionScore</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Version</th> 
                           <td class="content-container">1.0.000</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Identifier</th> 
                           <td class="content-container">CMS986FHIRMalnutritionScore</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Steward (Publisher)</th> 
                           <td class="content-container">Academy of Nutrition and Dietetics</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Description</th> 
                           <td class="content-container">CMS986FHIRMalnutritionScore</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/library-type#logic-library]</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: ServiceRequest 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, intent, intent.value, authoredOn, authoredOn.value 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: ServiceRequest 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, intent, intent.value, authoredOn, authoredOn.value 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Procedure 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, performed 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Procedure 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure 
                              <br></br>   
                              <em>Must Support Elements</em>: code, status, status.value, performed 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Condition 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns 
                              <br></br>   
                              <em>Must Support Elements</em>: code 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: code
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, period, status, status.value 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Library Content</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">CQL Content</th> 
                           <td> 
                              <a name="cql-content"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">library CMS986FHIRMalnutritionScore version '1.0.000'

using QICore version '6.0.0'

include FHIRHelpers version '4.4.000' called FHIRHelpers
include SupplementalDataElements version '5.1.000' called SDE
include QICoreCommon version '4.0.000' called QICoreCommon
include CQMCommon version '4.1.000' called CQMCommon
include Status version '1.15.000' called Status

valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "Hospice Status": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101'
valueset "Hospice Care Referral or Admission": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365'
valueset "Dietitian Referral": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91'
valueset "Malnutrition Diagnosis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55'
valueset "Malnutrition Risk Screening": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.92'
valueset "Malnutrition Screening Finding of At Risk Result": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.89'
valueset "Malnutrition Screening Finding of Not At Risk Result": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.34'
valueset "Nutrition Assessment": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.21'
valueset "Nutrition Assessment Status Finding of Moderately Malnourished": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.47'
valueset "Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.96'
valueset "Nutrition Assessment Status Finding of Severely Malnourished": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.43'
valueset "Nutrition Care Plan": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.93'

parameter "Measurement Period" Interval&lt;DateTime&gt;

context Patient

define "SDE Ethnicity":
  SDE."SDE Ethnicity"

define "SDE Payer Type":
  SDE."SDE Payer"

define "SDE Race":
  SDE."SDE Race"

define "SDE Sex":
  SDE."SDE Sex"

define "Measure Population":
  "Initial Population"

define "Initial Population":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.period ends during day of "Measurement Period"
      and AgeInYearsAt(date from start of EncounterInpatient.period) &gt;= 18
      and ( duration in hours of EncounterInpatient.period &gt;= 24 )
      and EncounterInpatient.status = 'finished'

define "Measure Population Exclusion":
  "Encounters with Discharge for Hospice Care"
    union "Encounters with Hospice during Eligible Encounter"

define "Encounters with Discharge for Hospice Care":
  "Measure Population" QualifyingEncounter
    where QualifyingEncounter.hospitalization.dischargeDisposition in "Hospice Care Referral or Admission"

/*define "Intervention Hospice Care":
    ( ["ServiceRequest": "Hospice Status"] HospiceStatusOrder
    where HospiceStatusOrder.status in { 'active', 'completed', 'on-hold' }
        and HospiceStatusOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
  )
    union ( ["Procedure": "Hospice Status"] HospiceStatusPerformed
            where HospiceStatusPerformed.status in { 'completed', 'in-progress' } 
           )

define "Encounters with Hospice during Eligible Encounter":
    "Measure Population" QualifyingEncounter
    with "Intervention Hospice Care" HospiceStatus
            such that Coalesce (start of HospiceStatus.performed.toInterval(), HospiceStatus.authoredOn) during day of QualifyingEncounter.hospitalizationWithObservation ( )
*/
//Testing definitions based on Codev comment



define "Intervention Hospice Care":
  ( ["ServiceRequest": "Hospice Status"] HospiceStatusOrder
      where HospiceStatusOrder.status in { 'active', 'completed', 'on-hold' }
        and HospiceStatusOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      return HospiceStatusOrder.authoredOn
  )
    union ( ["Procedure": "Hospice Status"] HospiceStatusPerformed
        where HospiceStatusPerformed.status in { 'completed', 'in-progress' }
        return start of HospiceStatusPerformed.performed.toInterval ( )
    )

define "Encounters with Hospice during Eligible Encounter":
  "Measure Population" QualifyingEncounter
    with "Intervention Hospice Care" HospiceStatusDate
      such that HospiceStatusDate during day of QualifyingEncounter.hospitalizationWithObservation ( )

/*define "Intervention Dietitian Referral":
( ["ServiceRequest": "Dietitian Referral"] DietitianReferralOrder
    where DietitianReferralOrder.status in { 'active', 'completed', 'on-hold' }
        and DietitianReferralOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
  
  )
    union ( ["Procedure": "Dietitian Referral"] DietitianReferralPerformed
            where DietitianReferralPerformed.status in { 'completed', 'in-progress' } 
           )

define "Encounters with Dietitian Referral":
    "Measure Population" QualifyingEncounter
    with "Intervention Dietitian Referral" DietitianReferral
            such that Coalesce (start of DietitianReferral.performed.toInterval(), DietitianReferral.authoredOn) during day of QualifyingEncounter.hospitalizationWithObservation ( )
*/
//New definition from Codev comments



define "Intervention Dietitian Referral":
  ( ["ServiceRequest": "Dietitian Referral"] DietitianReferralOrder
      where DietitianReferralOrder.status in { 'active', 'completed', 'on-hold' }
        and DietitianReferralOrder.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      return DietitianReferralOrder.authoredOn
  )
    union ( ["Procedure": "Dietitian Referral"] DietitianReferralPerformed
        where DietitianReferralPerformed.status in { 'completed', 'in-progress' }
        return start of DietitianReferralPerformed.performed.toInterval ( )
    )

define "Encounters with Dietitian Referral":
  "Measure Population" QualifyingEncounter
    with "Intervention Dietitian Referral" DietitianReferralDate
      such that DietitianReferralDate during day of QualifyingEncounter.hospitalizationWithObservation ( )

define "Encounters with Malnutrition Risk Screening":
  "Encounters with Malnutrition Risk Screening Not At Risk"
    union "Encounters with Malnutrition Risk Screening At Risk"

define "Encounters with Malnutrition Risk Screening or with Dietitian Referral":
  "Encounters with Malnutrition Risk Screening"
    union "Encounters with Dietitian Referral"

define "Encounters with Malnutrition Risk Screening Not At Risk":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Malnutrition Risk Screening"] MalnutritionRiskScreening
      such that MalnutritionRiskScreening.status in { 'final', 'amended', 'corrected' }
        and MalnutritionRiskScreening.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( MalnutritionRiskScreening.value as Concept in "Malnutrition Screening Finding of Not At Risk Result" )

define "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral":
  "Encounters with Malnutrition Risk Screening Not At Risk"
    except "Encounters with Dietitian Referral"

define "Encounters with Malnutrition Risk Screening At Risk":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Malnutrition Risk Screening"] MalnutritionRiskScreening
      such that MalnutritionRiskScreening.status in { 'final', 'amended', 'corrected' }
        and MalnutritionRiskScreening.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( MalnutritionRiskScreening.value as Concept in "Malnutrition Screening Finding of At Risk Result" )

define "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral":
  "Encounters with Malnutrition Risk Screening At Risk"
    union "Encounters with Dietitian Referral"
   

/*define function "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter Encounter):
  Max("Nutrition Assessment Performed" NutritionAssessmentTuple
    where NutritionAssessmentTuple.HospEncId = QualifyingEncounter.id
    return NutritionAssessmentTuple.NutrAssessTimingLatest
  )

define "Nutrition Assessment Performed":
    from
    "Measure Population" QualifyingEncounter,
    ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
        where NutritionAssessment.status in { 'final', 'amended', 'corrected' }
            and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
            and NutritionAssessment.value is not null
            return Tuple {
        HospEncId: QualifyingEncounter.id,
        NutrAssessTimingLatest: NutritionAssessment.effective.latest()
        }
*/
//Test definition per CODev feedback



define function "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter Encounter):
  Max(["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      where NutritionAssessment.status in { 'final', 'amended', 'corrected' }
        and NutritionAssessment.effective.toInterval() during QualifyingEncounter.hospitalizationWithObservation()
        and NutritionAssessment.value is not null
      return NutritionAssessment.effective.latest()
  )

define "Encounter With Most Recent Nutrition Assessment And Identified Status":
  "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      such that ( NutritionAssessment.status in { 'final', 'amended', 'corrected' }
          and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
          and ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished"
              or ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Moderately Malnourished" )
              or ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Severely Malnourished" )
          )
          and NutritionAssessment.effective.latest ( ) same day as "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter)
      )

define "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      such that NutritionAssessment.status in { 'final', 'amended', 'corrected' }
        and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
        and ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Moderately Malnourished"
            or NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Severely Malnourished"
        )
        and NutritionAssessment.effective.latest ( ) same day as "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter)

define "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished":
  "Measure Population" QualifyingEncounter
    with ["ObservationScreeningAssessment": "Nutrition Assessment"] NutritionAssessment
      such that ( NutritionAssessment.status in { 'final', 'amended', 'corrected' }
          and NutritionAssessment.effective.toInterval ( ) during QualifyingEncounter.hospitalizationWithObservation ( )
          and ( NutritionAssessment.value as Concept in "Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished" )
          and NutritionAssessment.effective.latest ( ) same day as "Last Nutrition Assessment Day During Encounter"(QualifyingEncounter)
      )

define "Encounters with Malnutrition Diagnosis":
  ( "Measure Population" QualifyingEncounter
      where exists ( "Has Malnutrition Diagnosis" MalnutritionDiagnosis
          where MalnutritionDiagnosis.prevalenceInterval ( ) overlaps day of QualifyingEncounter.hospitalizationWithObservation ( )
      )
  )
    union "Encounters With Encounter Diagnosis Of Malnutrition Diagnosis"

define "Has Malnutrition Diagnosis":
  [ConditionProblemsHealthConcerns: "Malnutrition Diagnosis"] MalnutritionDiagnosis
    where MalnutritionDiagnosis.prevalenceInterval ( ) overlaps "Measurement Period"
      and MalnutritionDiagnosis.isVerified ( )

define "Encounters With Encounter Diagnosis Of Malnutrition Diagnosis":
  "Measure Population" QualifyingEncounter
    where QualifyingEncounter.reasonCode in "Malnutrition Diagnosis"
      or QualifyingEncounter.encounterDiagnosis ( ).verified ( ).code in "Malnutrition Diagnosis"

define fluent function isVerified(condition Choice&lt;QICore.ConditionProblemsHealthConcerns, QICore.ConditionEncounterDiagnosis&gt;):
  condition.verificationStatus is not null implies ( condition.verificationStatus ~ QICoreCommon."confirmed"
      or condition.verificationStatus ~ QICoreCommon."unconfirmed"
      or condition.verificationStatus ~ QICoreCommon."provisional"
      or condition.verificationStatus ~ QICoreCommon."differential"
  )

define "Encounters with Nutrition Care Plan":
  "Measure Population" QualifyingEncounter
    with ["Procedure": "Nutrition Care Plan"] NutritionCarePlan
      such that NutritionCarePlan.status in { 'completed', 'in-progress' }
        and NutritionCarePlan.performed.earliest ( ) during QualifyingEncounter.hospitalizationWithObservation ( )

define function "Measure Observation 1"(MalnutritionRiskScreening Encounter):
  if "Encounters with Malnutrition Risk Screening or with Dietitian Referral" contains MalnutritionRiskScreening then 1 
    else 0

define function "Measure Observation 2"(NutritionAssessment Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains NutritionAssessment then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains NutritionAssessment then if "Encounter With Most Recent Nutrition Assessment And Identified Status" contains NutritionAssessment then 1 
    else 0 
    else 0

define function "Measure Observation 3"(MalnutritionDiagnosis Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains MalnutritionDiagnosis then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains MalnutritionDiagnosis then if "Encounters with Malnutrition Diagnosis" contains MalnutritionDiagnosis then if "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains MalnutritionDiagnosis then 0 
    else if "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished" contains MalnutritionDiagnosis then 1 
    else 0 
    else 0 
    else 0

define function "Measure Observation 4"(NutritionCarePlan Encounter):
  if "Encounters with Malnutrition Not At Risk Screening and without Dietitian Referral" contains NutritionCarePlan then 0 
    else if "Encounters with Malnutrition Risk Screening At Risk or with Dietitian Referral" contains NutritionCarePlan then if "Encounters with Nutrition Care Plan" contains NutritionCarePlan then if "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains NutritionCarePlan then 0 
    else if "Encounter With Most Recent Nutrition Assessment Status of Moderately Or Severely Malnourished" contains NutritionCarePlan then 1 
    else 0 
    else 0 
    else 0

define function "Total Malnutrition Care Score Eligible Occurrences"(QualifyingEncounter Encounter):
  if "Encounters with Malnutrition Risk Screening or with Dietitian Referral" contains QualifyingEncounter
    and "Encounters with Malnutrition Risk Screening Not At Risk" contains QualifyingEncounter
    and not ( "Encounters with Dietitian Referral" contains QualifyingEncounter ) then 1 
    else if ( "Encounters with Malnutrition Risk Screening or with Dietitian Referral" contains QualifyingEncounter
      and "Encounters with Malnutrition Risk Screening At Risk" contains QualifyingEncounter
      or "Encounters with Dietitian Referral" contains QualifyingEncounter
  )
    and "Encounter With Most Recent Nutrition Assessment Status of Not or Mildly Malnourished" contains QualifyingEncounter
    or not ( "Encounter With Most Recent Nutrition Assessment And Identified Status" contains QualifyingEncounter ) then 2 
    else 4

define function "Measure Observation Total Malnutrition Components Score"(QualifyingEncounter Encounter):
  Sum({ "Measure Observation 1"(QualifyingEncounter), "Measure Observation 2"(QualifyingEncounter), "Measure Observation 3"(QualifyingEncounter), "Measure Observation 4"(QualifyingEncounter) })

define function "Measure Observation Total Malnutrition Care Score as Percentage"(QualifyingEncounter Encounter):
  100 * ( "Measure Observation Total Malnutrition Components Score"(QualifyingEncounter) / "Total Malnutrition Care Score Eligible Occurrences"(QualifyingEncounter) )</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Generated using version 0.4.9 of the sample-content-ig Liquid templates</th> 
                        </tr> 
                     </tbody> 
                  </table> 
               </div>
            </text>
            <url value="https://madie.cms.gov/Library/CMS986FHIRMalnutritionScore"></url>
            <identifier>
               <use value="official"></use>
               <system value="https://madie.cms.gov/login"></system>
               <value value="CMS986FHIRMalnutritionScore"></value>
            </identifier>
            <version value="1.0.000"></version>
            <name value="CMS986FHIRMalnutritionScore"></name>
            <title value="CMS986FHIRMalnutritionScore"></title>
            <status value="active"></status>
            <experimental value="false"></experimental>
            <type>
               <coding>
                  <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
                  <code value="logic-library"></code>
               </coding>
            </type>
            <date value="2025-11-24T17:18:50+00:00"></date>
            <publisher value="Academy of Nutrition and Dietetics"></publisher>
            <description value="CMS986FHIRMalnutritionScore"></description>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="QICore model information"></display>
               <resource value="http://hl7.org/fhir/Library/QICore-ModelInfo"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library FHIRHelpers"></display>
               <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library QICoreCommon"></display>
               <resource value="https://madie.cms.gov/Library/QICoreCommon|4.0.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library CQMCommon"></display>
               <resource value="https://madie.cms.gov/Library/CQMCommon|4.1.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library SDE"></display>
               <resource value="https://madie.cms.gov/Library/SupplementalDataElements|5.1.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library Status"></display>
               <resource value="https://madie.cms.gov/Library/Status|1.15.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Encounter Inpatient"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Hospice Care Referral or Admission"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Hospice Status"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Malnutrition Risk Screening"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.92"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Malnutrition Screening Finding of Not At Risk Result"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.34"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Malnutrition Screening Finding of At Risk Result"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.89"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Dietitian Referral"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Nutrition Assessment"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.21"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Nutrition Assessment Status Finding of Well Nourished or Not Malnourished or Mildly Malnourished"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.96"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Nutrition Assessment Status Finding of Moderately Malnourished"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.47"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Nutrition Assessment Status Finding of Severely Malnourished"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.43"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Malnutrition Diagnosis"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Nutrition Care Plan"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.93"></resource>
            </relatedArtifact>
            <dataRequirement>
               <type value="ServiceRequest"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest"></profile>
               <mustSupport value="code"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="intent"></mustSupport>
               <mustSupport value="intent.value"></mustSupport>
               <mustSupport value="authoredOn"></mustSupport>
               <mustSupport value="authoredOn.value"></mustSupport>
               <codeFilter>
                  <path value="code"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="ServiceRequest"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest"></profile>
               <mustSupport value="code"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="intent"></mustSupport>
               <mustSupport value="intent.value"></mustSupport>
               <mustSupport value="authoredOn"></mustSupport>
               <mustSupport value="authoredOn.value"></mustSupport>
               <codeFilter>
                  <path value="code"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Procedure"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"></profile>
               <mustSupport value="code"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="performed"></mustSupport>
               <codeFilter>
                  <path value="code"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.101"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Procedure"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"></profile>
               <mustSupport value="code"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="performed"></mustSupport>
               <codeFilter>
                  <path value="code"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.91"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Condition"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"></profile>
               <mustSupport value="code"></mustSupport>
               <codeFilter>
                  <path value="code"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.55"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Encounter"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
               <mustSupport value="type"></mustSupport>
               <mustSupport value="period"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <codeFilter>
                  <path value="type"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"></valueSet>
               </codeFilter>
            </dataRequirement>
            <content>
               <contentType value="text/cql"></contentType>
               <data value="[encoded data, 23632 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+json"></contentType>
               <data value="[encoded data, 1029844 characters]"></data>
            </content>
         </Library>
      </resource>
      <request>
         <method value="POST"></method>
         <url value="Library/CMS986FHIRMalnutritionScore"></url>
      </request>
   </entry>
   <entry>
      <fullUrl value="https://madie.cms.gov/Library/CQMCommon"></fullUrl>
      <resource>
         <Library xmlns="http://hl7.org/fhir">
            <id value="CQMCommon"></id>
            <meta>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-executablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-json-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-xml-library"></profile>
            </meta>
            <language value="en"></language>
            <text>
               <status value="extensions"></status>
               <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
                  <table class="narrative-table"> 
                     <tbody> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Metadata</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Title</th> 
                           <td class="content-container">CQMCommon</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Version</th> 
                           <td class="content-container">4.1.000</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Identifier</th> 
                           <td class="content-container">67dda0df9e9ab93ec36dad4f</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Steward (Publisher)</th> 
                           <td class="content-container">ICF</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Description</th> 
                           <td class="content-container">This library contains declarations that are commonly used in eCQMs and shared across the logic of multiple measures, such as the Encounter Inpatient value set, and the Inpatient Encounter population criteria definition. This library also contains functions for calculating hospitalization duration as well as hospital arrival and departure times.</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/library-type#logic-library]</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Location 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-location 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Condition 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Condition 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, status, status.value, period, rank, rank.value, use, condition, location, location.type, diagnosis, diagnosis.code, onAdmission 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, status, status.value, period, rank, rank.value, use, condition, location, location.type, diagnosis, diagnosis.code, onAdmission 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, status, status.value, period, rank, rank.value, use, condition, location, location.type, diagnosis, diagnosis.code, onAdmission 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: type, period, rank, rank.value, use, condition, location, location.type, diagnosis, diagnosis.code, onAdmission 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Encounter 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter 
                              <br></br>   
                              <em>Must Support Elements</em>: period, rank, rank.value, use, condition, location, location.type, diagnosis, diagnosis.code, type, onAdmission 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Claim 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-claim 
                              <br></br>   
                              <em>Must Support Elements</em>: status, status.value, use, use.value, item 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: MedicationRequest 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest 
                              <br></br>   
                              <em>Must Support Elements</em>: medication 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Medication 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication 
                              <br></br>   
                              <em>Must Support Elements</em>: code 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Library Content</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">CQL Content</th> 
                           <td> 
                              <a name="cql-content"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">library CQMCommon version '4.1.000'

using QICore version '6.0.0'

include FHIRHelpers version '4.4.000' called FHIRHelpers
include QICoreCommon version '4.0.000' called QICoreCommon

codesystem DiagnosisRole: 'http://terminology.hl7.org/CodeSystem/diagnosis-role'
codesystem "Diagnosis Type": 'http://terminology.hl7.org/CodeSystem/ex-diagnosistype'
codesystem "Procedure Type": 'http://terminology.hl7.org/CodeSystem/ex-procedure-type'
codesystem "Present On Admission Indicators": 'https://www.cms.gov/Medicare/Medicare-Fee-for-Service-Payment/HospitalAcqCond/Coding'

valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292'
valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "Intensive Care Unit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1029.206'
valueset "Observation Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143'
valueset "Outpatient Surgery Service": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38'
valueset "Present on Admission or Clinically Undetermined": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.197'

code "Billing": 'billing' from DiagnosisRole display 'Billing'
code "Admitting Diagnosis": 'admitting' from "Diagnosis Type" display 'Admitting Diagnosis'
code "Clinical Diagnosis": 'clinical' from "Diagnosis Type" display 'Clinical Diagnosis'
code "Differential Diagnosis": 'differential' from "Diagnosis Type" display 'Differential Diagnosis'
code "Discharge Diagnosis": 'discharge' from "Diagnosis Type" display 'Discharge Diagnosis'
code "Laboratory Diagnosis": 'laboratory' from "Diagnosis Type" display 'Laboratory Diagnosis'
code "Nursing Diagnosis": 'nursing' from "Diagnosis Type" display 'Nursing Diagnosis'
code "Prenatal Diagnosis": 'prenatal' from "Diagnosis Type" display 'Prenatal Diagnosis'
code "Principal Diagnosis": 'principal' from "Diagnosis Type" display 'Principal Diagnosis'
code "Radiology Diagnosis": 'radiology' from "Diagnosis Type" display 'Radiology Diagnosis'
code "Remote Diagnosis": 'remote' from "Diagnosis Type" display 'Remote Diagnosis'
code "Retrospective Diagnosis": 'retrospective' from "Diagnosis Type" display 'Retrospetive Diagnosis'
code "Self Diagnosis": 'self' from "Diagnosis Type" display 'Self Diagnosis'
code "Primary procedure": 'primary' from "Procedure Type" display 'Primary procedure'
code "POA-Y": 'Y' from "Present On Admission Indicators" display 'POA-Y'
code "POA-N": 'N' from "Present On Admission Indicators" display 'POA-N'
code "POA-W": 'W' from "Present On Admission Indicators" display 'POA-W'
code "POA-1": '1' from "Present On Admission Indicators" display 'POA-1'
code "POA-U": 'U' from "Present On Admission Indicators" display 'POA-U'

parameter "Measurement Period" Interval&lt;DateTime&gt;

context Patient

define "Inpatient Encounter":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.status = 'finished'
      and EncounterInpatient.period ends during day of "Measurement Period"

/*
@description: Returns an interval of date values extracted from the input interval of date-time values
@comment: This function returns an interval constructed using the `date from` extractor on the start
and end values of the input date-time interval. Note that using a precision specifier such as `day of`
as part of a timing phrase is preferred to communicate intent to perform day-level comparison, as well
as for general readability.
*/
define function "ToDateInterval"(period Interval&lt;DateTime&gt;):
  Interval[date from start of period, date from end of period]

/*
@description: Calculates the difference in calendar days between the start and end of the given interval.
@deprecated: This function in deprecated. Use the fluent function `lengthInDays()` instead.
*/
define function "LengthInDays"(Value Interval&lt;DateTime&gt; ):
  difference in days between start of Value and end of Value

/*
@description: Calculates the difference in calendar days between the start and end of the given interval.
*/
define fluent function lengthInDays(Value Interval&lt;DateTime&gt; ):
  difference in days between start of Value and end of Value

/*
@description: Returns the most recent emergency department visit, if any, that occurs 1 hour or less prior to the given encounter.
@deprecated: This function is deprecated. Use the fluent function `edVisit()` instead.
*/
define function "ED Visit"(TheEncounter Encounter ):
  Last(
    [Encounter: "Emergency Department Visit"] EDVisit
      where EDVisit.status = 'finished'
        and EDVisit.period ends 1 hour or less on or before start of TheEncounter.period
      sort by end of period
    )

/*
@description: Returns the most recent emergency department visit, if any, that occurs 1 hour or less prior to the given encounter.
*/
define fluent function edVisit(TheEncounter Encounter ):
  Last(
    [Encounter: "Emergency Department Visit"] EDVisit
      where EDVisit.status = 'finished'
        and EDVisit.period ends 1 hour or less on or before start of TheEncounter.period
      sort by end of period
    )

/*
@description: Hospitalization returns the total interval for admission to discharge for the given encounter, or for the admission of any immediately prior emergency department visit to the discharge of the given encounter.
@deprecated: This function is deprecated. Use the fluent function `hospitalization()` instead.
*/
define function "Hospitalization"(TheEncounter Encounter ):
  ( "ED Visit"(TheEncounter) ) X
    return
        if X is null then TheEncounter.period
        else Interval[start of X.period, end of TheEncounter.period)

/*
@description: Hospitalization returns the total interval for admission to discharge for the given encounter, or for the admission of any immediately prior emergency department visit to the discharge of the given encounter.
*/
define fluent function hospitalization(TheEncounter Encounter ):
  (TheEncounter."edVisit"()) X
    return
        if X is null then TheEncounter.period
        else Interval[start of X.period, end of TheEncounter.period]

/*
@description: Returns list of all locations within an encounter, including locations for immediately prior ED visit.
@deprecated: This function is deprecated. Use the fluent function `hospitalizationLocations()` instead.
*/
define function "Hospitalization Locations"(TheEncounter Encounter ):
  ( "ED Visit"(TheEncounter) ) EDEncounter
    return
        if EDEncounter is null then TheEncounter.location
        else flatten { EDEncounter.location, TheEncounter.location }

/*
@description: Returns list of all locations within an encounter, including locations for immediately prior ED visit.
*/
define fluent function hospitalizationLocations(TheEncounter Encounter ):
  ( TheEncounter."edVisit"()) EDEncounter
    return
        if EDEncounter is null then TheEncounter.location
        else flatten { EDEncounter.location, TheEncounter.location }

/*
@description: Returns the length of stay in days (i.e. the number of days between admission and discharge) for the given encounter, or from the admission of any immediately prior emergency department visit to the discharge of the encounter
@deprecated: This function is deprecated. Use the fluent function `hospitalizationLengthOfStay()` instead.
*/
define function "Hospitalization Length of Stay"(TheEncounter Encounter ):
  LengthInDays("Hospitalization"(TheEncounter))

/*
@description: Returns the length of stay in days (i.e. the number of days between admission and discharge) for the given encounter, or from the admission of any immediately prior emergency department visit to the discharge of the encounter
*/
define fluent function hospitalizationLengthOfStay(TheEncounter Encounter ):
   TheEncounter."hospitalization"()."lengthInDays"()

/*
@description: Returns admission time for an encounter or for immediately prior emergency department visit.
@deprecated: This function is deprecated. Use the fluent function `hospitalAdmissionTime()` instead.
*/
define function "Hospital Admission Time"(TheEncounter Encounter ):
  start of "Hospitalization"(TheEncounter)

/*
@description: Returns admission time for an encounter or for immediately prior emergency department visit.
*/
define fluent function hospitalAdmissionTime(TheEncounter Encounter ):
  start of (TheEncounter."hospitalization"())

/*
@description: Hospital Discharge Time returns the discharge time for an encounter
@deprecated: This function is deprecated. Use the fluent function `hospitalDischargeTime()` instead.
*/
define function "Hospital Discharge Time"(TheEncounter Encounter ):
  end of TheEncounter.period

/*
@description: Hospital Discharge Time returns the discharge time for an encounter
*/
define fluent function hospitalDischargeTime(TheEncounter Encounter ):
  end of TheEncounter.period

/*
@description: Returns earliest arrival time for an encounter including any prior ED visit.
@deprecated: This function is deprecated. Use the fluent function `hospitalArrivalTime()` instead.
*/
define function "Hospital Arrival Time"(TheEncounter Encounter ):
  start of First(
  	    ("Hospitalization Locations"(TheEncounter) ) HospitalLocation
  			sort by start of period
  	).period

/*
@description: Returns earliest arrival time for an encounter including any prior ED visit.
*/
define fluent function hospitalArrivalTime(TheEncounter Encounter ):
  start of First(
  	    (TheEncounter."hospitalizationLocations"()) HospitalLocation
  			sort by start of period
  	).period

/*
@description: Returns the latest departure time for encounter including any prior ED visit.
@deprecated: This function is deprecated. Use the fluent function `hospitalDepartureTime()` instead.
*/
define function "Hospital Departure Time"(TheEncounter Encounter):
	end of Last(
	    ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation
			sort by start of period
	).period

/*
@description: Returns the latest departure time for encounter including any prior ED visit.
*/
define fluent function hospitalDepartureTime(TheEncounter Encounter):
	end of Last(
	    (TheEncounter."hospitalizationLocations"()) HospitalLocation
			sort by start of period
	).period

/*
@description: Returns the emergency department arrival time for the encounter.
@deprecated. This function is deprecated. Use the fluent function `emergencyDepartmentArrivalTime()` instead.
*/
define function "Emergency Department Arrival Time"(TheEncounter Encounter):
	start of (
	    singleton from (
	        ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation
				where GetLocation(HospitalLocation.location).type in "Emergency Department Visit"
		)
	).period

/*
@description: Returns the emergency department arrival time for the encounter.
*/
define fluent function emergencyDepartmentArrivalTime(TheEncounter Encounter):
	start of (
	    singleton from (
	        ( (TheEncounter."hospitalizationLocations"()) ) HospitalLocation
				where GetLocation(HospitalLocation.location).type in "Emergency Department Visit"
		)
	).period

/*
@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 "HospitalizationWithObservationAndOutpatientSurgeryService"(TheEncounter "Encounter" ):
  TheEncounter Visit
	  let ObsVisit: Last([Encounter: "Observation Services"] 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: "Emergency Department Visit"] 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: "Outpatient Surgery Service"] 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]

/*
@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 "Encounter" ):
  TheEncounter Visit
	  let ObsVisit: Last([Encounter: "Observation Services"] 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: "Emergency Department Visit"] 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: "Outpatient Surgery Service"] 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]

/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
@deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservation()` instead.
*/
define function "HospitalizationWithObservation"(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: "Observation Services"] 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: "Emergency Department Visit"] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]

/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
*/
define fluent function hospitalizationWithObservation(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: "Observation Services"] 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: "Emergency Department Visit"] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]

/*
@description: Hospitalization with Observation Length of Stay returns the length in days from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
@deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservationLengthofStay()` instead.
*/
define function "HospitalizationWithObservationLengthofStay"(TheEncounter "Encounter" ):
  "LengthInDays"("HospitalizationWithObservation"(TheEncounter))

/*
@description: Hospitalization with Observation Length of Stay returns the length in days from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
*/
define fluent function hospitalizationWithObservationLengthofStay(TheEncounter "Encounter" ):
  ((TheEncounter."hospitalizationWithObservation"()."lengthInDays"()))

/*
@description: First Inpatient Intensive Care Unit returns the first intensive care unit for the given encounter, without considering any immediately prior emergency department visit.
@deprecated: This function is deprecated. Use the fluent function `firstInpatientIntensiveCareUnit()` instead.
*/
define function "FirstInpatientIntensiveCareUnit"(Encounter Encounter ):
  First((Encounter.location)HospitalLocation
  			where GetLocation(HospitalLocation.location).type in "Intensive Care Unit"
  				and HospitalLocation.period during Encounter.period
  			sort by start of period
  	)

/*
@description: First Inpatient Intensive Care Unit returns the first intensive care unit for the given encounter, without considering any immediately prior emergency department visit.
*/
define fluent function firstInpatientIntensiveCareUnit(Encounter Encounter ):
  First((Encounter.location)HospitalLocation
  			where GetLocation(HospitalLocation.location).type in "Intensive Care Unit"
  				and HospitalLocation.period during Encounter.period
  			sort by start of period
  	)

/*
@description: Returns the Condition resource referenced by the `diagnosis.condition` element of the Encounter
@deprecated: This function is deprecated. Use the fluent function `encounterDiagnosis()` instead.
*/
define function "EncounterDiagnosis"(Encounter Encounter ):
  Encounter.diagnosis D
	return singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where D.condition.references(C.id))

/*  
@description: Returns the Condition resources referenced by the diagnosis element of the Encounter  
*/
define fluent function encounterDiagnosis(Encounter Encounter ):
  Encounter.reasonReference D
    return singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where D.references(C.id))


/*
@description: Returns the Condition resource for the given reference
@deprecated: This function is deprecated. Use the fluent function `getCondition()` instead
*/
define function "GetCondition"(reference Reference):
  singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where reference.references(C.id))

/*
@description: Returns the Condition resource for the given reference
*/
define fluent function getCondition(reference Reference):
  singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where reference.references(C.id))

/*
@description: Returns the condition that is specified as the principal diagnosis for the encounter
@deprecated: This function is deprecated. Use the fluent function `principalDiagnosis()` instead.
*/
define function "PrincipalDiagnosis"(Encounter Encounter):
	singleton from (
	(Encounter.diagnosis D where D.rank = 1 and D.use ~ "Billing") PD
      return singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where PD.condition.references(C.id))
	)

/*
@description: Returns the claim diagnosis element that is specified as the principal diagnosis for the encounter
 @comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
*/
define fluent function principalDiagnosis(encounter Encounter):
singleton from (
     (encounter.claimDiagnosis()) CD
       where CD.type.includesCode("Principal Diagnosis")
   )
/*
@description: Returns the claim diagnosis elements for the given encounter
@comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
*/
define fluent function claimDiagnosis(encounter Encounter):
  encounter E
    let 
      claim: ([Claim] C where C.status = 'active' and C.use = 'claim' and exists (C.item I where I.encounter.references(E))),
      claimItem: (claim.item I where I.encounter.references(E))
    return claim.diagnosis D where D.sequence in claimItem.diagnosisSequence


/*
 @description: Returns the condition that is specified as the principal diagnosis for the encounter and has a code in the given valueSet.
 @comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
 */
 define fluent function hasPrincipalDiagnosisOf(encounter Encounter, valueSet ValueSet):
   (encounter.principalDiagnosis()) PD
     return PD.diagnosis in valueSet
       or PD.diagnosis.getCondition().code in valueSet

/*
 @description: Returns true if the given diagnosis is present on admission, based on the given poaValueSet
 @comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
 */
 define fluent function isDiagnosisPresentOnAdmission(encounter Encounter, diagnosisValueSet ValueSet, poaValueSet ValueSet):
   exists (
     (encounter.claimDiagnosis()) CD
       where CD.onAdmission in poaValueSet
         and (
           CD.diagnosis in diagnosisValueSet
             or CD.diagnosis.getCondition().code in diagnosisValueSet
         )
   )

/*
@description: Returns the Location resource specified by the given reference
@deprecated: This function is deprecated. Use the fluent function `getLocation()` instead.
*/
define function "GetLocation"(reference Reference):
  singleton from (
    [Location] L where reference.references(L)
  )

/*
@description: Returns the Location resource specified by the given reference.
*/
define fluent function getLocation(reference Reference):
  singleton from (
    [Location] L where reference.references(L)
  )

/*
@description: Returns the medication code for the given MedicationRequest
@deprecated: This function is deprecated. Use the fluent function `getMedicationCode()` instead.
*/
define function "GetMedicationCode"(request MedicationRequest):
  if request.medication is Concept then
  	  request.medication as Concept
  	else
  	  (singleton from ([Medication] M where request.medication.references(M))).code

/*
@description: Returns the medication code for the given MedicationRequest
*/
define fluent function getMedicationCode(request MedicationRequest):
  if request.medication is Concept then
  	  request.medication as Concept
  	else
  	  (singleton from ([Medication] M where request.medication.references(M))).code
  	  
/*
@description: Returns the claim procedure elements for the given encounter
*/
define fluent function principalProcedure(encounter Encounter):  	  
  	 encounter E
  	 let 
        claim: [Claim] C where C.status = 'active' and C.use = 'claim' and exists (C.item I where I.encounter.references(E)),
        claimItem: claim.item I where I.encounter.references(E),
        princProcedure: singleton from (claim.procedure P where P.sequence in claimItem.procedureSequence and P.type.includesCode("Primary procedure"))
    return princProcedure</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Generated using version 0.4.9 of the sample-content-ig Liquid templates</th> 
                        </tr> 
                     </tbody> 
                  </table> 
               </div>
            </text>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="billing"></code>
                  <display value="Billing"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="admitting"></code>
                  <display value="Admitting Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="clinical"></code>
                  <display value="Clinical Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="differential"></code>
                  <display value="Differential Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="discharge"></code>
                  <display value="Discharge Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="laboratory"></code>
                  <display value="Laboratory Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="nursing"></code>
                  <display value="Nursing Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="prenatal"></code>
                  <display value="Prenatal Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="principal"></code>
                  <display value="Principal Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="radiology"></code>
                  <display value="Radiology Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="remote"></code>
                  <display value="Remote Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="retrospective"></code>
                  <display value="Retrospective Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></system>
                  <code value="self"></code>
                  <display value="Self Diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/ex-procedure-type"></system>
                  <code value="primary"></code>
                  <display value="Primary procedure"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="https://www.cms.gov/Medicare/Medicare-Fee-for-Service-Payment/HospitalAcqCond/Coding"></system>
                  <code value="Y"></code>
                  <display value="POA-Y"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="https://www.cms.gov/Medicare/Medicare-Fee-for-Service-Payment/HospitalAcqCond/Coding"></system>
                  <code value="N"></code>
                  <display value="POA-N"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="https://www.cms.gov/Medicare/Medicare-Fee-for-Service-Payment/HospitalAcqCond/Coding"></system>
                  <code value="W"></code>
                  <display value="POA-W"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="https://www.cms.gov/Medicare/Medicare-Fee-for-Service-Payment/HospitalAcqCond/Coding"></system>
                  <code value="1"></code>
                  <display value="POA-1"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="https://www.cms.gov/Medicare/Medicare-Fee-for-Service-Payment/HospitalAcqCond/Coding"></system>
                  <code value="U"></code>
                  <display value="POA-U"></display>
               </valueCoding>
            </extension>
            <url value="https://madie.cms.gov/Library/CQMCommon"></url>
            <identifier>
               <use value="official"></use>
               <system value="https://madie.cms.gov/login"></system>
               <value value="67dda0df9e9ab93ec36dad4f"></value>
            </identifier>
            <version value="4.1.000"></version>
            <name value="CQMCommon"></name>
            <title value="CQMCommon"></title>
            <status value="active"></status>
            <experimental value="false"></experimental>
            <type>
               <coding>
                  <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
                  <code value="logic-library"></code>
               </coding>
            </type>
            <date value="2025-11-24T17:18:53+00:00"></date>
            <publisher value="ICF"></publisher>
            <description value="This library contains declarations that are commonly used in eCQMs and shared across the logic of multiple measures, such as the Encounter Inpatient value set, and the Inpatient Encounter population criteria definition. This library also contains functions for calculating hospitalization duration as well as hospital arrival and departure times."></description>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="QICore model information"></display>
               <resource value="http://hl7.org/fhir/Library/QICore-ModelInfo"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library QICoreCommon"></display>
               <resource value="https://madie.cms.gov/Library/QICoreCommon|4.0.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library FHIRHelpers"></display>
               <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system DiagnosisRole"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system Diagnosis Type"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/ex-diagnosistype"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system Procedure Type"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/ex-procedure-type"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Observation Services"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Emergency Department Visit"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Outpatient Surgery Service"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Encounter Inpatient"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Intensive Care Unit"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1029.206"></resource>
            </relatedArtifact>
            <dataRequirement>
               <type value="Location"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-location"></profile>
            </dataRequirement>
            <dataRequirement>
               <type value="Condition"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis"></profile>
            </dataRequirement>
            <dataRequirement>
               <type value="Condition"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"></profile>
            </dataRequirement>
            <dataRequirement>
               <type value="Encounter"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
               <mustSupport value="type"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="period"></mustSupport>
               <mustSupport value="rank"></mustSupport>
               <mustSupport value="rank.value"></mustSupport>
               <mustSupport value="use"></mustSupport>
               <mustSupport value="condition"></mustSupport>
               <mustSupport value="location"></mustSupport>
               <mustSupport value="location.type"></mustSupport>
               <mustSupport value="diagnosis"></mustSupport>
               <mustSupport value="diagnosis.code"></mustSupport>
               <mustSupport value="onAdmission"></mustSupport>
               <codeFilter>
                  <path value="type"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Encounter"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
               <mustSupport value="type"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="period"></mustSupport>
               <mustSupport value="rank"></mustSupport>
               <mustSupport value="rank.value"></mustSupport>
               <mustSupport value="use"></mustSupport>
               <mustSupport value="condition"></mustSupport>
               <mustSupport value="location"></mustSupport>
               <mustSupport value="location.type"></mustSupport>
               <mustSupport value="diagnosis"></mustSupport>
               <mustSupport value="diagnosis.code"></mustSupport>
               <mustSupport value="onAdmission"></mustSupport>
               <codeFilter>
                  <path value="type"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Encounter"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
               <mustSupport value="type"></mustSupport>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="period"></mustSupport>
               <mustSupport value="rank"></mustSupport>
               <mustSupport value="rank.value"></mustSupport>
               <mustSupport value="use"></mustSupport>
               <mustSupport value="condition"></mustSupport>
               <mustSupport value="location"></mustSupport>
               <mustSupport value="location.type"></mustSupport>
               <mustSupport value="diagnosis"></mustSupport>
               <mustSupport value="diagnosis.code"></mustSupport>
               <mustSupport value="onAdmission"></mustSupport>
               <codeFilter>
                  <path value="type"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Encounter"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
               <mustSupport value="type"></mustSupport>
               <mustSupport value="period"></mustSupport>
               <mustSupport value="rank"></mustSupport>
               <mustSupport value="rank.value"></mustSupport>
               <mustSupport value="use"></mustSupport>
               <mustSupport value="condition"></mustSupport>
               <mustSupport value="location"></mustSupport>
               <mustSupport value="location.type"></mustSupport>
               <mustSupport value="diagnosis"></mustSupport>
               <mustSupport value="diagnosis.code"></mustSupport>
               <mustSupport value="onAdmission"></mustSupport>
               <codeFilter>
                  <path value="type"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38"></valueSet>
               </codeFilter>
            </dataRequirement>
            <dataRequirement>
               <type value="Encounter"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"></profile>
               <mustSupport value="period"></mustSupport>
               <mustSupport value="rank"></mustSupport>
               <mustSupport value="rank.value"></mustSupport>
               <mustSupport value="use"></mustSupport>
               <mustSupport value="condition"></mustSupport>
               <mustSupport value="location"></mustSupport>
               <mustSupport value="location.type"></mustSupport>
               <mustSupport value="diagnosis"></mustSupport>
               <mustSupport value="diagnosis.code"></mustSupport>
               <mustSupport value="type"></mustSupport>
               <mustSupport value="onAdmission"></mustSupport>
            </dataRequirement>
            <dataRequirement>
               <type value="Claim"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-claim"></profile>
               <mustSupport value="status"></mustSupport>
               <mustSupport value="status.value"></mustSupport>
               <mustSupport value="use"></mustSupport>
               <mustSupport value="use.value"></mustSupport>
               <mustSupport value="item"></mustSupport>
            </dataRequirement>
            <dataRequirement>
               <type value="MedicationRequest"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest"></profile>
               <mustSupport value="medication"></mustSupport>
            </dataRequirement>
            <dataRequirement>
               <type value="Medication"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication"></profile>
               <mustSupport value="code"></mustSupport>
            </dataRequirement>
            <content>
               <contentType value="text/cql"></contentType>
               <data value="[encoded data, 32192 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+xml"></contentType>
               <data value="[encoded data, 704780 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+json"></contentType>
               <data value="[encoded data, 1082368 characters]"></data>
            </content>
         </Library>
      </resource>
      <request>
         <method value="POST"></method>
         <url value="Library/CQMCommon"></url>
      </request>
   </entry>
   <entry>
      <fullUrl value="https://madie.cms.gov/Library/SupplementalDataElements"></fullUrl>
      <resource>
         <Library xmlns="http://hl7.org/fhir">
            <id value="SupplementalDataElements"></id>
            <meta>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-executablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-json-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-xml-library"></profile>
            </meta>
            <language value="en"></language>
            <text>
               <status value="extensions"></status>
               <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
                  <table class="narrative-table"> 
                     <tbody> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Metadata</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Title</th> 
                           <td class="content-container">SupplementalDataElements</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Version</th> 
                           <td class="content-container">5.1.000</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Identifier</th> 
                           <td class="content-container">67e5bc4d88f4d211353e632e</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Steward (Publisher)</th> 
                           <td class="content-container">ICF</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Description</th> 
                           <td class="content-container">This is the QI-Core 6.0.0 version of the Supplemental Data Elements library containing the CMS SDE definitions for Payer, Race, Ethnicity and Sex</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/library-type#logic-library]</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Patient 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient 
                              <br></br>   
                              <em>Must Support Elements</em>: extension, url 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Coverage 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage 
                              <br></br>   
                              <em>Must Support Elements</em>: type, period 
                              <br></br>  
                              <em>Code Filter(s)</em>: 
                              <br></br>  
                              <span class="tab-one">
                                 <em>Path</em>: type
                              </span> 
                              <br></br>  
                              <span class="tab-one">
                                 <em>ValueSet</em>:
                              </span> http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591 
                              <br></br>   
                           </td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Library Content</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">CQL Content</th> 
                           <td> 
                              <a name="cql-content"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@update: GCW 2025-03-27 -&gt;
Updated to reflect valueset name change from CMS Sex to Federal Administrative Sex
*/
library SupplementalDataElements version '5.1.000'

using QICore version '6.0.0'

include FHIRHelpers version '4.4.000' called FHIRHelpers

codesystem "SNOMEDCT": 'http://snomed.info/sct'

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

code "Male (finding)": '248153007' from "SNOMEDCT" display 'Male (finding)'
code "Female (finding)": '248152002' from "SNOMEDCT" display 'Female (finding)'

context Patient

define "SDE Ethnicity":
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }

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

define "SDE Race":
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }

define "SDE Sex":
  case
    when Patient.sex = '248153007' then "Male (finding)"
    when Patient.sex = '248152002' then "Female (finding)"
    else null
  end</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Generated using version 0.4.9 of the sample-content-ig Liquid templates</th> 
                        </tr> 
                     </tbody> 
                  </table> 
               </div>
            </text>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://snomed.info/sct"></system>
                  <code value="248153007"></code>
                  <display value="Male (finding)"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://snomed.info/sct"></system>
                  <code value="248152002"></code>
                  <display value="Female (finding)"></display>
               </valueCoding>
            </extension>
            <url value="https://madie.cms.gov/Library/SupplementalDataElements"></url>
            <identifier>
               <use value="official"></use>
               <system value="https://madie.cms.gov/login"></system>
               <value value="67e5bc4d88f4d211353e632e"></value>
            </identifier>
            <version value="5.1.000"></version>
            <name value="SupplementalDataElements"></name>
            <title value="SupplementalDataElements"></title>
            <status value="active"></status>
            <experimental value="false"></experimental>
            <type>
               <coding>
                  <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
                  <code value="logic-library"></code>
               </coding>
            </type>
            <date value="2025-11-24T17:18:51+00:00"></date>
            <publisher value="ICF"></publisher>
            <description value="This is the QI-Core 6.0.0 version of the Supplemental Data Elements library containing the CMS SDE definitions for Payer, Race, Ethnicity and Sex"></description>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="QICore model information"></display>
               <resource value="http://hl7.org/fhir/Library/QICore-ModelInfo"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library FHIRHelpers"></display>
               <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system SNOMEDCT"></display>
               <resource value="http://snomed.info/sct"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Value set Payer Type"></display>
               <resource value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"></resource>
            </relatedArtifact>
            <dataRequirement>
               <type value="Patient"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient"></profile>
               <mustSupport value="extension"></mustSupport>
               <mustSupport value="url"></mustSupport>
            </dataRequirement>
            <dataRequirement>
               <type value="Coverage"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage"></profile>
               <mustSupport value="type"></mustSupport>
               <mustSupport value="period"></mustSupport>
               <codeFilter>
                  <path value="type"></path>
                  <valueSet value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"></valueSet>
               </codeFilter>
            </dataRequirement>
            <content>
               <contentType value="text/cql"></contentType>
               <data value="LyoNCkB1cGRhdGU6IEdDVyAyMDI1LTAzLTI3IC0+DQpVcGRhdGVkIHRvIHJlZmxlY3QgdmFsdWVzZXQgbmFtZSBjaGFuZ2UgZnJvbSBDTVMgU2V4IHRvIEZlZGVyYWwgQWRtaW5pc3RyYXRpdmUgU2V4DQoqLw0KbGlicmFyeSBTdXBwbGVtZW50YWxEYXRhRWxlbWVudHMgdmVyc2lvbiAnNS4xLjAwMCcNCg0KdXNpbmcgUUlDb3JlIHZlcnNpb24gJzYuMC4wJw0KDQppbmNsdWRlIEZISVJIZWxwZXJzIHZlcnNpb24gJzQuNC4wMDAnIGNhbGxlZCBGSElSSGVscGVycw0KDQpjb2Rlc3lzdGVtICJTTk9NRURDVCI6ICdodHRwOi8vc25vbWVkLmluZm8vc2N0Jw0KDQp2YWx1ZXNldCAiRXRobmljaXR5IjogJ2h0dHA6Ly9jdHMubmxtLm5paC5nb3YvZmhpci9WYWx1ZVNldC8yLjE2Ljg0MC4xLjExNDIyMi40LjExLjgzNycNCnZhbHVlc2V0ICJGZWRlcmFsIEFkbWluaXN0cmF0aXZlIFNleCI6ICdodHRwOi8vY3RzLm5sbS5uaWguZ292L2ZoaXIvVmFsdWVTZXQvMi4xNi44NDAuMS4xMTM3NjIuMS40LjEwMjEuMTIxJw0KdmFsdWVzZXQgIlBheWVyIFR5cGUiOiAnaHR0cDovL2N0cy5ubG0ubmloLmdvdi9maGlyL1ZhbHVlU2V0LzIuMTYuODQwLjEuMTE0MjIyLjQuMTEuMzU5MScNCnZhbHVlc2V0ICJSYWNlIjogJ2h0dHA6Ly9jdHMubmxtLm5paC5nb3YvZmhpci9WYWx1ZVNldC8yLjE2Ljg0MC4xLjExNDIyMi40LjExLjgzNicNCg0KY29kZSAiTWFsZSAoZmluZGluZykiOiAnMjQ4MTUzMDA3JyBmcm9tICJTTk9NRURDVCIgZGlzcGxheSAnTWFsZSAoZmluZGluZyknDQpjb2RlICJGZW1hbGUgKGZpbmRpbmcpIjogJzI0ODE1MjAwMicgZnJvbSAiU05PTUVEQ1QiIGRpc3BsYXkgJ0ZlbWFsZSAoZmluZGluZyknDQoNCmNvbnRleHQgUGF0aWVudA0KDQpkZWZpbmUgIlNERSBFdGhuaWNpdHkiOg0KICBQYXRpZW50LmV0aG5pY2l0eSBFDQogICAgcmV0dXJuIFR1cGxlIHsNCiAgICAgIGNvZGVzOiB7IEUub21iQ2F0ZWdvcnkgfSB1bmlvbiBFLmRldGFpbGVkLA0KICAgICAgZGlzcGxheTogRS50ZXh0DQogICAgfQ0KDQpkZWZpbmUgIlNERSBQYXllciI6DQogIFtDb3ZlcmFnZTogdHlwZSBpbiAiUGF5ZXIgVHlwZSJdIFBheWVyDQogICAgcmV0dXJuIHsNCiAgICAgIGNvZGU6IFBheWVyLnR5cGUsDQogICAgICBwZXJpb2Q6IFBheWVyLnBlcmlvZA0KICAgIH0NCg0KZGVmaW5lICJTREUgUmFjZSI6DQogIFBhdGllbnQucmFjZSBSDQogICAgcmV0dXJuIFR1cGxlIHsNCiAgICAgIGNvZGVzOiBSLm9tYkNhdGVnb3J5IHVuaW9uIFIuZGV0YWlsZWQsDQogICAgICBkaXNwbGF5OiBSLnRleHQNCiAgICB9DQoNCmRlZmluZSAiU0RFIFNleCI6DQogIGNhc2UNCiAgICB3aGVuIFBhdGllbnQuc2V4ID0gJzI0ODE1MzAwNycgdGhlbiAiTWFsZSAoZmluZGluZykiDQogICAgd2hlbiBQYXRpZW50LnNleCA9ICcyNDgxNTIwMDInIHRoZW4gIkZlbWFsZSAoZmluZGluZykiDQogICAgZWxzZSBudWxsDQogIGVuZA=="></data>
            </content>
            <content>
               <contentType value="application/elm+xml"></contentType>
               <data value="[encoded data, 61716 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+json"></contentType>
               <data value="[encoded data, 121536 characters]"></data>
            </content>
         </Library>
      </resource>
      <request>
         <method value="POST"></method>
         <url value="Library/SupplementalDataElements"></url>
      </request>
   </entry>
   <entry>
      <fullUrl value="https://madie.cms.gov/Library/Status"></fullUrl>
      <resource>
         <Library xmlns="http://hl7.org/fhir">
            <id value="Status"></id>
            <meta>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-executablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-json-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-xml-library"></profile>
            </meta>
            <language value="en"></language>
            <text>
               <status value="extensions"></status>
               <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
                  <table class="narrative-table"> 
                     <tbody> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Metadata</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Title</th> 
                           <td class="content-container">Status</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Version</th> 
                           <td class="content-container">1.15.000</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Identifier</th> 
                           <td class="content-container">684c4d910d70b65363c69edf</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Steward (Publisher)</th> 
                           <td class="content-container">National Committee for Quality Assurance</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Description</th> 
                           <td class="content-container">This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA.</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/library-type#logic-library]</td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Library Content</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">CQL Content</th> 
                           <td> 
                              <a name="cql-content"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">library Status version '1.15.000'

using QICore version '6.0.0'

include FHIRHelpers version '4.4.000' called FHIRHelpers

codesystem "ObservationCategoryCodes": 'http://terminology.hl7.org/CodeSystem/observation-category'
codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'

code "exam": 'exam' from "ObservationCategoryCodes" display 'exam'
code "imaging": 'imaging' from "ObservationCategoryCodes" display 'imaging'
code "confirmed": 'confirmed' from ConditionVerificationStatusCodes display 'confirmed'
code "unconfirmed": 'unconfirmed' from ConditionVerificationStatusCodes display 'unconfirmed'
code "provisional": 'provisional' from ConditionVerificationStatusCodes display 'provisional'
code "differential": 'differential' from ConditionVerificationStatusCodes display 'differential'

context Patient

//This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA.

//Condition
//Returns conditions in the given list that either have no verification status or have a verification status of confirmed, unconfirmed, provisional, or differential
define fluent function verified(conditions List&lt;Choice&lt;ConditionProblemsHealthConcerns, ConditionEncounterDiagnosis&gt;&gt;):
  conditions C
    where C.verificationStatus is not null implies
      (C.verificationStatus ~ "confirmed"
        or C.verificationStatus ~ "unconfirmed"
        or C.verificationStatus ~ "provisional"
        or C.verificationStatus ~ "differential"
      )

//Assessment, Performed
define fluent function isAssessmentPerformed(Obs List&lt;ObservationScreeningAssessment&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }

//Device, Order - Personal Use Devices
define fluent function isDeviceOrderPersonalUseDevices(DeviceRequest List&lt;DeviceRequest&gt;):
  DeviceRequest D
    where D.status in { 'active', 'completed' }
      and D.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}

//Diagnostic Study, Order
define fluent function isDiagnosticStudyOrder(ServiceRequest List&lt;ServiceRequest&gt;):
  ServiceRequest S
    where S.status in { 'active', 'completed' }
      and S.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}
      
//Intervention, Order
define fluent function isInterventionOrder(ServiceRequest List&lt;ServiceRequest&gt;):
  ServiceRequest S
    where S.status in { 'active', 'completed' }
      and S.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}    

//Laboratory Test, Order
define fluent function isLaboratoryTestOrder(ServiceRequest List&lt;ServiceRequest&gt;):
  ServiceRequest S
    where S.status in { 'active', 'completed' }
      and S.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}       

//Diagnostic Study, Performed
define fluent function isDiagnosticStudyPerformed(Obs List&lt;ObservationClinicalResult&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
        and exists ( O.category ObservationCategory
        where ( ObservationCategory ) ~ "imaging"
    )
    
//Encounter, Performed
//General usage unless required otherwise by measure intent (e.g., follow-up encounters)
define fluent function isEncounterPerformed(Enc List&lt;Encounter&gt;):
  Enc E
    where E.status = 'finished'

//Immunization, Administered
define fluent function isImmunizationAdministered(Immunization List&lt;Immunization&gt;):
  Immunization I
    where I.status ~ 'completed'

//Intervention, Performed
define fluent function isInterventionPerformed(Proc List&lt;Procedure&gt;):
  Proc P
    where P.status ~ 'completed'

//Procedure, Performed
define fluent function isProcedurePerformed(Proc List&lt;Procedure&gt;):
  Proc P
    where P.status ~ 'completed'

//Laboratory Test, Performed
define fluent function isLaboratoryTestPerformed(Obs List&lt;LaboratoryResultObservation&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }

//Medication, Active
define fluent function isMedicationActive(MedicationRequest List&lt;MedicationRequest&gt;):
  MedicationRequest M
    where M.status = 'active'
      and M.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}

//Medication, Dispensed
define fluent function isMedicationDispensed(Med List&lt;MedicationDispense&gt;):
  Med M
    where M.status in { 'completed', 'in-progress', 'on-hold' }

//Medication, Order
define fluent function isMedicationOrder(MedicationRequest List&lt;MedicationRequest&gt;):
  MedicationRequest M
    where M.status in { 'active', 'completed' }
    and M.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}

//Physical Exam, Performed
define fluent function isPhysicalExamPerformed(Obs List&lt;ObservationClinicalResult&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      and exists ( O.category ObservationCategory
          where ( ObservationCategory ) ~ "exam"
      )

//Observation Vital Signs
define fluent function isObservationBP(Obs List&lt;USCoreBloodPressureProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      
define fluent function isObservationBodyHeight(Obs List&lt;USCoreBodyHeightProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      
define fluent function isObservationBodyWeight(Obs List&lt;USCoreBodyWeightProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      
define fluent function isObservationBMI(Obs List&lt;USCoreBMIProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
 
//Observation Pediatric BMI
define fluent function isObservationPediatricBMI(Obs List&lt;USCorePediatricBMIforAgeObservationProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' } 
   
//Observation Smoking Status
define fluent function isObservationSmokingStatus(Obs List&lt;USCoreSmokingStatusProfile&gt;):
  Obs O
    where O.status = 'final' 

//Symptom
define fluent function isSymptom(Obs List&lt;SimpleObservation&gt;):
  Obs O
    where O.status in { 'preliminary', 'final', 'amended', 'corrected' }</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Generated using version 0.4.9 of the sample-content-ig Liquid templates</th> 
                        </tr> 
                     </tbody> 
                  </table> 
               </div>
            </text>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="exam"></code>
                  <display value="exam"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="imaging"></code>
                  <display value="imaging"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="confirmed"></code>
                  <display value="confirmed"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="unconfirmed"></code>
                  <display value="unconfirmed"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="provisional"></code>
                  <display value="provisional"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="differential"></code>
                  <display value="differential"></display>
               </valueCoding>
            </extension>
            <url value="https://madie.cms.gov/Library/Status"></url>
            <identifier>
               <use value="official"></use>
               <system value="https://madie.cms.gov/login"></system>
               <value value="684c4d910d70b65363c69edf"></value>
            </identifier>
            <version value="1.15.000"></version>
            <name value="Status"></name>
            <title value="Status"></title>
            <status value="active"></status>
            <experimental value="false"></experimental>
            <type>
               <coding>
                  <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
                  <code value="logic-library"></code>
               </coding>
            </type>
            <date value="2025-11-24T17:18:54+00:00"></date>
            <publisher value="National Committee for Quality Assurance"></publisher>
            <description value="This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA."></description>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="QICore model information"></display>
               <resource value="http://hl7.org/fhir/Library/QICore-ModelInfo"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library FHIRHelpers"></display>
               <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system ObservationCategoryCodes"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/observation-category"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system ConditionVerificationStatusCodes"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></resource>
            </relatedArtifact>
            <content>
               <contentType value="text/cql"></contentType>
               <data value="[encoded data, 8456 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+xml"></contentType>
               <data value="[encoded data, 208832 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+json"></contentType>
               <data value="[encoded data, 391068 characters]"></data>
            </content>
         </Library>
      </resource>
      <request>
         <method value="POST"></method>
         <url value="Library/Status"></url>
      </request>
   </entry>
   <entry>
      <fullUrl value="https://madie.cms.gov/Library/QICoreCommon"></fullUrl>
      <resource>
         <Library xmlns="http://hl7.org/fhir">
            <id value="QICoreCommon"></id>
            <meta>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-executablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-json-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-xml-library"></profile>
            </meta>
            <language value="en"></language>
            <text>
               <status value="extensions"></status>
               <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
                  <table class="narrative-table"> 
                     <tbody> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Metadata</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Title</th> 
                           <td class="content-container">QICoreCommon</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Version</th> 
                           <td class="content-container">4.0.000</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Identifier</th> 
                           <td class="content-container">67cb33c19e9ab93ec36dad45</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Steward (Publisher)</th> 
                           <td class="content-container">ICF</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Description</th> 
                           <td class="content-container">Common terminologies and functions used in QI-Core-based CQL artifacts</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/library-type#logic-library]</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Resource 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/StructureDefinition/Resource 
                              <br></br>   
                              <em>Must Support Elements</em>: id, id.value 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: Patient 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient 
                              <br></br>   
                              <em>Must Support Elements</em>: birthDate, birthDate.value 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Data Requirement</th> 
                           <td class="content-container"> 
                              <em>Type</em>: DeviceRequest 
                              <br></br> 
                              <em>Profile(s)</em>:  http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-devicerequest 
                              <br></br>   
                              <em>Must Support Elements</em>: modifierExtension 
                              <br></br>  
                           </td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Library Content</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">CQL Content</th> 
                           <td> 
                              <a name="cql-content"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">library QICoreCommon version '4.0.000'

using QICore version '6.0.0'

include FHIRHelpers version '4.4.000' called FHIRHelpers

codesystem "LOINC": 'http://loinc.org'
codesystem "SNOMEDCT": 'http://snomed.info/sct'
codesystem "ActCode": 'http://terminology.hl7.org/CodeSystem/v3-ActCode'
codesystem "RoleCode": 'http://terminology.hl7.org/CodeSystem/v3-RoleCode'
codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role'
codesystem "RequestIntent": 'http://hl7.org/fhir/request-intent'
codesystem "MedicationRequestCategory": 'http://terminology.hl7.org/CodeSystem/medicationrequest-category'
codesystem "ConditionClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-clinical'
codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'
codesystem "AllergyIntoleranceClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical'
codesystem "AllergyIntoleranceVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification'
codesystem "ObservationCategoryCodes": 'http://terminology.hl7.org/CodeSystem/observation-category'
codesystem "USCoreObservationCategoryExtensionCodes": 'http://hl7.org/fhir/us/core/CodeSystem/us-core-observation-category'  
codesystem "ConditionCategory": 'http://terminology.hl7.org/CodeSystem/condition-category'
codesystem "USCoreConditionCategoryExtensionCodes": 'http://hl7.org/fhir/us/core/CodeSystem/condition-category'
codesystem "TaskCodeSystem": 'http://hl7.org/fhir/CodeSystem/task-code' 



code "Birthdate": '21112-8' from "LOINC" display 'Birth date'
code "Dead": '419099009' from "SNOMEDCT" display 'Dead'
code "ER": 'ER' from "RoleCode" display 'Emergency room'
code "ICU": 'ICU' from "RoleCode" display 'Intensive care unit'
code "Billing": 'billing' from "Diagnosis Role" display 'Billing'

//Task codes
code "Fulfill": 'fulfill' from "TaskCodeSystem" display 'Fulfill'

// Encounter Class Codes
code "ambulatory": 'AMB' from ActCode display 'ambulatory'
code "emergency": 'EMER' from ActCode display 'emergency'
code "field": 'FLD' from ActCode display 'field'
code "home health": 'HH' from ActCode display 'home health'
code "inpatient encounter": 'IMP' from ActCode display 'inpatient encounter'
code "inpatient acute": 'ACUTE' from ActCode display 'inpatient acute'
code "inpatient non-acute": 'NONAC' from ActCode display 'inpatient non-acute'
code "observation encounter": 'OBSENC' from ActCode display 'observation encounter'
code "pre-admission": 'PRENC' from ActCode display 'pre-admission'
code "short stay": 'SS' from ActCode display 'short stay'
code "virtual": 'VR' from ActCode display 'Virtual'

// Condition Category Codes
code "problem-list-item": 'problem-list-item' from "ConditionCategory" display 'Problem List Item'
code "encounter-diagnosis": 'encounter-diagnosis' from "ConditionCategory" display 'Encounter Diagnosis'
code "health-concern": 'health-concern' from "USCoreConditionCategoryExtensionCodes" display 'Health Concern'

// Condition Clinical Status Codes - Consider value sets for these
code "active": 'active' from "ConditionClinicalStatusCodes" display 'Active'
code "recurrence": 'recurrence' from "ConditionClinicalStatusCodes" display 'Recurrence'
code "relapse": 'relapse' from "ConditionClinicalStatusCodes" display 'Relapse'
code "inactive": 'inactive' from "ConditionClinicalStatusCodes" display 'Inactive'
code "remission": 'remission' from "ConditionClinicalStatusCodes" display 'Remission'
code "resolved": 'resolved' from "ConditionClinicalStatusCodes" display 'Resolved'

// Condition Verification Status Codes - Consider value sets for these
code "unconfirmed": 'unconfirmed' from ConditionVerificationStatusCodes display 'Unconfirmed'
code "provisional": 'provisional' from ConditionVerificationStatusCodes display 'Provisional'
code "differential": 'differential' from ConditionVerificationStatusCodes display 'Differential'
code "confirmed": 'confirmed' from ConditionVerificationStatusCodes display 'Confirmed'
code "refuted": 'refuted' from ConditionVerificationStatusCodes display 'Refuted'
code "entered-in-error": 'entered-in-error' from ConditionVerificationStatusCodes display 'Entered in Error'

code "allergy-active": 'active' from "AllergyIntoleranceClinicalStatusCodes" display 'Active'
code "allergy-inactive": 'inactive' from "AllergyIntoleranceClinicalStatusCodes" display 'Inactive'
code "allergy-resolved": 'resolved' from "AllergyIntoleranceClinicalStatusCodes" display 'Resolved'

// Allergy/Intolerance Verification Status Codes - Consider value sets for these
code "allergy-unconfirmed": 'unconfirmed' from AllergyIntoleranceVerificationStatusCodes display 'Unconfirmed'
code "allergy-confirmed": 'confirmed' from AllergyIntoleranceVerificationStatusCodes display 'Confirmed'
code "allergy-refuted": 'refuted' from AllergyIntoleranceVerificationStatusCodes display 'Refuted'

// MedicationRequest Category Codes
code "Inpatient": 'inpatient' from "MedicationRequestCategory" display 'Inpatient'
code "Outpatient": 'outpatient' from "MedicationRequestCategory" display 'Outpatient'
code "Community": 'community' from "MedicationRequestCategory" display 'Community'
code "Discharge": 'discharge' from "MedicationRequestCategory" display 'Discharge'

// Diagnosis Role Codes
code "AD": 'AD' from "Diagnosis Role" display 'Admission diagnosis'
code "DD": 'DD' from "Diagnosis Role" display 'Discharge diagnosis'
code "CC": 'CC' from "Diagnosis Role" display 'Chief complaint'
code "CM": 'CM' from "Diagnosis Role" display 'Comorbidity diagnosis'
code "pre-op": 'pre-op' from "Diagnosis Role" display 'pre-op diagnosis'
code "post-op": 'post-op' from "Diagnosis Role" display 'post-op diagnosis'
code "billing": 'billing' from "Diagnosis Role" display 'Billing'

// Observation Category Codes
code "social-history": 'social-history' from "ObservationCategoryCodes" display 'Social History'
code "vital-signs": 'vital-signs' from "ObservationCategoryCodes" display 'Vital Signs'
code "imaging": 'imaging' from "ObservationCategoryCodes" display 'Imaging'
code "laboratory": 'laboratory' from "ObservationCategoryCodes" display 'Laboratory'
code "procedure": 'procedure' from "ObservationCategoryCodes" display 'Procedure'
code "survey": 'survey' from "ObservationCategoryCodes" display 'Survey'
code "exam": 'exam' from "ObservationCategoryCodes" display 'Exam'
code "therapy": 'therapy' from "ObservationCategoryCodes" display 'Therapy'
code "activity": 'activity' from "ObservationCategoryCodes" display 'Activity'

context Patient

/* Candidates for FHIRCommon */

/*
@description: Returns true if the given condition has a clinical status of active, recurrence, or relapse
*/
define fluent function isActive(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
  condition.clinicalStatus ~ "active"
    or condition.clinicalStatus ~ "recurrence"
    or condition.clinicalStatus ~ "relapse"

/*
@description: Returns true if the given condition has the given category
*/
define fluent function hasCategory(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;, category Code):
  exists (condition.category C
    where C ~ category
  )

/*
@description: Returns true if the given condition is a problem list item.
*/
define fluent function isProblemListItem(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
  exists (condition.category C
    where C ~ "problem-list-item"
  )

/*
@description: Returns true if the given condition is an encounter diagnosis
*/
define fluent function isEncounterDiagnosis(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
  exists (condition.category C
    where C ~ "encounter-diagnosis"
  )

/*
@description: Returns true if the given condition is a health concern
*/
define fluent function isHealthConcern(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
  exists (condition.category C
    where C ~ "health-concern"
  )

/*
@description: Returns true if the given observation has the given category
*/
define fluent function hasCategory(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;, 
category Code):
  exists (observation.category C
    where C ~ category
  )

/*
@description: Returns true if the given observation is a social history observation
*/
define fluent function isSocialHistory(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "social-history"
  )

/*
@description: Returns true if the given observation is a vital sign
*/
define fluent function isVitalSign(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "vital-signs"
  )

/*
@description: Returns true if the given observation is an imaging observation
*/
define fluent function isImaging(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "imaging"
  )

/*
@description: Returns true if the given observation is a laboratory observation
*/
define fluent function isLaboratory(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "laboratory"
  )

/*
@description: Returns true if the given observation is a procedure observation
*/
define fluent function isProcedure(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "procedure"
  )

/*
@description: Returns true if the given observation is a survey observation
*/
define fluent function isSurvey(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "survey"
  )

/*
@description: Returns true if the given observation is an exam observation
*/
define fluent function isExam(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "exam"
  )

/*
@description: Returns true if the given observation is a therapy observation
*/
define fluent function isTherapy(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "therapy"
  )

/*
@description: Returns true if the given observation is an activity observation
*/
define fluent function isActivity(observation Choice&lt;"SimpleObservation", 
"ObservationCancelled",
"NonPatientObservation",
"LaboratoryResultObservation",
"ObservationClinicalResult",
"ObservationScreeningAssessment"&gt;):
  exists (observation.category C
    where C ~ "activity"
  )

/*
@description: Returns true if the given MedicationRequest has a category of Community
*/
define fluent function isCommunity(medicationRequest Choice&lt;MedicationRequest, MedicationNotRequested&gt;):
  exists (medicationRequest.category C
    where C ~ Community
  )

/*
@description: Returns true if the given MedicationRequest has a category of Discharge
*/
define fluent function isDischarge(medicationRequest Choice&lt;MedicationRequest, MedicationNotRequested&gt;):
  exists (medicationRequest.category C
    where C ~ Discharge
  )

/*
@description: Returns true if the given DeviceRequest is a negation (i.e. do not perform this order)
@deprecated: This function is no longer required in QICore 6.0.0 and above
*/
define fluent function doNotPerform(deviceRequest DeviceRequest):
  // KNOWN ISSUE: The translator reports this as an error but the execution still works, this is under investigation
  deviceRequest.doNotPerform

/*
@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

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

/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
@deprecated: This function is deprecated. Use the fluent function `abatementInterval()` instead.
*/
define function ToAbatementInterval(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
	if condition.abatement is DateTime then
	  Interval[condition.abatement as DateTime, condition.abatement as DateTime]
	else if condition.abatement is Quantity then
		Interval[Patient.birthDate + (condition.abatement as Quantity),
			Patient.birthDate + (condition.abatement as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;Quantity&gt; then
	  Interval[Patient.birthDate + (condition.abatement.low as Quantity),
		  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;DateTime&gt; then
	  Interval[condition.abatement.low, condition.abatement.high)
	else null as Interval&lt;DateTime&gt;

/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
*/
define fluent function abatementInterval(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
	if condition.abatement is DateTime then
	  Interval[condition.abatement as DateTime, condition.abatement as DateTime]
	else if condition.abatement is Quantity then
		Interval[Patient.birthDate + (condition.abatement as Quantity),
			Patient.birthDate + (condition.abatement as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;Quantity&gt; then
	  Interval[Patient.birthDate + (condition.abatement.low as Quantity),
		  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
	else if condition.abatement is Interval&lt;DateTime&gt; then
	  Interval[condition.abatement.low, condition.abatement.high)
	else null as Interval&lt;DateTime&gt;

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

/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
*/
define fluent function prevalenceInterval(condition Choice&lt;"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns"&gt;):
if condition.clinicalStatus ~ "active"
  or condition.clinicalStatus ~ "recurrence"
  or condition.clinicalStatus ~ "relapse" then
  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
else
    (end of condition.abatementInterval()) abatementDate
    return if abatementDate is null then
      Interval[start of condition.onset.toInterval(), abatementDate)
    else
      Interval[start of condition.onset.toInterval(), abatementDate]

/*
@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.
@deprecated: This function is deprecated. Use the fluent function `getId()` instead
*/
define function GetId(uri String):
  Last(Split(uri, '/'))

/*
@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, '/'))

/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resource Resource):
  resource.id = Last(Split(reference.reference, '/'))  

/*
@description: Returns true if the given reference is to the given resourceId
@comment: Returns true if the `resourceId` parameter exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resourceId String):
  resourceId = Last(Split(reference.reference, '/'))

/*
@description: Returns true if any of the given references are to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List&lt;Reference&gt;, resource Resource):
  exists (references R where R.references(resource))
  
/*
@description: Returns true if any of the given references are to the given resourceId
@comment: Returns true if the `resourceId` parameter exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List&lt;Reference&gt;, resourceId String):
  exists (references R where R.references(resourceId))

/*
@description: Returns true if the given code is in the given codeList
@comment: Returns true if the `code` is equivalent to any of the codes in the given `codeList`, false otherwise.
*/
define fluent function includesCode(codeList List&lt;Concept&gt;, code Code):
  exists (codeList C where C ~ code)

/*
@description: Given an interval, return true if the interval has a starting boundary specified
(i.e. the start of the interval is not null and not the minimum DateTime value)
@deprecated: This function is deprecated. Uee the fluent function `hasStart()` instead
*/
define function "HasStart"(period Interval&lt;DateTime&gt; ):
  not ( start of period is null
      or start of period = minimum DateTime
  )

/*
@description: Given an interval, return true if the interval has a starting boundary specified
(i.e. the start of the interval is not null and not the minimum DateTime value)
*/
define fluent function hasStart(period Interval&lt;DateTime&gt; ):
  not ( start of period is null
      or start of period = minimum DateTime
  )

/*
@description: Given an interval, returns true if the interval has an ending boundary specified
(i.e. the end of the interval is not null and not the maximum DateTime value)
@deprecated: This function is deprecated. Use the fluent function `hasEnd()` instead
*/
define function "HasEnd"(period Interval&lt;DateTime&gt; ):
  not (
    end of period is null
      or end of period = maximum DateTime
  )

/*
@description: Given an interval, returns true if the interval has an ending boundary specified
(i.e. the end of the interval is not null and not the maximum DateTime value)
*/
define fluent function hasEnd(period Interval&lt;DateTime&gt; ):
  not (
    end of period is null
      or end of period = maximum DateTime
  )

/*
@description: Given an interval, returns the ending point if the interval has an ending boundary specified,
otherwise, returns the starting point
@deprecated: This function is deprecated. Use the fluent function `latest()` instead
*/
define function "Latest"(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (HasEnd(period)) then end of period
      else start of period

/*
@description: Given an interval, returns the ending point if the interval has an ending boundary specified,
otherwise, returns the starting point
*/
define fluent function latest(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (period."hasEnd"()) then end of period
      else start of period

/*
@description: Given an interval, return the starting point if the interval has a starting boundary specified,
otherwise, return the ending point
@deprecated: This function is deprecated. Use the fluent function `earliest()` instead
*/
define function "Earliest"(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (HasStart(period)) then start of period
      else end of period

/*
@description: Given an interval, return the starting point if the interval has a starting boundary specified,
otherwise, return the ending point
*/
define fluent function earliest(choice Choice&lt;DateTime, Quantity, Interval&lt;DateTime&gt;, Interval&lt;Quantity&gt;&gt; ):
  (choice.toInterval()) period
    return
      if (period."hasStart"()) then start of period
      else end of period

/*
@description: Creates a list of integers from 1 to how many days are in the interval. Note, this wont create an index for
the final day if it is less than 24 hours. This also includes the first 24 hour period.
@deprecated: This function is deprecated. Use the fluent function `toDayNumbers()` instead
*/
define function "Interval To Day Numbers"(Period Interval&lt;DateTime&gt;):
  ( expand { Interval[1, duration in days between start of Period and end of Period]} ) DayNumber
    return end of DayNumber

/*
@description: Creates a list of integers from 1 to how many days are in the interval. Note, this wont create an index for
the final day if it is less than 24 hours. This also includes the first 24 hour period.
*/
define fluent function toDayNumbers(Period Interval&lt;DateTime&gt;):
  ( expand { Interval[1, duration in days between start of Period and end of Period]} ) DayNumber
    return end of DayNumber

/*
@description: Creates a list of 24 hour long intervals in an interval paired with the index (1 indexed) to which 24 hour interval it is.
Note that the result will include intervals that are closed at the beginning and open at the end
@deprecated: This function is deprecated. Use the fluent function `daysInPeriod()` instead
*/
define function "Days In Period"(Period Interval&lt;DateTime&gt;):
  ( "Interval To Day Numbers"(Period)) DayIndex
    let startPeriod: start of Period + (24 hours * (DayIndex - 1)),
    endPeriod: if (hours between startPeriod and end of Period &lt; 24) then startPeriod
      else start of Period + (24 hours * DayIndex)
    return Tuple {
      dayIndex: DayIndex,
      dayPeriod: Interval[startPeriod, endPeriod)
    }

/*
@description: Creates a list of 24 hour long intervals in an interval paired with the index (1 indexed) to which 24 hour interval it is.
Note that the result will include intervals that are closed at the beginning and open at the end
*/
define fluent function daysInPeriod(Period Interval&lt;DateTime&gt;):
  ( "Interval To Day Numbers"(Period)) DayIndex
    let startPeriod: start of Period + (24 hours * (DayIndex - 1)),
    endPeriod: if (hours between startPeriod and end of Period &lt; 24) then startPeriod
      else start of Period + (24 hours * DayIndex)
    return Tuple {
      dayIndex: DayIndex,
      dayPeriod: Interval[startPeriod, endPeriod)
    }</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Generated using version 0.4.9 of the sample-content-ig Liquid templates</th> 
                        </tr> 
                     </tbody> 
                  </table> 
               </div>
            </text>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://loinc.org"></system>
                  <code value="21112-8"></code>
                  <display value="Birthdate"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://snomed.info/sct"></system>
                  <code value="419099009"></code>
                  <display value="Dead"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-RoleCode"></system>
                  <code value="ER"></code>
                  <display value="ER"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-RoleCode"></system>
                  <code value="ICU"></code>
                  <display value="ICU"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="billing"></code>
                  <display value="Billing"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://hl7.org/fhir/CodeSystem/task-code"></system>
                  <code value="fulfill"></code>
                  <display value="Fulfill"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="AMB"></code>
                  <display value="ambulatory"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="EMER"></code>
                  <display value="emergency"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="FLD"></code>
                  <display value="field"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="HH"></code>
                  <display value="home health"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="IMP"></code>
                  <display value="inpatient encounter"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="ACUTE"></code>
                  <display value="inpatient acute"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="NONAC"></code>
                  <display value="inpatient non-acute"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="OBSENC"></code>
                  <display value="observation encounter"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="PRENC"></code>
                  <display value="pre-admission"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="SS"></code>
                  <display value="short stay"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/v3-ActCode"></system>
                  <code value="VR"></code>
                  <display value="virtual"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-category"></system>
                  <code value="problem-list-item"></code>
                  <display value="problem-list-item"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-category"></system>
                  <code value="encounter-diagnosis"></code>
                  <display value="encounter-diagnosis"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://hl7.org/fhir/us/core/CodeSystem/condition-category"></system>
                  <code value="health-concern"></code>
                  <display value="health-concern"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                  <code value="active"></code>
                  <display value="active"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                  <code value="recurrence"></code>
                  <display value="recurrence"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                  <code value="relapse"></code>
                  <display value="relapse"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                  <code value="inactive"></code>
                  <display value="inactive"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                  <code value="remission"></code>
                  <display value="remission"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-clinical"></system>
                  <code value="resolved"></code>
                  <display value="resolved"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="unconfirmed"></code>
                  <display value="unconfirmed"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="provisional"></code>
                  <display value="provisional"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="differential"></code>
                  <display value="differential"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="confirmed"></code>
                  <display value="confirmed"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="refuted"></code>
                  <display value="refuted"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
                  <code value="entered-in-error"></code>
                  <display value="entered-in-error"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"></system>
                  <code value="active"></code>
                  <display value="allergy-active"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"></system>
                  <code value="inactive"></code>
                  <display value="allergy-inactive"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"></system>
                  <code value="resolved"></code>
                  <display value="allergy-resolved"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/allergyintolerance-verification"></system>
                  <code value="unconfirmed"></code>
                  <display value="allergy-unconfirmed"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/allergyintolerance-verification"></system>
                  <code value="confirmed"></code>
                  <display value="allergy-confirmed"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/allergyintolerance-verification"></system>
                  <code value="refuted"></code>
                  <display value="allergy-refuted"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/medicationrequest-category"></system>
                  <code value="inpatient"></code>
                  <display value="Inpatient"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/medicationrequest-category"></system>
                  <code value="outpatient"></code>
                  <display value="Outpatient"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/medicationrequest-category"></system>
                  <code value="community"></code>
                  <display value="Community"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/medicationrequest-category"></system>
                  <code value="discharge"></code>
                  <display value="Discharge"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="AD"></code>
                  <display value="AD"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="DD"></code>
                  <display value="DD"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="CC"></code>
                  <display value="CC"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="CM"></code>
                  <display value="CM"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="pre-op"></code>
                  <display value="pre-op"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="post-op"></code>
                  <display value="post-op"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/diagnosis-role"></system>
                  <code value="billing"></code>
                  <display value="billing"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="social-history"></code>
                  <display value="social-history"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="vital-signs"></code>
                  <display value="vital-signs"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="imaging"></code>
                  <display value="imaging"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="laboratory"></code>
                  <display value="laboratory"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="procedure"></code>
                  <display value="procedure"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="survey"></code>
                  <display value="survey"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="exam"></code>
                  <display value="exam"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="therapy"></code>
                  <display value="therapy"></display>
               </valueCoding>
            </extension>
            <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
               <valueCoding>
                  <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
                  <code value="activity"></code>
                  <display value="activity"></display>
               </valueCoding>
            </extension>
            <url value="https://madie.cms.gov/Library/QICoreCommon"></url>
            <identifier>
               <use value="official"></use>
               <system value="https://madie.cms.gov/login"></system>
               <value value="67cb33c19e9ab93ec36dad45"></value>
            </identifier>
            <version value="4.0.000"></version>
            <name value="QICoreCommon"></name>
            <title value="QICoreCommon"></title>
            <status value="active"></status>
            <experimental value="false"></experimental>
            <type>
               <coding>
                  <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
                  <code value="logic-library"></code>
               </coding>
            </type>
            <date value="2025-11-24T17:18:52+00:00"></date>
            <publisher value="ICF"></publisher>
            <description value="Common terminologies and functions used in QI-Core-based CQL artifacts"></description>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="QICore model information"></display>
               <resource value="http://hl7.org/fhir/Library/QICore-ModelInfo"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Library FHIRHelpers"></display>
               <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system USCoreConditionCategoryExtensionCodes"></display>
               <resource value="http://hl7.org/fhir/us/core/CodeSystem/condition-category"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system ObservationCategoryCodes"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/observation-category"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system ConditionClinicalStatusCodes"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/condition-clinical"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system MedicationRequestCategory"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/medicationrequest-category"></resource>
            </relatedArtifact>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="Code system ConditionCategory"></display>
               <resource value="http://terminology.hl7.org/CodeSystem/condition-category"></resource>
            </relatedArtifact>
            <dataRequirement>
               <type value="Resource"></type>
               <profile value="http://hl7.org/fhir/StructureDefinition/Resource"></profile>
               <mustSupport value="id"></mustSupport>
               <mustSupport value="id.value"></mustSupport>
            </dataRequirement>
            <dataRequirement>
               <type value="Patient"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient"></profile>
               <mustSupport value="birthDate"></mustSupport>
               <mustSupport value="birthDate.value"></mustSupport>
            </dataRequirement>
            <dataRequirement>
               <type value="DeviceRequest"></type>
               <profile value="http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-devicerequest"></profile>
               <mustSupport value="modifierExtension"></mustSupport>
            </dataRequirement>
            <content>
               <contentType value="text/cql"></contentType>
               <data value="[encoded data, 43100 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+xml"></contentType>
               <data value="[encoded data, 1733416 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+json"></contentType>
               <data value="[encoded data, 2930368 characters]"></data>
            </content>
         </Library>
      </resource>
      <request>
         <method value="POST"></method>
         <url value="Library/QICoreCommon"></url>
      </request>
   </entry>
   <entry>
      <fullUrl value="https://madie.cms.gov/Library/FHIRHelpers"></fullUrl>
      <resource>
         <Library xmlns="http://hl7.org/fhir">
            <id value="FHIRHelpers"></id>
            <meta>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-executablelibrary"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-json-library"></profile>
               <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-xml-library"></profile>
            </meta>
            <language value="en"></language>
            <text>
               <status value="extensions"></status>
               <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
                  <table class="narrative-table"> 
                     <tbody> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Metadata</th> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Title</th> 
                           <td class="content-container">FHIRHelpers</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Version</th> 
                           <td class="content-container">4.4.000</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Identifier</th> 
                           <td class="content-container">660d90bc01598d085de46056</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Steward (Publisher)</th> 
                           <td class="content-container">ICF</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Description</th> 
                           <td class="content-container">This library defines functions to convert between FHIR
 data types and CQL system-defined types, as well as functions to support FHIRPath implementation. For more information, the FHIRHelpers wiki page:
 https://github.com/cqframework/clinical_quality_language/wiki/FHIRHelpers</td> 
                        </tr> 
                        <tr> 
                           <th scope="row" class="row-header">Type</th> 
                           <td class="content-container">[http://terminology.hl7.org/CodeSystem/library-type#logic-library]</td> 
                        </tr> 
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Library Content</th> 
                        </tr>  
                        <tr> 
                           <th scope="row" class="row-header">CQL Content</th> 
                           <td> 
                              <a name="cql-content"> </a> 
                              <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">library FHIRHelpers version '4.4.000'

using FHIR version '4.0.1'

/*
@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."start" is null then
            Interval(period."start".value, period."end".value]
        else
            Interval[period."start".value, period."end".value]

/*
@description: Converts a UCUM definite duration unit to a CQL calendar duration
unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities) 
topic of the CQL specification.
@comment: Note that for durations above days (or weeks), the conversion is understood to be approximate
*/
define function ToCalendarUnit(unit System.String):
    case unit
        when 'ms' then 'millisecond'
        when 's' then 'second'
        when 'min' then 'minute'
        when 'h' then 'hour'
        when 'd' then 'day'
        when 'wk' then 'week'
        when 'mo' then 'month'
        when 'a' then 'year'
        else unit
    end

/*
@description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) 
value to a CQL Quantity
@comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity
has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`)
an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used.
@seealso: ToCalendarUnit
*/
define function ToQuantity(quantity FHIR.Quantity):
    case
        when quantity is null then null
        when quantity.value is null then null
        when quantity.comparator is not null then
            Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')
        when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
              or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
            System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
        else
            Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' &amp; quantity.unit.value &amp; ' (' &amp; quantity.system.value &amp; '|' &amp; quantity.code.value &amp; ')')
    end

/*
@description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) value to a CQL Quantity, ignoring
the comparator element. This function should only be used when an application is justified in ignoring the comparator value (i.e. the
context is looking for boundary).
@comment: If the given quantity has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units 
(i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`) an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function 
is used.
@seealso: ToCalendarUnit
*/
define function ToQuantityIgnoringComparator(quantity FHIR.Quantity):
    case
        when quantity is null then null
        when quantity.value is null then null
        when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
              or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
            System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
        else
            Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' &amp; quantity.unit.value &amp; ' (' &amp; quantity.system.value &amp; '|' &amp; quantity.code.value &amp; ')')
    end

/*
@description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) value to a CQL Interval of Quantity.
@comment: If the given quantity has a comparator, it is used to construct an interval based on the value of the comparator. If the comparator
is less than, the resulting interval will start with a null closed boundary and end with an open boundary on the quantity. If the comparator
is less than or equal, the resulting interval will start with a null closed boundary and end with a closed boundary on the quantity. If the 
comparator is greater or equal, the resulting interval will start with a closed boundary on the quantity and end with a closed null boundary.
If the comparator is greatter than, the resulting interval will start with an open boundary on the quantity and end with a closed null boundary.
If no comparator is specified, the resulting interval will start and end with a closed boundary on the quantity.
*/
define function ToInterval(quantity FHIR.Quantity):
    if quantity is null then null else
        case quantity.comparator.value
            when '&lt;' then
                Interval[
                    null,
                    ToQuantityIgnoringComparator(quantity)
                )
            when '&lt;=' then
                Interval[
                    null,
                    ToQuantityIgnoringComparator(quantity)
                ]
            when '&gt;=' then
                Interval[
                    ToQuantityIgnoringComparator(quantity),
                    null
                ]
            when '&gt;' then
                Interval(
                    ToQuantityIgnoringComparator(quantity),
                    null
                ]
            else
                Interval[ToQuantity(quantity), ToQuantity(quantity)]
        end

/*
@description: Converts the given FHIR [Ratio](https://hl7.org/fhir/datatypes.html#Ratio) value to a CQL Ratio.
*/
define function ToRatio(ratio FHIR.Ratio):
    if ratio is null then
        null
    else
        System.Ratio { numerator: ToQuantity(ratio.numerator), denominator: ToQuantity(ratio.denominator) }

/*
@description: Converts the given FHIR [Range](https://hl7.org/fhir/datatypes.html#Range) value to a CQL Interval of Quantity
*/
define function ToInterval(range FHIR.Range):
    if range is null then
        null
    else
        Interval[ToQuantity(range.low), ToQuantity(range.high)]

/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }

/*
@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
*/
define function ToConcept(concept FHIR.CodeableConcept):
    if concept is null then
        null
    else
        System.Concept {
            codes: concept.coding C return ToCode(C),
            display: concept.text.value
        }

/*
@description: Converts the given value (assumed to be a URI) to a CQL [ValueSet](https://cql.hl7.org/09-b-cqlreference.html#valueset)
*/
define function ToValueSet(uri String):
    if uri is null then
        null
    else
        System.ValueSet {
            id: uri
        }

/*
@description: Constructs a FHIR [Reference](https://hl7.org/fhir/datatypes.html#Reference) from the given reference (assumed to be a FHIR resource URL)
*/
define function reference(reference String):
    if reference is null then
        null
    else
        Reference { reference: string { value: reference } }

/*
@description: Converts the given value to a CQL value using the appropriate accessor or conversion function.
@comment: TODO: document conversion
*/
define function ToValue(value Choice&lt;base64Binary,
        boolean,
        canonical,
        code,
        date,
        dateTime,
        decimal,
        id,
        instant,
        integer,
        markdown,
        oid,
        positiveInt,
        string,
        time,
        unsignedInt,
        uri,
        url,
        uuid,
        Address,
        Age,
        Annotation,
        Attachment,
        CodeableConcept,
        Coding,
        ContactPoint,
        Count,
        Distance,
        Duration,
        HumanName,
        Identifier,
        Money,
        Period,
        Quantity,
        Range,
        Ratio,
        Reference,
        SampledData,
        Signature,
        Timing,
        ContactDetail,
        Contributor,
        DataRequirement,
        Expression,
        ParameterDefinition,
        RelatedArtifact,
        TriggerDefinition,
        UsageContext,
        Dosage,
        Meta&gt;):
    case
      when value is base64Binary then (value as base64Binary).value
      when value is boolean then (value as boolean).value
      when value is canonical then (value as canonical).value
      when value is code then (value as code).value
      when value is date then (value as date).value
      when value is dateTime then (value as dateTime).value
      when value is decimal then (value as decimal).value
      when value is id then (value as id).value
      when value is instant then (value as instant).value
      when value is integer then (value as integer).value
      when value is markdown then (value as markdown).value
      when value is oid then (value as oid).value
      when value is positiveInt then (value as positiveInt).value
      when value is string then (value as string).value
      when value is time then (value as time).value
      when value is unsignedInt then (value as unsignedInt).value
      when value is uri then (value as uri).value
      when value is url then (value as url).value
      when value is uuid then (value as uuid).value
      when value is Age then ToQuantity(value as Age)
      when value is CodeableConcept then ToConcept(value as CodeableConcept)
      when value is Coding then ToCode(value as Coding)
      when value is Count then ToQuantity(value as Count)
      when value is Distance then ToQuantity(value as Distance)
      when value is Duration then ToQuantity(value as Duration)
      when value is Quantity then ToQuantity(value as Quantity)
      when value is Range then ToInterval(value as Range)
      when value is Period then ToInterval(value as Period)
      when value is Ratio then ToRatio(value as Ratio)
      else value as Choice&lt;Address,
        Annotation,
        Attachment,
        ContactPoint,
        HumanName,
        Identifier,
        Money,
        Reference,
        SampledData,
        Signature,
        Timing,
        ContactDetail,
        Contributor,
        DataRequirement,
        Expression,
        ParameterDefinition,
        RelatedArtifact,
        TriggerDefinition,
        UsageContext,
        Dosage,
        Meta&gt;
    end

/*
@description: Resolve the given reference as a url to a resource. If the item resolves, the Resource is returned, otherwise the result is null.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function resolve(reference String) returns Resource: external
/*
@description: Resolve the reference element of the given Reference. If the item resolves, the Resource is returned, otherwise the result is null.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function resolve(reference Reference) returns Resource: external
/*
@description: Constructs a Reference to the given Resource. The resulting reference will typically be relative, but implementations may provide a base URL if one can be unambiguously determined.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function reference(resource Resource) returns Reference: external
/*
@description: Returns any extensions with the given url defined on the given element.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function extension(element Element, url String) returns List&lt;Extension&gt;: external
/*
@description: Returns any extensions with the given url defined on the given resource.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function extension(resource DomainResource, url String) returns List&lt;Extension&gt;: external
/*
@description: Returns any modifier extensions with the given url defined on the given element.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function modifierExtension(element BackboneElement, url String) returns List&lt;Extension&gt;: external
/*
@description: Returns any modifier extensions with the given url defined on the given resource.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function modifierExtension(resource DomainResource, url String) returns List&lt;Extension&gt;: external
/*
@description: Returns true if the element is a FHIR primitive type with a value element (as opposed to having only extensions); false otherwise
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function hasValue(element Element) returns Boolean: external
/*
@description: Returns the value of the FHIR primitive; null otherwise
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function getValue(element Element) returns Any: external
/*
@description: Returns a list containing only those elements in the input that are of the given type, specified as a string.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function ofType(identifier String) returns List&lt;Any&gt;: external
/*
@description: Returns true if the input is of the given type; false otherwise
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function is(identifier String) returns Boolean: external
/*
@description: If the input is of the given type; returns the value as that type; null otherwise.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function as(identifier String) returns Any: external
/*
@description: Returns the FHIR element definition for the given element
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function elementDefinition(element Element) returns ElementDefinition: external
/*
@description: Returns the given slice as defined in the given structure definition. The structure argument is a uri that resolves to the structure definition, and the name must be the name of a slice within that structure definition. If the structure cannot be resolved, or the name of the slice within the resolved structure is not present, an error is thrown.
@comment: For every element in the input collection, if the resolved slice is present on the element, it will be returned. If the slice does not match any element in the input collection, or if the input collection is empty, the result is an empty collection ({ }).
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function slice(element Element, url String, name String) returns List&lt;Element&gt;: external
/*
@description: For each element in the input collection, verifies that there are no modifying extensions defined other than the ones given by the modifier argument. If the check passes, the input collection is returned. Otherwise, an error is thrown.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function checkModifiers(resource Resource) returns Resource: external
/*
@description: For each element in the input collection, verifies that there are no modifying extensions defined other than the ones given by the modifier argument. If the check passes, the input collection is returned. Otherwise, an error is thrown.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function checkModifiers(resource Resource, modifier String) returns Resource: external
/*
@description: For each element in the input collection, verifies that there are no modifying extensions defined other than the ones given by the modifier argument. If the check passes, the input collection is returned. Otherwise, an error is thrown.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function checkModifiers(element Element) returns Element: external
/*
@description: For each element in the input collection, verifies that there are no modifying extensions defined other than the ones given by the modifier argument. If the check passes, the input collection is returned. Otherwise, an error is thrown.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function checkModifiers(element Element, modifier String) returns Element: external
/*
@description: Returns true if the single input element conforms to the profile specified by the structure argument, and false otherwise. If the structure cannot be resolved to a valid profile, an error is thrown. If the input contains more than one element, an error is thrown. If the input is empty, the result is empty.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function conformsTo(resource Resource, structure String) returns Boolean: external
/*
@description: Returns true if the given code is equal to a code in the valueset, so long as the valueset only contains one codesystem. If the valueset contains more than one codesystem, an error is thrown.
@comment: If the valueset cannot be resolved as a uri to a value set, an error is thrown.
Note that implementations are encouraged to make use of a terminology service to provide this functionality.
For example:
```fhirpath
Observation.component.where(code.memberOf('http://hl7.org/fhir/ValueSet/observation-vitalsignresult'))
```
This expression returns components that have a code that is a member of the observation-vitalsignresult valueset.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function memberOf(code code, valueSet String) returns Boolean: external
/*
@description: Returns true if the code is a member of the given valueset.
@comment: If the valueset cannot be resolved as a uri to a value set, an error is thrown.
Note that implementations are encouraged to make use of a terminology service to provide this functionality.
For example:
```fhirpath
Observation.component.where(code.memberOf('http://hl7.org/fhir/ValueSet/observation-vitalsignresult'))
```
This expression returns components that have a code that is a member of the observation-vitalsignresult valueset.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function memberOf(coding Coding, valueSet String) returns Boolean: external
/*
@description: Returns true if any code in the concept is a member of the given valueset.
@comment: If the valueset cannot be resolved as a uri to a value set, an error is thrown.
Note that implementations are encouraged to make use of a terminology service to provide this functionality.
For example:
```fhirpath
Observation.component.where(code.memberOf('http://hl7.org/fhir/ValueSet/observation-vitalsignresult'))
```
This expression returns components that have a code that is a member of the observation-vitalsignresult valueset.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function memberOf(concept CodeableConcept, valueSet String) returns Boolean: external
/*
@description: Returns true if the source code is equivalent to the given code, or if the source code subsumes the given code (i.e. the source code is an ancestor of the given code in a subsumption hierarchy), and false otherwise.
@comment: If the Codings are from different code systems, the relationships between the code systems must be well-defined or a run-time error is thrown.
Note that implementations are encouraged to make use of a terminology service to provide this functionality.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function subsumes(coding Coding, subsumedCoding Coding) returns Boolean: external
/*
@description: Returns true if any Coding in the source or given elements is equivalent to or subsumes the given code.
@comment: If the Codings are from different code systems, the relationships between the code systems must be well-defined or a run-time error is thrown.
Note that implementations are encouraged to make use of a terminology service to provide this functionality.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function subsumes(concept CodeableConcept, subsumedConcept CodeableConcept) returns Boolean: external
/*
@description: Returns true if the source code is equivalent to the given code, or if the source code is subsumed by the given code (i.e. the source code is a descendant of the given code in a subsumption hierarchy), and false otherwise.
@comment: If the Codings are from different code systems, the relationships between the code systems must be well-defined or a run-time error is thrown.
Note that implementations are encouraged to make use of a terminology service to provide this functionality.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function subsumedBy(coding Coding, subsumingCoding Coding) returns Boolean: external
/*
@description: Returns true if any Coding in the source or given elements is equivalent to or subsumed by the given code.
@comment: If the Codings are from different code systems, the relationships between the code systems must be well-defined or a run-time error is thrown.
Note that implementations are encouraged to make use of a terminology service to provide this functionality.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function subsumedBy(concept CodeableConcept, subsumingConcept CodeableConcept) returns Boolean: external
/*
@description: When invoked on an xhtml element, returns true if the rules around HTML usage are met, and false if they are not. The return value is undefined (null) on any other kind of element.
@seealso: https://hl7.org/fhir/fhirpath.html#functions
*/
define function htmlChecks(element Element) returns Boolean: external

define function ToString(value AccountStatus): value.value
define function ToString(value ActionCardinalityBehavior): value.value
define function ToString(value ActionConditionKind): value.value
define function ToString(value ActionGroupingBehavior): value.value
define function ToString(value ActionParticipantType): value.value
define function ToString(value ActionPrecheckBehavior): value.value
define function ToString(value ActionRelationshipType): value.value
define function ToString(value ActionRequiredBehavior): value.value
define function ToString(value ActionSelectionBehavior): value.value
define function ToString(value ActivityDefinitionKind): value.value
define function ToString(value ActivityParticipantType): value.value
define function ToString(value AddressType): value.value
define function ToString(value AddressUse): value.value
define function ToString(value AdministrativeGender): value.value
define function ToString(value AdverseEventActuality): value.value
define function ToString(value AggregationMode): value.value
define function ToString(value AllergyIntoleranceCategory): value.value
define function ToString(value AllergyIntoleranceCriticality): value.value
define function ToString(value AllergyIntoleranceSeverity): value.value
define function ToString(value AllergyIntoleranceType): value.value
define function ToString(value AppointmentStatus): value.value
define function ToString(value AssertionDirectionType): value.value
define function ToString(value AssertionOperatorType): value.value
define function ToString(value AssertionResponseTypes): value.value
define function ToString(value AuditEventAction): value.value
define function ToString(value AuditEventAgentNetworkType): value.value
define function ToString(value AuditEventOutcome): value.value
define function ToString(value BindingStrength): value.value
define function ToString(value BiologicallyDerivedProductCategory): value.value
define function ToString(value BiologicallyDerivedProductStatus): value.value
define function ToString(value BiologicallyDerivedProductStorageScale): value.value
define function ToString(value BundleType): value.value
define function ToString(value CapabilityStatementKind): value.value
define function ToString(value CarePlanActivityKind): value.value
define function ToString(value CarePlanActivityStatus): value.value
define function ToString(value CarePlanIntent): value.value
define function ToString(value CarePlanStatus): value.value
define function ToString(value CareTeamStatus): value.value
define function ToString(value CatalogEntryRelationType): value.value
define function ToString(value ChargeItemDefinitionPriceComponentType): value.value
define function ToString(value ChargeItemStatus): value.value
define function ToString(value ClaimResponseStatus): value.value
define function ToString(value ClaimStatus): value.value
define function ToString(value ClinicalImpressionStatus): value.value
define function ToString(value CodeSearchSupport): value.value
define function ToString(value CodeSystemContentMode): value.value
define function ToString(value CodeSystemHierarchyMeaning): value.value
define function ToString(value CommunicationPriority): value.value
define function ToString(value CommunicationRequestStatus): value.value
define function ToString(value CommunicationStatus): value.value
define function ToString(value CompartmentCode): value.value
define function ToString(value CompartmentType): value.value
define function ToString(value CompositionAttestationMode): value.value
define function ToString(value CompositionStatus): value.value
define function ToString(value ConceptMapEquivalence): value.value
define function ToString(value ConceptMapGroupUnmappedMode): value.value
define function ToString(value ConditionalDeleteStatus): value.value
define function ToString(value ConditionalReadStatus): value.value
define function ToString(value ConsentDataMeaning): value.value
define function ToString(value ConsentProvisionType): value.value
define function ToString(value ConsentState): value.value
define function ToString(value ConstraintSeverity): value.value
define function ToString(value ContactPointSystem): value.value
define function ToString(value ContactPointUse): value.value
define function ToString(value ContractPublicationStatus): value.value
define function ToString(value ContractStatus): value.value
define function ToString(value ContributorType): value.value
define function ToString(value CoverageStatus): value.value
define function ToString(value CurrencyCode): value.value
define function ToString(value DayOfWeek): value.value
define function ToString(value DaysOfWeek): value.value
define function ToString(value DetectedIssueSeverity): value.value
define function ToString(value DetectedIssueStatus): value.value
define function ToString(value DeviceMetricCalibrationState): value.value
define function ToString(value DeviceMetricCalibrationType): value.value
define function ToString(value DeviceMetricCategory): value.value
define function ToString(value DeviceMetricColor): value.value
define function ToString(value DeviceMetricOperationalStatus): value.value
define function ToString(value DeviceNameType): value.value
define function ToString(value DeviceRequestStatus): value.value
define function ToString(value DeviceUseStatementStatus): value.value
define function ToString(value DiagnosticReportStatus): value.value
define function ToString(value DiscriminatorType): value.value
define function ToString(value DocumentConfidentiality): value.value
define function ToString(value DocumentMode): value.value
define function ToString(value DocumentReferenceStatus): value.value
define function ToString(value DocumentRelationshipType): value.value
define function ToString(value EligibilityRequestPurpose): value.value
define function ToString(value EligibilityRequestStatus): value.value
define function ToString(value EligibilityResponsePurpose): value.value
define function ToString(value EligibilityResponseStatus): value.value
define function ToString(value EnableWhenBehavior): value.value
define function ToString(value EncounterLocationStatus): value.value
define function ToString(value EncounterStatus): value.value
define function ToString(value EndpointStatus): value.value
define function ToString(value EnrollmentRequestStatus): value.value
define function ToString(value EnrollmentResponseStatus): value.value
define function ToString(value EpisodeOfCareStatus): value.value
define function ToString(value EventCapabilityMode): value.value
define function ToString(value EventTiming): value.value
define function ToString(value EvidenceVariableType): value.value
define function ToString(value ExampleScenarioActorType): value.value
define function ToString(value ExplanationOfBenefitStatus): value.value
define function ToString(value ExposureState): value.value
define function ToString(value ExtensionContextType): value.value
define function ToString(value FHIRAllTypes): value.value
define function ToString(value FHIRDefinedType): value.value
define function ToString(value FHIRDeviceStatus): value.value
define function ToString(value FHIRResourceType): value.value
define function ToString(value FHIRSubstanceStatus): value.value
define function ToString(value FHIRVersion): value.value
define function ToString(value FamilyHistoryStatus): value.value
define function ToString(value FilterOperator): value.value
define function ToString(value FlagStatus): value.value
define function ToString(value GoalLifecycleStatus): value.value
define function ToString(value GraphCompartmentRule): value.value
define function ToString(value GraphCompartmentUse): value.value
define function ToString(value GroupMeasure): value.value
define function ToString(value GroupType): value.value
define function ToString(value GuidanceResponseStatus): value.value
define function ToString(value GuidePageGeneration): value.value
define function ToString(value GuideParameterCode): value.value
define function ToString(value HTTPVerb): value.value
define function ToString(value IdentifierUse): value.value
define function ToString(value IdentityAssuranceLevel): value.value
define function ToString(value ImagingStudyStatus): value.value
define function ToString(value ImmunizationEvaluationStatus): value.value
define function ToString(value ImmunizationStatus): value.value
define function ToString(value InvoicePriceComponentType): value.value
define function ToString(value InvoiceStatus): value.value
define function ToString(value IssueSeverity): value.value
define function ToString(value IssueType): value.value
define function ToString(value LinkType): value.value
define function ToString(value LinkageType): value.value
define function ToString(value ListMode): value.value
define function ToString(value ListStatus): value.value
define function ToString(value LocationMode): value.value
define function ToString(value LocationStatus): value.value
define function ToString(value MeasureReportStatus): value.value
define function ToString(value MeasureReportType): value.value
define function ToString(value MediaStatus): value.value
define function ToString(value MedicationAdministrationStatus): value.value
define function ToString(value MedicationDispenseStatus): value.value
define function ToString(value MedicationKnowledgeStatus): value.value
define function ToString(value MedicationRequestIntent): value.value
define function ToString(value MedicationRequestPriority): value.value
define function ToString(value MedicationRequestStatus): value.value
define function ToString(value MedicationStatementStatus): value.value
define function ToString(value MedicationStatus): value.value
define function ToString(value MessageSignificanceCategory): value.value
define function ToString(value Messageheader_Response_Request): value.value
define function ToString(value MimeType): value.value
define function ToString(value NameUse): value.value
define function ToString(value NamingSystemIdentifierType): value.value
define function ToString(value NamingSystemType): value.value
define function ToString(value NarrativeStatus): value.value
define function ToString(value NoteType): value.value
define function ToString(value NutritiionOrderIntent): value.value
define function ToString(value NutritionOrderStatus): value.value
define function ToString(value ObservationDataType): value.value
define function ToString(value ObservationRangeCategory): value.value
define function ToString(value ObservationStatus): value.value
define function ToString(value OperationKind): value.value
define function ToString(value OperationParameterUse): value.value
define function ToString(value OrientationType): value.value
define function ToString(value ParameterUse): value.value
define function ToString(value ParticipantRequired): value.value
define function ToString(value ParticipantStatus): value.value
define function ToString(value ParticipationStatus): value.value
define function ToString(value PaymentNoticeStatus): value.value
define function ToString(value PaymentReconciliationStatus): value.value
define function ToString(value ProcedureStatus): value.value
define function ToString(value PropertyRepresentation): value.value
define function ToString(value PropertyType): value.value
define function ToString(value ProvenanceEntityRole): value.value
define function ToString(value PublicationStatus): value.value
define function ToString(value QualityType): value.value
define function ToString(value QuantityComparator): value.value
define function ToString(value QuestionnaireItemOperator): value.value
define function ToString(value QuestionnaireItemType): value.value
define function ToString(value QuestionnaireResponseStatus): value.value
define function ToString(value ReferenceHandlingPolicy): value.value
define function ToString(value ReferenceVersionRules): value.value
define function ToString(value ReferredDocumentStatus): value.value
define function ToString(value RelatedArtifactType): value.value
define function ToString(value RemittanceOutcome): value.value
define function ToString(value RepositoryType): value.value
define function ToString(value RequestIntent): value.value
define function ToString(value RequestPriority): value.value
define function ToString(value RequestStatus): value.value
define function ToString(value ResearchElementType): value.value
define function ToString(value ResearchStudyStatus): value.value
define function ToString(value ResearchSubjectStatus): value.value
define function ToString(value ResourceType): value.value
define function ToString(value ResourceVersionPolicy): value.value
define function ToString(value ResponseType): value.value
define function ToString(value RestfulCapabilityMode): value.value
define function ToString(value RiskAssessmentStatus): value.value
define function ToString(value SPDXLicense): value.value
define function ToString(value SearchComparator): value.value
define function ToString(value SearchEntryMode): value.value
define function ToString(value SearchModifierCode): value.value
define function ToString(value SearchParamType): value.value
define function ToString(value SectionMode): value.value
define function ToString(value SequenceType): value.value
define function ToString(value ServiceRequestIntent): value.value
define function ToString(value ServiceRequestPriority): value.value
define function ToString(value ServiceRequestStatus): value.value
define function ToString(value SlicingRules): value.value
define function ToString(value SlotStatus): value.value
define function ToString(value SortDirection): value.value
define function ToString(value SpecimenContainedPreference): value.value
define function ToString(value SpecimenStatus): value.value
define function ToString(value Status): value.value
define function ToString(value StrandType): value.value
define function ToString(value StructureDefinitionKind): value.value
define function ToString(value StructureMapContextType): value.value
define function ToString(value StructureMapGroupTypeMode): value.value
define function ToString(value StructureMapInputMode): value.value
define function ToString(value StructureMapModelMode): value.value
define function ToString(value StructureMapSourceListMode): value.value
define function ToString(value StructureMapTargetListMode): value.value
define function ToString(value StructureMapTransform): value.value
define function ToString(value SubscriptionChannelType): value.value
define function ToString(value SubscriptionStatus): value.value
define function ToString(value SupplyDeliveryStatus): value.value
define function ToString(value SupplyRequestStatus): value.value
define function ToString(value SystemRestfulInteraction): value.value
define function ToString(value TaskIntent): value.value
define function ToString(value TaskPriority): value.value
define function ToString(value TaskStatus): value.value
define function ToString(value TestReportActionResult): value.value
define function ToString(value TestReportParticipantType): value.value
define function ToString(value TestReportResult): value.value
define function ToString(value TestReportStatus): value.value
define function ToString(value TestScriptRequestMethodCode): value.value
define function ToString(value TriggerType): value.value
define function ToString(value TypeDerivationRule): value.value
define function ToString(value TypeRestfulInteraction): value.value
define function ToString(value UDIEntryType): value.value
define function ToString(value UnitsOfTime): value.value
define function ToString(value Use): value.value
define function ToString(value VariableType): value.value
define function ToString(value VisionBase): value.value
define function ToString(value VisionEyes): value.value
define function ToString(value VisionStatus): value.value
define function ToString(value XPathUsageType): value.value
define function ToString(value base64Binary): value.value
define function ToBoolean(value boolean): value.value
define function ToDate(value date): value.value
define function ToDateTime(value dateTime): value.value
define function ToDecimal(value decimal): value.value
define function ToDateTime(value instant): value.value
define function ToInteger(value integer): value.value
define function ToString(value string): value.value
define function ToTime(value time): value.value
define function ToString(value uri): value.value
define function ToString(value xhtml): value.value</code></pre> 
                           </td> 
                        </tr>   
                        <tr> 
                           <th colspan="2" scope="row" class="row-header">Generated using version 0.4.9 of the sample-content-ig Liquid templates</th> 
                        </tr> 
                     </tbody> 
                  </table> 
               </div>
            </text>
            <url value="https://madie.cms.gov/Library/FHIRHelpers"></url>
            <identifier>
               <use value="official"></use>
               <system value="https://madie.cms.gov/login"></system>
               <value value="660d90bc01598d085de46056"></value>
            </identifier>
            <version value="4.4.000"></version>
            <name value="FHIRHelpers"></name>
            <title value="FHIRHelpers"></title>
            <status value="active"></status>
            <experimental value="false"></experimental>
            <type>
               <coding>
                  <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
                  <code value="logic-library"></code>
               </coding>
            </type>
            <date value="2025-11-24T17:18:51+00:00"></date>
            <publisher value="ICF"></publisher>
            <description value="This library defines functions to convert between FHIR
 data types and CQL system-defined types, as well as functions to support
 FHIRPath implementation. For more information, the FHIRHelpers wiki page:
 https://github.com/cqframework/clinical_quality_language/wiki/FHIRHelpers"></description>
            <relatedArtifact>
               <type value="depends-on"></type>
               <display value="FHIR model information"></display>
               <resource value="http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1"></resource>
            </relatedArtifact>
            <content>
               <contentType value="text/cql"></contentType>
               <data value="[encoded data, 52440 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+xml"></contentType>
               <data value="[encoded data, 1342916 characters]"></data>
            </content>
            <content>
               <contentType value="application/elm+json"></contentType>
               <data value="[encoded data, 2177516 characters]"></data>
            </content>
         </Library>
      </resource>
      <request>
         <method value="POST"></method>
         <url value="Library/FHIRHelpers"></url>
      </request>
   </entry>
</Bundle>