eCQM QICore Content Implementation Guide
2024.0.0 - CI Build

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

Measure: Initiation and Engagement of Substance Use Disorder TreatmentFHIR

Official URL: https://madie.cms.gov/Measure/InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Version: 0.0.002
Draft as of 2024-07-09 Responsible: National Committee for Quality Assurance Computable Name: InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR
Other Identifiers: Short Name (use: usual, ), UUID:7738a412-7fff-4276-a140-8ee4c08503a2 (use: official, ), UUID:5a9ec9ee-f497-4cc1-b8da-9b051397d5b6 (use: official, ), Publisher (use: official, )

Copyright/Legal: This Physician Performance Measure (Measure) and related data specifications are owned and were developed by the National Committee for Quality Assurance (NCQA). NCQA is not responsible for any use of the Measure. NCQA makes no representations, warranties, or endorsement about the quality of any organization or physician that uses or reports performance measures and NCQA has no liability to anyone who relies on such measures or specifications. NCQA holds a copyright in the Measure. The Measure can be reproduced and distributed, without modification, for noncommercial purposes (e.g., use by healthcare providers in connection with their practices) without obtaining approval from NCQA. Commercial use is defined as the sale, licensing, or distribution of the Measure for commercial gain, or incorporation of the Measure into a product or service that is sold, licensed or distributed for commercial gain. All commercial uses or requests for modification must be approved by NCQA and are subject to a license at the discretion of NCQA. (C) 2012-2024 National Committee for Quality Assurance. All Rights Reserved. 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. NCQA disclaims all liability for use or accuracy of any third-party codes contained in the specifications. CPT(R) codes, descriptions and other data are copyright 2024. American Medical Association. All rights reserved. CPT is a trademark of the American Medical Association. Fee schedules, relative value units, conversion factors and/or related components are not assigned by the AMA, are not part of CPT, and the AMA is not recommending their use. The AMA does not directly or indirectly practice medicine or dispense medical services. The AMA assumes no liability for data contained or not contained herein. Applicable FARS/DFARS restrictions apply to government use. Some measure specifications contain coding from LOINC(R) (http://loinc.org). The LOINC table, LOINC codes, LOINC panels and form file, LOINC linguistic variants file, LOINC/RSNA Radiology Playbook, and LOINC/IEEE Medical Device Code Mapping Table are copyright 2004-2024 Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee, and are available at no cost under the license at http://loinc.org/terms-of-use. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2023 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved. Some measures use RxNorm, a standardized nomenclature and coding for clinical drugs and drug delivery devices, which is made publicly available courtesy of the U.S. National Library of Medicine (NLM), National Institutes of Health, Department of Health and Human Services. NLM is not responsible for the measures and does not endorse or recommend this or any other product. “HL7” is the registered trademark of Health Level Seven International.

Percentage of patients 13 years of age and older with a new substance use disorder (SUD) episode who received the following (Two rates are reported): a. Percentage of patients who initiated treatment, including either an intervention or medication for the treatment of SUD, within 14 days of the new SUD episode. b. Percentage of patients who engaged in ongoing treatment, including two additional interventions or medication treatment events for SUD, or one long-acting medication event for the treatment of SUD, within 34 days of the initiation.

UNKNOWN

Title: Initiation and Engagement of Substance Use Disorder TreatmentFHIR
Id: InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR
Version: 0.0.002
Url: Initiation and Engagement of Substance Use Disorder TreatmentFHIR
short-name identifier:

CMS137FHIR

version-independent identifier:

urn:uuid:7738a412-7fff-4276-a140-8ee4c08503a2

version-specific identifier:

urn:uuid:5a9ec9ee-f497-4cc1-b8da-9b051397d5b6

publisher (CMS) identifier:

137FHIR

Effective Period: 2025-01-01..2025-12-31
Status: draft
Publisher: National Committee for Quality Assurance
Author: National Committee for Quality Assurance
Description:

Percentage of patients 13 years of age and older with a new substance use disorder (SUD) episode who received the following (Two rates are reported): a. Percentage of patients who initiated treatment, including either an intervention or medication for the treatment of SUD, within 14 days of the new SUD episode. b. Percentage of patients who engaged in ongoing treatment, including two additional interventions or medication treatment events for SUD, or one long-acting medication event for the treatment of SUD, within 34 days of the initiation.

Purpose:

UNKNOWN

Copyright:

This Physician Performance Measure (Measure) and related data specifications are owned and were developed by the National Committee for Quality Assurance (NCQA). NCQA is not responsible for any use of the Measure. NCQA makes no representations, warranties, or endorsement about the quality of any organization or physician that uses or reports performance measures and NCQA has no liability to anyone who relies on such measures or specifications. NCQA holds a copyright in the Measure. The Measure can be reproduced and distributed, without modification, for noncommercial purposes (e.g., use by healthcare providers in connection with their practices) without obtaining approval from NCQA. Commercial use is defined as the sale, licensing, or distribution of the Measure for commercial gain, or incorporation of the Measure into a product or service that is sold, licensed or distributed for commercial gain. All commercial uses or requests for modification must be approved by NCQA and are subject to a license at the discretion of NCQA. (C) 2012-2024 National Committee for Quality Assurance. All Rights Reserved. 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. NCQA disclaims all liability for use or accuracy of any third-party codes contained in the specifications. CPT(R) codes, descriptions and other data are copyright 2024. American Medical Association. All rights reserved. CPT is a trademark of the American Medical Association. Fee schedules, relative value units, conversion factors and/or related components are not assigned by the AMA, are not part of CPT, and the AMA is not recommending their use. The AMA does not directly or indirectly practice medicine or dispense medical services. The AMA assumes no liability for data contained or not contained herein. Applicable FARS/DFARS restrictions apply to government use. Some measure specifications contain coding from LOINC(R) (http://loinc.org). The LOINC table, LOINC codes, LOINC panels and form file, LOINC linguistic variants file, LOINC/RSNA Radiology Playbook, and LOINC/IEEE Medical Device Code Mapping Table are copyright 2004-2024 Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee, and are available at no cost under the license at http://loinc.org/terms-of-use. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2023 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved. Some measures use RxNorm, a standardized nomenclature and coding for clinical drugs and drug delivery devices, which is made publicly available courtesy of the U.S. National Library of Medicine (NLM), National Institutes of Health, Department of Health and Human Services. NLM is not responsible for the measures and does not endorse or recommend this or any other product. “HL7” is the registered trademark of Health Level Seven International.

Disclaimer:

The performance Measure is not a clinical guideline and does not establish a standard of medical care, and has not been tested for all potential applications. THE MEASURE AND SPECIFICATIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].

Rationale:

There are more deaths, illnesses and disabilities from substance abuse than from any other preventable health condition. In 2021, 46.3 million individuals in the U.S. age 12 or older (16.5 percent of the population) met the diagnosis criteria for having an SUD within the past year (Substance Abuse and Mental Health Services Administration [SAMHSA], 2022). Despite the high prevalence of SUD in the U.S., 94 percent of individuals aged 12 or older with an SUD did not receive any treatment (SAMHSA, 2022).

Clinical recommendation statement:

American Society of Addiction Medicine (2020) - All Food and Drug Administration approved medications for the treatment of opioid use disorder should be available to all patients. Clinicians should consider the patient’s preferences, past treatment history, current state of illness, and treatment setting when deciding between the use of methadone, buprenorphine, and naltrexone. - There is no recommended time limit for pharmacological treatment - Patients’ psychosocial needs should be assessed, and patients should be offered or referred to psychosocial treatment based on their individual needs. However, a patient’s decision to decline psychosocial treatment or the absence of available psychosocial treatment should not preclude or delay pharmacotherapy, with appropriate medication management. Motivational interviewing or enhancement can be used to encourage patients to engage in psychosocial treatment services appropriate for addressing individual needs. American Psychiatric Association (2018) - Patients with alcohol use disorder should have a documented comprehensive and person-centered treatment plan that includes evidence-based nonpharmacological and pharmacological treatments. [1C] - Naltrexone or acamprosate should be offered to patients with moderate to severe alcohol use disorder who have a goal of reducing alcohol consumption or achieving abstinence, prefer pharmacotherapy or have not responded to nonpharmacological treatments alone, and have no contraindications to the use of these medications. [1B] - Disulfiram should be offered to patients with moderate to severe alcohol use disorder who have a goal of achieving abstinence, prefer disulfiram or are intolerant to or have not responded to naltrexone and acamprosate, are capable of understanding the risks of alcohol consumption while taking disulfiram, and have no contraindications to the use of this medication. [2C] - Topiramate or gabapentin should be offered to patients with moderate to severe alcohol use disorder who have a goal of reducing alcohol consumption or achieving abstinence, prefer topiramate or gabapentin or are intolerant to or have not responded to naltrexone and acamprosate, and have no contraindications to the use of these medications. [2C] American Psychiatric Association (2006) - Because many substance use disorders are chronic, patients usually require long-term treatment, although the intensity and specific components of treatment may vary over time [I rating]. - It is important to intensify the monitoring for substance use during periods when the patient is at a high risk of relapsing, including during the early stages of treatment, times of transition to less intensive levels of care, and the first year after active treatment has ceased [I rating]. - Outpatient treatment of substance use disorders is appropriate for patients whose clinical condition or environmental circumstances do not require a more intensive level of care [I rating]. As in other treatment settings, a comprehensive approach is optimal, using, where indicated, a variety of psychotherapeutic and pharmacological interventions along with behavioral monitoring [I rating]. - Disulfiram is also recommended for patients with alcohol dependence [II rating]. - Naltrexone, injectable naltrexone, acamprosate, a y-aminobutyric acid (GABA) are recommended for patients with alcohol dependence [I rating]. Disulfiram is also recommended for patients with alcohol dependence [II rating]. - Methadone and buprenorphine are recommended for patients with opioid dependence [I rating]. - Naltrexone is an alternative strategy [I rating]. American Society of Addiction Medicine (2015) - Methadone and buprenorphine are recommended for opioid use disorder treatment and withdrawal management. - Naltrexone (oral; extended-release injectable) is recommended for relapse prevention. Michigan Quality Improvement Consortium (2021) - Patients with substance use disorder or risky substance use: Patient Education and Brief Intervention by a Primary Care Physician (PCP) or Trained Staff (e.g., Registered Nurse [RN], Master of Social Work [MSW]) - If diagnosed with substance use disorder or risky substance use, initiate an intervention within 14 days. - Frequent follow-up is helpful to support behavior change; preferably 2 visits within 30 days. - Refer to a substance abuse health specialist, an addiction physician specialist, or a physician experienced in pharmacologic management of addiction. Department of Veterans Affairs/Department of Defense (2015) - Offer referral to specialty SUD care for addiction treatment based on willingness to engage. [B] - For patients with moderate-severe alcohol use disorder, we recommend: Acamprosate, Disulfiram, Naltrexone- oral or extended release, or Topiramate. [A] - Medications should be offered in combined with addiction-focused counseling, offering one or more of the following interventions considering patient preference and provider training/competence: Behavioral Couples Therapy for alcohol use disorder, Cognitive Behavioral Therapy for substance use disorders, Community Reinforcement Approach, Motivational Enhancement Therapy, 12-Step Facilitation. [A] - For patients with opioid use disorder we recommend buprenorphine/naloxone or methadone in an Opioid Treatment Program. For patients for whom agonist treatment is contraindicated, unacceptable, unavailable, or discontinued, we recommend extended-release injectable naltrexone. [A] - For patients initiated in an intensive phase of outpatient or residential treatment, recommend ongoing systematic relapse prevention efforts or recovery support, individualized on the basis of treatment response. [A]

Guidance (Usage): This eCQM is a patient-based measure. This FHIR-based measure has been derived from the QDM-based measure: CMS137v13. Please refer to the HL7 QI-Core Implementation Guide (http://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (http://hl7.org/fhir/us/qicore/STU4.1.1/qdm-to-qicore.html).
Population Criteria: Stratifier Criteria:
662125a90f0a9077c1d5b5af
Initial Population: Patients 13 years of age and older as of the start of the measurement period who were diagnosed with a new SUD episode during a visit between January 1 and November 14 of the measurement period
Denominator: Equals Initial Population
Denominator Exclusion: Exclude patients who are in hospice care for any part of the measurement period
Numerator: Numerator 1: Initiation of treatment includes either an intervention or medication for the treatment of SUD within 14 days of the new SUD episode.
Stratum: Report a total score, and each of the following strata: Patients age 13-17 at the start of the measurement period
Stratum: Patients age 18-64 at the start of the measurement period
Stratum: Patients age 65 and older at the start of the measurement period
Stratifier Criteria:
662125a90f0a9077c1d5b5b0
Initial Population: Patients 13 years of age and older as of the start of the measurement period who were diagnosed with a new SUD episode during a visit between January 1 and November 14 of the measurement period
Denominator: Equals Initial Population
Denominator Exclusion: Exclude patients who are in hospice care for any part of the measurement period
Numerator: Numerator 2: Engagement in ongoing SUD treatment within 34 days of initiation includes: 1. A long-acting SUD medication on the day after the initiation through 34 days after the initiation of treatment. 2. One of the following options on the day after the initiation of treatment through 34 days after the initiation of treatment: a) two engagement visits, b) two engagement medication treatment events, c) one engagement visit and one engagement medication treatment event.
Stratum: Report a total score, and each of the following strata: Patients age 13-17 at the start of the measurement period
Stratum: Patients age 18-64 at the start of the measurement period
Stratum: Patients age 65 and older at the start of the measurement period
Libraries:
InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR
Terminology and Other Dependencies:
  • Library/Status|1.8.000
  • Library/QICoreCommon|2.1.000
  • Library/FHIRHelpers|4.4.000
  • Library/CQMCommon|2.2.000
  • Library/Hospice|6.12.000
  • SNOMED CT (all versions)
  • Observation Category Codes
  • Logical Observation Identifiers, Names and Codes (LOINC)
  • Office Visit
  • Emergency Department Visit
  • Detoxification Visit
  • Hospital Inpatient Visit - Initial
  • Discharge Services - Hospital Inpatient Same Day Discharge
  • Discharge Services - Hospital Inpatient
  • Telephone Visits
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089
  • Alcohol and Drug Dependence
  • Alcohol and Drug Dependence Treatment
  • Psych Visit - Psychotherapy
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1156
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1157
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1149
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1150
  • Encounter Inpatient
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
  • Hospice Care Ambulatory
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
  • Parameters:
    name use min max type
    Measurement Period In 0 1 Period
    Stratification 3 Out 0 1 boolean
    Stratification 2 Out 0 1 boolean
    Stratification 1 Out 0 1 boolean
    Denominator Out 0 1 boolean
    Numerator 1 Out 0 1 boolean
    Numerator 2 Out 0 1 boolean
    Initial Population Out 0 1 boolean
    Denominator Exclusions Out 0 1 boolean
    DataRequirements:
    Resource Type Resource Elements Valueset Name Valueset
    Patient(QICorePatient)
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Office Visit Office Visit
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Initial Hospital Inpatient Visit Hospital Inpatient Visit - Initial
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Discharge Services Hospital Inpatient Same Day Discharge Discharge Services - Hospital Inpatient Same Day Discharge
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Discharge Services Hospital Inpatient Discharge Services - Hospital Inpatient
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Emergency Department Evaluation and Management Visit Emergency Department Visit
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Detoxification Visit Detoxification Visit
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Telephone Visits Telephone Visits
    Encounter(QICoreEncounter) type status status.value period condition condition.reference condition.reference.value Virtual Encounter http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089
    Encounter(QICoreEncounter) type hospitalization hospitalization.dischargeDisposition period status status.value condition condition.reference condition.reference.value Encounter Inpatient Encounter Inpatient
    Encounter(QICoreEncounter) type period status status.value condition condition.reference condition.reference.value Hospice Encounter http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
    Condition(QICoreCondition) code Substance Use Disorder Alcohol and Drug Dependence
    Condition(QICoreCondition) id id.value code
    Condition(QICoreCondition) code Hospice Diagnosis http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
    Procedure(QICoreProcedure) code status status.value performed Substance Use Disorder Treatment Alcohol and Drug Dependence Treatment
    Procedure(QICoreProcedure) code status status.value performed Psych Visit Psychotherapy Psych Visit - Psychotherapy
    Procedure(QICoreProcedure) code status status.value performed Substance Use Disorder Long Acting Medication Administration http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1156
    Procedure(QICoreProcedure) code performed status status.value Substance Use Disorder Long Acting Medication Administration http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1156
    Procedure(QICoreProcedure) code status status.value performed Substance Use Disorder Short Acting Medication Administration http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1157
    Procedure(QICoreProcedure) code performed status status.value Hospice Care Ambulatory Hospice Care Ambulatory
    Medication(QICoreMedication) id
    Medication(QICoreMedication) id
    Medication(QICoreMedication) id
    Medication(QICoreMedication) id
    Medication(QICoreMedication) id
    Medication(QICoreMedication) id
    MedicationRequest(QICoreMedicationRequest) medication status status.value intent intent.value authoredOn authoredOn.value Substance Use Disorder Long Acting Medication http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1149
    MedicationRequest(QICoreMedicationRequest) medication.reference status status.value intent intent.value authoredOn authoredOn.value
    MedicationRequest(QICoreMedicationRequest) medication status status.value intent intent.value authoredOn authoredOn.value Substance Use Disorder Short Acting Medication http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1150
    Observation(QICoreObservation) code value effective status status.value category
    ServiceRequest(QICoreServiceRequest) code authoredOn authoredOn.value status status.value intent intent.value Hospice Care Ambulatory Hospice Care Ambulatory
    Direct Reference Codes:
    display code system
    Discharge to home for hospice care (procedure) 428361000124107 http://snomed.info/sct
    Discharge to healthcare facility for hospice care (procedure) 428371000124100 http://snomed.info/sct
    survey survey http://terminology.hl7.org/CodeSystem/observation-category
    Yes (qualifier value) 373066001 http://snomed.info/sct
    Hospice care [Minimum Data Set] 45755-6 http://loinc.org
    Logic Definitions:
    Group Scoring Population Criteria Expression
    662125a90f0a9077c1d5b5af Group scoring: proportion
    Type:

    Process

    Rate Aggregation: None
    Improvement Notation:

    increase

    Initial Population
    define "Initial Population":
      AgeInYearsAt(date from start of "Measurement Period") >= 13
        and "First SUD Episode During Measurement Period" is not null
        and not exists "History of SUD Diagnosis or Treatment"
    Denominator
    define "Denominator":
      "Initial Population"
    Denominator Exclusion
    define "Denominator Exclusions":
      Hospice."Has Hospice Services"
    Numerator
    define "Numerator 1":
      exists "Treatment Initiation With Non Medication Intervention Dates"
        or exists "Treatment Initiation With Medication Order Dates"
    662125a90f0a9077c1d5b5b0 Group scoring: proportion
    Type:

    Process

    Rate Aggregation: None
    Improvement Notation:

    increase

    Initial Population
    define "Initial Population":
      AgeInYearsAt(date from start of "Measurement Period") >= 13
        and "First SUD Episode During Measurement Period" is not null
        and not exists "History of SUD Diagnosis or Treatment"
    Denominator
    define "Denominator":
      "Initial Population"
    Denominator Exclusion
    define "Denominator Exclusions":
      Hospice."Has Hospice Services"
    Numerator
    define "Numerator 2":
      "Has Treatment Engagement With Long Acting Medication"
        or "Has Two or More Treatment Engagements With Short Acting Medication or Non Medication Intervention"
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Stratification 3
    define "Stratification 3":
      AgeInYearsAt(date from start of "Measurement Period") >= 65
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Stratification 2
    define "Stratification 2":
      AgeInYearsAt(date from start of "Measurement Period") in Interval[18, 64]
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Stratification 1
    define "Stratification 1":
      AgeInYearsAt(date from start of "Measurement Period") in Interval[13, 17]
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Qualifying Encounters
    define "Qualifying Encounters":
      ( [Encounter: "Office Visit"]
          union [Encounter: "Emergency Department Evaluation and Management Visit"]
          union [Encounter: "Detoxification Visit"]
          union [Encounter: "Initial Hospital Inpatient Visit"]
          union [Encounter: "Discharge Services Hospital Inpatient Same Day Discharge"]
          union [Encounter: "Discharge Services Hospital Inpatient"]
          union [Encounter: "Telephone Visits"]
          union [Encounter: "Virtual Encounter"]
      ).isEncounterPerformed ( )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR First SUD Episode During Measurement Period
    define "First SUD Episode During Measurement Period":
      First(("Qualifying Encounters") ValidEncounters
          with [Condition: "Substance Use Disorder"] SUDDiagnosis
            such that ValidEncounters.period.toInterval() during "Measurement Period"
              and SUDDiagnosis.prevalenceInterval() starts during ValidEncounters.period.toInterval()
              and SUDDiagnosis.prevalenceInterval() starts 47 days or more before day of 
              end of "Measurement Period"
          return {
            ValidEncounterDate: date from start of ValidEncounters.period.toInterval(),
            ValidEncounter: ValidEncounters
          }
          sort by ValidEncounterDate
      ).ValidEncounter
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Emergency Department or Detoxification Visit
    define "Emergency Department or Detoxification Visit":
      ( [Encounter: "Emergency Department Evaluation and Management Visit"]
          union [Encounter: "Detoxification Visit"]
      ).isEncounterPerformed ( )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR History of SUD Diagnosis or Treatment
    define "History of SUD Diagnosis or Treatment":
      ( ( ( [Procedure: "Substance Use Disorder Treatment"]
            union [Procedure: "Psych Visit Psychotherapy"]
            union [Procedure: "Substance Use Disorder Long Acting Medication Administration"]
            union [Procedure: "Substance Use Disorder Short Acting Medication Administration"]
        ).isInterventionPerformed ( ) ) Interventions
          with "First SUD Episode During Measurement Period" FirstSUDEpisode
            such that Interventions.performed.toInterval ( ) starts 60 days or less before day of date from start of FirstSUDEpisode.period.toInterval ( )
      )
        union ( ( ( ( "Qualifying Encounters"
              except "Emergency Department or Detoxification Visit" ) QualifyingEncounter
              where exists ( ( QualifyingEncounter.encounterDiagnosis ( ) ) SUDDiagnosis
                  where SUDDiagnosis.code in "Substance Use Disorder"
              )
          ) ) SUDEncounterDx
            with "First SUD Episode During Measurement Period" FirstSUDEpisode
              such that SUDEncounterDx.period.toInterval ( ) starts 60 days or less before day of date from start of FirstSUDEpisode.period.toInterval ( )
        )
        union ( ( ( [MedicationRequest: "Substance Use Disorder Long Acting Medication"]
              union [MedicationRequest: "Substance Use Disorder Short Acting Medication"]
          ).isMedicationOrder ( ) ) SUDMedication
            with "First SUD Episode During Measurement Period" FirstSUDEpisode
              such that SUDMedication.authoredOn.toInterval ( ) 60 days or less before day of date from start of FirstSUDEpisode.period.toInterval ( )
        )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Initial Population
    define "Initial Population":
      AgeInYearsAt(date from start of "Measurement Period") >= 13
        and "First SUD Episode During Measurement Period" is not null
        and not exists "History of SUD Diagnosis or Treatment"
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Denominator
    define "Denominator":
      "Initial Population"
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Psychosocial Visit
    define "Psychosocial Visit":
      ( ( [Procedure: "Substance Use Disorder Treatment"]
            union [Procedure: "Psych Visit Psychotherapy"]
        ).isInterventionPerformed ( )
      )
        union ( ( [Encounter: "Telephone Visits"]
            union [Encounter: "Virtual Encounter"]
        ).isEncounterPerformed ( ) ) TelehealthEncounter
          where exists ( ( TelehealthEncounter.encounterDiagnosis ( ) ) SUDDiagnosis
              where SUDDiagnosis.code in "Substance Use Disorder"
          )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Treatment Initiation With Non Medication Intervention Dates
    define "Treatment Initiation With Non Medication Intervention Dates":
      ( "Psychosocial Visit" PsychosocialVisitProcedure
          let treatmentDate: date from start of PsychosocialVisitProcedure.performed.toInterval ( )
          with "First SUD Episode During Measurement Period" FirstSUDEpisode
            such that treatmentDate during Interval[date from start of FirstSUDEpisode.period.toInterval ( ), date from start of FirstSUDEpisode.period.toInterval ( ) + 14 days )
              and PsychosocialVisitProcedure.id !~ FirstSUDEpisode.id
          return all treatmentDate
      )
        union ( "Psychosocial Visit" PsychosocialVisitEncounter
            let treatmentDate: date from start of PsychosocialVisitEncounter.period.toInterval ( )
            with "First SUD Episode During Measurement Period" FirstSUDEpisode
              such that treatmentDate during Interval[date from start of FirstSUDEpisode.period.toInterval ( ), date from start of FirstSUDEpisode.period.toInterval ( ) + 14 days )
                and PsychosocialVisitEncounter.id !~ FirstSUDEpisode.id
            return all treatmentDate
        )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Treatment Initiation With Medication Order Dates
    define "Treatment Initiation With Medication Order Dates":
      ( ( ( [MedicationRequest: "Substance Use Disorder Short Acting Medication"]
            union [MedicationRequest: "Substance Use Disorder Long Acting Medication"]
        ).isMedicationOrder ( ) ) SUDMedication
          let treatmentDate: date from start of SUDMedication.authoredOn.toInterval ( )
          with "First SUD Episode During Measurement Period" FirstSUDEpisode
            such that treatmentDate during Interval[date from start of FirstSUDEpisode.period.toInterval ( ), date from start of FirstSUDEpisode.period.toInterval ( ) + 14 days )
          return all treatmentDate
      )
        union ( ( ( [Procedure: "Substance Use Disorder Short Acting Medication Administration"]
              union [Procedure: "Substance Use Disorder Long Acting Medication Administration"]
          ).isInterventionPerformed ( ) ) SUDMedAdministration
            let treatmentDate: date from start of SUDMedAdministration.performed.toInterval ( )
            with "First SUD Episode During Measurement Period" FirstSUDEpisode
              such that treatmentDate during Interval[date from start of FirstSUDEpisode.period.toInterval ( ), date from start of FirstSUDEpisode.period.toInterval ( ) + 14 days )
            return all treatmentDate
        )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Numerator 1
    define "Numerator 1":
      exists "Treatment Initiation With Non Medication Intervention Dates"
        or exists "Treatment Initiation With Medication Order Dates"
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Has Treatment Engagement With Long Acting Medication
    define "Has Treatment Engagement With Long Acting Medication":
      exists ( ( ( ( [MedicationRequest: "Substance Use Disorder Long Acting Medication"] ).isMedicationOrder ( ) ) LongActingMedOrder
            with ( Min("Treatment Initiation With Non Medication Intervention Dates"
                union "Treatment Initiation With Medication Order Dates"
            ) ) InitiationTreatmentDate
              such that date from start of LongActingMedOrder.authoredOn.toInterval ( ) 34 days or less after InitiationTreatmentDate
        )
          union ( ( ( [Procedure: "Substance Use Disorder Long Acting Medication Administration"] ).isInterventionPerformed ( ) ) LongActingTreatment
              with ( Min("Treatment Initiation With Non Medication Intervention Dates"
                  union "Treatment Initiation With Medication Order Dates"
              ) ) InitiationTreatmentDate
                such that date from start of LongActingTreatment.performed.toInterval ( ) 34 days or less after InitiationTreatmentDate
          )
      )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Has Two or More Treatment Engagements With Short Acting Medication or Non Medication Intervention
    define "Has Two or More Treatment Engagements With Short Acting Medication or Non Medication Intervention":
      Count((("Psychosocial Visit"
            union(([Procedure: "Substance Use Disorder Short Acting Medication Administration"]).isInterventionPerformed())) ShortActingTreatment
            with(Min("Treatment Initiation With Non Medication Intervention Dates"
                union "Treatment Initiation With Medication Order Dates"
            )) InitiationTreatmentDate
              such that date from start of ShortActingTreatment.performed.toInterval() 34 days or less after InitiationTreatmentDate
                or date from start of ShortActingTreatment.period.toInterval() 34 days or less after InitiationTreatmentDate
            return all ShortActingTreatment
        )
          union((([MedicationRequest: "Substance Use Disorder Short Acting Medication"]).isMedicationOrder()) ShortActingMedOrder
              with(Min("Treatment Initiation With Non Medication Intervention Dates"
                  union "Treatment Initiation With Medication Order Dates"
              )) InitiationTreatmentDate
                such that date from start of ShortActingMedOrder.authoredOn.toInterval() 34 days or less after InitiationTreatmentDate
              return all ShortActingMedOrder
          )
      ) >= 2
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Numerator 2
    define "Numerator 2":
      "Has Treatment Engagement With Long Acting Medication"
        or "Has Two or More Treatment Engagements With Short Acting Medication or Non Medication Intervention"
    Library Name Name
    Hospice Has Hospice Services
    define "Has Hospice Services":
      exists ((([Encounter: "Encounter Inpatient"]).isEncounterPerformed()) InpatientEncounter
          where (InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to home for hospice care (procedure)"
              or InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to healthcare facility for hospice care (procedure)"
          )
            and InpatientEncounter.period.toInterval() ends during day of "Measurement Period"
      )
        or exists ((([Encounter: "Hospice Encounter"]).isEncounterPerformed()) HospiceEncounter
            where HospiceEncounter.period.toInterval() overlaps day of "Measurement Period"
        )
        or exists ((([Observation: "Hospice care [Minimum Data Set]"]).isAssessmentPerformed()) HospiceAssessment
            where HospiceAssessment.value ~ "Yes (qualifier value)"
              and HospiceAssessment.effective.toInterval() overlaps day of "Measurement Period"
        )
        or exists ((([ServiceRequest: "Hospice Care Ambulatory"]).isInterventionOrder()) HospiceOrder
            where HospiceOrder.authoredOn.toInterval() during day of "Measurement Period"
            // and HospiceOrder.doNotPerform is not true
            // https://oncprojectracking.healthit.gov/support/browse/CQLIT-447
        )
        or exists ((([Procedure: "Hospice Care Ambulatory"]).isInterventionPerformed()) HospicePerformed
            where HospicePerformed.performed.toInterval() overlaps day of "Measurement Period"
        )
        or exists (([Condition: "Hospice Diagnosis"]) HospiceCareDiagnosis
            where HospiceCareDiagnosis.prevalenceInterval() overlaps day of "Measurement Period"
        )
    Library Name Name
    InitiationandEngagementofSubstanceUseDisorderTreatmentFHIR Denominator Exclusions
    define "Denominator Exclusions":
      Hospice."Has Hospice Services"
    Library Name Name
    Status isEncounterPerformed
    //Encounter, Performed
    //General usage unless required otherwise by measure intent (e.g., follow-up encounters)
    define fluent function isEncounterPerformed(Enc List<Encounter>):
      Enc E
        where E.status in {'finished', 'arrived', 'triaged', 'in-progress', 'onleave'}
    Library Name Name
    QICoreCommon toInterval
    /*
    @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
    Library Name Name
    QICoreCommon prevalenceInterval
    /*
    @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 Condition):
    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]
    Library Name Name
    Status isInterventionPerformed
    //Intervention, Performed
    define fluent function isInterventionPerformed(Proc List<Procedure>):
      Proc P
        where P.status ~ 'completed'
    Library Name Name
    CQMCommon encounterDiagnosis
    /*
    @description: Returns the Condition resources referenced by the diagnosis element of the Encounter
    */
    define fluent function encounterDiagnosis(Encounter Encounter ):
      Encounter.diagnosis D
        return singleton from ([Condition] C where C.id = D.condition.reference.getId())
    Library Name Name
    QICoreCommon getId
    /*
    @description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
    @comment: This function can be used to determine the logical id of a given resource. It can be used in
    a single-server environment to trace references. However, this function does not attempt to resolve
    or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
    */
    define fluent function getId(uri String):
      Last(Split(uri, '/'))
    Library Name Name
    Status isMedicationOrder
    //Medication, Order: active and completed only
    define fluent function isMedicationOrder(MedicationRequest List<MedicationRequest>):
      MedicationRequest M
        where M.status in { 'active', 'completed' }
          and M.intent = 'order'
    Library Name Name
    Status isAssessmentPerformed
    //This library contains functions that are based on QDM 5.6 to QICore 4.1.1 March 2023 (https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns---QICore-v4.1.1). The functions may appear similar to some QICoreCommon functions but different in that they have constraints that are relevant for measures authored by NCQA.
    
    //Assessment, Performed
    define fluent function isAssessmentPerformed(Obs List<Observation>):
      Obs O
        where O.status in { 'final', 'amended', 'corrected' }
              and exists ( O.category ObservationCategory
              where ( ObservationCategory ) ~ "survey"
          )
    Library Name Name
    FHIRHelpers ToConcept
    /*
    @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
            }
    Library Name Name
    Status isInterventionOrder
    //Intervention, Order: active and completed only    
    define fluent function isInterventionOrder(ServiceRequest List<ServiceRequest>):
      ServiceRequest S
        where S.status in { 'active', 'completed' }
          and S.intent = 'order'