Quality Measure Implementation Guide
2.0.0 - STU 2 International flag

Quality Measure Implementation Guide, published by HL7 International / Clinical Quality Information. This guide is not an authorized publication; it is the continuous build for version 2.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/fhir-cqm/ and changes regularly. See the Directory of published versions

Library: EXM108 - Venous Thromboembolism Prophylaxis Library (Experimental)

Official URL: http://hl7.org/fhir/uv/cqm/Library/EXM108 Version: 2.0.0
Standards status: Informative Computable Name: EXM108
Other Identifiers: http://example.org/fhir/cqi/ecqm/Library/Identifier#EXM108 (use: official, ), OID:2.16.840.1.113883.4.642.40.61.28.8

This library is used as an example in the FHIR Quality Measure Implementation Guide

Metadata
Title EXM108 - Venous Thromboembolism Prophylaxis Library
Version 2.0.0
Identifier EXM108
Identifier urn:oid:2.16.840.1.113883.4.642.40.61.28.8
Approval Date 2019-08-03
Last Review Date 2019-08-03
Experimental true
Jurisdiction http://unstats.un.org/unsd/methods/m49/m49.htm#001
Topic FHIR
Topic CQL
Steward (Publisher) HL7 International / Clinical Quality Information
Description

This library is used as an example in the FHIR Quality Measure Implementation Guide

Type http://terminology.hl7.org/CodeSystem/library-type#logic-library
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: General Surgery
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Gynecological Surgery
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Hip Fracture Surgery
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Intracranial Neurosurgery
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Urological Surgery
Data Requirement Type: ServiceRequest
Profile(s): ServiceRequest
Code Filter(s):
Path: code
ValueSet: Comfort Measures
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Comfort Measures
Data Requirement Type: Condition
Profile(s): Condition
Code Filter(s):
Path: code
ValueSet: Atrial Fibrillation or Flutter
Data Requirement Type: Condition
Profile(s): Condition
Code Filter(s):
Path: code
ValueSet: Venous Thromboembolism
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Hip Replacement Surgery
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Knee Replacement Surgery
Data Requirement Type: Observation
Profile(s): Observation
Code Filter(s):
Path: code
Code(s): LOINC: 72136-5 (Risk for venous thromboembolism)
Data Requirement Type: Observation
Profile(s): Observation
Code Filter(s):
Path: code
ValueSet: INR
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Data Requirement Type: Medication
Profile(s): Medication
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Code Filter(s):
Path: medication
ValueSet: Low Dose Unfractionated Heparin for VTE Prophylaxis
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Code Filter(s):
Path: medication
ValueSet: Low Molecular Weight Heparin for VTE Prophylaxis
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Code Filter(s):
Path: medication
ValueSet: Injectable Factor Xa Inhibitor for VTE Prophylaxis
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Code Filter(s):
Path: medication
ValueSet: Warfarin
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Code Filter(s):
Path: medication
ValueSet: Low Dose Unfractionated Heparin for VTE Prophylaxis
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Code Filter(s):
Path: medication
ValueSet: Low Molecular Weight Heparin for VTE Prophylaxis
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Code Filter(s):
Path: medication
ValueSet: Injectable Factor Xa Inhibitor for VTE Prophylaxis
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Code Filter(s):
Path: medication
ValueSet: Warfarin
Data Requirement Type: ServiceRequest
Profile(s): ServiceRequest
Code Filter(s):
Path: code
ValueSet: Venous foot pumps
Data Requirement Type: ServiceRequest
Profile(s): ServiceRequest
Code Filter(s):
Path: code
ValueSet: Intermittent pneumatic compression devices
Data Requirement Type: ServiceRequest
Profile(s): ServiceRequest
Code Filter(s):
Path: code
ValueSet: Graduated compression stockings
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: Device Application
Data Requirement Type: Procedure
Profile(s): Procedure
Code Filter(s):
Path: code
ValueSet: General or Neuraxial Anesthesia
Parameters
Name Use Card. Type Documentation
Patient Out 0..1 Patient
SDE Ethnicity Out 0..* Coding
SDE Payer Out 0..* Resource
SDE Race Out 0..* Coding
SDE Sex Out 0..1 Coding
Admission Without VTE or Obstetrical Conditions Out 0..* Encounter
Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions Out 0..* Encounter
Initial Population Out 0..* Encounter
Denominator Out 0..* Encounter
Encounter Less Than 2 Days Out 0..* Encounter
Encounter With ICU Location Stay 1 Day or More Out 0..* Encounter
Encounter With Principal Diagnosis of Mental Disorder or Stroke Out 0..* Encounter
SCIP VTE Selected Surgery Out 0..* Procedure
Encounter With Principal Procedure of SCIP VTE Selected Surgery Out 0..* Resource
Intervention Comfort Measures Out 0..* Resource
Encounter With Intervention Comfort Measures From Day of Start of Hospitalization To Day After Admission Out 0..* Encounter
Encounter With Intervention Comfort Measures on Day of or Day After Procedure Out 0..* Encounter
Denominator Exclusion Out 0..* Resource
VTE Prophylaxis by Medication Administered or Device Applied Out 0..* Resource
Encounter With VTE Prophylaxis Received on Day of or Day After Admission or Procedure Out 0..* Encounter
Encounter With Medication Oral Factor Xa Inhibitor Administered on Day of or Day After Admission or Procedure Out 0..* Encounter
Encounter With Prior or Present Diagnosis of Atrial Fibrillation or VTE Out 0..* Encounter
Encounter With Prior or Present Procedure of Hip or Knee Replacement Surgery Out 0..* Encounter
Is In Low Risk for VTE or On Anticoagulant Out 0..* Observation
Low Risk for VTE or Anticoagulant Administered From Day of Start of Hospitalization To Day After Admission Out 0..* Encounter
Low Risk for VTE or Anticoagulant Administered on Day of or Day After Procedure Out 0..* Encounter
Encounter With Low Risk for VTE or Anticoagulant Administered Out 0..* Encounter
No VTE Prophylaxis Medication Administered or Ordered Out 0..* Resource
No VTE Prophylaxis Medication Due to Medical Reason From Day of Start of Hospitalization To Day After Admission Out 0..* Encounter
No VTE Prophylaxis Device Applied or Ordered Out 0..* Resource
No VTE Prophylaxis Device Due to Medical Reason From Day of Start of Hospitalization To Day After Admission Out 0..* Encounter
No VTE Prophylaxis Medication Due to Medical Reason on Day of or Day After Procedure Out 0..* Encounter
No VTE Prophylaxis Device Due to Medical Reason on Day of or Day After Procedure Out 0..* Encounter
Encounter With No VTE Prophylaxis Due to Medical Reason Out 0..* Encounter
No VTE Prophylaxis Medication or Device Due to Patient Refusal Out 0..* Resource
No VTE Prophylaxis Due to Patient Refusal From Day of Start of Hospitalization To Day After Admission Out 0..* Encounter
No VTE Prophylaxis Due to Patient Refusal on Day of or Day After Procedure Out 0..* Encounter
Encounter With No VTE Prophylaxis Due to Patient Refusal Out 0..* Encounter
Numerator Out 0..* Encounter
Library Content
CQL Content
/*
This example is a work in progress and should not be considered a final specification
or recommendation for guidance. This example will help guide and direct the process
of finding conventions and usage patterns that meet the needs of the various stakeholders
in the measure development community.

@author: TJC
Based on CMS108v8 2020 reporting year. QDM to QI-4
Venous Thromboembolism Prophylaxis
*/
library EXM108

