FHIR © HL7.org  |  Server Home  |  XIG Home  |  XIG Stats  |  Server Source  |  FHIR  

FHIR IG Statistics: Measure/CMS506FHIRSafeUseofOpioids

Packagegov.healthit.ecqi.ecqms
Resource TypeMeasure
IdCMS506FHIRSafeUseofOpioids
FHIR VersionR4
Sourcehttp://ecqi.healthit.gov/ecqms/https://build.fhir.org/ig/cqframework/ecqm-content-qicore-2025/Measure-CMS506FHIRSafeUseofOpioids.html
URLhttps://madie.cms.gov/Measure/CMS506FHIRSafeUseofOpioids
Version0.3.007
Statusactive
Date2025-07-07T16:25:33+00:00
NameCMS506FHIRSafeUseofOpioids
TitleSafe Use of Opioids - Concurrent PrescribingFHIR
DescriptionProportion of inpatient hospitalizations for patients 18 years of age and older prescribed, or continued on, two or more opioids or an opioid and benzodiazepine concurrently at discharge
CopyrightLimited 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. CPT(R) contained in the measure specifications is copyright 2004-2024 American Medical Association. 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.

Resources that use this resource

No resources found


Resources that this resource uses

No resources found


Narrative

Note: links and images are rebased to the (stated) source

Metadata
Title Safe Use of Opioids - Concurrent PrescribingFHIR
Version 0.3.007
Short Name CMS506FHIR
GUID (Version Independent) urn:uuid:95d529af-66b4-4cfd-bc1f-f43704dc47ad
GUID (Version Specific) urn:uuid:a5424631-846f-4d04-803b-afbf6dc25df6
CMS Identifier 506FHIR
CMS Consensus Based Entity Identifier 3316e
Effective Period 2026-01-01 through 2026-12-31
Steward (Publisher) Centers for Medicare & Medicaid Services (CMS)
Developer Mathematica
Description

Proportion of inpatient hospitalizations for patients 18 years of age and older prescribed, or continued on, two or more opioids or an opioid and benzodiazepine concurrently at discharge

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.

CPT(R) contained in the measure specifications is copyright 2004-2024 American Medical Association. 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

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

THE MEASURES AND SPECIFICATION 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

Unintentional opioid overdose fatalities have become a major public health concern in the United States (Rudd, Aleshire, Zibbel, & Gladden, 2016). Reducing the number of unintentional overdoses has become a priority for numerous federal organizations including, but not limited to, the Centers for Disease Control and Prevention (CDC), the Federal Interagency Workgroup for Opioid Adverse Drug Events, and the Substance Abuse and Mental Health Services Administration.

Concurrent prescriptions of opioids or opioids and benzodiazepines places patients at a greater risk of unintentional overdose due to the increased risk of respiratory depression (Dowell, Haegerich, & Chou, 2016; Dowell, Ragan, Jones, Baldwin, & Chou, 2022). An analysis of national prescribing patterns shows that more than half of patients who received an opioid prescription in 2009 had filled another opioid prescription within the previous 30 days (National Institute on Drug Abuse, 2011). Studies of multiple claims and prescription databases have shown that between 5%-15% of patients receive concurrent opioid prescriptions and 5%-20% of patients receive concurrent opioid and benzodiazepine prescriptions across various settings (Liu et al., 2013; Mack et al., 2015, Park et al., 2015). Patients who have multiple opioid prescriptions have an increased risk for overdose (Jena et al., 2014). Rates of fatal overdose are ten times higher in patients who are co-dispensed opioid analgesics and benzodiazepines than opioids alone (Dasgupta et al., 2015). The number of opioid overdose deaths involving benzodiazepines increased 14% on average each year from 2006 to 2011, while the number of opioid analgesic overdose deaths not involving benzodiazepines did not change significantly (Jones & McAninch, 2015). Furthermore, concurrent use of benzodiazepines with opioids was prevalent in 31%-51% of fatal overdoses (Dowell, Haegerich, & Chou, 2016). One study found that eliminating concurrent use of opioids and benzodiazepines could reduce the risk of opioid overdose-related emergency department (ED) and inpatient visits by 15% and potentially could have prevented an estimated 2,630 deaths related to opioid painkiller overdoses in 2015 (Sun, Dixit, Humphreys, Darnall, & Mackey, 2017).

A study on The Opioid Safety Initiative in the Veterans Health Administration (VHA), which includes an opioid and benzodiazepine concurrent prescribing measure that this measure is based on, was associated with a decrease of 20.67% overall and 0.86% patients per month (781 patients per month) receiving concurrent benzodiazepine with an opioid among all adult VHA patients who filled outpatient opioid prescriptions from October 2012 to September 2014 (Lin, Bohnert, Kerns, Clay, Ganoczy, & Ilgen, 2017).

Adopting a measure that calculates the proportion of patients with two or more opioids or opioids and benzodiazepines concurrently has the potential to reduce preventable mortality and reduce the costs associated with adverse events related to opioid use by (1) encouraging providers to identify patients with concurrent prescriptions of opioids or opioids and benzodiazepines and (2) discouraging providers from prescribing two or more opioids or opioids and benzodiazepines concurrently.

Clinical Recommendation Statement

The CDC Clinical Practice Guideline for Prescribing Opioids for Pain - United States, 2022 recommends that clinicians should:

  • "[Use strategies minimizing] opioid use... for both opioid-naive and opioid-tolerant patients with acute pain when possible. If patients receiving long-term opioid therapy require additional medication for acute pain, nonopioid medications should be used when possible."
  • "Use particular caution when prescribing opioid pain medication and benzodiazepines concurrently."
  • "Review increased risks for respiratory depression when opioids are taken with benzodiazepines, other sedatives, alcohol, nonprescribed or illicit drugs (e.g., heroin), or other opioids (see Recommendations 8 and 11)"
  • "Closely monitor patients who are unable to taper and who continue on high-dose or otherwise high-risk opioid regimens (e.g., opioids prescribed concurrently with benzodiazepines) and should work with patients to mitigate overdose risk (e.g., by providing overdose education and naloxone) (see Recommendation 8)."
  • "Discuss information from the PDMP with the patient and confirm that the patient is aware of any additional prescriptions."
  • "Discuss safety concerns, including increased risk for respiratory depression and overdose, with patients found to be receiving overlapping prescription opioids from multiple clinicians who are not coordinating the patient's care or patients who are receiving medications that increase risk when combined with opioids (e.g., benzodiazepines) (see Recommendation 11), and offer naloxone (see Recommendation 8)."
  • "Discuss safety concerns with other clinicians who are prescribing controlled substances for the patient. Ideally, clinicians should first discuss concerns with the patient and inform them that they plan to coordinate care with their other clinicians to improve the patient's safety."

