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: Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department FHIR

Official URL: https://madie.cms.gov/Measure/CMS996FHIRAptTxforSTEMI Version: 1.2.001
Active as of 2024-12-18 Responsible: Centers for Medicare & Medicaid Services (CMS) Computable Name: CMS996FHIRAptTxforSTEMI
Other Identifiers: Short Name: CMS996FHIR (use: usual, ), UUID:a48685e0-4926-4ae8-9eb3-d8e8839b1704 (use: official, ), UUID:feb911dd-6b34-4b3f-866f-3059dd4d19d0 (use: official, ), Publisher: 996FHIR (use: official, )

Copyright/Legal: Limited proprietary coding is contained in these specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. All rights reserved.

LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc.

CPT(R) contained in the measure specifications is copyright 2004-2024 American Medical Association.

ICD-10 is copyright 2024 World Health Organization. All Rights Reserved.

Percentage of emergency department (ED) encounters for patients 18 years and older with a diagnosis of ST-segment elevation myocardial infarction (STEMI) that received appropriate treatment, defined as fibrinolytic therapy within 30 minutes of ED arrival, percutaneous coronary intervention (PCI) within 90 minutes of ED arrival, or transfer within 45 minutes of ED arrival

UNKNOWN

Title: Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department FHIR
Id: CMS996FHIRAptTxforSTEMI
Version: 1.2.001
Url: Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department FHIR
Short Name Identifier:

CMS996FHIR

Version Independent Identifier:

urn:uuid:a48685e0-4926-4ae8-9eb3-d8e8839b1704

Version Specific Identifier:

urn:uuid:feb911dd-6b34-4b3f-866f-3059dd4d19d0

Publisher (CMS) Identifier:

996FHIR

Effective Period: 2026-01-01..2026-12-31
Publisher: Centers for Medicare & Medicaid Services (CMS)
Author: Acumen, LLC
Description:

Percentage of emergency department (ED) encounters for patients 18 years and older with a diagnosis of ST-segment elevation myocardial infarction (STEMI) that received appropriate treatment, defined as fibrinolytic therapy within 30 minutes of ED arrival, percutaneous coronary intervention (PCI) within 90 minutes of ED arrival, or transfer within 45 minutes of ED arrival

Purpose:

UNKNOWN

Copyright:

Limited proprietary coding is contained in these specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. All rights reserved.

LOINC(R) copyright 2004-2024 Regenstrief Institute, Inc.

CPT(R) contained in the measure specifications is copyright 2004-2024 American Medical Association.

ICD-10 is copyright 2024 World Health Organization. All Rights Reserved.

Disclaimer:

These performance specifications are not clinical guidelines, do not establish a standard of medical care, and have not been tested for all potential applications.

THE MEASURES AND SPECIFICATIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.

Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].

Rationale:

Studies have shown that delays in the treatment of acute myocardial infarction (AMI) leads to increased risk of in-hospital mortality and morbidity, with nearly two lives per 1,000 patients lost per hour of delay in treatment (Solhpour & Yusuf, 2013; Fibrinolytic Therapy Trialists’ Collaborative Group, 1994). For patients receiving fibrinolytic therapy, the American Heart Association (AHA) estimates that 65 lives will be saved per 1,000 patients if treatment is administered within the first hour of symptom onset, and 131 lives will be saved per 1,000 patients treated if fibrinolytic therapy is delivered within the first three hours (O’Connor et al., 2010). The total ischemic time—that is, the time from onset of STEMI symptoms to the initiation of some form of reperfusion therapy—is the principal determinant of health outcomes for patients with an AMI, so timely care is essential to minimize disease morbidity and mortality. Primary PCI is the preferred treatment approach, with guidelines recommending initiation of PCI within 120 minutes from first medical contact (O’Gara et al., 2013). In situations where it is unlikely or impossible for a patient to receive primary PCI within the 120-minute timeframe, fibrinolytic therapy may be used for reperfusion and should be rapidly administered to reduce mortality and minimize morbidity; guidelines recommend that fibrinolytic therapy administration occur within 30 minutes of hospital arrival; this may also require rapid transfer for PCI (O’Gara et al., 2013). Implementation of an eCQM addressing appropriateness and effectiveness of care for STEMI patients in the ED has the potential to improve the delivery of care furthering alignment with current clinical practice guidelines, while reducing adverse health outcomes such as mortality, bleeding events, and reinfarction. Use of the eCQM could also reduce burden on facilities currently measured using the chart-abstracted Fibrinolytic Therapy Received within 30 Minutes of ED Arrival (OP-2) measure and broaden the population for which performance scores could be publicly reported.

Clinical recommendation statement:

Primary PCI in STEMI: The 2013 ACCF/AHA clinical practice guideline for the management of STEMI recommends that:

  • "Primary PCI should be performed in patients with STEMI and ischemic symptoms of less than 12 hours’ duration."
  • "Primary PCI should be performed in patients with STEMI and ischemic symptoms of less than 12 hours’ duration who have contraindications to fibrinolytic therapy, irrespective of the time delay from first medical contact."

