eCQM QICore Content Implementation Guide
2024.0.0 - CI Build

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

Measure: Heart Failure (HF): Beta-Blocker Therapy for Left Ventricular Systolic Dysfunction (LVSD)FHIR

Official URL: https://madie.cms.gov/Measure/HFBetaBlockerTherapyforLVSDFHIR Version: 1.4.000
Draft as of 2024-12-18 Responsible: American Heart Association Computable Name: HFBetaBlockerTherapyforLVSDFHIR
Other Identifiers: Short Name (use: usual, ), UUID:73947208-412c-4295-bf7f-43bc907569d3 (use: official, ), UUID:42d6879c-a0a4-4f59-be82-ba03783e88da (use: official, ), Endorser (use: official, ), Publisher (use: official, )

Copyright/Legal: Copyright 2024 American College of Cardiology and American Heart Association. All Rights Reserved.

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

UNKNOWN

Title: Heart Failure (HF): Beta-Blocker Therapy for Left Ventricular Systolic Dysfunction (LVSD)FHIR
Id: HFBetaBlockerTherapyforLVSDFHIR
Version: 1.4.000
Url: Heart Failure (HF): Beta-Blocker Therapy for Left Ventricular Systolic Dysfunction (LVSD)FHIR
short-name identifier:

CMS144FHIR

version-independent identifier:

urn:uuid:73947208-412c-4295-bf7f-43bc907569d3

version-specific identifier:

urn:uuid:42d6879c-a0a4-4f59-be82-ba03783e88da

endorser (CMS Consensus Based Entity) identifier:

0083e

publisher (CMS) identifier:

144FHIR

Effective Period: 2025-01-01..2025-12-31
Status: draft
Publisher: American Heart Association
Author: American Heart Association, American Medical Association (AMA), American Medical Association-convened Physician Consortium for Performance Improvement(R) (AMA-PCPI)
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 2024 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-2023 American Medical Association. LOINC(R) is copyright 2004-2023 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2023 International Health Terminology Standards Development Organisation. ICD-10 is copyright 2023 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].

Scoring:

Proportion

Rationale:

Beta blockers improve survival and reduce hospitalization for patients with stable heart failure with reduced ejection fraction (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 patients with HFrEF, with current or previous symptoms, use of 1 of the 3 beta blockers proven to reduce mortality (e.g., bisoprolol, carvedilol, sustained-release metoprolol succinate) is recommended to reduce mortality and hospitalizations (Class I, Level of Evidence A) (Heidenreich, 2022). 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) Target 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 25-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. In order for the Ejection Fraction result pathway to be recognized as below 40%, the result must be reported as a number with unit of %. A text string of "below 40%" or "ejection fraction between 35 and 40%" will not be recognized through electronic data capture. Although, this criteria can also be met using the Diagnosis pathway if specified as "Moderate or Severe." 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 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: CMS144v13. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (https://hl7.org/fhir/us/qicore/STU4.1.1/qdm-to-qicore.html).
Population Criteria:
664396d3f4fc785d87117076
Initial Population: All patients aged 18 years and older with two qualifying encounters during the measurement period and a diagnosis of heart failure on or before at least one qualifying encounter
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
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 Elements:

SDE Ethnicity

SDE Payer

SDE Race

SDE Sex

Supplemental Data Guidance : For every patient evaluated by this measure also identify payer, race, ethnicity and sex; SDE Ethnicity SDE Payer SDE Race SDE Sex
Libraries:
HFBetaBlockerTherapyforLVSDFHIR
Terminology and Other Dependencies:
  • Library/SupplementalDataElements|3.5.000
  • Library/AHAOverall|2.8.000
  • Library/QICoreCommon|2.1.000
  • Library/FHIRHelpers|4.4.000
  • AdministrativeGender
  • Condition Clinical Status Codes
  • ConditionVerificationStatus
  • SNOMED CT (all versions)
  • AllergyIntolerance Clinical Status Codes
  • AllergyIntolerance Verification Status
  • Beta Blocker Therapy for LVSD
  • Care Services in Long-Term Residential Facility
  • Home Healthcare Services
  • Nursing Facility Visit
  • Office Visit
  • Outpatient Consultation
  • Heart Failure
  • Ejection Fraction
  • Moderate or Severe LVSD
  • Moderate or Severe
  • Patient Provider Interaction
  • Payer
  • 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
  • Hypotension
  • Asthma
  • Allergy to Beta Blocker Therapy
  • Intolerance to Beta Blocker Therapy
  • Bradycardia
  • Beta Blocker Therapy Ingredient
  • Atrioventricular Block
  • Cardiac Pacer in Situ
  • 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
    SDE Sex Out 0 1 Coding
    Numerator Out 0 1 boolean
    Denominator Out 0 1 boolean
    SDE Payer Out 0 * Resource
    Initial Population Out 0 1 boolean
    SDE Ethnicity Out 0 1 Resource
    Denominator Exclusions Out 0 1 boolean
    SDE Race Out 0 1 Resource
    Denominator Exceptions Out 0 1 boolean
    DataRequirements:
    Resource Type Resource Elements Valueset Name Valueset
    Patient(QICorePatient) ethnicity race
    Encounter(QICoreEncounter) type period id id.value Office Visit Office Visit
    Encounter(QICoreEncounter) type period id id.value Outpatient Consultation Outpatient Consultation
    Encounter(QICoreEncounter) type period id id.value Nursing Facility Visit Nursing Facility Visit
    Encounter(QICoreEncounter) type period id id.value Care Services in Long Term Residential Facility Care Services in Long-Term Residential Facility
    Encounter(QICoreEncounter) type period id id.value Home Healthcare Services Home Healthcare Services
    Encounter(QICoreEncounter) type period id id.value Patient Provider Interaction Patient Provider Interaction
    Condition(QICoreCondition) code Heart Failure Heart Failure
    Condition(QICoreCondition) code severity
    Condition(QICoreCondition) code Moderate or Severe LVSD Moderate or Severe LVSD
    Condition(QICoreCondition) code recordedDate recordedDate.value Heart Transplant Complications http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.56
    Condition(QICoreCondition) code recordedDate recordedDate.value Left Ventricular Assist Device Complications http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.58
    Condition(QICoreCondition) code Hypotension Hypotension
    Condition(QICoreCondition) code Asthma Asthma
    Condition(QICoreCondition) code Allergy to Beta Blocker Therapy Allergy to Beta Blocker Therapy
    Condition(QICoreCondition) code Intolerance to Beta Blocker Therapy Intolerance to Beta Blocker Therapy
    Condition(QICoreCondition) code Bradycardia Bradycardia
    Condition(QICoreCondition) code Atrioventricular Block Atrioventricular Block
    Condition(QICoreCondition) code Cardiac Pacer in Situ Cardiac Pacer in Situ
    Observation(QICoreObservation) code value status status.value Ejection Fraction Ejection Fraction
    Medication(QICoreMedication) id
    Medication(QICoreMedication) id
    MedicationRequest(QICoreMedicationRequest) medication.reference timing repeat bounds
    MedicationRequest(QICoreMedicationRequest) medication timing repeat bounds Beta Blocker Therapy for LVSD Beta Blocker Therapy for LVSD
    Coverage(QICoreCoverage) type period Payer Type Payer
    Procedure(QICoreProcedure) code performed status status.value Heart Transplant http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.33
    Procedure(QICoreProcedure) 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(QICoreProcedure) code performed status status.value Cardiac Pacer http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.53
    Observation(Observation Heart Rate Profile) effective value status status.value
    AllergyIntolerance(QICoreAllergyIntolerance) code clinicalStatus Beta Blocker Therapy Ingredient Beta Blocker Therapy Ingredient
    AllergyIntolerance(QICoreAllergyIntolerance) code clinicalStatus
    Direct Reference Codes:
    display code system
    Male M http://hl7.org/fhir/administrative-gender
    Female F http://hl7.org/fhir/administrative-gender
    Active active http://terminology.hl7.org/CodeSystem/condition-clinical
    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
    Left ventricular systolic dysfunction (disorder) 134401001 http://snomed.info/sct
    Substance with beta adrenergic receptor antagonist mechanism of action (substance) 373254001 http://snomed.info/sct
    Active active http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical
    Confirmed confirmed http://terminology.hl7.org/CodeSystem/allergyintolerance-verification
    Logic Definitions:
    Group Scoring Population Criteria Expression
    664396d3f4fc785d87117076 Group scoring: proportion Measure scoring:

    Proportion

    Type:

    Process

    Rate Aggregation: None
    Improvement Notation:

    Increased score indicates improvement

    Initial Population
    define "Initial Population":
      AHA."Is Adults With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period"
    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"
    Denominator Exception
    /*
    @commentedOuf: Temporary removal of "Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD"
    @commentedOufReason: Negation issue noted in https://github.com/cqframework/cql-execution/issues/296, which is tied to https://oncprojectracking.healthit.gov/support/browse/BONNIEMAT-1455
    */
    
    
    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 "M"
        when Patient.gender = 'female' then "F"
        else null
      end
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR SDE Sex
    define "SDE Sex":
      SDE."SDE Sex"
    Library Name Name
    AHAOverall Heart Failure Outpatient Encounter
    /*
    @description: Returns certain finished encounter types that overlap a Heart Failure condition and are during the measurement 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)
                    * home healthcare services (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016)
                    * nursing facility visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012)
                    * office visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001)
                    * outpatient consolutations (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008)
    */   
    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 day of "Measurement Period"
          and QualifyingEncounter.isFinished()
    Library Name Name
    AHAOverall Moderate or Severe LVSD Findings
    /*
    @description: Returns a union  of the following:
                    * Observations where the final, amended or correction ejection fraction result is <= 40
                    * Moderate or Severe LVSD conditions where the diagnosis has been confirmed as active
    */  
    define "Moderate or Severe LVSD Findings":
      ( [Observation: "Ejection Fraction"] EjectionFraction
          where EjectionFraction.value as Quantity <= 40 '%'
            and EjectionFraction.status in {'final', 'amended', 'corrected'} 
       )
       union ( 
               ( [Condition: "Moderate or Severe LVSD"]
                 union ( [Condition: "Left ventricular systolic dysfunction (disorder)"] LVSDDiagnosis
                           where LVSDDiagnosis.severity in "Moderate or Severe" )
                ) ModerateOrSevereLVSD   
                where ModerateOrSevereLVSD.isConfirmedActiveDiagnosis()
              )
    Library Name Name
    AHAOverall Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD
    /*
    @description: Returns heart failure outpatient encounters that start before the end of a moderate or severe LVSD finding
    */ 
    define "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD":
        "Heart Failure Outpatient Encounter" HFOutpatientEncounter
            with "Moderate or Severe LVSD Findings" LVSDFindings
                such that Coalesce(LVSDFindings.prevalenceInterval(), LVSDFindings.effective.toInterval()) starts before end of HFOutpatientEncounter.period
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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 ( )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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
    HFBetaBlockerTherapyforLVSDFHIR 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
    /*
    @description: Returns certain finished encounter types that occurred during the measurement period: 
                    * office visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001)
                    * outpatient consolutations (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008)
                    * nursing facility visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012)
                    * 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)
                    * home healthcare services (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016)
                    * patient provider interactions (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1012) 
    */          
    define "Qualifying Outpatient Encounter During Measurement Period":
        ( [Encounter: "Office Visit"]
            union [Encounter: "Outpatient Consultation"]
            union [Encounter: "Nursing Facility Visit"]
            union [Encounter: "Care Services in Long Term Residential Facility"]
            union [Encounter: "Home Healthcare Services"]
            union [Encounter: "Patient Provider Interaction"] ) ValidEncounter
          where ValidEncounter.period during day of "Measurement Period"
            and ValidEncounter.isFinished()
    Library Name Name
    AHAOverall Is Adults With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period
    /*
    @description: Returns true if the patient meets the following criteria:
                    * 18 years of age or older, has two 
                    * Has two Qualifying Outpatient Encounters During Measurement Period
                    * Has a Heart Failure Outpatient Encounter
    */           
    define "Is Adults With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period":
      AgeInYearsAt(date from start of "Measurement Period") >= 18
        and exists ( "Qualifying Outpatient Encounter During Measurement Period" Encounter1
            with "Qualifying Outpatient Encounter During Measurement Period" Encounter2
              such that Encounter2.id !~ Encounter1.id
        )
        and exists "Heart Failure Outpatient Encounter"
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR Initial Population
    define "Initial Population":
      AHA."Is Adults With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period"
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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 Type"] Payer
        return {
          code: Payer.type,
          period: Payer.period
        }
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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
    HFBetaBlockerTherapyforLVSDFHIR SDE Ethnicity
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
    Library Name Name
    AHAOverall Has Heart Transplant
    /*
    @description: Returns completed heart tansplant procedures that start before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
    */ 
    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
    /*
    @description: Returns true if patient has confirmed heart transplant complications that start before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
    */ 
    define "Has Heart Transplant Complications":
      exists ( 
              [Condition: "Heart Transplant Complications"] HeartTransplantComplications
                let diagnosisStart: Coalesce( HeartTransplantComplications.recordedDate, start of HeartTransplantComplications.prevalenceInterval() )  
                with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                  such that diagnosisStart before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
                where HeartTransplantComplications.isConfirmedActiveDiagnosis()
              )
    Library Name Name
    AHAOverall Has Left Ventricular Assist Device
    /*
    @description: Returns true if patient has a completed LVAD placement that starts before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
    */ 
    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
    /*
    @description: Returns true if patient has active LVAD complications that start before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
    */ 
    define "Has Left Ventricular Assist Device Complications":
      exists (
                [Condition: "Left Ventricular Assist Device Complications"] LVADComplications
                  let diagnosisStart: Coalesce( LVADComplications.recordedDate, start of LVADComplications.prevalenceInterval() ) 
                  with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                    such that diagnosisStart before end of ModerateOrSevereLVSDHFOutpatientEncounter.period  
                  where LVADComplications.isConfirmedActiveDiagnosis()
              )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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
    HFBetaBlockerTherapyforLVSDFHIR SDE Race
    define "SDE Race":
      SDE."SDE Race"
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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
    HFBetaBlockerTherapyforLVSDFHIR Has Hypotension Diagnosis
    define "Has Hypotension Diagnosis":
      exists ( ["Condition": "Hypotension"] Hypotension
          where Hypotension.overlapsHeartFailureOutpatientEncounter ( )
            and Hypotension.isConfirmedActiveDiagnosis ( )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR Has Asthma Diagnosis
    define "Has Asthma Diagnosis":
      exists ( [Condition: "Asthma"] Asthma
          where Asthma.overlapsHeartFailureOutpatientEncounter ( )
            and Asthma.isConfirmedActiveDiagnosis ( )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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.isConfirmedActiveDiagnosis ( )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR Has Bradycardia Diagnosis
    define "Has Bradycardia Diagnosis":
      exists ( [Condition: "Bradycardia"] Bradycardia
          where Bradycardia.overlapsHeartFailureOutpatientEncounter ( )
            and Bradycardia.isConfirmedActiveDiagnosis ( )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR Has Allergy or Intolerance to Beta Blocker Therapy Ingredient
    /*
    @commentedOut: implies logic
    @commentedOutReason: implies not available in cql-execution. Reference https://github.com/cqframework/cql-execution/issues/319.
    */
    
    
    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 ( /*https://oncprojectracking.healthit.gov/support/browse/BONNIEMAT-1771 - issue with implies operator tied to a non-supported feature in cql-exectuion 
                          For cql-execution issue, reference https://github.com/cqframework/cql-execution/issues/319.
                           ( BetaBlockerAllergyIntolerance.clinicalStatus is not null implies 
                                 BetaBlockerAllergyIntolerance.clinicalStatus !~ QICoreCommon."allergy-inactive" ) 
                            or */
              BetaBlockerAllergyIntolerance.clinicalStatus ~ QICoreCommon."allergy-active"
            )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR Has Atrioventricular Block Diagnosis
    define "Has Atrioventricular Block Diagnosis":
      exists ( [Condition: "Atrioventricular Block"] AtrioventricularBlock
          where AtrioventricularBlock.overlapsHeartFailureOutpatientEncounter ( )
            and AtrioventricularBlock.isConfirmedActiveDiagnosis ( )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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.isConfirmedActiveDiagnosis ( )
      )
    Library Name Name
    HFBetaBlockerTherapyforLVSDFHIR 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
    HFBetaBlockerTherapyforLVSDFHIR 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
    HFBetaBlockerTherapyforLVSDFHIR Denominator Exceptions
    /*
    @commentedOuf: Temporary removal of "Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD"
    @commentedOufReason: Negation issue noted in https://github.com/cqframework/cql-execution/issues/296, which is tied to https://oncprojectracking.healthit.gov/support/browse/BONNIEMAT-1455
    */
    
    
    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
    /*
    @description: Returns true if the given MedicationRequest is ordered during the heart failure outpatient encounter with history of moderate or severe LVSD at any point
    */
    define fluent function isOrderedDuringHeartFailureOutpatientEncounter(MedicationRequest MedicationRequest): 
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                where MedicationRequest.authoredOn during day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                  and MedicationRequest.status in {'active', 'completed'}
                  and MedicationRequest.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
                  /*Issue: The logic commented out below was added to the logic due to an issue described in the authoring patterns for QI-Core: https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns---QICore-v4.1.1#medication-ordered. However, when this logic is present, it causes an issue in Coverage calculation for resources that must be QI-Core compliant, because the inverse cannot be tested for a QI-Core MedicationRequest profile instance. This logic was commented out to achieve 100% Coverage. This requirement is really to handle what would happen if a MedicationRequest instance that could be set to 'false' were provided, but this should not happen within a trusted environment where QI-Core profile instances must be provided.*/
                  // and MedicationRequest.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, or has an abatement date the resulting 
    interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
    */
    define fluent function prevalenceInterval(condition Condition):
    if condition.clinicalStatus ~ "active"
      or condition.clinicalStatus ~ "recurrence"
      or condition.clinicalStatus ~ "relapse" then
      Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
    else
        (end of condition.abatementInterval()) abatementDate
        return if abatementDate is null then
          Interval[start of condition.onset.toInterval(), abatementDate)
        else
          Interval[start of condition.onset.toInterval(), abatementDate]
    Library Name Name
    AHAOverall isConfirmedActiveDiagnosis
    /*
    @description: Returns true if the given Condition is confirmed as active
    */
    define fluent function isConfirmedActiveDiagnosis(condition Condition):
        condition.isActive()
            and condition.verificationStatus ~ QICoreCommon."confirmed"
    Library Name Name
    QICoreCommon 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"
    Library Name Name
    AHAOverall isFinished
    /*
    @description: Returns true if the given Encounter is finished
    */
    define fluent function isFinished(Encounter Encounter):
        Encounter.status = 'finished'
    Library Name Name
    AHAOverall overlapsAfterHeartFailureOutpatientEncounter
    /*
    @overloaded
    @description: Returns true if the given MedicationRequest overlaps after the day of the heart failure outpatient encounter with history of moderate or severe LVSD
    */                    
    define fluent function overlapsAfterHeartFailureOutpatientEncounter(MedicationRequest MedicationRequest): 
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                 where First( ( collapse (MedicationRequest.dosageInstruction.timing.repeat.bounds DoseTime
                                            return DoseTime.toInterval()) ) DrugPeriods
                               sort by start of $this ) overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period 
                   and MedicationRequest.status in { 'active', 'completed' } 
                   and MedicationRequest.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
                   /*Issue: The logic commented out below was added to the logic due to an issue described in the authoring patterns for QI-Core: https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns---QICore-v4.1.1#medication-ordered. However, when this logic is present, it causes an issue in Coverage calculation for resources that must be QI-Core compliant, because the inverse cannot be tested for a QI-Core MedicationRequest profile instance. This logic was commented out to achieve 100% Coverage. This requirement is really to handle what would happen if a MedicationRequest instance that could be set to 'false' were provided, but this should not happen within a trusted environment where QI-Core profile instances must be provided.*/
                   // and Event.doNotPerform is not true 
              )
    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
    AHAOverall overlapsHeartFailureOutpatientEncounter
    /*
    @description: Returns true if the given Condition overlaps the heart failure outpatient encounter with history of moderate or severe LVSD at any point
    */
    define fluent function overlapsHeartFailureOutpatientEncounter(Condition Condition): 
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
                where Condition.prevalenceInterval() overlaps day of ModerateOrSevereLVSDHFOutpatientEncounter.period
                  and Condition.isConfirmedActiveDiagnosis()
              )