eCQM QICore Content Implementation Guide
2024.0.0 - CI Build

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

Measure: Antithrombotic Therapy By End of Hospital Day 2FHIR

Official URL: https://madie.cms.gov/Measure/AntithromboticTherapyByEndofHospitalDay2FHIR Version: 0.7.000
Draft as of 2024-07-09 Responsible: The Joint Commission Computable Name: AntithromboticTherapyByEndofHospitalDay2FHIR
Other Identifiers: Short Name (use: usual, ), UUID:b6ae4357-9baa-4195-a9cd-50391b7d0dab (use: official, ), UUID:e74bdff8-3857-471e-a0c5-b9307889bda6 (use: official, ), Publisher (use: official, )

Copyright/Legal: Measure specifications are in the Public Domain

LOINC(R) copyright 2004-2023 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2023 International Health Terminology Standards Development Organisation. ICD-10 copyright 2023 World Health Organization. All Rights Reserved.

Ischemic stroke patients administered antithrombotic therapy by the end of hospital day 2

UNKNOWN

Title: Antithrombotic Therapy By End of Hospital Day 2FHIR
Id: AntithromboticTherapyByEndofHospitalDay2FHIR
Version: 0.7.000
Url: Antithrombotic Therapy By End of Hospital Day 2FHIR
short-name identifier:

CMS72FHIR

version-independent identifier:

urn:uuid:b6ae4357-9baa-4195-a9cd-50391b7d0dab

version-specific identifier:

urn:uuid:e74bdff8-3857-471e-a0c5-b9307889bda6

publisher (CMS) identifier:

72FHIR

Effective Period: 2025-01-01..2025-12-31
Status: draft
Publisher: The Joint Commission
Author: The Joint Commission
Description:

Ischemic stroke patients administered antithrombotic therapy by the end of hospital day 2

Purpose:

UNKNOWN

Copyright:

Measure specifications are in the Public Domain

LOINC(R) copyright 2004-2023 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2023 International Health Terminology Standards Development Organisation. ICD-10 copyright 2023 World Health Organization. All Rights Reserved.

Disclaimer:

These performance measures 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 without warranty.

Scoring:

Proportion

Rationale:

The effectiveness of antithrombotic agents in reducing stroke mortality, stroke-related morbidity and recurrence rates has been studied in several large clinical trials. While the use of these agents for patients with acute ischemic stroke and transient ischemic attacks (TIA) continues to be the subject of study, substantial evidence is available from completed studies. Data at this time suggest that antithrombotic therapy should be administered within 2 days of symptom onset in acute ischemic stroke patients to reduce stroke mortality and morbidity as long as no contraindications exist.

Aspirin is the recommended antithrombotic medication for early antithrombotic therapy and most frequently administered unless contraindicated. Anticoagulants at doses to prevent venous thromboembolism (VTE) are insufficient. Subcutaneous Lovenox (enoxaparin) and unfractionated heparin (UFH) SQ at lower dosages used for VTE prophylaxis (i.e., enoxaparin SQ 40 mg once daily; enoxaparin SQ 30 mg Q12 hours; UFH 5,000 units or less two or three times daily) are not sufficient for early antithrombotic therapy.

Anticoagulants at doses to prevent VTE are insufficient antithrombotic therapy to prevent recurrent ischemic stroke or TIA.

Clinical recommendation statement:

Antithrombotic therapy should be administered within 2 days of symptom onset in acute ischemic stroke patients to reduce stroke mortality and morbidity as long as no contraindications exist

