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: Follow-Up Care for Children Prescribed ADHD MedicationFHIR

Official URL: https://madie.cms.gov/Measure/CMS136FHIRChildADHDMedFollowUp Version: 1.0.000
Active as of 2026-01-16 Responsible: National Committee for Quality Assurance Computable Name: CMS136FHIRChildADHDMedFollowUp
Other Identifiers: Short Name: CMS136FHIR (use: usual, ), UUID:fd12596b-b29b-4584-b592-defc57f1acd6 (use: official, ), UUID:d40b39ef-3d68-4293-be29-a0db65d66eab (use: official, ), Publisher: 136FHIR (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 endorsements about the quality of any product, test or protocol identified as numerator compliant or otherwise identified as meeting the requirements of the measure or specification. 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 may be used for internal, noncommercial purposes (e.g., use by healthcare providers in connection with their practices) without obtaining approval from NCQA. All other uses, including a commercial use (including but not limited to vendors using or embedding the measures and specifications into any product or service to calculate measure results for customers for any purpose), must be approved by NCQA and are subject to a license at the discretion of NCQA. (C) 2012-2025 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 2025. 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) (https://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-2025 Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee, and are available at no cost under the license at https://loinc.org/kb/license/. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 copyright 2025 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 children 6-12 years of age and newly prescribed a medication for attention-deficit/hyperactivity disorder (ADHD) who had appropriate follow-up care. Two rates are reported. a. Percentage of children who had one follow-up visit with a practitioner with prescribing authority during the 30-Day Initiation Phase. b. Percentage of children who remained on ADHD medication for at least 210 treatment days and who, in addition to the visit in the Initiation Phase, had at least two additional follow-up visits with a practitioner within 270 days (9 months) after the Initiation Phase ended.

Metadata
Title Follow-Up Care for Children Prescribed ADHD MedicationFHIR
Version 1.0.000
Short Name CMS136FHIR
GUID (Version Independent) urn:uuid:fd12596b-b29b-4584-b592-defc57f1acd6
GUID (Version Specific) urn:uuid:d40b39ef-3d68-4293-be29-a0db65d66eab
CMS Identifier 136FHIR
Effective Period 2026-01-01 through 2026-12-31
Steward (Publisher) National Committee for Quality Assurance
Developer National Committee for Quality Assurance
Description

Percentage of children 6-12 years of age and newly prescribed a medication for attention-deficit/hyperactivity disorder (ADHD) who had appropriate follow-up care. Two rates are reported. a. Percentage of children who had one follow-up visit with a practitioner with prescribing authority during the 30-Day Initiation Phase. b. Percentage of children who remained on ADHD medication for at least 210 treatment days and who, in addition to the visit in the Initiation Phase, had at least two additional follow-up visits with a practitioner within 270 days (9 months) after the Initiation Phase ended.

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 endorsements about the quality of any product, test or protocol identified as numerator compliant or otherwise identified as meeting the requirements of the measure or specification. 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 may be used for internal, noncommercial purposes (e.g., use by healthcare providers in connection with their practices) without obtaining approval from NCQA. All other uses, including a commercial use (including but not limited to vendors using or embedding the measures and specifications into any product or service to calculate measure results for customers for any purpose), must be approved by NCQA and are subject to a license at the discretion of NCQA. (C) 2012-2025 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 2025. 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) (https://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-2025 Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee, and are available at no cost under the license at https://loinc.org/kb/license/. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 copyright 2025 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

ADHD is one of the more common chronic conditions of childhood. Children with ADHD may experience significant functional problems, such as school difficulties; academic underachievement; troublesome relationships with family members and peers; and behavioral problems (AAP, 2019). Given the high prevalence of ADHD among U.S. children (8.7%, or 5.3 million individuals), primary care clinicians will regularly encounter children with ADHD and should have a strategy for diagnosing and long-term management of this condition (AAP, 2019; Bozinovic et al. 2021). Medication may be recommended for ADHD treatment. American Academy of Pediatrics (AAP) guidelines recommend that the prescribing clinician should titrate ADHD medication to achieve maximum benefit with tolerable side effects, and once symptom improvement is achieved, provide chronic care management with at least two visits annually (AAP, 2019). Providers have an opportunity to track medication use in patients and provide the appropriate follow-up care to monitor clinical symptoms and potential adverse events.

Clinical Recommendation Statement

American Academy of Pediatrics Clinical Practice Guideline for the Diagnosis, Evaluation and Treatment of ADHD in Children and Adolescents (2019) - Key Action Statement (KAS) 1: The pediatrician or other primary care clinicians (PCC) should initiate an evaluation for ADHD for any child or adolescent age 4 years to the 18th birthday who presents with academic or behavioral problems and symptoms of inattention, hyperactivity, or impulsivity. Grade B: Strong Recommendation - KAS 4: ADHD is a chronic condition; therefore, the PCC should manage children and adolescents with ADHD in the same manner that they would children and youth with special health care needs, following the principles of the chronic care model and the medical home. Grade B: Strong Recommendation - KAS 5b: For elementary and middle school-aged children (age 6 years to the 12th birthday) with ADHD, the PCC should prescribe FDA-approved medications for ADHD, along with parent training in behavior management (PTBM) and/or behavioral classroom intervention (preferably both PTBM and behavioral classroom interventions). Educational interventions and individualized instructional supports, including school environment, class placement, instructional placement, and behavioral supports, are a necessary part of any treatment plan and often include an Individualized Education Program (IEP) or a rehabilitation plan (504 plan). Grade A: Strong Recommendation - KAS 6. “The PCC should titrate doses of medication for ADHD to achieve maximum benefit with tolerable side effects”. Grade B, strong recommendation American Academy of Child and Adolescent Psychiatry (AACAP) Practice Parameter for the Assessment and Treatment of Children and Adolescents with ADHD (2007) - Overall Guideline: The key to effective long-term management of the patient with ADHD is continuity of care with a clinician experienced in the treatment of ADHD. The frequency and duration of follow-up sessions should be individualized for each family and patient, depending on the severity of ADHD symptoms; the degree of comorbidity of other psychiatric illness; the response to treatment; and the degree of impairment in home, school, work, or peer-related activities. The clinician should establish an effective mechanism for receiving feedback from the family and other important informants in the patient's environment to be sure symptoms are well controlled and side effects are minimal. Although this parameter does not seek to set a formula for the method of follow-up, significant contact with the clinician should typically occur two to four times per year in cases of uncomplicated ADHD and up to weekly sessions at times of severe dysfunction or complications of treatment. - Recommendation 6: A Well-Thought-Out and Comprehensive Treatment Plan Should Be Developed for the Patient With ADHD. The treatment plan should be reviewed regularly and modified if the patient's symptoms do not respond. Minimal Standard [MS] - Recommendation 9. During a Psychopharmacological Intervention for ADHD, the Patient Should Be Monitored for Treatment-Emergent Side Effects. Minimal Standard [MS] - Recommendation 12. Patients Should Be Assessed Periodically to Determine Whether There Is Continued Need for Treatment or If Symptoms Have Remitted. Treatment of ADHD Should Continue as Long as Symptoms Remain Present and Cause Impairment. Minimal Standard [MS]

Citation

Bozinovic, K., F. McLamb, K. O’Connell et al. November 10, 2021. “U.S. National, Regional, and State-Specific Socioeconomic Factors Correlate with Child and Adolescent ADHD Diagnoses Pre-COVID-19 Pandemic.” Sci Rep 11(1):2. Doi: 10.1038/s41598-021-01233-2.

Citation

Pliszka, S., & AACAP Work Group on Quality Issues. (2007). Practice parameter for the assessment and treatment of children and adolescents with attention-deficit/hyperactivity disorder. Journal of the American Academy of Child and Adolescent Psychiatry (AACAP), 46(7), 894-921.

Citation

Woolrich, M.L., J.F. Hagan, Jr., C. Allan, E. Chan, D. Davison, M. Earls, S.W. Evans, S.K. Flinn, T. Froehlich, J. Frost, J.R. Holbrook, C.U. Lehmann, H.R. Lessin, K. Okechukwu, K.L. Pierce, J.D. Winner, W. Zurhellen. October 2019. “Subcommittee on Children and Adolescents With Attention-Deficit/Hyperactive Disorder. Clinical Practice Guideline for the Diagnosis, Evaluation, and Treatment of Attention-Deficit/Hyperactivity Disorder in Children and Adolescents.” Pediatrics 144(4):e20192528. Doi: 10.1542/peds.2019-2528. Erratum in: Pediatrics. 2020 Mar;145(3): PMID: 31570648; PMCID: PMC7067282.

Justification Description: American Academy of Pediatrics. (2000). Clinical practice guideline: diagnosis and evaluation of the child with attention-deficit/hyperactivity disorder. Pediatrics, 105(5), 1158-1170.
Justification Description: American Academy of Pediatrics. (2001). Clinical practice guideline: treatment of the school-aged child with attention-deficit/hyperactivity disorder. Pediatrics, 108(4), 1033–44.
Definition Continuation and Maintenance Phase: The 300 days following the IPSD.
Definition Index Prescription Start Date (IPSD): The earliest prescription date for an ADHD medication where the date is in the Intake Period and the patient is not actively on ADHD medication during the 120 days prior.
Definition Initiation Phase: The 30 days following the IPSD.
Definition Intake Period: The twelve-month period starting March 1 of the year prior to the measurement period and ending the last calendar day of February of the measurement period.
Definition Treatment days (covered days): The actual number of calendar days covered with prescriptions during the 301-day period. Use the following steps to identify and calculate covered days. Step 1: For same medications that are prescribed on the same day or on different days with overlapping days supply, the days supply is summed. The start and end dates are then identified. The start date is the date of service of the earliest prescription event and the first covered day. The end date is the calendar day when the days supply runs out. The start date through the end date are considered covered days. This rule assumes that the patient will take one prescription at a time (and start taking the next prescription after exhausting the previous prescription). For example: - If there are three 7-days supply prescription events for the same medication on January 1, the start date is January 1 and the end date is January 21. Covered days include January 1–21. - If there are two 7-days supply prescription events for the same medication on January 1 and January 5, the start date is January 1 and the end date is January 14. Covered days include January 1–14. - If there are three 7-days supply prescription events for the same medication on January 1, a 7-days supply prescription event on January 20 and a 7-days supply prescription event on January 28, the start date is January 1 and the end date is February 4. Covered days include January 1–February 4. Step 2: For all other events (multiple prescriptions for the same medication on different days without overlap, multiple prescriptions for different medications on the same or different days, with or without overlap), the covered days are identified by the start and end dates for each prescription event individually. The start date through the end date are considered covered days. This rule assumes the member will take the different medications concurrently. Step 3: Each calendar day covered by one or more medications is considered one covered day.
Guidance (Usage) This eCQM is a patient-based measure. This FHIR-based measure has been derived from the QDM-based measure: CMS136v15. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU6/) for more information on QI-Core and mapping recommendations from QDM to QI-Core STU 6. (https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html).
Measure Group (Rate) (ID: Group_1)
Basis boolean
Scoring Proportion
Improvement Notation Increased score indicates improvement
Type Process
Rate Aggregation None
Initial Population ID: InitialPopulation_1
Description:

Children 6-12 years of age as of the Intake Period who had an IPSD and who had a visit within 6 months prior to the IPSD including the IPSD. Children are removed if they had an acute inpatient stay with a principal diagnosis of mental, behavioral or neurodevelopmental disorder during the Initiation Phase.

Criteria: Initial Population 1
Denominator ID: Denominator_1
Description:

Equals Initial Population

Criteria: Denominator 1
Denominator Exclusion ID: DenominatorExclusion_1
Description:

Exclude patients who are in hospice care for any part of the measurement period. Exclude patients diagnosed with narcolepsy at any point in their history or during the measurement period.

Criteria: Denominator Exclusions
Numerator ID: Numerator_1
Description:

Patients who had at least one visit with a practitioner with prescribing authority during the Initiation Phase.

Criteria: Numerator 1
Measure Group (Rate) (ID: Group_2)
Basis boolean
Scoring Proportion
Improvement Notation Increased score indicates improvement
Type Process
Rate Aggregation None
Initial Population ID: InitialPopulation_2
Description:

Children 6-12 years of age as of the Intake Period who had an IPSD and remained on the medication for at least 210 treatment days during the 301-day period, beginning on the IPSD through 300 days after the IPSD, and who had a visit within 6 months prior to the IPSD including the IPSD. Children are removed if they had an acute inpatient stay with a principal diagnosis of mental, behavioral or neurodevelopmental disorder during the Continuation and Maintenance Phase.

