# Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department (ED)FHIR - eCQM QICore Content Implementation Guide v2023.0.0

* [**Table of Contents**](toc.md)
* [**Artifacts Summary**](artifacts.md)
* **Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department (ED)FHIR**

## 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)/a>  *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    
* **Logic Definitions:**: **Id: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: AppropriateTreatmentforSTEMIFHIR
* **Logic Definitions:**: **Download cql: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: [AppropriateTreatmentforSTEMIFHIR.cql](Library-AppropriateTreatmentforSTEMIFHIR.cql)
* **Logic Definitions:**: **Version: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 0.0.008
* **Logic Definitions:**: **Url: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: [Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department (ED)FHIR](Measure-AppropriateTreatmentforSTEMIFHIR.md)
* **Logic Definitions:**: ** short-name identifier: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````:  CMS996FHIR 
* **Logic Definitions:**: ** version-independent identifier: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````:  urn:uuid:a48685e0-4926-4ae8-9eb3-d8e8839b1704 
* **Logic Definitions:**: ** version-specific identifier: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````:  urn:uuid:2c92808482113ece01821188a1500069 
* **Logic Definitions:**: ** endorser (NQF) identifier: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````:  3613e 
* **Logic Definitions:**: ** publisher (CMS) identifier: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````:  996FHIR 
* **Logic Definitions:**: **Effective Period: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 2024-01-01 ..2024-12-31
* **Logic Definitions:**: **Status: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: draft
* **Logic Definitions:**: **Date: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 2023-10-27 08:12:31+0000
* **Logic Definitions:**: **Approval Date: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 2023-08-17
* **Logic Definitions:**: **Last Review Date: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 2023-08-17
* **Logic Definitions:**: **Name: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: AppropriateTreatmentforSTEMIFHIR
* **Logic Definitions:**: **Publisher: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: Centers for Medicare & Medicaid Services (CMS)
* **Logic Definitions:**: **Author: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: Yale New Haven Health Service Corporation/ Center for Outcomes Research and Evaluation:[https://medicine.yale.edu/core/](https://medicine.yale.edu/core/), The Lewin Group:[https://www.lewin.com/](https://www.lewin.com/)
* **Logic Definitions:**: **Description: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 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
* **Logic Definitions:**: **Purpose: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: UNKNOWN
* **Logic Definitions:**: **Copyright: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 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.
* **Logic Definitions:**: **Disclaimer: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 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].
* **Logic Definitions:**: **Rationale: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 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.
* **Logic Definitions:**: **Clinical recommendation statement: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 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.

* **Logic Definitions:**: **Guidance (Usage): **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 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).
* **Logic Definitions:**: ** Supplemental Data Guidance : **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 
* **Logic Definitions:**: ** Supplemental Data Elements: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: SDE Ethnicity SDE Payer SDE Race SDE Sex
* **Logic Definitions:**: **Libraries: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: 
| |
| :--- |
| [AppropriateTreatmentforSTEMIFHIR](Library-AppropriateTreatmentforSTEMIFHIR.md) |

* **Logic Definitions:**: **Related Artifact Dependencies: **
  * * **Group**: 6384fdb64ba3d47c885c02a6
  * **Scoring**: **Group scoring:** proportion 

* **Library Name**: SupplementalDataElements
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": case when Patient.gender = 'male' then "M" when Patient.gender = 'female' then "F" else null end````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Sex
* **Library Name**: 
  * **Name**: ````define "SDE Sex": SDE."SDE Sex"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Encounter Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Diagnosis of STEMI
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with STEMI Diagnosis
* **Library Name**: 
  * **Name**: ````define "ED Encounter with STEMI Diagnosis": "ED Encounter with Encounter Diagnosis of STEMI" union "ED Encounter with Diagnosis of STEMI"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Fibrinolytic Therapy within 30 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: PCI within 90 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Numerator
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Initial Population
* **Library Name**: 
  * **Name**: ````/***Population Criteria***/ define "Initial Population": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator
* **Library Name**: 
  * **Name**: ````define "Denominator": "Initial Population"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": [Coverage: type in "Payer Type"] Payer return { code: Payer.type, period: Payer.period }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Payer
* **Library Name**: 
  * **Name**: ````define "SDE Payer": SDE."SDE Payer"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": Patient.ethnicity E return Tuple { codes: { E.ombCategory } union E.detailed, display: E.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Ethnicity