using FHIR version '4.0.1'

include hl7.fhir.uv.cql.FHIRHelpers version '4.0.1' called FHIRHelpers
include hl7.fhir.uv.cql.FHIRCommon version '2.0.0' called FHIRCommon

include EXMCommon
include MATGlobalCommonFunctions called Global
include SupplementalDataElements called SDE
include VTEICU called VTEICU
include TJCOverall called TJC

codesystem "SNOMEDCT": 'http://snomed.info/sct'
codesystem "LOINC": 'http://loinc.org'
// NOTE: R4 code system URLs changed to be based on terminology.hl7.org...
codesystem "RequestIntent": 'http://hl7.org/fhir/request-intent'
//NOTE: Created for ActPriority for Encounter.category which is codeableConcept
codesystem "ActPriority": 'http://terminology.hl7.org/ValueSet/v3-ActPriority'

valueset "Device Application": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.48'
valueset "Atrial Fibrillation/Flutter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.202'
valueset "Comfort Measures": 'http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45'
valueset "Direct Thrombin Inhibitor": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.205'
valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292'
valueset "General or Neuraxial Anesthesia": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.1743'
valueset "General Surgery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.255'
valueset "Glycoprotein IIb/IIIa Inhibitors": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.41'
valueset "Graduated compression stockings (GCS)": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.256'
valueset "Gynecological Surgery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.257'
valueset "Hemorrhagic Stroke": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.212'
valueset "Hip Fracture Surgery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.258'
valueset "Hip Replacement Surgery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.259'
valueset "Injectable Factor Xa Inhibitor for VTE Prophylaxis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.211'
valueset "INR": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.213'
valueset "Intermittent pneumatic compression devices (IPC)": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.214'
valueset "Intracranial Neurosurgery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.260'
valueset "Intravenous route": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.222'
valueset "Ischemic Stroke": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.247'
valueset "Knee Replacement Surgery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.261'
valueset "Low Dose Unfractionated Heparin for VTE Prophylaxis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.39'
valueset "Low Molecular Weight Heparin for VTE Prophylaxis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.219'
valueset "Low Risk": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.400'
valueset "Medical Reason": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.473'
valueset "Mental Health Diagnoses": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.105.12.1004'
valueset "Obstetrics": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.263'
valueset "Obstetrics VTE": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.264'
valueset "Oral Factor Xa Inhibitor for VTE Prophylaxis or VTE Treatment": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.134'
valueset "Patient Refusal": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.93'
valueset "Subcutaneous route": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.223'
valueset "Unfractionated Heparin": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.218'
valueset "Urological Surgery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.272'
valueset "Venous foot pumps (VFP)": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.230'
valueset "Venous Thromboembolism": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.279'
valueset "Warfarin": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.232'
valueset "Intensive Care Unit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.23'

