Draft dQM CMS Content Implementation Guide
2025.1.0 - CI Build

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

## Measure: Preventive Care and Screening: Screening for Depression and Follow-Up PlanFHIR

Official URL: https://madie.cms.gov/Measure/CMS2FHIRPCSDepScreenAndFollowUp | Version: 1.1.000
Active as of 2026-01-16 | Responsible: Centers for Medicare & Medicaid Services (CMS) | Computable Name: CMS2FHIRPCSDepScreenAndFollowUp
Other Identifiers: Short Name: CMS2FHIR (use: usual, ), UUID:deb30835-dbec-4f11-aab0-3a282040e37c (use: official, ), UUID:fd005986-96a6-404d-896f-14257cf9611b (use: official, ), Publisher: 2FHIR (use: official, )
Copyright/Legal: This electronic clinical quality measure (Measure) and related data specifications are owned and stewarded by the Centers for Medicare \& Medicaid Services (CMS). CMS contracted (Contract # 75FCMC18D0027/ Task Order #: 75FCMC24F0144) with the American Institutes for Research (AIR) to develop this electronic measure. AIR is not responsible for any use of the Measure. AIR makes no representations, warranties, or endorsement about the quality of any organization or physician that uses or reports performance measures and AIR has no liability to anyone who relies on such measures or specifications. 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. AIR 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) is copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organization. ICD-10 is copyright 2024 World Health Organization. All Rights Reserved.

Percentage of patients aged 12 years and older screened for depression on the date of the encounter or up to 14 days prior to the date of the encounter using an age-appropriate standardized depression screening tool AND if positive, a follow-up plan is documented on the date of or up to two days after the date of the qualifying encounter

Metadata
Title | Preventive Care and Screening: Screening for Depression and Follow-Up PlanFHIR
Version | 1.1.000
Short Name | CMS2FHIR
GUID (Version Independent) | urn:uuid:deb30835-dbec-4f11-aab0-3a282040e37c
GUID (Version Specific) | urn:uuid:fd005986-96a6-404d-896f-14257cf9611b
CMS Identifier | 2FHIR
Effective Period | 2026-01-01 through 2026-12-31
Steward (Publisher) | Centers for Medicare &amp; Medicaid Services (CMS)
Developer | American Institutes for Research (AIR)
Description | Percentage of patients aged 12 years and older screened for depression on the date of the encounter or up to 14 days prior to the date of the encounter using an age-appropriate standardized depression screening tool AND if positive, a follow-up plan is documented on the date of or up to two days after the date of the qualifying encounter
Copyright | This electronic clinical quality measure (Measure) and related data specifications are owned and stewarded by the Centers for Medicare & Medicaid Services (CMS). CMS contracted (Contract # 75FCMC18D0027/ Task Order #: 75FCMC24F0144) with the American Institutes for Research (AIR) to develop this electronic measure. AIR is not responsible for any use of the Measure. AIR makes no representations, warranties, or endorsement about the quality of any organization or physician that uses or reports performance measures and AIR has no liability to anyone who relies on such measures or specifications. 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. AIR 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) is copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organization. ICD-10 is copyright 2024 World Health Organization. All Rights Reserved.
Disclaimer | These performance measures are not clinical guidelines and do not establish a standard of medical care, and have not been tested for all potential applications. THE MEASURES AND SPECIFICATIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].
Rationale | Depression affects more than two hundred sixty million people across the world and is a leading cause of disability, with a variety of depressive disorders that are independent risk factors for chronic diseases, such as cardiovascular disease and diabetes, lending screening for depression as paramount to identify depressive disorders that can affect the most vulnerable populations (Costantini et al., 2021). Results from a 2018 U.S. survey indicated that 14.4 percent of adolescents (3.5 million adolescents) had a major depressive episode (MDE) in the past year, with nine percent of adolescents (2.4 million adolescents) having one MDE with severe impairment (Substance Abuse and Mental Health Services Administration, 2019). The odds of a diagnosis of depression are believed to be 2.6 times greater for children and adolescents exposed to trauma as compared to those unexposed or less exposed (Vibhakar et al., 2019). Children and teens with major depressive disorder (MDD) have been found to have difficulty carrying out their daily activities, relating to others, growing up healthy, and are at an increased risk of suicide (Siu on behalf of the U.S. Preventive Services Task Force [USPSTF], 2016). The same 2018 study indicated that 7.2 percent of adults aged 18 or older (17.7 million adults) had at least one MDE with 4.7 percent of adults (11.5 million adults) having one MDE with severe impairment in the past year (Substance Abuse and Mental Health Services Administration, 2019). Moreover, it is estimated 22.9 percent of adult patients with chronic pain (2.2 million adults) were diagnosed with comorbid depression from 2011 to 2015, with an upward trend of prevalence among Black Americans, patients aged 65 to 84 years old, Medicare and Medicaid insured patients, and patients from zip code areas with low annual household incomes (Orhurhu et al., 2019). Depression and other mood disorders, such as bipolar disorder and anxiety disorders, especially during the perinatal period, can have devastating effects on women, infants, and families (American College of Obstetricians and Gynecologists, 2018). It's estimated that the global prevalence of antenatal (or perinatal) depression ranges from 15 to 65 percent, with current or previous exposure to abuse and violence, lack of social support, and family history of mental disorders being risk factors. Depressive symptoms measured during pregnancy have been shown to influence the quality of the postpartum mother-infant relationship (Hazell Raine et al., 2020). Additionally, the risk of low birth weight and preterm birth is higher among infants born from depressed mothers (Dadi, Miller, Bisetegn, & Mwanri, 2020). Negative outcomes associated with depression make it crucial to screen in order to identify and treat depression in its early stages. Multiple social costs of depression have been identified, such as reduced educational achievements, poor financial success and role performance, higher amount of days out of role, and increased risk of job loss (Costantini et al., 2021). Depression also imposes significant economic burden through direct and indirect costs, supporting the need for regular depression screening. "In the United States, an estimated $22.8 billion was spent on depression treatment in 2009, and lost productivity cost an additional estimated $23 billion in 2011" (Siu & USPSTF, 2016, p. 383-384). Numerous studies have found significant disparities in depression prevalence and treatment among racial/ethnic minorities. One study revealed that Indigenous adults are at a high risk for posttraumatic stress disorder, depression, suicide, substance use disorder, and concurrent behavioral health disorders secondary to these initial health problems (Ka'apu and Burnette, 2019). Additionally, though rates of depression are lower among Blacks and Hispanics than among whites, depression among Blacks and Hispanics is likely to be more recurrent. Furthermore, 48 percent of whites receive mental health services, compared to just 31 percent of Blacks and Hispanics, and 22 percent of Asians (American Psychiatric Association, 2017). Asian Americans and Black Americans are also significantly more likely to utilize emergency rooms for depression treatment, which contributes to inconsistent follow-up care (Lee et al., 2014). While primary care providers (PCPs) serve as the first line of defense in the detection of depression, studies show that PCPs fail to recognize up to 46 percent of depressed patients (Borner et al., 2010). "In nationally representative U.S. surveys, about eight percent of adolescents reported having major depression in the past year. Only 36 percent to 44 percent of children and adolescents with depression receive treatment, suggesting that a majority of depressed youth are undiagnosed and untreated" (Siu on behalf of USPSTF, 2016). Furthermore, evidence supports that screening for depression in pregnant and postpartum women is of moderate net benefit, and treatment options for positive depression screening should be available for patients twelve and older including pregnant and postpartum women. This measure seeks to align with USPSTF clinical guideline recommendations as well as the Healthy People 2030 recommendation to increase the proportion of adolescents and adults who are screened for depression and if positive, receive appropriate treatment (U.S. Preventive Services Task Force, 2016; U.S. Department of Health and Human Services, 2020). For patients with depression, rescreening has been shown to be an effective tool for measuring response to therapy, therefore influencing appropriate care adjustments in the treatment of depression (Anderson et al., 2002). Chen et al. noted that when patients were re-administered a screening tool after at least eight weeks after starting treatment, their "score gave primary care physicians a clear idea about the nature of patients' depressive symptoms and gave both the patient and the physician an indication of treatment progress" (Chen et al., 2006).
Clinical Recommendation Statement | Adolescent Recommendation (12-18 years): "The USPSTF recommends screening for MDD in adolescents aged 12 to 18 years. Screening should be implemented with adequate systems in place to ensure accurate diagnosis, effective treatment, and appropriate follow-up (B recommendation)" (Siu on behalf of USPSTF, 2016). Adult Recommendation (18 years and older): "The USPSTF recommends screening for depression in the general adult population, including pregnant and postpartum women. Screening should be implemented with adequate systems in place to ensure accurate diagnosis, effective treatment, and appropriate follow-up (B recommendation)" (Siu & USPSTF, 2016). "The USPSTF recommends that clinicians provide or refer pregnant and postpartum persons who are at increased risk of perinatal depression to counseling interventions (B recommendation)" (U.S. Preventive Services Task Force, 2019). The American College of Obstetricians and Gynecologists (ACOG) provides the following recommendation: "All obstetrician--gynecologists and other obstetric care providers should complete a full assessment of mood and emotional well-being (including screening for postpartum depression and anxiety with a validated instrument) during the comprehensive postpartum visit for each patient" (American College of Obstetricians and Gynecologists, 2018). The Institute for Clinical Systems Improvement (ICSI) health care guideline, Adult Depression in Primary Care, provides the following recommendations: "Clinicians should routinely screen all adults for depression using a standardized instrument." "Clinicians should establish and maintain follow-up with patients." "Clinicians should screen and monitor depression in pregnant and post-partum women" (Trangle et al., 2016).
Citation | American College of Obstetricians and Gynecologists, Committee on Obstetric Practice. (2018). ACOG Committee Opinion Number 757: Screening for perinatal depression. Obstetrics and Gynecology, 132(5), e208-e212. doi: 10.1097/AOG.0000000000002927
Citation | American Psychiatric Association. (2017). Mental Health Disparities: Diverse Populations. Retrieved from https://www.psychiatry.org/psychiatrists/cultural-competency/education/mental-health-facts
Citation | Anderson, J., Michalak, E., & Lam, R. (2002). Depression in primary care: Tools for screening, diagnosis, and measuring response to treatment. BCMJ, 44(8),415-419. https://bcmj.org/articles/depression-primary-care-tools-screening-diagnosis-and-measuring-response-treatment
Citation | Borner, I., Braunstein, J. W., St. Victor, R., & Pollack, J. (2010). Evaluation of a 2-question screening tool for detecting depression in adolescents in primary care. Clinical Pediatrics, 49(10), 947-995. doi:10.1177/0009922810370203
Citation | Chen, T., Huang, F., Chang, C., & Chung, H. (2006), Using the PHQ-9 for depression screening and treatment monitoring for Chinese Americans in primary care. Psychiatr Serv., 57(7),976--981. https://ps.psychiatryonline.org/doi/full/10.1176/ps.2006.57.7.976
Citation | Costantini, L., Costanza, A., Odone, A., Aguglia, A., Escelsior, A., Serafini, G., Amore, M., & Amerio, A. (2021). A breakthrough in research on depression screening: from validation to efficacy studies. Acta bio-medica : Atenei Parmensis, 92(3), e2021215. https://doi.org/10.23750/abm.v92i3.11574
Citation | Dadi, A. F., Miller, E. R., Bisetegn, T. A., & Mwanri, L. (2020). Global burden of antenatal depression and its association with adverse birth outcomes: an umbrella review. BMC public health, 20(1), 173. https://doi.org/10.1186/s12889-020-8293-9
Citation | Hazell Raine, K., Nath, S., Howard, L. M., Cockshaw, W., Boyce, P., Sawyer, E., & Thorpe, K. (2020). Associations between prenatal maternal mental health indices and mother-infant relationship quality 6 to 18 months' postpartum: A systematic review. Infant mental health journal, 41(1), 24--39. https://doi.org/10.1002/imhj.21825
Citation | Ka'apu, K., & Burnette, C. E. (2019). A Culturally Informed Systematic Review of Mental Health Disparities Among Adult Indigenous Men and Women of the USA: What is known?. British journal of social work, 49(4), 880--898. https://doi.org/10.1093/bjsw/bcz009
Citation | Lee, S. Y., Xue, Q. L., Spira, A. P., & Lee, H. B. (2014). Racial and ethnic differences in depressive subtypes and access to mental health care in the United States. Journal of affective disorders, 155, 130--137. https://doi.org/10.1016/j.jad.2013.10.037
Citation | Orhurhu, V., Olusunmade, M., Akinola, Y., Urits, I., Orhurhu, M. S., Viswanath, O., ... Gill, J. S. (2019). Depression Trends in Patients with Chronic Pain: An Analysis of the Nationwide Inpatient Sample. Pain physician, 22(5), E487--E494.
Citation | Siu, A. L., & USPSTF. (2016). Screening for depression in adults: U.S. Preventive Services Task Force recommendation statement. Journal of the American Medical Association, 315(4), 380-387. doi:10.1001/jama.2015.18392.
Citation | Siu, A. L., on behalf of USPSTF. (2016). Screening for depression in children and adolescents: U.S. Preventive Services Task Force recommendation statement. Annals of Internal Medicine, 164(5), 360-366. doi:10.7326/M15-2957
Citation | Substance Abuse and Mental Health Services Administration. (2019). Key substance use and mental health indicators in the United States: Results from the 2018 National Survey on Drug Use and Health (HHS Publication No. PEP19 5068, NSDUH Series H 54). Rockville, MD: Center for Behavioral Health Statistics and Quality, Substance Abuse and Mental Health Services Administration. Retrieved from https://www.samhsa.gov/data/sites/default/files/cbhsq-reports/NSDUHNationalFindingsReport2018/NSDUHNationalFindingsReport2018.htm#mde
Citation | Trangle, M., Gursky, J., Haight, R., Hardwig, J., Hinnenkamp, T., Kessler, D.,... Myszkowski, M. (2016). Adult depression in primary care. Bloomington, MN: Institute for Clinical Systems Improvement. Retrieved from https://www.icsi.org/guideline/depression/
Citation | U.S. Department of Health and Human Services. (2020). Healthy People 2030: Depression in adults: Screening. Washington, DC: U.S. Department of Health and Human Services. Retrieved from https://health.gov/healthypeople/tools-action/browse-evidence-based-resources/depression-adults-screening
Citation | U.S. Preventive Services Task Force. (2016). Final recommendation statement: depression in adults: screening. Retrieved from https://www.uspreventiveservicestaskforce.org/uspstf/recommendation/depression-in-adults-screening
Citation | U.S. Preventive Services Task Force. (2019). Interventions to Prevent Perinatal Depression: US Preventive Services Task Force Recommendation Statement. JAMA, 321(6):580--587. doi:10.1001/jama.2019.0007
Citation | Vibhakar, V., Allen, L. R., Gee, B., & Meiser-Stedman, R. (2019). A systematic review and meta-analysis on the prevalence of depression in children and adolescents after exposure to trauma. Journal of affective disorders, 255, 77--89. https://doi.org/10.1016/j.jad.2019.05.005
Definition | Follow-Up Plan: Documented follow-up for a positive depression screening must include one or more of the following: * Referral to a provider for additional evaluation and assessment to formulate a follow-up plan for a positive depression screen * Pharmacological interventions (prescribed or active depression medication) * Other interventions or follow-up for the diagnosis or treatment of depression
Definition | Screening: Completion of a clinical or diagnostic tool used to identify people at risk of developing or having a certain disease or condition, even in the absence of symptoms.
Definition | Standardized Depression Screening Tool: A normalized and validated depression screening tool developed for the patient population in which it is being utilized. Examples of standardized depression screening tools include but are not limited to: * Adolescent Screening Tools (12-17 years) * Patient Health Questionnaire for Adolescents (PHQ-A) * Beck Depression Inventory-Primary Care Version (BDI-PC) * Mood Feeling Questionnaire (MFQ) * Center for Epidemiologic Studies Depression Scale (CES-D) * Patient Health Questionnaire (PHQ-9) * Pediatric Symptom Checklist (PSC-17) * Primary Care Evaluation of Mental Disorders Patient Health Questionnaire (PRIME-MD PHQ-2) * Adult Screening Tools (18 years and older) * Patient Health Questionnaire (PHQ-9) * Beck Depression Inventory (BDI or BDI-II) * Center for Epidemiologic Studies Depression Scale (CES-D) * Depression Scale (DEPS) * Duke Anxiety-Depression Scale (DADS) * Geriatric Depression Scale (GDS) * Cornell Scale for Depression in Dementia (CSDD) * PRIME MD-PHQ-2 * Hamilton Rating Scale for Depression (HAM-D) * Quick Inventory of Depressive Symptomatology Self-Report (QID-SR) * Computerized Adaptive Testing Depression Inventory (CAT-DI) * Computerized Adaptive Diagnostic Screener (CAD-MDD) * Perinatal Screening Tools * Edinburgh Postnatal Depression Scale * Postpartum Depression Screening Scale * Patient Health Questionnaire 9 (PHQ-9) * Beck Depression Inventory * Beck Depression Inventory-II * Center for Epidemiologic Studies Depression Scale * Zung Self-rating Depression Scale
Guidance (Usage) | The intent of the measure is to screen all patients for depression except those with previous diagnosis of bipolar disorder. Patients who have ever been diagnosed with bipolar disorder prior to the qualifying encounter will be excluded from the measure regardless of whether the diagnosis is active or not. A depression screen is completed on the date of the encounter or up to 14 calendar days prior to the date of the encounter using an age-appropriate standardized depression screening tool AND if positive, a follow-up plan must be documented on the date of or up to two calendar days after the date of the encounter, such as referral to a provider for additional evaluation, pharmacological interventions, or other interventions for the treatment of depression. An example to illustrate the follow-up plan documentation timing: if the encounter is on a Monday from 3-4 pm (day 0) and the patient screens positive, the clinician has through anytime on Wednesday (day 2) to complete follow-up plan documentation. This measure does not require documentation of a specific score, just whether results of the normalized and validated depression screening tool used are considered positive or negative. Each standardized screening tool provides guidance on whether a particular score is considered positive for depression. The measure is not prescriptive in the specific screening tool being used and provides no hierarchy for acceptance of one tool over another. In the case where two screenings are documented on the same date/time with different results (one positive and one negative), the measure only assesses the most recent screening. Since both screenings are both considered the most recent, the patient will be captured in the numerator if the positive screening result also includes documentation of an intervention following the positive screen. This eCQM is a patient-based measure. Depression screening is required once per measurement period, not at all encounters. Screening Tools: * An age-appropriate, standardized, and validated depression screening tool must be used for numerator compliance. * The name of the age-appropriate standardized depression screening tool utilized must be documented in the medical record. * The depression screening must be reviewed and addressed by the provider, filing the code, on the date of the encounter. Positive pre-screening results indicating a patient is at high risk for self-harm should receive more urgent intervention as determined by the provider practice. * The screening should occur during a qualifying encounter or up to 14 calendar days prior to the date of the qualifying encounter. * The measure assesses the most recent depression screening completed either during the qualifying encounter or within the 14 calendar days prior to that encounter. Therefore, a clinician would not be able to complete another screening at the time of the encounter to count towards a follow-up, because that would serve as the most recent screening. In order to satisfy the follow-up requirement for a patient screening positively, the eligible clinician would need to provide one of the aforementioned follow-up actions, which does not include use of a standardized depression screening tool. Follow-Up Plan: While there are many validated depression screening tools, they are not necessarily diagnostic tools. Patients with elevated depression screening scores should be followed by a clinician to evaluate whether a depression diagnosis is appropriate, but a medication and/or referral are not always indicated for a positive score. In these cases, a follow up plan is appropriate. The follow-up plan MUST still be provided for and discussed with the patient during the qualifying encounter used to evaluate the numerator. However, documentation of the follow-up plan can occur up to two calendar days after the qualifying encounter, in accordance with the policies of an eligible clinician or provider's practice or health system. All services should be documented during, or as soon as practicable, after the qualifying encounter in order to maintain an accurate medical record. Examples of a follow-up plan include but are not limited to: * Referral to a provider or program for further evaluation for depression, for example, referral to a psychiatrist, psychiatric nurse practitioner, psychologist, clinical social worker, mental health counselor, or other mental health service such as family or group therapy, support group, depression management program, or other service for treatment of depression * Other interventions designed to treat depression such as behavioral health evaluation, psychotherapy, pharmacological interventions, or additional treatment options. * Exercise regimens, education counseling, coping support, and completion of a mental health crisis plan. Should a patient screen positive for depression, a clinician should: * Only order pharmacological intervention when appropriate and after sufficient diagnostic evaluation. However, for the purposes of this measure, additional screening and assessment during the qualifying encounter will not qualify as a follow-up plan. * Opt to complete a suicide risk assessment when appropriate and based on individual patient characteristics. However, for the purposes of this measure, a suicide risk assessment or an additional screening using a standardized tool will not qualify as a follow-up plan. This FHIR-based measure has been derived from the QDM-based measure: CMS2v15. 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.0.0 (https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html).
Measure Group (Rate) (ID: Group_1)
Summary | Percentage of patients aged 12 years and older screened for depression on the date of the encounter or up to 14 days prior to the date of the encounter using an age-appropriate standardized depression screening tool AND if positive, a follow-up plan is documented on the date of or up to two days after the date of the qualifying encounter
Basis | boolean
Scoring | Proportion
Improvement Notation | Increased score indicates improvement
Type | Process
Initial Population | ID: InitialPopulation_1 Description: All patients aged 12 years and older at the beginning of the measurement period with at least one qualifying encounter during the measurement period Criteria: Initial Population
Denominator | ID: Denominator_1 Description: Equals Initial Population Criteria: Denominator
Denominator Exclusion | ID: DenominatorExclusion_1 Description: Patients who have ever been diagnosed with bipolar disorder at any time prior to the qualifying encounter Criteria: Denominator Exclusions
Denominator Exception | ID: DenominatorException_1 Description: Patient Reason(s) - Patient refuses to participate in or complete the depression screening OR Medical Reason(s) - Documentation of medical reason for not screening patient for depression (e.g., cognitive, functional, or motivational limitations that may impact accuracy of results; patient is in an urgent or emergent situation where time is of the essence and to delay treatment would jeopardize the patient's health status) Criteria: Denominator Exceptions
Numerator | ID: Numerator_1 Description: Patients screened for depression on the date of the encounter or up to 14 days prior to the date of the encounter using an age-appropriate standardized tool AND if positive, a follow-up plan is documented on the date of or up to two days after the date of the qualifying encounter or an active depression medication overlaps the date of the qualifying encounter Criteria: Numerator
Supplemental Data Guidance Guidance | <p>For every patient evaluated by this measure also identify payer, race, ethnicity, and sex</p>
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 | CMS2FHIRPCSDepScreenAndFollowUp
Contents | Population Criteria Logic Definitions Terminology Dependencies Data Requirements Parameters
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
    define "Initial Population":
      "Patient Age 12 Years or Older at Start of Measurement Period"
        and exists ( "Qualifying Encounter During Measurement Period" )
Definition
Denominator
    define "Denominator":
      "Initial Population"
Definition
Denominator Exclusion
    define "Denominator Exclusions":
      exists "History of Bipolar Diagnosis Before Qualifying Encounter"
Definition
Denominator Exception
    define "Denominator Exceptions":
      false
Definition
Numerator
    define "Numerator":
      ( "Patient Age 12 to 16 Years at Start of Measurement Period"
          and ( "Has Most Recent Adolescent Screening Negative"
              or exists "Most Recent Adolescent Depression Screening Positive and Follow Up Provided"
          )
      )
        or ( "Patient Age 17 Years at Start of Measurement Period"
            and ( "Has Most Recent Adolescent Screening Negative"
                or exists "Most Recent Adolescent Depression Screening Positive and Follow Up Provided"
                or "Has Most Recent Adult Screening Negative"
                or exists "Most Recent Adult Depression Screening Positive and Follow Up Provided"
            )
        )
        or ( "Patient Age 18 Years or Older at Start of Measurement Period"
            and ( "Has Most Recent Adult Screening Negative"
                or exists "Most Recent Adult Depression Screening Positive and Follow Up Provided"
            )
        )
Definition
Logic Definitions
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Sex":
      case
        when Patient.sex() = '248153007' then "Male (finding)"
        when Patient.sex() = '248152002' then "Female (finding)"
        else null
      end
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Payer":
      [USQualityCore.Coverage: type in "Payer Type"] Payer
        return {
          code: Payer.type,
          period: Payer.period
        }
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Ethnicity":
      (Patient.ethnicity()) E
        return Tuple {
          codes: { E.ombCategory } union E.detailed,
          display: E.text
        }
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Race":
      (Patient.race()) R
        return Tuple {
          codes: R.ombCategory union R.detailed,
          display: R.text
        }
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "SDE Sex":
      SDE."SDE Sex"
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Patient Age 12 to 16 Years at Start of Measurement Period":
      AgeInYearsAt(date from start of "Measurement Period") in Interval[12, 16]
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Qualifying Encounter During Measurement Period":
      ( [USQualityCore.Encounter: "Encounter to Screen for Depression"]
        union [USQualityCore.Encounter: "Physical Therapy Evaluation"]
        union [USQualityCore.Encounter: "Telephone Visits"] ) QualifyingEncounter
        where QualifyingEncounter.period during day of "Measurement Period"
          and QualifyingEncounter.status = 'finished'
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    /*
    TODO: Needs to be reassessed given the pattern change for ObservationCancelled, this should really be a ServiceRequest with a TaskRejected, yes?
    define "Medical or Patient Reason for Not Screening Adolescent for Depression":
      [USQualityCore.ObservationCancelled: code ~ "Adolescent depression screening assessment"] NoAdolescentScreen
        with "Qualifying Encounter During Measurement Period" QualifyingEncounter
          such that NoAdolescentScreen.issued during day of QualifyingEncounter.period
        where ( NoAdolescentScreen.notDoneReason ~ "Depression screening declined (situation)"
            or NoAdolescentScreen.notDoneReason in "Medical Reason"
        )

    define "Medical or Patient Reason for Not Screening Adult for Depression":
      [USQualityCore.ObservationCancelled: code ~ "Adult depression screening assessment"] NoAdultScreen
        with "Qualifying Encounter During Measurement Period" QualifyingEncounter
          such that NoAdultScreen.issued during day of QualifyingEncounter.period
        where ( NoAdultScreen.notDoneReason ~ "Depression screening declined (situation)"
            or NoAdultScreen.notDoneReason in "Medical Reason"
        )
    */

    define "Most Recent Adolescent Depression Screening":
      Last([USQualityCore.ObservationScreeningAssessment: "Adolescent depression screening assessment"] AdolescentDepressionScreening
          with "Qualifying Encounter During Measurement Period" QualifyingEncounter
            such that AdolescentDepressionScreening.effective.toInterval() 14 days or less on or before day of start of QualifyingEncounter.period
              and AdolescentDepressionScreening.value is not null
              and AdolescentDepressionScreening.status in { 'final', 'amended', 'corrected' }
          sort by start of effective.toInterval()
      )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Has Most Recent Adolescent Screening Negative":
      ( "Most Recent Adolescent Depression Screening" AdolescentScreen
          where AdolescentScreen.value ~ "Depression screening negative (finding)"
      ) is not null
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    /*
    TODO: Need to reassess how we are representing given no ObservationCancelled profile
      ( exists "Medical or Patient Reason for Not Screening Adolescent for Depression"
          and not "Has Adolescent Depression Screening"
      )
        or ( exists "Medical or Patient Reason for Not Screening Adult for Depression"
            and not "Has Adult Depression Screening"
        )
    */

    define "Follow Up Intervention for Positive Adolescent Depression Screening":
      ( ( [USQualityCore.MedicationRequest: "Adolescent Depression Medications"] AdolescentMed
            with "Qualifying Encounter During Measurement Period" QualifyingEncounter
              such that "Most Recent Adolescent Depression Screening".effective.toInterval ( ) starts 14 days or less on or before day of start of QualifyingEncounter.period
                and AdolescentMed.medicationRequestPeriod ( ) overlaps after day of QualifyingEncounter.period
                and "Most Recent Adolescent Depression Screening".value ~ "Depression screening positive (finding)"
                and AdolescentMed.status in { 'active', 'completed' }
                and AdolescentMed.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
        )
          union ( [USQualityCore.ServiceRequest: "Referral for Adolescent Depression"] AdolescentReferral
              where AdolescentReferral.status in { 'active', 'completed' }
          )
          union ( [USQualityCore.Procedure: "Follow Up for Adolescent Depression"] AdolescentFollowUp
              where AdolescentFollowUp.status = 'completed'
          )
      )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Most Recent Adolescent Depression Screening Positive and Follow Up Provided":
      from
        "Most Recent Adolescent Depression Screening" LastAdolescentScreen,
        "Follow Up Intervention for Positive Adolescent Depression Screening" FollowUpPositiveAdolescentScreen,
        "Qualifying Encounter During Measurement Period" QualifyingEncounter
        where LastAdolescentScreen.effective.toInterval ( ) starts 14 days or less on or before day of start of QualifyingEncounter.period
          and LastAdolescentScreen.value ~ "Depression screening positive (finding)"
          and ( start of FollowUpPositiveAdolescentScreen.performed.toInterval ( ) during QualifyingEncounter.period
              or FollowUpPositiveAdolescentScreen.authoredOn 2 days or less on or after day of end of QualifyingEncounter.period
          )
          and ( Coalesce(start of FollowUpPositiveAdolescentScreen.performed.toInterval(), FollowUpPositiveAdolescentScreen.authoredOn) during day of "Measurement Period" )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Patient Age 17 Years at Start of Measurement Period":
      AgeInYearsAt(date from start of "Measurement Period") = 17
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Most Recent Adult Depression Screening":
      Last([USQualityCore.ObservationScreeningAssessment: "Adult depression screening assessment"] AdultDepressionScreening
          with "Qualifying Encounter During Measurement Period" QualifyingEncounter
            such that AdultDepressionScreening.effective.toInterval() 14 days or less on or before day of start of QualifyingEncounter.period
              and AdultDepressionScreening.value is not null
              and AdultDepressionScreening.status in { 'final', 'amended', 'corrected' }
          sort by start of effective.toInterval()
      )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Has Most Recent Adult Screening Negative":
      ( "Most Recent Adult Depression Screening" AdultScreen
          where AdultScreen.value ~ "Depression screening negative (finding)"
      ) is not null
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Follow Up Intervention for Positive Adult Depression Screening":
      ( ( [USQualityCore.MedicationRequest: "Adult Depression Medications"] AdultMed
            with "Qualifying Encounter During Measurement Period" QualifyingEncounter
              such that "Most Recent Adult Depression Screening".effective.toInterval ( ) starts 14 days or less on or before day of start of QualifyingEncounter.period
                and AdultMed.medicationRequestPeriod ( ) overlaps after day of QualifyingEncounter.period
                and "Most Recent Adult Depression Screening".value ~ "Depression screening positive (finding)"
                and AdultMed.status in { 'active', 'completed' }
                and AdultMed.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
        )
          union ( [USQualityCore.ServiceRequest: "Referral for Adult Depression"] AdultReferral
              where AdultReferral.status in { 'active', 'completed' }
          )
          union ( [USQualityCore.Procedure: "Follow Up for Adult Depression"] AdultFollowUp
              where AdultFollowUp.status = 'completed'
          )
      )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Most Recent Adult Depression Screening Positive and Follow Up Provided":
      from
        "Most Recent Adult Depression Screening" LastAdultScreen,
        "Follow Up Intervention for Positive Adult Depression Screening" FollowUpPositiveAdultScreen,
        "Qualifying Encounter During Measurement Period" QualifyingEncounter
        where LastAdultScreen.effective.toInterval ( ) starts 14 days or less on or before day of start of QualifyingEncounter.period
          and LastAdultScreen.value ~ "Depression screening positive (finding)"
          and ( start of FollowUpPositiveAdultScreen.performed.toInterval ( ) during QualifyingEncounter.period
              or FollowUpPositiveAdultScreen.authoredOn 2 days or less on or after day of end of QualifyingEncounter.period
          )
          and ( Coalesce(start of FollowUpPositiveAdultScreen.performed.toInterval(), FollowUpPositiveAdultScreen.authoredOn) during day of "Measurement Period" )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Patient Age 18 Years or Older at Start of Measurement Period":
      AgeInYearsAt(date from start of "Measurement Period") >= 18
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Numerator":
      ( "Patient Age 12 to 16 Years at Start of Measurement Period"
          and ( "Has Most Recent Adolescent Screening Negative"
              or exists "Most Recent Adolescent Depression Screening Positive and Follow Up Provided"
          )
      )
        or ( "Patient Age 17 Years at Start of Measurement Period"
            and ( "Has Most Recent Adolescent Screening Negative"
                or exists "Most Recent Adolescent Depression Screening Positive and Follow Up Provided"
                or "Has Most Recent Adult Screening Negative"
                or exists "Most Recent Adult Depression Screening Positive and Follow Up Provided"
            )
        )
        or ( "Patient Age 18 Years or Older at Start of Measurement Period"
            and ( "Has Most Recent Adult Screening Negative"
                or exists "Most Recent Adult Depression Screening Positive and Follow Up Provided"
            )
        )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Patient Age 12 Years or Older at Start of Measurement Period":
      AgeInYearsAt(date from start of "Measurement Period") >= 12
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Initial Population":
      "Patient Age 12 Years or Older at Start of Measurement Period"
        and exists ( "Qualifying Encounter During Measurement Period" )
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Denominator":
      "Initial Population"
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "SDE Payer":
      SDE."SDE Payer"
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "History of Bipolar Diagnosis Before Qualifying Encounter":
      [USQualityCore.ConditionProblemsHealthConcerns: "Bipolar Disorder"] BipolarDiagnosis
        with "Qualifying Encounter During Measurement Period" QualifyingEncounter
          such that BipolarDiagnosis.prevalenceInterval ( ) starts before day of start of QualifyingEncounter.period
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Denominator Exclusions":
      exists "History of Bipolar Diagnosis Before Qualifying Encounter"
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "SDE Race":
      SDE."SDE Race"
Logic Definition | Library Name: CMS2FHIRPCSDepScreenAndFollowUp
    define "Denominator Exceptions":
      false
Logic Definition | Library Name: CumulativeMedicationDuration
    /*
    Calculates the Medication Period for a single MedicationRequest.
    MedicationRequest instances provided to this function are expected
    to conform to the [MMEMedicationRequest](http://build.fhir.org/ig/cqframework/opioid-mme-r4/StructureDefinition-mmemedicationrequest.html)
    profile, which expects:
    * 1 and only 1 dosageInstruction, multiple dosageInstruction elements will result in an error
    * 1 and only 1 doseAndRate, multiple doseAndRate elements will result in an error
    * 1 timing with 1 repeat, missing timing or repeat elements will result in a null
    * frequency, frequencyMax, defaulting to 1
    * period, periodUnit, defaulting to 1 'd'
    * timeOfDay
    * doseQuantity or doseRange, missing doseQuantity and doseRange will result in a null
    Note that MedicationRequest status is not considered by this calculation, as the
    list of MedicationRequest instances provided to this function should already have
    considered appropriate statuses, depending on the use case, typically `completed`.

    NOTE: Updated return to use "date from end of boundsPeriod" to ensure result is Interval<Date>
    */
    define fluent function medicationRequestPeriod(Request MedicationRequest):
      Request R
        let
          dosage: singleton from R.dosageInstruction,
          doseAndRate: singleton from dosage.doseAndRate,
          timing: dosage.timing,
          frequency: Coalesce(timing.repeat.frequencyMax, timing.repeat.frequency),
          period: Quantity(timing.repeat.period, timing.repeat.periodUnit),
          doseRange: doseAndRate.dose as FHIR.Range,
          doseQuantity: doseAndRate.dose as FHIR.SimpleQuantity,

          dose: Coalesce(end of doseRange, doseQuantity),
          dosesPerDay: Coalesce(ToDaily(frequency, period), Count(timing.repeat.timeOfDay), 1.0),
          boundsPeriod: timing.repeat.bounds as Period,
          // TODO: this isn't working as expected, convert results in null
          //daysSupply: (convert(R.dispenseRequest.expectedSupplyDuration) to days).value,
          daysSupply: (R.dispenseRequest.expectedSupplyDuration).value,
          quantity: R.dispenseRequest.quantity,
          refills: Coalesce(R.dispenseRequest.numberOfRepeatsAllowed, 0),
          startDate:
            Coalesce(
              date from start of boundsPeriod,
              date from R.authoredOn,
              date from start of R.dispenseRequest.validityPeriod
            ),
          totalDaysSupplied: Coalesce(daysSupply, quantity.value / (dose.value * dosesPerDay)) * (1 + refills)
        return
          if startDate is not null and totalDaysSupplied is not null then
            Interval[startDate, startDate + Quantity(totalDaysSupplied - 1, 'day') ]
          else if startDate is not null and boundsPeriod."end" is not null then
            Interval[startDate, date from end of boundsPeriod]
          else
            null
Logic Definition | Library Name: CumulativeMedicationDuration
    /**********************************************************************/
    /* Functions in this region are copied from opioid-mme-r4             */
    /**********************************************************************/

    define function Quantity(value Decimal, unit String):
      if value is not null then
        System.Quantity { value: value, unit: unit }
      else
        null
Logic Definition | Library Name: CumulativeMedicationDuration
    /*
     Goal is to get to number of days
     Two broad approaches to the calculation:
      1) Based on supply and frequency, calculate the number of expected days the medication will cover/has covered
      2) Based on relevant period, determine a covered interval and calculate the length of that interval in days

    This topic covers several use cases and illustrates how to calculate Cumulative
    Medication Duration for each type of medication resource using the supply and
    frequency approach.
    */

    /*
      For the first approach, we need to get from frequency to a frequency/day
      So we define ToDaily
    */

    /*
      Calculates daily frequency given frequency within a period
    */
    define function ToDaily(frequency System.Integer, period System.Quantity):
      case period.unit
        when 'h' then frequency * (24.0 / period.value)
        when 'min' then frequency * (24.0 / period.value) * 60
        when 's' then frequency * (24.0 / period.value) * 60 * 60
        when 'd' then frequency * (24.0 / period.value) / 24
        when 'wk' then frequency * (24.0 / period.value) / (24 * 7)
        when 'mo' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
        when 'a' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
        when 'hour' then frequency * (24.0 / period.value)
        when 'minute' then frequency * (24.0 / period.value) * 60
        when 'second' then frequency * (24.0 / period.value) * 60 * 60
        when 'day' then frequency * (24.0 / period.value) / 24
        when 'week' then frequency * (24.0 / period.value) / (24 * 7)
        when 'month' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
        when 'year' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
        when 'hours' then frequency * (24.0 / period.value)
        when 'minutes' then frequency * (24.0 / period.value) * 60
        when 'seconds' then frequency * (24.0 / period.value) * 60 * 60
        when 'days' then frequency * (24.0 / period.value) / 24
        when 'weeks' then frequency * (24.0 / period.value) / (24 * 7)
        when 'months' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
        when 'years' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
        else Message(null, true, 'CMDLogic.ToDaily.UnknownUnit', ErrorLevel, 'Unknown unit ' & period.unit)
      end
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value string): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value uri): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToDate(value date): value.value
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
    value to a CQL DateTime Interval
    @comment: If the start value of the given period is unspecified, the starting
    boundary of the resulting interval will be open (meaning the start of the interval
    is unknown, as opposed to interpreted as the beginning of time).
    */
    define function ToInterval(period FHIR.Period):
        if period is null then
            null
        else
            if period."start" is null then
                Interval(period."start".value, period."end".value]
            else
                Interval[period."start".value, period."end".value]
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value EncounterStatus): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToDateTime(value dateTime): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToDateTime(value instant): value.value
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity)
    value to a CQL Quantity
    @comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity
    has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`)
    an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used.
    @seealso: ToCalendarUnit
    */
    define function ToQuantity(quantity FHIR.Quantity):
        case
            when quantity is null then null
            when quantity.value is null then null
            when quantity.comparator is not null then
                Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')
            when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
                  or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
                System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
            else
                Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')
        end
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts a UCUM definite duration unit to a CQL calendar duration
    unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities)
    topic of the CQL specification.
    @comment: Note that for durations above days (or weeks), the conversion is understood to be approximate
    */
    define function ToCalendarUnit(unit System.String):
        case unit
            when 'ms' then 'millisecond'
            when 's' then 'second'
            when 'min' then 'minute'
            when 'h' then 'hour'
            when 'd' then 'day'
            when 'wk' then 'week'
            when 'mo' then 'month'
            when 'a' then 'year'
            else unit
        end
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value ObservationStatus): value.value
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
    */
    define function ToConcept(concept FHIR.CodeableConcept):
        if concept is null then
            null
        else
            System.Concept {
                codes: concept.coding C return ToCode(C),
                display: concept.text.value
            }
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
    */
    define function ToCode(coding FHIR.Coding):
        if coding is null then
            null
        else
            System.Code {
              code: coding.code.value,
              system: coding.system.value,
              version: coding.version.value,
              display: coding.display.value
            }
Logic Definition | Library Name: FHIRHelpers
    define function ToDecimal(value decimal): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value UnitsOfTime): value.value
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts the given FHIR [Range](https://hl7.org/fhir/datatypes.html#Range) value to a CQL Interval of Quantity
    */
    define function ToInterval(range FHIR.Range):
        if range is null then
            null
        else
            Interval[ToQuantity(range.low), ToQuantity(range.high)]
Logic Definition | Library Name: FHIRHelpers
    define function ToInteger(value integer): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value MedicationRequestStatus): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value MedicationRequestIntent): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value ServiceRequestStatus): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value ProcedureStatus): value.value
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns the single extension (if present) on the given resource with the specified url.
    @comment: This function uses singleton from to ensure that a run-time exception is thrown if there
    is more than one extension on the given resource with the specified url.
    */
    define fluent function ext(domainResource DomainResource, url String):
      singleton from domainResource.exts(url)
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns any extensions defined on the given resource with the specified url
    */
    define fluent function exts(domainResource DomainResource, url String):
      domainResource.extension E
        where E.url = url
        return E
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
    @comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range types
    to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
    representations for timing-valued elements in FHIR, allowing this function to be used across any resource.

    The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.
    The intent of this function is to provide a clear and concise mechanism to treat single
    elements that have multiple possible representations as intervals so that logic doesn't have to account
    for the variability. More complex calculations (such as medication request period or dispense period
    calculation) need specific guidance and consideration. That guidance may make use of this function, but
    the focus of this function is on single element calculations where the semantics are unambiguous.
    If the input is a dateTime, the result a DateTime Interval beginning and ending on that dateTime.
    If the input is a Period, the result is a DateTime Interval.
    If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.
    If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.
    If the input is a string, an error is raised indicating a single interval cannot be computed from a string.
    If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,
    and ending immediately prior to when the patient was the given Age plus one year.
    If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given
    by the low end of the Range, and ending immediately prior to when the patient was the Age given by the
    high end of the Range plus one year.

    NOTE: Due to the
    complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used
    with a Timing or String.
    */
    define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):
      case
        when choice is FHIR.dateTime then
          Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
        when choice is FHIR.Period then
          FHIRHelpers.ToInterval(choice as FHIR.Period)
        when choice is FHIR.instant then
          Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
        when choice is FHIR.Age then
          Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
            FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
        when choice is FHIR.Range then
          Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
            FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
        when choice is FHIR.Timing then
          Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported')
        when choice is FHIR.string then
          Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
        else
          null as Interval<DateTime>
      end
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns the single extension (if present) on the given element with the specified url.
    @comment: This function uses singleton from to ensure that a run-time exception is thrown if there
    is more than one extension on the given element with the specified url.
    */
    define fluent function ext(element Element, url String):
      singleton from element.exts(url)
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns any extensions defined on the given element with the specified url.
    */
    define fluent function exts(element Element, url String):
      element.extension E
        where E.url = url
        return E
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns an interval representing the normalized prevalence period of a given Condition resource.
    @comment: Uses the toInterval and toAbatementInterval functions to determine the widest potential interval from
    onset to abatement as specified in the given Condition.
    */
    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]
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns an interval representing the normalized Abatement of a given Condition resource.
    @comment: @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.

    NOTE: Due to the complexity of determining an interval from a String, this function will throw
    a run-time exception if used with a Condition instance that has a String as the abatement value.
    */
    define fluent function abatementInterval(condition Condition):
      if condition.abatement is FHIR.dateTime then
        Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)]
      else if condition.abatement is FHIR.Period then
        FHIRHelpers.ToInterval(condition.abatement as FHIR.Period)
      else if condition.abatement is FHIR.string then
        Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
      else if condition.abatement is FHIR.Age then
        Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age),
          FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year)
      else if condition.abatement is FHIR.Range then
        Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low),
          FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year)
      else if condition.abatement is FHIR.boolean then
        Interval[end of condition.onset.toInterval(), condition.recordedDate)
      else
        null
Logic Definition | Library Name: USCoreCommon
    /*
    @description: Returns the sex element as defined for the USCore patient profile
    */
    define fluent function sex(patient Patient):
      patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-sex').value as FHIR.code
Logic Definition | Library Name: USCoreCommon
    define fluent function ethnicity(patient Patient):
      (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity')) E
        return {
          ombCategory: E.ext('ombCategory').value as FHIR.Coding,
          detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
          text: E.ext('text').value as FHIR.string
        }
Logic Definition | Library Name: USCoreCommon
    define fluent function race(patient Patient):
      (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-race')) E
        return {
          ombCategory: (E.exts('ombCategory')) o return o.value as FHIR.Coding,
          detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
          text: E.ext('text').value as FHIR.string
        }
Terminology
Code System | Description: Code system SNOMEDCT Resource: SNOMED CT (all versions) Canonical URL: `http://snomed.info/sct`
Code System | Description: Code system LOINC Resource: Logical Observation Identifiers, Names and Codes (LOINC) Canonical URL: `http://loinc.org`
Code System | Description: Code system ConditionClinicalStatusCodes Resource: Condition Clinical Status Codes Canonical URL: `http://terminology.hl7.org/CodeSystem/condition-clinical`
Value Set | Description: Value set Encounter to Screen for Depression Resource: Encounter to Screen for Depression Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1916`
Value Set | Description: Value set Physical Therapy Evaluation Resource: Physical Therapy Evaluation Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1022`
Value Set | Description: Value set Telephone Visits Resource: Telephone Visits Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1080`
Value Set | Description: Value set Adolescent Depression Medications Resource: Adolescent Depression Medications Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1567`
Value Set | Description: Value set Referral for Adolescent Depression Resource: Referral for Adolescent Depression Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1570`
Value Set | Description: Value set Follow Up for Adolescent Depression Resource: Follow Up for Adolescent Depression Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1569`
Value Set | Description: Value set Adult Depression Medications Resource: Adult Depression Medications Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1566`
Value Set | Description: Value set Referral for Adult Depression Resource: Referral for Adult Depression Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1571`
Value Set | Description: Value set Follow Up for Adult Depression Resource: Follow Up for Adult Depression Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1568`
Value Set | Description: Value set Payer Type Resource: Payer Type Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591`
Value Set | Description: Value set Bipolar Disorder Resource: Bipolar Disorder Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.67.1.101.1.128`
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: Adolescent depression screening assessment Code: 73831-0 System: `http://loinc.org`
Direct Reference Code | Display: Depression screening negative (finding) Code: 428171000124102 System: `http://snomed.info/sct`
Direct Reference Code | Display: Depression screening positive (finding) Code: 428181000124104 System: `http://snomed.info/sct`
Direct Reference Code | Display: Adult depression screening assessment Code: 73832-8 System: `http://loinc.org`
Direct Reference Code | Code: active System: `http://terminology.hl7.org/CodeSystem/condition-clinical`
Direct Reference Code | Code: recurrence System: `http://terminology.hl7.org/CodeSystem/condition-clinical`
Direct Reference Code | Code: relapse System: `http://terminology.hl7.org/CodeSystem/condition-clinical`
Dependencies
Dependency | Description: USQualityCore model information Resource: `https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild` Canonical URL: `https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild`
Dependency | Description: USCore model information Resource: http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived Canonical URL: `http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived`
Dependency | Description: FHIR model information Resource: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1 Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1`
Dependency | Description: Library SDE Resource: SupplementalDataElementsversion: null6.1.000) Canonical URL: `https://madie.cms.gov/Library/SupplementalDataElements|6.1.000`
Dependency | Description: Library FHIRHelpers Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1 Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1`
Dependency | Description: Library USCommon Resource: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot Canonical URL: `http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot`
Dependency | Description: Library FHIRCommon Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0 Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0`
Dependency | Description: Library CMD Resource: http://hl7.org/fhir/us/cql/Library/CumulativeMedicationDuration|2.0.0-ballot Canonical URL: `http://hl7.org/fhir/us/cql/Library/CumulativeMedicationDuration|2.0.0-ballot`
Data Requirements
Data Requirement | Type: Patient Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-patient` Must Support Elements: ombCategory, detailed, text
Data Requirement | Type: Encounter Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-encounter` Must Support Elements: type, period, status Code Filter(s): Path: type ValueSet: Encounter to Screen for Depression
Data Requirement | Type: Encounter Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-encounter` Must Support Elements: type, period, status Code Filter(s): Path: type ValueSet: Physical Therapy Evaluation
Data Requirement | Type: Encounter Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-encounter` Must Support Elements: type, period, status Code Filter(s): Path: type ValueSet: Telephone Visits
Data Requirement | Type: Patient Profile(s): Patient Must Support Elements: birthDate
Data Requirement | Type: Observation Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-screening-assessment` Must Support Elements: code, effective, value, status Code Filter(s): Path: code Code(s): LOINC: 73831-0 (Adolescent depression screening assessment)
Data Requirement | Type: Observation Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-screening-assessment` Must Support Elements: code, effective, value, status Code Filter(s): Path: code Code(s): LOINC: 73832-8 (Adult depression screening assessment)
Data Requirement | Type: Observation Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-screening-assessment` Must Support Elements: effective, value
Data Requirement | Type: Medication Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-medication` Must Support Elements: id, code Code Filter(s): Path: code ValueSet: Adolescent Depression Medications
Data Requirement | Type: Medication Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-medication` Must Support Elements: id, code Code Filter(s): Path: code ValueSet: Adult Depression Medications
Data Requirement | Type: MedicationRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-medicationrequest` Must Support Elements: medication, status, intent Code Filter(s): Path: medication ValueSet: Adolescent Depression Medications
Data Requirement | Type: MedicationRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-medicationrequest` Must Support Elements: medication.reference, status, intent
Data Requirement | Type: MedicationRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-medicationrequest` Must Support Elements: medication, status, intent Code Filter(s): Path: medication ValueSet: Adult Depression Medications
Data Requirement | Type: ServiceRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-servicerequest` Must Support Elements: code, status Code Filter(s): Path: code ValueSet: Referral for Adolescent Depression
Data Requirement | Type: ServiceRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-servicerequest` Must Support Elements: code, status Code Filter(s): Path: code ValueSet: Referral for Adult Depression
Data Requirement | Type: Procedure Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-procedure` Must Support Elements: code, status Code Filter(s): Path: code ValueSet: Follow Up for Adolescent Depression Path: status Code(s): [not stated]: completed (completed)
Data Requirement | Type: Procedure Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-procedure` Must Support Elements: code, status Code Filter(s): Path: code ValueSet: Follow Up for Adult Depression Path: status Code(s): [not stated]: completed (completed)
Data Requirement | Type: Coverage Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-coverage` Must Support Elements: type, period Code Filter(s): Path: type ValueSet: Payer Type
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: abatement, onset, recordedDate, clinicalStatus
Data Requirement | Type: Condition Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-problems-health-concerns` Must Support Elements: code Code Filter(s): Path: code ValueSet: Bipolar Disorder
Parameters
Name | Use | Card. | Type | Documentation
Measurement Period | In | 0..1 | Period |
ErrorLevel | In | 0..1 | string |
SDE Sex | Out | 0..1 | Coding |
Numerator | Out | 0..1 | boolean |
Denominator | Out | 0..1 | boolean |
SDE Payer | Out | 0..* | Resource |
Initial Population | Out | 0..1 | boolean |
SDE Ethnicity | Out | 0..1 | Resource |
Denominator Exclusions | Out | 0..1 | boolean |
SDE Race | Out | 0..1 | Resource |
Denominator Exceptions | Out | 0..1 | boolean |
Generated using version 0.5.4 of the sample-content-ig Liquid templates