* **Library Name**: 
  * **Name**: ````define "SDE Ethnicity": SDE."SDE Ethnicity"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Adverse Effect to Thrombolytic Medications Before End of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis at Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/***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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Oral Anticoagulant Medication at the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter
* **Library Name**: 
  * **Name**: ````/*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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: ED Encounter with Discharge Disposition as Patient Expired
* **Library Name**: 
  * **Name**: ````define "ED Encounter with Discharge Disposition as Patient Expired": "ED Encounter with STEMI Diagnosis" EDwithSTEMI where EDwithSTEMI.hospitalization.dischargeDisposition in "Patient Expired"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: Denominator Exclusions
* **Library Name**: 
  * **Name**: ````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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: SupplementalDataElements
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": Patient.race R return Tuple { codes: R.ombCategory union R.detailed, display: R.text }````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: SDE Race
* **Library Name**: 
  * **Name**: ````define "SDE Race": SDE."SDE Race"````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToConcept
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: encounterDiagnosis
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: getId
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: prevalenceInterval
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: AppropriateTreatmentforSTEMIFHIR
  * **Name**: currentemergencyDepartmentArrivalTime
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: CQMCommon
  * **Name**: GetLocation
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToString
* **Library Name**: 
  * **Name**: ````define function ToString(value uri): value.value````
* **Library Name**: **Library Name**
  * **Name**: **Name**
* **Library Name**: FHIRHelpers
  * **Name**: ToCode
* **Library Name**: 
  * **Name**: ````/* @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**: **Library Name**
  * **Name**: **Name**
* **Library Name**: QICoreCommon
  * **Name**: toInterval
* **Library Name**: 
  * **Name**: ````/* @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````: * [SupplementalDataElements](Library-SupplementalDataElements.md) version: 3.4.000
* [FHIRHelpers](Library-FHIRHelpers.md) version: 4.3.000
* [CQMCommon](Library-CQMCommon.md) version: 1.4.000
* [QICoreCommon](Library-QICoreCommon.md) version: 1.5.000
* `http://hl7.org/fhir/v3/AdministrativeGender`
* [ActCode](http://terminology.hl7.org/7.1.0/CodeSystem-v3-ActCode.html)
* [Condition Clinical Status Codes](http://terminology.hl7.org/7.1.0/CodeSystem-condition-clinical.html)
* [AllergyIntolerance Clinical Status Codes](http://terminology.hl7.org/7.1.0/CodeSystem-allergyintolerance-clinical.html)
* [ED](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.464.1003.101.12.1085/expansion)
* [STEMI](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4017/expansion)
* [Fibrinolytic Therapy](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4020/expansion)
* [Emergency Department Visit](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion)
* [Percutaneous Coronary Intervention](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.2000.5/expansion)
* [Discharge To Acute Care Facility](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.87/expansion)
* [Payer](https://vsac.nlm.nih.gov/valueset/2.16.840.1.114222.4.11.3591/expansion)
* [Thrombolytic Therapy Allergen](https://tx.fhir.org/r4/ValueSet/2.16.840.1.113762.1.4.1170.4-20211007)
* [Thrombolytics Adverse Event](https://tx.fhir.org/r4/ValueSet/2.16.840.1.113762.1.4.1170.6-20250211)
* [Active Bleeding or Bleeding Diathesis (Excluding Menses)](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4036/expansion)
* [Malignant Intracranial Neoplasm Group](https://tx.fhir.org/r4/ValueSet/2.16.840.1.113762.1.4.1170.3-20211005)
* [Cerebral Vascular Lesion](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4025/expansion)
* [Dementia](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4043/expansion)
* [Pregnancy](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4055/expansion)
* [Allergy to Thrombolytics](https://tx.fhir.org/r4/ValueSet/2.16.840.1.113762.1.4.1170.5-20250211)
* [Anticoagulant Medications, Oral](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4045/expansion)
* [Aortic Dissection](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4028/expansion)
* [Neurologic impairment](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.464.1003.114.12.1012/expansion)
* [Cardiopulmonary Arrest](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4048/expansion)
* [Major Surgical Procedure](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4056/expansion)
* [Endotracheal Intubation](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113762.1.4.1045.69/expansion)
* [Mechanical Circulatory Assist Device](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4052/expansion)
* [Ischemic Stroke](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.464.1003.104.12.1024/expansion)
* [Closed Head Trauma](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4026/expansion)
* [Active Peptic Ulcer](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.3157.4031/expansion)
* [Intracranial or Intraspinal Surgery](https://tx.fhir.org/r4/ValueSet/2.16.840.1.113762.1.4.1170.2-20220218)
* [Patient Expired](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.309/expansion)


                                 ](https://www.cms.gov/) |



## Resource Content

```json
{
  "resourceType" : "Measure",
  "id" : "AppropriateTreatmentforSTEMIFHIR",
  "meta" : {
    "profile" : ["http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm",
    "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/publishable-measure-cqfm",
    "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/executable-measure-cqfm"]
  },
  "contained" : [{
    "resourceType" : "Library",
    "id" : "effective-data-requirements",
    "extension" : [{
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode",
      "valueCoding" : {
        "system" : "http://hl7.org/fhir/v3/AdministrativeGender",
        "code" : "M",
        "display" : "Male"
      }
    },
    {
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode",
      "valueCoding" : {
        "system" : "http://hl7.org/fhir/v3/AdministrativeGender",
        "code" : "F",
        "display" : "Female"
      }
    },
    {
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode",
      "valueCoding" : {
        "system" : "http://terminology.hl7.org/CodeSystem/v3-ActCode",
        "code" : "EMER",
        "display" : "emergency"
      }
    },
    {
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode",
      "valueCoding" : {
        "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical",
        "code" : "active"
      }
    },
    {
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode",
      "valueCoding" : {
        "system" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
        "code" : "active"
      }
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "SupplementalDataElements"
      },
      {
        "url" : "name",
        "valueString" : "SDE Sex"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Sex\":\n  case\n      when Patient.gender = 'male' then \"M\"\n      when Patient.gender = 'female' then \"F\"\n      else null\n    end"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 0
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "SDE Sex"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Sex\":\n  SDE.\"SDE Sex\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 1
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "ED Encounter with Encounter Diagnosis of STEMI"
      },
      {
        "url" : "statement",
        "valueString" : "define \"ED Encounter with Encounter Diagnosis of STEMI\":\n  [\"Encounter\": \"ED\"] EDEncounter\n    where EDEncounter.status = 'finished'\n      and EDEncounter.class ~ \"EMER\"\n      and ( EDEncounter.reasonCode in \"STEMI\"\n          or exists ( ( EDEncounter.encounterDiagnosis ( ) ) EncDiagnosis\n              where EncDiagnosis.code in \"STEMI\"\n          )\n      )\n      and EDEncounter.period during \"Measurement Period\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 2
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "ED Encounter with Diagnosis of STEMI"
      },
      {
        "url" : "statement",
        "valueString" : "define \"ED Encounter with Diagnosis of STEMI\":\n  [\"Encounter\": \"ED\"] EDEncounter\n    with [\"Condition\": \"STEMI\"] DxSTEMI\n      such that DxSTEMI.clinicalStatus ~ QICoreCommon.\"active\"\n        and EDEncounter.status = 'finished'\n        and EDEncounter.class ~ \"EMER\"\n        and DxSTEMI.prevalenceInterval ( ) starts during EDEncounter.period\n        and EDEncounter.period during day of \"Measurement Period\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 3
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "ED Encounter with STEMI Diagnosis"
      },
      {
        "url" : "statement",
        "valueString" : "define \"ED Encounter with STEMI Diagnosis\":\n  \"ED Encounter with Encounter Diagnosis of STEMI\"\n    union \"ED Encounter with Diagnosis of STEMI\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 4
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Fibrinolytic Therapy within 30 Minutes of Arrival"
      },
      {
        "url" : "statement",
        "valueString" : "/*Did not include a status of active as any diagnosis that resolves during the ED visit would not be counted*/\n\n\ndefine \"Fibrinolytic Therapy within 30 Minutes of Arrival\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with [\"MedicationAdministration\": \"Fibrinolytic Therapy\"] Fibrinolytic\n      such that Fibrinolytic.status = 'completed'\n        and start of ( Fibrinolytic.effective.toInterval ( ) ) 30 minutes or less after EDwithSTEMI.currentemergencyDepartmentArrivalTime ( )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 5
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "PCI within 90 Minutes of Arrival"
      },
      {
        "url" : "statement",
        "valueString" : "define \"PCI within 90 Minutes of Arrival\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with [\"Procedure\": \"Percutaneous Coronary Intervention\"] PCI\n      such that PCI.performed.toInterval ( ) starts 90 minutes or less after EDwithSTEMI.currentemergencyDepartmentArrivalTime ( )\n        and PCI.status = 'completed'"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 6
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival"
      },
      {
        "url" : "statement",
        "valueString" : "define \"ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    where ( EDwithSTEMI.period ) ends 45 minutes or less after start of ( EDwithSTEMI.period )\n      and EDwithSTEMI.hospitalization.dischargeDisposition in \"Discharge To Acute Care Facility\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 7
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Numerator"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Numerator\":\n  \"Fibrinolytic Therapy within 30 Minutes of Arrival\"\n    union \"PCI within 90 Minutes of Arrival\"\n    union \"ED Departure with Transfer to Acute Care Facility Within 45 Minutes of Arrival\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 8
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Initial Population"
      },
      {
        "url" : "statement",
        "valueString" : "/***Population Criteria***/\n\n\ndefine \"Initial Population\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    where AgeInYearsAt(date from start of(EDwithSTEMI.period)) >= 18"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 9
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Denominator"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Denominator\":\n  \"Initial Population\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 10
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "SupplementalDataElements"
      },
      {
        "url" : "name",
        "valueString" : "SDE Payer"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Payer\":\n  [Coverage: type in \"Payer Type\"] Payer\n    return {\n      code: Payer.type,\n      period: Payer.period\n    }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 11
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "SDE Payer"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Payer\":\n  SDE.\"SDE Payer\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 12
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "SupplementalDataElements"
      },
      {
        "url" : "name",
        "valueString" : "SDE Ethnicity"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Ethnicity\":\n  Patient.ethnicity E\n    return Tuple {\n      codes: { E.ombCategory } union E.detailed,\n      display: E.text\n    }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 13
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "SDE Ethnicity"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Ethnicity\":\n  SDE.\"SDE Ethnicity\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 14
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter\":\n  \"ED Encounter with STEMI Diagnosis\" EDwSTEMI\n    with [\"AllergyIntolerance\": \"Thrombolytic medications\"] ThrombolyticAllergy\n      such that ThrombolyticAllergy.clinicalStatus ~ QICoreCommon.\"allergy-active\"\n        and ThrombolyticAllergy.onset.toInterval ( ) overlaps ( EDwSTEMI.period )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 15
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Adverse Effect to Thrombolytic Medications Before End of ED Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "/*this definition differs from QDM re: timing - cannot use overlaps for a single point in time*/\n\n/*define \"Adverse Effect to Thrombolytic Medications Before End of ED Encounter\":\n\"ED Encounter with STEMI Diagnosis\" EDwSTEMI\n    with [AdverseEvent: event in \"Thrombolytic medications\"] ThrombolyticAdverseEvent\n    such that ThrombolyticAdverseEvent.category in \"Adverse reaction to thrombolytics\"\n    and ThrombolyticAdverseEvent.recordedDate before end of ( EDwSTEMI.period )\n        and ThrombolyticAdverseEvent.actuality = 'actual'*/\n/*KS Note - not sure we need category in the logic - it is must support, but not sure this brings value to the measure logic*/\n\n\n\n\ndefine \"Adverse Effect to Thrombolytic Medications Before End of ED Encounter\":\n  \"ED Encounter with STEMI Diagnosis\" EDwSTEMI\n    with [AdverseEvent: event in \"Adverse reaction to thrombolytics\"] ThrombolyticAdverseEvent\n      such that ThrombolyticAdverseEvent.recordedDate before end of ( EDwSTEMI.period )\n        and ThrombolyticAdverseEvent.actuality = 'actual'"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 16
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Active Exclusion Diagnosis at Start of ED Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "/***Definitions***/\n\n\ndefine \"Active Exclusion Diagnosis at Start of ED Encounter\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with ( [\"Condition\": \"Active Bleeding Excluding Menses or Bleeding Diathesis\"]\n      union [\"Condition\": \"Malignant Intracranial Neoplasm Group\"]\n      union [\"Condition\": \"Cerebral Vascular Lesion\"]\n      union [\"Condition\": \"Dementia\"]\n      union [\"Condition\": \"Pregnancy\"]\n      union [\"Condition\": \"Allergy to thrombolytics\"] ) ActiveExclusionDx\n      such that /*ActiveExclusionDx.isActive ()\n        and */\n      ActiveExclusionDx.prevalenceInterval ( ) overlaps before ( EDwithSTEMI.period )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 17
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Active Oral Anticoagulant Medication at the Start of ED Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Active Oral Anticoagulant Medication at the Start of ED Encounter\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with [\"MedicationRequest\": \"Oral Anticoagulant Medications\"] OralAnticoagulant\n      such that OralAnticoagulant.status = 'active'\n        and OralAnticoagulant.intent = 'order'\n        and OralAnticoagulant.authoredOn before or on start of EDwithSTEMI.period"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 18
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with ( [\"Condition\": \"Aortic Dissection and Rupture\"]\n      union [\"Condition\": \"Neurologic impairment\"]\n      union [\"Condition\": \"Cardiopulmonary Arrest\"] ) ExclusionDiagnosis\n      such that ( ExclusionDiagnosis.prevalenceInterval ( ) starts during EDwithSTEMI.period )\n        or ( ExclusionDiagnosis.prevalenceInterval ( ) starts 24 hours or less before start of EDwithSTEMI.period )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 19
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with [\"Procedure\": \"Major Surgical Procedure\"] MajorSurgery\n      such that MajorSurgery.performed.toInterval ( ) starts 21 days or less before start of ( EDwithSTEMI.period )\n        and MajorSurgery.status = 'completed'"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 20
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with ( [\"Procedure\": \"Endotracheal Intubation\"]\n      union [\"Procedure\": \"Insertion or Replacement of Mechanical Circulatory Assist Device\"] ) AirwayProcedure\n      such that ( ( AirwayProcedure.performed.toInterval ( ) starts during ( EDwithSTEMI.period ) )\n          or ( AirwayProcedure.performed.toInterval ( ) starts 24 hours or less before start of ( EDwithSTEMI.period ) )\n      )\n        and AirwayProcedure.status = 'completed'"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 21
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "/*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'  */\n\n\ndefine \"Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter\":\n  \"ED Encounter with STEMI Diagnosis\" EDwSTEMI\n    with ( [\"Condition\": \"Ischemic Stroke\"]\n      union [\"Condition\": \"Closed Head and Facial Trauma\"]\n      union [\"Condition\": \"Active Peptic Ulcer\"]\n      union [\"Condition\": \"Cardiopulmonary Arrest\"] ) ExclusionCondition\n      such that /* ExclusionCondition.isActive ()\n   and */\n      ExclusionCondition.prevalenceInterval ( ) starts during Interval[start of ( EDwSTEMI.period ) - 90 days, start of ( EDwSTEMI.period )]"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 22
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    with [\"Procedure\": \"Intracranial or Intraspinal surgery\"] CranialorSpinalSurgery\n      such that CranialorSpinalSurgery.performed.toInterval ( ) starts 90 days or less before start of ( EDwithSTEMI.period )\n        and CranialorSpinalSurgery.status = 'completed'"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 23
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "ED Encounter with Discharge Disposition as Patient Expired"
      },
      {
        "url" : "statement",
        "valueString" : "define \"ED Encounter with Discharge Disposition as Patient Expired\":\n  \"ED Encounter with STEMI Diagnosis\" EDwithSTEMI\n    where EDwithSTEMI.hospitalization.dischargeDisposition in \"Patient Expired\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 24
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "Denominator Exclusions"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Denominator Exclusions\":\n  \"Allergy or Intolerance to Thrombolytic Medications Overlaps ED Encounter\"\n    union \"Adverse Effect to Thrombolytic Medications Before End of ED Encounter\"\n    union \"Active Exclusion Diagnosis at Start of ED Encounter\"\n    union \"Active Oral Anticoagulant Medication at the Start of ED Encounter\"\n    union \"Exclusion Diagnosis During ED Encounter or Within 24 Hours of ED Encounter Start\"\n    union \"Major Surgical Procedure 21 Days or Less Before Start of or Starts During ED Encounter\"\n    union \"Intubation or Mechanical Circulatory Assist Procedure During ED Encounter or Within 24 Hours of ED Encounter Start\"\n    union \"Active Exclusion Diagnosis Within 90 Days Before or At the Start of ED Encounter\"\n    union \"Intracranial or Intraspinal Procedure 90 Days or Less Before Start of ED Encounter\"\n    union \"ED Encounter with Discharge Disposition as Patient Expired\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 25
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "SupplementalDataElements"
      },
      {
        "url" : "name",
        "valueString" : "SDE Race"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Race\":\n  Patient.race R\n    return Tuple {\n      codes: R.ombCategory union R.detailed,\n      display: R.text\n    }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 26
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "SDE Race"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Race\":\n  SDE.\"SDE Race\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 27
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToConcept"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.\n*/\ndefine function ToConcept(concept FHIR.CodeableConcept):\n    if concept is null then\n        null\n    else\n        System.Concept {\n            codes: concept.coding C return ToCode(C),\n            display: concept.text.value\n        }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 28
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "CQMCommon"
      },
      {
        "url" : "name",
        "valueString" : "encounterDiagnosis"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Returns the Condition resources referenced by the diagnosis element of the Encounter\n*/\ndefine fluent function encounterDiagnosis(Encounter Encounter ):\n  Encounter.diagnosis D\n    return singleton from ([Condition] C where C.id = D.condition.reference.getId())"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 29
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "QICoreCommon"
      },
      {
        "url" : "name",
        "valueString" : "getId"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).\n@comment: This function can be used to determine the logical id of a given resource. It can be used in\na single-server environment to trace references. However, this function does not attempt to resolve\nor distinguish the base of the given url, and so cannot be used safely in multi-server environments.\n*/\ndefine fluent function getId(uri String):\n  Last(Split(uri, '/'))"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 30
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "QICoreCommon"
      },
      {
        "url" : "name",
        "valueString" : "prevalenceInterval"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Returns an interval representing the normalized prevalence period of a given Condition.\n@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from\nonset to abatement as specified in the given Condition. If the condition is active, the resulting interval will have\na closed ending boundary. If the condition is not active, the resulting interval will have an open ending boundary.\n*/\ndefine fluent function prevalenceInterval(condition Condition):\nif condition.clinicalStatus ~ \"active\"\n  or condition.clinicalStatus ~ \"recurrence\"\n  or condition.clinicalStatus ~ \"relapse\" then\n  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]\nelse\n  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval())"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 31
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "AppropriateTreatmentforSTEMIFHIR"
      },
      {
        "url" : "name",
        "valueString" : "currentemergencyDepartmentArrivalTime"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Returns the emergency department arrival time for the encounter.\n*/\n\n\ndefine fluent function currentemergencyDepartmentArrivalTime(EDEncounter Encounter):\n  start of ( singleton from ( ( ( EDEncounter.location ) ) EDLocation\n        where CQMCommon.GetLocation ( EDLocation.location ).type in \"Emergency Department Visit\"\n    )\n  ).period"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 32
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "CQMCommon"
      },
      {
        "url" : "name",
        "valueString" : "GetLocation"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Returns the Location resource specified by the given reference\n@deprecated: This function is deprecated. Use the fluent function `getLocation()` instead.\n*/\ndefine function \"GetLocation\"(reference Reference ):\n  singleton from (\n    [Location] L where L.id = reference.reference.getId()\n  )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 33
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToString"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToString(value uri): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 34
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToCode"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.\n*/\ndefine function ToCode(coding FHIR.Coding):\n    if coding is null then\n        null\n    else\n        System.Code {\n          code: coding.code.value,\n          system: coding.system.value,\n          version: coding.version.value,\n          display: coding.display.value\n        }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 35
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "QICoreCommon"
      },
      {
        "url" : "name",
        "valueString" : "toInterval"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval\n@comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> types\nto an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible\nrepresentations for timing-valued elements in QICore, allowing this function to be used across any resource.\nThe input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.\nThe intent of this function is to provide a clear and concise mechanism to treat single\nelements that have multiple possible representations as intervals so that logic doesn't have to account\nfor the variability. More complex calculations (such as medication request period or dispense period\ncalculation) need specific guidance and consideration. That guidance may make use of this function, but\nthe focus of this function is on single element calculations where the semantics are unambiguous.\nIf the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.\nIf the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,\nand the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.\nIf the input is a DateTime Interval, the result is the input.\nIf the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result\nis a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending\nimmediately before one year later than the date the patient turned the age given as the end of the quantity interval.\nAny other input will reslt in a null DateTime Interval\n*/\ndefine fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>>):\n  case\n\t  when choice is DateTime then\n    \tInterval[choice as DateTime, choice as DateTime]\n\t\twhen choice is Interval<DateTime> then\n  \t\tchoice as Interval<DateTime>\n\t\twhen choice is Quantity then\n\t\t  Interval[Patient.birthDate + (choice as Quantity),\n\t\t\t  Patient.birthDate + (choice as Quantity) + 1 year)\n\t\twhen choice is Interval<Quantity> then\n\t\t  Interval[Patient.birthDate + (choice.low as Quantity),\n\t\t\t  Patient.birthDate + (choice.high as Quantity) + 1 year)\n\t\telse\n\t\t\tnull as Interval<DateTime>\n\tend"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 36
      }],
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"
    }],
    "status" : "active",
    "type" : {
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/library-type",
        "code" : "module-definition"
      }]
    },
    "relatedArtifact" : [{
      "type" : "depends-on",
      "display" : "Library SDE",
      "resource" : "http://ecqi.healthit.gov/ecqms/Library/SupplementalDataElements|3.4.000"
    },
    {
      "type" : "depends-on",
      "display" : "Library FHIRHelpers",
      "resource" : "http://ecqi.healthit.gov/ecqms/Library/FHIRHelpers|4.3.000"
    },
    {
      "type" : "depends-on",
      "display" : "Library CQMCommon",
      "resource" : "http://ecqi.healthit.gov/ecqms/Library/CQMCommon|1.4.000"
    },
    {
      "type" : "depends-on",
      "display" : "Library QICoreCommon",
      "resource" : "http://ecqi.healthit.gov/ecqms/Library/QICoreCommon|1.5.000"
    },
    {
      "type" : "depends-on",
      "display" : "Code system AdministrativeGender",
      "resource" : "http://hl7.org/fhir/v3/AdministrativeGender"
    },
    {
      "type" : "depends-on",
      "display" : "Code system ActCode",
      "resource" : "http://terminology.hl7.org/CodeSystem/v3-ActCode"
    },
    {
      "type" : "depends-on",
      "display" : "Code system ConditionClinicalStatusCodes",
      "resource" : "http://terminology.hl7.org/CodeSystem/condition-clinical"
    },
    {
      "type" : "depends-on",
      "display" : "Code system AllergyIntoleranceClinicalStatusCodes",
      "resource" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"
    },
    {
      "type" : "depends-on",
      "display" : "Value set ED",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1085"
    },
    {
      "type" : "depends-on",
      "display" : "Value set STEMI",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4017"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Fibrinolytic Therapy",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4020"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Emergency Department Visit",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Percutaneous Coronary Intervention",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.2000.5"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Discharge To Acute Care Facility",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Payer Type",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Thrombolytic medications",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.4"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Adverse reaction to thrombolytics",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.6"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Active Bleeding Excluding Menses or Bleeding Diathesis",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4036"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Malignant Intracranial Neoplasm Group",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.3"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Cerebral Vascular Lesion",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4025"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Dementia",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4043"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Pregnancy",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4055"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Allergy to thrombolytics",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.5"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Oral Anticoagulant Medications",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4045"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Aortic Dissection and Rupture",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4028"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Neurologic impairment",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.114.12.1012"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Cardiopulmonary Arrest",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4048"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Major Surgical Procedure",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4056"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Endotracheal Intubation",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.69"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Insertion or Replacement of Mechanical Circulatory Assist Device",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4052"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Ischemic Stroke",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.104.12.1024"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Closed Head and Facial Trauma",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4026"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Active Peptic Ulcer",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4031"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Intracranial or Intraspinal surgery",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.2"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Patient Expired",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309"
    }],
    "parameter" : [{
      "name" : "Measurement Period",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "type" : "Period"
    },
    {
      "name" : "SDE Sex",
      "use" : "out",
      "min" : 0,
      "max" : "1",
      "type" : "Coding"
    },
    {
      "name" : "Numerator",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Resource"
    },
    {
      "name" : "Denominator",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Resource"
    },
    {
      "name" : "SDE Payer",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Resource"
    },
    {
      "name" : "Initial Population",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Resource"
    },
    {
      "name" : "SDE Ethnicity",
      "use" : "out",
      "min" : 0,
      "max" : "1",
      "type" : "Resource"
    },
    {
      "name" : "Denominator Exclusions",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Resource"
    },
    {
      "name" : "SDE Race",
      "use" : "out",
      "min" : 0,
      "max" : "1",
      "type" : "Resource"
    }],
    "dataRequirement" : [{
      "type" : "Patient",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient"],
      "mustSupport" : ["ethnicity", "race"]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["id", "id.value", "code"]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code", "clinicalStatus"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4017"
      },
      {
        "path" : "clinicalStatus"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4036"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.3"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4025"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4043"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4055"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.5"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4028"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.114.12.1012"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.104.12.1024"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4026"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4031"
      }]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition"],
      "mustSupport" : ["code"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4048"
      }]
    },
    {
      "type" : "Encounter",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"],
      "mustSupport" : ["type",
      "status",
      "status.value",
      "class",
      "period",
      "condition",
      "condition.reference",
      "condition.reference.value",
      "location",
      "location.type",
      "hospitalization",
      "hospitalization.dischargeDisposition"],
      "codeFilter" : [{
        "path" : "type",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1085"
      },
      {
        "path" : "status.value",
        "code" : [{
          "code" : "finished"
        }]
      },
      {
        "path" : "class"
      }]
    },
    {
      "type" : "Encounter",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"],
      "mustSupport" : ["type",
      "status",
      "status.value",
      "class",
      "reasonCode",
      "period",
      "condition",
      "condition.reference",
      "condition.reference.value",
      "location",
      "location.type",
      "hospitalization",
      "hospitalization.dischargeDisposition"],
      "codeFilter" : [{
        "path" : "type",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1085"
      }]
    },
    {
      "type" : "Location",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-location"],
      "mustSupport" : ["id", "id.value"]
    },
    {
      "type" : "MedicationAdministration",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration"],
      "mustSupport" : ["medication", "status", "status.value", "effective"],
      "codeFilter" : [{
        "path" : "medication",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4020"
      }]
    },
    {
      "type" : "Procedure",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"],
      "mustSupport" : ["code", "performed", "status", "status.value"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.2000.5"
      },
      {
        "path" : "status.value",
        "code" : [{
          "code" : "completed"
        }]
      }]
    },
    {
      "type" : "Procedure",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"],
      "mustSupport" : ["code", "performed", "status", "status.value"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4056"
      },
      {
        "path" : "status.value",
        "code" : [{
          "code" : "completed"
        }]
      }]
    },
    {
      "type" : "Procedure",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"],
      "mustSupport" : ["code", "performed", "status", "status.value"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.69"
      }]
    },
    {
      "type" : "Procedure",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"],
      "mustSupport" : ["code", "performed", "status", "status.value"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4052"
      }]
    },
    {
      "type" : "Procedure",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure"],
      "mustSupport" : ["code", "performed", "status", "status.value"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.2"
      },
      {
        "path" : "status.value",
        "code" : [{
          "code" : "completed"
        }]
      }]
    },
    {
      "type" : "Coverage",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage"],
      "mustSupport" : ["type", "period"],
      "codeFilter" : [{
        "path" : "type",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"
      }]
    },
    {
      "type" : "AllergyIntolerance",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-allergyintolerance"],
      "mustSupport" : ["code", "clinicalStatus", "onset"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.4"
      },
      {
        "path" : "clinicalStatus"
      }]
    },
    {
      "type" : "AdverseEvent",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-adverseevent"],
      "mustSupport" : ["event",
      "recordedDate",
      "recordedDate.value",
      "actuality",
      "actuality.value"],
      "codeFilter" : [{
        "path" : "event",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1170.6"
      },
      {
        "path" : "actuality.value",
        "code" : [{
          "code" : "actual"
        }]
      }]
    },
    {
      "extension" : [{
        "extension" : [{
          "url" : "targetId",
          "valueString" : "G10002"
        },
        {
          "url" : "targetProperty",
          "valueString" : "medication"
        }],
        "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-relatedRequirement"
      }],
      "type" : "Medication",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication"],
      "mustSupport" : ["id"]
    },
    {
      "id" : "G10002",
      "type" : "MedicationRequest",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest"],
      "mustSupport" : ["medication.reference",
      "status",
      "status.value",
      "intent",
      "intent.value",
      "authoredOn",
      "authoredOn.value"]
    },
    {
      "type" : "MedicationRequest",
      "profile" : ["http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest"],
      "mustSupport" : ["medication",
      "status",
      "status.value",
      "intent",
      "intent.value",
      "authoredOn",
      "authoredOn.value"],
      "codeFilter" : [{
        "path" : "medication",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.4045"
      }]
    }]
  }],
  "extension" : [{
    "id" : "supplementalDataGuidance",
    "extension" : [{
      "url" : "guidance"
    },
    {
      "url" : "usage",
      "valueCodeableConcept" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
          "code" : "supplemental-data",
          "display" : "Supplemental Data"
        }],
        "text" : "Supplemental Data Guidance"
      }
    }],
    "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-supplementalDataGuidance"
  },
  {
    "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-softwaresystem",
    "valueReference" : {
      "reference" : "Device/cqf-tooling"
    }
  },
  {
    "id" : "effective-data-requirements",
    "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-effectiveDataRequirements",
    "valueReference" : {
      "reference" : "#effective-data-requirements"
    }
  }],
  "url" : "http://ecqi.healthit.gov/ecqms/Measure/AppropriateTreatmentforSTEMIFHIR",
  "identifier" : [{
    "use" : "usual",
    "type" : {
      "coding" : [{
        "system" : "http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type",
        "code" : "short-name"
      }]
    },
    "system" : "https://madie.cms.gov/measure/shortName",
    "value" : "CMS996FHIR"
  },
  {
    "use" : "official",
    "type" : {
      "coding" : [{
        "system" : "http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type",
        "code" : "version-independent"
      }]
    },
    "system" : "urn:ietf:rfc:3986",
    "value" : "urn:uuid:a48685e0-4926-4ae8-9eb3-d8e8839b1704"
  },
  {
    "use" : "official",
    "type" : {
      "coding" : [{
        "system" : "http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type",
        "code" : "version-specific"
      }]
    },
    "system" : "urn:ietf:rfc:3986",
    "value" : "urn:uuid:2c92808482113ece01821188a1500069"
  },
  {
    "use" : "official",
    "type" : {
      "coding" : [{
        "system" : "http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type",
        "code" : "endorser"
      }]
    },
    "system" : "https://madie.cms.gov/measure/nqfId",
    "value" : "3613e",
    "assigner" : {
      "display" : "NQF"
    }
  },
  {
    "use" : "official",
    "type" : {
      "coding" : [{
        "system" : "http://hl7.org/fhir/us/cqfmeasures/CodeSystem/identifier-type",
        "code" : "publisher"
      }]
    },
    "system" : "https://madie.cms.gov/measure/cmsId",
    "value" : "996FHIR",
    "assigner" : {
      "display" : "CMS"
    }
  }],
  "version" : "0.0.008",
  "name" : "AppropriateTreatmentforSTEMIFHIR",
  "title" : "Appropriate Treatment for ST-Segment Elevation Myocardial Infarction (STEMI) Patients in the Emergency Department (ED)FHIR",
  "status" : "draft",
  "experimental" : false,
  "date" : "2023-10-27T08:12:31+00:00",
  "publisher" : "Centers for Medicare & Medicaid Services (CMS)",
  "contact" : [{
    "telecom" : [{
      "system" : "url",
      "value" : "https://www.cms.gov/"
    }]
  }],
  "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",
  "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.\n\nThis FHIR-based measure has been derived from the QDM-based measure: CMS996v4.\n\nPlease 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).",
  "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.\n\nThis material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2022 International Health Terminology Standards Development Organisation. All rights reserved.\n\nLOINC(R) copyright 2004-2022 Regenstrief Institute, Inc.\n\nCPT(R) contained in the Measure specifications is copyright 2004-2022 American Medical Association.\n\nICD-10 is copyright 2022 World Health Organization. All Rights Reserved.",
  "approvalDate" : "2023-08-17",
  "lastReviewDate" : "2023-08-17",
  "effectivePeriod" : {
    "start" : "2024-01-01",
    "end" : "2024-12-31"
  },
  "author" : [{
    "name" : "Yale New Haven Health Service Corporation/ Center for Outcomes Research and Evaluation",
    "telecom" : [{
      "system" : "url",
      "value" : "https://medicine.yale.edu/core/"
    }]
  },
  {
    "name" : "The Lewin Group",
    "telecom" : [{
      "system" : "url",
      "value" : "https://www.lewin.com/"
    }]
  }],
  "library" : ["http://ecqi.healthit.gov/ecqms/Library/AppropriateTreatmentforSTEMIFHIR"],
  "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.\n\nTHE MEASURES AND SPECIFICATIONS ARE PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND.\n\nDue 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). \nThe 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).\nImplementation 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.",
  "clinicalRecommendationStatement" : "Primary PCI in STEMI:\nThe 2013 ACCF/AHA clinical practice guideline for the management of STEMI recommends that:\n- \"Primary PCI should be performed in patients with STEMI and ischemic symptoms of less than 12 hours’ duration.\"\n- \"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.\"\n \nFibrinolytic Therapy when there is an Anticipated Delay to Performing Primary PCI within 120 Minutes of First Medical Contact:\nThe 2013 ACCF/AHA clinical practice guideline for the management of STEMI recommends that:\n- \"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.”\n \nTransfer to a PCI-Capable Hospital after Fibrinolytic Therapy:\nThe 2013 ACCF/AHA clinical practice guideline for the management of STEMI recommends that:\n- 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.\n- 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. \n- 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.",
  "group" : [{
    "id" : "6384fdb64ba3d47c885c02a6",
    "extension" : [{
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-scoring",
      "valueCodeableConcept" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-scoring",
          "code" : "proportion",
          "display" : "Proportion"
        }]
      }
    },
    {
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis",
      "valueCode" : "Encounter"
    },
    {
      "url" : "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-type",
      "valueCodeableConcept" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-type",
          "code" : "process",
          "display" : "Process"
        }]
      }
    }],
    "population" : [{
      "id" : "9368D43C-EC53-489B-BFAB-E61F16298E63",
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "initial-population",
          "display" : "Initial Population"
        }]
      },
      "description" : "All emergency department encounters for patients 18 years and older with a diagnosis of ST-segment elevation myocardial infarction (STEMI)",
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Initial Population"
      }
    },
    {
      "id" : "EBF05C28-BF39-423D-A055-FCD964FE0333",
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "denominator",
          "display" : "Denominator"
        }]
      },
      "description" : "Equals Initial Population",
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Denominator"
      }
    },
    {
      "id" : "9BDC7445-0BF6-4941-8732-893B185A378E",
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "denominator-exclusion",
          "display" : "Denominator Exclusion"
        }]
      },
      "description" : "Patients with the following conditions are excluded from measure denominator:\n • Expired in the ED\n • Bleeding or bleeding diathesis (excluding menses)\n • Intracranial or intraspinal surgery\n • Ischemic stroke \n • Known malignant intracranial neoplasm (primary or metastatic)\n • Known structural cerebral vascular lesion (e.g., AVM)\n • Significant facial and/or closed head trauma\n • Suspected aortic dissection\n •  Peptic ulcer\n •  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\n • Allergic reaction to alteplase, streptokinase, anistreplase, tenecteplase, or reteplase\n • Intubation, including endotracheal intubation, mechanical ventilation, nasotracheal intubation, or orotracheal intubation\n • 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\n • Oral anticoagulant therapy \n • Advanced dementia\n • Pregnancy\n • Internal bleeding\n • Major surgery\n • Severe neurologic impairment (e.g., based on Glasgow coma scale or as indicated by the patient receiving therapeutic hypothermia in the ED)",
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Denominator Exclusions"
      }
    },
    {
      "id" : "D66FC17B-ABED-4476-A524-B092500128D9",
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "numerator",
          "display" : "Numerator"
        }]
      },
      "description" : "Emergency department encounters with a diagnosis of STEMI:\n - where time from ED arrival to fibrinolysis is 30 minutes or fewer;\nOR \n- where PCI is performed within 90 minutes of arrival for non-transfer patients; \nOR\n- where the patient is transferred within 45 minutes of ED arrival.",
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Numerator"
      }
    },
    {
      "id" : "dfe4fe2d-fdea-484b-bd77-b2e4bd2523a3",
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "numerator-exclusion",
          "display" : "Numerator Exclusion"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier"
      }
    },
    {
      "id" : "752e3422-6975-4e47-8557-a2cb68f6adad",
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "denominator-exception",
          "display" : "Denominator Exception"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier"
      }
    }]
  }],
  "supplementalData" : [{
    "id" : "sde-ethnicity",
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "description" : "SDE Ethnicity",
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Ethnicity"
    }
  },
  {
    "id" : "sde-payer",
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "description" : "SDE Payer",
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Payer"
    }
  },
  {
    "id" : "sde-race",
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "description" : "SDE Race",
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Race"
    }
  },
  {
    "id" : "sde-sex",
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "description" : "SDE Sex",
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Sex"
    }
  }]
}

```
