| CMS506FHIRSafeUseofOpioids | 
| CMS506FHIRSafeUseofOpioids | 
| active | 
| false | 
| CMS506FHIRSafeUseofOpioids | 
| Centers for Medicare & Medicaid Services (CMS) | 
  
  
  
  
  
  
  | Description: Library SDE Resource: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
 Canonical URL: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
 | 
  
  
  
  
  
  
  | Description: Library CQMCommon Resource: https://madie.cms.gov/Library/CQMCommon|4.1.000
 Canonical URL: https://madie.cms.gov/Library/CQMCommon|4.1.000
 | 
  
  
  
  
  
  
  | Description: Library FHIRHelpers Resource: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
 Canonical URL: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
 | 
  
  
  
  
  
  
  | Description: Library QICoreCommon Resource: https://madie.cms.gov/Library/QICoreCommon|4.0.000
 Canonical URL: https://madie.cms.gov/Library/QICoreCommon|4.0.000
 | 
  
  
  
  
  
  
  | Description: Value set Schedule II, III and IV Opioid Medications Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241
 | 
  
  
  
  
  
  
  | Description: Value set Schedule IV Benzodiazepines Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1
 | 
  
  
  
  
  
  
  | Description: Value set Cancer Related Pain Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180
 | 
  
  
  
  
  
  
  | Description: Value set Sickle Cell Disease with and without Crisis Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175
 | 
  
  
  
  
  
  
  | Description: Value set Medications for Opioid Use Disorder (MOUD) Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269
 | 
  
  
  
  
  
  
  | Description: Value set Opioid Medication Assisted Treatment (MAT) Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177
 | 
  
  
  
  
  
  
  | Description: Value set Opioid Use Disorder Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171
 | 
  
  
  
  
  
  
  | Description: Value set Palliative or Hospice Care Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
 | 
  
  
  
  
  
  
  | Description: 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
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87
 | 
  
  
  
  
  
  
  | Description: Value set Hospice Care Referral or Admission Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365
 | 
  
  
  
  
  
  
  | Description: Value set Patient Expired Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309
 | 
  
  
  
  
  
  
  | Description: Value set Left Against Medical Advice Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308
 Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308
 | 