Fibrinolytic Therapy when there is an Anticipated Delay to Performing Primary PCI within 120 Minutes of First Medical Contact: The 2013 American College of Cardiology Foundation (ACCF)/American Heart Association(AHA) clinical practice guideline for the management of STEMI recommends that:

  • "In the absence of contraindications, fibrinolytic therapy should be given to patients with STEMI and onset of ischemic symptoms within the previous 12 hours when it is anticipated that primary PCI cannot be performed within 120 minutes of first medical contact.”

Transfer to a PCI-Capable Hospital after Fibrinolytic Therapy: The 2013 ACCF/AHA clinical practice guideline for the management of STEMI recommends that:

  • Immediate transfer to a PCI-capable hospital for coronary angiography is recommended for suitable patients with STEMI who develop cardiogenic shock or acute severe heart failure (HF), irrespective of the time delay from MI onset.
  • Urgent transfer to a PCI-capable hospital for coronary angiography is reasonable for patients with STEMI who demonstrate evidence of failed reperfusion or reocclusion after fibrinolytic therapy.
  • Transfer to a PCI-capable hospital for coronary angiography is reasonable for patients with STEMI who have received fibrinolytic therapy even when hemodynamically stable and with clinical evidence of successful reperfusion. Angiography can be performed as soon as logistically feasible at the receiving hospital, and ideally within 24 hours, but should not be performed within the first 2 to 3 hours after administration of fibrinolytic therapy.