In addition to the 2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain, opioid prescribing guidelines issued by various state agencies and professional societies for various settings agree with the recommendation to avoid concurrently prescribing opioids (American Academy of Emergency Medicine (AAEM), 2013; and Washington Agency Medical Directors' Group (WAMDG), 2015), and opioids and benzodiazepines (WAMDG, 2015; American Society of Interventional Pain Physicians (ASIPP), 2012;, and New York City Department Of Health and Mental Hygiene (NYC DPOMH), 2013) whenever possible as the combination of these medications may potentiate opioid-induced respiratory depression.

Citation

CITATION - American Academy of Emergency Medicine (AAEM). (2013). Emergency department opioid-prescribing guidelines for the treatment of non-cancer-related pain. Retrieved from https://www.aaem.org/UserFiles/file/Emergency-Department-Opoid-Prescribing-Guidelines.pdf

Citation

CITATION - American Society of Interventional Pain Physicians (ASIPP). (2012). Guidelines for responsible opioid prescribing in chronic noncancer pain. Retrieved from https://pubmed.ncbi.nlm.nih.gov/22786449/

Citation

CITATION - Dasgupta, N., Jonsson Funk, M., Proescholdbell, S., et al. (2015, September). Cohort study of the impact of high-dose opioid analgesics on overdose mortality. Pain Medicine. Retrieved from http://onlinelibrary.wiley.com/doi/10.1111/pme.12907/abstract

Citation

CITATION - Dowell, D., Haegerich, T., & Chou, R. (2016). CDC guideline for prescribing opioids for chronic pain-United States, 2016. MMWR Recommendations and Reports, 65. Retrieved from http://www.cdc.gov/media/dpk/2016/dpk-opioid-prescription-guidelines.html

Citation

CITATION - Geller, A. I., Dowell, D., Lovegrove, M. C., Mcaninch, J. K., Goring, S. K., Rose, K. O., Budnitz, D. S. (2019). U.S. Emergency Department Visits Resulting From Nonmedical Use of Pharmaceuticals, 2016. American Journal of Preventive Medicine, 56(5), 639-647. https://doi.org/10.1016/j.amepre.2018.12.009

Citation

CITATION - Herzig, S., Rothberg, M., Cheung, M., et al. (2014). Opioid utilization and opioid-related adverse events in nonsurgical patients in U.S. hospitals. Journal of Hospital Medicine, 9(2), 73-81.

Citation

CITATION - Jena, A., Goldman, D., Schaeffer, L. D., et al. (2014). Opioid prescribing by multiple providers in Medicare: Retrospective observational study of insurance claims. BMJ, 348, g1393. DOI: 10.1136/bmj.g1393

Citation

CITATION - Lin, L. A., Bohnert, A. S., Kerns, R. D., et al. (2017). Impact of the opioid safety initiative on opioid-related prescribing in veterans. Pain, 158(5), 833-839. Retrieved from https://www.ncbi.nlm.nih.gov/pubmed/28240996

Citation

CITATION - Liu, Y., Logan, J., Paulozzi, L., et al. (2013). Potential misuse and inappropriate prescription practices involving opioid analgesics. American Journal of Managed Care, 19(8), 648-665. Retrieved from http://www.ajmc.com/journals/issue/2013/2013-1-vol19-n8/Potential-Misuse-and-Inappropriate-Prescription-Practices-Involving-Opioid-Analgesics/

Citation

CITATION - Mack, K., Zhang, K., Paulozzi, L., et al. (2015, February). Prescription practices involving opioid analgesics among Americans with Medicaid, 2010. Journal of Health Care for the Poor and Underserved, 26(1), 182-198. Retrieved from http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4365785

Citation

CITATION - National Institute on Drug Abuse. (2011). Analysis of opioid prescription practices finds areas of concern. Retrieved from https://www.drugabuse.gov/news-events/news-releases/2011/04/analysis-opioid-prescription-practices-finds-areas-concern

Citation

CITATION - New York City (NYC) Department of Health and Mental Hygiene (NYC DOHMH). (2013). NYC emergency department discharge opioid-prescribing guidelines. Retrieved from https://www1.nyc.gov/site/doh/providers/health-topics/opioid-prescribing-resources-for-emergency-departments.page

Citation

CITATION - Park, T., Saitz, R., Ganoczy, D., et al. (2015). Benzodiazepine-prescribing patterns and deaths from drug overdose among U.S. veterans receiving opioid analgesics: Case-cohort study. BMJ, 350, h2698. Retrieved from http://www.bmj.com/content/350/bmj.h2698

Citation

CITATION - Rudd, R., Aleshire, N., Zibbell, J., et al. (2016, January). Increases in drug and opioid overdose deaths-United States, 2000-2014. Morbidity and Mortality Weekly Report, 64(50), 1378-1382. Retrieved from http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6450a3.htm

Citation

CITATION - Sun, E., Dixit, A., Humphreys, K., et al. (2017). Association between concurrent use of prescription opioids and benzodiazepines and overdose: Retrospective analysis. BMJ, 356, j760. Retrieved from http://www.bmj.com/content/356/bmj.j760

Citation

CITATION - U.S. Department of Veterans Affairs. (2014). Opioid safety initiative toolkit. Retrieved from https://www.va.gov/PAINMANAGEMENT/Opioid_Safety_Initiative_OSI.asp

Citation

CITATION - U.S. Department of Veterans Affairs. (2016). Opioid safety initiative: Opioids (including tramadol) used in combination with benzodiazepine derivative sedatives/hypnotics. Unpublished manuscript.

Citation

CITATION - Washington Agency Medical Directors' Group (WAMDG). (2015). Interagency guideline on prescribing opioids for pain, Part II: Prescribing opioids in the acute and subacute phase. Retrieved from http://www.agencymeddirectors.wa.gov/Files/2015AMDGOpioidGuideline.pdf

Guidance (Usage) Clinician judgement, clinical appropriateness, or both may indicate concurrent prescribing of two unique opioids or an opioid and benzodiazepine is medically necessary, thus the measure is not expected to have a zero rate. New or continuing opioid and benzodiazepine medications are included with the use of the MedicationRequest QI-Core Profile. The Profile's community and discharge category codes indicate that the medications should be taken by or given to the patient after being discharged from an inpatient encounter, which could include previously or newly prescribed medications. Inpatient hospitalizations with discharge medications of an opioid or benzodiazepine prescription should be included in the initial population. Inpatient hospitalizations with discharge medications of two or more opioids or an opioid and benzodiazepine resulting in concurrent therapy at discharge should be included in the numerator. Each benzodiazepine and opioid included on the medication discharge list is considered a unique prescription. The denominator 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 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: CMS 506v8.0. 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
Type Process
Rate Aggregation None
Improvement Notation Decreased score indicates improvement
Initial Population ID: InitialPopulation_1
Description:

Inpatient hospitalizations that end during the measurement period, where the patient is 18 years of age and older at the start of the encounter and prescribed one opioid and/or benzodiazepine at discharge

Logic Definition: Initial Population
Denominator ID: Denominator_1
Description:

Equals Initial Population

Logic Definition: Denominator
Denominator Exclusion ID: DenominatorExclusion_1
Description:

Inpatient hospitalizations where patients have cancer pain that begins prior to or during the encounter or are ordered or are receiving palliative or hospice care (including comfort measures, terminal care, and dying care) during the hospitalization or in an emergency department encounter or observation stay immediately prior to hospitalization, patients receiving medication for opioid use disorder (OUD) with active OUD diagnosis or Opioid Medication Assisted Treatment (MAT), patients with sickle cell disease, patients discharged to another inpatient care facility or left against medical advice, and patients who expire during the inpatient stay

Logic Definition: Denominator Exclusion
Numerator ID: Numerator_1
Description:

Inpatient hospitalizations where the patient is prescribed two or more opioids or an opioid and benzodiazepine at discharge

Logic Definition: Numerator
Supplemental Data Guidance 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 CMS506FHIRSafeUseofOpioids
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
define "Initial Population":
  "Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge"
Denominator
define "Denominator":
  "Initial Population"
Denominator Exclusion
define "Denominator Exclusion":
  /*Excludes encounters of patients with cancer pain or who are receiving palliative or hospice care at the time of the encounter or who receive treatment for opioid use disorder, have sickle cell disease, or who are discharged to another inpatient care facility or discharged against medical advice, or expire during the inpatient stay*/
  
  "Denominator" InpatientEncounter
    where exists ( ["ConditionProblemsHealthConcerns": "Cancer Related Pain"] CancerPain
        where CancerPain.prevalenceInterval ( ) overlaps day of InpatientEncounter.period
          and ( CancerPain.verificationStatus is not null implies ( CancerPain.verificationStatus !~ QICoreCommon."refuted"
                or CancerPain.verificationStatus !~ QICoreCommon."entered-in-error"
            )
          )
    )
      or exists ( "Inpatient Encounter With Encounter Diagnosis Of Cancer Pain" )
      or exists ( ["ConditionProblemsHealthConcerns": "Sickle Cell Disease with and without Crisis"] SickleCellDisease
          where SickleCellDisease.prevalenceInterval ( ) overlaps day of InpatientEncounter.period
            and ( SickleCellDisease.verificationStatus is not null implies ( SickleCellDisease.verificationStatus !~ QICoreCommon."refuted"
                  or SickleCellDisease.verificationStatus !~ QICoreCommon."entered-in-error"
              )
            )
      )
      or exists ( "Treatment For Opioid Use Disorders" OUDTreatment
          where OUDTreatment.authoredOn during day of InpatientEncounter.period
      )
      or exists ( "Intervention Palliative Or Hospice Care" PalliativeOrHospiceCare
          where Coalesce(start of PalliativeOrHospiceCare.performed.toInterval(), PalliativeOrHospiceCare.authoredOn) during InpatientEncounter.hospitalizationWithObservation ( )
      )
      or ( InpatientEncounter.hospitalization.dischargeDisposition in "Discharge To Acute Care Facility"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Hospice Care Referral or Admission"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Patient Expired"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Left Against Medical Advice"
      )
Numerator
define "Numerator":
  /*Encounters of patients prescribed two or more opioids or an opioid and benzodiazepine at discharge.*/
  
  "Denominator" InpatientEncounter
    where ( Count("Opioid At Discharge" OpioidMedications
          where OpioidMedications.authoredOn during day of InpatientEncounter.period
          return distinct OpioidMedications.medication
      ) >= 2
    )
      or ( exists "Opioid At Discharge" OpioidDischargeMedications
          where OpioidDischargeMedications.authoredOn during day of InpatientEncounter.period
            and exists ( "Benzodiazepine At Discharge" BenzodiazepineDischargeMedication
                where BenzodiazepineDischargeMedication.authoredOn during day of InpatientEncounter.period
            )
      )
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":
  [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: CMS506FHIRSafeUseofOpioids
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Inpatient Encounter With Age Greater Than Or Equal To 18":
  CQMCommon."Inpatient Encounter" InpatientHospitalEncounter
    where AgeInYearsAt(date from start of InpatientHospitalEncounter.period) >= 18
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Opioid At Discharge":
  ["MedicationRequest": "Schedule II, III and IV Opioid Medications"] OpioidMedications
    where ( OpioidMedications.isCommunity ( )
        or OpioidMedications.isDischarge ( )
    )
      and OpioidMedications.status in { 'active', 'completed' }
      and OpioidMedications.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Benzodiazepine At Discharge":
  ["MedicationRequest": "Schedule IV Benzodiazepines"] BenzoMedications
    where ( BenzoMedications.isCommunity ( )
        or BenzoMedications.isDischarge ( )
    )
      and BenzoMedications.status in { 'active', 'completed' }
      and BenzoMedications.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge":
/*Captures encounters of patients with an opioid and/or benzodiazepine at discharge*/
  
  "Inpatient Encounter With Age Greater Than Or Equal To 18" InpatientEncounter
    with ( "Opioid At Discharge"
      union "Benzodiazepine At Discharge" ) OpioidOrBenzodiazepineAtDischarge
      such that OpioidOrBenzodiazepineAtDischarge.authoredOn during day of InpatientEncounter.period
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Initial Population":
  "Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge"
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Denominator":
  "Initial Population"
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Numerator":
  /*Encounters of patients prescribed two or more opioids or an opioid and benzodiazepine at discharge.*/
  
  "Denominator" InpatientEncounter
    where ( Count("Opioid At Discharge" OpioidMedications
          where OpioidMedications.authoredOn during day of InpatientEncounter.period
          return distinct OpioidMedications.medication
      ) >= 2
    )
      or ( exists "Opioid At Discharge" OpioidDischargeMedications
          where OpioidDischargeMedications.authoredOn during day of InpatientEncounter.period
            and exists ( "Benzodiazepine At Discharge" BenzodiazepineDischargeMedication
                where BenzodiazepineDischargeMedication.authoredOn during day of InpatientEncounter.period
            )
      )
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Inpatient Encounter With Encounter Diagnosis Of Cancer Pain":
  "Denominator" QualifyingEncounter
    where QualifyingEncounter.reasonCode in "Cancer Related Pain"
      or QualifyingEncounter.encounterDiagnosis ( ).code in "Cancer Related Pain"
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Medications For Opioid Use Disorder":
  ["MedicationRequest": "Medications for Opioid Use Disorder (MOUD)"] DischargeMedication
    where ( DischargeMedication.isCommunity ( )
        or DischargeMedication.isDischarge ( )
    )
      and DischargeMedication.status in { 'active', 'completed' }
      and DischargeMedication.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Treatment For Opioid Use Disorders":
  ( "Medications For Opioid Use Disorder" MedicationTreatment
      with ["Procedure": "Opioid Medication Assisted Treatment (MAT)"] MAT
        such that MedicationTreatment.authoredOn during day of MAT.performed.toInterval ( )
          and MedicationTreatment.authoredOn during day of "Measurement Period"
          and MAT.status in { 'completed', 'in-progress' }
  )
    union ( "Medications For Opioid Use Disorder" MedicationTreatment
        with ["ConditionProblemsHealthConcerns": "Opioid Use Disorder"] OUD
          such that MedicationTreatment.authoredOn during day of OUD.prevalenceInterval ( )
            and OUD.prevalenceInterval ( ) overlaps day of "Measurement Period"
            and ( OUD.verificationStatus is not null implies ( OUD.verificationStatus !~ QICoreCommon."refuted"
                  or OUD.verificationStatus !~ QICoreCommon."entered-in-error"
              )
            )
    )
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Intervention Palliative Or Hospice Care":
  ( ["ServiceRequest": "Palliative or Hospice Care"] PalliativeOrHospiceCareOrder
      where PalliativeOrHospiceCareOrder.status in { 'active', 'completed', 'on-hold' }
  )
    union ( ["Procedure": "Palliative or Hospice Care"] PalliativeOrHospiceCarePerformed
        where PalliativeOrHospiceCarePerformed.status in { 'completed', 'in-progress' }
    )
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "Denominator Exclusion":
  /*Excludes encounters of patients with cancer pain or who are receiving palliative or hospice care at the time of the encounter or who receive treatment for opioid use disorder, have sickle cell disease, or who are discharged to another inpatient care facility or discharged against medical advice, or expire during the inpatient stay*/
  
  "Denominator" InpatientEncounter
    where exists ( ["ConditionProblemsHealthConcerns": "Cancer Related Pain"] CancerPain
        where CancerPain.prevalenceInterval ( ) overlaps day of InpatientEncounter.period
          and ( CancerPain.verificationStatus is not null implies ( CancerPain.verificationStatus !~ QICoreCommon."refuted"
                or CancerPain.verificationStatus !~ QICoreCommon."entered-in-error"
            )
          )
    )
      or exists ( "Inpatient Encounter With Encounter Diagnosis Of Cancer Pain" )
      or exists ( ["ConditionProblemsHealthConcerns": "Sickle Cell Disease with and without Crisis"] SickleCellDisease
          where SickleCellDisease.prevalenceInterval ( ) overlaps day of InpatientEncounter.period
            and ( SickleCellDisease.verificationStatus is not null implies ( SickleCellDisease.verificationStatus !~ QICoreCommon."refuted"
                  or SickleCellDisease.verificationStatus !~ QICoreCommon."entered-in-error"
              )
            )
      )
      or exists ( "Treatment For Opioid Use Disorders" OUDTreatment
          where OUDTreatment.authoredOn during day of InpatientEncounter.period
      )
      or exists ( "Intervention Palliative Or Hospice Care" PalliativeOrHospiceCare
          where Coalesce(start of PalliativeOrHospiceCare.performed.toInterval(), PalliativeOrHospiceCare.authoredOn) during InpatientEncounter.hospitalizationWithObservation ( )
      )
      or ( InpatientEncounter.hospitalization.dischargeDisposition in "Discharge To Acute Care Facility"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Hospice Care Referral or Admission"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Patient Expired"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Left Against Medical Advice"
      )
Logic Definition Library Name: CMS506FHIRSafeUseofOpioids
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: FHIRHelpers
define function ToString(value uri): 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
/*
@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: QICoreCommon
/*
@description: Returns true if the given MedicationRequest has a category of Community
*/
define fluent function isCommunity(medicationRequest Choice<MedicationRequest, MedicationNotRequested>):
  exists (medicationRequest.category C
    where C ~ Community
  )
Logic Definition Library Name: QICoreCommon
/*
@description: Returns true if the given MedicationRequest has a category of Discharge
*/
define fluent function isDischarge(medicationRequest Choice<MedicationRequest, MedicationNotRequested>):
  exists (medicationRequest.category C
    where C ~ Discharge
  )
Logic Definition Library Name: QICoreCommon
/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
*/
define fluent function prevalenceInterval(condition Choice<"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns">):
if condition.clinicalStatus ~ "active"
  or condition.clinicalStatus ~ "recurrence"
  or condition.clinicalStatus ~ "relapse" then
  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
else
    (end of condition.abatementInterval()) abatementDate
    return if abatementDate is null then
      Interval[start of condition.onset.toInterval(), abatementDate)
    else
      Interval[start of condition.onset.toInterval(), abatementDate]
Logic Definition Library Name: QICoreCommon
/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
*/
define fluent function abatementInterval(condition Choice<"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns">):
	if condition.abatement is DateTime then
	  Interval[condition.abatement as DateTime, condition.abatement as DateTime]
	else if condition.abatement is Quantity then
		Interval[Patient.birthDate + (condition.abatement as Quantity),
			Patient.birthDate + (condition.abatement as Quantity) + 1 year)
	else if condition.abatement is Interval<Quantity> then
	  Interval[Patient.birthDate + (condition.abatement.low as Quantity),
		  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
	else if condition.abatement is Interval<DateTime> then
	  Interval[condition.abatement.low, condition.abatement.high)
	else null as Interval<DateTime>
Logic Definition Library Name: QICoreCommon
/*
@description: Returns true if the given reference is to the given resourceId
@comment: Returns true if the `resourceId` parameter exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resourceId String):
  resourceId = Last(Split(reference.reference, '/'))
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
Logic Definition Library Name: CQMCommon
define "Inpatient Encounter":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.status = 'finished'
      and EncounterInpatient.period ends during day of "Measurement Period"
Logic Definition Library Name: CQMCommon
/*  
@description: Returns the Condition resources referenced by the diagnosis element of the Encounter  
*/
define fluent function encounterDiagnosis(Encounter Encounter ):
  Encounter.reasonReference D
    return singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where D.references(C.id))
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]
Terminology
Code System Description: Code system SNOMEDCT
Resource: SNOMED CT (all versions)
Canonical URL: http://snomed.info/sct
Code System Description: Code system MedicationRequestCategory
Resource: MedicationRequest Category Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Code System Description: Code system ConditionClinicalStatusCodes
Resource: Condition Clinical Status Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-clinical
Code System Description: Code system ConditionVerificationStatusCodes
Resource: ConditionVerificationStatus
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-ver-status
Value Set 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
Value Set Description: Value set Schedule II, III and IV Opioid Medications
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241
Value Set Description: Value set Schedule IV Benzodiazepines
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1
Value Set 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
Value Set Description: Value set Cancer Related Pain
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180
Value Set Description: Value set Sickle Cell Disease with and without Crisis
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175
Value Set Description: Value set Medications for Opioid Use Disorder (MOUD)
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269
Value Set Description: Value set Opioid Medication Assisted Treatment (MAT)
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177
Value Set Description: Value set Opioid Use Disorder
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171
Value Set Description: Value set Palliative or Hospice Care
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
Value Set 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
Value Set 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
Value Set Description: Value set Discharge To Acute Care Facility
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87
Value Set Description: Value set Hospice Care Referral or Admission
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365
Value Set Description: Value set Patient Expired
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309
Value Set Description: Value set Left Against Medical Advice
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308
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: Community
Code: community
System: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Direct Reference Code Display: Discharge
Code: discharge
System: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Direct Reference Code Display: Active
Code: active
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Recurrence
Code: recurrence
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Relapse
Code: relapse
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Refuted
Code: refuted
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Direct Reference Code Display: Entered in Error
Code: entered-in-error
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Dependencies
Dependency Description: Library SDE
Resource: SupplementalDataElementsversion: null5.1.000)
Canonical URL: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
Dependency Description: Library FHIRHelpers
Resource: FHIRHelpersversion: null4.4.000)
Canonical URL: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
Dependency Description: Library CQMCommon
Resource: CQMCommonversion: null4.1.000)
Canonical URL: https://madie.cms.gov/Library/CQMCommon|4.1.000
Dependency Description: Library QICoreCommon
Resource: QICoreCommonversion: null4.0.000)
Canonical URL: https://madie.cms.gov/Library/QICoreCommon|4.0.000
Data Requirements
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: extension, url, birthDate, birthDate.value
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period, reasonCode, hospitalization, hospitalization.dischargeDisposition
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, reasonCode, hospitalization, hospitalization.dischargeDisposition
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, status, status.value, period, reasonCode, hospitalization, hospitalization.dischargeDisposition
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: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, status, status.value, intent, intent.value, authoredOn, authoredOn.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, status, status.value, intent, intent.value, authoredOn, authoredOn.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, status, status.value, intent, intent.value, authoredOn, authoredOn.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication.reference.value, status, status.value, intent, intent.value, authoredOn, authoredOn.value, medication
Data Requirement Type: Medication
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication
Must Support Elements: id.value, code
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: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
Must Support Elements: code, verificationStatus
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
Must Support Elements: code, verificationStatus
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
Must Support Elements: code, verificationStatus
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175
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.1111.177
Data Requirement Type: Procedure
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure
Must Support Elements: code, status, status.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
Data Requirement Type: ServiceRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest
Must Support Elements: code, status, status.value
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
Generated using version 0.4.8 of the sample-content-ig Liquid templates

