eCQM QICore Content Implementation Guide
2024.0.0 - CI Build

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

Measure: Core Clinical Data Elements for the Hybrid Hospital Wide Readmission Measure with Claims and Electronic Health Record Data HWRFHIR

Official URL: https://madie.cms.gov/Measure/CMSFHIR529HybridHospitalWideReadmission Version: 0.1.001
Active as of 2024-12-18 Responsible: Centers for Medicare & Medicaid Services (CMS) Computable Name: CMSFHIR529HybridHospitalWideReadmission
Other Identifiers: Short Name: CMS529FHIR (use: usual, ), UUID:66842e26-2256-4a2d-8dac-dd014c425748 (use: official, ), UUID:d95d574f-1d07-4a69-b14d-98a8b0b35f0a (use: official, ), Endorser: 2879 (use: official, ), Publisher: 529FHIR (use: official, )

Copyright/Legal: Limited proprietary coding is contained in these specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. All rights reserved.

LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc.

This logic is intended to extract electronic clinical data. This is not an electronic clinical quality measure and this logic will not produce measure results. Instead, it will produce a file containing the data that CMS will link with administrative claims to risk adjust the Hybrid HWR outcome measure. It is designed to extract the first resulted set of vital signs and basic laboratory results obtained from hospitalizations for adult Medicare Fee-For-Service (FFS) and Medicare Advantage (MA) patients admitted to acute care hospitals.

UNKNOWN

Title: Core Clinical Data Elements for the Hybrid Hospital Wide Readmission Measure with Claims and Electronic Health Record Data HWRFHIR
Id: CMSFHIR529HybridHospitalWideReadmission
Version: 0.1.001
Url: Core Clinical Data Elements for the Hybrid Hospital Wide Readmission Measure with Claims and Electronic Health Record Data HWRFHIR
Short Name Identifier:

CMS529FHIR

Version Independent Identifier:

urn:uuid:66842e26-2256-4a2d-8dac-dd014c425748

Version Specific Identifier:

urn:uuid:d95d574f-1d07-4a69-b14d-98a8b0b35f0a

Endorser (CMS Consensus Based Entity) Identifier:

2879

Publisher (CMS) Identifier:

529FHIR

Effective Period: 2026-07-01..2027-06-30
Publisher: Centers for Medicare & Medicaid Services (CMS)
Author: Lantana Consulting Group, Yale New Haven Health Service Corporation/ Center for Outcomes Research and Evaluation
Description:

This logic is intended to extract electronic clinical data. This is not an electronic clinical quality measure and this logic will not produce measure results. Instead, it will produce a file containing the data that CMS will link with administrative claims to risk adjust the Hybrid HWR outcome measure. It is designed to extract the first resulted set of vital signs and basic laboratory results obtained from hospitalizations for adult Medicare Fee-For-Service (FFS) and Medicare Advantage (MA) patients admitted to acute care hospitals.

Purpose:

UNKNOWN

Copyright:

Limited proprietary coding is contained in these specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. All rights reserved.

LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc.

Disclaimer:

These performance specifications are not clinical guidelines, do not establish a standard of medical care, and have not been tested for all potential applications.

THE MEASURES AND SPECIFICATIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.

Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].

Rationale:

The intent of this logic is to extract the FIRST valid set of clinical data elements from hospital electronic health records (EHRs) for all qualifying hospitalizations. The data will be linked with administrative claims to risk adjust the Hybrid HWR outcome measure. This work addresses stakeholder concerns that clinical data garnered from patients and used by clinicians to guide diagnostic decisions and treatment, are preferable to administrative claims data when profiling hospitals' case mix. We are calling the list of data elements for extraction the "HWR-specific core clinical data elements" (CCDE). The CCDE are the first set of vital signs and basic laboratory tests resulted from hospitalizations for adult Medicare FFS and MA patients, age 65 or older (Initial Population), after they arrive at the hospital to which they are subsequently admitted. For example, this first set of data values are often captured in the emergency department or in the pre-operative area, sometimes hours before a patient is admitted to that same facility.

