Title: TestHeart Failure (HF): Beta-Blocker Therapy for Left Ventricular Systolic Dysfunction (LVSD)FHIR
Id: TestHFBetaBlockerTherapyforLVSDFHIR
Download cql: TestHFBetaBlockerTherapyforLVSDFHIR.cql
Version: 0.0.000
Url: https://madie.cms.gov/Measure/TestHFBetaBlockerTherapyforLVSDFHIR
short-name identifier:

CMS144FHIR

version-independent identifier:

urn:uuid:879db57c-1c2f-4662-908a-feade55e6113

version-specific identifier:

urn:uuid:b5527afa-6ad3-41cd-88bb-1affe067780c

Effective Period: 2025-01-01 ..2025-12-31
Status: draft
Date: 2023-11-06T20:29:25+00:00
Approval Date: 2023-11-07
Last Review Date: 2023-11-07
Name: TestHFBetaBlockerTherapyforLVSDFHIR
Publisher: American Heart Association
Author: org.hl7.fhir.r5.model.ContactDetail@49db2d83
Description: Percentage of patients aged 18 years and older with a diagnosis of heart failure (HF) with a current or prior left ventricular ejection fraction (LVEF) <= 40% who were prescribed or already taking beta-blocker therapy during the measurement period
Purpose: UNKNOWN
Copyright: Copyright 2022 American College of Cardiology and American Heart Association. All Rights Reserved.
Disclaimer: The Measure is not a clinical guideline, does not establish a standard of medical care, and has not been tested for all potential applications. The Measure, while copyrighted, can be reproduced and distributed, without modification, for noncommercial purposes, e.g., use by health care providers in connection with their practices. Commercial use is defined as the sale, license, or distribution of the Measure for commercial gain, or incorporation of the Measure into a product or service that is sold, licensed or distributed for commercial gain. Commercial uses of the Measure require a license agreement between the user and the American College of Cardiology (ACC) or the American Heart Association (AHA). Neither the ACC, nor AHA, nor their members shall be responsible for any use of the Measure. ACC and AHA encourage use of the Measure by other health care professionals, where appropriate. THE MEASURE AND SPECIFICATIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. Limited proprietary coding is contained in the Measure specifications for convenience. Users of the proprietary code sets should obtain all necessary licenses from the owners of these code sets. The ACC and AHA and their members disclaim all liability for use or accuracy of any Current Procedural Terminology (CPT[R]) or other coding contained in the specifications. CPT(R) contained in the Measure specifications is copyright 2004-2021 American Medical Association. LOINC(R) is copyright 2004-2021 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2021 International Health Terminology Standards Development Organisation. ICD-10 is copyright 2021 World Health Organization. All Rights Reserved. The American Medical Association’s and the PCPI(R) Foundation’s significant past efforts and contributions to the performance measure are gratefully acknowledged. Due to technical limitations, registered trademarks are indicated by (R) or [R].
Rationale: Beta blockers improve survival and reduce hospitalization for patients with stable heart failure and reduced LVEF (HFrEF). Treatment should be initiated as soon as a patient is diagnosed with reduced LVEF and does not have prohibitively low systemic blood pressure, fluid overload, or recent treatment with an intravenous positive inotropic agent. Beta blockers have also been shown to lessen the symptoms of heart failure, improve the clinical status of patients, and reduce future clinical deterioration. Despite these benefits, use of beta blockers in eligible patients remains suboptimal.
Clinical recommendation statement: In approximately half of patients with HFrEF, variable degrees of LV enlargement may accompany HFrEF. The definition of HFrEF has varied, with guidelines of left ventricular ejection fraction (LVEF) ≤35%, <40%, and ≤40%. Randomized controlled trials (RCTs) in patients with HF have mainly enrolled patients with HFrEF with an EF ≤35% or ≤40%, and it is only in these patients that efficacious therapies have been demonstrated to date. For the present guideline, HFrEF is defined as the clinical diagnosis of HF and EF ≤40%. (ACCF/AHA, 2013). Use of 1 of the 3 beta blockers proven to reduce mortality (e.g., bisoprolol, carvedilol, and sustained-release metoprolol succinate) is recommended for all patients with current or prior symptoms of HFrEF [heart failure with reduced ejection fraction], unless contraindicated, to reduce morbidity and mortality (Class I, Level of Evidence: A) (ACCF/AHA, 2013). Treatment with a beta blocker should be initiated at very low doses [see excerpt from guideline table below] followed by gradual increments in dose if lower doses have been well tolerated... Clinicians should make every effort to achieve the target doses of the beta blockers shown to be effective in major clinical trials. Even if symptoms do not improve, long-term treatment should be maintained to reduce the risk of major clinical events. Abrupt withdrawal of treatment with a beta blocker can lead to clinical deterioration and should be avoided (ACCF/AHA, 2013). Drugs Commonly Used for Stage C HFrEF (abbreviated to align with focus of measure to include only Beta-blocker therapy) Drug Initial Daily Dose(s) Maximum Dose(s) Mean Doses Achieved in Clinical Trials Beta Blockers Bisoprolol 1.25 mg once 10 mg once 8.6 mg/d Carvedilol 3.125 mg twice 50 mg twice 37 mg/d Carvedilol CR 10 mg once 80 mg once N/A Metoprolol succinate 12.5 to 25 mg once 200 mg once 159 mg/d extended release (metoprolol CR/XL)
Guidance (Usage): This eCQM is to be reported as patient-based. To satisfy this measure, it must be reported for all heart failure patients at least once during the measurement period. A range value should satisfy the logic requirement for 'Ejection Fraction' as long as the ranged observation value clearly meets the less than or equal to 40% threshold noted in the denominator logic. A range that is greater than 40% would not meet the measure requirement. Beta-blocker therapy: -For patients with prior LVEF <= 40%, beta-blocker therapy should include bisoprolol, carvedilol, or sustained release metoprolol succinate. The requirement of two or more visits is to establish that the eligible professional or eligible clinician has an existing relationship with the patient. This eCQM is a PATIENT-based measure. This FHIR-based measure has been derived from the QDM-based measure: CMS144v12. Please refer to the HL7 QI-Core Implementation Guide (http://hl7.org/fhir/us/qicore/index.html) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (http://hl7.org/fhir/us/qicore/qdm-to-qicore.html).
Population Criteria:
65494c7fc7595406b197afa8
Initial Population: All patients aged 18 years and older with two qualifying encounters during the measurement period and a diagnosis of heart failure
Denominator: Equals Initial Population with a current or prior LVEF <= 40%
Denominator Exclusion: Patients with a history of heart transplant or with a Left Ventricular Assist Device (LVAD) prior to the end of the outpatient encounter with Moderate or Severe LVSD
Numerator: Patients who were prescribed or already taking beta-blocker therapy during the measurement period
Numerator Exclusion: None
Denominator Exception: Documentation of medical reason(s) for not prescribing beta-blocker therapy (e.g., arrhythmia, asthma, bradycardia, hypotension, patients with atrioventricular block without cardiac pacer, observation of consecutive heart rates <50, allergy, intolerance, other medical reasons). Documentation of patient reason(s) for not prescribing beta-blocker therapy (e.g., patient declined, other patient reasons)
Supplemental Data Guidance :
Supplemental Data Elements: SDE Ethnicity SDE Payer SDE Race SDE Sex
Libraries:
https://madie.cms.gov/Library/TestHFBetaBlockerTherapyforLVSDFHIR
Related Artifact Dependencies:
  • Library/SupplementalDataElements|3.2.000
  • Library/AHAOverall|2.4.000
  • Library/QICoreCommon|1.3.000
  • Library/FHIRHelpers|4.2.000
  • Library/QICoreCommonNew|2.0.000
  • http://terminology.hl7.org/CodeSystem/condition-clinical
  • http://terminology.hl7.org/CodeSystem/condition-ver-status
  • http://snomed.info/sct
  • http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical
  • http://terminology.hl7.org/CodeSystem/allergyintolerance-verification
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1184
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.376
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1134
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1090
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1092
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1012
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.33
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.56
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.61
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.58
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1007
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1008
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.366
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.370
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.362
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1177
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1178
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.412
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1493
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.367
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.368
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.53
  • Parameters:
    name use min max type
    Measurement Period in 0 1 Period
    Numerator out 0 1 boolean
    Denominator out 0 1 boolean
    Initial Population out 0 1 boolean
    Denominator Exclusions out 0 1 boolean
    Denominator Exceptions out 0 1 boolean
    SDE Sex out 0 1 Coding
    SDE Payer out 0 * Resource
    SDE Ethnicity out 0 1 Resource
    SDE Race out 0 1 Resource
    DataRequirements:
    Type Elements Valueset Name Valueset
    Patient(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient) gender gender.value birthDate birthDate.value url extension
    Encounter(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter) status period status.value
    Encounter(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter) type period Care Services in Long Term Residential Facility http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014
    Encounter(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter) type period Home Healthcare Services http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016
    Encounter(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter) type period Nursing Facility Visit http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012
    Encounter(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter) type period Office Visit http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001
    Encounter(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter) type period Outpatient Consultation http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008
    Encounter(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter) type period Patient Provider Interaction http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1012
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code clinicalStatus verificationStatus Heart Failure http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.376
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code clinicalStatus verificationStatus Moderate or Severe LVSD http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1090
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code severity clinicalStatus verificationStatus
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code recordedDate recordedDate.value clinicalStatus verificationStatus Heart Transplant Complications http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.56
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code recordedDate recordedDate.value clinicalStatus verificationStatus Left Ventricular Assist Device Complications http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.58
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) clinicalStatus verificationStatus
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code verificationStatus clinicalStatus Arrhythmia http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.366
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code verificationStatus clinicalStatus Hypotension http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.370
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code verificationStatus clinicalStatus Asthma http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.362
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code clinicalStatus verificationStatus Allergy to Beta Blocker Therapy http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1177
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code clinicalStatus verificationStatus Intolerance to Beta Blocker Therapy http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1178
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code verificationStatus clinicalStatus Bradycardia http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.412
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code verificationStatus clinicalStatus Atrioventricular Block http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.367
    Condition(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition) code verificationStatus clinicalStatus Cardiac Pacer in Situ http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.368
    Observation(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation) code Ejection Fraction http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1134
    MedicationRequest(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest) medication status status.value intent intent.value Beta Blocker Therapy for LVSD http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1184
    MedicationRequest(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest) authoredOn status status.value intent intent.value authoredOn.value doNotPerform doNotPerform.value medication.reference
    Medication(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication) id
    Coverage(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage) type period Payer http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
    Procedure(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure) code performed status status.value Heart Transplant http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.33
    Procedure(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure) code performed status status.value Left Ventricular Assist Device Placement http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.61
    Procedure(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure) code performed status status.value Cardiac Pacer http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.53
    Observation(http://hl7.org/fhir/StructureDefinition/heartrate) effective status status.value value
    MedicationRequest(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-mednotrequested) authoredOn authoredOn.value medication reasonCode
    AllergyIntolerance(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-allergyintolerance) code clinicalStatus Beta Blocker Therapy Ingredient http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1493
    AllergyIntolerance(http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-allergyintolerance) code clinicalStatus
    Direct Reference Codes:
    display code system
    active http://terminology.hl7.org/CodeSystem/condition-clinical
    unconfirmed http://terminology.hl7.org/CodeSystem/condition-ver-status
    refuted http://terminology.hl7.org/CodeSystem/condition-ver-status
    entered-in-error http://terminology.hl7.org/CodeSystem/condition-ver-status
    Left ventricular systolic dysfunction (disorder) 134401001 http://snomed.info/sct
    active http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical
    unconfirmed http://terminology.hl7.org/CodeSystem/allergyintolerance-verification
    refuted http://terminology.hl7.org/CodeSystem/allergyintolerance-verification
    entered-in-error http://terminology.hl7.org/CodeSystem/allergyintolerance-verification
    Recurrence recurrence http://terminology.hl7.org/CodeSystem/condition-clinical
    Relapse relapse http://terminology.hl7.org/CodeSystem/condition-clinical
    Confirmed confirmed http://terminology.hl7.org/CodeSystem/condition-ver-status
    Substance with beta adrenergic receptor antagonist mechanism of action (substance) 373254001 http://snomed.info/sct
    Logic Definitions:
    Group Scoring Population Criteria Expression
    65494c7fc7595406b197afa8 Group scoring: proportion
    Initial Population
    define "Initial Population":
      AgeInYearsAt(date from start of "Measurement Period") >= 18
        and Count(AHA."Qualifying Outpatient Encounter During Measurement Period") >= 2
        and exists AHA."Heart Failure Outpatient Encounter"
    Denominator
    define "Denominator":
      "Initial Population"
        and exists AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD"
    Denominator Exclusion
    define "Denominator Exclusions":
      AHA."Has Heart Transplant"
        or AHA."Has Heart Transplant Complications"
        or AHA."Has Left Ventricular Assist Device"
        or AHA."Has Left Ventricular Assist Device Complications"
    Numerator
    define "Numerator":
      "Has Beta Blocker Therapy for LVSD Ordered"
        or "Is Currently Taking Beta Blocker Therapy for LVSD"
    Numerator Exclusion None
    Denominator Exception
    define "Denominator Exceptions":
      "Has Consecutive Heart Rates Less than 50"
        or "Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD"
        or "Has Arrhythmia Diagnosis"
        or "Has Hypotension Diagnosis"
        or "Has Asthma Diagnosis"
        or "Has Diagnosis of Allergy or Intolerance to Beta Blocker Therapy"
        or "Has Bradycardia Diagnosis"
        or "Has Allergy or Intolerance to Beta Blocker Therapy Ingredient"
        or "Atrioventricular Block without Cardiac Pacer"
    Library Name Name
    SupplementalDataElements SDE Sex
    define "SDE Sex":
      case
          when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' }
          when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' }
          else null
        end
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR SDE Sex
    define "SDE Sex":
      SDE."SDE Sex"
    Library Name Name
    AHAOverall Heart Failure Outpatient Encounter
    define "Heart Failure Outpatient Encounter":
      ( [Encounter: "Care Services in Long Term Residential Facility"]
          union [Encounter: "Home Healthcare Services"]
          union [Encounter: "Nursing Facility Visit"]
          union [Encounter: "Office Visit"]
          union [Encounter: "Outpatient Consultation"]
         ) QualifyingEncounter
        with [Condition: "Heart Failure"] HeartFailure
          such that HeartFailure.prevalenceInterval() overlaps QualifyingEncounter.period  
            and HeartFailure.isConfirmedActiveDiagnosis()
        where QualifyingEncounter.period during "Measurement Period"
          and QualifyingEncounter.isFinished()
    Library Name Name
    AHAOverall Moderate or Severe LVSD Dates
    /**
    * Modified Moderate or Severe LVSD Findings defintion to return dates of findings due 
    * to issues in Translator around union of unlike types: refer to 
    * https://github.com/cqframework/clinical_quality_language/issues/1126
    **/
    define "Moderate or Severe LVSD Dates":
        ( [Observation: "Ejection Fraction"] EjectionFraction
            let dateOfFinding: start of ( EjectionFraction Fraction
                                     where Fraction.value as Quantity <= 40 '%'
                                       and Fraction.status in {'final', 'amended', 'corrected'} 
                                     return Fraction.effective.toInterval()
                                       )
            return dateOfFinding 
          )
        union
        ( 
            ( [Condition: "Moderate or Severe LVSD"]
                union ( [Condition: "Left ventricular systolic dysfunction (disorder)"] LVSDDiagnosis
                           where LVSDDiagnosis.severity in "Moderate or Severe"
                        ) 
              ) ModerateOrSevereLVSD
            let dateOfFinding: start of ( ModerateOrSevereLVSD LVSD
                                      where LVSD.isConfirmedActiveDiagnosis()
                                      return LVSD.prevalenceInterval()
                                    )
            return dateOfFinding 
          )
    Library Name Name
    AHAOverall Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD
    define "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD":
        "Heart Failure Outpatient Encounter" HFOutpatientEncounter
            with "Moderate or Severe LVSD Dates" ModerateSevereLVSDDate
                such that ModerateSevereLVSDDate before end of HFOutpatientEncounter.period
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Beta Blocker Therapy for LVSD Ordered
    define "Has Beta Blocker Therapy for LVSD Ordered":
      exists ( [MedicationRequest: "Beta Blocker Therapy for LVSD"] BetaBlockerOrdered
          where BetaBlockerOrdered.isOrderedDuringHeartFailureOutpatientEncounter ( )
            and BetaBlockerOrdered.status in { 'active', 'completed' }
            and BetaBlockerOrdered.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Is Currently Taking Beta Blocker Therapy for LVSD
    define "Is Currently Taking Beta Blocker Therapy for LVSD":
      exists ( ["MedicationRequest": "Beta Blocker Therapy for LVSD"] ActiveBetaBlocker
          where ActiveBetaBlocker.overlapsAfterHeartFailureOutpatientEncounter ( )
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Numerator
    define "Numerator":
      "Has Beta Blocker Therapy for LVSD Ordered"
        or "Is Currently Taking Beta Blocker Therapy for LVSD"
    Library Name Name
    AHAOverall Qualifying Outpatient Encounter During Measurement Period
    define "Qualifying Outpatient Encounter During Measurement Period":
        ( [Encounter: "Care Services in Long Term Residential Facility"]
                  union [Encounter: "Home Healthcare Services"]
                  union [Encounter: "Nursing Facility Visit"]
                  union [Encounter: "Office Visit"]
                  union [Encounter: "Outpatient Consultation"]
                  union [Encounter: "Patient Provider Interaction"]
         ) ValidEncounter
          where ValidEncounter.period during "Measurement Period"
            and ValidEncounter.isFinished()
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Initial Population
    define "Initial Population":
      AgeInYearsAt(date from start of "Measurement Period") >= 18
        and Count(AHA."Qualifying Outpatient Encounter During Measurement Period") >= 2
        and exists AHA."Heart Failure Outpatient Encounter"
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Denominator
    define "Denominator":
      "Initial Population"
        and exists AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD"
    Library Name Name
    SupplementalDataElements SDE Payer
    define "SDE Payer":
      [Coverage: type in "Payer"] Payer
        return {
          code: Payer.type,
          period: Payer.period
        }
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR SDE Payer
    define "SDE Payer":
      SDE."SDE Payer"
    Library Name Name
    SupplementalDataElements SDE Ethnicity
    define "SDE Ethnicity":
      Patient.ethnicity E
        return Tuple {
          codes: { E.ombCategory } union E.detailed,
          display: E.text
        }
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR SDE Ethnicity
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
    Library Name Name
    AHAOverall Has Heart Transplant
    define "Has Heart Transplant":
      exists (
              [Procedure: "Heart Transplant"] HeartTransplant
                with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                  such that HeartTransplant.performed.toInterval() starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
                where HeartTransplant.status = 'completed'
              )
    Library Name Name
    AHAOverall Has Heart Transplant Complications
    define "Has Heart Transplant Complications":
      exists ( 
              [Condition: "Heart Transplant Complications"] HeartTransplantComplications
                with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                  such that ( Coalesce( HeartTransplantComplications.recordedDate.toInterval(), HeartTransplantComplications.prevalenceInterval() ) ) starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
                where HeartTransplantComplications.isConfirmedActiveDiagnosis()
              )
    Library Name Name
    AHAOverall Has Left Ventricular Assist Device
    define "Has Left Ventricular Assist Device":
      exists (
                [Procedure: "Left Ventricular Assist Device Placement"] LVADOutpatient
                  with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                    such that LVADOutpatient.performed.toInterval() starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
                  where LVADOutpatient.status = 'completed'
                )
    Library Name Name
    AHAOverall Has Left Ventricular Assist Device Complications
    define "Has Left Ventricular Assist Device Complications":
      exists (
                [Condition: "Left Ventricular Assist Device Complications"] LVADComplications
                  with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                    such that ( Coalesce( LVADComplications.recordedDate.toInterval(), LVADComplications.prevalenceInterval() ) ) starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period  
                  where LVADComplications.isConfirmedActiveDiagnosis()
              )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Denominator Exclusions
    define "Denominator Exclusions":
      AHA."Has Heart Transplant"
        or AHA."Has Heart Transplant Complications"
        or AHA."Has Left Ventricular Assist Device"
        or AHA."Has Left Ventricular Assist Device Complications"
    Library Name Name
    SupplementalDataElements SDE Race
    define "SDE Race":
      Patient.race R
        return Tuple {
          codes: R.ombCategory union R.detailed,
          display: R.text
        }
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR SDE Race
    define "SDE Race":
      SDE."SDE Race"
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Consecutive Heart Rates Less than 50
    define "Has Consecutive Heart Rates Less than 50":
      exists ( from
          ["observation-heartrate"] HeartRate,
          AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
          let PriorHeartRate: Last(["observation-heartrate"] MostRecentPriorHeartRate
              where MostRecentPriorHeartRate.effective.toInterval() during ModerateOrSevereLVSDHFOutpatientEncounter.period
                and MostRecentPriorHeartRate.effective.toInterval() before HeartRate.effective.toInterval()
              sort by start of effective.toInterval()
          )
          where HeartRate.effective.toInterval ( ) during ModerateOrSevereLVSDHFOutpatientEncounter.period
            and HeartRate.status in { 'final', 'amended', 'corrected' }
            and HeartRate.value < 50 '/min'
            and PriorHeartRate.value < 50 '/min'
          return HeartRate
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD
    define "Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD":
      exists ( ["MedicationNotRequested"] NoBetaBlockerOrdered
          with AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
            such that NoBetaBlockerOrdered.authoredOn during ModerateOrSevereLVSDHFOutpatientEncounter.period
          where NoBetaBlockerOrdered.medication in "Beta Blocker Therapy for LVSD"
            and ( NoBetaBlockerOrdered.reasonCode in "Medical Reason"
                or NoBetaBlockerOrdered.reasonCode in "Patient Reason"
            )
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Arrhythmia Diagnosis
    define "Has Arrhythmia Diagnosis":
      exists ( [Condition: "Arrhythmia"] Arrhythmia
          where Arrhythmia.overlapsHeartFailureOutpatientEncounter ( )
            and Arrhythmia.isActive ( )
            and Arrhythmia.verificationStatus ~ QICoreCommon."confirmed"
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Hypotension Diagnosis
    define "Has Hypotension Diagnosis":
      exists ( ["Condition": "Hypotension"] Hypotension
          where Hypotension.overlapsHeartFailureOutpatientEncounter ( )
            and Hypotension.isActive ( )
            and Hypotension.verificationStatus ~ QICoreCommon."confirmed"
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Asthma Diagnosis
    define "Has Asthma Diagnosis":
      exists ( [Condition: "Asthma"] Asthma
          where Asthma.overlapsHeartFailureOutpatientEncounter ( )
            and Asthma.isActive ( )
            and Asthma.verificationStatus ~ QICoreCommon."confirmed"
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Diagnosis of Allergy or Intolerance to Beta Blocker Therapy
    define "Has Diagnosis of Allergy or Intolerance to Beta Blocker Therapy":
      exists ( ( ["Condition": "Allergy to Beta Blocker Therapy"]
          union ["Condition": "Intolerance to Beta Blocker Therapy"] ) BetaBlockerAllergyOrIntoleranceDiagnosis
          where BetaBlockerAllergyOrIntoleranceDiagnosis.overlapsAfterHeartFailureOutpatientEncounter ( )
            and BetaBlockerAllergyOrIntoleranceDiagnosis.isActive ( )
            and BetaBlockerAllergyOrIntoleranceDiagnosis.verificationStatus ~ QICoreCommon."confirmed"
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Bradycardia Diagnosis
    define "Has Bradycardia Diagnosis":
      exists ( [Condition: "Bradycardia"] Bradycardia
          where Bradycardia.overlapsHeartFailureOutpatientEncounter ( )
            and Bradycardia.isActive ( )
            and Bradycardia.verificationStatus ~ QICoreCommon."confirmed"
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Allergy or Intolerance to Beta Blocker Therapy Ingredient
    define "Has Allergy or Intolerance to Beta Blocker Therapy Ingredient":
      exists ( ( [AllergyIntolerance: "Beta Blocker Therapy Ingredient"]
          union [AllergyIntolerance: "Substance with beta adrenergic receptor antagonist mechanism of action (substance)"] ) BetaBlockerAllergyIntolerance
          where BetaBlockerAllergyIntolerance.overlapsAfterHeartFailureOutpatientEncounter ( )
            and ( BetaBlockerAllergyIntolerance.clinicalStatus is null
                or BetaBlockerAllergyIntolerance.clinicalStatus ~ QICoreCommon."allergy-active"
            )
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Atrioventricular Block Diagnosis
    define "Has Atrioventricular Block Diagnosis":
      exists ( [Condition: "Atrioventricular Block"] AtrioventricularBlock
          where AtrioventricularBlock.overlapsHeartFailureOutpatientEncounter ( )
            and AtrioventricularBlock.isActive ( )
            and AtrioventricularBlock.verificationStatus ~ QICoreCommon."confirmed"
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Diagnosis of Cardiac Pacer in Situ
    define "Has Diagnosis of Cardiac Pacer in Situ":
      exists ( ["Condition": "Cardiac Pacer in Situ"] CardiacPacerDiagnosis
          where CardiacPacerDiagnosis.overlapsAfterHeartFailureOutpatientEncounter ( )
            and CardiacPacerDiagnosis.isActive ( )
            and CardiacPacerDiagnosis.verificationStatus ~ QICoreCommon."confirmed"
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Has Cardiac Pacer Device Implanted
    define "Has Cardiac Pacer Device Implanted":
      exists ( [Procedure: "Cardiac Pacer"] ImplantedCardiacPacer
          with AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
            such that ImplantedCardiacPacer.performed.toInterval ( ) starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
          where ImplantedCardiacPacer.status = 'completed'
      )
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Atrioventricular Block without Cardiac Pacer
    define "Atrioventricular Block without Cardiac Pacer":
      "Has Atrioventricular Block Diagnosis"
        and not "Has Diagnosis of Cardiac Pacer in Situ"
        and not "Has Cardiac Pacer Device Implanted"
    Library Name Name
    TestHFBetaBlockerTherapyforLVSDFHIR Denominator Exceptions
    define "Denominator Exceptions":
      "Has Consecutive Heart Rates Less than 50"
        or "Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD"
        or "Has Arrhythmia Diagnosis"
        or "Has Hypotension Diagnosis"
        or "Has Asthma Diagnosis"
        or "Has Diagnosis of Allergy or Intolerance to Beta Blocker Therapy"
        or "Has Bradycardia Diagnosis"
        or "Has Allergy or Intolerance to Beta Blocker Therapy Ingredient"
        or "Atrioventricular Block without Cardiac Pacer"
    Library Name Name
    AHAOverall isOrderedDuringHeartFailureOutpatientEncounter
    define fluent function isOrderedDuringHeartFailureOutpatientEncounter(Order MedicationRequest): 
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                where Order.authoredOn during day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                  and Order.status in {'active', 'completed'}
                  and Order.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
                  and Order.doNotPerform is not true
              )
    Library Name Name
    QICoreCommon prevalenceInterval
    /*
    @description: Returns an interval representing the normalized prevalence period of a given Condition.
    @comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
    onset to abatement as specified in the given Condition. If the condition is active, the resulting interval will have
    a closed ending boundary. If the condition is not active, the resulting interval will have an open ending boundary.
    */
    define fluent function prevalenceInterval(condition Condition):
    if condition.clinicalStatus ~ "active"
      or condition.clinicalStatus ~ "recurrence"
      or condition.clinicalStatus ~ "relapse" then
      Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
    else
      Interval[start of condition.onset.toInterval(), end of condition.abatementInterval())
    Library Name Name
    AHAOverall isConfirmedActiveDiagnosis
    define fluent function isConfirmedActiveDiagnosis(Condition Condition):
      ( Condition Diagnosis
        where Diagnosis.clinicalStatus ~ QICoreCommon."active"
            and not ( Diagnosis.verificationStatus ~ QICoreCommon."unconfirmed"
                         or Diagnosis.verificationStatus ~ QICoreCommon."refuted"
                         or Diagnosis.verificationStatus ~ QICoreCommon."entered-in-error" )
        ) is not null
    Library Name Name
    AHAOverall isFinished
    define fluent function isFinished(Visit Encounter):
      Visit.status = 'finished'
    Library Name Name
    QICoreCommon toInterval
    /*
    @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
    @comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> types
    to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
    representations for timing-valued elements in QICore, allowing this function to be used across any resource.
    The input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.
    The intent of this function is to provide a clear and concise mechanism to treat single
    elements that have multiple possible representations as intervals so that logic doesn't have to account
    for the variability. More complex calculations (such as medication request period or dispense period
    calculation) need specific guidance and consideration. That guidance may make use of this function, but
    the focus of this function is on single element calculations where the semantics are unambiguous.
    If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
    If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
    and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
    If the input is a DateTime Interval, the result is the input.
    If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
    is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
    immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
    Any other input will reslt in a null DateTime Interval
    */
    define fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>>):
      case
    	  when choice is DateTime then
        	Interval[choice as DateTime, choice as DateTime]
    		when choice is Interval<DateTime> then
      		choice as Interval<DateTime>
    		when choice is Quantity then
    		  Interval[Patient.birthDate + (choice as Quantity),
    			  Patient.birthDate + (choice as Quantity) + 1 year)
    		when choice is Interval<Quantity> then
    		  Interval[Patient.birthDate + (choice.low as Quantity),
    			  Patient.birthDate + (choice.high as Quantity) + 1 year)
    		else
    			null as Interval<DateTime>
    	end
    Library Name Name
    AHAOverall overlapsAfterHeartFailureOutpatientEncounter
    define fluent function overlapsAfterHeartFailureOutpatientEncounter(Event Choice<Condition, Procedure, AllergyIntolerance, MedicationRequest, "observation-heartrate">): 
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                where 
                  case
                    when Event is Condition then 
                      Event.prevalenceInterval() overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                        and Event.isConfirmedActiveDiagnosis()
                    when Event is Procedure then
                      Event.performed.toInterval() overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                        and Event.status = 'completed'
                    when Event is AllergyIntolerance then
                      Interval[start of Event.onset.toInterval(), Event.lastOccurrence] overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                        and Event.clinicalStatus ~ QICoreCommon."allergy-active"
                        and not (Event.verificationStatus ~ QICoreCommon."allergy-unconfirmed"
                            or Event.verificationStatus ~ QICoreCommon."allergy-refuted"
                            or Event.verificationStatus ~ "allergy-entered-in-error")
                    when Event is MedicationRequest then
                      First( ( collapse (Event.dosageInstruction.timing.repeat.bounds DoseTime
                                            return DoseTime.toInterval()) ) DrugPeriods
                               sort by start of $this ) overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period 
                        and Event.status in { 'active', 'completed' } 
                        and Event.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
                        and Event.doNotPerform is not true
                    when Event is "observation-heartrate" then
                      Event.effective.toInterval() overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                        and Event.status in {'final', 'amended', 'corrected'}
                    else false
                  end
              )
    Library Name Name
    FHIRHelpers ToString
    define function ToString(value uri): value.value
    Library Name Name
    FHIRHelpers ToCode
    /*
    @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
            }
    Library Name Name
    FHIRHelpers ToConcept
    /*
    @description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
    */
    define function ToConcept(concept FHIR.CodeableConcept):
        if concept is null then
            null
        else
            System.Concept {
                codes: concept.coding C return ToCode(C),
                display: concept.text.value
            }
    Library Name Name
    AHAOverall overlapsHeartFailureOutpatientEncounter
    define fluent function overlapsHeartFailureOutpatientEncounter(Diagnosis Condition): 
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                where Diagnosis.prevalenceInterval() overlaps day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                  and Diagnosis.isConfirmedActiveDiagnosis()
              )
    Library Name Name
    QICoreCommonNew isActive
    /* Candidates for FHIRCommon */
    
    /*
    @description: Returns true if the given condition has a clinical status of active, recurrence, or relapse
    */
    define fluent function isActive(condition Condition):
      condition.clinicalStatus ~ "active"
        or condition.clinicalStatus ~ "recurrence"
        or condition.clinicalStatus ~ "relapse"