Draft dQM CMS Content Implementation Guide
2025.1.0 - CI Build

Draft dQM CMS Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.1.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-cms-2025/ and changes regularly. See the Directory of published versions

Measure: Hospital Harm - Severe HypoglycemiaFHIR

Official URL: https://madie.cms.gov/Measure/CMS816FHIRHHHypo Version: 1.0.000
Active as of 2026-01-16 Responsible: Centers for Medicare & Medicaid Services (CMS) Computable Name: CMS816FHIRHHHypo
Other Identifiers: Short Name: CMS816FHIR (use: usual, ), UUID:1238aa6c-b533-4289-9ab9-8bb9900e9736 (use: official, ), UUID:7a1b776e-a7a3-4074-a523-8481a6638826 (use: official, ), Endorser: 3503e (use: official, ), Publisher: 816FHIR (use: official, )

Copyright/Legal: Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets. Mathematica disclaims all liability for use or accuracy of any third-party codes contained in the specifications. LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved.

The measure assesses the number of inpatient hospitalizations for patients age 18 and older who were administered at least one hypoglycemic medication during the encounter, who suffer the harm of a severe hypoglycemic event during the encounter

Metadata
Title Hospital Harm - Severe HypoglycemiaFHIR
Version 1.0.000
Short Name CMS816FHIR
GUID (Version Independent) urn:uuid:1238aa6c-b533-4289-9ab9-8bb9900e9736
GUID (Version Specific) urn:uuid:7a1b776e-a7a3-4074-a523-8481a6638826
CMS Identifier 816FHIR
CMS Consensus Based Entity Identifier 3503e
Effective Period 2026-01-01 through 2026-12-31
Steward (Publisher) Centers for Medicare & Medicaid Services (CMS)
Developer Mathematica
Description

The measure assesses the number of inpatient hospitalizations for patients age 18 and older who were administered at least one hypoglycemic medication during the encounter, who suffer the harm of a severe hypoglycemic event during the encounter

Copyright

Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets. Mathematica disclaims all liability for use or accuracy of any third-party codes contained in the specifications. LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved.

Disclaimer

This performance measure is not a clinical guideline and does not establish a standard of medical care, and has not been tested for all potential applications. THE MEASURES AND SPECIFICATIONS ARE PROVIDED "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

This measure focuses on severe hypoglycemia as an outcome in the hospital inpatient setting. In a study published by the Office of the Inspector General (OIG), in 2018 adverse drug events represented 43% of all adverse events in hospitals among Medicare patients; of those events, hypoglycemia was among the top 5 adverse drug events (Office of the Inspector General, 2022). Inpatient hypoglycemia can be life-threatening, and is associated with longer hospital stays and increased medical costs. Severe hypoglycemia (<40 mg/dL) occurs in 2-5% of hospitalized patients with diabetes mellitus, and medication-related hypoglycemic events are common causes of adverse drug events occurring in inpatient settings. Up to half of inpatient adverse drug events may be preventable, and recent studies show that rates of severe hypoglycemia vary across hospitals, suggesting opportunities for improved care (Santos et al., 2020). Rates of inpatient hypoglycemia events are considered an indicator of the quality of care provided by a hospital. Severe hypoglycemia events are largely avoidable by careful use of antihyperglycemic medication. Moreover, the rate of severe hypoglycemia varies across hospitals indicating an opportunity for improvement in care. The Agency for Healthcare Research and Quality (AHRQ) identified insulin and other hypoglycemic agents as high alert medications and associated adverse events to be included as a measure in the Medicare Patient Safety Monitoring System (MPSMS) (Classen et al., 2021). Hypoglycemic events are an adverse outcome that can cause patients to experience drowsiness, confusion, anxiety, irritability, sweating, weakness, increased heart rate, uncontrollable trembling, as well as loss of consciousness and seizure (American Diabetes Association, 2022; Cruz, 2020). It has been found that fasting glucose levels <100 mg/dL are predictors of hypoglycemia within the next 24 hours (ElSayed et al., 2023).