Criteria: Initial Population 2
Denominator ID: Denominator_2
Description:

Equals Initial Population

Criteria: Denominator 2
Denominator Exclusion ID: DenominatorExclusion_2
Description:

Exclude patients who are in hospice care for any part of the measurement period. Exclude patients diagnosed with narcolepsy at any point in their history or during the measurement period.

Criteria: Denominator Exclusions
Numerator ID: Numerator_2
Description:

Patients who had at least one visit with a practitioner with prescribing authority during the Initiation Phase, and at least two follow-up visits on different dates of service during the 31-300 days after the IPSD.

Criteria: Numerator 2
For every patient evaluated by this measure also identify payer, race, ethnicity and sex
Supplemental Data Elements
Supplemental Data Element ID: sde-ethnicity
Usage Code: Supplemental Data
Description: SDE Ethnicity
Logic Definition: SDE Ethnicity
Supplemental Data Element ID: sde-payer
Usage Code: Supplemental Data
Description: SDE Payer
Logic Definition: SDE Payer
Supplemental Data Element ID: sde-race
Usage Code: Supplemental Data
Description: SDE Race
Logic Definition: SDE Race
Supplemental Data Element ID: sde-sex
Usage Code: Supplemental Data
Description: SDE Sex
Logic Definition: SDE Sex
Measure Logic
Primary Library https://madie.cms.gov/Library/CMS136FHIRChildADHDMedFollowUp
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Parameters
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
define "Initial Population 1":
  AgeInYearsAt(date from start of "Intake Period") >= 6
    and AgeInYearsAt(date from 
      end of "Intake Period"
    ) <= 12
    and exists "Qualifying Encounter"
    and "First ADHD Medication Prescribed During Intake Period" is not null
    and not exists "Inpatient Stay with Qualifying Diagnosis During Initiation Phase"
Definition
Denominator
define "Denominator 1":
  "Initial Population 1"
Definition
Denominator Exclusion
define "Denominator Exclusions":
  Hospice."Has Hospice Services"
    or exists "Narcolepsy Exclusion"
Definition
Numerator
define "Numerator 1":
  exists "Encounter During Initiation Phase"
Definition
Measure Group (Rate) (ID: Group_2)
Initial Population
define "Initial Population 2":
  AgeInYearsAt(date from start of "Intake Period") >= 6
    and AgeInYearsAt(date from 
      end of "Intake Period"
    ) <= 12
    and exists "Qualifying Encounter"
    and "First ADHD Medication Prescribed During Intake Period" is not null
    and "Has ADHD Cumulative Medication Duration Greater Than or Equal to 210 Days"
    and not exists "Inpatient Stay with Qualifying Diagnosis During Continuation and Maintenance Phase"
Definition
Denominator
define "Denominator 2":
  "Initial Population 2"
Definition
Denominator Exclusion
define "Denominator Exclusions":
  Hospice."Has Hospice Services"
    or exists "Narcolepsy Exclusion"
Definition
Numerator
define "Numerator 2":
  exists "Encounter During Initiation Phase"
    and ( "Two or More Encounters 31 to 300 Days into Continuation and Maintenance Phase"
        or ( exists "Encounter 31 to 300 Days into Continuation and Maintenance Phase" Encounter1
            with "Virtual Encounter 31 to 300 Days into Continuation and Maintenance Phase" Encounter2
              such that Encounter1 is not null
                and Encounter2 is not null
                and Encounter1 !~ Encounter2
        )
    )
