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: Heart Failure (HF): Angiotensin-Converting Enzyme (ACE) Inhibitor or Angiotensin Receptor Blocker (ARB) or Angiotensin Receptor-Neprilysin Inhibitor (ARNI) Therapy for Left Ventricular Systolic Dysfunction (LVSD)FHIR

Official URL: https://madie.cms.gov/Measure/CMS135FHIRACEIorARBorARNIforHF | Version: 1.1.000
Active as of 2026-01-16 | Responsible: American Heart Association | Computable Name: CMS135FHIRACEIorARBorARNIforHF
Other Identifiers: Short Name: CMS135FHIR (use: usual, ), UUID:86136d6c-dbe1-4b7f-89f3-406cb90f08d5 (use: official, ), UUID:a0aa7f51-9882-4ceb-b4e5-bb94669b62ca (use: official, ), Endorser: 0081e (use: official, ), Publisher: 135FHIR (use: official, )
Copyright/Legal: Copyright 2025 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 ACE inhibitor or ARB or ARNI therapy during the measurement period

Metadata
Title | Heart Failure (HF): Angiotensin-Converting Enzyme (ACE) Inhibitor or Angiotensin Receptor Blocker (ARB) or Angiotensin Receptor-Neprilysin Inhibitor (ARNI) Therapy for Left Ventricular Systolic Dysfunction (LVSD)FHIR
Version | 1.1.000
Short Name | CMS135FHIR
GUID (Version Independent) | urn:uuid:86136d6c-dbe1-4b7f-89f3-406cb90f08d5
GUID (Version Specific) | urn:uuid:a0aa7f51-9882-4ceb-b4e5-bb94669b62ca
CMS Identifier | 135FHIR
CMS Consensus Based Entity Identifier | 0081e
Effective Period | 2026-01-01 through 2026-12-31
Steward (Publisher) | American Heart Association
Developer | American Heart Association
Developer | American Medical Association (AMA)
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 ACE inhibitor or ARB or ARNI therapy during the measurement period
Copyright | Copyright 2025 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-20234 American Medical Association. LOINC(R) is copyright 2004-20234 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-20234 International Health Terminology Standards Development Organisation. ICD-10 is copyright 20234 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 | Use of ACE inhibitor, ARB, or ARNI therapy has been associated with improved outcomes in patients with reduced LVEF. Long-term therapy with ARBs have also been shown to reduce morbidity and mortality, especially in ACE inhibitor--intolerant patients. More recently, ARNI therapy has also been shown to more significantly improve outcomes, such that the newest guidelines recommend replacement of ACE inhibitors or ARBs with ARNI therapy in eligible patients. However, despite the benefits of these drugs, use of ACE inhibitor, ARB, or ARNI remains suboptimal.
Clinical Recommendation Statement | In patients with Heart Failure with Reduced Ejection Fraction (HFrEF) and New York Heart Association (NYHA) class II to III symptoms, the use of ARNI is recommended to reduce morbidity and mortality (Class I, Level of Evidence A) (Heidenreich et al., 2022). In patients with previous or current symptoms of chronic HFrEF, the use of angiotension-converting enzyme inhibitors (ACEi) is beneficial to reduce morbidity and mortality when the use of ARNI is not feasible (Class I, Level of Evidence A) (Heidenreich et al., 2022). In patients with previous or current symptoms of chronic HFrEF who are intolerant to ACEi because of cough or angioedema and when the use of ARNI is not feasible, the use of ARB is recommended to reduce morbidity and mortality (Class I, Level of Evidence A) (Heidenreich et al., 2022). In patients with chronic symptomatic HFrEF NYHA class II or III who tolerate an ACEi or ARB, replacement by an ARNI is recommended to further reduce morbidity and mortality (Class I, Level of Evidence B-R) (Heidenreich et al., 2022). ARNI should not be administered concomitantly with ACEi or within 36 hours of the last dose of an ACEi (Class II: Harm, Level of Evidence B-R) (Heidenreich et al., 2022). ARNI should not be administered to patients with any history of angioedema (Class III: Harm, Level of Evidence C-LD) (Heidenreich et al., 2022). ACEi should not be administered to patients with any history of angioedema (Class III: Harm, Level of Evidence C-LD) (Heidenreich et al., 2022). Drugs Commonly Used for Stage C HFrEF (abbreviated to align with focus of measure to include only ACE inhibitors, ARB and ARNI therapy)
Drug | Initial Daily Dose(s) | Target Dose(s) | Mean Doses Achieved in Clinical Trials
--- | --- | --- | ---
ACEi | <br /> | <br /> | <br />
Captopril | 6.25 mg 3 times | 50 mg 3 times | 122.7 mg total daily
Enalapril | 2.5 mg twice | 10 to 20 mg twice | 16.6 mg total daily
Fosinopril | 5 to 10 mg once | 40 mg once | N/A
Lisinopril | 2.5 to 5 mg once | 20 to 40 mg once | 32.5 to 35.0 mg total daily
Perindopril | 2 mg once | 8 to 16 mg once | N/A
Quinapril | 5 mg twice | 20 mg twice | N/A
Ramipril | 1.25 to 2.5 mg once | 10 mg once | N/A
Trandolapril | 1 mg once | 4 mg once | N/A
ARB | <br /> | <br /> | <br />
Candesartan | 4 to 8 mg once | 32 mg once | 24 mg total daily
Losartan | 25 to 50 mg once | 50 to 150 mg once | 129 mg total daily
Valsartan | 20 to 40 mg twice | 160 mg twice | 254 mg total daily
ARNI | <br /> | <br /> | <br />
Sacubitril-valsartan | 49/51 mg twice (sacubitril/valsartan) | 97/103 mg twice (sacubitril/valsartan) | 182/193 mg (sacubitril/valsartan) total daily (therapy may be initiated at 24/26 mg twice)
Citation | Heidenreich, P.A., Bozkurt, B, Aguilar, D., ... Allen, L. A. (2022). 2022 AHA/ACC/HFSA Guideline for the Management of Heart Failure A report of the American College of Cardiology/American Heart Association Joint Committee on Clinical Practice Guidelines. Circulation, 145(18), e895-e1032. doi: 10.1161/CIR.0000000000001063
Definition | Moderate or Severe LVSD: LVEF \<=40% corresponds to qualitative documentation of moderate dysfunction or severe dysfunction (LVSD). The LVSD may be determined by quantitative or qualitative assessment, which may be current or historical. Examples of a quantitative or qualitative assessment may include an echocardiogram: 1. that provides a numerical value of LVSD or 2. that uses descriptive terms such as moderately or severely depressed left ventricular systolic function. Any current or prior ejection fraction study documenting LVSD can be used to identify patients.
Definition | Prescribed: Denotes that a prescription has been given to the patient for ACE inhibitor or ARB or ARNI therapy at one or more visits in the measurement period OR that the patient is already taking an ACE inhibitor or ARB or ARNI therapy as documented in their current medication list
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. The requirement of two or more visits is used to establish that the eligible clinician has an existing relationship with the patient. 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." Eligible clinicians who have given a prescription for or whose patient is already taking an Angiotensin-Converting Enzyme Inhibitor (ACEI) or Angiotensin Receptor Blocker (ARB) would meet performance for this measure. Other combination therapies that consist of an ACEI plus diuretic, ARB + neprilysin inhibitor (ARNI), ARB plus diuretic, ACEI plus calcium channel blocker, ARB plus calcium channel blocker, or ARB plus calcium channel blocker plus diuretic would also meet performance for this measure. This FHIR-based measure has been derived from the QDM-based measure CMS135v14. 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
Initial Population | ID: InitialPopulation_1 Description: 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 Criteria: Initial Population
Denominator | ID: Denominator_1 Description: Equals Initial Population with a current or prior LVEF \<= 40% Criteria: Denominator
Denominator Exclusion | ID: DenominatorExclusion_1 Description: 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 Criteria: Denominator Exclusions
Denominator Exception | ID: DenominatorException_1 Description: * Documentation of medical reason(s) for not prescribing ACE inhibitor or ARB or ARNI therapy (e.g., pregnancy, renal failure due to ACEI, allergy, intolerance, other medical reasons). * Documentation of patient reason(s) for not prescribing ACE inhibitor or ARB or ARNI therapy (e.g., patient declined, other patient reasons). Criteria: Denominator Exceptions
Numerator | ID: Numerator_1 Description: Patients who were prescribed or already taking ACE inhibitor or ARB or ARNI therapy during the measurement period Criteria: Numerator
Supplemental Data Guidance Guidance | <p>For every patient evaluated by this measure also identify payer, race, ethnicity and sex</p>
Supplemental Data Elements
Supplemental Data Element | ID: sde-ethnicity Usage Code: Supplemental Data Description: SDE Ethnicity Logic Definition: SDE Ethnicity
Supplemental Data Element | ID: sde-payer Usage Code: Supplemental Data Description: SDE Payer Logic Definition: SDE Payer
Supplemental Data Element | ID: sde-race Usage Code: Supplemental Data Description: SDE Race Logic Definition: SDE Race
Supplemental Data Element | ID: sde-sex Usage Code: Supplemental Data Description: SDE Sex Logic Definition: SDE Sex
Measure Logic
Primary Library | CMS135FHIRACEIorARBorARNIforHF
Contents | Population Criteria Logic Definitions Terminology Dependencies Data Requirements Parameters
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
    define "Initial Population":
      AHA."Is Adult With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period"