Source

{
  "resourceType": "Measure",
  "id": "CMS506FHIRSafeUseofOpioids",
  "meta": {
    "profile": [
      "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablemeasure",
      "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm",
      "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/publishable-measure-cqfm",
      "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/executable-measure-cqfm",
      "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cql-measure-cqfm",
      "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/elm-measure-cqfm",
      "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/proportion-measure-cqfm"
    ]
  },
  "text": {
    "status": "extensions",
    "div": "<!-- snip (see above) -->"
  },
  "contained": [
    {
      "resourceType": "Library",
      "id": "effective-data-requirements",
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://snomed.info/sct",
            "code": "248153007",
            "display": "Male (finding)"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://snomed.info/sct",
            "code": "248152002",
            "display": "Female (finding)"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://terminology.hl7.org/CodeSystem/medicationrequest-category",
            "code": "community",
            "display": "Community"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://terminology.hl7.org/CodeSystem/medicationrequest-category",
            "code": "discharge",
            "display": "Discharge"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
            "code": "active",
            "display": "Active"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
            "code": "recurrence",
            "display": "Recurrence"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
            "code": "relapse",
            "display": "Relapse"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
            "code": "refuted",
            "display": "Refuted"
          }
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
          "valueCoding": {
            "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
            "code": "entered-in-error",
            "display": "Entered in Error"
          }
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "SupplementalDataElements"
            },
            {
              "url": "name",
              "valueString": "SDE Sex"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Sex\":\n  case\n    when Patient.sex = '248153007' then \"Male (finding)\"\n    when Patient.sex = '248152002' then \"Female (finding)\"\n    else null\n  end"
            },
            {
              "url": "displaySequence",
              "valueInteger": 0
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "SDE Sex"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Sex\":\n  SDE.\"SDE Sex\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 1
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CQMCommon"
            },
            {
              "url": "name",
              "valueString": "Inpatient Encounter"
            },
            {
              "url": "statement",
              "valueString": "define \"Inpatient Encounter\":\n  [Encounter: \"Encounter Inpatient\"] EncounterInpatient\n    where EncounterInpatient.status = 'finished'\n      and EncounterInpatient.period ends during day of \"Measurement Period\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 2
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Inpatient Encounter With Age Greater Than Or Equal To 18"
            },
            {
              "url": "statement",
              "valueString": "define \"Inpatient Encounter With Age Greater Than Or Equal To 18\":\n  CQMCommon.\"Inpatient Encounter\" InpatientHospitalEncounter\n    where AgeInYearsAt(date from start of InpatientHospitalEncounter.period) >= 18"
            },
            {
              "url": "displaySequence",
              "valueInteger": 3
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Opioid At Discharge"
            },
            {
              "url": "statement",
              "valueString": "define \"Opioid At Discharge\":\n  [\"MedicationRequest\": \"Schedule II, III and IV Opioid Medications\"] OpioidMedications\n    where ( OpioidMedications.isCommunity ( )\n        or OpioidMedications.isDischarge ( )\n    )\n      and OpioidMedications.status in { 'active', 'completed' }\n      and OpioidMedications.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 4
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Benzodiazepine At Discharge"
            },
            {
              "url": "statement",
              "valueString": "define \"Benzodiazepine At Discharge\":\n  [\"MedicationRequest\": \"Schedule IV Benzodiazepines\"] BenzoMedications\n    where ( BenzoMedications.isCommunity ( )\n        or BenzoMedications.isDischarge ( )\n    )\n      and BenzoMedications.status in { 'active', 'completed' }\n      and BenzoMedications.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 5
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge"
            },
            {
              "url": "statement",
              "valueString": "define \"Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge\":\n/*Captures encounters of patients with an opioid and/or benzodiazepine at discharge*/\n  \n  \"Inpatient Encounter With Age Greater Than Or Equal To 18\" InpatientEncounter\n    with ( \"Opioid At Discharge\"\n      union \"Benzodiazepine At Discharge\" ) OpioidOrBenzodiazepineAtDischarge\n      such that OpioidOrBenzodiazepineAtDischarge.authoredOn during day of InpatientEncounter.period"
            },
            {
              "url": "displaySequence",
              "valueInteger": 6
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Initial Population"
            },
            {
              "url": "statement",
              "valueString": "define \"Initial Population\":\n  \"Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 7
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Denominator"
            },
            {
              "url": "statement",
              "valueString": "define \"Denominator\":\n  \"Initial Population\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 8
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Numerator"
            },
            {
              "url": "statement",
              "valueString": "define \"Numerator\":\n  /*Encounters of patients prescribed two or more opioids or an opioid and benzodiazepine at discharge.*/\n  \n  \"Denominator\" InpatientEncounter\n    where ( Count(\"Opioid At Discharge\" OpioidMedications\n          where OpioidMedications.authoredOn during day of InpatientEncounter.period\n          return distinct OpioidMedications.medication\n      ) >= 2\n    )\n      or ( exists \"Opioid At Discharge\" OpioidDischargeMedications\n          where OpioidDischargeMedications.authoredOn during day of InpatientEncounter.period\n            and exists ( \"Benzodiazepine At Discharge\" BenzodiazepineDischargeMedication\n                where BenzodiazepineDischargeMedication.authoredOn during day of InpatientEncounter.period\n            )\n      )"
            },
            {
              "url": "displaySequence",
              "valueInteger": 9
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "SupplementalDataElements"
            },
            {
              "url": "name",
              "valueString": "SDE Payer"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Payer\":\n  [Coverage: type in \"Payer Type\"] Payer\n    return {\n      code: Payer.type,\n      period: Payer.period\n    }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 10
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "SDE Payer"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Payer\":\n  SDE.\"SDE Payer\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 11
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "SupplementalDataElements"
            },
            {
              "url": "name",
              "valueString": "SDE Ethnicity"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Ethnicity\":\n  Patient.ethnicity E\n    return Tuple {\n      codes: { E.ombCategory } union E.detailed,\n      display: E.text\n    }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 12
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "SDE Ethnicity"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Ethnicity\":\n  SDE.\"SDE Ethnicity\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 13
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Inpatient Encounter With Encounter Diagnosis Of Cancer Pain"
            },
            {
              "url": "statement",
              "valueString": "define \"Inpatient Encounter With Encounter Diagnosis Of Cancer Pain\":\n  \"Denominator\" QualifyingEncounter\n    where QualifyingEncounter.reasonCode in \"Cancer Related Pain\"\n      or QualifyingEncounter.encounterDiagnosis ( ).code in \"Cancer Related Pain\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 14
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Medications For Opioid Use Disorder"
            },
            {
              "url": "statement",
              "valueString": "define \"Medications For Opioid Use Disorder\":\n  [\"MedicationRequest\": \"Medications for Opioid Use Disorder (MOUD)\"] DischargeMedication\n    where ( DischargeMedication.isCommunity ( )\n        or DischargeMedication.isDischarge ( )\n    )\n      and DischargeMedication.status in { 'active', 'completed' }\n      and DischargeMedication.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 15
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Treatment For Opioid Use Disorders"
            },
            {
              "url": "statement",
              "valueString": "define \"Treatment For Opioid Use Disorders\":\n  ( \"Medications For Opioid Use Disorder\" MedicationTreatment\n      with [\"Procedure\": \"Opioid Medication Assisted Treatment (MAT)\"] MAT\n        such that MedicationTreatment.authoredOn during day of MAT.performed.toInterval ( )\n          and MedicationTreatment.authoredOn during day of \"Measurement Period\"\n          and MAT.status in { 'completed', 'in-progress' }\n  )\n    union ( \"Medications For Opioid Use Disorder\" MedicationTreatment\n        with [\"ConditionProblemsHealthConcerns\": \"Opioid Use Disorder\"] OUD\n          such that MedicationTreatment.authoredOn during day of OUD.prevalenceInterval ( )\n            and OUD.prevalenceInterval ( ) overlaps day of \"Measurement Period\"\n            and ( OUD.verificationStatus is not null implies ( OUD.verificationStatus !~ QICoreCommon.\"refuted\"\n                  or OUD.verificationStatus !~ QICoreCommon.\"entered-in-error\"\n              )\n            )\n    )"
            },
            {
              "url": "displaySequence",
              "valueInteger": 16
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Intervention Palliative Or Hospice Care"
            },
            {
              "url": "statement",
              "valueString": "define \"Intervention Palliative Or Hospice Care\":\n  ( [\"ServiceRequest\": \"Palliative or Hospice Care\"] PalliativeOrHospiceCareOrder\n      where PalliativeOrHospiceCareOrder.status in { 'active', 'completed', 'on-hold' }\n  )\n    union ( [\"Procedure\": \"Palliative or Hospice Care\"] PalliativeOrHospiceCarePerformed\n        where PalliativeOrHospiceCarePerformed.status in { 'completed', 'in-progress' }\n    )"
            },
            {
              "url": "displaySequence",
              "valueInteger": 17
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "Denominator Exclusion"
            },
            {
              "url": "statement",
              "valueString": "define \"Denominator Exclusion\":\n  /*Excludes encounters of patients with cancer pain or who are receiving palliative or hospice care at the time of the encounter or who receive treatment for opioid use disorder, have sickle cell disease, or who are discharged to another inpatient care facility or discharged against medical advice, or expire during the inpatient stay*/\n  \n  \"Denominator\" InpatientEncounter\n    where exists ( [\"ConditionProblemsHealthConcerns\": \"Cancer Related Pain\"] CancerPain\n        where CancerPain.prevalenceInterval ( ) overlaps day of InpatientEncounter.period\n          and ( CancerPain.verificationStatus is not null implies ( CancerPain.verificationStatus !~ QICoreCommon.\"refuted\"\n                or CancerPain.verificationStatus !~ QICoreCommon.\"entered-in-error\"\n            )\n          )\n    )\n      or exists ( \"Inpatient Encounter With Encounter Diagnosis Of Cancer Pain\" )\n      or exists ( [\"ConditionProblemsHealthConcerns\": \"Sickle Cell Disease with and without Crisis\"] SickleCellDisease\n          where SickleCellDisease.prevalenceInterval ( ) overlaps day of InpatientEncounter.period\n            and ( SickleCellDisease.verificationStatus is not null implies ( SickleCellDisease.verificationStatus !~ QICoreCommon.\"refuted\"\n                  or SickleCellDisease.verificationStatus !~ QICoreCommon.\"entered-in-error\"\n              )\n            )\n      )\n      or exists ( \"Treatment For Opioid Use Disorders\" OUDTreatment\n          where OUDTreatment.authoredOn during day of InpatientEncounter.period\n      )\n      or exists ( \"Intervention Palliative Or Hospice Care\" PalliativeOrHospiceCare\n          where Coalesce(start of PalliativeOrHospiceCare.performed.toInterval(), PalliativeOrHospiceCare.authoredOn) during InpatientEncounter.hospitalizationWithObservation ( )\n      )\n      or ( InpatientEncounter.hospitalization.dischargeDisposition in \"Discharge To Acute Care Facility\"\n          or InpatientEncounter.hospitalization.dischargeDisposition in \"Hospice Care Referral or Admission\"\n          or InpatientEncounter.hospitalization.dischargeDisposition in \"Patient Expired\"\n          or InpatientEncounter.hospitalization.dischargeDisposition in \"Left Against Medical Advice\"\n      )"
            },
            {
              "url": "displaySequence",
              "valueInteger": 18
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "SupplementalDataElements"
            },
            {
              "url": "name",
              "valueString": "SDE Race"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Race\":\n  Patient.race R\n    return Tuple {\n      codes: R.ombCategory union R.detailed,\n      display: R.text\n    }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 19
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CMS506FHIRSafeUseofOpioids"
            },
            {
              "url": "name",
              "valueString": "SDE Race"
            },
            {
              "url": "statement",
              "valueString": "define \"SDE Race\":\n  SDE.\"SDE Race\""
            },
            {
              "url": "displaySequence",
              "valueInteger": 20
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "FHIRHelpers"
            },
            {
              "url": "name",
              "valueString": "ToString"
            },
            {
              "url": "statement",
              "valueString": "define function ToString(value uri): value.value"
            },
            {
              "url": "displaySequence",
              "valueInteger": 21
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "FHIRHelpers"
            },
            {
              "url": "name",
              "valueString": "ToInterval"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)\nvalue to a CQL DateTime Interval\n@comment: If the start value of the given period is unspecified, the starting\nboundary of the resulting interval will be open (meaning the start of the interval\nis unknown, as opposed to interpreted as the beginning of time).\n*/\ndefine function ToInterval(period FHIR.Period):\n    if period is null then\n        null\n    else\n        if period.\"start\" is null then\n            Interval(period.\"start\".value, period.\"end\".value]\n        else\n            Interval[period.\"start\".value, period.\"end\".value]"
            },
            {
              "url": "displaySequence",
              "valueInteger": 22
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "QICoreCommon"
            },
            {
              "url": "name",
              "valueString": "isCommunity"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Returns true if the given MedicationRequest has a category of Community\n*/\ndefine fluent function isCommunity(medicationRequest Choice<MedicationRequest, MedicationNotRequested>):\n  exists (medicationRequest.category C\n    where C ~ Community\n  )"
            },
            {
              "url": "displaySequence",
              "valueInteger": 23
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "FHIRHelpers"
            },
            {
              "url": "name",
              "valueString": "ToConcept"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.\n*/\ndefine function ToConcept(concept FHIR.CodeableConcept):\n    if concept is null then\n        null\n    else\n        System.Concept {\n            codes: concept.coding C return ToCode(C),\n            display: concept.text.value\n        }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 24
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "FHIRHelpers"
            },
            {
              "url": "name",
              "valueString": "ToCode"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.\n*/\ndefine function ToCode(coding FHIR.Coding):\n    if coding is null then\n        null\n    else\n        System.Code {\n          code: coding.code.value,\n          system: coding.system.value,\n          version: coding.version.value,\n          display: coding.display.value\n        }"
            },
            {
              "url": "displaySequence",
              "valueInteger": 25
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "QICoreCommon"
            },
            {
              "url": "name",
              "valueString": "isDischarge"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Returns true if the given MedicationRequest has a category of Discharge\n*/\ndefine fluent function isDischarge(medicationRequest Choice<MedicationRequest, MedicationNotRequested>):\n  exists (medicationRequest.category C\n    where C ~ Discharge\n  )"
            },
            {
              "url": "displaySequence",
              "valueInteger": 26
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "QICoreCommon"
            },
            {
              "url": "name",
              "valueString": "prevalenceInterval"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Returns an interval representing the normalized prevalence period of a given Condition.\n@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from\nonset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting \ninterval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.\n*/\ndefine fluent function prevalenceInterval(condition Choice<\"ConditionEncounterDiagnosis\", \"ConditionProblemsHealthConcerns\">):\nif condition.clinicalStatus ~ \"active\"\n  or condition.clinicalStatus ~ \"recurrence\"\n  or condition.clinicalStatus ~ \"relapse\" then\n  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]\nelse\n    (end of condition.abatementInterval()) abatementDate\n    return if abatementDate is null then\n      Interval[start of condition.onset.toInterval(), abatementDate)\n    else\n      Interval[start of condition.onset.toInterval(), abatementDate]"
            },
            {
              "url": "displaySequence",
              "valueInteger": 27
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "QICoreCommon"
            },
            {
              "url": "name",
              "valueString": "abatementInterval"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Returns an interval representing the normalized abatement of a given Condition.\n@comment: If the abatement element of the Condition is represented as a DateTime, the result\nis an interval beginning and ending on that DateTime.\nIf the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The\nresult is an interval from the date the patient turned that age to immediately before one year later.\nIf the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during\nwhich the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately\nbefore one year later than the date the patient turned the ending age of the quantity interval.\n*/\ndefine fluent function abatementInterval(condition Choice<\"ConditionEncounterDiagnosis\", \"ConditionProblemsHealthConcerns\">):\n\tif condition.abatement is DateTime then\n\t  Interval[condition.abatement as DateTime, condition.abatement as DateTime]\n\telse if condition.abatement is Quantity then\n\t\tInterval[Patient.birthDate + (condition.abatement as Quantity),\n\t\t\tPatient.birthDate + (condition.abatement as Quantity) + 1 year)\n\telse if condition.abatement is Interval<Quantity> then\n\t  Interval[Patient.birthDate + (condition.abatement.low as Quantity),\n\t\t  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)\n\telse if condition.abatement is Interval<DateTime> then\n\t  Interval[condition.abatement.low, condition.abatement.high)\n\telse null as Interval<DateTime>"
            },
            {
              "url": "displaySequence",
              "valueInteger": 28
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CQMCommon"
            },
            {
              "url": "name",
              "valueString": "encounterDiagnosis"
            },
            {
              "url": "statement",
              "valueString": "/*  \n@description: Returns the Condition resources referenced by the diagnosis element of the Encounter  \n*/\ndefine fluent function encounterDiagnosis(Encounter Encounter ):\n  Encounter.reasonReference D\n    return singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where D.references(C.id))"
            },
            {
              "url": "displaySequence",
              "valueInteger": 29
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "QICoreCommon"
            },
            {
              "url": "name",
              "valueString": "references"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Returns true if the given reference is to the given resourceId\n@comment: Returns true if the `resourceId` parameter exactly equals the tail of the given reference.\nNOTE: This function assumes resources from the same source server.\n*/\ndefine fluent function references(reference Reference, resourceId String):\n  resourceId = Last(Split(reference.reference, '/'))"
            },
            {
              "url": "displaySequence",
              "valueInteger": 30
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "QICoreCommon"
            },
            {
              "url": "name",
              "valueString": "toInterval"
            },
            {
              "url": "statement",
              "valueString": "/*\n@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval\n@comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> types\nto an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible\nrepresentations for timing-valued elements in QICore, allowing this function to be used across any resource.\nThe input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.\nThe intent of this function is to provide a clear and concise mechanism to treat single\nelements that have multiple possible representations as intervals so that logic doesn't have to account\nfor the variability. More complex calculations (such as medication request period or dispense period\ncalculation) need specific guidance and consideration. That guidance may make use of this function, but\nthe focus of this function is on single element calculations where the semantics are unambiguous.\nIf the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.\nIf the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,\nand the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.\nIf the input is a DateTime Interval, the result is the input.\nIf the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result\nis a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending\nimmediately before one year later than the date the patient turned the age given as the end of the quantity interval.\nIf 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\n*/\ndefine fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>, Timing>):\n  case\n\t  when choice is DateTime then\n    \tInterval[choice as DateTime, choice as DateTime]\n\t\twhen choice is Interval<DateTime> then\n  \t\tchoice as Interval<DateTime>\n\t\twhen choice is Quantity then\n\t\t  Interval[Patient.birthDate + (choice as Quantity),\n\t\t\t  Patient.birthDate + (choice as Quantity) + 1 year)\n\t\twhen choice is Interval<Quantity> then\n\t\t  Interval[Patient.birthDate + (choice.low as Quantity),\n\t\t\t  Patient.birthDate + (choice.high as Quantity) + 1 year)\n\t\twhen choice is Timing then\n      Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval<DateTime>\n\t\telse\n\t\t\tnull as Interval<DateTime>\n\tend"
            },
            {
              "url": "displaySequence",
              "valueInteger": 31
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        },
        {
          "extension": [
            {
              "url": "libraryName",
              "valueString": "CQMCommon"
            },
            {
              "url": "name",
              "valueString": "hospitalizationWithObservation"
            },
            {
              "url": "statement",
              "valueString": "/*\n@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\n*/\ndefine fluent function hospitalizationWithObservation(TheEncounter Encounter ):\n  TheEncounter Visit\n  \t\tlet ObsVisit: Last([Encounter: \"Observation Services\"] LastObs\n  \t\t\t\twhere LastObs.status = 'finished'\n            and LastObs.period ends 1 hour or less on or before start of Visit.period\n  \t\t\t\tsort by end of period\n  \t\t\t),\n  \t\t\tVisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),\n  \t\t\tEDVisit: Last([Encounter: \"Emergency Department Visit\"] LastED\n  \t\t\t\twhere LastED.status = 'finished'\n            and LastED.period ends 1 hour or less on or before VisitStart\n  \t\t\t\tsort by end of period\n  \t\t\t)\n  \t\treturn Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]"
            },
            {
              "url": "displaySequence",
              "valueInteger": 32
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
        }
      ],
      "name": "EffectiveDataRequirements",
      "status": "active",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/library-type",
            "code": "module-definition"
          }
        ]
      },
      "relatedArtifact": [
        {
          "type": "depends-on",
          "display": "Library SDE",
          "resource": "https://madie.cms.gov/Library/SupplementalDataElements|5.1.000"
        },
        {
          "type": "depends-on",
          "display": "Library FHIRHelpers",
          "resource": "https://madie.cms.gov/Library/FHIRHelpers|4.4.000"
        },
        {
          "type": "depends-on",
          "display": "Library CQMCommon",
          "resource": "https://madie.cms.gov/Library/CQMCommon|4.1.000"
        },
        {
          "type": "depends-on",
          "display": "Library QICoreCommon",
          "resource": "https://madie.cms.gov/Library/QICoreCommon|4.0.000"
        },
        {
          "type": "depends-on",
          "display": "Code system SNOMEDCT",
          "resource": "http://snomed.info/sct"
        },
        {
          "type": "depends-on",
          "display": "Code system MedicationRequestCategory",
          "resource": "http://terminology.hl7.org/CodeSystem/medicationrequest-category"
        },
        {
          "type": "depends-on",
          "display": "Code system ConditionClinicalStatusCodes",
          "resource": "http://terminology.hl7.org/CodeSystem/condition-clinical"
        },
        {
          "type": "depends-on",
          "display": "Code system ConditionVerificationStatusCodes",
          "resource": "http://terminology.hl7.org/CodeSystem/condition-ver-status"
        },
        {
          "type": "depends-on",
          "display": "Value set Encounter Inpatient",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"
        },
        {
          "type": "depends-on",
          "display": "Value set Schedule II, III and IV Opioid Medications",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241"
        },
        {
          "type": "depends-on",
          "display": "Value set Schedule IV Benzodiazepines",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1"
        },
        {
          "type": "depends-on",
          "display": "Value set Payer Type",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"
        },
        {
          "type": "depends-on",
          "display": "Value set Cancer Related Pain",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180"
        },
        {
          "type": "depends-on",
          "display": "Value set Sickle Cell Disease with and without Crisis",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175"
        },
        {
          "type": "depends-on",
          "display": "Value set Medications for Opioid Use Disorder (MOUD)",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269"
        },
        {
          "type": "depends-on",
          "display": "Value set Opioid Medication Assisted Treatment (MAT)",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177"
        },
        {
          "type": "depends-on",
          "display": "Value set Opioid Use Disorder",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171"
        },
        {
          "type": "depends-on",
          "display": "Value set Palliative or Hospice Care",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579"
        },
        {
          "type": "depends-on",
          "display": "Value set Observation Services",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"
        },
        {
          "type": "depends-on",
          "display": "Value set Emergency Department Visit",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"
        },
        {
          "type": "depends-on",
          "display": "Value set Discharge To Acute Care Facility",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87"
        },
        {
          "type": "depends-on",
          "display": "Value set Hospice Care Referral or Admission",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365"
        },
        {
          "type": "depends-on",
          "display": "Value set Patient Expired",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309"
        },
        {
          "type": "depends-on",
          "display": "Value set Left Against Medical Advice",
          "resource": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308"
        }
      ],
      "parameter": [
        {
          "name": "Measurement Period",
          "use": "in",
          "min": 0,
          "max": "1",
          "type": "Period"
        },
        {
          "name": "Numerator",
          "use": "out",
          "min": 0,
          "max": "*",
          "type": "Resource"
        },
        {
          "name": "Denominator",
          "use": "out",
          "min": 0,
          "max": "*",
          "type": "Resource"
        },
        {
          "name": "Initial Population",
          "use": "out",
          "min": 0,
          "max": "*",
          "type": "Resource"
        },
        {
          "name": "Denominator Exclusion",
          "use": "out",
          "min": 0,
          "max": "*",
          "type": "Resource"
        },
        {
          "name": "SDE Sex",
          "use": "out",
          "min": 0,
          "max": "1",
          "type": "Coding"
        },
        {
          "name": "SDE Payer",
          "use": "out",
          "min": 0,
          "max": "*",
          "type": "Resource"
        },
        {
          "name": "SDE Ethnicity",
          "use": "out",
          "min": 0,
          "max": "1",
          "type": "Resource"
        },
        {
          "name": "SDE Race",
          "use": "out",
          "min": 0,
          "max": "1",
          "type": "Resource"
        }
      ],
      "dataRequirement": [
        {
          "type": "Patient",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient"
          ],
          "mustSupport": [
            "extension",
            "url",
            "birthDate",
            "birthDate.value"
          ]
        },
        {
          "type": "Encounter",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"
          ],
          "mustSupport": [
            "type",
            "status",
            "status.value",
            "period",
            "reasonCode",
            "hospitalization",
            "hospitalization.dischargeDisposition"
          ],
          "codeFilter": [
            {
              "path": "type",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307"
            }
          ]
        },
        {
          "type": "Encounter",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"
          ],
          "mustSupport": [
            "type",
            "status",
            "status.value",
            "period",
            "reasonCode",
            "hospitalization",
            "hospitalization.dischargeDisposition"
          ],
          "codeFilter": [
            {
              "path": "type",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143"
            }
          ]
        },
        {
          "type": "Encounter",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"
          ],
          "mustSupport": [
            "type",
            "status",
            "status.value",
            "period",
            "reasonCode",
            "hospitalization",
            "hospitalization.dischargeDisposition"
          ],
          "codeFilter": [
            {
              "path": "type",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"
            }
          ]
        },
        {
          "type": "MedicationRequest",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest"
          ],
          "mustSupport": [
            "medication",
            "status",
            "status.value",
            "intent",
            "intent.value",
            "authoredOn",
            "authoredOn.value"
          ],
          "codeFilter": [
            {
              "path": "medication",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241"
            }
          ]
        },
        {
          "type": "MedicationRequest",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest"
          ],
          "mustSupport": [
            "medication",
            "status",
            "status.value",
            "intent",
            "intent.value",
            "authoredOn",
            "authoredOn.value"
          ],
          "codeFilter": [
            {
              "path": "medication",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1"
            }
          ]
        },
        {
          "type": "MedicationRequest",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest"
          ],
          "mustSupport": [
            "medication",
            "status",
            "status.value",
            "intent",
            "intent.value",
            "authoredOn",
            "authoredOn.value"
          ],
          "codeFilter": [
            {
              "path": "medication",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269"
            }
          ]
        },
        {
          "type": "MedicationRequest",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest"
          ],
          "mustSupport": [
            "medication.reference.value",
            "status",
            "status.value",
            "intent",
            "intent.value",
            "authoredOn",
            "authoredOn.value",
            "medication"
          ]
        },
        {
          "type": "Medication",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication"
          ],
          "mustSupport": [
            "id.value",
            "code"
          ]
        },
        {
          "type": "Coverage",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage"
          ],
          "mustSupport": [
            "type",
            "period"
          ],
          "codeFilter": [
            {
              "path": "type",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"
            }
          ]
        },
        {
          "type": "Condition",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis"
          ]
        },
        {
          "type": "Condition",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"
          ]
        },
        {
          "type": "Condition",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"
          ],
          "mustSupport": [
            "code",
            "verificationStatus"
          ],
          "codeFilter": [
            {
              "path": "code",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171"
            }
          ]
        },
        {
          "type": "Condition",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"
          ],
          "mustSupport": [
            "code",
            "verificationStatus"
          ],
          "codeFilter": [
            {
              "path": "code",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180"
            }
          ]
        },
        {
          "type": "Condition",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns"
          ],
          "mustSupport": [
            "code",
            "verificationStatus"
          ],
          "codeFilter": [
            {
              "path": "code",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175"
            }
          ]
        },
        {
          "type": "Procedure",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"
          ],
          "mustSupport": [
            "code",
            "performed",
            "status",
            "status.value"
          ],
          "codeFilter": [
            {
              "path": "code",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177"
            }
          ]
        },
        {
          "type": "Procedure",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"
          ],
          "mustSupport": [
            "code",
            "status",
            "status.value"
          ],
          "codeFilter": [
            {
              "path": "code",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579"
            }
          ]
        },
        {
          "type": "ServiceRequest",
          "profile": [
            "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest"
          ],
          "mustSupport": [
            "code",
            "status",
            "status.value"
          ],
          "codeFilter": [
            {
              "path": "code",
              "valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579"
            }
          ]
        }
      ]
    }
  ],
  "extension": [
    {
      "id": "supplementalDataGuidance",
      "extension": [
        {
          "url": "guidance",
          "valueString": "For every patient evaluated by this measure also identify payer, race, ethnicity and sex.\n "
        },
        {
          "url": "usage",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-data-usage",
                "code": "supplemental-data",
                "display": "Supplemental Data"
              }
            ],
            "text": "Supplemental Data Guidance"
          }
        }
      ],
      "url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-supplementalDataGuidance"
    },
    {
      "url": "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements",
      "valueReference": {
        "reference": "#effective-data-requirements"
      }
    }
  ],
  "url": "https://madie.cms.gov/Measure/CMS506FHIRSafeUseofOpioids",
  "identifier": [
    {
      "use": "usual",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/artifact-identifier-type",
            "code": "short-name",
            "display": "Short Name"
          }
        ]
      },
      "system": "https://madie.cms.gov/measure/shortName",
      "value": "CMS506FHIR"
    },
    {
      "use": "official",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/artifact-identifier-type",
            "code": "version-independent",
            "display": "Version Independent"
          }
        ]
      },
      "system": "urn:ietf:rfc:3986",
      "value": "urn:uuid:95d529af-66b4-4cfd-bc1f-f43704dc47ad"
    },
    {
      "use": "official",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/artifact-identifier-type",
            "code": "version-specific",
            "display": "Version Specific"
          }
        ]
      },
      "system": "urn:ietf:rfc:3986",
      "value": "urn:uuid:a5424631-846f-4d04-803b-afbf6dc25df6"
    },
    {
      "use": "official",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/artifact-identifier-type",
            "code": "endorser",
            "display": "Endorser"
          }
        ]
      },
      "system": "https://madie.cms.gov/measure/cbeId",
      "value": "3316e",
      "assigner": {
        "display": "CMS Consensus Based Entity"
      }
    },
    {
      "use": "official",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/artifact-identifier-type",
            "code": "publisher",
            "display": "Publisher"
          }
        ]
      },
      "system": "https://madie.cms.gov/measure/cmsId",
      "value": "506FHIR",
      "assigner": {
        "display": "CMS"
      }
    }
  ],
  "version": "0.3.007",
  "name": "CMS506FHIRSafeUseofOpioids",
  "title": "Safe Use of Opioids - Concurrent PrescribingFHIR",
  "status": "active",
  "experimental": false,
  "date": "2025-07-07T16:25:33+00:00",
  "publisher": "Centers for Medicare & Medicaid Services (CMS)",
  "contact": [
    {
      "telecom": [
        {
          "system": "url",
          "value": "https://www.cms.gov/"
        }
      ]
    }
  ],
  "description": "Proportion of inpatient hospitalizations for patients 18 years of age and older prescribed, or continued on, two or more opioids or an opioid and benzodiazepine concurrently at discharge",
  "usage": "Clinician judgement, clinical appropriateness, or both may indicate concurrent prescribing of two unique opioids or an opioid and benzodiazepine is medically necessary, thus the measure is not expected to have a zero rate. \n\nNew or continuing opioid and benzodiazepine medications are included with the use of the MedicationRequest QI-Core Profile. The Profile's community and discharge category codes indicate that the medications should be taken by or given to the patient after being discharged from an inpatient encounter, which could include previously or newly prescribed medications.\n\nInpatient hospitalizations with discharge medications of an opioid or benzodiazepine prescription should be included in the initial population. \n\nInpatient hospitalizations with discharge medications of two or more opioids or an opioid and benzodiazepine resulting in concurrent therapy at discharge should be included in the numerator. Each benzodiazepine and opioid included on the medication discharge list is considered a unique prescription.\n\nThe denominator 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.\n\nThis dQM is an episode-based measure. An episode is defined as each inpatient hospitalization or encounter that ends during the measurement period. \n\nThis FHIR-based measure has been derived from the QDM-based measure: CMS 506v8.0. 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).",
  "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.\n\nCPT(R) contained in the measure specifications is copyright 2004-2024 American Medical Association. 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.",
  "effectivePeriod": {
    "start": "2026-01-01",
    "end": "2026-12-31"
  },
  "author": [
    {
      "name": "Mathematica",
      "telecom": [
        {
          "system": "url",
          "value": "https://www.mathematica.org/"
        }
      ]
    }
  ],
  "relatedArtifact": [
    {
      "type": "citation",
      "citation": "CITATION - American Academy of Emergency Medicine (AAEM). (2013). Emergency department opioid-prescribing guidelines for the treatment of non-cancer-related pain. Retrieved from https://www.aaem.org/UserFiles/file/Emergency-Department-Opoid-Prescribing-Guidelines.pdf\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - American Society of Interventional Pain Physicians (ASIPP). (2012). Guidelines for responsible opioid prescribing in chronic noncancer pain. Retrieved from https://pubmed.ncbi.nlm.nih.gov/22786449/\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Dasgupta, N., Jonsson Funk, M., Proescholdbell, S., et al. (2015, September). Cohort study of the impact of high-dose opioid analgesics on overdose mortality. Pain Medicine. Retrieved from http://onlinelibrary.wiley.com/doi/10.1111/pme.12907/abstract  \n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Dowell, D., Haegerich, T., & Chou, R. (2016). CDC guideline for prescribing opioids for chronic pain-United States, 2016. MMWR Recommendations and Reports, 65. Retrieved from http://www.cdc.gov/media/dpk/2016/dpk-opioid-prescription-guidelines.html\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Geller, A. I., Dowell, D., Lovegrove, M. C., Mcaninch, J. K., Goring, S. K., Rose, K. O., Budnitz, D. S. (2019). U.S. Emergency Department Visits Resulting From Nonmedical Use of Pharmaceuticals, 2016. American Journal of Preventive Medicine, 56(5), 639-647. https://doi.org/10.1016/j.amepre.2018.12.009\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Herzig, S., Rothberg, M., Cheung, M., et al. (2014). Opioid utilization and opioid-related adverse events in nonsurgical patients in U.S. hospitals. Journal of Hospital Medicine, 9(2), 73-81.\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Jena, A., Goldman, D., Schaeffer, L. D., et al. (2014). Opioid prescribing by multiple providers in Medicare: Retrospective observational study of insurance claims. BMJ, 348, g1393. DOI: 10.1136/bmj.g1393\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Lin, L. A., Bohnert, A. S., Kerns, R. D., et al. (2017). Impact of the opioid safety initiative on opioid-related prescribing in veterans. Pain, 158(5), 833-839. Retrieved from https://www.ncbi.nlm.nih.gov/pubmed/28240996\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Liu, Y., Logan, J., Paulozzi, L., et al. (2013). Potential misuse and inappropriate prescription practices involving opioid analgesics. American Journal of Managed Care, 19(8), 648-665. Retrieved from http://www.ajmc.com/journals/issue/2013/2013-1-vol19-n8/Potential-Misuse-and-Inappropriate-Prescription-Practices-Involving-Opioid-Analgesics/\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Mack, K., Zhang, K., Paulozzi, L., et al. (2015, February). Prescription practices involving opioid analgesics among Americans with Medicaid, 2010. Journal of Health Care for the Poor and Underserved, 26(1), 182-198. Retrieved from http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4365785\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - National Institute on Drug Abuse. (2011). Analysis of opioid prescription practices finds areas of concern. Retrieved from https://www.drugabuse.gov/news-events/news-releases/2011/04/analysis-opioid-prescription-practices-finds-areas-concern\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - New York City (NYC) Department of Health and Mental Hygiene (NYC DOHMH). (2013). NYC emergency department discharge opioid-prescribing guidelines. Retrieved from https://www1.nyc.gov/site/doh/providers/health-topics/opioid-prescribing-resources-for-emergency-departments.page\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Park, T., Saitz, R., Ganoczy, D., et al. (2015). Benzodiazepine-prescribing patterns and deaths from drug overdose among U.S. veterans receiving opioid analgesics: Case-cohort study. BMJ, 350, h2698. Retrieved from http://www.bmj.com/content/350/bmj.h2698\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Rudd, R., Aleshire, N., Zibbell, J., et al. (2016, January). Increases in drug and opioid overdose deaths-United States, 2000-2014. Morbidity and Mortality Weekly Report, 64(50), 1378-1382. Retrieved from http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6450a3.htm\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Sun, E., Dixit, A., Humphreys, K., et al. (2017). Association between concurrent use of prescription opioids and benzodiazepines and overdose: Retrospective analysis. BMJ, 356, j760. Retrieved from\nhttp://www.bmj.com/content/356/bmj.j760\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - U.S. Department of Veterans Affairs. (2014). Opioid safety initiative toolkit. Retrieved from https://www.va.gov/PAINMANAGEMENT/Opioid_Safety_Initiative_OSI.asp\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - U.S. Department of Veterans Affairs. (2016). Opioid safety initiative: Opioids (including tramadol) used in combination with benzodiazepine derivative sedatives/hypnotics. Unpublished manuscript.\n"
    },
    {
      "type": "citation",
      "citation": "CITATION - Washington Agency Medical Directors' Group (WAMDG). (2015). Interagency guideline on prescribing opioids for pain, Part II: Prescribing opioids in the acute and subacute phase. Retrieved from http://www.agencymeddirectors.wa.gov/Files/2015AMDGOpioidGuideline.pdf\n"
    }
  ],
  "library": [
    "https://madie.cms.gov/Library/CMS506FHIRSafeUseofOpioids"
  ],
  "disclaimer": "These performance measures are not clinical guidelines, do not establish a standard of medical care, and have not been tested for all potential applications.\n\nTHE MEASURES AND SPECIFICATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND.\n\nDue to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].",
  "rationale": "Unintentional opioid overdose fatalities have become a major public health concern in the United States (Rudd, Aleshire, Zibbel, & Gladden, 2016). Reducing the number of unintentional overdoses has become a priority for numerous federal organizations including, but not limited to, the Centers for Disease Control and Prevention (CDC), the Federal Interagency Workgroup for Opioid Adverse Drug Events, and the Substance Abuse and Mental Health Services Administration. \n\nConcurrent prescriptions of opioids or opioids and benzodiazepines places patients at a greater risk of unintentional overdose due to the increased risk of respiratory depression (Dowell, Haegerich, & Chou, 2016; Dowell, Ragan, Jones, Baldwin, & Chou, 2022). An analysis of national prescribing patterns shows that more than half of patients who received an opioid prescription in 2009 had filled another opioid prescription within the previous 30 days (National Institute on Drug Abuse, 2011). Studies of multiple claims and prescription databases have shown that between 5%-15% of patients receive concurrent opioid prescriptions and 5%-20% of patients receive concurrent opioid and benzodiazepine prescriptions across various settings (Liu et al., 2013; Mack et al., 2015, Park et al., 2015). Patients who have multiple opioid prescriptions have an increased risk for overdose (Jena et al., 2014). Rates of fatal overdose are ten times higher in patients who are co-dispensed opioid analgesics and benzodiazepines than opioids alone (Dasgupta et al., 2015). The number of opioid overdose deaths involving benzodiazepines increased 14% on average each year from 2006 to 2011, while the number of opioid analgesic overdose deaths not involving benzodiazepines did not change significantly (Jones & McAninch, 2015). Furthermore, concurrent use of benzodiazepines with opioids was prevalent in 31%-51% of fatal overdoses (Dowell, Haegerich, & Chou, 2016). One study found that eliminating concurrent use of opioids and benzodiazepines could reduce the risk of opioid overdose-related emergency department (ED) and inpatient visits by 15% and potentially could have prevented an estimated 2,630 deaths related to opioid painkiller overdoses in 2015 (Sun, Dixit, Humphreys, Darnall, & Mackey, 2017). \n\nA study on The Opioid Safety Initiative in the Veterans Health Administration (VHA), which includes an opioid and benzodiazepine concurrent prescribing measure that this measure is based on, was associated with a decrease of 20.67% overall and 0.86% patients per month (781 patients per month) receiving concurrent benzodiazepine with an opioid among all adult VHA patients who filled outpatient opioid prescriptions from October 2012 to September 2014 (Lin, Bohnert, Kerns, Clay, Ganoczy, & Ilgen, 2017).\n\nAdopting a measure that calculates the proportion of patients with two or more opioids or opioids and benzodiazepines concurrently has the potential to reduce preventable mortality and reduce the costs associated with adverse events related to opioid use by (1) encouraging providers to identify patients with concurrent prescriptions of opioids or opioids and benzodiazepines and (2) discouraging providers from prescribing two or more opioids or opioids and benzodiazepines concurrently.",
  "clinicalRecommendationStatement": "The CDC Clinical Practice Guideline for Prescribing Opioids for Pain - United States, 2022 recommends that clinicians should:\n- \"[Use strategies minimizing] opioid use... for both opioid-naive and opioid-tolerant patients with acute pain when possible. If patients receiving long-term opioid therapy require additional medication for acute pain, nonopioid medications should be used when possible.\"\n- \"Use particular caution when prescribing opioid pain medication and benzodiazepines concurrently.\"\n- \"Review increased risks for respiratory depression when opioids are taken with benzodiazepines, other sedatives, alcohol, nonprescribed or illicit drugs (e.g., heroin), or other opioids (see Recommendations 8 and 11)\"\n- \"Closely monitor patients who are unable to taper and who continue on high-dose or otherwise high-risk opioid regimens (e.g., opioids prescribed concurrently with benzodiazepines) and should work with patients to mitigate overdose risk (e.g., by providing overdose education and naloxone) (see Recommendation 8).\"\n- \"Discuss information from the PDMP with the patient and confirm that the patient is aware of any additional prescriptions.\"\n- \"Discuss safety concerns, including increased risk for respiratory depression and overdose, with patients found to be receiving overlapping prescription opioids from multiple clinicians who are not coordinating the patient's care or patients who are receiving medications that increase risk when combined with opioids (e.g., benzodiazepines) (see Recommendation 11), and offer naloxone (see Recommendation 8).\"\n- \"Discuss safety concerns with other clinicians who are prescribing controlled substances for the patient. Ideally, clinicians should first discuss concerns with the patient and inform them that they plan to coordinate care with their other clinicians to improve the patient's safety.\"\n\nIn addition to the 2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain, opioid prescribing guidelines issued by various state agencies and professional societies for various settings agree with the recommendation to avoid concurrently prescribing opioids  (American Academy of Emergency Medicine (AAEM), 2013; and Washington Agency Medical Directors' Group (WAMDG), 2015), and opioids and benzodiazepines (WAMDG, 2015; American Society of Interventional Pain Physicians (ASIPP), 2012;, and New York City Department Of Health and Mental Hygiene (NYC DPOMH), 2013) whenever possible as the combination of these medications may potentiate opioid-induced respiratory depression.",
  "group": [
    {
      "id": "Group_1",
      "extension": [
        {
          "url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-scoring",
                "code": "proportion",
                "display": "Proportion"
              }
            ]
          }
        },
        {
          "url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis",
          "valueCode": "Encounter"
        },
        {
          "url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-type",
                "code": "process",
                "display": "Process"
              }
            ]
          }
        },
        {
          "url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-rateAggregation",
          "valueCode": "None"
        },
        {
          "url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-improvementNotation",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-improvement-notation",
                "code": "decrease",
                "display": "Decreased score indicates improvement"
              }
            ]
          }
        }
      ],
      "population": [
        {
          "id": "InitialPopulation_1",
          "code": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-population",
                "code": "initial-population",
                "display": "Initial Population"
              }
            ]
          },
          "description": "Inpatient hospitalizations that end during the measurement period, where the patient is 18 years of age and older at the start of the encounter and prescribed one opioid and/or benzodiazepine at discharge",
          "criteria": {
            "language": "text/cql-identifier",
            "expression": "Initial Population"
          }
        },
        {
          "id": "Denominator_1",
          "code": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-population",
                "code": "denominator",
                "display": "Denominator"
              }
            ]
          },
          "description": "Equals Initial Population",
          "criteria": {
            "language": "text/cql-identifier",
            "expression": "Denominator"
          }
        },
        {
          "id": "DenominatorExclusion_1",
          "code": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-population",
                "code": "denominator-exclusion",
                "display": "Denominator Exclusion"
              }
            ]
          },
          "description": "Inpatient hospitalizations where patients have cancer pain that begins prior to or during the encounter or are ordered or are receiving palliative or hospice care (including comfort measures, terminal care, and dying care) during the hospitalization or in an emergency department encounter or observation stay immediately prior to hospitalization, patients receiving medication for opioid use disorder (OUD) with active OUD diagnosis or Opioid Medication Assisted Treatment (MAT), patients with sickle cell disease, patients discharged to another inpatient care facility or left against medical advice, and patients who expire during the inpatient stay",
          "criteria": {
            "language": "text/cql-identifier",
            "expression": "Denominator Exclusion"
          }
        },
        {
          "id": "Numerator_1",
          "code": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/measure-population",
                "code": "numerator",
                "display": "Numerator"
              }
            ]
          },
          "description": "Inpatient hospitalizations where the patient is prescribed two or more opioids or an opioid and benzodiazepine at discharge",
          "criteria": {
            "language": "text/cql-identifier",
            "expression": "Numerator"
          }
        }
      ]
    }
  ],
  "supplementalData": [
    {
      "id": "sde-ethnicity",
      "usage": [
        {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/measure-data-usage",
              "code": "supplemental-data"
            }
          ]
        }
      ],
      "description": "SDE Ethnicity",
      "criteria": {
        "language": "text/cql-identifier",
        "expression": "SDE Ethnicity"
      }
    },
    {
      "id": "sde-payer",
      "usage": [
        {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/measure-data-usage",
              "code": "supplemental-data"
            }
          ]
        }
      ],
      "description": "SDE Payer",
      "criteria": {
        "language": "text/cql-identifier",
        "expression": "SDE Payer"
      }
    },
    {
      "id": "sde-race",
      "usage": [
        {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/measure-data-usage",
              "code": "supplemental-data"
            }
          ]
        }
      ],
      "description": "SDE Race",
      "criteria": {
        "language": "text/cql-identifier",
        "expression": "SDE Race"
      }
    },
    {
      "id": "sde-sex",
      "usage": [
        {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/measure-data-usage",
              "code": "supplemental-data"
            }
          ]
        }
      ],
      "description": "SDE Sex",
      "criteria": {
        "language": "text/cql-identifier",
        "expression": "SDE Sex"
      }
    }
  ]
}