Clinical Recommendation Statement

From Section 16, Diabetes Care in the Hospital in the Standards of Medical Care in Diabetes by the American Diabetes Association, (American Diabetes Association, 2024): 16.12 A hypoglycemia management protocol should be adopted and implemented by each hospital or hospital system. A plan for preventing and treating hypoglycemia should be established for each individual. Episodes of hypoglycemia in the hospital should be documented in the electronic health record and tracked for quality assessment and quality improvement. 16.13 Treatment plans should be reviewed and changed as necessary to prevent hypoglycemia when a blood glucose value of <70 mg/dL (3.9 mmol/L) is documented. A standardized hospital-wide, nurse-initiated hypoglycemia treatment protocol should be in place to immediately address blood glucose levels of <70 mg/dL (3.9 mmol/L). In addition, individualized plans for preventing and treating hypoglycemia for each patient should also be developed. An American Diabetes Association consensus statement recommends that an individuals treatment plan be reviewed any time a blood glucose value of <70 mg/dL (3.9 mmol/L) occurs, as this level often predict subsequent level 3 hypoglycemia. Episodes of hypoglycemia in the hospital should be documented in the EHR and tracked. A key strategy is embedding hypoglycemia treatment into all insulin and insulin infusion orders. From the Endocrine Society clinical practice guideline on the Management of Hyperglycemia in Hospitalized Patients in Non-critical Care Setting (Korytkowski et al., 2022) as it relates to patients at high risk of hypoglycemia: Recommendation 1.1 In adults with insulin-treated diabetes hospitalized for noncritical illness who are at high risk of hypoglycemia, we suggest the use of real-time continuous glucose monitoring (CGM) with confirmatory bedside point-of-care blood glucose (POC-BG) monitoring for adjustments in insulin dosing rather than point-of-care blood glucose POC-BG testing alone in hospital settings where resources and training are available. Recommendation 2.1 Management of patients with glucocorticoid (GC)-associated hyperglycemia requires ongoing BG monitoring with adjustment of insulin dosing. All therapies require safeguards to avoid hypoglycemia when doses of GCs are tapered or abruptly discontinued. Recommendation 10.1 In adults with no prior history of diabetes hospitalized for noncritical illness with hyperglycemia [defined as BG > 140 mg/dL (7.8 mmol/L)] during hospitalization, we suggest initial therapy with correctional insulin over scheduled insulin therapy (defined as basal or basal/bolus insulin) to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L). For patients with persistent hyperglycemia [>= 2 POC-BG measurements >= 180 mg/dL (>=10.0 mmol/L) in a 24-hour period on correctional insulin alone], we suggest the addition of scheduled insulin therapy. Recommendation 10.2 In adults with diabetes treated with diet or noninsulin diabetes medications prior to admission, we suggest initial therapy with correctional insulin or scheduled insulin therapy to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L). For hospitalized adults started on correctional insulin alone and with persistent hyperglycemia [>=2 point-of-care blood glucose (POC-BG) measurements >= 180 mg/dL in a 24-hour period (>=10.0 mmol/L)], we suggest addition of scheduled insulin therapy. We suggest initiation of scheduled insulin therapy for patients with confirmed admission blood glucose (BG) >= 180 mg/dL (>=10.0 mmol/L). Recommendation 10.3 In adults with insulin-treated diabetes prior to admission who are hospitalized for noncritical illness, we recommend continuation of the scheduled insulin regimen modified for nutritional status and severity of illness to maintain glucose targets in the range of 100 to 180 mg/dL (5.6 to 10.0 mmol/L). Remarks Reductions in the dose of basal insulin (by 10% to 20%) at time of hospitalization may be required for patients on basal heavy insulin regimens (defined as doses of basal insulin >= 0.6 to 1.0 units/kg/day), in which basal insulin is being used inappropriately to cover meal-related excursions in BG.

Citation