Definition
Denominator
    define "Denominator":
      "Initial Population"
        and exists AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD"
Definition
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"
Definition
Denominator Exception
    define "Denominator Exceptions":
      "Has Medical or Patient Reason for Not Ordering ACEI or ARB or ARNI"
        or "Has Allergy or Intolerance to ACEI or ARB or ARNI Ingredient"
        or "Has Diagnosis of Allergy or Intolerance to ACEI or ARB"
        or "Has Diagnosis of Pregnancy"
        or "Has Diagnosis of Renal Failure Due to ACEI"
Definition
Numerator
    define "Numerator":
      "Has ACEI or ARB or ARNI Ordered"
        or "Is Currently Taking ACEI or ARB or ARNI"
Definition
Logic Definitions
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Sex":
      case
        when Patient.sex() = '248153007' then "Male (finding)"
        when Patient.sex() = '248152002' then "Female (finding)"
        else null
      end
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Payer":
      [USQualityCore.Coverage: type in "Payer Type"] Payer
        return {
          code: Payer.type,
          period: Payer.period
        }
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Ethnicity":
      (Patient.ethnicity()) E
        return Tuple {
          codes: { E.ombCategory } union E.detailed,
          display: E.text
        }
Logic Definition | Library Name: SupplementalDataElements
    define "SDE Race":
      (Patient.race()) R
        return Tuple {
          codes: R.ombCategory union R.detailed,
          display: R.text
        }
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "SDE Sex":
      SDE."SDE Sex"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Has ACEI or ARB or ARNI Ordered":
      exists ( [MedicationRequest: medication in "ACE Inhibitor or ARB or ARNI"] ACEIOrARBOrARNIOrdered
          where ACEIOrARBOrARNIOrdered.isOrderedDuringHeartFailureOutpatientEncounter ( )
      )
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Is Currently Taking ACEI or ARB or ARNI":
      exists ( [MedicationRequest: medication in "ACE Inhibitor or ARB or ARNI"] ActiveACEIOrARBOrARNI
          where ActiveACEIOrARBOrARNI.overlapsAfterHeartFailureOutpatientEncounter ( )
      )
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Numerator":
      "Has ACEI or ARB or ARNI Ordered"
        or "Is Currently Taking ACEI or ARB or ARNI"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Initial Population":
      AHA."Is Adult With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Denominator":
      "Initial Population"
        and exists AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "SDE Payer":
      SDE."SDE Payer"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    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"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "SDE Race":
      SDE."SDE Race"
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Has Medical or Patient Reason for Not Ordering ACEI or ARB or ARNI":
      exists ( [MedicationNotRequested: medication in "ACE Inhibitor or ARB or ARNI"] NoACEIOrARBOrARNIOrdered
          where NoACEIOrARBOrARNIOrdered.isMedicationNotRequestedOrderedDuringHeartFailureOutpatientEncounter ( )
            and ( NoACEIOrARBOrARNIOrdered.reasonCode in "Medical Reason"
                or NoACEIOrARBOrARNIOrdered.reasonCode in "Patient Reason"
                or NoACEIOrARBOrARNIOrdered.reasonCode in "Patient Reason for ACE Inhibitor or ARB Decline"
            )
      )
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Has Allergy or Intolerance to ACEI or ARB or ARNI Ingredient":
      exists ( ( [AllergyIntolerance: "ACE Inhibitor or ARB or ARNI Ingredient"]
          union [AllergyIntolerance: "Substance with angiotensin-converting enzyme inhibitor mechanism of action (substance)"]
          union [AllergyIntolerance: "Substance with angiotensin II receptor antagonist mechanism of action (substance)"]
          union [AllergyIntolerance: "Substance with neprilysin inhibitor mechanism of action (substance)"] ) ACEIOrARBOrARNIAllergyIntolerance
          where ACEIOrARBOrARNIAllergyIntolerance.overlapsAfterHeartFailureOutpatientEncounter ( )
      )
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Has Diagnosis of Allergy or Intolerance to ACEI or ARB":
      exists ( (
        ["Condition": "Allergy to ACE Inhibitor or ARB"]
          union ["Condition": "Intolerance to ACE Inhibitor or ARB"]
       ) ACEIOrARBAllergyOrIntoleranceDiagnosis
          where ACEIOrARBAllergyOrIntoleranceDiagnosis.overlapsAfterHeartFailureOutpatientEncounter ( )
      )
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Has Diagnosis of Pregnancy":
      exists ( ( [Condition: "Pregnancy"] ) PregnancyDiagnosis
          with AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
            such that PregnancyDiagnosis.prevalenceInterval ( ) starts 9 months or less before or on start of ModerateOrSevereLVSDHFOutpatientEncounter.period
              and PregnancyDiagnosis.isVerified ( )
      )
        or exists ( [USCore.ObservationPregnancyStatusProfile] PregnantObservation
            with AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
              such that PregnantObservation.effective.toInterval ( ) starts 9 months or less before or on start of ModerateOrSevereLVSDHFOutpatientEncounter.period
                and ( PregnantObservation.value in "Pregnancy"
                    and PregnantObservation.status in { 'final', 'amended', 'corrected' }
                )
        )
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Has Diagnosis of Renal Failure Due to ACEI":
      exists ( ( [Condition: "Acute renal failure caused by angiotensin-converting-enzyme inhibitor (disorder)"] ) RenalFailureDueToACEI
          where RenalFailureDueToACEI.overlapsHeartFailureOutpatientEncounter ( )
      )