| org.hl7.fhir.r5.model.Identifier@4f42a513 | 
| 0.3.007 | 
| [http://terminology.hl7.org/CodeSystem/library-type#logic-library] | 
  
  | Type: MedicationRequest Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
 Must Support Elements: medication, status, status.value, intent, intent.value, authoredOn, authoredOn.value
 Code Filter(s):
 Path: medication
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241
 
 | 
  
  | Type: MedicationRequest Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
 Must Support Elements: medication, status, status.value, intent, intent.value, authoredOn, authoredOn.value
 Code Filter(s):
 Path: medication
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1
 
 | 
  
  | Type: MedicationRequest Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
 Must Support Elements: medication, status, status.value, intent, intent.value, authoredOn, authoredOn.value
 Code Filter(s):
 Path: medication
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269
 
 | 
  
  | Type: MedicationRequest Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
 Must Support Elements: medication.reference.value, status, status.value, intent, intent.value, authoredOn, authoredOn.value, medication
 
 | 
  
  | Type: Medication Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication
 Must Support Elements: id.value, code
 
 | 
  
  | Type: Condition Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
 Must Support Elements: code, verificationStatus
 Code Filter(s):
 Path: code
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180
 
 | 
  
  | Type: Condition Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
 Must Support Elements: code, verificationStatus
 Code Filter(s):
 Path: code
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175
 
 | 
  
  | Type: Condition Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
 Must Support Elements: code, verificationStatus
 Code Filter(s):
 Path: code
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171
 
 | 
  
  | Type: Procedure Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure
 Must Support Elements: code, performed, status, status.value
 Code Filter(s):
 Path: code
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177
 
 | 
  
  | Type: Procedure Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure
 Must Support Elements: code, status, status.value
 Code Filter(s):
 Path: code
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
 
 | 
  
  | Type: ServiceRequest Profile(s): 
  
    http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest
 Must Support Elements: code, status, status.value
 Code Filter(s):
 Path: code
 ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579
 
 | 
  
  
    
    
      
      | library CMS506FHIRSafeUseofOpioids version '0.3.007'
using QICore version '6.0.0'
include CQMCommon version '4.1.000' called CQMCommon
include FHIRHelpers version '4.4.000' called FHIRHelpers
include QICoreCommon version '4.0.000' called QICoreCommon
include SupplementalDataElements version '5.1.000' called SDE
valueset "Cancer Related Pain": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.180'
valueset "Discharge To Acute Care Facility": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87'
valueset "Hospice Care Referral or Admission": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1116.365'
valueset "Left Against Medical Advice": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308'
valueset "Medications for Opioid Use Disorder (MOUD)": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.269'
valueset "Opioid Medication Assisted Treatment (MAT)": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.177'
valueset "Opioid Use Disorder": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.171'
valueset "Palliative or Hospice Care": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579'
valueset "Patient Expired": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309'
valueset "Schedule II, III and IV Opioid Medications": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.241'
valueset "Schedule IV Benzodiazepines": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1'
valueset "Sickle Cell Disease with and without Crisis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.175'
parameter "Measurement Period" Interval<DateTime>
context Patient
define "Initial Population":
  "Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge"
define "Denominator":
  "Initial Population"
define "Inpatient Encounter With Age Greater Than Or Equal To 18":
  CQMCommon."Inpatient Encounter" InpatientHospitalEncounter
    where AgeInYearsAt(date from start of InpatientHospitalEncounter.period) >= 18
define "Inpatient Encounters With An Opioid Or Benzodiazepine At Discharge":
/*Captures encounters of patients with an opioid and/or benzodiazepine at discharge*/
  
  "Inpatient Encounter With Age Greater Than Or Equal To 18" InpatientEncounter
    with ( "Opioid At Discharge"
      union "Benzodiazepine At Discharge" ) OpioidOrBenzodiazepineAtDischarge
      such that OpioidOrBenzodiazepineAtDischarge.authoredOn during day of InpatientEncounter.period
define "Benzodiazepine At Discharge":
  ["MedicationRequest": "Schedule IV Benzodiazepines"] BenzoMedications
    where ( BenzoMedications.isCommunity ( )
        or BenzoMedications.isDischarge ( )
    )
      and BenzoMedications.status in { 'active', 'completed' }
      and BenzoMedications.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
define "Opioid At Discharge":
  ["MedicationRequest": "Schedule II, III and IV Opioid Medications"] OpioidMedications
    where ( OpioidMedications.isCommunity ( )
        or OpioidMedications.isDischarge ( )
    )
      and OpioidMedications.status in { 'active', 'completed' }
      and OpioidMedications.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
define "Numerator":
  /*Encounters of patients prescribed two or more opioids or an opioid and benzodiazepine at discharge.*/
  
  "Denominator" InpatientEncounter
    where ( Count("Opioid At Discharge" OpioidMedications
          where OpioidMedications.authoredOn during day of InpatientEncounter.period
          return distinct OpioidMedications.medication
      ) >= 2
    )
      or ( exists "Opioid At Discharge" OpioidDischargeMedications
          where OpioidDischargeMedications.authoredOn during day of InpatientEncounter.period
            and exists ( "Benzodiazepine At Discharge" BenzodiazepineDischargeMedication
                where BenzodiazepineDischargeMedication.authoredOn during day of InpatientEncounter.period
            )
      )
define "Inpatient Encounter With Encounter Diagnosis Of Cancer Pain":
  "Denominator" QualifyingEncounter
    where QualifyingEncounter.reasonCode in "Cancer Related Pain"
      or QualifyingEncounter.encounterDiagnosis ( ).code in "Cancer Related Pain"
define "Denominator Exclusion":
  /*Excludes encounters of patients with cancer pain or who are receiving palliative or hospice care at the time of the encounter or who receive treatment for opioid use disorder, have sickle cell disease, or who are discharged to another inpatient care facility or discharged against medical advice, or expire during the inpatient stay*/
  
  "Denominator" InpatientEncounter
    where exists ( ["ConditionProblemsHealthConcerns": "Cancer Related Pain"] CancerPain
        where CancerPain.prevalenceInterval ( ) overlaps day of InpatientEncounter.period
          and ( CancerPain.verificationStatus is not null implies ( CancerPain.verificationStatus !~ QICoreCommon."refuted"
                or CancerPain.verificationStatus !~ QICoreCommon."entered-in-error"
            )
          )
    )
      or exists ( "Inpatient Encounter With Encounter Diagnosis Of Cancer Pain" )
      or exists ( ["ConditionProblemsHealthConcerns": "Sickle Cell Disease with and without Crisis"] SickleCellDisease
          where SickleCellDisease.prevalenceInterval ( ) overlaps day of InpatientEncounter.period
            and ( SickleCellDisease.verificationStatus is not null implies ( SickleCellDisease.verificationStatus !~ QICoreCommon."refuted"
                  or SickleCellDisease.verificationStatus !~ QICoreCommon."entered-in-error"
              )
            )
      )
      or exists ( "Treatment For Opioid Use Disorders" OUDTreatment
          where OUDTreatment.authoredOn during day of InpatientEncounter.period
      )
      or exists ( "Intervention Palliative Or Hospice Care" PalliativeOrHospiceCare
          where Coalesce(start of PalliativeOrHospiceCare.performed.toInterval(), PalliativeOrHospiceCare.authoredOn) during InpatientEncounter.hospitalizationWithObservation ( )
      )
      or ( InpatientEncounter.hospitalization.dischargeDisposition in "Discharge To Acute Care Facility"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Hospice Care Referral or Admission"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Patient Expired"
          or InpatientEncounter.hospitalization.dischargeDisposition in "Left Against Medical Advice"
      )
define "Treatment For Opioid Use Disorders":
  ( "Medications For Opioid Use Disorder" MedicationTreatment
      with ["Procedure": "Opioid Medication Assisted Treatment (MAT)"] MAT
        such that MedicationTreatment.authoredOn during day of MAT.performed.toInterval ( )
          and MedicationTreatment.authoredOn during day of "Measurement Period"
          and MAT.status in { 'completed', 'in-progress' }
  )
    union ( "Medications For Opioid Use Disorder" MedicationTreatment
        with ["ConditionProblemsHealthConcerns": "Opioid Use Disorder"] OUD
          such that MedicationTreatment.authoredOn during day of OUD.prevalenceInterval ( )
            and OUD.prevalenceInterval ( ) overlaps day of "Measurement Period"
            and ( OUD.verificationStatus is not null implies ( OUD.verificationStatus !~ QICoreCommon."refuted"
                  or OUD.verificationStatus !~ QICoreCommon."entered-in-error"
              )
            )
    )
define "Medications For Opioid Use Disorder":
  ["MedicationRequest": "Medications for Opioid Use Disorder (MOUD)"] DischargeMedication
    where ( DischargeMedication.isCommunity ( )
        or DischargeMedication.isDischarge ( )
    )
      and DischargeMedication.status in { 'active', 'completed' }
      and DischargeMedication.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
define "Intervention Palliative Or Hospice Care":
  ( ["ServiceRequest": "Palliative or Hospice Care"] PalliativeOrHospiceCareOrder
      where PalliativeOrHospiceCareOrder.status in { 'active', 'completed', 'on-hold' }
  )
    union ( ["Procedure": "Palliative or Hospice Care"] PalliativeOrHospiceCarePerformed
        where PalliativeOrHospiceCarePerformed.status in { 'completed', 'in-progress' }
    )
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
define "SDE Payer":
  SDE."SDE Payer"
define "SDE Race":
  SDE."SDE Race"
define "SDE Sex":
  SDE."SDE Sex"
 |