American Diabetes Association Professional Practice Committee; 16. (2022). Diabetes Care in the Hospital: Standards of Medical Care in Diabetes-2022. Diabetes Care 1 January 2022; 45 (Supplement_1): S244-S253. https://doi.org/10.2337/dc22-S016

Citation

Classen, D. C. MD, MS; Munier, W. MD; Verzier, N. MSN, RN; Eldridge, N. MS; Hunt, D. MD; Metersky, M. MD; Richards, C. MD, MPH; Wang, Y. PhD; Brady, P. J. MD, MPH; Helwig, A. MD; Battles, J. PhD. (2021). Measuring Patient Safety: The Medicare Patient Safety Monitoring System (Past, Present, and Future). Journal of Patient Safety: April 2021 - Volume 17 - Issue 3 - p e234-e240 doi: 10.1097/PTS.0000000000000322

Citation

Cruz, P. (2020). Inpatient Hypoglycemia: The Challenge Remains. J Diabetes Sci Technol. 2020;14(3):560-566. doi:10.1177/1932296820918540

Citation

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

Citation

Office of Inspector General Adverse Events in Hospitals. (2022). A Quarter of Medicare Patients Experienced Harm in October 2018. https://oig.hhs.gov/oei/reports/OEI-06-18-00400.asp

Citation

Santos, C.A.Q., Conover, C., Shehab, N., et al. (2020). Electronic Measurement of a Clinical Quality Measure for Inpatient Hypoglycemic Events: A Multicenter Validation Study. Med Care. 2020;58(10):927-933. doi:10.1097/MLR.0000000000001398

Guidance (Usage) Note the measure is currently confined to using mg/dL as the unit of measurement for glucose results. Glucose levels are determined by laboratory or point-of-care (POC) tests, including capillary/glucometer blood glucose tests, and by interstitial fluid specimens from continuous glucose monitors. Glucose test results from urine specimens are not considered. Millimoles per liter (mmol/L) should be converted to milligrams per deciliter (mg/dL) for reporting this measure. This dQM is an episode-based measure. An episode is defined as each inpatient hospitalization or encounter that ends during the measurement period. This FHIR-based measure has been derived from the QDM-based measure: CMS816v5. 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).
Measure Group (Rate) (ID: Group_1)
Basis Encounter
Scoring Proportion
Improvement Notation Decreased score indicates improvement
Type Outcome
Rate Aggregation None
Initial Population ID: InitialPopulation_1
Description:

Inpatient hospitalizations that end during the measurement period for patients age 18 and older and at least one hypoglycemic medication administration starts during the encounter

Criteria: Initial Population
Denominator ID: Denominator_1
Description:

Equals Initial Population

Criteria: Denominator
Numerator ID: Numerator_1
Description:

Inpatient hospitalizations where a severe hypoglycemic event occurred during the encounter. A severe hypoglycemic event is: - A glucose result less than 40 mg/dL AND - A hypoglycemic medication was administered within 24 hours before the start of the severe hypoglycemic event (i.e., the glucose test with a result less than 40 mg/dL) AND -There was no subsequent repeat test for glucose with a result greater than 80 mg/dL within five minutes or less from the start of the initial glucose test with a result less than 40mg/dL Only one qualifying severe hypoglycemic event is counted in the numerator, and only one severe hypoglycemic event is counted per encounter. The 24-hour and 5-minute timeframes are based on the time the glucose was drawn, as this reflects the time the patient was experiencing that specific glucose level.

Criteria: Numerator
For every patient evaluated by this measure also identify payer, race, ethnicity and sex
Supplemental Data Elements
Supplemental Data Element ID: sde-ethnicity
Usage Code: Supplemental Data
Description: SDE Ethnicity
Logic Definition: SDE Ethnicity
Supplemental Data Element ID: sde-payer
Usage Code: Supplemental Data
Description: SDE Payer
Logic Definition: SDE Payer
Supplemental Data Element ID: sde-race
Usage Code: Supplemental Data
Description: SDE Race
Logic Definition: SDE Race
Supplemental Data Element ID: sde-sex
Usage Code: Supplemental Data
Description: SDE Sex
Logic Definition: SDE Sex
Measure Logic
Primary Library https://madie.cms.gov/Library/CMS816FHIRHHHypo
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Parameters
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
define "Initial Population":
  "Encounter With Hypoglycemic Medication Administration"