Logic Definition | Library Name: CMS135FHIRACEIorARBorARNIforHF
    define "Denominator Exceptions":
      "Has Medical or Patient Reason for Not Ordering ACEI or ARB or ARNI"
        or "Has Allergy or Intolerance to ACEI or ARB or ARNI Ingredient"
        or "Has Diagnosis of Allergy or Intolerance to ACEI or ARB"
        or "Has Diagnosis of Pregnancy"
        or "Has Diagnosis of Renal Failure Due to ACEI"
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
    /*
    @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 ToDateTime(value dateTime): 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 ToDateTime(value instant): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToDate(value date): value.value
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity)
    value to a CQL Quantity
    @comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity
    has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`)
    an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used.
    @seealso: ToCalendarUnit
    */
    define function ToQuantity(quantity FHIR.Quantity):
        case
            when quantity is null then null
            when quantity.value is null then null
            when quantity.comparator is not null then
                Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')
            when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
                  or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
                System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
            else
                Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')
        end
Logic Definition | Library Name: FHIRHelpers
    /*
    @description: Converts a UCUM definite duration unit to a CQL calendar duration
    unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities)
    topic of the CQL specification.
    @comment: Note that for durations above days (or weeks), the conversion is understood to be approximate
    */
    define function ToCalendarUnit(unit System.String):
        case unit
            when 'ms' then 'millisecond'
            when 's' then 'second'
            when 'min' then 'minute'
            when 'h' then 'hour'
            when 'd' then 'day'
            when 'wk' then 'week'
            when 'mo' then 'month'
            when 'a' then 'year'
            else unit
        end
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value EncounterStatus): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value ObservationStatus): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value MedicationRequestStatus): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value MedicationRequestIntent): value.value
Logic Definition | Library Name: FHIRHelpers
    define function ToString(value ProcedureStatus): value.value
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
        }
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 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: 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 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: FHIRCommon
    /*
    @description: Returns true if the given condition either has no verification status or has a verification status of confirmed, unconfirmed, provisional, or differential
    */
    define fluent function isVerified(condition FHIR.Condition):
      condition.verificationStatus is not null implies
        (condition.verificationStatus ~ "confirmed"
          or condition.verificationStatus ~ "unconfirmed"
          or condition.verificationStatus ~ "provisional"
          or condition.verificationStatus ~ "differential"
        )
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 the single extension (if present) on the given element with the specified url.
    @comment: This function uses singleton from to ensure that a run-time exception is thrown if there
    is more than one extension on the given element with the specified url.
    */
    define fluent function ext(element Element, url String):
      singleton from element.exts(url)
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns any extensions defined on the given element with the specified url.
    */
    define fluent function exts(element Element, url String):
      element.extension E
        where E.url = url
        return E