code "Risk for venous thromboembolism": '72136-5' from "LOINC" display 'Risk for venous thromboembolism'

context Patient

define "SDE Ethnicity":
  SDE."SDE Ethnicity"

define "SDE Payer":
	SDE."SDE Payer"

define "SDE Race":
  SDE."SDE Race"

define "SDE Sex":
	SDE."SDE Sex"

define "Initial Population":
  "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions"

// Note: added FHIRHelpers.ToDate() in R4
define "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions":
  ( Global."Inpatient Encounter" InpatientEncounter
        where Global."CalendarAgeInYearsAt"(FHIRHelpers.ToDate(Patient.birthDate), start of InpatientEncounter.period) >= 18
  )
    intersect "Admission Without VTE or Obstetrical Conditions"

define "Admission Without VTE or Obstetrical Conditions":
  Global."Inpatient Encounter" InpatientEncounter
    where not exists (
      (Global.EncounterDiagnosis(InpatientEncounter)) EncounterDiagnosis
        where EncounterDiagnosis.code in "Obstetrics"
          or EncounterDiagnosis.code in "Venous Thromboembolism"
          or EncounterDiagnosis.code in "Obstetrics VTE"
    )

define "Denominator":
      "Initial Population"

define "Denominator Exclusion":
  "Encounter Less Than 2 Days"
     union "Encounter With ICU Location Stay 1 Day or More"
     union "Encounter With Principal Diagnosis of Mental Disorder or Stroke"
     union "Encounter With Principal Procedure of SCIP VTE Selected Surgery"
     union "Encounter With Intervention Comfort Measures From Day of Start of Hospitalization To Day After Admission"
     union "Encounter With Intervention Comfort Measures on Day of or Day After Procedure"

define "Encounter Less Than 2 Days":
  "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
  	where QualifyingEncounter.period.lengthInDays() < 2

define "Encounter With ICU Location Stay 1 Day or More":
  "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
    where exists ( QualifyingEncounter.location Location
   		where Global.GetLocation(Location.location).type in "Intensive Care Unit"
   			and Location.period.lengthInDays() >= 1
   			and Location.period starts during TJC."CalendarDayOfOrDayAfter"(start of QualifyingEncounter.period)
    )

define "Encounter With Principal Diagnosis of Mental Disorder or Stroke":
  "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
    where QualifyingEncounter.principalDiagnosis().diagnosis in "Mental Health Diagnoses"
      or QualifyingEncounter.principalDiagnosis().diagnosis in "Hemorrhagic Stroke"
      or QualifyingEncounter.principalDiagnosis().diagnosis in "Ischemic Stroke"

define "Encounter With Principal Procedure of SCIP VTE Selected Surgery":
  from
    "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
    "SCIP VTE Selected Surgery" SelectedProcedure
  let EncounterProcedure: QualifyingEncounter.principalProcedure()
  where EncounterProcedure.procedure.references(SelectedProcedure)
    and SelectedProcedure.performed.toInterval() during QualifyingEncounter.period

