2022 CDC Clinical Practice Guideline for Prescribing Opioids Implementation Guide
2022.1.0 - CI Build
2022 CDC Clinical Practice Guideline for Prescribing Opioids Implementation Guide, published by Centers for Disease Control and Prevention (CDC). This guide is not an authorized publication; it is the continuous build for version 2022.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/opioid-cds-r4/ and changes regularly. See the Directory of published versions
Draft as of 2025-04-24 |
<PlanDefinition xmlns="http://hl7.org/fhir">
<id value="opioidcds-07"/>
<meta>
<profile
value="http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-recommendationdefinition"/>
<profile
value="http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-publishableplandefinition"/>
</meta>
<text>
<status value="extensions"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<table class="grid dict">
<tr>
<th scope="row"><b>Id: </b></th>
<td style="padding-left: 4px;">opioidcds-07</td>
</tr>
<tr>
<th scope="row"><b>Url: </b></th>
<td style="padding-left: 4px;"><a href="PlanDefinition-opioidcds-07.html">Recommendation #7 - Opioid Therapy Risk Assessment</a></td>
</tr>
<tr>
<th scope="row"><b>Version: </b></th>
<td style="padding-left: 4px;">2022.1.0</td>
</tr>
<tr>
<th scope="row"><b>Identifier: </b></th>
<td style="padding-left: 4px;">
<p style="margin-bottom: 5px;">
<b>value: </b> <span>cdc-opioid-guidance</span>
</p>
</td>
</tr>
<tr>
<th scope="row"><b>Name: </b></th>
<td style="padding-left: 4px;">PlanDefinition_Recommendation_07_Order_Sign</td>
</tr>
<tr>
<th scope="row"><b>Title: </b></th>
<td style="padding-left: 4px;">Recommendation #7 - Opioid Therapy Risk Assessment</td>
</tr>
<tr>
<th scope="row"><b>Status: </b></th>
<td style="padding-left: 4px;">draft</td>
</tr>
<tr>
<th scope="row"><b>Experimental: </b></th>
<td style="padding-left: 4px;">true</td>
</tr>
<tr>
<th scope="row"><b>Type: </b></th>
<td style="padding-left: 4px;">
<p style="margin-bottom: 5px;">
<b>system: </b> <span><a href="http://terminology.hl7.org/6.4.0/CodeSystem-plan-definition-type.html">http://terminology.hl7.org/CodeSystem/plan-definition-type</a></span>
</p>
<p style="margin-bottom: 5px;">
<b>code: </b> <span>eca-rule</span>
</p>
<p style="margin-bottom: 5px;">
<b>display: </b> <span>ECA Rule</span>
</p>
</td>
</tr>
<tr>
<th scope="row"><b>Date: </b></th>
<td style="padding-left: 4px;">2025-04-24</td>
</tr>
<tr>
<th scope="row"><b>Publisher: </b></th>
<td style="padding-left: 4px;">Centers for Disease Control and Prevention (CDC)</td>
</tr>
<tr>
<th scope="row"><b>Description: </b></th>
<td style="padding-left: 4px;">Clinicians should evaluate benefits and risks with patients within 1-4 weeks of starting opioid therapy for subacute or chronic pain or of dosage escalation. Clinicians should regularly reevaluate benefits and risks of continued opioid therapy with patients.</td>
</tr>
<tr>
<th scope="row"><a name="effective-data-requirements"> </a><b>Logic Definitions: </b></th>
<td style="padding-left: 4px;">
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Chronic Pain Opioid Analgesic with Ambulatory Misuse Potential Prescriptions</td>
<td>0</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Chronic Pain Opioid Analgesic with Ambulatory Misuse Potential Prescriptions":
( Common."Is Opioid Analgesic with Ambulatory Misuse Potential?"( ContextPrescriptions ) ) AmbulatoryOpioidPrescription
where Routines."Is Subacute or Chronic Pain Prescription?"( AmbulatoryOpioidPrescription )</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential</td>
<td>1</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential":
exists( "Chronic Pain Opioid Analgesic with Ambulatory Misuse Potential Prescriptions" )</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Patient Age Less Than 18</td>
<td>2</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Patient Age Less Than 18":
if (Config."Age Less than 18 Years Is Enabled") then
AgeInYearsAt(Today()) < 18
else false</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Condition Positive for Sickle Cell</td>
<td>3</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Condition Positive for Sickle Cell":
if (Config."Sickle Cell Check Enabled") then
exists(
Common."Positive Sickle Cell Condition"
)
else false</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Is Active Cancer Treatment?</td>
<td>4</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Is Active Cancer Treatment?":
if (Config."Active Cancer Treatment Encounters Condition Is Enabled")
then "Has Two or More Encounters with Cancer Diagnosis During Encounter Period"
or "Has Active Cancer Diagnosis on Problem List"
else false</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Conditions Likely Terminal for Opioid Prescribing</td>
<td>5</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Conditions Likely Terminal for Opioid Prescribing":
if (Config."End-Stage Disease Criteria Enabled") then
exists (
Common."US Core-Categorized Conditions" EOLC
where EOLC.code in Common."Conditions likely terminal for opioid prescribing"
// and EOLC.clinicalStatus in Common."Active Condition"
)
else false</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Is Opioid Review Useful?</td>
<td>6</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Is Opioid Review Useful?":
not "Patient Age Less Than 18"
and not "Condition Positive for Sickle Cell"
and not "Is Active Cancer Treatment?"
and not "Conditions Likely Terminal for Opioid Prescribing"</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Risk Assessment Interval</td>
<td>7</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Risk Assessment Interval":
Interval[Today() - 91 days, Today() - 1 day]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Opioid Risk Assessment in Past 90 Days</td>
<td>8</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Opioid Risk Assessment in Past 90 Days":
[Procedure: Common."Opioid misuse assessment procedure"] riskAssessment
where start of (riskAssessment.performed as FHIR.Period) in day of "Risk Assessment Interval"</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Previous 10 Days Interval</td>
<td>9</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Previous 10 Days Interval":
Interval[Today() - 10 days, Today()]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Encounter Interval</td>
<td>10</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Encounter Interval":
Interval[Today() - 12 months - 1 days, Today() - 1 day]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Prescribed Opioids for 7 of Past 10 Days with an Encounter</td>
<td>11</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Prescribed Opioids for 7 of Past 10 Days with an Encounter":
Common."Days on Opioids during Period"( "Previous 10 Days Interval" ) >= 7
and exists (
[Encounter: Common."Office Visit"] AmbulatoryEncounter
where AmbulatoryEncounter.period during "Encounter Interval"
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>First Month</td>
<td>12</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "First Month":
Interval[Today() - 3 months, Today() - 2 months]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Second Month</td>
<td>13</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Second Month":
Interval[Today() - 2 months, Today() - 1 months]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Third Month</td>
<td>14</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Third Month":
Interval[Today() - 1 months, Today()]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Prescribed Opioids for 21 or more of 30 Days for each of the past 3 Months</td>
<td>15</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Prescribed Opioids for 21 or more of 30 Days for each of the past 3 Months":
"Days on Opioids during Period"("First Month") >= 21
and "Days on Opioids during Period"("Second Month") >= 21
and "Days on Opioids during Period"("Third Month") >= 21</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Inclusion Criteria</td>
<td>16</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Inclusion Criteria":
"Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential"
and Routines."Is Opioid Review Useful?"
and not exists ( "Opioid Risk Assessment in Past 90 Days" )
and (
"Prescribed Opioids for 7 of Past 10 Days with an Encounter"
or Common."Prescribed Opioids for 21 or more of 30 Days for each of the past 3 Months"
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>US Core-Categorized Conditions</td>
<td>17</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">// 3. Medications indicating end of life
/* or exists (
"Medications Indicating End of Life"
) */
define "US Core-Categorized Conditions":
[Condition: category in "Encounter Diagnosis Condition Category"]
union [Condition: category in "Problem List Condition Category"]
union [Condition: category in "US Core Health Concern Condition Category"]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Conditions Indicating End of Life or With Limited Life Expectancy</td>
<td>18</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Conditions Indicating End of Life or With Limited Life Expectancy":
(
"US Core-Categorized Conditions" C
where C.code in "Conditions likely terminal for opioid prescribing"
and C.clinicalStatus in "Active Condition"
)
union
(
"US Core-Categorized Conditions" C
where C.code in "Limited life expectancy conditions"
and C.clinicalStatus in "Active Condition"
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Admitted/Referred/Discharged to Hospice Care</td>
<td>19</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Admitted/Referred/Discharged to Hospice Care":
(
if (Config."Hospice Findings Exclusion Enabled") then
[Observation: code in "Hospice Finding Codes"] O
where not (O.status.value in { 'unknown', 'entered-in-error', 'cancelled' })
else
{}
)
union
(
[Encounter] E
where date from E.period.start 1 year or less on or before Today()
and (
if E.hospitalization.dischargeDisposition.coding is null
or not exists (E.hospitalization.dischargeDisposition.coding)
then false
else E.hospitalization.dischargeDisposition in "Hospice Disposition"
)
and E.status.value in { 'planned', 'arrived', 'in-progress', 'finished', 'onleave' }
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>End of Life Assessment</td>
<td>20</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "End of Life Assessment":
// 1. Conditions indicating end of life or with limited life expectancy
exists (
"Conditions Indicating End of Life or With Limited Life Expectancy"
)
// 2. Admitted/referred/discharged to hospice care
or exists (
"Admitted/Referred/Discharged to Hospice Care"
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Exclusion Criteria</td>
<td>21</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Exclusion Criteria":
Common."End of Life Assessment"</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSREC07</td>
<td>Is Recommendation Applicable?</td>
<td>22</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define "Is Recommendation Applicable?":
"Inclusion Criteria"
and not "Exclusion Criteria"</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Is Opioid Analgesic with Ambulatory Misuse Potential?</td>
<td>23</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function "Is Opioid Analgesic with Ambulatory Misuse Potential?"(value List<MedicationRequest>):
("Get MedicationRequest Medication as Code"(value)) Rx
where Rx.medication in "Opioid analgesics with ambulatory misuse potential"
and Rx.category in "Community"</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Get MedicationRequest Medication as Code</td>
<td>24</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function "Get MedicationRequest Medication as Code"(value List<MedicationRequest>):
value Rx
let Med:
if Rx.medication is Reference then singleton from (
[Medication] M
where M.id = (Last(Split((Rx.medication as FHIR.Reference).reference, '/')))
) else null
return
MedicationRequest {
id: Rx.id,
status: Rx.status,
intent: Rx.intent,
category: Rx.category,
medication: if Rx.medication is Reference then Med.code else Rx.medication as CodeableConcept,
subject: Rx.subject,
authoredOn: Rx.authoredOn,
recorder: Rx.recorder,
dosageInstruction: Rx.dosageInstruction,
dispenseRequest: Rx.dispenseRequest
}</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>FHIRHelpers</td>
<td>ToConcept</td>
<td>25</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">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
}</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Is Subacute or Chronic Pain Prescription?</td>
<td>26</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">// End of Active Cancer Treatment Routine
/*
** Routine #4
** For Subacute or Chronic Pain Routine
**
** Definition | Answer to Proceed | Details | Data (Terminology) Requirement
** -----------------------------------------------------------------------------------------------------------------------------------
** Order for opioid analgesic | Yes | Order for opioid analgesics with ambulatory | Opioid analgesics with
** with expected supply | | misuse potential with a supply duration of >= | ambulatory misuse potential
** duration >= 28 days | | 28 days |
** | | |
** | | - Subacute definition = order for opioid |
** | | analgesics with ambulatory misuse |
** | | potential with a supply duration of one to |
** | | two months. |
** | | - Chronic pain definition = order for opioid |
** | | analgesics with ambulatory misuse |
** | | potential with a supply duration of >= two |
** | | months. |
** -----------------------------------------------------------------------------------------------------------------------------------
**
*/
define function "Is Subacute or Chronic Pain Prescription?"(prescription FHIR.MedicationRequest):
"Is Subacute or Chronic Pain Using Expected Supply Duration"(prescription)
or "Is Subacute or Chronic Pain Using Validity Period"(prescription)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Is Subacute or Chronic Pain Using Expected Supply Duration</td>
<td>27</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function "Is Subacute or Chronic Pain Using Expected Supply Duration"(prescription FHIR.MedicationRequest):
(
prescription.dispenseRequest is not null
and prescription.dispenseRequest.expectedSupplyDuration is not null
and (
Common.GetDurationInDays(prescription.dispenseRequest.expectedSupplyDuration) >= 28 days
)
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>GetDurationInDays</td>
<td>28</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function GetDurationInDays(value FHIR.Duration):
if value is null then null
else
case
when value.code.value ~ 'a' then System.Quantity{ value: value.value.value * 365.0, unit: 'days' }
when value.code.value ~ 'mo' then System.Quantity{ value: value.value.value * 30.0, unit: 'days' }
when value.code.value ~ 'wk' then System.Quantity{ value: value.value.value * 7.0, unit: 'days' }
when value.code.value ~ 'd' then System.Quantity{ value: value.value.value, unit: 'days' }
when value.code.value ~ 'h' then System.Quantity{ value: value.value.value / 24.0, unit: 'days' }
when value.code.value ~ 'min' then System.Quantity{ value: value.value.value / 60.0 / 24.0, unit: 'days' }
when value.code.value ~ 's' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0, unit: 'days' }
when value.code.value ~ 'ms' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0 / 1000.0, unit: 'days' }
when value.code.value is null then Message(1000, true, 'Undefined', 'Error', 'Duration unit code is null')
else Message(1000, true, 'Undefined', 'Error', 'Unsupported duration unit code: ' + value.code.value)
end</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSRoutines</td>
<td>Is Subacute or Chronic Pain Using Validity Period</td>
<td>29</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function "Is Subacute or Chronic Pain Using Validity Period"(prescription FHIR.MedicationRequest):
(
prescription.dispenseRequest is not null
and prescription.dispenseRequest.validityPeriod is not null
and (
days between prescription.dispenseRequest.validityPeriod.start and prescription.dispenseRequest.validityPeriod.end >= 28
)
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>FHIRHelpers</td>
<td>ToDateTime</td>
<td>30</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function ToDateTime(value dateTime): value.value</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>FHIRHelpers</td>
<td>ToInterval</td>
<td>31</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function ToInterval(period FHIR.Period):
if period is null then
null
else
if period."start" is null then
Interval(period."start".value, period."end".value]
else
Interval[period."start".value, period."end".value]</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Days on Opioids during Period</td>
<td>32</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function "Days on Opioids during Period"(period Interval<Date>):
Sum(
(
collapse (
[MedicationRequest: "Opioid analgesics with ambulatory misuse potential"] OpioidPrescription
return "Prescription Relevant Period"( OpioidPrescription ) intersect period
)
) OpioidUseInterval
return days between start of OpioidUseInterval and end of OpioidUseInterval
)</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>FHIRHelpers</td>
<td>ToString</td>
<td>33</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function ToString(value string): value.value</code></pre>
<br/><br/>
<table class="grid-dict">
<tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>
<tr>
<td>OpioidCDSCommon</td>
<td>Prescription Relevant Period</td>
<td>34</td>
</tr>
</table>
<pre style="max-width: 990px;"><code class="language-cql">define function "Prescription Relevant Period"(prescription FHIR.MedicationRequest):
if (
prescription.authoredOn is not null and prescription.dispenseRequest is not null
and prescription.dispenseRequest.expectedSupplyDuration is not null
)
then Interval[
date from prescription.authoredOn,
date from prescription.authoredOn + GetDurationInDays(prescription.dispenseRequest.expectedSupplyDuration)
]
else null</code></pre>
<br/><br/>
</td>
</tr>
<tr>
<th scope="row"><b>Knowledge Capability: </b></th>
<td style="padding-left: 4px;">
shareable computable executable publishable
</td>
</tr>
<tr>
<th scope="row"><b>Use Context: </b></th>
<td style="padding-left: 4px;">
<table class="grid-dict">
<tr><th><b>code</b></th><th><b>value</b></th><th><b>display</b></th></tr>
<tr>
<td>focus</td>
<td>182888003</td>
<td>Medication requested (situation)</td>
</tr>
<tr>
<td>focus</td>
<td>82423001</td>
<td>Chronic pain (finding)</td>
</tr>
<tr>
<td>focus</td>
<td/>
<td/>
</tr>
</table>
</td>
</tr>
<tr>
<th scope="row"><b>Purpose: </b></th>
<td style="padding-left: 4px;"><div><p>The 2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain is intended to improve communication between clinicians and patients about the benefits and risks of pain treatments, including opioid therapy; improve the effectiveness and safety of pain treatment; mitigate pain; improve function and quality of life for patients with pain; and reduce risks associated with opioid pain therapy, including opioid use disorder, overdose, and death. The recommendations do not apply to pain related to sickle cell disease or cancer or to patients receiving palliative or end-of-life care.</p>
</div></td>
</tr>
<tr>
<th scope="row"><b>Usage: </b></th>
<td style="padding-left: 4px;">In addition to evaluating benefits and risks of opioids before starting opioid therapy (see Recommendation 2), clinicians should evaluate patients to assess benefits and risks of opioids within 1-4 weeks of starting long-term opioid therapy or of dosage escalation.</td>
</tr>
<tr>
<th scope="row"><b>Copyright: </b></th>
<td style="padding-left: 4px;"><div><p>© CDC 2016+.</p>
</div></td>
</tr>
<tr>
<th scope="row"><b>Related Artifacts: </b></th>
<td style="padding-left: 4px;">
<p><b>Documentation</b></p>
<ul>
<li>
<a href="https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm"> 2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain</a>
</li>
</ul>
</td>
</tr>
<tr>
<th scope="row"><b>Libraries: </b></th>
<td style="padding-left: 4px;">
<table class="grid-dict">
<tr><td><a href="Library-OpioidCDSREC07.html">Library - Recommendation #7 - Opioid Therapy Risk Assessment</a></td></tr>
</table>
</td>
</tr>
<tr>
<th scope="row"><b>Actions: </b></th>
<td style="padding-left: 4px;">
<table class="grid-dict">
<tr>
<td>
<b> Regularly Evaluate the Benefits and Risks of Opioid Therapy:</b> Recommend that clinicians evaluate benefits and risks with patients within 1-4 weeks of starting opioid therapy for subacute or chronic pain or of dosage escalation. Clinicians should also regularly reevaluate the benefits and risks of continued opioid therapy with patients.
For additional guidance regarding opioid therapy patient consultations, see [Recommendation 7 of the 2022 CDC Clinical Practice Guideline for additional guidance](https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm#Recommendation7)<br/>
<b>When:</b> <i>Named Event:</i> order-sign<br/>
<b>If:</b> <i>Applicability:</i> Check whether the patient has a current order is for an opioid with ambulatory misuse potential for subacute or chronic pain, a risk assessment has been performed in the past 90 days, has taken an opioid with abuse potential for 7 of the past 10 days or 63 of the past 90 days and if an opioid review is appropriate. <i>(Is Recommendation Applicable?)</i><br/>
<b>Then:</b>
<table class="grid-dict">
<tr>
<td>
<b> :</b> Document - Conducted benefit and risk assessment<br/>
<b>Then:</b>
</td>
</tr>
<tr>
<td>
<b> :</b> Snooze* - Conducted assessment, snooze 3 months<br/>
<b>Then:</b>
</td>
</tr>
<tr>
<td>
<b> :</b> Snooze* - N/A see comment, snooze 3 months<br/>
<b>Then:</b>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</text>
<contained>
<Library>
<id value="effective-data-requirements"/>
<name value="EffectiveDataRequirements"/>
<status value="active"/>
<type>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/library-type"/>
<code value="module-definition"/>
</coding>
</type>
<relatedArtifact>
<type value="depends-on"/>
<display value="Library Common"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSCommon|2022.1.0"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Library FHIRHelpers"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/Library/FHIRHelpers|4.0.1"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Library Routines"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSRoutines|2022.1.0"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display
value="Value set Opioid analgesics with ambulatory misuse potential"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-analgesics-with-ambulatory-misuse-potential"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Community"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/medicationrequest-category-community"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Opioid misuse assessment procedure"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-misuse-assessment-procedure"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Office Visit"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/office-visit"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Encounter Diagnosis Condition Category"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-encounter-diagnosis-category"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Problem List Condition Category"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-problem-list-category"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set US Core Health Concern Condition Category"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-us-core-health-concern-category"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display
value="Value set Conditions likely terminal for opioid prescribing"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/conditions-likely-terminal-for-opioid-prescribing"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Active Condition"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-clinical-status-active"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Limited life expectancy conditions"/>
<resource
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/limited-life-expectancy-conditions"/>
</relatedArtifact>
<parameter>
<name value="ContextPrescriptions"/>
<use value="in"/>
<min value="0"/>
<max value="*"/>
<type value="MedicationRequest"/>
</parameter>
<parameter>
<name value="Is Recommendation Applicable?"/>
<use value="out"/>
<min value="0"/>
<max value="1"/>
<type value="boolean"/>
</parameter>
<dataRequirement>
<type value="Procedure"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Procedure"/>
<mustSupport value="code"/>
<mustSupport value="performed"/>
<codeFilter>
<path value="code"/>
<valueSet
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-misuse-assessment-procedure"/>
</codeFilter>
</dataRequirement>
<dataRequirement>
<type value="MedicationRequest"/>
<profile
value="http://hl7.org/fhir/StructureDefinition/MedicationRequest"/>
<mustSupport value="medication"/>
<mustSupport value="id"/>
<mustSupport value="status"/>
<mustSupport value="intent"/>
<mustSupport value="category"/>
<mustSupport value="subject"/>
<mustSupport value="authoredOn"/>
<mustSupport value="recorder"/>
<mustSupport value="dosageInstruction"/>
<mustSupport value="dispenseRequest"/>
<codeFilter>
<path value="medication"/>
<valueSet
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-analgesics-with-ambulatory-misuse-potential"/>
</codeFilter>
</dataRequirement>
<dataRequirement>
<type value="MedicationRequest"/>
<profile
value="http://hl7.org/fhir/StructureDefinition/MedicationRequest"/>
<mustSupport value="medication.reference"/>
<mustSupport value="id"/>
<mustSupport value="status"/>
<mustSupport value="intent"/>
<mustSupport value="category"/>
<mustSupport value="subject"/>
<mustSupport value="authoredOn"/>
<mustSupport value="recorder"/>
<mustSupport value="dosageInstruction"/>
<mustSupport value="dispenseRequest"/>
<mustSupport value="medication"/>
</dataRequirement>
<dataRequirement>
<type value="Medication"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Medication"/>
<mustSupport value="id"/>
<mustSupport value="code"/>
</dataRequirement>
<dataRequirement>
<type value="Encounter"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
<mustSupport value="type"/>
<mustSupport value="period"/>
<codeFilter>
<path value="type"/>
<valueSet
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/office-visit"/>
</codeFilter>
</dataRequirement>
<dataRequirement>
<type value="Encounter"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
<mustSupport value="period"/>
<mustSupport value="period.start"/>
<mustSupport value="status"/>
<mustSupport value="status.value"/>
</dataRequirement>
<dataRequirement>
<type value="Condition"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Condition"/>
<mustSupport value="category"/>
<mustSupport value="code"/>
<mustSupport value="clinicalStatus"/>
<codeFilter>
<path value="category"/>
<valueSet
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-encounter-diagnosis-category"/>
</codeFilter>
</dataRequirement>
<dataRequirement>
<type value="Condition"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Condition"/>
<mustSupport value="category"/>
<mustSupport value="code"/>
<mustSupport value="clinicalStatus"/>
<codeFilter>
<path value="category"/>
<valueSet
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-problem-list-category"/>
</codeFilter>
</dataRequirement>
<dataRequirement>
<type value="Condition"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Condition"/>
<mustSupport value="category"/>
<mustSupport value="code"/>
<mustSupport value="clinicalStatus"/>
<codeFilter>
<path value="category"/>
<valueSet
value="http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-us-core-health-concern-category"/>
</codeFilter>
</dataRequirement>
</Library>
</contained>
<extension
url="http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability">
<valueCode value="shareable"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability">
<valueCode value="computable"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability">
<valueCode value="executable"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability">
<valueCode value="publishable"/>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString
value="Chronic Pain Opioid Analgesic with Ambulatory Misuse Potential Prescriptions"/>
</extension>
<extension url="statement">
<valueString
value="define "Chronic Pain Opioid Analgesic with Ambulatory Misuse Potential Prescriptions":
( Common."Is Opioid Analgesic with Ambulatory Misuse Potential?"( ContextPrescriptions ) ) AmbulatoryOpioidPrescription
where Routines."Is Subacute or Chronic Pain Prescription?"( AmbulatoryOpioidPrescription )"/>
</extension>
<extension url="displaySequence">
<valueInteger value="0"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString
value="Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential"/>
</extension>
<extension url="statement">
<valueString
value="define "Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential":
exists( "Chronic Pain Opioid Analgesic with Ambulatory Misuse Potential Prescriptions" )"/>
</extension>
<extension url="displaySequence">
<valueInteger value="1"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString value="Patient Age Less Than 18"/>
</extension>
<extension url="statement">
<valueString
value="define "Patient Age Less Than 18":
if (Config."Age Less than 18 Years Is Enabled") then
AgeInYearsAt(Today()) < 18
else false"/>
</extension>
<extension url="displaySequence">
<valueInteger value="2"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString value="Condition Positive for Sickle Cell"/>
</extension>
<extension url="statement">
<valueString
value="define "Condition Positive for Sickle Cell":
if (Config."Sickle Cell Check Enabled") then
exists(
Common."Positive Sickle Cell Condition"
)
else false"/>
</extension>
<extension url="displaySequence">
<valueInteger value="3"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString value="Is Active Cancer Treatment?"/>
</extension>
<extension url="statement">
<valueString
value="define "Is Active Cancer Treatment?":
if (Config."Active Cancer Treatment Encounters Condition Is Enabled")
then "Has Two or More Encounters with Cancer Diagnosis During Encounter Period"
or "Has Active Cancer Diagnosis on Problem List"
else false"/>
</extension>
<extension url="displaySequence">
<valueInteger value="4"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString value="Conditions Likely Terminal for Opioid Prescribing"/>
</extension>
<extension url="statement">
<valueString
value="define "Conditions Likely Terminal for Opioid Prescribing":
if (Config."End-Stage Disease Criteria Enabled") then
exists (
Common."US Core-Categorized Conditions" EOLC
where EOLC.code in Common."Conditions likely terminal for opioid prescribing"
// and EOLC.clinicalStatus in Common."Active Condition"
)
else false"/>
</extension>
<extension url="displaySequence">
<valueInteger value="5"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString value="Is Opioid Review Useful?"/>
</extension>
<extension url="statement">
<valueString
value="define "Is Opioid Review Useful?":
not "Patient Age Less Than 18"
and not "Condition Positive for Sickle Cell"
and not "Is Active Cancer Treatment?"
and not "Conditions Likely Terminal for Opioid Prescribing""/>
</extension>
<extension url="displaySequence">
<valueInteger value="6"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString value="Risk Assessment Interval"/>
</extension>
<extension url="statement">
<valueString
value="define "Risk Assessment Interval":
Interval[Today() - 91 days, Today() - 1 day]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="7"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString value="Opioid Risk Assessment in Past 90 Days"/>
</extension>
<extension url="statement">
<valueString
value="define "Opioid Risk Assessment in Past 90 Days":
[Procedure: Common."Opioid misuse assessment procedure"] riskAssessment
where start of (riskAssessment.performed as FHIR.Period) in day of "Risk Assessment Interval""/>
</extension>
<extension url="displaySequence">
<valueInteger value="8"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString value="Previous 10 Days Interval"/>
</extension>
<extension url="statement">
<valueString
value="define "Previous 10 Days Interval":
Interval[Today() - 10 days, Today()]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="9"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString value="Encounter Interval"/>
</extension>
<extension url="statement">
<valueString
value="define "Encounter Interval":
Interval[Today() - 12 months - 1 days, Today() - 1 day]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="10"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString
value="Prescribed Opioids for 7 of Past 10 Days with an Encounter"/>
</extension>
<extension url="statement">
<valueString
value="define "Prescribed Opioids for 7 of Past 10 Days with an Encounter":
Common."Days on Opioids during Period"( "Previous 10 Days Interval" ) >= 7
and exists (
[Encounter: Common."Office Visit"] AmbulatoryEncounter
where AmbulatoryEncounter.period during "Encounter Interval"
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="11"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="First Month"/>
</extension>
<extension url="statement">
<valueString
value="define "First Month":
Interval[Today() - 3 months, Today() - 2 months]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="12"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="Second Month"/>
</extension>
<extension url="statement">
<valueString
value="define "Second Month":
Interval[Today() - 2 months, Today() - 1 months]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="13"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="Third Month"/>
</extension>
<extension url="statement">
<valueString
value="define "Third Month":
Interval[Today() - 1 months, Today()]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="14"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString
value="Prescribed Opioids for 21 or more of 30 Days for each of the past 3 Months"/>
</extension>
<extension url="statement">
<valueString
value="define "Prescribed Opioids for 21 or more of 30 Days for each of the past 3 Months":
"Days on Opioids during Period"("First Month") >= 21
and "Days on Opioids during Period"("Second Month") >= 21
and "Days on Opioids during Period"("Third Month") >= 21"/>
</extension>
<extension url="displaySequence">
<valueInteger value="15"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString value="Inclusion Criteria"/>
</extension>
<extension url="statement">
<valueString
value="define "Inclusion Criteria":
"Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential"
and Routines."Is Opioid Review Useful?"
and not exists ( "Opioid Risk Assessment in Past 90 Days" )
and (
"Prescribed Opioids for 7 of Past 10 Days with an Encounter"
or Common."Prescribed Opioids for 21 or more of 30 Days for each of the past 3 Months"
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="16"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="US Core-Categorized Conditions"/>
</extension>
<extension url="statement">
<valueString
value="// 3. Medications indicating end of life
/* or exists (
"Medications Indicating End of Life"
) */
define "US Core-Categorized Conditions":
[Condition: category in "Encounter Diagnosis Condition Category"]
union [Condition: category in "Problem List Condition Category"]
union [Condition: category in "US Core Health Concern Condition Category"]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="17"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString
value="Conditions Indicating End of Life or With Limited Life Expectancy"/>
</extension>
<extension url="statement">
<valueString
value="define "Conditions Indicating End of Life or With Limited Life Expectancy":
(
"US Core-Categorized Conditions" C
where C.code in "Conditions likely terminal for opioid prescribing"
and C.clinicalStatus in "Active Condition"
)
union
(
"US Core-Categorized Conditions" C
where C.code in "Limited life expectancy conditions"
and C.clinicalStatus in "Active Condition"
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="18"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="Admitted/Referred/Discharged to Hospice Care"/>
</extension>
<extension url="statement">
<valueString
value="define "Admitted/Referred/Discharged to Hospice Care":
(
if (Config."Hospice Findings Exclusion Enabled") then
[Observation: code in "Hospice Finding Codes"] O
where not (O.status.value in { 'unknown', 'entered-in-error', 'cancelled' })
else
{}
)
union
(
[Encounter] E
where date from E.period.start 1 year or less on or before Today()
and (
if E.hospitalization.dischargeDisposition.coding is null
or not exists (E.hospitalization.dischargeDisposition.coding)
then false
else E.hospitalization.dischargeDisposition in "Hospice Disposition"
)
and E.status.value in { 'planned', 'arrived', 'in-progress', 'finished', 'onleave' }
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="19"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="End of Life Assessment"/>
</extension>
<extension url="statement">
<valueString
value="define "End of Life Assessment":
// 1. Conditions indicating end of life or with limited life expectancy
exists (
"Conditions Indicating End of Life or With Limited Life Expectancy"
)
// 2. Admitted/referred/discharged to hospice care
or exists (
"Admitted/Referred/Discharged to Hospice Care"
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="20"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString value="Exclusion Criteria"/>
</extension>
<extension url="statement">
<valueString
value="define "Exclusion Criteria":
Common."End of Life Assessment""/>
</extension>
<extension url="displaySequence">
<valueInteger value="21"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSREC07"/>
</extension>
<extension url="name">
<valueString value="Is Recommendation Applicable?"/>
</extension>
<extension url="statement">
<valueString
value="define "Is Recommendation Applicable?":
"Inclusion Criteria"
and not "Exclusion Criteria""/>
</extension>
<extension url="displaySequence">
<valueInteger value="22"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString
value="Is Opioid Analgesic with Ambulatory Misuse Potential?"/>
</extension>
<extension url="statement">
<valueString
value="define function "Is Opioid Analgesic with Ambulatory Misuse Potential?"(value List<MedicationRequest>):
("Get MedicationRequest Medication as Code"(value)) Rx
where Rx.medication in "Opioid analgesics with ambulatory misuse potential"
and Rx.category in "Community""/>
</extension>
<extension url="displaySequence">
<valueInteger value="23"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="Get MedicationRequest Medication as Code"/>
</extension>
<extension url="statement">
<valueString
value="define function "Get MedicationRequest Medication as Code"(value List<MedicationRequest>):
value Rx
let Med:
if Rx.medication is Reference then singleton from (
[Medication] M
where M.id = (Last(Split((Rx.medication as FHIR.Reference).reference, '/')))
) else null
return
MedicationRequest {
id: Rx.id,
status: Rx.status,
intent: Rx.intent,
category: Rx.category,
medication: if Rx.medication is Reference then Med.code else Rx.medication as CodeableConcept,
subject: Rx.subject,
authoredOn: Rx.authoredOn,
recorder: Rx.recorder,
dosageInstruction: Rx.dosageInstruction,
dispenseRequest: Rx.dispenseRequest
}"/>
</extension>
<extension url="displaySequence">
<valueInteger value="24"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRHelpers"/>
</extension>
<extension url="name">
<valueString value="ToConcept"/>
</extension>
<extension url="statement">
<valueString
value="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
}"/>
</extension>
<extension url="displaySequence">
<valueInteger value="25"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString value="Is Subacute or Chronic Pain Prescription?"/>
</extension>
<extension url="statement">
<valueString
value="// End of Active Cancer Treatment Routine
/*
** Routine #4
** For Subacute or Chronic Pain Routine
**
** Definition | Answer to Proceed | Details | Data (Terminology) Requirement
** -----------------------------------------------------------------------------------------------------------------------------------
** Order for opioid analgesic | Yes | Order for opioid analgesics with ambulatory | Opioid analgesics with
** with expected supply | | misuse potential with a supply duration of >= | ambulatory misuse potential
** duration >= 28 days | | 28 days |
** | | |
** | | - Subacute definition = order for opioid |
** | | analgesics with ambulatory misuse |
** | | potential with a supply duration of one to |
** | | two months. |
** | | - Chronic pain definition = order for opioid |
** | | analgesics with ambulatory misuse |
** | | potential with a supply duration of >= two |
** | | months. |
** -----------------------------------------------------------------------------------------------------------------------------------
**
*/
define function "Is Subacute or Chronic Pain Prescription?"(prescription FHIR.MedicationRequest):
"Is Subacute or Chronic Pain Using Expected Supply Duration"(prescription)
or "Is Subacute or Chronic Pain Using Validity Period"(prescription)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="26"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString
value="Is Subacute or Chronic Pain Using Expected Supply Duration"/>
</extension>
<extension url="statement">
<valueString
value="define function "Is Subacute or Chronic Pain Using Expected Supply Duration"(prescription FHIR.MedicationRequest):
(
prescription.dispenseRequest is not null
and prescription.dispenseRequest.expectedSupplyDuration is not null
and (
Common.GetDurationInDays(prescription.dispenseRequest.expectedSupplyDuration) >= 28 days
)
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="27"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="GetDurationInDays"/>
</extension>
<extension url="statement">
<valueString
value="define function GetDurationInDays(value FHIR.Duration):
if value is null then null
else
case
when value.code.value ~ 'a' then System.Quantity{ value: value.value.value * 365.0, unit: 'days' }
when value.code.value ~ 'mo' then System.Quantity{ value: value.value.value * 30.0, unit: 'days' }
when value.code.value ~ 'wk' then System.Quantity{ value: value.value.value * 7.0, unit: 'days' }
when value.code.value ~ 'd' then System.Quantity{ value: value.value.value, unit: 'days' }
when value.code.value ~ 'h' then System.Quantity{ value: value.value.value / 24.0, unit: 'days' }
when value.code.value ~ 'min' then System.Quantity{ value: value.value.value / 60.0 / 24.0, unit: 'days' }
when value.code.value ~ 's' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0, unit: 'days' }
when value.code.value ~ 'ms' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0 / 1000.0, unit: 'days' }
when value.code.value is null then Message(1000, true, 'Undefined', 'Error', 'Duration unit code is null')
else Message(1000, true, 'Undefined', 'Error', 'Unsupported duration unit code: ' + value.code.value)
end"/>
</extension>
<extension url="displaySequence">
<valueInteger value="28"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSRoutines"/>
</extension>
<extension url="name">
<valueString value="Is Subacute or Chronic Pain Using Validity Period"/>
</extension>
<extension url="statement">
<valueString
value="define function "Is Subacute or Chronic Pain Using Validity Period"(prescription FHIR.MedicationRequest):
(
prescription.dispenseRequest is not null
and prescription.dispenseRequest.validityPeriod is not null
and (
days between prescription.dispenseRequest.validityPeriod.start and prescription.dispenseRequest.validityPeriod.end >= 28
)
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="29"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRHelpers"/>
</extension>
<extension url="name">
<valueString value="ToDateTime"/>
</extension>
<extension url="statement">
<valueString
value="define function ToDateTime(value dateTime): value.value"/>
</extension>
<extension url="displaySequence">
<valueInteger value="30"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRHelpers"/>
</extension>
<extension url="name">
<valueString value="ToInterval"/>
</extension>
<extension url="statement">
<valueString
value="define function ToInterval(period FHIR.Period):
if period is null then
null
else
if period."start" is null then
Interval(period."start".value, period."end".value]
else
Interval[period."start".value, period."end".value]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="31"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="Days on Opioids during Period"/>
</extension>
<extension url="statement">
<valueString
value="define function "Days on Opioids during Period"(period Interval<Date>):
Sum(
(
collapse (
[MedicationRequest: "Opioid analgesics with ambulatory misuse potential"] OpioidPrescription
return "Prescription Relevant Period"( OpioidPrescription ) intersect period
)
) OpioidUseInterval
return days between start of OpioidUseInterval and end of OpioidUseInterval
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="32"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRHelpers"/>
</extension>
<extension url="name">
<valueString value="ToString"/>
</extension>
<extension url="statement">
<valueString
value="define function ToString(value string): value.value"/>
</extension>
<extension url="displaySequence">
<valueInteger value="33"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="OpioidCDSCommon"/>
</extension>
<extension url="name">
<valueString value="Prescription Relevant Period"/>
</extension>
<extension url="statement">
<valueString
value="define function "Prescription Relevant Period"(prescription FHIR.MedicationRequest):
if (
prescription.authoredOn is not null and prescription.dispenseRequest is not null
and prescription.dispenseRequest.expectedSupplyDuration is not null
)
then Interval[
date from prescription.authoredOn,
date from prescription.authoredOn + GetDurationInDays(prescription.dispenseRequest.expectedSupplyDuration)
]
else null"/>
</extension>
<extension url="displaySequence">
<valueInteger value="34"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements" id="effective-data-requirements">
<valueCanonical value="#effective-data-requirements"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem">
<valueReference>🔗
<reference value="Device/cqf-tooling"/>
</valueReference>
</extension>
<url
value="http://fhir.org/guides/cdc/opioid-cds/PlanDefinition/opioidcds-07"/>
<identifier>
<use value="official"/>
<value value="cdc-opioid-guidance"/>
</identifier>
<version value="2022.1.0"/>
<name value="PlanDefinition_Recommendation_07_Order_Sign"/>
<title value="Recommendation #7 - Opioid Therapy Risk Assessment"/>
<type>
<coding>
<system
value="http://terminology.hl7.org/CodeSystem/plan-definition-type"/>
<code value="eca-rule"/>
<display value="ECA Rule"/>
</coding>
</type>
<status value="draft"/>
<experimental value="true"/>
<date value="2025-04-24"/>
<publisher value="Centers for Disease Control and Prevention (CDC)"/>
<contact>
<telecom>
<system value="url"/>
<value value="https://www.cdc.gov"/>
</telecom>
</contact>
<description
value="Clinicians should evaluate benefits and risks with patients within 1-4 weeks of starting opioid therapy for subacute or chronic pain or of dosage escalation. Clinicians should regularly reevaluate benefits and risks of continued opioid therapy with patients."/>
<useContext>
<code>
<system
value="http://terminology.hl7.org/CodeSystem/usage-context-type"/>
<code value="focus"/>
<display value="Clinical Focus"/>
</code>
<valueCodeableConcept>
<coding>
<system value="http://snomed.info/sct"/>
<code value="182888003"/>
<display value="Medication requested (situation)"/>
</coding>
</valueCodeableConcept>
</useContext>
<useContext>
<code>
<system
value="http://terminology.hl7.org/CodeSystem/usage-context-type"/>
<code value="focus"/>
<display value="Clinical Focus"/>
</code>
<valueCodeableConcept>
<coding>
<system value="http://snomed.info/sct"/>
<code value="82423001"/>
<display value="Chronic pain (finding)"/>
</coding>
</valueCodeableConcept>
</useContext>
<useContext>
<code>
<system
value="http://terminology.hl7.org/CodeSystem/usage-context-type"/>
<code value="focus"/>
<display value="Clinical Focus"/>
</code>
<valueCodeableConcept>
<text value="Subacute pain"/>
</valueCodeableConcept>
</useContext>
<purpose
value="The 2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain is intended to improve communication between clinicians and patients about the benefits and risks of pain treatments, including opioid therapy; improve the effectiveness and safety of pain treatment; mitigate pain; improve function and quality of life for patients with pain; and reduce risks associated with opioid pain therapy, including opioid use disorder, overdose, and death. The recommendations do not apply to pain related to sickle cell disease or cancer or to patients receiving palliative or end-of-life care."/>
<usage
value="In addition to evaluating benefits and risks of opioids before starting opioid therapy (see Recommendation 2), clinicians should evaluate patients to assess benefits and risks of opioids within 1-4 weeks of starting long-term opioid therapy or of dosage escalation."/>
<copyright value="© CDC 2016+."/>
<topic>
<text value="Opioid Prescribing"/>
</topic>
<author>
<name value="Kensaku Kawamoto, MD, PhD, MHS"/>
</author>
<author>
<name value="Bryn Rhodes"/>
</author>
<author>
<name value="Floyd Eisenberg, MD, MPH"/>
</author>
<author>
<name value="Robert McClure, MD, MPH"/>
</author>
<relatedArtifact>
<type value="documentation"/>
<display
value="2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain"/>
<url value="https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm"/>
<document>
<url value="https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm"/>
</document>
</relatedArtifact>
<library
value="http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSREC07"/>
<action>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-strengthOfRecommendation">
<valueCodeableConcept>
<coding>
<system
value="http://terminology.hl7.org/CodeSystem/recommendation-strength"/>
<code value="strong"/>
<display value="Strong"/>
</coding>
</valueCodeableConcept>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-qualityOfEvidence">
<valueCodeableConcept>
<coding>
<system
value="http://terminology.hl7.org/CodeSystem/evidence-quality"/>
<code value="very-low"/>
<display value="Very Low quality"/>
</coding>
</valueCodeableConcept>
</extension>
<title
value="Regularly Evaluate the Benefits and Risks of Opioid Therapy"/>
<description
value="Recommend that clinicians evaluate benefits and risks with patients within 1-4 weeks of starting opioid therapy for subacute or chronic pain or of dosage escalation. Clinicians should also regularly reevaluate the benefits and risks of continued opioid therapy with patients.
For additional guidance regarding opioid therapy patient consultations, see [Recommendation 7 of the 2022 CDC Clinical Practice Guideline for additional guidance](https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm#Recommendation7)"/>
<priority value="urgent"/>
<trigger>
<type value="named-event"/>
<name value="order-sign"/>
</trigger>
<condition>
<kind value="applicability"/>
<expression>
<description
value="Check whether the patient has a current order is for an opioid with ambulatory misuse potential for subacute or chronic pain, a risk assessment has been performed in the past 90 days, has taken an opioid with abuse potential for 7 of the past 10 days or 63 of the past 90 days and if an opioid review is appropriate."/>
<language value="text/cql.identifier"/>
<expression value="Is Recommendation Applicable?"/>
</expression>
</condition>
<type>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/action-type"/>
<code value="create"/>
<display value="Create"/>
</coding>
</type>
<groupingBehavior value="visual-group"/>
<selectionBehavior value="any"/>
<definitionCanonical
value="http://fhir.org/guides/cdc/opioid-cds/ActivityDefinition/opioidcds-risk-assessment-request"/>
<action>
<description value="Document - Conducted benefit and risk assessment"/>
</action>
<action>
<description value="Snooze* - Conducted assessment, snooze 3 months"/>
</action>
<action>
<description value="Snooze* - N/A see comment, snooze 3 months"/>
</action>
</action>
</PlanDefinition>