Logic Definition | Library Name: FHIRCommon
    /*
    @description: Returns true if the given condition either has no verification status or has a verification status of confirmed, unconfirmed, provisional, or differential
    */
    define fluent function isVerified(allergyIntolerance FHIR.AllergyIntolerance):
      allergyIntolerance.verificationStatus is not null implies
        (allergyIntolerance.verificationStatus ~ "allergy-confirmed"
          or allergyIntolerance.verificationStatus ~ "allergy-unconfirmed"
        )
Logic Definition | Library Name: AHAOverall
    define "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"]
      )
Logic Definition | Library Name: AHAOverall
    /*
    @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 consultation (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008)
    */
    define "Heart Failure Outpatient Encounter":
      "Outpatient Encounter" QualifyingEncounter
        with ( [Condition: "Heart Failure"] ) HeartFailure
          such that HeartFailure.prevalenceInterval ( ) overlaps day of QualifyingEncounter.period
            and HeartFailure.isVerified ( )
        where QualifyingEncounter.period during day of "Measurement Period"
          and QualifyingEncounter.isEncounterFinished ( )
Logic Definition | Library Name: AHAOverall
    /*
    @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":
      ( [ObservationClinicalResult: "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.isVerified ( )
        )
Logic Definition | Library Name: AHAOverall
    /*
    @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
Logic Definition | Library Name: AHAOverall
    define "Outpatient Encounter or Patient Provider Interaction":
      "Outpatient Encounter"
        union [Encounter: "Patient Provider Interaction"]
Logic Definition | Library Name: AHAOverall
    /*
    @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 consultation (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":
      "Outpatient Encounter or Patient Provider Interaction" ValidEncounter
        where ValidEncounter.period during day of "Measurement Period"
          and ValidEncounter.isEncounterFinished ( )
Logic Definition | Library Name: AHAOverall
    /*
    @description: Returns true if the patient meets the following criteria:
                    * 18 years of age or older,
                    * Has two Qualifying Outpatient Encounters During Measurement Period
                    * Has a Heart Failure Outpatient Encounter
    */
    define "Is Adult 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"