define "SCIP VTE Selected Surgery":
  (	["Procedure": "General Surgery"]
    union ["Procedure": "Gynecological Surgery"]
    union ["Procedure": "Hip Fracture Surgery"]
    union ["Procedure": "Hip Replacement Surgery"]
    union ["Procedure": "Intracranial Neurosurgery"]
    union ["Procedure": "Knee Replacement Surgery"]
    union ["Procedure": "Urological Surgery"] ) Procedure
  where Procedure.status = 'completed'

define "Encounter With Intervention Comfort Measures From Day of Start of Hospitalization To Day After Admission":
	"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
		with "Intervention Comfort Measures" ComfortMeasure
		such that Coalesce(start of ComfortMeasure.performed.toInterval(), ComfortMeasure.authoredOn) during VTEICU."FromDayOfStartOfHospitalizationToDayAfterAdmission"(QualifyingEncounter)

define "Intervention Comfort Measures":
	(["ServiceRequest": "Comfort Measures"] P
 		where P.intent = 'order'
  )
  	union
    	(["Procedure": "Comfort Measures"] InterventionPerformed
      	where InterventionPerformed.status in {'completed', 'in-progress'})

define "Encounter With Intervention Comfort Measures on Day of or Day After Procedure":
  from
    "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
    ["Procedure": "General or Neuraxial Anesthesia"] AnesthesiaProcedure,
    "Intervention Comfort Measures" ComfortMeasure
  where AnesthesiaProcedure.status = 'completed'
    and AnesthesiaProcedure.performed.toInterval() ends 1 day after day of start of QualifyingEncounter.period
    and Coalesce(start of ComfortMeasure.performed.toInterval(), ComfortMeasure.authoredOn) during TJC."CalendarDayOfOrDayAfter"(end of AnesthesiaProcedure.performed.toInterval())
  return QualifyingEncounter

define "Numerator":
  "Encounter With VTE Prophylaxis Received on Day of or Day After Admission or Procedure"
    union ( "Encounter With Medication Oral Factor Xa Inhibitor Administered on Day of or Day After Admission or Procedure"
  	  intersect ( "Encounter With Prior or Present Diagnosis of Atrial Fibrillation or VTE"
  	    union "Encounter With Prior or Present Procedure of Hip or Knee Replacement Surgery"
      )
    )
    union "Encounter With Low Risk for VTE or Anticoagulant Administered"
    union "Encounter With No VTE Prophylaxis Due to Medical Reason"
    union "Encounter With No VTE Prophylaxis Due to Patient Refusal"

define "Encounter With VTE Prophylaxis Received on Day of or Day After Admission or Procedure":
 	( from
      "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
      "VTE Prophylaxis by Medication Administered or Device Applied" VTEProphylaxis
    where Coalesce(VTEProphylaxis.effective.toInterval(), VTEProphylaxis.performed.toInterval()) starts during TJC."CalendarDayOfOrDayAfter"(start of QualifyingEncounter.period)
    return QualifyingEncounter
 	)
 	union (
    from
      "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
      ["Procedure": "General or Neuraxial Anesthesia"] AnesthesiaProcedure,
      "VTE Prophylaxis by Medication Administered or Device Applied" VTEProphylaxis
    where AnesthesiaProcedure.performed.toInterval() ends 1 day after day of start of QualifyingEncounter.period
      and Coalesce(VTEProphylaxis.effective.toInterval(), VTEProphylaxis.performed.toInterval()) starts during TJC."CalendarDayOfOrDayAfter"(end of AnesthesiaProcedure.performed.toInterval())
    return QualifyingEncounter
	)

// 10/29: Replaced DeviceUseStatement with Procedure with a new value set and procedure.usdCode for specifying devices
define "VTE Prophylaxis by Medication Administered or Device Applied":
  ( ["MedicationAdministration": medication in "Low Dose Unfractionated Heparin for VTE Prophylaxis"] VTEMedication
      where VTEMedication.status ='completed'
        and VTEMedication.dosage.route in "Subcutaneous route"
  )
   union (["MedicationAdministration": medication in "Low Molecular Weight Heparin for VTE Prophylaxis"] LMWH where LMWH.status = 'completed')
   union (["MedicationAdministration": medication in "Injectable Factor Xa Inhibitor for VTE Prophylaxis"] FactorXa where FactorXa.status = 'completed')
   union (["MedicationAdministration": medication in "Warfarin"] WarfarinAdmin where WarfarinAdmin.status = 'completed')
   union (
    ["Procedure": "Device Application"] DeviceApplied
      where DeviceApplied.status = 'complete'
        and (
          DeviceApplied.usedCode in "Intermittent pneumatic compression devices (IPC)"
            or DeviceApplied.usedCode in"Venous foot pumps (VFP)"
            or DeviceApplied.usedCode in "Graduated compression stockings (GCS)"
        )
  )

