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: Oncology: Medical and Radiation Pain Intensity QuantifiedFHIR

Official URL: https://madie.cms.gov/Measure/CMS157FHIRPainIntensityQuantified Version: 1.0.000
Active as of 2026-01-16 Responsible: American Society of Clinical Oncology Computable Name: CMS157FHIRPainIntensityQuantified
Other Identifiers: Short Name: CMS157FHIR (use: usual, ), UUID:b7b487bf-bc27-48c9-994f-6d095ff84500 (use: official, ), UUID:0f0317d4-38c3-4b87-b0a9-9b74aaa9a466 (use: official, ), Endorser: 0384e (use: official, ), Publisher: 157FHIR (use: official, )

Copyright/Legal: Copyright 2025 American Society of Clinical Oncology. All Rights Reserved.

Percentage of patient visits, regardless of patient age, with a diagnosis of cancer currently receiving chemotherapy or radiation therapy in which pain intensity is quantified

Metadata
Title Oncology: Medical and Radiation Pain Intensity QuantifiedFHIR
Version 1.0.000
Short Name CMS157FHIR
GUID (Version Independent) urn:uuid:b7b487bf-bc27-48c9-994f-6d095ff84500
GUID (Version Specific) urn:uuid:0f0317d4-38c3-4b87-b0a9-9b74aaa9a466
CMS Identifier 157FHIR
CMS Consensus Based Entity Identifier 0384e
Effective Period 2026-01-01 through 2026-12-31
Steward (Publisher) American Society of Clinical Oncology
Developer American Society of Clinical Oncology
Description

Percentage of patient visits, regardless of patient age, with a diagnosis of cancer currently receiving chemotherapy or radiation therapy in which pain intensity is quantified

Copyright

Copyright 2025 American Society of Clinical Oncology. All Rights Reserved.

Disclaimer

The Measure is not a clinical guideline, does not establish a standard of medical care, and has not been tested for all potential applications.

The Measure, while copyrighted, can be reproduced and distributed, without modification, for noncommercial purposes, e.g., use by health care providers in connection with their practices. Commercial use is defined as the sale, license, or distribution of the Measure for commercial gain, or incorporation of the Measure into a product or service that is sold, licensed or distributed for commercial gain.

Commercial uses of the Measure require a license agreement between the user and American Society of Clinical Oncology (ASCO) and prior written approval of ASCO. Contact measurement@asco.org for licensing this measure. Neither ASCO nor its members shall be responsible for any use of the Measure.

The PCPI's and American Medical Association's significant past efforts and contributions to the development and updating of the Measures are acknowledged.

ASCO is solely responsible for the review and enhancement ("Maintenance") of the Measure as of June 2020.

ASCO encourages the use of the Measure by other health care professionals, where appropriate.

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

Limited proprietary coding may be contained in the Measure specifications for convenience. A license agreement must be entered prior to a third party's use of Current Procedural Terminology (CPT[R]) or other proprietary code set contained in the Measures. Any other use of CPT or other coding by the third party is strictly prohibited. ASCO and its members disclaim all liability for use or accuracy of any CPT or other coding contained in the specifications.

CPT(R) contained in the Measure specifications is copyright 2004-2024 American Medical Association. LOINC(R) is 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 is copyright 2024 World Health Organization. All Rights Reserved.

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

Rationale

Pain is a commonly occurring symptom for cancer patients as 30% to 50% (510,000 to 850,000 each year based on current statistics) will experience moderate to severe pain (Wiffen, Wee, Derry, Bell, & Moore, 2017). Initial and ongoing pain assessments are essential to determine the pathophysiology of pain and ensure proper pain management. According to the National Comprehensive Cancer Network (NCCN, 2024), undertreatment of pain remains a problem among a significant subset of cancer patients, survival is linked with symptom control and pain management, and pain management contributes to broad quality of life improvement. Furthermore, NCCN notes that formal pain reevaluation is required at each contact to ensure that pain management therapies are successfully meeting patient-specific goals for comfort, function, and safety. Cancer patients have reported that pain interferes with their mood, work, relationships with other people, sleep and overall enjoyment of life (Moryl et al., 2018). Pain management is an essential part of oncologic management and contributes to a patient's overall function and quality of life (NCCN, 2024).

A recent analysis of registry data for chronic pain cancer patients found average pain intensity reported as mild (24.6% of patients), moderate (41.5%), and severe (33.9%). The study also indicated that patient report of pain relief is inversely related to the average pain intensity reported (Moryl et al., 2018). These data suggest that assessing and managing a cancer patient's pain is critical and there remains significant room for improvement in assessing and mitigating cancer-related pain. A prospective study of changes in pain severity of cancer patients found that, at initial assessment, 47% of patients reported pain. At follow-up, the patients with pain at initial assessment reported reduced pain (32.2%), stable pain (48.2%) and worse pain (19.6%). Of the 53% of patients reporting no pain at initial assessment, 82.6% reported stable pain and 17.4% reported worse pain at follow-up assessment (Zhao et al., 2014). This study highlights the importance of initial and ongoing assessments of pain to identify gaps and ensure proper pain management.

