CMS FHIR Prototype Measure Calculation Tool IG
0.1.0 - CI Build

CMS FHIR Prototype Measure Calculation Tool IG, published by HL7 International - [Some] Work Group. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/mct-ig/ and changes regularly. See the Directory of published versions

## Library: Discharged on Antithrombotic Therapy QICore

Official URL: http://cms.gov/fhir/mct/Library/DischargedonAntithromboticTherapyQICore4 | Version: 0.1.0
Active as of 2021-08-24 | Computable Name: DischargedonAntithromboticTherapyQICore4

Discharged on Antithrombotic Therapy QICore

Id: | DischargedonAntithromboticTherapyQICore4
Url: | Discharged on Antithrombotic Therapy QICore
Version: | 0.1.0
Name: | DischargedonAntithromboticTherapyQICore4
Title: | Discharged on Antithrombotic Therapy QICore
Status: | active
Experimental: | false
Type: | system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library
Date: | 2021-08-24 19:12:29+0000
Publisher: | HL7 International - [Some] Work Group
Description: | Discharged on Antithrombotic Therapy QICore
Jurisdiction: | US
Content: text/cql
    library DischargedonAntithromboticTherapyQICore4 version '0.0.010'

    /* based upon FHIR library DischargedonAntithromboticTherapyFHIR4 version '0.4.000'
    PJM - updated to QICore, shared libraries, valuesets, default Interval to 2022
    Definition names with 'DISPLAY' are used to display pertinent data
    */

    using QICore version '4.1.1'

    include FHIRHelpers version '4.0.013' called FHIRHelpers
    include MATGlobalCommonFunctionsQICore4 version '7.0.000' called Global
    include QICoreCommon version '1.0.000' called QICoreCommon
    include SupplementalDataElementsQICore4 version '3.0.000' called SDE
    //include TJCOverallQICore4 version '6.0.000' called TJC

    valueset &quot;Antithrombotic Therapy&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.62'
    valueset &quot;Medical Reason&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.473'
    valueset &quot;Patient Refusal&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.93'
    valueset &quot;Pharmacological Contraindications For Antithrombotic Therapy&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.52'

    //from TJCOverall
    valueset &quot;Comfort Measures&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45'
    valueset &quot;Discharge To Acute Care Facility&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87'
    valueset &quot;Discharged to Health Care Facility for Hospice Care&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.207'
    valueset &quot;Discharged to Home for Hospice Care&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.209'
    valueset &quot;Emergency Department Visit&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292'
    valueset &quot;Encounter Inpatient&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
    valueset &quot;Hemorrhagic Stroke&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.212'
    valueset &quot;Ischemic Stroke&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.247'
    valueset &quot;Left Against Medical Advice&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308'
    valueset &quot;Non-Elective Inpatient Encounter&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.424'
    valueset &quot;Observation Services&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143'
    valueset &quot;Patient Expired&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309'
    valueset &quot;Ticagrelor Therapy&quot;: 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.39'

    parameter &quot;Measurement Period&quot; Interval&lt;DateTime&gt;
      default Interval[@2022-01-01T00:00:00.0, @2023-01-01T00:00:00.0)

    context Patient

    define &quot;Initial Population&quot;:
      &quot;Encounter with Principal Diagnosis and Age&quot;
    //ORIG TJC.&quot;Encounter with Principal Diagnosis and Age&quot;

    // PJM - fix for AgeInYearsAt issue
    //FIX current problem with AgeInYearsAt required a modified approach - refer to https://github.com/cqframework/ecqm-content-qicore-2022/issues/6
    define &quot;Encounter with Principal Diagnosis and Age&quot;:
      &quot;All Stroke Encounter&quot; AllStrokeEncounter
        where CalculateAgeInYearsAt ( Patient.birthDate, date from start of AllStrokeEncounter.period ) &gt;= 18
    //ORIG    where AgeInYearsAt(date from(start of AllStrokeEncounter.period))&gt;= 18

    //TJCOverall
    define &quot;Non Elective Inpatient Encounter&quot;:
      [&quot;Encounter&quot;: &quot;Non-Elective Inpatient Encounter&quot;] NonElectiveEncounter
    		where Global.&quot;LengthInDays&quot;(NonElectiveEncounter.period) &lt;= 120
    			and NonElectiveEncounter.period ends during day of &quot;Measurement Period&quot;

    //TJCOverall
    define &quot;All Stroke Encounter&quot;:
      &quot;Non Elective Inpatient Encounter&quot; NonElectiveEncounter
        let EncPrincipalDx: Global.&quot;PrincipalDiagnosis&quot;(NonElectiveEncounter)
        where NonElectiveEncounter.status ~ 'finished'
          and EncPrincipalDx.verificationStatus ~ QICoreCommon.&quot;confirmed&quot;
          and (EncPrincipalDx.code in &quot;Hemorrhagic Stroke&quot;
            or EncPrincipalDx.code in &quot;Ischemic Stroke&quot;
          )

    define &quot;Denominator&quot;:
      &quot;Ischemic Stroke Encounter&quot;

    //TJCOverall
    define &quot;Ischemic Stroke Encounter&quot;:
      &quot;Encounter with Principal Diagnosis and Age&quot; EncounterWithAge
        let EncPrincipalDx: Global.&quot;PrincipalDiagnosis&quot;(EncounterWithAge)
         where EncounterWithAge.status = 'finished'
           and EncPrincipalDx.code in &quot;Ischemic Stroke&quot;

    //TJCOverall
    //See if can work old way after Bryn gets Coalesce to work
    define &quot;Denominator Exclusions&quot;:
      &quot;Ischemic Stroke Encounters with Discharge Disposition&quot;
        union &quot;Encounter with Comfort Measure Procedure during Hospitalization&quot;
        union &quot;Encounter with Comfort Measure ServiceRequest during Hospitalization&quot;
    /*Original before QICore
    define &quot;Denominator Exclusions&quot;:
      TJC.&quot;Ischemic Stroke Encounters with Discharge Disposition&quot;
        union TJC.&quot;Encounter with Comfort Measures during Hospitalization&quot;
    */

    //TJCOverall
    define &quot;Ischemic Stroke Encounters with Discharge Disposition&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
        let EncDischDisp: IschemicStrokeEncounter.hospitalization.dischargeDisposition
            where EncDischDisp in &quot;Discharge To Acute Care Facility&quot;
               or EncDischDisp in &quot;Left Against Medical Advice&quot;
               or EncDischDisp in &quot;Patient Expired&quot;
               or EncDischDisp in &quot;Discharged to Home for Hospice Care&quot;
               or EncDischDisp in &quot;Discharged to Health Care Facility for Hospice Care&quot;

    define &quot;DISPLAY Comfort Measures during Hospitalization&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
        let ComfortMeasure: &quot;Intervention Comfort Measures&quot; ComfortMeasure
           where Coalesce(ComfortMeasure.performed, ComfortMeasure.authoredOn) during Global.&quot;HospitalizationWithObservation&quot;(IschemicStrokeEncounter)
         return Tuple {
           comfMeasPerformed: ComfortMeasure.performed,
           comfmeasPerfToInt: QICoreCommon.&quot;ToInterval&quot;(ComfortMeasure.performed),
           comfMeasAuthoredOn: ComfortMeasure.authoredOn,
           comfMeasCoalesce: Coalesce((start of QICoreCommon.&quot;ToInterval&quot;(ComfortMeasure.performed)), ComfortMeasure.authoredOn),
           hospitalization: Global.&quot;HospitalizationWithObservation&quot; ( IschemicStrokeEncounter )
         }

    //TJCOverall - needs Coalesce fix
    define &quot;Encounter with Comfort Measures during Hospitalization&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
        with &quot;Intervention Comfort Measures&quot; ComfortMeasure
         such that Coalesce((start of QICoreCommon.&quot;ToInterval&quot;(ComfortMeasure.performed)), ComfortMeasure.authoredOn) during Global.&quot;HospitalizationWithObservation&quot; ( IschemicStrokeEncounter )
    /*Original before QICore...Note: This is not used, could not get coalesce to work...instead split (see below)
    define &quot;Encounter with Comfort Measures during Hospitalization&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
              with &quot;Intervention Comfort Measures&quot; ComfortMeasure
                  such that Coalesce((start of Global.&quot;Normalize Interval&quot;(ComfortMeasure.performed)), ComfortMeasure.authoredOn)during Global.&quot;HospitalizationWithObservation&quot; ( IschemicStrokeEncounter )
    */

    //Note: Below does not have 'as dateTime' after performed because it errored, and tried many variations
    define &quot;Encounter with Comfort Measure Procedure during Hospitalization&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
        with &quot;Intervention Comfort Measures Procedure&quot; ComfortMeasure
         such that start of QICoreCommon.&quot;ToInterval&quot;(ComfortMeasure.performed) during Global.&quot;HospitalizationWithObservation&quot; ( IschemicStrokeEncounter )

    define &quot;Encounter with Comfort Measure ServiceRequest during Hospitalization&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
        with &quot;Intervention Comfort Measures ServiceRequest&quot; ComfortMeasure
         such that ComfortMeasure.authoredOn during Global.&quot;HospitalizationWithObservation&quot; ( IschemicStrokeEncounter )

    //TJCOverall
    //Note: Below is not used because could not get coalesce to work in &quot;Encounter with Comfort Measures during Hospitalization&quot;
    define &quot;Intervention Comfort Measures&quot;:
      ( [&quot;ServiceRequest&quot;: &quot;Comfort Measures&quot;] P
          where P.intent = 'order'
           and P.status in { 'active', 'on-hold', 'completed'}
      )
        union ( [&quot;Procedure&quot;: &quot;Comfort Measures&quot;] InterventionPerformed
            where InterventionPerformed.status in { 'completed', 'in-progress' }
        )

    //Instead split ServiceRequest and Procedure into two different definitions
    define &quot;Intervention Comfort Measures ServiceRequest&quot;:
      ( [&quot;ServiceRequest&quot;: &quot;Comfort Measures&quot;] P
          where P.intent = 'order'
           and P.status in { 'active', 'on-hold', 'completed'}
      )

    define &quot;Intervention Comfort Measures Procedure&quot;:
      ( [&quot;Procedure&quot;: &quot;Comfort Measures&quot;] InterventionPerformed
            where InterventionPerformed.status in { 'completed', 'in-progress' }
      )

    define &quot;Numerator&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
        with &quot;Antithrombotic Therapy at Discharge&quot; DischargeAntithrombotic
          such that DischargeAntithrombotic.authoredOn during IschemicStrokeEncounter.period

    //Note: QICore manual says to constrain status to 'active' and category to 'Community' and does not mention intent.
    //      ask Yanyan if should follow that or what is below.
    define &quot;Antithrombotic Therapy at Discharge&quot;:
      [&quot;MedicationRequest&quot;: medication in &quot;Antithrombotic Therapy&quot;] Antithrombotic
          where Antithrombotic.doNotPerform is not true
            and Antithrombotic.status in { 'active', 'completed' }
            and Antithrombotic.intent = 'order'
            and exists (Antithrombotic.category C
              where C ~ QICoreCommon.&quot;Discharge&quot; or C ~ QICoreCommon.&quot;Community&quot;
            )

    define &quot;Denominator Exceptions&quot;:
      &quot;Encounter with No Antithrombotic At Discharge&quot;
      union &quot;Encounter with Pharmacological Contraindications for Antithrombotic Therapy at Discharge&quot;

    define &quot;Reason for Not Giving Antithrombotic at Discharge&quot;:
      [&quot;MedicationRequest&quot;: &quot;Antithrombotic Therapy&quot;] NoAntithromboticDischarge
          where NoAntithromboticDischarge.doNotPerform is true
            and ( NoAntithromboticDischarge.reasonCode in &quot;Medical Reason&quot;
                    or NoAntithromboticDischarge.reasonCode in &quot;Patient Refusal&quot;
                )
            and NoAntithromboticDischarge.status in { 'completed', 'cancelled' }
            and NoAntithromboticDischarge.intent = 'order'
            and exists (NoAntithromboticDischarge.category C where
                       C ~ QICoreCommon.Discharge or C ~ QICoreCommon.Community)
    //  [&quot;MedicationRequest&quot;: medication in &quot;Antithrombotic Therapy&quot;] NoAntithromboticDischarge

    define &quot;zDISPLAY Medication Request&quot;:
      [&quot;MedicationRequest&quot;: medication in &quot;Antithrombotic Therapy&quot;] NoAntithromboticDischarge
      return Tuple {
        doNotPerform: NoAntithromboticDischarge.doNotPerform,
        medication: NoAntithromboticDischarge.medication,
        reasonCode: NoAntithromboticDischarge.reasonCode,
        reasonInMed: ( NoAntithromboticDischarge.reasonCode in &quot;Medical Reason&quot;),
        reasonInPatRef: (NoAntithromboticDischarge.reasonCode in &quot;Patient Refusal&quot;),
        category: NoAntithromboticDischarge.category,
        dischargeStatus: NoAntithromboticDischarge.status,
        intent: NoAntithromboticDischarge.intent
      }

    define &quot;Encounter with No Antithrombotic At Discharge&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
      	with &quot;Reason for Not Giving Antithrombotic at Discharge&quot; NoDischargeAntithrombotic
      	such that NoDischargeAntithrombotic.authoredOn during IschemicStrokeEncounter.period

    define &quot;Encounter with Pharmacological Contraindications for Antithrombotic Therapy at Discharge&quot;:
      &quot;Ischemic Stroke Encounter&quot; IschemicStrokeEncounter
          with &quot;Pharmacological Contraindications for Antithrombotic Therapy at Discharge&quot; DischargePharmacological
            such that DischargePharmacological.authoredOn during IschemicStrokeEncounter.period

    define &quot;Pharmacological Contraindications for Antithrombotic Therapy at Discharge&quot;:
      [&quot;MedicationRequest&quot;: medication in &quot;Pharmacological Contraindications For Antithrombotic Therapy&quot;] Pharmacological
          where Pharmacological.doNotPerform is not true
            and exists (Pharmacological.category C where
                       C ~ QICoreCommon.Discharge or C ~ QICoreCommon.Community)
            and Pharmacological.status in { 'active', 'completed' }
            and Pharmacological.intent = 'order'

    define &quot;SDE Ethnicity&quot;:
      SDE.&quot;SDE Ethnicity&quot;

    define &quot;SDE Payer&quot;:
      SDE.&quot;SDE Payer&quot;

    define &quot;SDE Race&quot;:
      SDE.&quot;SDE Race&quot;

    define &quot;SDE Sex&quot;:
      SDE.&quot;SDE Sex&quot;