define "Encounter With Medication Oral Factor Xa Inhibitor Administered on Day of or Day After Admission or Procedure":
	( from
   		"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
			["MedicationAdministration": medication in "Oral Factor Xa Inhibitor for VTE Prophylaxis or VTE Treatment"] FactorXaMedication
    where FactorXaMedication.status = 'completed'
      and FactorXaMedication.effective.toInterval() starts during TJC."CalendarDayOfOrDayAfter"(start of QualifyingEncounter.period)
    return QualifyingEncounter
  )
    union ( 
      from
			  "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
 				["Procedure": "General or Neuraxial Anesthesia"] AnesthesiaProcedure,
 				["MedicationAdministration": medication in "Oral Factor Xa Inhibitor for VTE Prophylaxis or VTE Treatment"] FactorXaMedication
 			where FactorXaMedication.status = 'completed'
        and AnesthesiaProcedure.status = 'completed'
  	    and AnesthesiaProcedure.performed.toInterval() ends 1 day after day of start of QualifyingEncounter.period
				and FactorXaMedication.effective.toInterval() starts during TJC."CalendarDayOfOrDayAfter"(end of AnesthesiaProcedure.performed.toInterval())
   		return QualifyingEncounter
 		)

define "Encounter With Prior or Present Diagnosis of Atrial Fibrillation or VTE":
	( "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
		with ["Condition": code in "Atrial Fibrillation/Flutter"] AtrialFibrillation
      such that AtrialFibrillation.prevalenceInterval() starts on or before end of QualifyingEncounter.period
    )
    union ( 
      "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
    	  where Global.EncounterDiagnosis(QualifyingEncounter).code in "Atrial Fibrillation/Flutter"
		)
    union ( 
      "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
				with ["Condition": code in "Venous Thromboembolism"] VTEDiagnosis
  				such that (
            VTEDiagnosis.clinicalStatus ~ Global."inactive"
              or VTEDiagnosis.clinicalStatus ~ Global."remission"
              or VTEDiagnosis.clinicalStatus ~ Global."resolved" 
          )
   	  			and VTEDiagnosis.onset.toInterval() before start of QualifyingEncounter.period
 		)

define "Encounter With Prior or Present Procedure of Hip or Knee Replacement Surgery":
	"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
	with ( 
    ["Procedure": "Hip Replacement Surgery"]
    	union ["Procedure": "Knee Replacement Surgery"] 
  ) HipKneeProcedure
  	such that HipKneeProcedure.status = 'completed'
	    and HipKneeProcedure.performed.toInterval() starts on or before end of QualifyingEncounter.period


define "Encounter With Low Risk for VTE or Anticoagulant Administered":
   "Low Risk for VTE or Anticoagulant Administered From Day of Start of Hospitalization To Day After Admission"
   	 union "Low Risk for VTE or Anticoagulant Administered on Day of or Day After Procedure"

define "Low Risk for VTE or Anticoagulant Administered From Day of Start of Hospitalization To Day After Admission":
 	"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
    with "Is In Low Risk for VTE or On Anticoagulant" VTERiskAssessment
    such that VTERiskAssessment.effective.toInterval() starts during VTEICU."FromDayOfStartOfHospitalizationToDayAfterAdmission"(QualifyingEncounter)

define "Is In Low Risk for VTE or On Anticoagulant":
	  ( ["Observation": "Risk for venous thromboembolism"] VTERiskAssessment
			  where VTERiskAssessment.value in "Low Risk"
        and VTERiskAssessment.status in {'final','amended', 'corrected'}
	  )
  union ( ["Observation": "INR"] INRLabTest
        where INRLabTest.value as Quantity > 3.0
            and INRLabTest.status in {'final','amended', 'corrected'}
        return "Observation" { id: INRLabTest.id, effective: INRLabTest.issued }
        )
  union ((( ["MedicationAdministration": "Unfractionated Heparin"] UnfractionatedHeparin
          where UnfractionatedHeparin.dosage.route in "Intravenous route"
         )
         union ["MedicationAdministration": "Direct Thrombin Inhibitor"]
         union ["MedicationAdministration": "Glycoprotein IIb/IIIa Inhibitors"] ) AnticoagulantMedication
         where AnticoagulantMedication.status = 'complete'
         return "Observation" { id: AnticoagulantMedication.id, effective: AnticoagulantMedication.effective }
      )