Guidance (Usage): In order to support the best outcomes for patients and align with other guidelines, PCI device deployment time should be used for calculating the “PCI is performed within 90 minutes of ED arrival” numerator criteria and not the start time of the procedure. This eCQM is an episode-based measure and should be reported for each instance of an ED encounter during the measurement period for patients with a STEMI. This FHIR-based measure has been derived from the QDM-based measure: CMS996v6. 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:
6633d92a6c1d307ea36e74c0
Initial Population: All emergency department encounters for patients 18 years and older at the start of the encounter with a diagnosis of ST-segment elevation myocardial infarction (STEMI) during an Emergency Department encounter that ends during the measurement period
Denominator: Equals Initial Population
Denominator Exclusion: Patients with the following conditions are excluded from measure denominator: At some point during ED encounter: - Allergic reaction to alteplase, streptokinase, anistreplase, tenecteplase, or reteplase Starts before the start of ED encounter and does not end before ED encounter: - Bleeding or bleeding diathesis (excluding menses) - Known malignant intracranial neoplasm (primary or metastatic) - Known structural cerebral vascular lesion (e.g., arteriovenous malformation) - Advanced dementia - Pregnancy - Diagnosis of allergy to thrombolytics At the start of ED encounter, or most recent dose within 90 days or less of ED encounter: -Active oral anticoagulant therapy Occurs 24 hours or less before start of ED encounter or during ED encounter: - Aortic dissection or ruptured aortic aneurysm, Angina pectoris with documented spasm, Aneurysm of heart, Ventricular aneurysm due to and following acute myocardial infarction (disorder), Takotsubo cardiomyopathy or syndrome - Severe neurologic impairment - Mechanical circulatory assist device placement or removal, including: aortic balloon pump, biventricular assist device, intra-aortic balloon, intra-aortic balloon counterpulsation, intra-aortic counterpulsation balloon pump, left ventricular device, percutaneous ventricular assist device, or ventricular assist device - Intubation, including endotracheal intubation, mechanical ventilation, nasotracheal intubation, or orotracheal intubation - Cardiopulmonary arrest, including: cardiac arrest, cardiopulmonary resuscitation (CPR), defibrillation, respiratory arrest, or ventricular fibrillation (V-fib), ventricular tachycardia (VT), or pulseless electrical activity (PEA); or, traumatic or prolonged (>10 minutes) CPR Occurs 21 days or less before start of ED encounter: - Major surgery Occurs 90 days before start of or at start of ED encounter: - Ischemic stroke - Significant facial and/or closed head trauma - Peptic ulcer Occurs 90 days or less before start of ED encounter: - Intracranial or intraspinal surgery With a discharge disposition of patient expired in the ED With a discharge disposition of left against medical advice With documentation of hospice services in the 6 months within start of ED encounter, or active hospice status at start of ED encounter
Numerator: Emergency department encounters with a diagnosis of STEMI: - where time from ED arrival to fibrinolysis is 30 minutes or fewer; OR - where PCI is performed within 90 minutes of arrival; OR - where the patient is discharged to an acute care facility within 45 minutes of ED arrival
Denominator Exception: Emergency department encounters where the patient received fibrinolytic therapy at another facility within 24 hours. Emergency department encounters with a documented reason for not administering fibrinolytic therapy within 30 minutes of ED arrival. Emergency department encounters with a documented reason for not performing a PCI within 90 minutes of ED arrival.
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
Libraries:
CMS996FHIRAptTxforSTEMI
Terminology and Other Dependencies:
  • Library/SupplementalDataElements|3.5.000
  • Library/FHIRHelpers|4.4.000
  • Library/CQMCommon|2.2.000
  • Library/QICoreCommon|2.1.000
  • Library/Status|1.8.000
  • AdministrativeGender
  • ActCode
  • Condition Clinical Status Codes
  • AllergyIntolerance Clinical Status Codes
  • International Classification of Diseases, 10th Revision, Clinical Modification (ICD-10-CM)
  • SNOMED CT (all versions)
  • Observation Category Codes
  • Logical Observation Identifiers, Names and Codes (LOINC)
  • Emergency Department Visit
  • STEMI
  • Fibrinolytic Therapy
  • Emergency Department Visit
  • Percutaneous Coronary Intervention
  • Discharge To Acute Care Facility
  • Payer
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.4
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.6
  • Active Bleeding or Bleeding Diathesis (Excluding Menses)
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.3
  • Cerebral Vascular Lesion
  • Dementia
  • Pregnancy
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.5
  • Anticoagulant Medications, Oral
  • Aortic Dissection
  • Neurologic impairment
  • Cardiopulmonary Arrest
  • Major Surgical Procedure
  • Endotracheal Intubation
  • Mechanical Circulatory Assist Device
  • Ischemic Stroke
  • Closed Head Trauma
  • Active Peptic Ulcer
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.2
  • Patient Expired
  • Left Against Medical Advice
  • Encounter Inpatient
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
  • Hospice Care Ambulatory
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
  • Patient Refusal
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1282.2
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1282.1
  • Parameters:
    name use min max type
    Measurement Period In 0 1 Period
    SDE Sex Out 0 1 Coding
    Numerator Out 0 * Resource
    Denominator Out 0 * Resource
    SDE Payer Out 0 * Resource
    Initial Population Out 0 * Resource
    SDE Ethnicity Out 0 1 Resource
    Denominator Exclusions Out 0 * Resource
    SDE Race Out 0 1 Resource
    Denominator Exceptions Out 0 * Resource
    DataRequirements:
    Resource Type Resource Elements Valueset Name Valueset
    Patient(QICorePatient) ethnicity race
    Encounter(QICoreEncounter) type period status status.value class reasonCode hospitalization hospitalization.dischargeDisposition condition condition.reference condition.reference.value location location.type Emergency Department Evaluation and Management Visit Emergency Department Visit
    Encounter(QICoreEncounter) type period status status.value class reasonCode condition condition.reference condition.reference.value location location.type Emergency Department Evaluation and Management Visit Emergency Department Visit
    Encounter(QICoreEncounter) type period status status.value class reasonCode hospitalization hospitalization.dischargeDisposition condition condition.reference condition.reference.value location location.type Emergency Department Evaluation and Management Visit Emergency Department Visit
    Encounter(QICoreEncounter) type period status status.value class reasonCode hospitalization hospitalization.dischargeDisposition condition condition.reference condition.reference.value location location.type Emergency Department Evaluation and Management Visit Emergency Department Visit
    Encounter(QICoreEncounter) type hospitalization hospitalization.dischargeDisposition period condition condition.reference condition.reference.value location location.type status status.value Encounter Inpatient Encounter Inpatient
    Encounter(QICoreEncounter) type period condition condition.reference condition.reference.value location location.type status status.value Hospice Encounter http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
    Encounter(QICoreEncounter) type period status status.value class condition condition.reference condition.reference.value location location.type reasonCode Emergency Department Evaluation and Management Visit Emergency Department Visit
    Condition(QICoreCondition) id id.value code
    Condition(QICoreCondition) code clinicalStatus STEMI STEMI
    Condition(QICoreCondition) code Active Bleeding Excluding Menses or Bleeding Diathesis Active Bleeding or Bleeding Diathesis (Excluding Menses)
    Condition(QICoreCondition) code Malignant Intracranial Neoplasm Group http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.3
    Condition(QICoreCondition) code Cerebral Vascular Lesion Cerebral Vascular Lesion
    Condition(QICoreCondition) code Dementia and Related Intracranial Pathologies Dementia
    Condition(QICoreCondition) code Pregnant State Pregnancy
    Condition(QICoreCondition) code Allergy to thrombolytics http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.5
    Condition(QICoreCondition) code
    Condition(QICoreCondition) code Aortic Dissection or Ruptured Aortic Aneurysm Aortic Dissection
    Condition(QICoreCondition) code Neurologic impairment Neurologic impairment
    Condition(QICoreCondition) code
    Condition(QICoreCondition) code
    Condition(QICoreCondition) code
    Condition(QICoreCondition) code
    Condition(QICoreCondition) code
    Condition(QICoreCondition) code Cardiopulmonary Arrest Cardiopulmonary Arrest
    Condition(QICoreCondition) code Ischemic Stroke Ischemic Stroke
    Condition(QICoreCondition) code Closed Head and Facial Trauma Closed Head Trauma
    Condition(QICoreCondition) code Active Peptic Ulcer Active Peptic Ulcer
    Condition(QICoreCondition) code Hospice Diagnosis http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
    Condition(QICoreCondition) code
    Location(QICoreLocation) id id.value
    MedicationAdministration(QICoreMedicationAdministration) medication status status.value effective Fibrinolytic Therapy Fibrinolytic Therapy
    Procedure(QICoreProcedure) code performed status status.value Percutaneous Coronary Intervention Percutaneous Coronary Intervention
    Procedure(QICoreProcedure) code performed status status.value Major Surgical Procedure Major Surgical Procedure
    Procedure(QICoreProcedure) code performed status status.value Endotracheal Intubation Endotracheal Intubation
    Procedure(QICoreProcedure) code performed status status.value Insertion, Replacement, or Removal of Mechanical Circulatory Assist Device Mechanical Circulatory Assist Device
    Procedure(QICoreProcedure) code performed status status.value Intracranial or Intraspinal surgery http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.2
    Procedure(QICoreProcedure) code performed status status.value Hospice Care Ambulatory Hospice Care Ambulatory
    Coverage(QICoreCoverage) type period Payer Type Payer
    AllergyIntolerance(QICoreAllergyIntolerance) code clinicalStatus onset Thrombolytic medications http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.4
    AdverseEvent(QICoreAdverseEvent) event recordedDate recordedDate.value actuality actuality.value Thrombolytics Adverse Event http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.6
    Medication(QICoreMedication) id
    MedicationRequest(QICoreMedicationRequest) medication.reference status status.value intent intent.value authoredOn authoredOn.value
    MedicationRequest(QICoreMedicationRequest) medication status status.value intent intent.value authoredOn authoredOn.value Oral Anticoagulant Medications Anticoagulant Medications, Oral
    Observation(QICoreObservation) code value effective status status.value category
    ServiceRequest(QICoreServiceRequest) code authoredOn authoredOn.value status status.value intent intent.value Hospice Care Ambulatory Hospice Care Ambulatory
    Procedure(QICoreProcedureNotDone) code statusReason id id.value extension authoredOn Percutaneous Coronary Intervention Percutaneous Coronary Intervention
    Procedure(QICoreProcedureNotDone) code statusReason id id.value extension authoredOn Percutaneous Coronary Intervention Percutaneous Coronary Intervention
    MedicationAdministration(QICoreMedicationAdministrationNotDone) medication statusReason id id.value extension authoredOn Fibrinolytic Therapy Fibrinolytic Therapy
    MedicationAdministration(QICoreMedicationAdministrationNotDone) medication statusReason id id.value extension authoredOn Fibrinolytic Therapy Fibrinolytic Therapy
    Direct Reference Codes:
    display code system
    Male M http://hl7.org/fhir/administrative-gender
    Female F http://hl7.org/fhir/administrative-gender
    emergency EMER http://terminology.hl7.org/CodeSystem/v3-ActCode
    Active active http://terminology.hl7.org/CodeSystem/condition-clinical
    Active active http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical
    Long term (current) use of anticoagulants Z79.01 http://hl7.org/fhir/sid/icd-10-cm
    Angina pectoris with documented spasm I20.1 http://hl7.org/fhir/sid/icd-10-cm
    Ventricular aneurysm due to and following acute myocardial infarction (disorder) 723858002 http://snomed.info/sct
    Aneurysm of heart I25.3 http://hl7.org/fhir/sid/icd-10-cm
    Takotsubo cardiomyopathy (disorder) 441541008 http://snomed.info/sct
    Takotsubo syndrome I51.81 http://hl7.org/fhir/sid/icd-10-cm
    Discharge to home for hospice care (procedure) 428361000124107 http://snomed.info/sct
    Discharge to healthcare facility for hospice care (procedure) 428371000124100 http://snomed.info/sct
    survey survey http://terminology.hl7.org/CodeSystem/observation-category
    Hospice care [Minimum Data Set] 45755-6 http://loinc.org
    Yes (qualifier value) 373066001 http://snomed.info/sct
    Status post administration of tPA (rtPA) in a different facility within the last 24 hours prior to admission to current facility Z92.82 http://hl7.org/fhir/sid/icd-10-cm
    Logic Definitions:
    Group Scoring Population Criteria Expression
    6633d92a6c1d307ea36e74c0 Group scoring: proportion
    Type:

    Process

    Rate Aggregation: None
    Improvement Notation:

    Increased score indicates improvement

    Initial Population
    define "Initial Population":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18
    Denominator
    define "Denominator":
      "Initial Population"
    Denominator Exclusion
    define "Denominator Exclusions":
      "Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter"
        union "Adverse Effect to Thrombolytic Medications Before End of ED Encounter"
        union "Active Exclusion Diagnosis at Start of ED Encounter"
        union "Active use of Anticoagulants"
        union "Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start"
        union "Major Surgical Procedure 21 Days or Less Before Start of ED Encounter"
        union "Intubation or Mechanical Circulatory Assist Device Placement or Removal Procedure During ED Encounter or Within 24 Hours of ED Encounter Start"
        union "Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter"
        union "Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter"
        union "ED Encounter with Discharge Disposition as Patient Expired"
        union "ED Encounter with Discharge Disposition as Left Against Medical Advice"
        union "ED Encounter with Hospice Services"
    Numerator
    define "Numerator":
      "Fibrinolytic Therapy within 30 Minutes of Arrival"
        union "PCI within 90 Minutes of Arrival"
        union "ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival"
    Denominator Exception
    define "Denominator Exceptions":
      "Received tPA in Another Facility within 24 hours Prior to Admission"
        union "ED Encounter with a Documented Reason for No PCI Performed Within 90 Minutes of ED Arrival"
        union "ED Encounter with a Documented Reason for Not Administering Fibrinolytic Therapy Within 30 Minutes of ED Arrival"
    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
    CMS996FHIRAptTxforSTEMI SDE Sex
    define "SDE Sex":
      SDE."SDE Sex"
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Encounter During MP
    define "ED Encounter During MP":
      ["Encounter": "Emergency Department Evaluation and Management Visit"] EDEncounter
        where EDEncounter.period ends during day of "Measurement Period"
          and EDEncounter.status = 'finished'
          and EDEncounter.class ~ "EMER"
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Encounter with STEMI Diagnosis
    define "ED Encounter with STEMI Diagnosis":
      "ED Encounter During MP" EDEncounter
        where ( EDEncounter.reasonCode in "STEMI"
            or exists ( ( EDEncounter.encounterDiagnosis ( ) ) EncDiagnosis
                where EncDiagnosis.code in "STEMI"
            )
            or exists ( ["Condition": "STEMI"] DxSTEMI
                where DxSTEMI.clinicalStatus ~ QICoreCommon."active"
                  and DxSTEMI.prevalenceInterval ( ) starts during EDEncounter.period
            )
        )
    Library Name Name
    CMS996FHIRAptTxforSTEMI Fibrinolytic Therapy within 30 Minutes of Arrival
    define "Fibrinolytic Therapy within 30 Minutes of Arrival":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ["MedicationAdministration": "Fibrinolytic Therapy"] Fibrinolytic
          such that Fibrinolytic.status = 'completed'
            and start of ( Fibrinolytic.effective.toInterval ( ) ) 30 minutes or less after EDwithSTEMI.currentemergencyDepartmentArrivalTime ( )
    Library Name Name
    CMS996FHIRAptTxforSTEMI PCI within 90 Minutes of Arrival
    define "PCI within 90 Minutes of Arrival":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ["Procedure": "Percutaneous Coronary Intervention"] PCI
          such that PCI.performed.toInterval ( ) starts 90 minutes or less after EDwithSTEMI.currentemergencyDepartmentArrivalTime ( )
            and PCI.status = 'completed'
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
    define "ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        where EDwithSTEMI.currentemergencyDepartmentDepartTime ( ) 45 minutes or less after EDwithSTEMI.currentemergencyDepartmentArrivalTime ( )
          and EDwithSTEMI.hospitalization.dischargeDisposition in "Discharge To Acute Care Facility"
    Library Name Name
    CMS996FHIRAptTxforSTEMI Numerator
    define "Numerator":
      "Fibrinolytic Therapy within 30 Minutes of Arrival"
        union "PCI within 90 Minutes of Arrival"
        union "ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival"
    Library Name Name
    CMS996FHIRAptTxforSTEMI Initial Population
    define "Initial Population":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18
    Library Name Name
    CMS996FHIRAptTxforSTEMI Denominator
    define "Denominator":
      "Initial Population"
    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
    CMS996FHIRAptTxforSTEMI 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
    CMS996FHIRAptTxforSTEMI SDE Ethnicity
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
    Library Name Name
    CMS996FHIRAptTxforSTEMI Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
    define "Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        with ["AllergyIntolerance": "Thrombolytic medications"] ThrombolyticAllergy
          such that ThrombolyticAllergy.clinicalStatus ~ QICoreCommon."allergy-active"
            and ThrombolyticAllergy.onset.toInterval ( ) overlaps ( EDwSTEMI.period )
    Library Name Name
    CMS996FHIRAptTxforSTEMI Adverse Effect to Thrombolytic Medications Before End of ED Encounter
    define "Adverse Effect to Thrombolytic Medications Before End of ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        with [AdverseEvent: event in "Thrombolytics Adverse Event"] ThrombolyticAdverseEvent
          such that ThrombolyticAdverseEvent.recordedDate before end of ( EDwSTEMI.period )
            and ThrombolyticAdverseEvent.actuality = 'actual'
    Library Name Name
    CMS996FHIRAptTxforSTEMI Active Exclusion Diagnosis at Start of ED Encounter
    define "Active Exclusion Diagnosis at Start of ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ( ["Condition": "Active Bleeding Excluding Menses or Bleeding Diathesis"]
          union ["Condition": "Malignant Intracranial Neoplasm Group"]
          union ["Condition": "Cerebral Vascular Lesion"]
          union ["Condition": "Dementia and Related Intracranial Pathologies"]
          union ["Condition": "Pregnant State"]
          union ["Condition": "Allergy to thrombolytics"] ) ActiveExclusionDx
          such that ActiveExclusionDx.prevalenceInterval ( ) overlaps before ( EDwithSTEMI.period )
    Library Name Name
    CMS996FHIRAptTxforSTEMI Active Oral Anticoagulant Medication at the Start of ED Encounter
    define "Active Oral Anticoagulant Medication at the Start of ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ["MedicationRequest": "Oral Anticoagulant Medications"] OralAnticoagulant
          such that OralAnticoagulant.status = 'active'
            and OralAnticoagulant.intent = 'order'
            and OralAnticoagulant.authoredOn 90 days or less before or on start of EDwithSTEMI.period
    Library Name Name
    CMS996FHIRAptTxforSTEMI Active Long Term use of Anticoagulants
    define "Active Long Term use of Anticoagulants":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ["Condition": "Long term (current) use of anticoagulants"] LongTermAnticoagulant
          such that ( LongTermAnticoagulant.prevalenceInterval ( ) starts before or on start of EDwithSTEMI.period
              and LongTermAnticoagulant.prevalenceInterval ( ) ends on or after start of EDwithSTEMI.period
          )
    Library Name Name
    CMS996FHIRAptTxforSTEMI Active use of Anticoagulants
    define "Active use of Anticoagulants":
      "Active Oral Anticoagulant Medication at the Start of ED Encounter"
        union "Active Long Term use of Anticoagulants"
    Library Name Name
    CMS996FHIRAptTxforSTEMI Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
    define "Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ( ["Condition": "Aortic Dissection or Ruptured Aortic Aneurysm"]
          union ["Condition": "Neurologic impairment"]
          union ["Condition": "Angina pectoris with documented spasm"]
          union ["Condition": "Ventricular aneurysm due to and following acute myocardial infarction (disorder)"]
          union ["Condition": "Aneurysm of heart"]
          union ["Condition": "Takotsubo cardiomyopathy (disorder)"]
          union ["Condition": "Takotsubo syndrome"]
          union ["Condition": "Cardiopulmonary Arrest"] ) ExclusionDiagnosis
          such that ( ExclusionDiagnosis.prevalenceInterval ( ) starts during EDwithSTEMI.period )
            or ( ExclusionDiagnosis.prevalenceInterval ( ) starts 24 hours or less before start of EDwithSTEMI.period )
    Library Name Name
    CMS996FHIRAptTxforSTEMI Major Surgical Procedure 21 Days or Less Before Start of ED Encounter
    define "Major Surgical Procedure 21 Days or Less Before Start of ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ["Procedure": "Major Surgical Procedure"] MajorSurgery
          such that MajorSurgery.performed.toInterval ( ) starts 21 days or less before start of ( EDwithSTEMI.period )
            and MajorSurgery.status = 'completed'
    Library Name Name
    CMS996FHIRAptTxforSTEMI Intubation or Mechanical Circulatory Assist Device Placement or Removal Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
    define "Intubation or Mechanical Circulatory Assist Device Placement or Removal Procedure During ED Encounter or Within 24 Hours of ED Encounter Start":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ( ["Procedure": "Endotracheal Intubation"]
          union ["Procedure": "Insertion, Replacement, or Removal of Mechanical Circulatory Assist Device"] ) AirwayProcedure
          such that ( ( AirwayProcedure.performed.toInterval ( ) starts during ( EDwithSTEMI.period ) )
              or ( AirwayProcedure.performed.toInterval ( ) starts 24 hours or less before start of ( EDwithSTEMI.period ) )
          )
            and AirwayProcedure.status = 'completed'
    Library Name Name
    CMS996FHIRAptTxforSTEMI Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
    define "Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        with ( ["Condition": "Ischemic Stroke"]
          union ["Condition": "Closed Head and Facial Trauma"]
          union ["Condition": "Active Peptic Ulcer"] ) ExclusionCondition
          such that ExclusionCondition.prevalenceInterval ( ) starts during Interval[start of ( EDwSTEMI.period ) - 90 days, start of ( EDwSTEMI.period )]
    Library Name Name
    CMS996FHIRAptTxforSTEMI Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
    define "Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ["Procedure": "Intracranial or Intraspinal surgery"] CranialorSpinalSurgery
          such that CranialorSpinalSurgery.performed.toInterval ( ) starts 90 days or less before start of ( EDwithSTEMI.period )
            and CranialorSpinalSurgery.status = 'completed'
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Encounter with Discharge Disposition as Patient Expired
    define "ED Encounter with Discharge Disposition as Patient Expired":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Encounter with Discharge Disposition as Left Against Medical Advice
    define "ED Encounter with Discharge Disposition as Left Against Medical Advice":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        where EDwSTEMI.hospitalization.dischargeDisposition in "Left Against Medical Advice"
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Encounter with Hospice Services
    define "ED Encounter with Hospice Services":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        where ( exists ( ( ( [Encounter: "Encounter Inpatient"] ).isEncounterPerformed ( ) ) InpatientEncounter
              where ( InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to home for hospice care (procedure)"
                  or InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to healthcare facility for hospice care (procedure)"
              )
                and InpatientEncounter.period.toInterval ( ) starts before or on start of ( EDwSTEMI.period )
                and ( InpatientEncounter.period.toInterval ( ) ends 6 months or less before day of start of ( EDwSTEMI.period )
                    or InpatientEncounter.period.toInterval ( ) ends on or after start of ( EDwSTEMI.period )
                )
          )
            or exists ( ( ( [Encounter: "Hospice Encounter"] ).isEncounterPerformed ( ) ) HospiceEncounter
                where HospiceEncounter.period.toInterval ( ) starts before or on start of ( EDwSTEMI.period )
                  and ( HospiceEncounter.period.toInterval ( ) ends 6 months or less before day of start of ( EDwSTEMI.period )
                      or HospiceEncounter.period.toInterval ( ) ends on or after start of ( EDwSTEMI.period )
                  )
            )
            or exists ( ( ( [Observation: "Hospice care [Minimum Data Set]"] ).isAssessmentPerformed ( ) ) HospiceAssessment
                where HospiceAssessment.value ~ "Yes (qualifier value)"
                  and HospiceAssessment.effective.toInterval ( ) starts before or on start of ( EDwSTEMI.period )
                  and ( HospiceAssessment.effective.toInterval ( ) ends 6 months or less before day of start of ( EDwSTEMI.period )
                      or HospiceAssessment.effective.toInterval ( ) ends on or after start of ( EDwSTEMI.period )
                  )
            )
            or exists ( ( ( [ServiceRequest: "Hospice Care Ambulatory"] ).isInterventionOrder ( ) ) HospiceOrder
                where HospiceOrder.authoredOn.toInterval ( ) 6 months or less before start of ( EDwSTEMI.period )
            )
            or exists ( ( ( [Procedure: "Hospice Care Ambulatory"] ).isInterventionPerformed ( ) ) HospicePerformed
                where HospicePerformed.performed.toInterval ( ) starts before or on start of ( EDwSTEMI.period )
                  and ( HospicePerformed.performed.toInterval ( ) ends 6 months or less before day of start of ( EDwSTEMI.period )
                      or HospicePerformed.performed.toInterval ( ) ends on or after start of ( EDwSTEMI.period )
                  )
            )
            or exists ( ( [Condition: "Hospice Diagnosis"] ) HospiceCareDiagnosis
                where HospiceCareDiagnosis.prevalenceInterval ( ) ends on or after start of ( EDwSTEMI.period )
            )
        )
    Library Name Name
    CMS996FHIRAptTxforSTEMI Denominator Exclusions
    define "Denominator Exclusions":
      "Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter"
        union "Adverse Effect to Thrombolytic Medications Before End of ED Encounter"
        union "Active Exclusion Diagnosis at Start of ED Encounter"
        union "Active use of Anticoagulants"
        union "Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start"
        union "Major Surgical Procedure 21 Days or Less Before Start of ED Encounter"
        union "Intubation or Mechanical Circulatory Assist Device Placement or Removal Procedure During ED Encounter or Within 24 Hours of ED Encounter Start"
        union "Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter"
        union "Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter"
        union "ED Encounter with Discharge Disposition as Patient Expired"
        union "ED Encounter with Discharge Disposition as Left Against Medical Advice"
        union "ED Encounter with Hospice Services"
    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
    CMS996FHIRAptTxforSTEMI SDE Race
    define "SDE Race":
      SDE."SDE Race"
    Library Name Name
    CMS996FHIRAptTxforSTEMI Received tPA in Another Facility within 24 hours Prior to Admission
    define "Received tPA in Another Facility within 24 hours Prior to Admission":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        with ( ["Condition": "Status post administration of tPA (rtPA) in a different facility within the last 24 hours prior to admission to current facility"] ) TPA
          such that TPA.prevalenceInterval ( ) starts during EDwithSTEMI.period
    Library Name Name
    CMS996FHIRAptTxforSTEMI Documented Reason for No PCI Performed Within 90 Minutes of ED Arrival
    define "Documented Reason for No PCI Performed Within 90 Minutes of ED Arrival":
      ["ProcedureNotDone": "Percutaneous Coronary Intervention"] PCINotDone
        where ( PCINotDone.statusReason in "Patient Refusal"
            or PCINotDone.statusReason in "Procedure Not Indicated/Contraindicated"
        )
        return {
          id: PCINotDone.id,
          authoredOn: PCINotDone.recorded
        }
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Encounter with a Documented Reason for No PCI Performed Within 90 Minutes of ED Arrival
    define "ED Encounter with a Documented Reason for No PCI Performed Within 90 Minutes of ED Arrival":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        with "Documented Reason for No PCI Performed Within 90 Minutes of ED Arrival" NoPCI
          such that NoPCI.authoredOn during EDwSTEMI.period
    Library Name Name
    CMS996FHIRAptTxforSTEMI Documented Reason for Not Administering Fibrinolytic Therapy Within 30 Minutes of ED Arrival
    define "Documented Reason for Not Administering Fibrinolytic Therapy Within 30 Minutes of ED Arrival":
      ["MedicationAdministrationNotDone": "Fibrinolytic Therapy"] FibrinolyticNoMed
        where ( FibrinolyticNoMed.statusReason in "Patient Refusal"
            or FibrinolyticNoMed.statusReason in "Drug Intervention Not Indicated/Contraindicated"
        )
        return {
          id: FibrinolyticNoMed.id,
          authoredOn: FibrinolyticNoMed.recorded
        }
    Library Name Name
    CMS996FHIRAptTxforSTEMI ED Encounter with a Documented Reason for Not Administering Fibrinolytic Therapy Within 30 Minutes of ED Arrival
    define "ED Encounter with a Documented Reason for Not Administering Fibrinolytic Therapy Within 30 Minutes of ED Arrival":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        with "Documented Reason for Not Administering Fibrinolytic Therapy Within 30 Minutes of ED Arrival" NoFibrinolytic
          such that NoFibrinolytic.authoredOn during EDwSTEMI.period
    Library Name Name
    CMS996FHIRAptTxforSTEMI Denominator Exceptions
    define "Denominator Exceptions":
      "Received tPA in Another Facility within 24 hours Prior to Admission"
        union "ED Encounter with a Documented Reason for No PCI Performed Within 90 Minutes of ED Arrival"
        union "ED Encounter with a Documented Reason for Not Administering Fibrinolytic Therapy Within 30 Minutes of ED Arrival"
    Library Name Name
    FHIRHelpers ToConcept
    /*
    @description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
    */
    define function ToConcept(concept FHIR.CodeableConcept):
        if concept is null then
            null
        else
            System.Concept {
                codes: concept.coding C return ToCode(C),
                display: concept.text.value
            }
    Library Name Name
    CQMCommon encounterDiagnosis
    /*
    @description: Returns the Condition resources referenced by the diagnosis element of the Encounter
    */
    define fluent function encounterDiagnosis(Encounter Encounter ):
      Encounter.diagnosis D
        return singleton from ([Condition] C where C.id = D.condition.reference.getId())
    Library Name Name
    QICoreCommon getId
    /*
    @description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
    @comment: This function can be used to determine the logical id of a given resource. It can be used in
    a single-server environment to trace references. However, this function does not attempt to resolve
    or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
    */
    define fluent function getId(uri String):
      Last(Split(uri, '/'))
    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
    CMS996FHIRAptTxforSTEMI currentemergencyDepartmentArrivalTime
    define fluent function currentemergencyDepartmentArrivalTime(EDEncounter Encounter):
      start of ( singleton from ( ( ( EDEncounter.location ) ) EDLocation
            where CQMCommon.GetLocation ( EDLocation.location ).type in "Emergency Department Visit"
        )
      ).period
    Library Name Name
    CQMCommon GetLocation
    /*
    @description: Returns the Location resource specified by the given reference
    @deprecated: This function is deprecated. Use the fluent function `getLocation()` instead.
    */
    define function "GetLocation"(reference Reference ):
      singleton from (
        [Location] L where L.id = reference.reference.getId()
      )
    Library Name Name
    CMS996FHIRAptTxforSTEMI currentemergencyDepartmentDepartTime
    define fluent function currentemergencyDepartmentDepartTime(EDEncounter Encounter):
      end of ( singleton from ( ( ( EDEncounter.location ) ) EDLocation
            where CQMCommon.GetLocation ( EDLocation.location ).type in "Emergency Department Visit"
        )
      ).period
    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
    Status isEncounterPerformed
    //Encounter, Performed
    //General usage unless required otherwise by measure intent (e.g., follow-up encounters)
    define fluent function isEncounterPerformed(Enc List<Encounter>):
      Enc E
        where E.status in {'finished', 'arrived', 'triaged', 'in-progress', 'onleave'}
    Library Name Name
    QICoreCommon toInterval
    /*
    @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
    @comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> types
    to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
    representations for timing-valued elements in QICore, allowing this function to be used across any resource.
    The input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.
    The intent of this function is to provide a clear and concise mechanism to treat single
    elements that have multiple possible representations as intervals so that logic doesn't have to account
    for the variability. More complex calculations (such as medication request period or dispense period
    calculation) need specific guidance and consideration. That guidance may make use of this function, but
    the focus of this function is on single element calculations where the semantics are unambiguous.
    If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
    If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
    and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
    If the input is a DateTime Interval, the result is the input.
    If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
    is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
    immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
    If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
    */
    define fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>, Timing>):
      case
    	  when choice is DateTime then
        	Interval[choice as DateTime, choice as DateTime]
    		when choice is Interval<DateTime> then
      		choice as Interval<DateTime>
    		when choice is Quantity then
    		  Interval[Patient.birthDate + (choice as Quantity),
    			  Patient.birthDate + (choice as Quantity) + 1 year)
    		when choice is Interval<Quantity> then
    		  Interval[Patient.birthDate + (choice.low as Quantity),
    			  Patient.birthDate + (choice.high as Quantity) + 1 year)
    		when choice is Timing then
          Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval<DateTime>
    		else
    			null as Interval<DateTime>
    	end
    Library Name Name
    Status isAssessmentPerformed
    //This library contains functions that are based on QDM 5.6 to QICore 4.1.1 March 2023 (https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns---QICore-v4.1.1). The functions may appear similar to some QICoreCommon functions but different in that they have constraints that are relevant for measures authored by NCQA.
    
    //Assessment, Performed
    define fluent function isAssessmentPerformed(Obs List<Observation>):
      Obs O
        where O.status in { 'final', 'amended', 'corrected' }
              and exists ( O.category ObservationCategory
              where ( ObservationCategory ) ~ "survey"
          )
    Library Name Name
    Status isInterventionOrder
    //Intervention, Order: active and completed only    
    define fluent function isInterventionOrder(ServiceRequest List<ServiceRequest>):
      ServiceRequest S
        where S.status in { 'active', 'completed' }
          and S.intent = 'order'
    Library Name Name
    Status isInterventionPerformed
    //Intervention, Performed
    define fluent function isInterventionPerformed(Proc List<Procedure>):
      Proc P
        where P.status ~ 'completed'