Logic Definition | Library Name: AHAOverall
    /*
    @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'
      )
Logic Definition | Library Name: AHAOverall
    /*
    @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(start of HeartTransplantComplications.prevalenceInterval(), HeartTransplantComplications.recordedDate)
          with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
            such that date from diagnosisStart on or before date from end of ModerateOrSevereLVSDHFOutpatientEncounter.period
          where HeartTransplantComplications.isVerified ( )
      )
Logic Definition | Library Name: AHAOverall
    /*
    @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"] LVADPlacement
          with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
            such that LVADPlacement.performed.toInterval ( ) starts before day of end of ModerateOrSevereLVSDHFOutpatientEncounter.period
          where LVADPlacement.status = 'completed'
      )
Logic Definition | Library Name: AHAOverall
    /*
    @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(start of LVADComplications.prevalenceInterval(), LVADComplications.recordedDate)
          with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
            such that date from diagnosisStart on or before date from end of ModerateOrSevereLVSDHFOutpatientEncounter.period
          where LVADComplications.isVerified ( )
      )
Logic Definition | Library Name: AHAOverall
    /*
    @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' }
            and not exists ( ["TaskRejected"] TaskReject
                where TaskReject.focus.references ( MedicationRequest )
                  and TaskReject.code ~ USQualityCoreCommon."Fulfill"
            )
      )
Logic Definition | Library Name: AHAOverall
    /*
    @description: Returns true if the given Encounter is finished
    */
    define fluent function isEncounterFinished(Encounter Encounter):
      Encounter.status = 'finished'