define "Low Risk for VTE or Anticoagulant Administered on Day of or Day After Procedure":
 	from
 		"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
 		["Procedure": "General or Neuraxial Anesthesia"] AnesthesiaProcedure,
 		"Is In Low Risk for VTE or On Anticoagulant" VTERiskAssessment
  where AnesthesiaProcedure.performed.toInterval() ends 1 day after day of start of QualifyingEncounter.period
		and VTERiskAssessment.effective.toInterval() starts during TJC."CalendarDayOfOrDayAfter"(end of AnesthesiaProcedure.performed.toInterval())
	return QualifyingEncounter

define "Encounter With No VTE Prophylaxis Due to Medical Reason":
  ( "No VTE Prophylaxis Medication Due to Medical Reason From Day of Start of Hospitalization To Day After Admission"
      intersect "No VTE Prophylaxis Device Due to Medical Reason From Day of Start of Hospitalization To Day After Admission"
  )
    union ( 
      "No VTE Prophylaxis Medication Due to Medical Reason on Day of or Day After Procedure"
        intersect "No VTE Prophylaxis Device Due to Medical Reason on Day of or Day After Procedure"
    )

define "No VTE Prophylaxis Medication Due to Medical Reason From Day of Start of Hospitalization To Day After Admission":
 	"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
    with	"No VTE Prophylaxis Medication Administered or Ordered" NoVTEMedication
     	such that Coalesce(NoVTEMedication.statusReason, NoVTEMedication.reasonCode) in "Medical Reason"
  			and Coalesce(NoVTEMedication.authoredOn, start of NoVTEMedication.effective.toInterval()) during VTEICU."FromDayOfStartOfHospitalizationToDayAfterAdmission"(QualifyingEncounter)

define "No VTE Prophylaxis Medication Administered or Ordered":
  ((	
    ["MedicationAdministration": medication in "Low Dose Unfractionated Heparin for VTE Prophylaxis"]
     union ["MedicationAdministration": medication in "Low Molecular Weight Heparin for VTE Prophylaxis"]
     union ["MedicationAdministration": medication in "Injectable Factor Xa Inhibitor for VTE Prophylaxis"]
     union ["MedicationAdministration": medication in "Warfarin"]
  ) MedicationAdm
    where MedicationAdm.status = 'not-done'
  )
  union
  ((	
    ["MedicationRequest": medication in "Low Dose Unfractionated Heparin for VTE Prophylaxis"]
  	  union ["MedicationRequest": medication in "Low Molecular Weight Heparin for VTE Prophylaxis"]
      union	["MedicationRequest": medication in "Injectable Factor Xa Inhibitor for VTE Prophylaxis"]
      union	["MedicationRequest": medication in "Warfarin"]
    ) MedicationOrder
    	where	MedicationOrder.doNotPerform is true
        and MedicationOrder.status in {'completed', 'cancelled'}
  )

define "No VTE Prophylaxis Medication Due to Medical Reason on Day of or Day After Procedure":
	from
		"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
		["Procedure": "General or Neuraxial Anesthesia"] AnesthesiaProcedure,
		"No VTE Prophylaxis Medication Administered or Ordered" NoVTEMedication
	where Coalesce(NoVTEMedication.statusReason,NoVTEMedication.reasonCode) in "Medical Reason"
  	and AnesthesiaProcedure.status = 'completed'
	  and AnesthesiaProcedure.performed.toInterval() ends 1 day after day of start of QualifyingEncounter.period
		and Coalesce(NoVTEMedication.authoredOn, start of NoVTEMedication.effective.toInterval()) during TJC."CalendarDayOfOrDayAfter"(end of AnesthesiaProcedure.performed.toInterval())
  return QualifyingEncounter

define "No VTE Prophylaxis Device Due to Medical Reason From Day of Start of Hospitalization To Day After Admission":
  "Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
  	with "No VTE Prophylaxis Device Applied or Ordered" NoVTEDevice
      such that NoVTEDevice.requestStatusReason in "Medical Reason"
        and  NoVTEDevice.authoredOn during VTEICU."FromDayOfStartOfHospitalizationToDayAfterAdmission"(QualifyingEncounter)