Clinical Recommendation Statement
  • Screen all patients for pain at each contact.

  • Routinely quantify and document pain intensity and quality as characterized by the patient (whenever possible). Include patient reporting of breakthrough pain, treatments used and their impact on pain, satisfaction with pain relief, pain interference, provider assessment of impact on function, and any special issues for the patient relevant to pain treatment and access to care. If necessary, get additional information from caregiver regarding pain and impact on function.

  • Perform comprehensive pain assessment if new or worsening pain is present and regularly for persisting pain.

    Various methods and tools exist to assess pain severity. Intensity of pain should be quantified using a numerical rating scale (i.e., 0-10), visual analog scale, categorical scale, or pictorial scale (e.g., The Faces Pain Rating Scale) (Category 2A) (National Comprehensive Cancer Network, 2024).

Citation

Moryl, N., Dave, V., Glare, P., Bokhari, A., Malhotra, V. T., Gulati, A., ... Inturrisi, C. E. (2018). Patient-Reported Outcomes and Opioid Use by Outpatient Cancer Patients. The Journal of Pain: official journal of the American Pain Society, 19(3), 278--290. doi:10.1016/j.jpain.2017.11.001

Citation

National Comprehensive Cancer Network (NCCN). (2024). NCCN Clinical Practice Guidelines in Oncology. Adult Cancer Pain Version 2.2024. Retrieved from http://www.nccn.org

Citation

Wiffen, P. J., Wee, B., Derry, S., Bell, R. F., & Moore, R. A. (2017). Opioids for cancer pain - an overview of Cochrane reviews. The Cochrane database of systematic reviews, 7(7), CD012592. doi:10.1002/14651858.CD012592.pub2

Citation

Zhao, F., Chang, V. T., Cleeland, C., Cleary, J. F., Mitchell, E. P., Wagner, L. I., & Fisch, M. J. (2014). Determinants of pain severity changes in ambulatory patients with cancer: an analysis from Eastern Cooperative Oncology Group trial E2Z02. Journal of clinical oncology: official journal of the American Society of Clinical Oncology, 32(4), 312--319. doi:10.1200/JCO.2013.50.6071

Guidance (Usage) This eCQM is an episode-based measure. An episode is defined as each eligible encounter for patients with a diagnosis of cancer who are also currently receiving chemotherapy or radiation therapy during the measurement period. For patients receiving radiation therapy, pain intensity should be quantified at each radiation treatment management encounter where the patient and physician have a face-to-face interaction. Due to the nature of some applicable coding related to radiation therapy (e.g., delivered in multiple fractions), the billing date for certain codes may or may not be the same as the face-to-face encounter date. In this instance, for the reporting purposes of this measure, the billing date should be used to pull the appropriate patients into the initial population. It is expected, though, that the numerator criteria would be performed at the time of the actual face-to-face encounter during the series of treatments. A lookback (retrospective) period of 7 days, including the billing date, may be used to identify the actual face-to-face encounter, which is required to assess the numerator. Therefore, pain intensity should be quantified during the face-to-face encounter occurring on the actual billing date or within the 6 days prior to the billing date. For patients receiving chemotherapy, pain intensity should be quantified at each face-to-face or telehealth encounter with the physician while the patient is currently receiving chemotherapy. For purposes of identifying eligible encounters, patients "currently receiving chemotherapy" refers to patients administered chemotherapy on the same day as the encounter or during the 30 days before the date of the encounter AND during the 30 days after the date of the encounter. Pain intensity should be quantified using a standard instrument, such as a 0-10 numerical rating scale, visual analog scale, a categorical scale, or pictorial scale. Examples include the Faces Pain Rating Scale and the Brief Pain Inventory (BPI). This FHIR-based measure has been derived from the QDM-based measure: CMS157v14. 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 STU6 (https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html).
Measure Group (Rate) (ID: Group_1)
Summary Percentage of patient visits, regardless of patient age, with a diagnosis of cancer currently receiving chemotherapy in which pain intensity is quantified
Basis Encounter
Scoring Proportion
Improvement Notation Increased score indicates improvement
Type Process
Rate Aggregation This measure is intended to have one reporting rate, which aggregates the following populations into a single performance rate for reporting purposes: * Population 1: Visits for patients with a diagnosis of cancer who are currently receiving chemotherapy * Population 2: Visits for patients with a diagnosis of cancer who are currently receiving radiation therapy For the purposes of this measure, a single performance rate can be calculated as follows: Performance Rate = (Numerator 1 + Numerator 2)/ (Denominator 1 + Denominator 2)
Initial Population ID: InitialPopulation_1
Description:

All patient visits, regardless of patient age, with a diagnosis of cancer currently receiving chemotherapy

Criteria: Initial Population 1
Denominator ID: Denominator_1
Description:

Equals Initial Population

Criteria: Denominator 1
Numerator ID: Numerator_1
Description:

Patient visits in which pain intensity is quantified

Criteria: Numerator 1
Measure Group (Rate) (ID: Group_2)
Summary Percentage of patient visits, regardless of patient age, with a diagnosis of cancer currently receiving radiation therapy in which pain intensity is quantified
Basis Encounter
Scoring Proportion
Improvement Notation Increased score indicates improvement
Type Process
Rate Aggregation This measure is intended to have one reporting rate, which aggregates the following populations into a single performance rate for reporting purposes: * Population 1: Visits for patients with a diagnosis of cancer who are currently receiving chemotherapy * Population 2: Visits for patients with a diagnosis of cancer who are currently receiving radiation therapy For the purposes of this measure, a single performance rate can be calculated as follows: Performance Rate = (Numerator 1 + Numerator 2)/ (Denominator 1 + Denominator 2)
Initial Population ID: InitialPopulation_2
Description:

All patient visits, regardless of patient age, with a diagnosis of cancer currently receiving radiation therapy

Criteria: Initial Population 2
Denominator ID: Denominator_2
Description:

Equals Initial Population

Criteria: Denominator 2
Numerator ID: Numerator_2
Description:

Patient visits in which pain intensity is quantified

Criteria: Numerator 2
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/CMS157FHIRPainIntensityQuantified
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Parameters
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
define "Initial Population 1":
  "Face to Face or Telehealth Encounter with Ongoing Chemotherapy"
Definition
Denominator
define "Denominator 1":
  "Initial Population 1"
Definition
Numerator
define "Numerator 1":
  "Face to Face or Telehealth Encounter with Ongoing Chemotherapy" FaceToFaceOrTelehealthEncounterWithChemo
    with "Standard Pain Assessment with Result" PainAssessed
      such that PainAssessed.effective.toInterval ( ) during day of FaceToFaceOrTelehealthEncounterWithChemo.period
Definition
Measure Group (Rate) (ID: Group_2)
Initial Population
define "Initial Population 2":
  "Radiation Treatment Management During Measurement Period with Cancer Diagnosis"
Definition
Denominator
define "Denominator 2":
  "Initial Population 2"
