dQM QICore Content Implementation Guide
2025.0.0 - CI Build

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

Measure: Core Clinical Data Elements HW Readmn FHIR

Official URL: https://madie.cms.gov/Measure/CMSFHIR529HybridHospitalWideReadmission Version: Draft based on 0.5.001
Draft as of 2025-06-11 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:8481929d-4878-4b5d-a078-2c52591a515a (use: official, ), Endorser: 2879 (use: official, ), Publisher: 529FHIR (use: official, )

Usage:Venue: EH

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.

Knowledge Artifact Metadata
Name (machine-readable) CMSFHIR529HybridHospitalWideReadmission
Title (human-readable) Core Clinical Data Elements HW Readmn FHIR
Status draft
Experimental false
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.
Clinical 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. As this is a hybrid outcome measure, the electronic specifications contained within this document only cover the case-mix risk-adjustment variables, which ultimately need to be combined with the claims data to calculate an outcome. The logic contained here cannot be used alone to calculate outcome or performance. 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. 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/STU6/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 6 (https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html).
Effective Period 2026-07-01..2027-06-30
Use Context org.hl7.fhir.r5.model.UsageContext@53dfc972
Measure Developer Lantana Consulting Group
Measure Developer Yale New Haven Health Service Corporation/ Center for Outcomes Research and Evaluation
Measure Steward Centers for Medicare & Medicaid Services (CMS)
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.
Citation Citation: CITATION - YYale New Haven Health Services Corporation/Center for Outcomes Research & Evaluation (YNHHSC/CORE). (2015). 2013 Core Clinical Data Elements Technical Report (Version 1.1). Centers for Medicare & Medicaid Services. https://www.cms.gov/Medicare/Quality-Initiatives-Patient-Assessment-Instruments/HospitalQualityInits/Downloads/Core-Clinical-Data-Elements-and-Hybrid-Measures.zip
Measure Metadata
Short Name Identifier CMS529FHIR
Version Independent Identifier urn:uuid:66842e26-2256-4a2d-8dac-dd014c425748
Version Specific Identifier urn:uuid:8481929d-4878-4b5d-a078-2c52591a515a
Publisher (CMS) Identifier 529FHIR
Identifier 2879
Version Number Draft based on 0.5.001
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.
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 For oxygen administration CCDE, report oxygen administered during Emergency Department (ED) admission OR 60 minutes prior to ED admission First values for the physical exam and laboratory test 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.
Measure Population Criteria (ID: Group_1)
Summary 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.
Initial Population ID: InitialPopulation_1
Description:

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.