Definition
Denominator
define "Denominator":
  "Initial Population"
Definition
Numerator
define "Numerator":
  "Encounter With Severe Hypoglycemic Harm Event"
Definition
Logic Definitions
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: SupplementalDataElements
define "SDE Payer":
  [USQualityCore.Coverage: type in "Payer Type"] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }
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: SupplementalDataElements
define "SDE Race":
  (Patient.race()) R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }
Logic Definition Library Name: CMS816FHIRHHHypo
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: CMS816FHIRHHHypo
define "Qualifying Encounter":
  ["Encounter": "Encounter Inpatient"] InpatientEncounter
    where AgeInYearsAt(date from start of InpatientEncounter.period) >= 18
      and InpatientEncounter.period ends during day of "Measurement Period"
      and InpatientEncounter.status = 'finished'
Logic Definition Library Name: CMS816FHIRHHHypo
define "Hypoglycemic Medication Administration":
  ["MedicationAdministration": "Hypoglycemics Severe Hypoglycemia"] HypoMedication
    where HypoMedication.status = 'completed'
Logic Definition Library Name: CMS816FHIRHHHypo
define "Encounter With Hypoglycemic Medication Administration":
  "Qualifying Encounter" InpatientHospitalization
    with "Hypoglycemic Medication Administration" HypoglycemicMedication
      such that HypoglycemicMedication.effective.toInterval ( ) starts during InpatientHospitalization.hospitalizationWithObservation ( )
Logic Definition Library Name: CMS816FHIRHHHypo
define "Initial Population":
  "Encounter With Hypoglycemic Medication Administration"
Logic Definition Library Name: CMS816FHIRHHHypo
define "Denominator":
  "Initial Population"
Logic Definition Library Name: CMS816FHIRHHHypo
define "Glucose Test With Result Less Than 40":
  from
    "Denominator" InpatientHospitalization,
    "Hypoglycemic Medication Administration" HypoglycemicMedication,
    ["LaboratoryResultObservation": "Glucose Lab Test Mass Per Volume"] GlucoseTest
    let HospitalizationInterval: InpatientHospitalization.hospitalizationWithObservation ( ),
    HypoglycemicMedicationStart: HypoglycemicMedication.effective.toInterval ( ),
    GlucoseTestTime: GlucoseTest.effective.earliest ( )
    where GlucoseTestTime during HospitalizationInterval
      and GlucoseTest.status in { 'final', 'amended', 'corrected' }
      and GlucoseTest.value < 40 'mg/dL'
      and HypoglycemicMedicationStart starts 24 hours or less before or on GlucoseTestTime
    return GlucoseTest
Logic Definition Library Name: CMS816FHIRHHHypo
define "Low Glucose Test Followed By Glucose Test Result Greater Than 80":
  from
    "Denominator" InpatientHospitalization,
    "Glucose Test With Result Less Than 40" LowGlucoseTest,
    ["LaboratoryResultObservation": "Glucose Lab Test Mass Per Volume"] FollowupGlucoseTest
    let GlucoseTestTime: LowGlucoseTest.effective.earliest ( ),
    FollowupGlucoseTestTime: FollowupGlucoseTest.effective.earliest ( )
    where FollowupGlucoseTestTime 5 minutes or less after GlucoseTestTime
      and GlucoseTestTime during InpatientHospitalization.hospitalizationWithObservation ( )
      and FollowupGlucoseTestTime during InpatientHospitalization.hospitalizationWithObservation ( )
      and FollowupGlucoseTest.id !~ LowGlucoseTest.id
      and FollowupGlucoseTest.status in { 'final', 'amended', 'corrected' }
      and FollowupGlucoseTest.value > 80 'mg/dL'
    return LowGlucoseTest