Definition
Numerator
define "Numerator 2":
  "Radiation Treatment Management During Measurement Period with Cancer Diagnosis" RadiationManagementEncounter
    with "Standard Pain Assessment with Result" PainAssessed
      such that case
        when exists ( ( RadiationManagementEncounter.type ) RadiationManagement
            where RadiationManagement ~ "Radiation treatment management, 5 treatments"
        ) then PainAssessed.effective.toInterval ( ) 6 days or less on or before day of start of RadiationManagementEncounter.period 
        else PainAssessed.effective.toInterval ( ) during day of RadiationManagementEncounter.period end
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: CMS157FHIRPainIntensityQuantified
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Radiation Treatment Management During Measurement Period with Cancer Diagnosis":
  ( [Encounter: "Radiation Treatment Management"] ) RadiationTreatmentManagement
    with ( [ConditionProblemsHealthConcerns: "Cancer"]
      union [ConditionEncounterDiagnosis: "Cancer"] ) CancerDx
      such that CancerDx.onset.toInterval ( ) overlaps day of RadiationTreatmentManagement.period
    where RadiationTreatmentManagement.period during day of "Measurement Period"
      and RadiationTreatmentManagement.status = 'finished'
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Initial Population 2":
  "Radiation Treatment Management During Measurement Period with Cancer Diagnosis"
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Denominator 2":
  "Initial Population 2"
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Chemotherapy Within 31 Days Prior and During Measurement Period":
  [Procedure: "Chemotherapy Administration"] ChemoAdministration
    where ChemoAdministration.performed.toInterval ( ) during Interval[start of "Measurement Period" - 31 days, end of "Measurement Period"]
      and ChemoAdministration.status in { 'completed', 'in-progress' }
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Face to Face or Telehealth Encounter with Ongoing Chemotherapy":
  from
    ( [Encounter: "Office Visit"]
      union [Encounter: "Audio Visual Telehealth Encounter"] ) FaceToFaceOrTelehealthEncounter,
    "Chemotherapy Within 31 Days Prior and During Measurement Period" ChemoBeforeEncounter,
    "Chemotherapy Within 31 Days Prior and During Measurement Period" ChemoAfterEncounter,
    ( [ConditionProblemsHealthConcerns: "Cancer"]
      union [ConditionEncounterDiagnosis: "Cancer"] ) CancerDx
    where CancerDx.onset.toInterval ( ) overlaps day of FaceToFaceOrTelehealthEncounter.period
      and ChemoBeforeEncounter.performed.toInterval ( ) starts 30 days or less on or before day of end of FaceToFaceOrTelehealthEncounter.period
      and ChemoAfterEncounter.performed.toInterval ( ) starts 30 days or less on or after day of end of FaceToFaceOrTelehealthEncounter.period
      and not ( ChemoAfterEncounter.performed.toInterval ( ) same day as ChemoBeforeEncounter.performed.toInterval ( ) )
      and FaceToFaceOrTelehealthEncounter.period during day of "Measurement Period"
      and FaceToFaceOrTelehealthEncounter.status = 'finished'
    return FaceToFaceOrTelehealthEncounter
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Standard Pain Assessment with Result":
  [ObservationScreeningAssessment: "Standardized Pain Assessment Tool"] AssessedPain
    where AssessedPain.value is not null
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Numerator 1":
  "Face to Face or Telehealth Encounter with Ongoing Chemotherapy" FaceToFaceOrTelehealthEncounterWithChemo
    with "Standard Pain Assessment with Result" PainAssessed
      such that PainAssessed.effective.toInterval ( ) during day of FaceToFaceOrTelehealthEncounterWithChemo.period
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Numerator 2":
  "Radiation Treatment Management During Measurement Period with Cancer Diagnosis" RadiationManagementEncounter
    with "Standard Pain Assessment with Result" PainAssessed
      such that case
        when exists ( ( RadiationManagementEncounter.type ) RadiationManagement
            where RadiationManagement ~ "Radiation treatment management, 5 treatments"
        ) then PainAssessed.effective.toInterval ( ) 6 days or less on or before day of start of RadiationManagementEncounter.period 
        else PainAssessed.effective.toInterval ( ) during day of RadiationManagementEncounter.period end
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Initial Population 1":
  "Face to Face or Telehealth Encounter with Ongoing Chemotherapy"
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: CMS157FHIRPainIntensityQuantified
define "Denominator 1":
  "Initial Population 1"
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 ToDateTime(value dateTime): 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 ToDateTime(value instant): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDate(value date): 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 EncounterStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value ProcedureStatus): 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: 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: 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
Code System Description: Code system CPT
Resource: Current Procedural Terminology (CPT®)
Canonical URL: http://www.ama-assn.org/go/cpt
Value Set Description: Value set Radiation Treatment Management
Resource: Radiation Treatment Management
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1026
Value Set Description: Value set Cancer
Resource: Cancer
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1010
Value Set Description: Value set Office Visit
Resource: Office Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001
Value Set Description: Value set Audio Visual Telehealth Encounter
Resource: Audio Visual Telehealth Encounter
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.1444.5.215
Value Set Description: Value set Chemotherapy Administration
Resource: Chemotherapy Administration
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1027
Value Set Description: Value set Standardized Pain Assessment Tool
Resource: Standardized Pain Assessment Tool
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1028
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
Direct Reference Code Display: Radiation treatment management, 5 treatments
Code: 77427
System: http://www.ama-assn.org/go/cpt
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
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: Patient
Profile(s): Patient
Must Support Elements: birthDate
Data Requirement Type: Condition
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-problems-health-concerns
Must Support Elements: code
Code Filter(s):
Path: code
ValueSet: Cancer
Data Requirement Type: Condition
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-encounter-diagnosis
Must Support Elements: code
Code Filter(s):
Path: code
ValueSet: Cancer
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Radiation Treatment Management
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: Office Visit
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Audio Visual Telehealth Encounter
Data Requirement Type: Procedure
Profile(s): Procedure
Must Support Elements: code, performed, status
Code Filter(s):
Path: code
ValueSet: Chemotherapy Administration
Data Requirement Type: Observation
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-screening-assessment
Must Support Elements: code, value, effective
Code Filter(s):
Path: code
ValueSet: Standardized Pain Assessment Tool
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
Denominator 2 Out 0..* Encounter
Numerator 1 Out 0..* Encounter
SDE Payer Out 0..* Resource
Numerator 2 Out 0..* Encounter
Initial Population 1 Out 0..* Encounter
SDE Ethnicity Out 0..1 Resource
Initial Population 2 Out 0..* Encounter
SDE Race Out 0..1 Resource
Denominator 1 Out 0..* Encounter
Generated using version 0.5.4 of the sample-content-ig Liquid templates