Logic Definition: Initial Population
Population Basis Encounter
Scoring [http://terminology.hl7.org/CodeSystem/measure-scoring#cohort: 'Cohort']
Type [http://terminology.hl7.org/CodeSystem/measure-type#outcome: 'Outcome']
Rate Aggregation None
Improvement Notation [http://terminology.hl7.org/CodeSystem/measure-improvement-notation#decrease: 'decrease']
Supplemental Data Elements
Supplemental Data Element ID: sde-encounter-with-first-body-temperature
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Body Temperature
Logic Definition: SDE Encounter With First Body Temperature
Supplemental Data Element ID: sde-encounter-with-first-heart-rate
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Heart Rate
Logic Definition: SDE Encounter With First Heart Rate
Supplemental Data Element ID: sde-encounter-with-first-oxygen-saturation
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Oxygen Saturation
Logic Definition: SDE Encounter With First Oxygen Saturation
Supplemental Data Element ID: sde-encounter-with-first-respiratory-rate
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Respiratory Rate
Logic Definition: SDE Encounter With First Respiratory Rate
Supplemental Data Element ID: sde-encounter-with-first-systolic-blood-pressure
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Systolic Blood Pressure
Logic Definition: SDE Encounter With First Systolic Blood Pressure
Supplemental Data Element ID: sde-encounter-with-first-bicarbonate-lab-test
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Bicarbonate Lab Test
Logic Definition: SDE Encounter With First Bicarbonate Lab Test
Supplemental Data Element ID: sde-encounter-with-first-creatinine-lab-test
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Creatinine Lab Test
Logic Definition: SDE Encounter With First Creatinine Lab Test
Supplemental Data Element ID: sde-encounter-with-first-glucose-lab-test
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Glucose Lab Test
Logic Definition: SDE Encounter With First Glucose Lab Test
Supplemental Data Element ID: sde-encounter-with-first-hematocrit-lab-test
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Hematocrit Lab Test
Logic Definition: SDE Encounter With First Hematocrit Lab Test
Supplemental Data Element ID: sde-encounter-with-first-potassium-lab-test
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Potassium Lab Test
Logic Definition: SDE Encounter With First Potassium Lab Test
Supplemental Data Element ID: sde-encounter-with-first-sodium-lab-test
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Sodium Lab Test
Logic Definition: SDE Encounter With First Sodium Lab Test
Supplemental Data Element ID: sde-encounter-with-first-white-blood-cells-lab-test
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First White Blood Cells Lab Test
Logic Definition: SDE Encounter With First White Blood Cells Lab Test
Supplemental Data Element ID: sde-encounter-with-first-weight-recorded
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With First Weight Recorded
Logic Definition: SDE Encounter With First Weight Recorded
Supplemental Data Element ID: sde-encounter-with-oxygen-60-minutes-or-less-prior-to-ed-admission-or-during-ed
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Encounter With Oxygen 60 Minutes Or Less Prior To ED Admission Or During ED
Logic Definition: SDE Encounter With Oxygen 60 Minutes Or Less Prior To ED Admission Or During ED
Supplemental Data Element ID: sde-ethnicity
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Ethnicity
Logic Definition: SDE Ethnicity
Supplemental Data Element ID: sde-payer
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Payer
Logic Definition: SDE Payer
Supplemental Data Element ID: sde-race
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Race
Logic Definition: SDE Race
Supplemental Data Element ID: sde-sex
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Sex
Logic Definition: SDE Sex
Measure Logic
Primary Library https://madie.cms.gov/Library/CMSFHIR529HybridHospitalWideReadmission
Dependency Description: Library CQMCommon
Resource: https://madie.cms.gov/Library/CQMCommon|4.1.000
Canonical URL: https://madie.cms.gov/Library/CQMCommon|4.1.000
Dependency Description: Library FHIRHelpers
Resource: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
Canonical URL: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
Dependency Description: Library QICoreCommon
Resource: https://madie.cms.gov/Library/QICoreCommon|4.0.000
Canonical URL: https://madie.cms.gov/Library/QICoreCommon|4.0.000
Dependency Description: Library SDE
Resource: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
Canonical URL: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
Dependency Description: Code system LOINC
Resource: http://loinc.org
Canonical URL: http://loinc.org
Dependency Description: Code system SNOMEDCT
Resource: http://snomed.info/sct
Canonical URL: http://snomed.info/sct
Dependency Description: Value set Encounter Inpatient
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Dependency Description: Value set Medicare FFS payer
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.10
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.10
Dependency Description: Value set Medicare Advantage payer
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.12
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.12
Dependency Description: Value set Observation Services
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Dependency Description: Value set Emergency Department Visit
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Dependency Description: Value set Outpatient Surgery Service
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38
Dependency Description: Value set Creatinine lab test
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.2363
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.2363
Dependency Description: Value set White blood cells count lab test
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.129
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.129
Dependency Description: Value set Sodium lab test
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.119
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.119
Dependency Description: Value set Hematocrit lab test
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.114
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.114
Dependency Description: Value set Non Invasive Oxygen Therapy by Nasal Cannula or Mask
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.209
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.209
Dependency Description: Value set Non Invasive Oxygen Therapy Device Codes
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.57
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.57
Dependency Description: Value set Oxygen Saturation by Pulse Oximetry
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.151
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.151
Dependency Description: Value set Potassium lab test
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.117
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.117
Dependency Description: Value set Payer Type
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Dependency Description: Value set Bicarbonate lab test
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.139
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.139
Dependency Description: Value set Glucose lab test
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.134
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.134
Direct Reference Code Display: Systolic BP
Code: 8480-6
System: http://loinc.org
Direct Reference Code Display: Male (finding)
Code: 248153007
System: http://snomed.info/sct
Direct Reference Code Display: Female (finding)
Code: 248152002
System: http://snomed.info/sct
Parameter Name: Measurement Period
Use: in
Min Cardinality: 0
Max Cardinality: 1
Type: Period
Parameter Name: Initial Population
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Creatinine Lab Test
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Systolic Blood Pressure
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First White Blood Cells Lab Test
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Sodium Lab Test
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Weight Recorded
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Race
Use: out
Min Cardinality: 0
Max Cardinality: 1
Type: Resource
Parameter Name: SDE Encounter With First Hematocrit Lab Test
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With Oxygen 60 Minutes Or Less Prior To ED Admission Or During ED
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Respiratory Rate
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Sex
Use: out
Min Cardinality: 0
Max Cardinality: 1
Type: Coding
Parameter Name: SDE Encounter With First Heart Rate
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Oxygen Saturation
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Potassium Lab Test
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Payer
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Ethnicity
Use: out
Min Cardinality: 0
Max Cardinality: 1
Type: Resource
Parameter Name: SDE Encounter With First Bicarbonate Lab Test
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Body Temperature
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Encounter With First Glucose Lab Test
Use: out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Measure Logic Data Requirements
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period, id, id.value
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, period, id, id.value
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.38
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period, id, id.value
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period, id, id.value
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: period, id, id.value
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: url, extension, birthDate, birthDate.value
Data Requirement Type: Coverage
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage
Must Support Elements: type
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.10
Data Requirement Type: Coverage
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage
Must Support Elements: type
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1104.12
Data Requirement Type: Coverage
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, status, status.value, value, issued, issued.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.2363
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, status, status.value, value, issued, issued.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.129
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, status, status.value, value, issued, issued.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.119
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, status, status.value, value, issued, issued.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.114
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, status, status.value, value, issued, issued.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.117
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, status, status.value, value, issued, issued.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.139
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, status, status.value, value, issued, issued.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.134
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-blood-pressure
Must Support Elements: effective, status, status.value, component
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-weight
Must Support Elements: effective, status, status.value, value
Data Requirement Type: ServiceRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest
Must Support Elements: code, authoredOn, authoredOn.value, status, status.value, intent, intent.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.209
Data Requirement Type: ServiceRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest
Must Support Elements: code, authoredOn, authoredOn.value, status, status.value, intent, intent.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.57
Data Requirement Type: Procedure
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure
Must Support Elements: code, performed, status, status.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.209
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-respiratory-rate
Must Support Elements: effective, status, status.value, value
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-heart-rate
Must Support Elements: effective, status, status.value, value
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry
Must Support Elements: code, effective, status, status.value, value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.151
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-temperature
Must Support Elements: effective, status, status.value, value
Measure Logic Definitions
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
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"
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Creatinine Lab Test":
  "Inpatient Encounters" EncounterInpatient
    let FirstCreatinineLab: First(["LaboratoryResultObservation": "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
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Systolic Blood Pressure":
  "Inpatient Encounters" EncounterInpatient
    let FirstSystolicBP: First(["USCoreBloodPressureProfile"] BP
        where BP.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
          and BP.status in { 'final', 'amended', 'corrected' }
          and BP.component.value is not null
        sort by effective.earliest()
    )
    return {
      EncounterId: EncounterInpatient.id,
      FirstSBPResult: FirstSystolicBP.component C
        where C.code ~ "Systolic blood pressure"
        return C.value as Quantity,
      Timing: FirstSystolicBP.effective.earliest ( )
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First White Blood Cells Lab Test":
  "Inpatient Encounters" EncounterInpatient
    let FirstWhiteBloodCellLab: First(["LaboratoryResultObservation": "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
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Sodium Lab Test":
  "Inpatient Encounters" EncounterInpatient
    let FirstSodiumLab: First(["LaboratoryResultObservation": "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
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Weight Recorded":
  "Inpatient Encounters" EncounterInpatient
    let FirstWeight: First(["USCoreBodyWeightProfile"] 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 ( )
    }
Logic Definition Library Name: SupplementalDataElements
define "SDE Race":
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Hematocrit Lab Test":
  "Inpatient Encounters" EncounterInpatient
    let FirstHematocritLab: First(["LaboratoryResultObservation": "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
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "Initial Population":
  "Inpatient Encounters"
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With Oxygen 60 Minutes Or Less Prior To ED Admission Or During ED":
  "Initial Population" EncounterInpatient
    where exists ( ( [ServiceRequest: "Non Invasive Oxygen Therapy by Nasal Cannula or Mask"]
        union [ServiceRequest: "Non Invasive Oxygen Therapy Device Codes"] ) OxygenTherapyOrder
        where ( OxygenTherapyOrder.authoredOn during EncounterInpatient.edVisit ( ).period
            or OxygenTherapyOrder.authoredOn 60 minutes or less before or on start of EncounterInpatient.edVisit ( ).period
        )
          and OxygenTherapyOrder.status in { 'active', 'completed' }
          and OxygenTherapyOrder.intent = 'order'
        return {
          EncounterId: EncounterInpatient.id,
          OrderStatus: OxygenTherapyOrder.status,
          OrderTiming: OxygenTherapyOrder.authoredOn
        }
    )
      or exists ( [Procedure: "Non Invasive Oxygen Therapy by Nasal Cannula or Mask"] OxygenAdminInterv
          where ( OxygenAdminInterv.performed.toInterval ( ) starts during EncounterInpatient.edVisit ( ).period
              or OxygenAdminInterv.performed.toInterval ( ) 60 minutes or less before or on start of EncounterInpatient.edVisit ( ).period
          )
            and OxygenAdminInterv.status = 'completed'
          return {
            EncounterId: EncounterInpatient.id,
            EDEncounterTiming: EncounterInpatient.edVisit ( ).period,
            PerformedStatus: OxygenAdminInterv.status,
            PerformedTiming: OxygenAdminInterv.performed.toInterval ( )
          }
      )
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Respiratory Rate":
  "Inpatient Encounters" EncounterInpatient
    let FirstRespRate: First([USCoreRespiratoryRateProfile] Respirations
        where Respirations.effective.earliest() during EncounterInpatient.hospitalizationWithObservationAndOutpatientSurgeryService()
          and Respirations.status in { 'final', 'amended', 'corrected' }
          and Respirations.value is not null
        sort by effective.earliest()
    )
    return {
      EncounterId: EncounterInpatient.id,
      FirstRespRateResult: FirstRespRate.value as Quantity,
      Timing: FirstRespRate.effective.earliest ( )
    }
Logic Definition Library Name: SupplementalDataElements
define "SDE Sex":
  case
    when Patient.sex = '248153007' then "Male (finding)"
    when Patient.sex = '248152002' then "Female (finding)"
    else null
  end
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Heart Rate":
  "Inpatient Encounters" EncounterInpatient
    let FirstHeartRate: First([USCoreHeartRateProfile] 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 ( )
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Oxygen Saturation":
  "Inpatient Encounters" EncounterInpatient
    let FirstOxygenSat: First(["USCorePulseOximetryProfile": "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 ( )
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Potassium Lab Test":
  "Inpatient Encounters" EncounterInpatient
    let FirstPotassiumLab: First(["LaboratoryResultObservation": "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
    }
Logic Definition Library Name: SupplementalDataElements
define "SDE Payer":
  [Coverage: type in "Payer Type"] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: SupplementalDataElements
define "SDE Ethnicity":
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Bicarbonate Lab Test":
  "Inpatient Encounters" EncounterInpatient
    let FirstBicarbonateLab: First(["LaboratoryResultObservation": "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
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Body Temperature":
  "Inpatient Encounters" EncounterInpatient
    let FirstTemperature: First([USCoreBodyTemperatureProfile] 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 ( )
    }
Logic Definition Library Name: CMSFHIR529HybridHospitalWideReadmission
define "SDE Encounter With First Glucose Lab Test":
  "Inpatient Encounters" EncounterInpatient
    let FirstGlucoseLab: First(["LaboratoryResultObservation": "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
    }
Logic Definition Library Name: CQMCommon
/*
@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
Logic Definition Library Name: CQMCommon
/*
@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]
Logic Definition Library Name: FHIRHelpers
/*
@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]
Logic Definition Library Name: QICoreCommon
/*
@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
Logic Definition Library Name: QICoreCommon
/*
@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<DateTime> ):
  not ( start of period is null
      or start of period = minimum DateTime
  )
Logic Definition Library Name: FHIRHelpers
define function ToString(value uri): value.value
Logic Definition Library Name: FHIRHelpers
/*
@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
        }
Logic Definition Library Name: CQMCommon
/*
@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
    )
Logic Definition Library Name: QICoreCommon
/*
@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<DateTime>, or Interval<Quantity> 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<DateTime> or Interval<Quantity>.
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<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>, Timing>):
  case
	  when choice is DateTime then
    	Interval[choice as DateTime, choice as DateTime]
		when choice is Interval<DateTime> then
  		choice as Interval<DateTime>
		when choice is Quantity then
		  Interval[Patient.birthDate + (choice as Quantity),
			  Patient.birthDate + (choice as Quantity) + 1 year)
		when choice is Interval<Quantity> 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<DateTime>
		else
			null as Interval<DateTime>
	end
Generated using version 0.4.7 of the sample-content-ig Liquid templates