define "No VTE Prophylaxis Device Applied or Ordered":
  ((
    ["ServiceRequest": "Venous foot pumps (VFP)"]
      union ["ServiceRequest": "Intermittent pneumatic compression devices (IPC)"]
      union ["ServiceRequest": "Graduated compression stockings (GCS)"]
  ) DeviceOrder
    where DeviceOrder.status = 'completed'
      and DeviceOrder.doNotPerform is true
    return {
      id: DeviceOrder.id, 
      requestStatusReason: DeviceOrder.statusReason(), 
      authoredOn: DeviceOrder.authoredOn
    }
  )
    union (
      ["Procedure": "Device Application"] DeviceApplied
        where (DeviceApplied.usedCode in "Intermittent pneumatic compression devices (IPC)"
          or DeviceApplied.usedCode in "Venous foot pumps (VFP)"
          or DeviceApplied.usedCode in "Graduated compression stockings (GCS)"
        )
          and DeviceApplied.status = 'not-done'
        return {
          id: DeviceApplied.id, 
          requestStatusReason: DeviceApplied.statusReason, 
          authoredOn: DeviceApplied.recorded()
        }

    )

define "No VTE Prophylaxis Device Due to Medical Reason on Day of or Day After Procedure":
  from
 		"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
 		["Procedure": "General or Neuraxial Anesthesia"] AnesthesiaProcedure,
 		"No VTE Prophylaxis Device Applied or Ordered" NoVTEDevice
  where NoVTEDevice.requestStatusReason in "Medical Reason"
    and AnesthesiaProcedure.status = 'completed'
		and AnesthesiaProcedure.performed.toInterval() ends 1 day after day of start of QualifyingEncounter.period
    and NoVTEDevice.authoredOn during TJC."CalendarDayOfOrDayAfter"(end of AnesthesiaProcedure.performed.toInterval())
  return QualifyingEncounter

define "Encounter With No VTE Prophylaxis Due to Patient Refusal":
  "No VTE Prophylaxis Due to Patient Refusal From Day of Start of Hospitalization To Day After Admission"
 	  union "No VTE Prophylaxis Due to Patient Refusal on Day of or Day After Procedure"

define "No VTE Prophylaxis Due to Patient Refusal From Day of Start of Hospitalization To Day After Admission":
 	"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter
  	with "No VTE Prophylaxis Medication or Device Due to Patient Refusal" PatientRefusal
      such that Coalesce(start of PatientRefusal.effective.toInterval(), PatientRefusal.authoredOn)
        during VTEICU."FromDayOfStartOfHospitalizationToDayAfterAdmission"(QualifyingEncounter)

define "No VTE Prophylaxis Medication or Device Due to Patient Refusal":
  ( 
    "No VTE Prophylaxis Medication Administered or Ordered" NoVTEMedication
      where Coalesce(NoVTEMedication.statusReason,NoVTEMedication.reasonCode) in "Patient Refusal"
  )
  union (
    "No VTE Prophylaxis Device Applied or Ordered" NoVTEDevice
      where NoVTEDevice.requestStatusReason in "Patient Refusal"
  )

define "No VTE Prophylaxis Due to Patient Refusal on Day of or Day After Procedure":
 	from
 		"Encounter With Age Range and Without VTE Diagnosis or Obstetrical Conditions" QualifyingEncounter,
 		["Procedure": "General or Neuraxial Anesthesia"] AnesthesiaProcedure,
 		"No VTE Prophylaxis Medication or Device Due to Patient Refusal" PatientRefusal
	where AnesthesiaProcedure.performed.toInterval() ends 1 day after day of start of QualifyingEncounter.period
		and Coalesce(start of PatientRefusal.effective.toInterval(), PatientRefusal.authoredOn)
      during TJC."CalendarDayOfOrDayAfter"(end of AnesthesiaProcedure.performed.toInterval())
	return QualifyingEncounter