Logic Definition | Library Name: AHAOverall
    /*
    @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 TimingBoundToInterval(MedicationRequest.authoredOn, DoseTime)
            )) 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' }
            and not exists ( ["TaskRejected"] TaskReject
                where TaskReject.focus.references ( MedicationRequest )
                  and TaskReject.code ~ USQualityCoreCommon."Fulfill"
            )
      )
Logic Definition | Library Name: AHAOverall
    /*
    @description: Converts the possible representations of the timing bound to an interval using the given date as an anchor for durations
    */
    define function TimingBoundToInterval(startDate System.DateTime, choice Choice<FHIR.Duration, FHIR.Range, FHIR.Period>):
      case
        when choice is FHIR.Period then
            choice as FHIR.Period
        when choice is FHIR.Range then
            Interval[startDate + (choice.low as Quantity), startDate + (choice.high as Quantity)]
        when choice is FHIR.Duration then
            Interval[startDate, startDate + (choice as FHIR.Duration))
        else
    		null as Interval<DateTime>
    	end
Logic Definition | Library Name: AHAOverall
    /*
    @description: Returns true if the given MedicationNotRequested overlaps after the day of the heart failure outpatient encounter with history of moderate or severe LVSD
    */
    define fluent function isMedicationNotRequestedOrderedDuringHeartFailureOutpatientEncounter(MedicationRequest MedicationNotRequested):
      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 { 'completed', 'active' }
            and MedicationRequest.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
            and not exists ( ["TaskRejected"] TaskReject
                where TaskReject.focus.references ( MedicationRequest )
                  and TaskReject.code ~ USQualityCoreCommon."Fulfill"
            )
      )
Logic Definition | Library Name: AHAOverall
    /*
    @overloaded
    @description: Returns true if the given AllergyIntolerance overlaps after the day of the heart failure outpatient encounter with history of moderate or severe LVSD
    */
    define fluent function overlapsAfterHeartFailureOutpatientEncounter(AllergyIntolerance AllergyIntolerance):
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
          where Interval[start of AllergyIntolerance.onset.toInterval ( ), AllergyIntolerance.lastOccurrence]overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period
            and AllergyIntolerance.isVerified ( )
      )
Logic Definition | Library Name: AHAOverall
    /*
    @overloaded
    @description: Returns true if the given Condition overlaps after the day of the heart failure outpatient encounter with history of moderate or severe LVSD
    */
    define fluent function overlapsAfterHeartFailureOutpatientEncounter(Condition Condition):
      exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
          where Condition.prevalenceInterval ( ) overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period
            and Condition.isVerified ( )
      )