Definition
Logic Definitions
Logic Definition Library Name: Hospice
define "Has Hospice Services":
  exists ((([USQualityCore.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 ends during day of "Measurement Period"
  )
    or exists ((([USQualityCore.Encounter: "Hospice Encounter"]).isEncounterPerformed()) HospiceEncounter
        where HospiceEncounter.period overlaps day of "Measurement Period"
    )
    // TODO: Shouldn't need to specify a code path here (see https://jira.hl7.org/browse/FHIR-53941)
    or exists ((([USQualityCore.ObservationScreeningAssessment: code ~ "Hospice care [Minimum Data Set]"]).isAssessmentPerformed()) HospiceAssessment
        where HospiceAssessment.value ~ "Yes (qualifier value)"
          and HospiceAssessment.effective.toInterval() overlaps day of "Measurement Period"
    )
    or exists ((([USQualityCore.ServiceRequest: "Hospice Care Ambulatory"]).isInterventionOrder()) HospiceOrder
        where HospiceOrder.authoredOn during day of "Measurement Period"
    )
    or exists ((([USQualityCore.Procedure: "Hospice Care Ambulatory"]).isInterventionPerformed()) HospicePerformed
        where HospicePerformed.performed.toInterval() overlaps day of "Measurement Period"
    )
    // TODO: Consider whether to keep this as the union of Problems and EncounterDiagnosis
    or exists ((([FHIR.Condition: "Hospice Diagnosis"]).verified()) HospiceCareDiagnosis
        where HospiceCareDiagnosis.prevalenceInterval() overlaps day of "Measurement Period"
    )
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: CMS136FHIRChildADHDMedFollowUp
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "March 1 of Year Prior to Measurement Period":
  DateTime((year from start of "Measurement Period" - 1), 3, 1, 0, 0, 0, 0, 0)
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Last Calendar Day of February of Measurement Period":
  ( DateTime(year from start of "Measurement Period", 3, 1, 23, 59, 59, 0, 0) ) - 1 day
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Intake Period":
  Interval["March 1 of Year Prior to Measurement Period", "Last Calendar Day of February of Measurement Period"]
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "ADHD Medication Prescribed During Intake Period and Not Previously on ADHD Medication":
  ( ( ( ( [MedicationRequest: "Atomoxetine"]
      union [MedicationRequest: "Clonidine"]
      union [MedicationRequest: "Dexmethylphenidate"]
      union [MedicationRequest: "Dextroamphetamine"]
      union [MedicationRequest: "Lisdexamfetamine"]
      union [MedicationRequest: "methamphetamine hydrochloride 5 MG Oral Tablet"]
      union [MedicationRequest: "Methylphenidate"]
      union [MedicationRequest: "Guanfacine Medications"]
      union [MedicationRequest: "Viloxazine"]
  ).isMedicationOrder ( ) ) ADHDMedications
    where ADHDMedications.medicationRequestPeriod ( ) starts during "Intake Period" ) ADHDMedicationOrder
    without ( ( [MedicationRequest: "Atomoxetine"]
        union [MedicationRequest: "Clonidine"]
        union [MedicationRequest: "Dexmethylphenidate"]
        union [MedicationRequest: "Dextroamphetamine"]
        union [MedicationRequest: "Lisdexamfetamine"]
        union [MedicationRequest: "methamphetamine hydrochloride 5 MG Oral Tablet"]
        union [MedicationRequest: "Methylphenidate"]
        union [MedicationRequest: "Guanfacine Medications"]
        union [MedicationRequest: "Viloxazine"]
    ).isMedicationActive ( ) ) ActiveADHDMedication
      such that ActiveADHDMedication.medicationRequestPeriod ( ) overlaps Interval[date from start of ADHDMedicationOrder.medicationRequestPeriod ( ) - 120 days, date from start of ADHDMedicationOrder.medicationRequestPeriod ( ) ) ) QualifyingMed
    return all {
      startDate: start of QualifyingMed.medicationRequestPeriod ( )
    }
    sort by startDate asc
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "First ADHD Medication Prescribed During Intake Period":
  First("ADHD Medication Prescribed During Intake Period and Not Previously on ADHD Medication".startDate)
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
/*Index Prescription Start Date (IPSD)*/


define "IPSD":
  "First ADHD Medication Prescribed During Intake Period"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Qualifying Encounter":
  ( ( [Encounter: "Office Visit"]
      union [Encounter: "Home Healthcare Services"]
      union [Encounter: "Preventive Care, Established Office Visit, 0 to 17"]
      union [Encounter: "Preventive Care Services, Initial Office Visit, 0 to 17"]
  ).isEncounterPerformed ( ) ) ValidEncounters
    where CQMCommon."ToDateInterval" ( ValidEncounters.period ) during day of Interval["IPSD" - 6 months, "IPSD"]
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "ADHD Medications Taken on IPSD or During Continuation and Maintenance Phase":
  ( ( ( ( ( ( [MedicationRequest: "Atomoxetine"] ).isMedicationOrder ( ) ) AtomoxetineMed
          return all {
            period: AtomoxetineMed.medicationRequestPeriod ( ),
            periodStart: start of AtomoxetineMed.medicationRequestPeriod ( )
          }
          sort by periodStart
      ).period
    ).rolloutIntervals ( )
  )
    union ( ( ( ( ( [MedicationRequest: "Clonidine"] ).isMedicationOrder ( ) ) ClonidineMed
            return all {
              period: ClonidineMed.medicationRequestPeriod ( ),
              periodStart: start of ClonidineMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    )
    union ( ( ( ( ( [MedicationRequest: "Dexmethylphenidate"] ).isMedicationOrder ( ) ) DexmethylphenidateMed
            return all {
              period: DexmethylphenidateMed.medicationRequestPeriod ( ),
              periodStart: start of DexmethylphenidateMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    )
    union ( ( ( ( ( [MedicationRequest: "Dextroamphetamine"] ).isMedicationOrder ( ) ) DextroamphetamineMed
            return all {
              period: DextroamphetamineMed.medicationRequestPeriod ( ),
              periodStart: start of DextroamphetamineMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    )
    union ( ( ( ( ( [MedicationRequest: "Lisdexamfetamine"] ).isMedicationOrder ( ) ) LisdexamfetamineMed
            return all {
              period: LisdexamfetamineMed.medicationRequestPeriod ( ),
              periodStart: start of LisdexamfetamineMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    )
    union ( ( ( ( ( [MedicationRequest: "Methylphenidate"] ).isMedicationOrder ( ) ) MethylphenidateMed
            return all {
              period: MethylphenidateMed.medicationRequestPeriod ( ),
              periodStart: start of MethylphenidateMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    )
    union ( ( ( ( ( [MedicationRequest: "Guanfacine Medications"] ).isMedicationOrder ( ) ) GuanfacineMed
            return all {
              period: GuanfacineMed.medicationRequestPeriod ( ),
              periodStart: start of GuanfacineMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    )
    union ( ( ( ( ( [MedicationRequest: "methamphetamine hydrochloride 5 MG Oral Tablet"] ).isMedicationOrder ( ) ) MethamphetamineMed
            return all {
              period: MethamphetamineMed.medicationRequestPeriod ( ),
              periodStart: start of MethamphetamineMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    )
    union ( ( ( ( ( [MedicationRequest: "Viloxazine"] ).isMedicationOrder ( ) ) ViloxazineMed
            return all {
              period: ViloxazineMed.medicationRequestPeriod ( ),
              periodStart: start of ViloxazineMed.medicationRequestPeriod ( )
            }
            sort by periodStart
        ).period
      ).rolloutIntervals ( )
    ) ) ADHDMedication
    let IPSDAndContinuationMaintenancePhase: Interval["IPSD", "IPSD" + 300 days]
    return all ADHDMedication
      intersect IPSDAndContinuationMaintenancePhase
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "ADHD Cumulative Medication Duration":
  ( "ADHD Medications Taken on IPSD or During Continuation and Maintenance Phase" ).cumulativeDuration ( )
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Has ADHD Cumulative Medication Duration Greater Than or Equal to 210 Days":
  "ADHD Cumulative Medication Duration" >= 210
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Inpatient Stay with Qualifying Diagnosis":
  ( ( [Encounter: "Encounter Inpatient"] ).isEncounterPerformed ( ) ) InpatientStay
    where InpatientStay.hasPrincipalDiagnosisOf ( "Mental Behavioral and Neurodevelopmental Disorders" )
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Inpatient Stay with Qualifying Diagnosis During Continuation and Maintenance Phase":
  "Inpatient Stay with Qualifying Diagnosis" InpatientStay
    where CQMCommon."ToDateInterval" ( InpatientStay.period ) starts 300 days or less after day of "IPSD"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Initial Population 2":
  AgeInYearsAt(date from start of "Intake Period") >= 6
    and AgeInYearsAt(date from 
      end of "Intake Period"
    ) <= 12
    and exists "Qualifying Encounter"
    and "First ADHD Medication Prescribed During Intake Period" is not null
    and "Has ADHD Cumulative Medication Duration Greater Than or Equal to 210 Days"
    and not exists "Inpatient Stay with Qualifying Diagnosis During Continuation and Maintenance Phase"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Denominator 2":
  "Initial Population 2"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Qualifying Numerator Encounter":
  [Encounter: "Office Visit"]
    union [Encounter: "Preventive Care Services Group Counseling"]
    union [Encounter: "Behavioral Health Follow up Visit"]
    union [Encounter: "Preventive Care Services Individual Counseling"]
    union ( [Encounter: "Psychotherapy and Pharmacologic Management"] PsychPharmManagement
        where exists ( PsychPharmManagement.location Location
            where CQMCommon."GetLocation" ( Location.location ).type in "Ambulatory"
        )
    )
    union [Encounter: "Outpatient Consultation"]
    union [Encounter: "Home Healthcare Services"]
    union [Encounter: "Preventive Care Services, Initial Office Visit, 0 to 17"]
    union [Encounter: "Preventive Care, Established Office Visit, 0 to 17"]
    union [Encounter: "Psych Visit Diagnostic Evaluation"]
    union [Encounter: "Psych Visit Psychotherapy"]
    union [Encounter: "Telephone Visits"]
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Encounter During Initiation Phase":
  ( "Qualifying Numerator Encounter".isEncounterPerformed ( ) ) ValidNumeratorEncounter
    where CQMCommon."ToDateInterval" ( ValidNumeratorEncounter.period ) starts 30 days or less after day of "IPSD"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Numerator 1":
  exists "Encounter During Initiation Phase"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Encounter 31 to 300 Days into Continuation and Maintenance Phase":
  ( "Qualifying Numerator Encounter".isEncounterPerformed ( ) ) ValidNumeratorEncounter
    where CQMCommon."ToDateInterval" ( ValidNumeratorEncounter.period ) starts during day of Interval["IPSD" + 31 days, "IPSD" + 300 days]
    return date from start of ValidNumeratorEncounter.period
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Two or More Encounters 31 to 300 Days into Continuation and Maintenance Phase":
  Count("Encounter 31 to 300 Days into Continuation and Maintenance Phase") >= 2
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Virtual Encounter 31 to 300 Days into Continuation and Maintenance Phase":
  ( ( [Encounter: "Virtual Encounter"] ).isEncounterPerformed ( ) ) VirtualEnc
    where CQMCommon."ToDateInterval" ( VirtualEnc.period ) starts during day of Interval["IPSD" + 31 days, "IPSD" + 300 days]
    return date from start of VirtualEnc.period
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Numerator 2":
  exists "Encounter During Initiation Phase"
    and ( "Two or More Encounters 31 to 300 Days into Continuation and Maintenance Phase"
        or ( exists "Encounter 31 to 300 Days into Continuation and Maintenance Phase" Encounter1
            with "Virtual Encounter 31 to 300 Days into Continuation and Maintenance Phase" Encounter2
              such that Encounter1 is not null
                and Encounter2 is not null
                and Encounter1 !~ Encounter2
        )
    )
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Inpatient Stay with Qualifying Diagnosis During Initiation Phase":
  "Inpatient Stay with Qualifying Diagnosis" InpatientStay
    where CQMCommon."ToDateInterval" ( InpatientStay.period ) starts 30 days or less after day of "IPSD"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Initial Population 1":
  AgeInYearsAt(date from start of "Intake Period") >= 6
    and AgeInYearsAt(date from 
      end of "Intake Period"
    ) <= 12
    and exists "Qualifying Encounter"
    and "First ADHD Medication Prescribed During Intake Period" is not null
    and not exists "Inpatient Stay with Qualifying Diagnosis During Initiation Phase"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Narcolepsy Exclusion":
  ( ( [ConditionProblemsHealthConcerns: "Narcolepsy"]
      union [ConditionEncounterDiagnosis: "Narcolepsy"]
  ).verified ( ) ) NarcolepsyDx
    where NarcolepsyDx.onset.toInterval ( ) starts on or before end of "Measurement Period"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Denominator Exclusions":
  Hospice."Has Hospice Services"
    or exists "Narcolepsy Exclusion"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: CMS136FHIRChildADHDMedFollowUp
define "Denominator 1":
  "Initial Population 1"
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: CumulativeMedicationDuration
/*
Now that we have functions for determining the medication period for individual
prescriptions, administrations, and dispenses, we can combine those using
an overall cumulative medication duration calculation.

There are two broad approaches to calculating cumulative duration, one that _collapses_
overlapping intervals so that calculations are not duplicated, and one that _rolls out_
overlapping intervals so that the durations are laid end-to-end.

First, we define a function that simply calculates CumulativeDuration of a set of
intervals:

NOTE: Updated argument to List<Interval<Date>> instead of List<Interval<DateTime>>
*/
define fluent function cumulativeDuration(Intervals List<Interval<Date>>):
   if Intervals is not null then ( Sum((collapse Intervals per day)X
        return all(difference in days between start of X and 
          end of X
        )+ 1
    )
  ) 
    else null
Logic Definition Library Name: CumulativeMedicationDuration
/*
Next, we define a function that rolls out intervals:

NOTE: Updated argument to List<Interval<Date>> instead of List<Interval<DateTime>>
*/
define fluent function rolloutIntervals(intervals List<Interval<Date>>):
 intervals I aggregate all R starting ( null as List<Interval<Date>>): R
    union ( { I X
        let S: Max({ 
          end of Last(R)+ 1 day, start of X }
        ),
        E: S + Quantity(Coalesce(duration in days of X, 0), 'day')
        return Interval[S, E]}
    )
Logic Definition Library Name: CQMCommon
/*
@description: Returns an interval of date values extracted from the input interval of date-time values
@comment: This function returns an interval constructed using the `date from` extractor on the start
and end values of the input date-time interval. Note that using a precision specifier such as `day of`
as part of a timing phrase is preferred to communicate intent to perform day-level comparison, as well
as for general readability.
*/
define function "ToDateInterval"(period Interval<DateTime>):
  Interval[date from start of period, date from end of period]
Logic Definition Library Name: CQMCommon
/*
 @description: Returns the condition that is specified as the principal diagnosis for the encounter and has a code in the given valueSet.
 @comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
 */
 define fluent function hasPrincipalDiagnosisOf(encounter Encounter, valueSet System.ValueSet):
   (encounter.principalDiagnosis()) PD
     return PD.diagnosis in valueSet
       or PD.diagnosis.getCondition().code in valueSet
Logic Definition Library Name: CQMCommon
/*
@description: Returns the claim diagnosis element that is specified as the principal diagnosis for the encounter
 @comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
*/
define fluent function principalDiagnosis(encounter Encounter):
singleton from (
     (encounter.claimDiagnosis()) CD
       where CD.type.includesCode("Principal Diagnosis")
   )
Logic Definition Library Name: CQMCommon
/*
@description: Returns the claim diagnosis elements for the given encounter
@comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
*/
define fluent function claimDiagnosis(encounter Encounter):
  encounter E
    let 
      claim: ([Claim] C where C.status = 'active' and C.use = 'claim' and exists (C.item I where I.encounter.references(E))),
      claimItem: (claim.item I where I.encounter.references(E))
    return claim.diagnosis D where D.sequence in claimItem.diagnosisSequence
Logic Definition Library Name: CQMCommon
/*
@description: Returns the Condition resource for the given reference
*/
define fluent function getCondition(reference Reference):
  singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where reference.references(C.id))
Logic Definition Library Name: CQMCommon
/*
@description: Returns the Location resource specified by the given reference
@deprecated: This function is deprecated. Use the fluent function `getLocation()` instead.
*/
define function "GetLocation"(reference Reference):
  singleton from (
    [Location] L where reference.references(L)
  )
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
define function ToString(value EncounterStatus): 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 MedicationRequestStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value MedicationRequestIntent): 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
/*
@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 ToInteger(value integer): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value dateTime): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value ClaimStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value Use): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value ObservationStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value instant): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value ServiceRequestStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value ServiceRequestIntent): 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: Returns true if any of the given references are to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource):
  exists (references R where R.references(resource))
Logic Definition Library Name: FHIRCommon
/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference FHIR.Reference, resource FHIR.Resource):
  resource.id = Last(Split(reference.reference, '/'))
Logic Definition Library Name: FHIRCommon
/*
@description: Returns true if the given code is in the given codeList
@comment: Returns true if the `code` is equivalent to any of the codes in the given `codeList`, false otherwise.
*/
define fluent function includesCode(codeList List<CodeableConcept>, code Concept):
  exists (codeList C where C ~ code)
Logic Definition Library Name: FHIRCommon
/*
@description: Returns true if the given reference is to the given resourceId
@comment: Returns true if the `resourceId` parameter exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference FHIR.Reference, resourceId String):
  resourceId = Last(Split(reference.reference, '/'))
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: 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 conditions in the given list that either have no verification status or have a verification status of confirmed, unconfirmed, provisional, or differential
*/
define fluent function verified(conditions List<FHIR.Condition>):
  conditions C
    where C.verificationStatus is not null implies
      (C.verificationStatus ~ "confirmed"
        or C.verificationStatus ~ "unconfirmed"
        or C.verificationStatus ~ "provisional"
        or C.verificationStatus ~ "differential"
      )
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: Status
//Encounter, Performed
//General usage unless required otherwise by measure intent (e.g., follow-up encounters)
define fluent function isEncounterPerformed(Enc List<FHIR.Encounter>):
  Enc E
    where E.status = 'finished'
Logic Definition Library Name: Status
//Medication, Order
define fluent function isMedicationOrder(MedicationRequest List<FHIR.MedicationRequest>):
  MedicationRequest M
    where M.status in { 'active', 'completed' }
    and M.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}
Logic Definition Library Name: Status
//Medication, Active
define fluent function isMedicationActive(MedicationRequest List<FHIR.MedicationRequest>):
  MedicationRequest M
    where M.status = 'active'
      and M.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}
Logic Definition Library Name: Status
//Assessment, Performed
define fluent function isAssessmentPerformed(Obs List<ObservationScreeningAssessment>):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
Logic Definition Library Name: Status
//Intervention, Order
define fluent function isInterventionOrder(ServiceRequest List<FHIR.ServiceRequest>):
  ServiceRequest S
    where S.status in { 'active', 'completed' }
      and S.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}
Logic Definition Library Name: Status
//Intervention, Performed
define fluent function isInterventionPerformed(Proc List<FHIR.Procedure>):
  Proc P
    where P.status ~ 'completed'
Logic Definition Library Name: Status
// TODO: Deprecate because this is now in FHIRCommon
//Condition
/*
@description: Returns conditions in the given list that either have no verification status or have a verification status of confirmed, unconfirmed, provisional, or differential
@deprecated: Use the USCoreCommon verified function insteada
*/
define fluent function verified(conditions List<Choice<ConditionProblemsHealthConcerns, ConditionEncounterDiagnosis>>):
  conditions C
    where C.verificationStatus is not null implies
      (C.verificationStatus ~ "confirmed"
        or C.verificationStatus ~ "unconfirmed"
        or C.verificationStatus ~ "provisional"
        or C.verificationStatus ~ "differential"
      )
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 RXNORM
Resource: RxNorm
Canonical URL: http://www.nlm.nih.gov/research/umls/rxnorm
Code System Description: Code system Diagnosis Type
Resource: Example Diagnosis Type Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/ex-diagnosistype
Code System Description: Code system LOINC
Resource: Logical Observation Identifiers, Names and Codes (LOINC)
Canonical URL: http://loinc.org
Code System Description: Code system ConditionVerificationStatusCodes
Resource: ConditionVerificationStatus
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-ver-status
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 Office Visit
Resource: Office Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001
Value Set Description: Value set Home Healthcare Services
Resource: Home Healthcare Services
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016
Value Set Description: Value set Preventive Care, Established Office Visit, 0 to 17
Resource: Preventive Care, Established Office Visit, 0 to 17
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1024
Value Set Description: Value set Preventive Care Services, Initial Office Visit, 0 to 17
Resource: Preventive Care Services, Initial Office Visit, 0 to 17
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1022
Value Set Description: Value set Atomoxetine
Resource: Atomoxetine
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1170
Value Set Description: Value set Clonidine
Resource: Clonidine
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1171
Value Set Description: Value set Dexmethylphenidate
Resource: Dexmethylphenidate
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1172
Value Set Description: Value set Dextroamphetamine
Resource: Dextroamphetamine
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1173
Value Set Description: Value set Lisdexamfetamine
Resource: Lisdexamfetamine
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1174
Value Set Description: Value set Methylphenidate
Resource: Methylphenidate
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1176
Value Set Description: Value set Guanfacine Medications
Resource: Guanfacine Medications
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.196.11.1252
Value Set Description: Value set Viloxazine
Resource: Viloxazine
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1260
Value Set Description: Value set Encounter Inpatient
Resource: Encounter Inpatient
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Value Set Description: Value set Mental Behavioral and Neurodevelopmental Disorders
Resource: Mental Behavioral and Neurodevelopmental Disorders
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.105.12.1203
Value Set Description: Value set Preventive Care Services Group Counseling
Resource: Preventive Care Services Group Counseling
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1027
Value Set Description: Value set Behavioral Health Follow up Visit
Resource: Behavioral Health Follow up Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1054
Value Set Description: Value set Preventive Care Services Individual Counseling
Resource: Preventive Care Services Individual Counseling
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1026
Value Set Description: Value set Psychotherapy and Pharmacologic Management
Resource: Psychotherapy and Pharmacologic Management
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1055
Value Set Description: Value set Ambulatory
Resource: Ambulatory
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.122.12.1003
Value Set Description: Value set Outpatient Consultation
Resource: Outpatient Consultation
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008
Value Set Description: Value set Psych Visit Diagnostic Evaluation
Resource: Psych Visit Diagnostic Evaluation
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1492
Value Set Description: Value set Psych Visit Psychotherapy
Resource: Psych Visit Psychotherapy
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1496
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 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 Virtual Encounter
Resource: Virtual Encounter
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089
Value Set Description: Value set Hospice Encounter
Resource: Hospice Encounter
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
Value Set Description: Value set Hospice Care Ambulatory
Resource: Hospice Care Ambulatory
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1584
Value Set Description: Value set Hospice Diagnosis
Resource: Hospice Diagnosis
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
Value Set Description: Value set Narcolepsy
Resource: Narcolepsy
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.114.12.1011
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: methamphetamine hydrochloride 5 MG Oral Tablet
Code: 977860
System: http://www.nlm.nih.gov/research/umls/rxnorm
Direct Reference Code Display: Principal Diagnosis
Code: principal
System: http://terminology.hl7.org/CodeSystem/ex-diagnosistype
Direct Reference Code Display: Discharge to home for hospice care (procedure)
Code: 428361000124107
System: http://snomed.info/sct
Direct Reference Code Display: Discharge to healthcare facility for hospice care (procedure)
Code: 428371000124100
System: http://snomed.info/sct
Direct Reference Code Display: Yes (qualifier value)
Code: 373066001
System: http://snomed.info/sct
Direct Reference Code Display: Hospice care [Minimum Data Set]
Code: 45755-6
System: http://loinc.org
Direct Reference Code Code: confirmed
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Direct Reference Code Code: unconfirmed
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Direct Reference Code Code: provisional
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Direct Reference Code Code: differential
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
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: SupplementalDataElements version: 6.1.000
Canonical URL: https://madie.cms.gov/Library/SupplementalDataElements|6.1.000
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Library USCommon
Resource: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot
Canonical URL: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot
Dependency Description: Library FHIRCommon
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Dependency Description: Library Status
Resource: Status version: 2.1.000
Canonical URL: https://madie.cms.gov/Library/Status|2.1.000
Dependency Description: Library CQMCommon
Resource: CQMCommon version: 5.1.000
Canonical URL: https://madie.cms.gov/Library/CQMCommon|5.1.000
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
Dependency Description: Library Hospice
Resource: Hospice version: 7.1.000
Canonical URL: https://madie.cms.gov/Library/Hospice|7.1.000
Data Requirements
Data Requirement Type: Patient
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-patient
Must Support Elements: ombCategory, detailed, text
Data Requirement Type: Medication
Profile(s): Medication
Must Support Elements: id, code
Code Filter(s):
Path: code
Data Requirement Type: Medication
Profile(s): Medication
Must Support Elements: id, code
Code Filter(s):
Path: code
ValueSet: Viloxazine
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Atomoxetine
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Clonidine
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Dexmethylphenidate
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Dextroamphetamine
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Lisdexamfetamine
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Methylphenidate
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Guanfacine Medications
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
Code(s): RxNorm: 977860 (methamphetamine hydrochloride 5 MG Oral Tablet)
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication.reference, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, status, intent, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.expectedSupplyDuration.value, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, authoredOn, dispenseRequest.validityPeriod, startDate, period
Code Filter(s):
Path: medication
ValueSet: Viloxazine
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Office Visit
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Preventive Care Services Group Counseling
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Behavioral Health Follow up Visit
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Preventive Care Services Individual Counseling
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, location, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Psychotherapy and Pharmacologic Management
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Outpatient Consultation
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Home Healthcare Services
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Preventive Care Services, Initial Office Visit, 0 to 17
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Preventive Care, Established Office Visit, 0 to 17
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Psych Visit Diagnostic Evaluation
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Psych Visit Psychotherapy
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Telephone Visits
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Virtual Encounter
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: Encounter Inpatient
Data Requirement Type: Resource
Profile(s): Resource
Must Support Elements: id
Data Requirement Type: Claim
Profile(s): Claim
Must Support Elements: status, use, item
Code Filter(s):
Path: status
Code(s): [not stated]: active (active)
Path: use
Code(s): [not stated]: claim (claim)
Data Requirement Type: Condition
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-encounter-diagnosis
Data Requirement Type: Condition
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-encounter-diagnosis
Must Support Elements: code
Code Filter(s):
Path: code
ValueSet: Narcolepsy
Data Requirement Type: Condition
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-problems-health-concerns
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: Narcolepsy
Data Requirement Type: Location
Profile(s): Location
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: Patient
Profile(s): Patient
Must Support Elements: birthDate
Data Requirement Type: Condition
Profile(s): Condition
Must Support Elements: abatement, verificationStatus, onset, recordedDate, clinicalStatus
Data Requirement Type: Condition
Profile(s): Condition
Must Support Elements: code, verificationStatus
Code Filter(s):
Path: code
ValueSet: Hospice Diagnosis
Data Requirement Type: Encounter
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-encounter
Must Support Elements: type, hospitalization, hospitalization.dischargeDisposition, period
Code Filter(s):
Path: type
ValueSet: Encounter Inpatient
Data Requirement Type: Encounter
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-encounter
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Hospice Encounter
Data Requirement Type: Observation
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-screening-assessment
Must Support Elements: code, value, effective, status
Code Filter(s):
Path: code
Code(s): LOINC: 45755-6 (Hospice care [Minimum Data Set])
Path: value
Data Requirement Type: ServiceRequest
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-servicerequest
Must Support Elements: code, authoredOn
Code Filter(s):
Path: code
ValueSet: Hospice Care Ambulatory
Data Requirement Type: Procedure
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-procedure
Must Support Elements: code, performed
Code Filter(s):
Path: code
ValueSet: Hospice Care Ambulatory
Parameters
Name Use Card. Type Documentation
Measurement Period In 0..1 Period
ErrorLevel In 0..1 string
SDE Sex Out 0..1 Coding
Denominator 2 Out 0..1 boolean
Numerator 1 Out 0..1 boolean
SDE Payer Out 0..* Resource
Numerator 2 Out 0..1 boolean
Initial Population 1 Out 0..1 boolean
SDE Ethnicity Out 0..1 Resource
Initial Population 2 Out 0..1 boolean
Denominator Exclusions Out 0..1 boolean
SDE Race Out 0..1 Resource
Denominator 1 Out 0..1 boolean
Generated using version 0.5.4 of the sample-content-ig Liquid templates