eCQM QICore Content Implementation Guide
2023.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 2023.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-2023/ and changes regularly. See the Directory of published versions

Measure: Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department (ED)FHIR

Official URL: http://ecqi.healthit.gov/ecqms/Measure/AppropriateTreatmentforSTEMIFHIR Version: 0.0.008
Draft as of 2023-10-27 Responsible: Centers for Medicare & Medicaid Services (CMS) Computable Name: AppropriateTreatmentforSTEMIFHIR
Other Identifiers: Short Name (use: usual, ), UUID:a48685e0-4926-4ae8-9eb3-d8e8839b1704 (use: official, ), UUID:2c92808482113ece01821188a1500069 (use: official, ), Endorser (use: official, ), Publisher (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-2022 International Health Terminology Standards Development Organisation. All rights reserved.

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

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

ICD-10 is copyright 2022 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 (ED)FHIR
Id: AppropriateTreatmentforSTEMIFHIR
Download cql: AppropriateTreatmentforSTEMIFHIR.cql
Version: 0.0.008
Url: Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department (ED)FHIR
short-name identifier:

CMS996FHIR

version-independent identifier:

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

version-specific identifier:

urn:uuid:2c92808482113ece01821188a1500069

endorser (NQF) identifier:

3613e

publisher (CMS) identifier:

996FHIR

Effective Period: 2024-01-01 ..2024-12-31
Status: draft
Date: 2023-10-27 08:12:31+0000
Approval Date: 2023-08-17
Last Review Date: 2023-08-17
Name: AppropriateTreatmentforSTEMIFHIR
Publisher: Centers for Medicare & Medicaid Services (CMS)
Author: Yale New Haven Health Service Corporation/ Center for Outcomes Research and Evaluation: https://medicine.yale.edu/core/, The Lewin Group: https://www.lewin.com/
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-2022 International Health Terminology Standards Development Organisation. All rights reserved.

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

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

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

Disclaimer:

These performance specifications are not clinical guidelines and 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 (Sohlpour & Yusuf, 2014; 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 proposed 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 ACCF/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 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): 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: CMS996v4. Please refer to the HL7 QI-Core Implementation Guide (http://hl7.org/fhir/us/qicore/index.html) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (http://hl7.org/fhir/us/qicore/qdm-to-qicore.html).
Population Criteria:
6384fdb64ba3d47c885c02a6
Initial Population: All emergency department encounters for patients 18 years and older with a diagnosis of ST-segment elevation myocardial infarction (STEMI)
Denominator: Equals Initial Population
Denominator Exclusion: Patients with the following conditions are excluded from measure denominator: • Expired in the ED • Bleeding or bleeding diathesis (excluding menses) • Intracranial or intraspinal surgery • Ischemic stroke • Known malignant intracranial neoplasm (primary or metastatic) • Known structural cerebral vascular lesion (e.g., AVM) • Significant facial and/or closed head trauma • Suspected aortic dissection • Peptic ulcer • Cardiopulmonary arrest, including: cardiac arrest, CPR, defibrillation, respiratory arrest, or ventricular fibrillation (V-fib), ventricular tachycardia (VT), or pulseless electrical activity (PEA); or, traumatic or prolonged (>10 minutes) CPR • Allergic reaction to alteplase, streptokinase, anistreplase, tenecteplase, or reteplase • Intubation, including endotracheal intubation, mechanical ventilation, nasotracheal intubation, or orotracheal intubation • Mechanical circulatory assist device placement, 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 • Oral anticoagulant therapy • Advanced dementia • Pregnancy • Internal bleeding • Major surgery • Severe neurologic impairment (e.g., based on Glasgow coma scale or as indicated by the patient receiving therapeutic hypothermia in the ED)
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 for non-transfer patients; OR - where the patient is transferred within 45 minutes of ED arrival.
Numerator Exclusion: None
Denominator Exception: None
Supplemental Data Guidance :
Supplemental Data Elements: SDE Ethnicity SDE Payer SDE Race SDE Sex
Libraries:
AppropriateTreatmentforSTEMIFHIR
Related Artifact Dependencies:
  • SupplementalDataElements version: 3.4.000
  • FHIRHelpers version: 4.3.000
  • CQMCommon version: 1.4.000
  • QICoreCommon version: 1.5.000
  • http://hl7.org/fhir/v3/AdministrativeGender
  • ActCode
  • Condition Clinical Status Codes
  • AllergyIntolerance Clinical Status Codes
  • ED
  • STEMI
  • Fibrinolytic Therapy
  • Emergency Department Visit
  • Percutaneous Coronary Intervention
  • Discharge To Acute Care Facility
  • Payer
  • Thrombolytic Therapy Allergen
  • Thrombolytics Adverse Event
  • Active Bleeding or Bleeding Diathesis (Excluding Menses)
  • Malignant Intracranial Neoplasm Group
  • Cerebral Vascular Lesion
  • Dementia
  • Pregnancy
  • Allergy to Thrombolytics
  • 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
  • Intracranial or Intraspinal Surgery
  • Patient Expired
  • 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
    DataRequirements:
    Type Elements Valueset Name Valueset
    Patient(QICorePatient) ethnicity race
    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 Malignant Intracranial Neoplasm Group
    Condition(QICoreCondition) code Cerebral Vascular Lesion Cerebral Vascular Lesion
    Condition(QICoreCondition) code Dementia Dementia
    Condition(QICoreCondition) code Pregnancy Pregnancy
    Condition(QICoreCondition) code Allergy to thrombolytics Allergy to Thrombolytics
    Condition(QICoreCondition) code Aortic Dissection and Rupture Aortic Dissection
    Condition(QICoreCondition) code Neurologic impairment Neurologic impairment
    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 Cardiopulmonary Arrest Cardiopulmonary Arrest
    Encounter(QICoreEncounter) type status status.value class period condition condition.reference condition.reference.value location location.type hospitalization hospitalization.dischargeDisposition ED ED
    Encounter(QICoreEncounter) type status status.value class reasonCode period condition condition.reference condition.reference.value location location.type hospitalization hospitalization.dischargeDisposition ED ED
    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 or Replacement of Mechanical Circulatory Assist Device Mechanical Circulatory Assist Device
    Procedure(QICoreProcedure) code performed status status.value Intracranial or Intraspinal surgery Intracranial or Intraspinal Surgery
    Coverage(QICoreCoverage) type period Payer Type Payer
    AllergyIntolerance(QICoreAllergyIntolerance) code clinicalStatus onset Thrombolytic medications Thrombolytic Therapy Allergen
    AdverseEvent(QICoreAdverseEvent) event recordedDate recordedDate.value actuality actuality.value Adverse reaction to thrombolytics Thrombolytics Adverse Event
    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
    Direct Reference Codes:
    display code system
    Male M http://hl7.org/fhir/v3/AdministrativeGender
    Female F http://hl7.org/fhir/v3/AdministrativeGender
    emergency EMER http://terminology.hl7.org/CodeSystem/v3-ActCode
    active http://terminology.hl7.org/CodeSystem/condition-clinical
    active http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical
    Logic Definitions:
    Group Scoring Population Criteria Expression
    6384fdb64ba3d47c885c02a6 Group scoring: proportion
    Initial Population
    /***Population Criteria***/
    
    
    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 Oral Anticoagulant Medication at the Start of ED Encounter"
        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 or Starts During ED Encounter"
        union "Intubation or Mechanical Circulatory Assist 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"
    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"
    Numerator Exclusion None
    Denominator Exception None
    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
    AppropriateTreatmentforSTEMIFHIR SDE Sex
    define "SDE Sex":
      SDE."SDE Sex"
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR ED Encounter with Encounter Diagnosis of STEMI
    define "ED Encounter with Encounter Diagnosis of STEMI":
      ["Encounter": "ED"] EDEncounter
        where EDEncounter.status = 'finished'
          and EDEncounter.class ~ "EMER"
          and ( EDEncounter.reasonCode in "STEMI"
              or exists ( ( EDEncounter.encounterDiagnosis ( ) ) EncDiagnosis
                  where EncDiagnosis.code in "STEMI"
              )
          )
          and EDEncounter.period during "Measurement Period"
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR ED Encounter with Diagnosis of STEMI
    define "ED Encounter with Diagnosis of STEMI":
      ["Encounter": "ED"] EDEncounter
        with ["Condition": "STEMI"] DxSTEMI
          such that DxSTEMI.clinicalStatus ~ QICoreCommon."active"
            and EDEncounter.status = 'finished'
            and EDEncounter.class ~ "EMER"
            and DxSTEMI.prevalenceInterval ( ) starts during EDEncounter.period
            and EDEncounter.period during day of "Measurement Period"
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR ED Encounter with STEMI Diagnosis
    define "ED Encounter with STEMI Diagnosis":
      "ED Encounter with Encounter Diagnosis of STEMI"
        union "ED Encounter with Diagnosis of STEMI"
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR Fibrinolytic Therapy within 30 Minutes of Arrival
    /*Did not include a status of active as any diagnosis that resolves during the ED visit would not be counted*/
    
    
    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
    AppropriateTreatmentforSTEMIFHIR 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
    AppropriateTreatmentforSTEMIFHIR 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.period ) ends 45 minutes or less after start of ( EDwithSTEMI.period )
          and EDwithSTEMI.hospitalization.dischargeDisposition in "Discharge To Acute Care Facility"
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR 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
    AppropriateTreatmentforSTEMIFHIR Initial Population
    /***Population Criteria***/
    
    
    define "Initial Population":
      "ED Encounter with STEMI Diagnosis" EDwithSTEMI
        where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR 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
    AppropriateTreatmentforSTEMIFHIR 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
    AppropriateTreatmentforSTEMIFHIR SDE Ethnicity
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR 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
    AppropriateTreatmentforSTEMIFHIR Adverse Effect to Thrombolytic Medications Before End of ED Encounter
    /*this definition differs from QDM re: timing - cannot use overlaps for a single point in time*/
    
    /*define "Adverse Effect to Thrombolytic Medications Before End of ED Encounter":
    "ED Encounter with STEMI Diagnosis" EDwSTEMI
        with [AdverseEvent: event in "Thrombolytic medications"] ThrombolyticAdverseEvent
        such that ThrombolyticAdverseEvent.category in "Adverse reaction to thrombolytics"
        and ThrombolyticAdverseEvent.recordedDate before end of ( EDwSTEMI.period )
            and ThrombolyticAdverseEvent.actuality = 'actual'*/
    /*KS Note - not sure we need category in the logic - it is must support, but not sure this brings value to the measure logic*/
    
    
    
    
    define "Adverse Effect to Thrombolytic Medications Before End of ED Encounter":
      "ED Encounter with STEMI Diagnosis" EDwSTEMI
        with [AdverseEvent: event in "Adverse reaction to thrombolytics"] ThrombolyticAdverseEvent
          such that ThrombolyticAdverseEvent.recordedDate before end of ( EDwSTEMI.period )
            and ThrombolyticAdverseEvent.actuality = 'actual'
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR Active Exclusion Diagnosis at Start of ED Encounter
    /***Definitions***/
    
    
    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"]
          union ["Condition": "Pregnancy"]
          union ["Condition": "Allergy to thrombolytics"] ) ActiveExclusionDx
          such that /*ActiveExclusionDx.isActive ()
            and */
          ActiveExclusionDx.prevalenceInterval ( ) overlaps before ( EDwithSTEMI.period )
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR 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 before or on start of EDwithSTEMI.period
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR 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 and Rupture"]
          union ["Condition": "Neurologic impairment"]
          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
    AppropriateTreatmentforSTEMIFHIR Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
    define "Major Surgical Procedure 21 Days or Less Before Start of or Starts During 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
    AppropriateTreatmentforSTEMIFHIR Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
    define "Intubation or Mechanical Circulatory Assist 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 or Replacement 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
    AppropriateTreatmentforSTEMIFHIR Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
    /*KS 8-10-23: in CQLIT-389, discussed the impacts of requiring a clinical status of active but the condition could end before the end (during) the ED Visit, which would trigger an inactive status. Decided to not follow the Authoring Patterns and remove the requirement for a clinicalstatus of 'active'  */
    
    
    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"]
          union ["Condition": "Cardiopulmonary Arrest"] ) ExclusionCondition
          such that /* ExclusionCondition.isActive ()
       and */
          ExclusionCondition.prevalenceInterval ( ) starts during Interval[start of ( EDwSTEMI.period ) - 90 days, start of ( EDwSTEMI.period )]
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR 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
    AppropriateTreatmentforSTEMIFHIR 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
    AppropriateTreatmentforSTEMIFHIR 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 Oral Anticoagulant Medication at the Start of ED Encounter"
        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 or Starts During ED Encounter"
        union "Intubation or Mechanical Circulatory Assist 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"
    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
    AppropriateTreatmentforSTEMIFHIR SDE Race
    define "SDE Race":
      SDE."SDE Race"
    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, the resulting interval will have
    a closed ending boundary. If the condition is not active, the resulting interval will have an open ending boundary.
    */
    define fluent function prevalenceInterval(condition Condition):
    if condition.clinicalStatus ~ "active"
      or condition.clinicalStatus ~ "recurrence"
      or condition.clinicalStatus ~ "relapse" then
      Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
    else
      Interval[start of condition.onset.toInterval(), end of condition.abatementInterval())
    Library Name Name
    AppropriateTreatmentforSTEMIFHIR currentemergencyDepartmentArrivalTime
    /*
    @description: Returns the emergency department arrival time for the encounter.
    */
    
    
    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
    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
    QICoreCommon toInterval
    /*
    @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
    @comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> types
    to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
    representations for timing-valued elements in QICore, allowing this function to be used across any resource.
    The input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.
    The intent of this function is to provide a clear and concise mechanism to treat single
    elements that have multiple possible representations as intervals so that logic doesn't have to account
    for the variability. More complex calculations (such as medication request period or dispense period
    calculation) need specific guidance and consideration. That guidance may make use of this function, but
    the focus of this function is on single element calculations where the semantics are unambiguous.
    If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
    If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
    and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
    If the input is a DateTime Interval, the result is the input.
    If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
    is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
    immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
    Any other input will reslt in a null DateTime Interval
    */
    define fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>>):
      case
    	  when choice is DateTime then
        	Interval[choice as DateTime, choice as DateTime]
    		when choice is Interval<DateTime> then
      		choice as Interval<DateTime>
    		when choice is Quantity then
    		  Interval[Patient.birthDate + (choice as Quantity),
    			  Patient.birthDate + (choice as Quantity) + 1 year)
    		when choice is Interval<Quantity> then
    		  Interval[Patient.birthDate + (choice.low as Quantity),
    			  Patient.birthDate + (choice.high as Quantity) + 1 year)
    		else
    			null as Interval<DateTime>
    	end