ELM XML Content
Encoded data 
ELM JSON Content
Encoded data 
Citations and References
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Library FHIRCommon
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Dependency Description: Library EXMCommon
Resource: EXMCommon
Canonical URL: http://hl7.org/fhir/uv/cqm/Library/EXMCommon
Dependency Description: Library Global
Resource: MAT Global Common Functions FHIR Library
Canonical URL: http://hl7.org/fhir/uv/cqm/Library/MATGlobalCommonFunctions
Dependency Description: Library SDE
Resource: Supplemental Data Elements
Canonical URL: http://hl7.org/fhir/uv/cqm/Library/SupplementalDataElements
Dependency Description: Library VTEICU
Resource: VTE ICU Library
Canonical URL: http://hl7.org/fhir/uv/cqm/Library/VTEICU
Dependency Description: Library TJC
Resource: TJC Overall Library
Canonical URL: http://hl7.org/fhir/uv/cqm/Library/TJCOverall
Dependency Description: Code System SNOMEDCT
Resource: SNOMED CT (all versions)
Canonical URL: http://snomed.info/sct
Dependency Description: Code System LOINC
Resource: Logical Observation Identifiers, Names and Codes (LOINC)
Canonical URL: http://loinc.org
Dependency Description: Code System RequestIntent
Resource: RequestIntent
Canonical URL: http://hl7.org/fhir/request-intent
Dependency Description: Code System ActPriority
Resource: ActPriority
Canonical URL: http://terminology.hl7.org/ValueSet/v3-ActPriority
Dependency Description: Value Set Device Application
Resource: Device Application
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.48
Dependency Description: Value Set Atrial Fibrillation/Flutter
Resource: Atrial Fibrillation or Flutter
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.202
Dependency Description: Value Set Comfort Measures
Resource: Comfort Measures
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45
Dependency Description: Value Set Direct Thrombin Inhibitor
Resource: Direct Thrombin Inhibitor
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.205
Dependency Description: Value Set Emergency Department Visit
Resource: Emergency Department Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Dependency Description: Value Set General or Neuraxial Anesthesia
Resource: General or Neuraxial Anesthesia
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.1743
Dependency Description: Value Set General Surgery
Resource: General Surgery
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.255
Dependency Description: Value Set Glycoprotein IIb/IIIa Inhibitors
Resource: Glycoprotein IIb IIIa Inhibitors
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.41
Dependency Description: Value Set Graduated compression stockings (GCS)
Resource: Graduated compression stockings
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.256
Dependency Description: Value Set Gynecological Surgery
Resource: Gynecological Surgery
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.257
Dependency Description: Value Set Hemorrhagic Stroke
Resource: Hemorrhagic Stroke
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.212
Dependency Description: Value Set Hip Fracture Surgery
Resource: Hip Fracture Surgery
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.258
Dependency Description: Value Set Hip Replacement Surgery
Resource: Hip Replacement Surgery
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.259
Dependency Description: Value Set Injectable Factor Xa Inhibitor for VTE Prophylaxis
Resource: Injectable Factor Xa Inhibitor for VTE Prophylaxis
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.211
Dependency Description: Value Set INR
Resource: INR
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.213
Dependency Description: Value Set Intermittent pneumatic compression devices (IPC)
Resource: Intermittent pneumatic compression devices
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.214
Dependency Description: Value Set Intracranial Neurosurgery
Resource: Intracranial Neurosurgery
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.260
Dependency Description: Value Set Intravenous route
Resource: Intravenous route
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.222
Dependency Description: Value Set Ischemic Stroke
Resource: Ischemic Stroke
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.247
Dependency Description: Value Set Knee Replacement Surgery
Resource: Knee Replacement Surgery
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.261
Dependency Description: Value Set Low Dose Unfractionated Heparin for VTE Prophylaxis
Resource: Low Dose Unfractionated Heparin for VTE Prophylaxis
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.39
Dependency Description: Value Set Low Molecular Weight Heparin for VTE Prophylaxis
Resource: Low Molecular Weight Heparin for VTE Prophylaxis
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.219
Dependency Description: Value Set Low Risk
Resource: Low Risk
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.400
Dependency Description: Value Set Medical Reason
Resource: Medical Reason For Not Providing Treatment
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.473
Dependency Description: Value Set Mental Health Diagnoses
Resource: Mental Health Diagnoses
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.105.12.1004
Dependency Description: Value Set Obstetrics
Resource: Obstetrical or Pregnancy Related Conditions
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.263
Dependency Description: Value Set Obstetrics VTE
Resource: Obstetrics VTE
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.264
Dependency Description: Value Set Oral Factor Xa Inhibitor for VTE Prophylaxis or VTE Treatment
Resource: Oral Factor Xa Inhibitor for VTE Prophylaxis or VTE Treatment
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.134
Dependency Description: Value Set Patient Refusal
Resource: Patient Refusal
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.93
Dependency Description: Value Set Subcutaneous route
Resource: Subcutaneous route
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.223
Dependency Description: Value Set Unfractionated Heparin
Resource: Unfractionated Heparin
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.218
Dependency Description: Value Set Urological Surgery
Resource: Urological Surgery
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.272
Dependency Description: Value Set Venous foot pumps (VFP)
Resource: Venous foot pumps
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.230
Dependency Description: Value Set Venous Thromboembolism
Resource: Venous Thromboembolism
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.279
Dependency Description: Value Set Warfarin
Resource: Warfarin
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.232
Dependency Description: Value Set Intensive Care Unit
Resource: Intensive Care Unit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.23
Generated using version 0.5.6 of the sample-content-ig Liquid templates