Logic Definition | Library Name: AHAOverall
    /*
    @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.isVerified ( )
      )
Terminology
Code System | Description: Code system SNOMEDCT Resource: SNOMED CT (all versions) Canonical URL: `http://snomed.info/sct`
Code System | Description: Code system ConditionClinicalStatusCodes Resource: Condition Clinical Status Codes Canonical URL: `http://terminology.hl7.org/CodeSystem/condition-clinical`
Code System | Description: Code system ConditionVerificationStatusCodes Resource: ConditionVerificationStatus Canonical URL: `http://terminology.hl7.org/CodeSystem/condition-ver-status`
Code System | Description: Code system TaskCodeSystem Resource: Task Codes Canonical URL: `http://hl7.org/fhir/CodeSystem/task-code`
Code System | Description: Code system AllergyIntoleranceVerificationStatusCodes Resource: AllergyIntolerance Verification Status Canonical URL: `http://terminology.hl7.org/CodeSystem/allergyintolerance-verification`
Value Set | Description: Value set ACE Inhibitor or ARB or ARNI Resource: ACE Inhibitor or ARB or ARNI Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1139`
Value Set | Description: Value set Care Services in Long Term Residential Facility Resource: Care Services in Long Term Residential Facility Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014`
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 Nursing Facility Visit Resource: Nursing Facility Visit Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012`
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 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 Heart Failure Resource: Heart Failure Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.376`
Value Set | Description: Value set Ejection Fraction Resource: Ejection Fraction Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1134`
Value Set | Description: Value set Moderate or Severe LVSD Resource: Moderate or Severe LVSD Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1090`
Value Set | Description: Value set Moderate or Severe Resource: Moderate or Severe Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1092`
Value Set | Description: Value set Patient Provider Interaction Resource: Patient Provider Interaction Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1012`
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 Heart Transplant Resource: Heart Transplant Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.33`
Value Set | Description: Value set Heart Transplant Complications Resource: Heart Transplant Complications Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.56`
Value Set | Description: Value set Left Ventricular Assist Device Placement Resource: Left Ventricular Assist Device Placement Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.61`
Value Set | Description: Value set Left Ventricular Assist Device Complications Resource: Left Ventricular Assist Device Complications Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1178.58`
Value Set | Description: Value set Medical Reason Resource: Medical Reason Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1007`
Value Set | Description: Value set Patient Reason Resource: Patient Reason Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1008`
Value Set | Description: Value set Patient Reason for ACE Inhibitor or ARB Decline Resource: Patient Reason for ACE Inhibitor or ARB Decline Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1140`
Value Set | Description: Value set ACE Inhibitor or ARB or ARNI Ingredient Resource: ACE Inhibitor or ARB or ARNI Ingredient Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1489`
Value Set | Description: Value set Allergy to ACE Inhibitor or ARB Resource: Allergy to ACE Inhibitor or ARB Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1211`
Value Set | Description: Value set Intolerance to ACE Inhibitor or ARB Resource: Intolerance to ACE Inhibitor or ARB Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1212`
Value Set | Description: Value set Pregnancy Resource: Pregnancy Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.378`
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 | 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`
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 | Display: Left ventricular systolic dysfunction (disorder) Code: 134401001 System: `http://snomed.info/sct`
Direct Reference Code | Display: Fulfill Code: fulfill System: `http://hl7.org/fhir/CodeSystem/task-code`
Direct Reference Code | Display: Substance with angiotensin-converting enzyme inhibitor mechanism of action (substance) Code: 372733002 System: `http://snomed.info/sct`
Direct Reference Code | Display: Substance with angiotensin II receptor antagonist mechanism of action (substance) Code: 372913009 System: `http://snomed.info/sct`
Direct Reference Code | Display: Substance with neprilysin inhibitor mechanism of action (substance) Code: 786886009 System: `http://snomed.info/sct`
Direct Reference Code | Code: confirmed System: `http://terminology.hl7.org/CodeSystem/allergyintolerance-verification`
Direct Reference Code | Code: unconfirmed System: `http://terminology.hl7.org/CodeSystem/allergyintolerance-verification`
Direct Reference Code | Display: Acute renal failure caused by angiotensin-converting-enzyme inhibitor (disorder) Code: 422593004 System: `http://snomed.info/sct`
Dependencies
Dependency | Description: USQualityCore model information Resource: `https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild` Canonical URL: `https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild`
Dependency | Description: USCore model information Resource: http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived Canonical URL: `http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived`
Dependency | Description: FHIR model information Resource: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1 Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1`
Dependency | Description: Library SDE Resource: SupplementalDataElementsversion: null6.1.000) Canonical URL: `https://madie.cms.gov/Library/SupplementalDataElements|6.1.000`
Dependency | Description: Library FHIRHelpers Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1 Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1`
Dependency | Description: Library USCommon Resource: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot Canonical URL: `http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot`
Dependency | Description: Library FHIRCommon Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0 Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0`
Dependency | Description: Library AHA Resource: AHAOverallversion: null5.1.000) Canonical URL: `https://madie.cms.gov/Library/AHAOverall|5.1.000`
Dependency | Description: Library USQualityCoreCommon Resource: US Quality Core Commonversion: null0.1.0-cibuild) Canonical URL: `https://madie.cms.gov/Library/USQualityCoreCommon|0.1.0-cibuild`
Data Requirements
Data Requirement | Type: Patient Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-patient` Must Support Elements: ombCategory, detailed, text
Data Requirement | Type: Encounter Profile(s): Encounter Must Support Elements: type, period, id Code Filter(s): Path: type ValueSet: Care Services in Long Term Residential Facility
Data Requirement | Type: Encounter Profile(s): Encounter Must Support Elements: type, period, id Code Filter(s): Path: type ValueSet: Home Healthcare Services
Data Requirement | Type: Encounter Profile(s): Encounter Must Support Elements: type, period, id Code Filter(s): Path: type ValueSet: Nursing Facility Visit
Data Requirement | Type: Encounter Profile(s): Encounter Must Support Elements: type, period, id Code Filter(s): Path: type ValueSet: Office Visit
Data Requirement | Type: Encounter Profile(s): Encounter Must Support Elements: type, period, id Code Filter(s): Path: type ValueSet: Outpatient Consultation
Data Requirement | Type: Encounter Profile(s): Encounter Must Support Elements: status, period, id
Data Requirement | Type: Encounter Profile(s): Encounter Must Support Elements: type, period, id Code Filter(s): Path: type ValueSet: Patient Provider Interaction
Data Requirement | Type: Patient Profile(s): Patient Must Support Elements: birthDate
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: abatement, onset, recordedDate, clinicalStatus, verificationStatus
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code Code Filter(s): Path: code ValueSet: Heart Failure
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code, severity Code Filter(s): Path: code Code(s): SNOMED CT: 134401001 (Left ventricular systolic dysfunction (disorder)) Path: severity ValueSet: Moderate or Severe
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code Code Filter(s): Path: code ValueSet: Moderate or Severe LVSD
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code, recordedDate Code Filter(s): Path: code ValueSet: Heart Transplant Complications
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code, recordedDate Code Filter(s): Path: code ValueSet: Left Ventricular Assist Device Complications
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code Code Filter(s): Path: code ValueSet: Allergy to ACE Inhibitor or ARB
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code Code Filter(s): Path: code ValueSet: Intolerance to ACE Inhibitor or ARB
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code Code Filter(s): Path: code ValueSet: Pregnancy
Data Requirement | Type: Condition Profile(s): Condition Must Support Elements: code Code Filter(s): Path: code Code(s): SNOMED CT: 422593004 (Acute renal failure caused by angiotensin-converting-enzyme inhibitor (disorder))
Data Requirement | Type: Observation Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-clinical-result` Must Support Elements: code, value, status Code Filter(s): Path: code ValueSet: Ejection Fraction
Data Requirement | Type: Resource Profile(s): Resource Must Support Elements: id
Data Requirement | Type: MedicationRequest Profile(s): MedicationRequest Must Support Elements: authoredOn, timing, repeat, bounds, status, intent
Data Requirement | Type: MedicationRequest Profile(s): MedicationRequest Must Support Elements: medication, timing, repeat, bounds Code Filter(s): Path: medication ValueSet: ACE Inhibitor or ARB or ARNI
Data Requirement | Type: Task Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-taskrejected` Must Support Elements: focus, code
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: Procedure Profile(s): Procedure Must Support Elements: code, performed, status Code Filter(s): Path: code ValueSet: Heart Transplant Path: status Code(s): [not stated]: completed (completed)
Data Requirement | Type: Procedure Profile(s): Procedure Must Support Elements: code, performed, status Code Filter(s): Path: code ValueSet: Left Ventricular Assist Device Placement Path: status Code(s): [not stated]: completed (completed)
Data Requirement | Type: MedicationRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-medicationnotrequested` Must Support Elements: authoredOn, status, intent
Data Requirement | Type: MedicationRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-medicationnotrequested` Must Support Elements: medication, reasonCode Code Filter(s): Path: medication ValueSet: ACE Inhibitor or ARB or ARNI
Data Requirement | Type: AllergyIntolerance Profile(s): AllergyIntolerance Must Support Elements: verificationStatus, onset, lastOccurrence
Data Requirement | Type: AllergyIntolerance Profile(s): AllergyIntolerance Must Support Elements: code Code Filter(s): Path: code ValueSet: ACE Inhibitor or ARB or ARNI Ingredient
Data Requirement | Type: AllergyIntolerance Profile(s): AllergyIntolerance Must Support Elements: code Code Filter(s): Path: code Code(s): SNOMED CT: 372733002 (Substance with angiotensin-converting enzyme inhibitor mechanism of action (substance))
Data Requirement | Type: AllergyIntolerance Profile(s): AllergyIntolerance Must Support Elements: code Code Filter(s): Path: code Code(s): SNOMED CT: 372913009 (Substance with angiotensin II receptor antagonist mechanism of action (substance))
Data Requirement | Type: AllergyIntolerance Profile(s): AllergyIntolerance Must Support Elements: code Code Filter(s): Path: code Code(s): SNOMED CT: 786886009 (Substance with neprilysin inhibitor mechanism of action (substance))
Data Requirement | Type: Observation Profile(s): US Core Observation Pregnancy Status Profile Must Support Elements: effective, value, status Code Filter(s): Path: value ValueSet: Pregnancy
Parameters
Name | Use | Card. | Type | Documentation
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 |
Generated using version 0.5.4 of the sample-content-ig Liquid templates