Guidance (Usage): The "Nonelective Inpatient Encounter" value set intends to capture all non-scheduled hospitalizations. This value set is a subset of the "Inpatient Encounter" value set, excluding concepts that specifically refer to elective hospital admissions. Non-elective Inpatient Encounters include emergency, urgent, and unplanned admissions. NPO (Nothing by mouth) is not a valid reason for not administering antithrombotic therapy by end of hospital day 2 as another route of administration can be used (i.e., rectal or intravenous). In the denominator exclusions, the intent is to only exclude patients with a total length of stay of <2 days, including Emergency Department (ED) visit (if there is one). For the eCQM we model both of the scenarios of admission via the ED as well as direct admits. This statement addresses direct admits. The denominator population includes patients with inpatient hospitalizations and patients from Acute Hospital Care at Home programs, who are treated and billed as inpatients but receive care in their home. This eCQM is an episode-based measure. An episode is defined as each inpatient hospitalization or encounter that ends during the measurement period. This FHIR-based measure has been derived from the QDM-based measure: CMS72v13. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (https://hl7.org/fhir/us/qicore/STU4.1.1/qdm-to-qicore.html).
Population Criteria:
64f0d9e456d636294b157dec
Initial Population: Inpatient hospitalization (non-elective admissions) for patients age 18 and older, discharged from inpatient care with a principal diagnosis of ischemic stroke that ends during the measurement period
Denominator: Equals Initial Population
Denominator Exclusion: - Inpatient hospitalization for patients who have a duration of stay less than 2 days. - Inpatient hospitalization for patients with comfort measures documented day of or the day after arrival. - Inpatient hospitalization for patients with intra-venous or intra-arterial Thrombolytic (t-PA) Therapy administered within 24 hours prior to arrival or anytime during hospitalization.
Numerator: Inpatient hospitalization for patients who had antithrombotic therapy administered the day of or day after hospital arrival
Denominator Exception: - Inpatient hospitalization for patients with a documented reason for not administering antithrombotic therapy the day of or day after hospital arrival. - Inpatient hospitalization for patients who receive Prasugrel as an antithrombotic therapy the day of or day after hospital arrival. - Inpatient hospitalization for patients with an international normalised ratio (INR) greater than 3.5.
Supplemental Data Elements:

SDE Ethnicity

SDE Payer

SDE Race

SDE Sex

Supplemental Data Guidance : For every patient evaluated by this measure also identify payer, race, ethnicity and sex; SDE Ethnicity-Patient's Ethnicity: Hispanic or Latino Not Hispanic or Latino SDE Payer-Patient's Payer: Categories of types of health care payer entities as defined by the US Public Health Data Consortium SOP code system SDE Race-Patient's Race: Native Hawaiian or Other Pacific Islander Asian American Indian or Alaska Native Other Race White Black or African American SDE Sex-Patient's Sex: Gender identity restricted to only Male and Female used in administrative situations requiring a restriction to these two categories.
Libraries:
AntithromboticTherapyByEndofHospitalDay2FHIR
Terminology and Other Dependencies:
  • Library/SupplementalDataElements|3.5.000
  • Library/TJCOverall|8.14.000
  • Library/FHIRHelpers|4.4.000
  • Library/CQMCommon|2.2.000
  • Library/QICoreCommon|2.1.000
  • AdministrativeGender
  • Diagnosis Role
  • Condition Clinical Status Codes
  • ConditionVerificationStatus
  • Non-Elective Inpatient Encounter
  • Ischemic Stroke
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.62
  • Observation Services
  • Emergency Department Visit
  • Payer
  • Comfort Measures
  • Thrombolytic (t-PA) Therapy
  • Intravenous or Intra-arterial Thrombolytic (t-PA) Therapy
  • Intravenous or Intra arterial Thrombolytic (tPA) Therapy Prior to Arrival
  • Medical Reason
  • Patient Refusal
  • Pharmacological Contraindications For Antithrombotic Therapy
  • INR
  • Parameters:
    name use min max type
    Measurement Period In 0 1 Period
    SDE Sex Out 0 1 Coding
    Numerator Out 0 * Resource
    Denominator Out 0 * Resource
    SDE Payer Out 0 * Resource
    Initial Population Out 0 * Resource
    SDE Ethnicity Out 0 1 Resource
    Denominator Exclusions Out 0 * Resource
    SDE Race Out 0 1 Resource
    Denominator Exceptions Out 0 * Resource
    DataRequirements:
    Resource Type Resource Elements Valueset Name Valueset
    Patient(QICorePatient) ethnicity race
    Encounter(QICoreEncounter) type status status.value period rank rank.value use condition condition.reference condition.reference.value Observation Services Observation Services
    Encounter(QICoreEncounter) type status status.value period rank rank.value use condition condition.reference condition.reference.value Emergency Department Visit Emergency Department Visit
    Encounter(QICoreEncounter) type period rank rank.value use condition condition.reference condition.reference.value Nonelective Inpatient Encounter Non-Elective Inpatient Encounter
    Condition(QICoreCondition) id id.value code
    Condition(QICoreCondition) code recordedDate recordedDate.value verificationStatus Intravenous or Intraarterial Thrombolytic tPA Therapy Prior to Arrival Intravenous or Intra arterial Thrombolytic (tPA) Therapy Prior to Arrival
    MedicationAdministration(QICoreMedicationAdministration) medication status status.value effective id id.value Antithrombotic Therapy for Ischemic Stroke http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.62
    MedicationAdministration(QICoreMedicationAdministration) medication status status.value effective id id.value Thrombolytic tPA Therapy Thrombolytic (t-PA) Therapy
    MedicationAdministration(QICoreMedicationAdministration) medication status status.value effective id id.value Pharmacological Contraindications For Antithrombotic Therapy Pharmacological Contraindications For Antithrombotic Therapy
    Coverage(QICoreCoverage) type period Payer Type Payer
    ServiceRequest(QICoreServiceRequest) code status status.value intent intent.value doNotPerform doNotPerform.value Comfort Measures Comfort Measures
    Procedure(QICoreProcedure) code status status.value Comfort Measures Comfort Measures
    Procedure(QICoreProcedure) code status status.value id id.value performed Intravenous or Intraarterial Thrombolytic tPA Therapy Intravenous or Intra-arterial Thrombolytic (t-PA) Therapy
    MedicationRequest(QICoreMedicationNotRequested) medication status status.value intent intent.value reasonCode id id.value authoredOn authoredOn.value Antithrombotic Therapy for Ischemic Stroke http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.62
    MedicationAdministration(QICoreMedicationAdministrationNotDone) medication statusReason id id.value extension Antithrombotic Therapy for Ischemic Stroke http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.62
    Observation(QICoreObservation) code value status status.value issued issued.value INR INR
    Direct Reference Codes:
    display code system
    Male M http://hl7.org/fhir/administrative-gender
    Female F http://hl7.org/fhir/administrative-gender
    Billing billing http://terminology.hl7.org/CodeSystem/diagnosis-role
    Active active http://terminology.hl7.org/CodeSystem/condition-clinical
    Recurrence recurrence http://terminology.hl7.org/CodeSystem/condition-clinical
    Relapse relapse http://terminology.hl7.org/CodeSystem/condition-clinical
    Confirmed confirmed http://terminology.hl7.org/CodeSystem/condition-ver-status
    Logic Definitions:
    Group Scoring Population Criteria Expression
    64f0d9e456d636294b157dec Group scoring: proportion Measure scoring:

    Proportion

    Type:

    Process

    Rate Aggregation: None
    Improvement Notation:

    increase

    Initial Population
    define "Initial Population":
      TJC."Ischemic Stroke Encounter"
    Denominator
    define "Denominator":
      "Initial Population"
    Denominator Exclusion
    define "Denominator Exclusions":
      "Encounter Less Than Two Days"
        union "Encounter with Comfort Measures during Day of or Day After Arrival"
        union "Encounter with Thrombolytic Therapy Given Prior To Arrival Or During Hospitalization"
    Numerator
    define "Numerator":
      "Encounter with Antithrombotic Therapy"
    Denominator Exception
    define "Denominator Exceptions":
      "Encounter with Documented Reason for No Antithrombotic Ordered or Administered Day Of or Day After Hospital Arrival"
        union "Encounter with Pharmacological Contraindications for Antithrombotic Therapy Given Day Of or Day After Hospital Arrival"
        union "Encounter with An INR Greater Than 3.5"
    Library Name Name
    SupplementalDataElements SDE Sex
    define "SDE Sex":
      case
        when Patient.gender = 'male' then "M"
        when Patient.gender = 'female' then "F"
        else null
      end
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR SDE Sex
    define "SDE Sex":
      SDE."SDE Sex"
    Library Name Name
    TJCOverall Non Elective Inpatient Encounter with Age
    define "Non Elective Inpatient Encounter with Age":
      ["Encounter": "Nonelective Inpatient Encounter"] NonElectiveEncounter
            where AgeInYearsAt(date from start of NonElectiveEncounter.period ) >= 18
             and NonElectiveEncounter.period ends during day of "Measurement Period"
    Library Name Name
    TJCOverall Ischemic Stroke Encounter
    define "Ischemic Stroke Encounter":
      "Non Elective Inpatient Encounter with Age" NonElectiveEncounterWithAge
        where NonElectiveEncounterWithAge.principalDiagnosis().code in "Ischemic Stroke"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Antithrombotic Therapy
    define "Encounter with Antithrombotic Therapy":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        with ["MedicationAdministration": "Antithrombotic Therapy for Ischemic Stroke"] Antithrombotic
          such that Antithrombotic.status in { 'in-progress', 'completed' }
            and Antithrombotic.effective.toInterval ( ) starts during day of ( start of IschemicStrokeEncounter.hospitalizationWithObservation ( ) ).CalendarDayOfOrDayAfter ( )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Numerator
    define "Numerator":
      "Encounter with Antithrombotic Therapy"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Initial Population
    define "Initial Population":
      TJC."Ischemic Stroke Encounter"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Denominator
    define "Denominator":
      "Initial Population"
    Library Name Name
    SupplementalDataElements SDE Payer
    define "SDE Payer":
      [Coverage: type in "Payer Type"] Payer
        return {
          code: Payer.type,
          period: Payer.period
        }
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR SDE Payer
    define "SDE Payer":
      SDE."SDE Payer"
    Library Name Name
    SupplementalDataElements SDE Ethnicity
    define "SDE Ethnicity":
      Patient.ethnicity E
        return Tuple {
          codes: { E.ombCategory } union E.detailed,
          display: E.text
        }
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR SDE Ethnicity
    define "SDE Ethnicity":
      SDE."SDE Ethnicity"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter Less Than Two Days
    define "Encounter Less Than Two Days":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        where IschemicStrokeEncounter.hospitalizationWithObservation ( ).lengthInDays ( ) < 2
    Library Name Name
    TJCOverall Intervention Comfort Measures
    define "Intervention Comfort Measures":
      ( ["ServiceRequest": code in "Comfort Measures"] SR
        where SR.status in { 'active', 'completed', 'on-hold' }
          and SR.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
          and SR.doNotPerform is not true
      )  
      union ( ["Procedure": "Comfort Measures"] InterventionPerformed
            where InterventionPerformed.status in { 'completed', 'in-progress' }
      )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Comfort Measures during Day of or Day After Arrival
    define "Encounter with Comfort Measures during Day of or Day After Arrival":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        with TJC."Intervention Comfort Measures" ComfortMeasure
          such that Coalesce(start of ComfortMeasure.performed.toInterval(), ComfortMeasure.authoredOn) during day of ( start of IschemicStrokeEncounter.hospitalizationWithObservation ( ) ).CalendarDayOfOrDayAfter ( )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Thrombolytic Therapy Medication or Procedures
    define "Thrombolytic Therapy Medication or Procedures":
      ( ["MedicationAdministration": "Thrombolytic tPA Therapy"] ThrombolyticMedication
          where ThrombolyticMedication.status in { 'in-progress', 'completed' }
          return {
            id: ThrombolyticMedication.id,
            effective: ThrombolyticMedication.effective
          }
      )
        union ( ["Procedure": "Intravenous or Intraarterial Thrombolytic tPA Therapy"] ThrombolyticProcedure
            where ThrombolyticProcedure.status = 'completed'
            return {
              id: ThrombolyticProcedure.id,
              effective: ThrombolyticProcedure.performed
            }
        )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Thrombolytic Therapy Medication or Procedures
    define "Encounter with Thrombolytic Therapy Medication or Procedures":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        with "Thrombolytic Therapy Medication or Procedures" ThrombolyticTherapy
          such that ThrombolyticTherapy.effective.toInterval ( ) starts during Interval[start of IschemicStrokeEncounter.hospitalizationWithObservation ( ) - 24 hours, end of IschemicStrokeEncounter.hospitalizationWithObservation ( ) )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Thrombolytic Therapy Prior to Arrival
    define "Encounter with Thrombolytic Therapy Prior to Arrival":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        where exists ( ( IschemicStrokeEncounter.encounterDiagnosis ( ) ) EncounterDiagnosis
            where ( EncounterDiagnosis.code in "Intravenous or Intraarterial Thrombolytic tPA Therapy Prior to Arrival" )
        )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Thrombolytic Therapy Documented As Already Given
    define "Encounter with Thrombolytic Therapy Documented As Already Given":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        with [Condition: "Intravenous or Intraarterial Thrombolytic tPA Therapy Prior to Arrival"] PriorTPA
          such that PriorTPA.recordedDate during CQMCommon."HospitalizationWithObservation" ( IschemicStrokeEncounter )
            and PriorTPA.isActive ( )
            and PriorTPA.verificationStatus is not null
            and PriorTPA.verificationStatus ~ QICoreCommon."confirmed"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Thrombolytic Therapy Given Prior To Arrival Or During Hospitalization
    define "Encounter with Thrombolytic Therapy Given Prior To Arrival Or During Hospitalization":
      "Encounter with Thrombolytic Therapy Medication or Procedures"
        union "Encounter with Thrombolytic Therapy Prior to Arrival"
        union "Encounter with Thrombolytic Therapy Documented As Already Given"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Denominator Exclusions
    define "Denominator Exclusions":
      "Encounter Less Than Two Days"
        union "Encounter with Comfort Measures during Day of or Day After Arrival"
        union "Encounter with Thrombolytic Therapy Given Prior To Arrival Or During Hospitalization"
    Library Name Name
    SupplementalDataElements SDE Race
    define "SDE Race":
      Patient.race R
        return Tuple {
          codes: R.ombCategory union R.detailed,
          display: R.text
        }
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR SDE Race
    define "SDE Race":
      SDE."SDE Race"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Reason for Not Ordering Antithrombotic
    define "Reason for Not Ordering Antithrombotic":
      ["MedicationNotRequested": medication in "Antithrombotic Therapy for Ischemic Stroke"] NoAntithromboticOrder
        where NoAntithromboticOrder.status = 'completed'
          and NoAntithromboticOrder.intent = 'order'
          and ( NoAntithromboticOrder.reasonCode in "Medical Reason for Not Providing Treatment"
              or NoAntithromboticOrder.reasonCode in "Patient Refusal"
          )
        return {
          id: NoAntithromboticOrder.id,
          authoredOn: NoAntithromboticOrder.authoredOn
        }
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Reason for Not Administering Antithrombotic
    define "Reason for Not Administering Antithrombotic":
      ["MedicationAdministrationNotDone": medication in "Antithrombotic Therapy for Ischemic Stroke"] MedicationAdm
        where ( MedicationAdm.statusReason in "Medical Reason for Not Providing Treatment"
            or MedicationAdm.statusReason in "Patient Refusal"
        )
        return {
          id: MedicationAdm.id,
          authoredOn: MedicationAdm.recorded
        }
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Documented Reason for No Antithrombotic Ordered or Administered
    define "Documented Reason for No Antithrombotic Ordered or Administered":
      "Reason for Not Ordering Antithrombotic"
        union "Reason for Not Administering Antithrombotic"
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Documented Reason for No Antithrombotic Ordered or Administered Day Of or Day After Hospital Arrival
    define "Encounter with Documented Reason for No Antithrombotic Ordered or Administered Day Of or Day After Hospital Arrival":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        with "Documented Reason for No Antithrombotic Ordered or Administered" NoAntithrombotic
          such that NoAntithrombotic.authoredOn during day of ( start of IschemicStrokeEncounter.hospitalizationWithObservation ( ) ).CalendarDayOfOrDayAfter ( )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with Pharmacological Contraindications for Antithrombotic Therapy Given Day Of or Day After Hospital Arrival
    define "Encounter with Pharmacological Contraindications for Antithrombotic Therapy Given Day Of or Day After Hospital Arrival":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        with ["MedicationAdministration": "Pharmacological Contraindications For Antithrombotic Therapy"] PharmacologicalContraindications
          such that PharmacologicalContraindications.status in { 'in-progress', 'completed' }
            and PharmacologicalContraindications.effective.toInterval ( ) starts during day of ( start of IschemicStrokeEncounter.hospitalizationWithObservation ( ) ).CalendarDayOfOrDayAfter ( )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Encounter with An INR Greater Than 3.5
    define "Encounter with An INR Greater Than 3.5":
      TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
        with ["Observation": "INR"] INR
          such that INR.value as Quantity > 3.5
            and INR.status in { 'final', 'amended', 'corrected' }
            and INR.issued during day of ( start of IschemicStrokeEncounter.hospitalizationWithObservation ( ) ).CalendarDayOfOrDayAfter ( )
    Library Name Name
    AntithromboticTherapyByEndofHospitalDay2FHIR Denominator Exceptions
    define "Denominator Exceptions":
      "Encounter with Documented Reason for No Antithrombotic Ordered or Administered Day Of or Day After Hospital Arrival"
        union "Encounter with Pharmacological Contraindications for Antithrombotic Therapy Given Day Of or Day After Hospital Arrival"
        union "Encounter with An INR Greater Than 3.5"
    Library Name Name
    CQMCommon principalDiagnosis
    /*
    @description: Returns the condition that is specified as the principal diagnosis for the encounter
    */
    define fluent function principalDiagnosis(Encounter Encounter ):
    	singleton from ((Encounter.diagnosis D where D.rank = 1 and D.use ~ "Billing") PD
          return singleton from ([Condition] C where C.id = PD.condition.reference.getId())
    	)
    Library Name Name
    QICoreCommon getId
    /*
    @description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
    @comment: This function can be used to determine the logical id of a given resource. It can be used in
    a single-server environment to trace references. However, this function does not attempt to resolve
    or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
    */
    define fluent function getId(uri String):
      Last(Split(uri, '/'))
    Library Name Name
    TJCOverall CalendarDayOfOrDayAfter
    define fluent function CalendarDayOfOrDayAfter(StartValue DateTime):
      Interval [date from (StartValue), date from (StartValue) + 1 day]
    Library Name Name
    CQMCommon hospitalizationWithObservation
    /*
    @description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
    */
    define fluent function hospitalizationWithObservation(TheEncounter Encounter ):
      TheEncounter Visit
      		let ObsVisit: Last([Encounter: "Observation Services"] LastObs
      				where LastObs.status = 'finished'
                and LastObs.period ends 1 hour or less on or before start of Visit.period
      				sort by end of period
      			),
      			VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
      			EDVisit: Last([Encounter: "Emergency Department Visit"] LastED
      				where LastED.status = 'finished'
                and LastED.period ends 1 hour or less on or before VisitStart
      				sort by end of period
      			)
      		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]
    Library Name Name
    FHIRHelpers ToString
    define function ToString(value uri): value.value
    Library Name Name
    FHIRHelpers ToCode
    /*
    @description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
    */
    define function ToCode(coding FHIR.Coding):
        if coding is null then
            null
        else
            System.Code {
              code: coding.code.value,
              system: coding.system.value,
              version: coding.version.value,
              display: coding.display.value
            }
    Library Name Name
    CQMCommon lengthInDays
    /*
    @description: Calculates the difference in calendar days between the start and end of the given interval.
    */
    define fluent function lengthInDays(Value Interval<DateTime> ):
      difference in days between start of Value and end of Value
    Library Name Name
    CQMCommon encounterDiagnosis
    /*
    @description: Returns the Condition resources referenced by the diagnosis element of the Encounter
    */
    define fluent function encounterDiagnosis(Encounter Encounter ):
      Encounter.diagnosis D
        return singleton from ([Condition] C where C.id = D.condition.reference.getId())
    Library Name Name
    CQMCommon HospitalizationWithObservation
    /*
    @description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
    @deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservation()` instead.
    */
    define function "HospitalizationWithObservation"(TheEncounter Encounter ):
      TheEncounter Visit
      		let ObsVisit: Last([Encounter: "Observation Services"] LastObs
      				where LastObs.status = 'finished'
                and LastObs.period ends 1 hour or less on or before start of Visit.period
      				sort by end of period
      			),
      			VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
      			EDVisit: Last([Encounter: "Emergency Department Visit"] LastED
      				where LastED.status = 'finished'
                and LastED.period ends 1 hour or less on or before VisitStart
      				sort by end of period
      			)
      		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]
    Library Name Name
    QICoreCommon isActive
    /* Candidates for FHIRCommon */
    
    /*
    @description: Returns true if the given condition has a clinical status of active, recurrence, or relapse
    */
    define fluent function isActive(condition Condition):
      condition.clinicalStatus ~ "active"
        or condition.clinicalStatus ~ "recurrence"
        or condition.clinicalStatus ~ "relapse"
    Library Name Name
    FHIRHelpers ToConcept
    /*
    @description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
    */
    define function ToConcept(concept FHIR.CodeableConcept):
        if concept is null then
            null
        else
            System.Concept {
                codes: concept.coding C return ToCode(C),
                display: concept.text.value
            }