Logic Definition Library Name: CMS816FHIRHHHypo
define "Severe Hypoglycemic Harm Event":
  "Glucose Test With Result Less Than 40" LowGlucoseTest
    where not ( LowGlucoseTest.id in "Low Glucose Test Followed By Glucose Test Result Greater Than 80".id )
Logic Definition Library Name: CMS816FHIRHHHypo
define "Encounter With Severe Hypoglycemic Harm Event":
  from
    "Denominator" InpatientHospitalization,
    "Severe Hypoglycemic Harm Event" HypoglycemicEvent
    let GlucoseTestTime: HypoglycemicEvent.effective.earliest ( ),
    HospitalizationInterval: InpatientHospitalization.hospitalizationWithObservation ( )
    where GlucoseTestTime during HospitalizationInterval
    return InpatientHospitalization
Logic Definition Library Name: CMS816FHIRHHHypo
define "Numerator":
  "Encounter With Severe Hypoglycemic Harm Event"
Logic Definition Library Name: CMS816FHIRHHHypo
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: CMS816FHIRHHHypo
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: CMS816FHIRHHHypo
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: CQMCommon
/*
@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]
Logic Definition Library Name: FHIRHelpers
define function ToString(value string): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value uri): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDate(value date): value.value
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: FHIRHelpers
define function ToString(value EncounterStatus): value.value
Logic Definition Library Name: FHIRHelpers
/*
@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
        }
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: FHIRHelpers
define function ToString(value MedicationAdministrationStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value dateTime): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value instant): value.value
Logic Definition Library Name: FHIRHelpers
/*
@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: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')
    end
Logic Definition Library Name: FHIRHelpers
/*
@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
Logic Definition Library Name: FHIRHelpers
define function ToString(value ObservationStatus): value.value
Logic Definition Library Name: FHIRCommon
/*
@description: Returns the single extension (if present) on the given resource with the specified url.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given resource with the specified url.
*/
define fluent function ext(domainResource DomainResource, url String):
  singleton from domainResource.exts(url)
Logic Definition Library Name: FHIRCommon
/*
@description: Returns any extensions defined on the given resource with the specified url
*/
define fluent function exts(domainResource DomainResource, url String):
  domainResource.extension E
    where E.url = url
    return E
Logic Definition Library Name: FHIRCommon
/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range 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 FHIR, allowing this function to be used across any resource.

The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.
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 Period, the result is a DateTime Interval.
If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.
If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.
If the input is a string, an error is raised indicating a single interval cannot be computed from a string.
If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,
and ending immediately prior to when the patient was the given Age plus one year.
If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given
by the low end of the Range, and ending immediately prior to when the patient was the Age given by the
high end of the Range plus one year.

NOTE: Due to the
complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used
with a Timing or String.
*/
define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):
  case
    when choice is FHIR.dateTime then
      Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
    when choice is FHIR.Period then
      FHIRHelpers.ToInterval(choice as FHIR.Period)
    when choice is FHIR.instant then
      Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
    when choice is FHIR.Age then
      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
    when choice is FHIR.Range then
      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
    when choice is FHIR.Timing then
      Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported')
    when choice is FHIR.string then
      Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
    else
      null as Interval<DateTime>
  end
Logic Definition Library Name: FHIRCommon
/*
@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<FHIR.dateTime, FHIR.Period, FHIR.Age, FHIR.Range>):
  (choice.toInterval()) period
    return
      if (period.hasStart()) then start of period
      else end of period
Logic Definition Library Name: FHIRCommon
/*
@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: FHIRCommon
/*
@description: Returns the single extension (if present) on the given element with the specified url.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given element with the specified url.
*/
define fluent function ext(element Element, url String):
  singleton from element.exts(url)