These data elements were selected because they: 1. reflect patients' clinical status when they first present to the hospital, 2. are clinically and statistically relevant to patient outcomes, 3. are consistently obtained during adult inpatient hospitalizations based on current clinical practice, 4. are captured with a standard definition and recorded in a standard format across providers, and 5. are entered in structured fields that are feasibly retrieved from current EHR systems (YNHHS/CORE, 2015).

Additional data called Linking Variables are used to link EHR data files with administrative claims data for CMS to calculate results for the Hybrid HWR measure, which are: CMS Certification Number (CCN); Medicare Beneficiary Identifier (MBI); Inpatient Admission Date; and Discharge Date.

Clinical recommendation statement:

The logic is not meant to guide or alter the care patients receive. The purpose of this CCDE logic is to extract clinical data that are already routinely captured in EHRs from hospitalizations for adult patients. It is not intended to require that clinical staff perform additional measurements or tests that are not needed for diagnostic assessment or treatment of patients.

Guidance (Usage): These specifications are for use for data with discharges that occur between July 1, 2026 and June 30, 2027. The associated Hospital Specific Report (HSR) is anticipated to be released in Spring 2028. This logic guides the user to extract the FIRST valid resulted HWR-specific CCDEs for all Medicare FFS and MA hospitalizations for patients age 65 or older (Initial Population) directly admitted to the hospital or admitted to the same facility after being treated in another area such as the emergency department or hospital outpatient/same day surgery location. The logic supports extraction of the FIRST resulted vital signs and laboratory tests, where the result is not null, during the patient encounter or episode of care. This may include values captured after inpatient admission, as well as prior to inpatient admission, for example from the emergency department, pre-operative, or other outpatient areas associated with the hospital, as long as the values fall within the allowed timeframes specified in the measure logic. All clinical systems used in inpatient and outpatient locations associated with the hospital facility should be queried for core clinical data element values related to a patient who is subsequently admitted. Patients who arrive at the hospital on oxygen therapy will be flagged in the logic and the information will be incorporated into the risk adjustment models. Rationale: patients who arrive on oxygen may appear in better condition, that is, having a higher oxygen saturation due to oxygen administration, that is not truly reflective of the patient's status upon arrival. Value sets for the laboratory tests are represented using Logical Observation Identifiers Names Codes (LOINC) currently available for these tests. If the institution is using local codes to capture and store relevant laboratory test data, those sites should map that information to the LOINC code for reporting of the CCDEs. NOTE: It is recommended hospitals only report the FIRST resulted value for EACH core clinical data element collected in the appropriate timeframe, if available. Hospitals may also choose to report ALL values on an encounter during their entire admission; however, only the first resulted values are utilized in the logic for measure calculation. For each CCDE, it is recommended that hospitals report the below Unified Code for Units of Measure (UCUM) units, however, any units may be submitted. Where the reported unit is not easily converted to the requested UCUM units, the value will be set to missing and the median value reported for that CCDE will be imputed. CCDE UCUM Units Bicarbonate-------------------------------------meq/L mmol/L Creatinine---------------------------------------mg/dL Glucose------------------------------------------mg/dL mmol/L - Heart rate---------------------------------------{Beats}/min Hematocrit --------------------------------------% Oxygen saturation (by pulse oximetry)- -% Potassium----------------------------------------meq/L mmol/L Respiratory rate---------------------------------{Breaths}/min Sodium--------------------------------------------meq/L mmol/L Systolic blood pressure-----------------------mm[Hg] Temperature-------------------------------------Cel [degF] Weight---------------------------------------------kg [lb_av] g White blood cell count -----------------------{Cells}/uL 10*3/uL 10*9/L For each hospitalization please also submit the following Linking Variables: CMS Certification Number (CCN); Medicare Beneficiary Identifier (MBI); Inpatient Admission Date; and Discharge Date. This is an encounter-based measure. The initial population includes patients with inpatient hospitalizations and patients from Acute Hospital Care at Home programs, who are treated and billed as inpatients but receive care in their home. This FHIR-based measure has been derived from the QDM-based measure: CMS529v6. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (https://hl7.org/fhir/us/qicore/STU4.1.1/qdm-to-qicore.html).
Population Criteria:
67533fe346b6174510cfed57
Initial Population: All Medicare FFS and MA hospitalizations for patients aged 65 and older at the start of an inpatient admission, where the length of stay is less than 365 days, and the hospitalization ends during the measurement period. NOTE: All Medicare FFS and MA hospitalizations meeting the above criteria should be included, regardless of whether Medicare FFS/MA is the primary, secondary, or tertiary payer.
Supplemental Data Elements:

Encounter with First Body Temperature

Encounter with First Heart Rate

Encounter with First Oxygen Saturation

Encounter with First Respiratory Rate

Encounter with First Systolic Blood Pressure

Encounter with First Bicarbonate Lab Test

Encounter with First Creatinine Lab Test

Encounter with First Glucose Lab Test

Encounter with First Hematocrit Lab Test

Encounter with First Potassium Lab Test

Encounter with First Sodium Lab Test

Encounter with First White Blood Cells Lab Test

SDE Ethnicity

SDE Payer

SDE Race

SDE Sex

Encounter with First Weight Recorded

Supplemental Data Guidance : For hospitalizations in the Initial Population, report the FIRST resulted vital signs (physical exams) during current hospitalization. The physical exam CCDEs are as follows: Body Temperature Heart rate Oxygen saturation (by pulse oximetry) Respiratory rate Systolic blood pressure Body weight For laboratory test results, report the FIRST resulted laboratory tests where result is not null during current hospitalization. The laboratory test CCDEs are as follows: Bicarbonate Creatinine Glucose Hematocrit Potassium Sodium White blood cell count First values for the CCDEs may be resulted in the emergency department or other hospital outpatient locations within the hospital facility before a patient is subsequently admitted to the same hospital. First values for these data elements may also be resulted in an inpatient location for directly admitted patients who do not receive care in the emergency department or other hospital outpatient/same day surgery locations before admission. NOTE: Hospitals may choose to submit all, or only report the FIRST resulted value for EACH CCDE collected in the appropriate timeframe, if available. For every patient in the Initial Population, also identify payer, race, ethnicity and sex.
Libraries:
CMSFHIR529HybridHospitalWideReadmission
Terminology and Other Dependencies:
  • Library/CQMCommon|2.2.000
  • Library/FHIRHelpers|4.4.000
  • Library/QICoreCommon|2.1.000
  • Library/SupplementalDataElements|3.5.000
  • Logical Observation Identifiers, Names and Codes (LOINC)
  • AdministrativeGender
  • Encounter Inpatient
  • Medicare payer
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.12
  • Observation Services
  • Emergency Department Visit
  • Outpatient Surgery Service
  • Bicarbonate lab test
  • White blood cells count lab test
  • Hematocrit lab test
  • Glucose lab test
  • Creatinine lab test
  • Payer
  • Oxygen Saturation in Arterial Blood by Pulse Oximetry
  • Potassium lab test
  • Sodium lab test
  • Parameters:
    name use min max type
    Measurement Period In 0 1 Period
    Encounter with First Heart Rate Out 0 * Resource
    Encounter with First Bicarbonate Lab Test Out 0 * Resource
    Encounter with First White Blood Cells Lab Test Out 0 * Resource
    Encounter with First Hematocrit Lab Test Out 0 * Resource
    Encounter with First Glucose Lab Test Out 0 * Resource
    SDE Race Out 0 1 Resource
    Encounter with First Systolic Blood Pressure Out 0 * string
    SDE Sex Out 0 1 Coding
    Encounter with First Respiratory Rate Out 0 * Resource
    Encounter with First Creatinine Lab Test Out 0 * Resource
    Encounter with First Body Temperature Out 0 * Resource
    SDE Payer Out 0 * Resource
    Encounter with First Weight Recorded Out 0 * Resource
    Initial Population Out 0 * Resource
    SDE Ethnicity Out 0 1 Resource
    Encounter with First Oxygen Saturation Out 0 * Resource
    Encounter with First Potassium Lab Test Out 0 * Resource
    Encounter with First Sodium Lab Test Out 0 * Resource
    DataRequirements:
    Resource Type Resource Elements Valueset Name Valueset
    Encounter(QICoreEncounter) type status status.value period id id.value Observation Services Observation Services
    Encounter(QICoreEncounter) type status status.value period id id.value Emergency Department Visit Emergency Department Visit
    Encounter(QICoreEncounter) type period id id.value Outpatient Surgery Service Outpatient Surgery Service
    Encounter(QICoreEncounter) type status status.value period id id.value Encounter Inpatient Encounter Inpatient
    Patient(QICorePatient) race ethnicity
    Coverage(QICoreCoverage) type Medicare FFS payer Medicare payer
    Coverage(QICoreCoverage) type Medicare Advantage payer http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.12
    Coverage(QICoreCoverage) type period Payer Type Payer
    Observation(Observation Heart Rate Profile) effective status status.value value
    Observation(US Core Laboratory Result Observation Profile) code effective status status.value value issued issued.value Bicarbonate lab test Bicarbonate lab test
    Observation(US Core Laboratory Result Observation Profile) code effective status status.value value issued issued.value White blood cells count lab test White blood cells count lab test
    Observation(US Core Laboratory Result Observation Profile) code effective status status.value value issued issued.value Hematocrit lab test Hematocrit lab test
    Observation(US Core Laboratory Result Observation Profile) code effective status status.value value issued issued.value Glucose lab test Glucose lab test
    Observation(US Core Laboratory Result Observation Profile) code effective status status.value value issued issued.value Creatinine lab test Creatinine lab test
    Observation(US Core Laboratory Result Observation Profile) code effective status status.value value issued issued.value Potassium lab test Potassium lab test
    Observation(US Core Laboratory Result Observation Profile) code effective status status.value value issued issued.value Sodium lab test Sodium lab test
    Observation(Observation Blood Pressure Profile) status status.value effective component
    Observation(Observation Respiratory Rate Profile) effective status status.value value
    Observation(Observation Body Temperature Profile) effective status status.value value
    Observation(Observation Body Weight Profile) effective status status.value value
    Observation(QICoreObservation) code effective status status.value value Oxygen Saturation by Pulse Oximetry Oxygen Saturation in Arterial Blood by Pulse Oximetry
    Direct Reference Codes:
    display code system
    Systolic BP 8480-6 http://loinc.org
    Male M http://hl7.org/fhir/administrative-gender
    Female F http://hl7.org/fhir/administrative-gender
    Logic Definitions:
    Group Scoring Population Criteria Expression
    67533fe346b6174510cfed57 Group scoring: cohort
    Type:

    Outcome

    Rate Aggregation: None
    Improvement Notation:

    decrease

    Initial Population
    define "Initial Population":
      "Inpatient Encounters"
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Inpatient Encounters
    define "Inpatient Encounters":
      [Encounter: "Encounter Inpatient"] InpatientEncounter
        with ( [Coverage: "Medicare FFS payer"]
          union [Coverage: "Medicare Advantage payer"] ) MedicarePayer
          such that ( InpatientEncounter.hospitalizationWithObservationAndOutpatientSurgeryService ( ).lengthInDays ( ) ) < 365
            and InpatientEncounter.status = 'finished'
            and AgeInYearsAt(date from start of InpatientEncounter.period) >= 65
            and InpatientEncounter.period ends during day of "Measurement Period"
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Heart Rate
    define "Encounter with First Heart Rate":
      "Inpatient Encounters" EncounterInpatient
        let FirstHeartRate: First(["observation-heartrate"] HeartRate
            where HeartRate.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and HeartRate.status in { 'final', 'amended', 'corrected' }
              and HeartRate.value is not null
            sort by effective.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstHeartRateResult: FirstHeartRate.value as Quantity,
          Timing: FirstHeartRate.effective.earliest ( )
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Bicarbonate Lab Test
    define "Encounter with First Bicarbonate Lab Test":
      "Inpatient Encounters" EncounterInpatient
        let FirstBicarbonateLab: First(["US Core Laboratory Result Observation Profile": "Bicarbonate lab test"] bicarbonatelab
            where bicarbonatelab.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and bicarbonatelab.status in { 'final', 'amended', 'corrected' }
              and bicarbonatelab.value is not null
            sort by issued.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstBicarbonateLab.value as Quantity,
          Timing: FirstBicarbonateLab.issued
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First White Blood Cells Lab Test
    define "Encounter with First White Blood Cells Lab Test":
      "Inpatient Encounters" EncounterInpatient
        let FirstWhiteBloodCellLab: First(["US Core Laboratory Result Observation Profile": "White blood cells count lab test"] WhiteBloodCellLab
            where WhiteBloodCellLab.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and WhiteBloodCellLab.status in { 'final', 'amended', 'corrected' }
              and WhiteBloodCellLab.value is not null
            sort by issued.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstWhiteBloodCellLab.value as Quantity,
          Timing: FirstWhiteBloodCellLab.issued
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Hematocrit Lab Test
    define "Encounter with First Hematocrit Lab Test":
      "Inpatient Encounters" EncounterInpatient
        let FirstHematocritLab: First(["US Core Laboratory Result Observation Profile": "Hematocrit lab test"] HematocritLab
            where HematocritLab.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and HematocritLab.status in { 'final', 'amended', 'corrected' }
              and HematocritLab.value is not null
            sort by issued.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstHematocritLab.value as Quantity,
          Timing: FirstHematocritLab.issued
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Glucose Lab Test
    define "Encounter with First Glucose Lab Test":
      "Inpatient Encounters" EncounterInpatient
        let FirstGlucoseLab: First(["US Core Laboratory Result Observation Profile": "Glucose lab test"] GlucoseLab
            where GlucoseLab.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and GlucoseLab.status in { 'final', 'amended', 'corrected' }
              and GlucoseLab.value is not null
            sort by issued.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstGlucoseLab.value as Quantity,
          Timing: FirstGlucoseLab.issued
        }
    Library Name Name
    SupplementalDataElements SDE Race
    define "SDE Race":
      Patient.race R
        return Tuple {
          codes: R.ombCategory union R.detailed,
          display: R.text
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission SDE Race
    define "SDE Race":
      SDE."SDE Race"
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Blood Pressure Reading
    define "Blood Pressure Reading":
      ["observation-bp"] BloodPressure
        where BloodPressure.status in { 'final', 'amended', 'corrected' }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Systolic Blood Pressure
    define "Encounter with First Systolic Blood Pressure":
      "Inpatient Encounters" EncounterInpatient
        let FirstSystolicBP: First("Blood Pressure Reading" SBPReading
            where SBPReading.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
            return singleton from(SBPReading.component SBPComponent
                where SBPComponent.code ~ "Systolic blood pressure"
                return SBPComponent.value as Quantity
            )
            sort ascending
        )
        return EncounterInpatient.id
    Library Name Name
    SupplementalDataElements SDE Sex
    define "SDE Sex":
      case
        when Patient.gender = 'male' then "M"
        when Patient.gender = 'female' then "F"
        else null
      end
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission SDE Sex
    define "SDE Sex":
      SDE."SDE Sex"
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Respiratory Rate
    define "Encounter with First Respiratory Rate":
      "Inpatient Encounters" EncounterInpatient
        let FirstRespRate: First(["observation-resprate"] RespRate
            where RespRate.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and RespRate.status in { 'final', 'amended', 'corrected' }
              and RespRate.value is not null
            sort by effective.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstRespRateResult: FirstRespRate.value as Quantity,
          Timing: FirstRespRate.effective.earliest ( )
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Creatinine Lab Test
    define "Encounter with First Creatinine Lab Test":
      "Inpatient Encounters" EncounterInpatient
        let FirstCreatinineLab: First(["US Core Laboratory Result Observation Profile": "Creatinine lab test"] CreatinineLab
            where CreatinineLab.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and CreatinineLab.status in { 'final', 'amended', 'corrected' }
              and CreatinineLab.value is not null
            sort by issued.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstCreatinineLab.value as Quantity,
          Timing: FirstCreatinineLab.issued
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Body Temperature
    define "Encounter with First Body Temperature":
      "Inpatient Encounters" EncounterInpatient
        let FirstTemperature: First(["observation-bodytemp"] temperature
            where temperature.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and temperature.status in { 'final', 'amended', 'corrected' }
              and temperature.value is not null
            sort by effective.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstTemperatureResult: FirstTemperature.value as Quantity,
          Timing: FirstTemperature.effective.earliest ( )
        }
    Library Name Name
    SupplementalDataElements SDE Payer
    define "SDE Payer":
      [Coverage: type in "Payer Type"] Payer
        return {
          code: Payer.type,
          period: Payer.period
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission SDE Payer
    define "SDE Payer":
      SDE."SDE Payer"
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Weight Recorded
    define "Encounter with First Weight Recorded":
      "Inpatient Encounters" EncounterInpatient
        let FirstWeight: First(["observation-bodyweight"] WeightExam
            where WeightExam.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and WeightExam.status in { 'final', 'amended', 'corrected' }
              and WeightExam.value is not null
            sort by effective.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstWeight.value as Quantity,
          Timing: FirstWeight.effective.earliest ( )
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Initial Population
    define "Initial Population":
      "Inpatient Encounters"
    Library Name Name
    SupplementalDataElements SDE Ethnicity
    define "SDE Ethnicity":
      Patient.ethnicity E
        return Tuple {
          codes: { E.ombCategory } union E.detailed,
          display: E.text
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission SDE Ethnicity
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Oxygen Saturation
    define "Encounter with First Oxygen Saturation":
      "Inpatient Encounters" EncounterInpatient
        let FirstOxygenSat: First([Observation: "Oxygen Saturation by Pulse Oximetry"] O2Saturation
            where O2Saturation.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and O2Saturation.status in { 'final', 'amended', 'corrected' }
              and O2Saturation.value is not null
            sort by effective.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstOxygenSatResult: FirstOxygenSat.value as Quantity,
          Timing: FirstOxygenSat.effective.earliest ( )
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Potassium Lab Test
    define "Encounter with First Potassium Lab Test":
      "Inpatient Encounters" EncounterInpatient
        let FirstPotassiumLab: First(["US Core Laboratory Result Observation Profile": "Potassium lab test"] PotassiumLab
            where PotassiumLab.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and PotassiumLab.status in { 'final', 'amended', 'corrected' }
              and PotassiumLab.value is not null
            sort by issued.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstPotassiumLab.value as Quantity,
          Timing: FirstPotassiumLab.issued
        }
    Library Name Name
    CMSFHIR529HybridHospitalWideReadmission Encounter with First Sodium Lab Test
    define "Encounter with First Sodium Lab Test":
      "Inpatient Encounters" EncounterInpatient
        let FirstSodiumLab: First(["US Core Laboratory Result Observation Profile": "Sodium lab test"] SodiumLab
            where SodiumLab.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
              and SodiumLab.status in { 'final', 'amended', 'corrected' }
              and SodiumLab.value is not null
            sort by issued.earliest()
        )
        return {
          EncounterId: EncounterInpatient.id,
          FirstResult: FirstSodiumLab.value as Quantity,
          Timing: FirstSodiumLab.issued
        }
    Library Name Name
    CQMCommon lengthInDays
    /*
    @description: Calculates the difference in calendar days between the start and end of the given interval.
    */
    define fluent function lengthInDays(Value Interval<DateTime> ):
      difference in days between start of Value and end of Value
    Library Name Name
    CQMCommon hospitalizationWithObservationAndOutpatientSurgeryService
    /*
    @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]
    Library Name Name
    QICoreCommon earliest
    /*
    @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<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>> ):
      (choice.toInterval()) period
        return
          if (period."hasStart"()) then start of period
          else end of period
    Library Name Name
    FHIRHelpers ToString
    define function ToString(value uri): value.value
    Library Name Name
    FHIRHelpers ToCode
    /*
    @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
            }