Logic Definition Library Name: FHIRCommon
/*
@description: Returns any extensions defined on the given element with the specified url.
*/
define fluent function exts(element Element, url String):
  element.extension E
    where E.url = url
    return E
Logic Definition Library Name: USCoreCommon
/*
@description: Returns the sex element as defined for the USCore patient profile
*/
define fluent function sex(patient Patient):
  patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-sex').value as FHIR.code
Logic Definition Library Name: USCoreCommon
define fluent function ethnicity(patient Patient):
  (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity')) E
    return {
      ombCategory: E.ext('ombCategory').value as FHIR.Coding,
      detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
      text: E.ext('text').value as FHIR.string
    }
Logic Definition Library Name: USCoreCommon
define fluent function race(patient Patient):
  (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-race')) E
    return {
      ombCategory: (E.exts('ombCategory')) o return o.value as FHIR.Coding,
      detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
      text: E.ext('text').value as FHIR.string
    }
Terminology
Code System Description: Code system SNOMEDCT
Resource: SNOMED CT (all versions)
Canonical URL: http://snomed.info/sct
Value Set Description: Value set Encounter Inpatient
Resource: Encounter Inpatient
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Value Set Description: Value set Hypoglycemics Severe Hypoglycemia
Resource: Hypoglycemics Severe Hypoglycemia
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1196.393
Value Set Description: Value set Observation Services
Resource: Observation Services
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Value Set Description: Value set Emergency Department Visit
Resource: Emergency Department Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Value Set Description: Value set Glucose Lab Test Mass Per Volume
Resource: Glucose Lab Test Mass Per Volume
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.34
Value Set Description: Value set Payer Type
Resource: Payer Type
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
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
Dependencies
Dependency Description: USQualityCore model information
Resource: https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild
Canonical URL: https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild
Dependency Description: USCore model information
Resource: http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived
Canonical URL: http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived
Dependency Description: FHIR model information
Resource: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1
Dependency Description: Library SDE
Resource: SupplementalDataElements version: 6.1.000
Canonical URL: https://madie.cms.gov/Library/SupplementalDataElements|6.1.000
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Library USCommon
Resource: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot
Canonical URL: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot
Dependency Description: Library FHIRCommon
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Dependency Description: Library CQMCommon
Resource: CQMCommon version: 5.1.000
Canonical URL: https://madie.cms.gov/Library/CQMCommon|5.1.000
Data Requirements
Data Requirement Type: Patient
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-patient
Must Support Elements: ombCategory, detailed, text
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period
Code Filter(s):
Path: type
ValueSet: Observation Services
Path: status
Code(s): [not stated]: finished (finished)
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period
Code Filter(s):
Path: type
ValueSet: Emergency Department Visit
Path: status
Code(s): [not stated]: finished (finished)
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Encounter Inpatient
Path: status
Code(s): [not stated]: finished (finished)
Data Requirement Type: Medication
Profile(s): Medication
Must Support Elements: id, code
Code Filter(s):
Path: code
ValueSet: Hypoglycemics Severe Hypoglycemia
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication.reference, status, effective
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication, status, effective
Code Filter(s):
Path: medication
ValueSet: Hypoglycemics Severe Hypoglycemia
Data Requirement Type: Patient
Profile(s): Patient
Must Support Elements: birthDate
Data Requirement Type: Observation
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-lab
Must Support Elements: code, effective, status, value, id
Code Filter(s):
Path: code
ValueSet: Glucose Lab Test Mass Per Volume
Data Requirement Type: Coverage
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Payer Type
Parameters
Name Use Card. Type Documentation
Measurement Period In 0..1 Period
SDE Sex Out 0..1 Coding
Numerator Out 0..* Encounter
Denominator Out 0..* Encounter
SDE Payer Out 0..* Resource
Initial Population Out 0..* Encounter
SDE Ethnicity Out 0..1 Resource
SDE Race Out 0..1 Resource
Generated using version 0.5.4 of the sample-content-ig Liquid templates