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

: Recommendation #3 - Opioid Immediate Release Form When Starting Opioid Therapy - TTL Representation

Draft as of 2025-08-06

Raw ttl | Download

@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sct: <http://snomed.info/id/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

 a fhir:PlanDefinition ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "opioidcds-03"] ; # 
  fhir:meta [
    ( fhir:profile [
fhir:v "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-recommendationdefinition"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-recommendationdefinition>     ] [
fhir:v "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-publishableplandefinition"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-publishableplandefinition>     ] )
  ] ; # 
  fhir:text [
fhir:status [ fhir:v "extensions" ] ;
fhir:div "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n    <table class=\"grid dict\">\n        \n        <tr>\n            <th scope=\"row\"><b>Id: </b></th>\n            <td style=\"padding-left: 4px;\">opioidcds-03</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Url: </b></th>\n            <td style=\"padding-left: 4px;\"><a href=\"PlanDefinition-opioidcds-03.html\">Recommendation #3 - Opioid Immediate Release Form When Starting Opioid Therapy</a></td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Version: </b></th>\n            <td style=\"padding-left: 4px;\">2022.1.0</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Identifier: </b></th>\n            <td style=\"padding-left: 4px;\">\n                \n                \n                <p style=\"margin-bottom: 5px;\">\n                    <b>value: </b> <span>cdc-opioid-guidance</span>\n                </p>\n                \n            </td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Name: </b></th>\n            <td style=\"padding-left: 4px;\">PlanDefinition_Recommendation_03_Order_Sign</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Title: </b></th>\n            <td style=\"padding-left: 4px;\">Recommendation #3 - Opioid Immediate Release Form When Starting Opioid Therapy</td>\n        </tr>\n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Status: </b></th>\n            <td style=\"padding-left: 4px;\">draft</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Experimental: </b></th>\n            <td style=\"padding-left: 4px;\">true</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Type: </b></th>\n            <td style=\"padding-left: 4px;\">\n                \n                    \n                        \n                        <p style=\"margin-bottom: 5px;\">\n                            <b>system: </b> <span><a href=\"http://terminology.hl7.org/6.5.0/CodeSystem-plan-definition-type.html\">http://terminology.hl7.org/CodeSystem/plan-definition-type</a></span>\n                        </p>\n                        \n                        \n                        <p style=\"margin-bottom: 5px;\">\n                            <b>code: </b> <span>eca-rule</span>\n                        </p>\n                        \n                        \n                        <p style=\"margin-bottom: 5px;\">\n                            <b>display: </b> <span>ECA Rule</span>\n                        </p>\n                        \n                    \n                \n                \n            </td>\n        </tr>\n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Date: </b></th>\n            <td style=\"padding-left: 4px;\">2025-08-06</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Publisher: </b></th>\n            <td style=\"padding-left: 4px;\">Centers for Disease Control and Prevention (CDC)</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Description: </b></th>\n            <td style=\"padding-left: 4px;\">When starting opioid therapy for acute, subacute, or chronic pain, clinicians should prescribe immediate-release opioids instead of extended-release and long-acting (ER/LA) opioids.</td>\n        </tr>\n        \n        \n            <tr>\n                <th scope=\"row\"><a name=\"effective-data-requirements\"> </a><b>Logic Definitions: </b></th>\n                <td style=\"padding-left: 4px;\">\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSREC03</td>\n                                \n                                \n                                    <td>Chronic Pain Extended Release Opioid Analgesic with Ambulatory Misuse Potential Prescriptions</td>\n                                \n                                \n                                    <td>0</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Chronic Pain Extended Release Opioid Analgesic with Ambulatory Misuse Potential Prescriptions\":\n  ( Common.\"Is Opioid Analgesic with Ambulatory Misuse Potential?\"( ContextPrescriptions ) ) AmbulatoryOpioidPrescription\n    where Routines.\"Is Subacute or Chronic Pain Prescription?\"( AmbulatoryOpioidPrescription )\n      and AmbulatoryOpioidPrescription.medication in Common.\"Extended release opioid with ambulatory misuse potential\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSREC03</td>\n                                \n                                \n                                    <td>Patient Is Being Prescribed Extended Release Opioid Analgesic with Ambulatory Misuse Potential</td>\n                                \n                                \n                                    <td>1</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Patient Is Being Prescribed Extended Release Opioid Analgesic with Ambulatory Misuse Potential\":\n  exists( \"Chronic Pain Extended Release Opioid Analgesic with Ambulatory Misuse Potential Prescriptions\" )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>Age Less than 18 Years Is Enabled</td>\n                                \n                                \n                                    <td>2</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// CDC 2022 General Inclusion Criteria\ndefine \"Age Less than 18 Years Is Enabled\":\n  true</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Patient Age Less Than 18</td>\n                                \n                                \n                                    <td>3</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Patient Age Less Than 18\":\n  if (Config.\"Age Less than 18 Years Is Enabled\") then\n    AgeInYearsAt(Today()) &lt; 18\n  else false</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>Sickle Cell Check Enabled</td>\n                                \n                                \n                                    <td>4</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// Sickle Cell\ndefine \"Sickle Cell Check Enabled\":\n  true</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>Sickle Cell Assumed Active</td>\n                                \n                                \n                                    <td>5</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Sickle Cell Assumed Active\":\n  true</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>US Core-Categorized Conditions</td>\n                                \n                                \n                                    <td>6</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// 3. Medications indicating end of life\n    /* or exists (\n      \"Medications Indicating End of Life\"\n    ) */\n\ndefine \"US Core-Categorized Conditions\":\n  [Condition: category in \"Encounter Diagnosis Condition Category\"]\n    union [Condition: category in \"Problem List Condition Category\"]\n    union [Condition: category in \"US Core Health Concern Condition Category\"]</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>Positive Sickle Cell Condition</td>\n                                \n                                \n                                    <td>7</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Positive Sickle Cell Condition\":\n  if Config.\"Sickle Cell Check Enabled\" and not Config.\"Sickle Cell Assumed Active\"\n    then (\n      \"US Core-Categorized Conditions\" C\n        where C.code in \"Sickle Cell Diseases\"\n          and C.clinicalStatus in \"Active Condition\"\n    ) else if Config.\"Sickle Cell Check Enabled\" and Config.\"Sickle Cell Assumed Active\"\n        then (\n          \"US Core-Categorized Conditions\" C\n            where C.code in \"Sickle Cell Diseases\"\n        )\n      else null</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Condition Positive for Sickle Cell</td>\n                                \n                                \n                                    <td>8</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Condition Positive for Sickle Cell\":\n  if (Config.\"Sickle Cell Check Enabled\") then\n    exists(\n      Common.\"Positive Sickle Cell Condition\"\n    ) \n  else false</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>Active Cancer Treatment Encounters Condition Is Enabled</td>\n                                \n                                \n                                    <td>9</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// Active Cancer Treatment\ndefine \"Active Cancer Treatment Encounters Condition Is Enabled\":\n  true</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Encounter Period</td>\n                                \n                                \n                                    <td>10</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// End of Opioid Naive Routine\n\n/*\n**  Routine #3\n**  Active Cancer Treatment Routine\n**\n**  Definition                    | Answer to Proceed   | Details                                    | Data (Terminology) Requirement\n**  ---------------------------------------------------------------------------------------------------------------------------------\n**  Two office visits within the  | No                  | Look for a minimum of two distinct         | Office Visit\n**  past 12 months                |                     | encounters within 12 months of the date    |\n**                                |                     | of the current visit for which each of the |\n**                                |                     | following is true:                         |\n**                                |                     |   - the encounter diagnosis (primary or    |\n**                                |                     |     secondary or co-morbidity diagnosis)   |\n**                                |                     |     is listed in the CDC Malignant Cancer  |\n**                                |                     |     Conditions value set                   |\n**  ---------------------------------------------------------------------------------------------------------------------------------\n**  Office visits with an         | No                  | The encounter is performed by an           | Oncology specialty\n**  oncology specialist           |                     | oncologist as defined in the oncology      | designations (NUCC)\n**  present                       |                     | specialty designations using the           |\n**                                |                     | National Uniform Claim Committee           |\n**                                |                     | (NUCC) classifications                     |\n**  ---------------------------------------------------------------------------------------------------------------------------------\n**  Office visits including CDC   | No                  | The encounter diagnosis (primary or        | CDC malignant cancer\n**  malignant cancer              |                     | secondary or co-morbidity diagnosis)       | conditions\n**  condition                     |                     | is listed in the CDC Malignant Cancer      |\n**                                |                     | Conditions value set                       |\n**  ----------------------------------------------------------------------------------------------------------------------------------\n**\n*/\n\ndefine \"Encounter Period\":\n  Interval[Today() - 12 months, Today())</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>USCore Encounter Cancer Diagnoses</td>\n                                \n                                \n                                    <td>11</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"USCore Encounter Cancer Diagnoses\":\n  [Condition: category in \"Encounter Diagnosis Condition Category\"] CancerDiagnoses\n    where CancerDiagnoses.code in \"CDC malignant cancer conditions\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Encounters with Cancer Diagnosis During Encounter Period</td>\n                                \n                                \n                                    <td>12</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// encounter-diagnosis, problem-list and health-concern Conditions\n// define \"US Core-Categorized Cancer Diagnoses\":\n//   Common.\"US Core-Categorized Conditions\" C\n//     where C.code in Common.\"CDC malignant cancer conditions\"\n\n// define \"Encounters with Cancer Diagnosis During Encounter Period\":\n//   [Encounter] Encounter\n//     with \"US Core-Categorized Cancer Diagnoses\" CancerDiagnosis\n//     such that date from Encounter.period.\"start\".value in day of \"Encounter Period\"\n//       and EndsWith(CancerDiagnosis.encounter.reference, Encounter.id)\n\ndefine \"Encounters with Cancer Diagnosis During Encounter Period\":\n  [Encounter] Encounters\n    where date from Encounters.period.\"start\" in day of \"Encounter Period\"\n      and exists (\n        Common.\"USCore Encounter Cancer Diagnoses\" CancerDiagnoses\n          where EndsWith(CancerDiagnoses.encounter.reference, Encounters.id)\n      )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Number of Encounters with Cancer Diagnosis During Encounter Period</td>\n                                \n                                \n                                    <td>13</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Number of Encounters with Cancer Diagnosis During Encounter Period\":\n  Count (\"Encounters with Cancer Diagnosis During Encounter Period\")</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Has Two or More Encounters with Cancer Diagnosis During Encounter Period</td>\n                                \n                                \n                                    <td>14</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Has Two or More Encounters with Cancer Diagnosis During Encounter Period\":\n  \"Number of Encounters with Cancer Diagnosis During Encounter Period\" &gt;= 2</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>USCore Problem List Cancer Diagnoses</td>\n                                \n                                \n                                    <td>15</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"USCore Problem List Cancer Diagnoses\":\n  [Condition: category in \"Problem List Condition Category\"] CancerDiagnoses\n    where CancerDiagnoses.code in \"CDC malignant cancer conditions\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Has Active Cancer Diagnosis on Problem List</td>\n                                \n                                \n                                    <td>16</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Has Active Cancer Diagnosis on Problem List\":\n  exists (\n    Common.\"USCore Problem List Cancer Diagnoses\" CancerDiagnoses\n      where CancerDiagnoses.category in Common.\"Problem List Condition Category\"\n        and exists(\n          CancerDiagnoses.clinicalStatus.coding ClinicalStatus\n            where ClinicalStatus.code ~ 'active'\n        )\n  )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Is Active Cancer Treatment?</td>\n                                \n                                \n                                    <td>17</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Is Active Cancer Treatment?\":\n  if (Config.\"Active Cancer Treatment Encounters Condition Is Enabled\") \n    then \"Has Two or More Encounters with Cancer Diagnosis During Encounter Period\"\n      or \"Has Active Cancer Diagnosis on Problem List\"\n  else false</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>End-Stage Disease Criteria Enabled</td>\n                                \n                                \n                                    <td>18</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// CDC 2022 General Inclusion Criteria\ndefine \"End-Stage Disease Criteria Enabled\":\n  true</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Conditions Likely Terminal for Opioid Prescribing</td>\n                                \n                                \n                                    <td>19</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Conditions Likely Terminal for Opioid Prescribing\":\n  if (Config.\"End-Stage Disease Criteria Enabled\") then\n    exists (\n      Common.\"US Core-Categorized Conditions\" EOLC\n        where EOLC.code in Common.\"Conditions likely terminal for opioid prescribing\"\n          // and EOLC.clinicalStatus in Common.\"Active Condition\"\n    )\n  else false</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>CDC 2022 Guideline General Inclusion Criteria</td>\n                                \n                                \n                                    <td>20</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"CDC 2022 Guideline General Inclusion Criteria\":\n  not \"Patient Age Less Than 18\"\n    and not \"Condition Positive for Sickle Cell\"\n    and not \"Is Active Cancer Treatment?\"\n    and not \"Conditions Likely Terminal for Opioid Prescribing\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>Opioid Naive Prescription Condition Is Enabled</td>\n                                \n                                \n                                    <td>21</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// Opioid Naive\ndefine \"Opioid Naive Prescription Condition Is Enabled\":\n  true</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>Can the implementing EHR support queries for past medications by date range?</td>\n                                \n                                \n                                    <td>22</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// Subroutine 2 - Past Medications\ndefine \"Can the implementing EHR support queries for past medications by date range?\":\n  true</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>Active Ambulatory Opioid Rx</td>\n                                \n                                \n                                    <td>23</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Active Ambulatory Opioid Rx\":\n    if Config.\"Can the implementing EHR support queries for past medications by date range?\" then\n      (\n        \"Get MedicationRequest Medication as Code\"(\"Get Active Ambulatory Medication Requests\"([MedicationRequest]))\n      ) Rx\n        where date from Rx.authoredOn 2 years or less on or before Today()\n          and Rx.medication in \"Opioid analgesics with ambulatory misuse potential\"\n    else\n        List&lt;FHIR.MedicationRequest&gt;{}</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Prescription/Dispense Inclusion Period</td>\n                                \n                                \n                                    <td>24</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// End of CDC 2022 General Inclusion Criteria Routine\n\n/*\n**  Routine #2\n**  Opioid Naive Routine\n**\n**  Definition                    | Answer to Proceed   | Details                                           | Data (Terminology) Requirement\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  Opioid analgesics with        | No                  | Look for an existing prescription (order) for     | Opioid analgesics with\n**  ambulatory misuse potential   |                     | opioid that is in the value set for opioid with   | ambulatory misuse potential\n**  prescription in past 90 days  |                     | ambulatory abuse potential authored               |\n**  excluding the previous 24     |                     | within the past 90 days (excluding previous 24    |\n**  hours                         |                     | hours)                                            |\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  Opioid analgesics with        | No                  | Look for evidence of active medication on         | Opioid analgesics with\n**  ambulatory misuse potential   |                     | the medication list that is in the value set      | ambulatory misuse potential\n**  reported in past 90 days      |                     | for opioid with ambulatory care abuse             |\n**  excluding previous 24 hours*  |                     | potential                                         |\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  Opioid analgesics with        | No                  | Look for evidence of a dispensing event for       | Opioid analgesics with\n**  ambulatory misuse potential   |                     | medication that is in the value set for opioid    | ambulatory misuse potential\n**  dispensing event in past 90   |                     | with ambulatory use potential occurring           |\n**  days excluding previous 24    |                     | within the past 90 days (excluding previous 24    |\n**  hours                         |                     | hours)                                            |\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  *Future consideration: Current algorithm addresses only orders (prescriptions).\n**\n**  Note – orders use RxNorm, but medication lists and dispensed medication will\n**  require an NDC value set and/or local mapping of NDC to RxNorm to enable this element\n**\n*/\n\ndefine \"Prescription/Dispense Inclusion Period\":\n  Interval[Now() - 90 days, Now() - 24 hours]</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Opioid RX with Ambulatory Abuse Potential In Past 90 Days</td>\n                                \n                                \n                                    <td>25</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Opioid RX with Ambulatory Abuse Potential In Past 90 Days\":\n  Common.\"Active Ambulatory Opioid Rx\" Rx\n      where Rx.authoredOn during day of \"Prescription/Dispense Inclusion Period\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Has Opioid RX with Ambulatory Abuse Potential In Past 90 Days</td>\n                                \n                                \n                                    <td>26</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Has Opioid RX with Ambulatory Abuse Potential In Past 90 Days\":\n    if (Config.\"Opioid Naive Prescription Condition Is Enabled\") then\n      exists (\"Opioid RX with Ambulatory Abuse Potential In Past 90 Days\")\n    else false</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days</td>\n                                \n                                \n                                    <td>27</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// NOTE: 2020-02-05: Review direction of MedicationStatement resource (US-Core focusing on MedicationRequest i/o Statement)\n// NOTE: 2020-04-21: MedicationStatement a) Shouldn't be use since guidance/direction from USCore is targeting MedicationUse in R5, and b) Breaks in the publisher\n/* define \"Reports of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\":\n    [MedicationStatement: Common.\"Opioid analgesics with ambulatory misuse potential\"] Statement\n        where Statement.status in {'active', 'completed'}\n            and Statement.effective during day of \"Report Inclusion Period\" */\n\n/* define \"Has Report of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\":\n    Config.\"Opioid Naive Report Condition Is Enabled\"\n        and exists (\"Reports of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\") */\n\ndefine \"Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\":\n    [MedicationDispense: Common.\"Opioid analgesics with ambulatory misuse potential\"] OpioidDispense\n        where OpioidDispense.whenHandedOver during day of \"Prescription/Dispense Inclusion Period\"\n            and OpioidDispense.status = 'completed'</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Has Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days</td>\n                                \n                                \n                                    <td>28</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Has Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\":\n  if (Config.\"Opioid Naive Prescription Condition Is Enabled\") then\n    exists (\"Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\")\n  else false</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Is Opioid Naive?</td>\n                                \n                                \n                                    <td>29</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// NOTE: MedicationStatement-dependent logic comment out due to bug in Publisher not supporting MedicationStatement in AllTypes.\ndefine \"Is Opioid Naive?\":\n    not (\"Has Opioid RX with Ambulatory Abuse Potential In Past 90 Days\")\n    /* and not (\"Has Report of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\") */\n    and not (\"Has Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\")</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSREC03</td>\n                                \n                                \n                                    <td>Inclusion Criteria</td>\n                                \n                                \n                                    <td>30</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Inclusion Criteria\":\n  \"Patient Is Being Prescribed Extended Release Opioid Analgesic with Ambulatory Misuse Potential\"\n      and Routines.\"CDC 2022 Guideline General Inclusion Criteria\"\n      and Routines.\"Is Opioid Naive?\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>Conditions Indicating End of Life or With Limited Life Expectancy</td>\n                                \n                                \n                                    <td>31</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Conditions Indicating End of Life or With Limited Life Expectancy\":\n  (\n    \"US Core-Categorized Conditions\" C\n      where C.code in \"Conditions likely terminal for opioid prescribing\"\n        and C.clinicalStatus in \"Active Condition\"\n  )\n  union\n  (\n    \"US Core-Categorized Conditions\" C\n      where C.code in \"Limited life expectancy conditions\"\n        and C.clinicalStatus in \"Active Condition\"\n  )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommonConfig</td>\n                                \n                                \n                                    <td>Hospice Findings Exclusion Enabled</td>\n                                \n                                \n                                    <td>32</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// OpioidCDSCommon\ndefine \"Hospice Findings Exclusion Enabled\":\n  false</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>Admitted/Referred/Discharged to Hospice Care</td>\n                                \n                                \n                                    <td>33</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Admitted/Referred/Discharged to Hospice Care\":\n  (\n    if (Config.\"Hospice Findings Exclusion Enabled\") then\n      [Observation: code in \"Hospice Finding Codes\"] O\n        where not (O.status.value in { 'unknown', 'entered-in-error', 'cancelled' })\n    else\n      {}\n  )\n  union\n  (\n    [Encounter] E\n      where date from E.period.start 1 year or less on or before Today()\n        and (\n          if E.hospitalization.dischargeDisposition.coding is null\n              or not exists (E.hospitalization.dischargeDisposition.coding)\n            then false\n          else E.hospitalization.dischargeDisposition in \"Hospice Disposition\"\n        )\n        and E.status.value in { 'planned', 'arrived', 'in-progress', 'finished', 'onleave' }\n  )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>End of Life Assessment</td>\n                                \n                                \n                                    <td>34</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"End of Life Assessment\":\n    // 1. Conditions indicating end of life or with limited life expectancy\n    exists (\n      \"Conditions Indicating End of Life or With Limited Life Expectancy\"\n    )\n    // 2. Admitted/referred/discharged to hospice care\n    or exists (\n      \"Admitted/Referred/Discharged to Hospice Care\"\n    )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSREC03</td>\n                                \n                                \n                                    <td>Exclusion Criteria</td>\n                                \n                                \n                                    <td>35</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Exclusion Criteria\":\n  Common.\"End of Life Assessment\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSREC03</td>\n                                \n                                \n                                    <td>Is Recommendation Applicable?</td>\n                                \n                                \n                                    <td>36</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define \"Is Recommendation Applicable?\":\n  \"Inclusion Criteria\"\n    and not \"Exclusion Criteria\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>Is Opioid Analgesic with Ambulatory Misuse Potential?</td>\n                                \n                                \n                                    <td>37</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function \"Is Opioid Analgesic with Ambulatory Misuse Potential?\"(value List&lt;MedicationRequest&gt;):\n  (\"Get MedicationRequest Medication as Code\"(value)) Rx\n    where Rx.medication in \"Opioid analgesics with ambulatory misuse potential\" \n      and Rx.category in \"Community\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>Get MedicationRequest Medication as Code</td>\n                                \n                                \n                                    <td>38</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function \"Get MedicationRequest Medication as Code\"(value List&lt;MedicationRequest&gt;):\n  value Rx\n    let Med: \n      if Rx.medication is Reference then singleton from (\n        [Medication] M\n          where M.id = (Last(Split((Rx.medication as FHIR.Reference).reference, '/')))\n      ) else null\n    return \n      MedicationRequest {\n        id: Rx.id,\n        status: Rx.status,\n        intent: Rx.intent,\n        category: Rx.category,\n        medication: if Rx.medication is Reference then Med.code else Rx.medication as CodeableConcept,\n        subject: Rx.subject,\n        authoredOn: Rx.authoredOn,\n        recorder: Rx.recorder,\n        dosageInstruction: Rx.dosageInstruction,\n        dispenseRequest: Rx.dispenseRequest\n      }</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>FHIRHelpers</td>\n                                \n                                \n                                    <td>ToString</td>\n                                \n                                \n                                    <td>39</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function ToString(value string): value.value</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>FHIRHelpers</td>\n                                \n                                \n                                    <td>ToConcept</td>\n                                \n                                \n                                    <td>40</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function ToConcept(concept FHIR.CodeableConcept):\n    if concept is null then\n        null\n    else\n        System.Concept {\n            codes: concept.coding C return ToCode(C),\n            display: concept.text.value\n        }</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>FHIRHelpers</td>\n                                \n                                \n                                    <td>ToCode</td>\n                                \n                                \n                                    <td>41</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function ToCode(coding FHIR.Coding):\n    if coding is null then\n        null\n    else\n        System.Code {\n          code: coding.code.value,\n          system: coding.system.value,\n          version: coding.version.value,\n          display: coding.display.value\n        }</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Is Subacute or Chronic Pain Prescription?</td>\n                                \n                                \n                                    <td>42</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">// End of Active Cancer Treatment Routine\n\n/*\n**  Routine #4\n**  For Subacute or Chronic Pain Routine\n**\n**  Definition                  | Answer to Proceed   | Details                                        | Data (Terminology) Requirement\n**  -----------------------------------------------------------------------------------------------------------------------------------\n**  Order for opioid analgesic  | Yes                 | Order for opioid analgesics with ambulatory    | Opioid analgesics with\n**  with expected supply        |                     | misuse potential with a supply duration of &gt;=  | ambulatory misuse potential\n**  duration &gt;= 28 days         |                     | 28 days                                        |\n**                              |                     |                                                |\n**                              |                     | - Subacute definition = order for opioid       |\n**                              |                     |   analgesics with ambulatory misuse            |\n**                              |                     |   potential with a supply duration of one to   |\n**                              |                     |   two months.                                  |\n**                              |                     | - Chronic pain definition = order for opioid   |\n**                              |                     |   analgesics with ambulatory misuse            |\n**                              |                     |   potential with a supply duration of &gt;= two   |\n**                              |                     |   months.                                      |\n**  -----------------------------------------------------------------------------------------------------------------------------------\n**\n*/\n\ndefine function \"Is Subacute or Chronic Pain Prescription?\"(prescription FHIR.MedicationRequest):\n  \"Is Subacute or Chronic Pain Using Expected Supply Duration\"(prescription)\n    or \"Is Subacute or Chronic Pain Using Validity Period\"(prescription)</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Is Subacute or Chronic Pain Using Expected Supply Duration</td>\n                                \n                                \n                                    <td>43</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function \"Is Subacute or Chronic Pain Using Expected Supply Duration\"(prescription FHIR.MedicationRequest):\n  (\n    prescription.dispenseRequest is not null\n      and prescription.dispenseRequest.expectedSupplyDuration is not null\n      and (\n        Common.GetDurationInDays(prescription.dispenseRequest.expectedSupplyDuration) &gt;= 28 days \n      )\n  )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>GetDurationInDays</td>\n                                \n                                \n                                    <td>44</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function GetDurationInDays(value FHIR.Duration):\n  if value is null then null\n  else\n    case\n      when value.code.value ~ 'a' then System.Quantity{ value: value.value.value * 365.0, unit: 'days' }\n      when value.code.value ~ 'mo' then System.Quantity{ value: value.value.value * 30.0, unit: 'days' }\n      when value.code.value ~ 'wk' then System.Quantity{ value: value.value.value * 7.0, unit: 'days' }\n      when value.code.value ~ 'd' then System.Quantity{ value: value.value.value, unit: 'days' }\n      when value.code.value ~ 'h' then System.Quantity{ value: value.value.value / 24.0, unit: 'days' }\n      when value.code.value ~ 'min' then System.Quantity{ value: value.value.value / 60.0 / 24.0, unit: 'days' }\n      when value.code.value ~ 's' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0, unit: 'days' }\n      when value.code.value ~ 'ms' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0 / 1000.0, unit: 'days' }\n      when value.code.value is null then Message(1000, true, 'Undefined', 'Error', 'Duration unit code is null')\n      else Message(1000, true, 'Undefined', 'Error', 'Unsupported duration unit code: ' + value.code.value)\nend</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSRoutines</td>\n                                \n                                \n                                    <td>Is Subacute or Chronic Pain Using Validity Period</td>\n                                \n                                \n                                    <td>45</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function \"Is Subacute or Chronic Pain Using Validity Period\"(prescription FHIR.MedicationRequest):\n  (\n    prescription.dispenseRequest is not null\n      and prescription.dispenseRequest.validityPeriod is not null\n      and (\n        days between prescription.dispenseRequest.validityPeriod.start and prescription.dispenseRequest.validityPeriod.end &gt;= 28 \n      )\n  )</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>FHIRHelpers</td>\n                                \n                                \n                                    <td>ToDateTime</td>\n                                \n                                \n                                    <td>46</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function ToDateTime(value dateTime): value.value</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>OpioidCDSCommon</td>\n                                \n                                \n                                    <td>Get Active Ambulatory Medication Requests</td>\n                                \n                                \n                                    <td>47</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function \"Get Active Ambulatory Medication Requests\" (value List&lt;MedicationRequest&gt;) returns List&lt;MedicationRequest&gt;:\n  value Rx\n    where Rx.status.value = 'active'\n      and Rx.category in \"Community\"</code></pre>\n                        \n                        <br/><br/>\n                    \n                        <table class=\"grid-dict\">\n                            <tr><th><b>Library Name</b></th><th><b>Name</b></th><th><b>sequence</b></th></tr>\n                            <tr>\n                                \n                                    <td>FHIRHelpers</td>\n                                \n                                \n                                    <td>ToString</td>\n                                \n                                \n                                    <td>48</td>\n                                \n                            </tr>\n                        </table>\n                        \n                            <pre style=\"max-width: 990px;\"><code class=\"language-cql\">define function ToString(value MedicationDispenseStatus): value.value</code></pre>\n                        \n                        <br/><br/>\n                    \n                </td>\n            </tr>\n        \n        \n        <tr>\n          <th scope=\"row\"><b>Knowledge Capability: </b></th>\n          <td style=\"padding-left: 4px;\">\n            shareable computable executable publishable \n          </td>\n        </tr>\n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Use Context: </b></th>\n            <td style=\"padding-left: 4px;\">\n                <table class=\"grid-dict\">\n                    <tr><th><b>code</b></th><th><b>value</b></th><th><b>display</b></th></tr>\n                    \n                      <tr>\n                        <td>focus</td>\n                        <td>182888003</td>\n                        <td>Medication requested (situation)</td>\n                      </tr>\n                    \n                      <tr>\n                        <td>focus</td>\n                        <td>82423001</td>\n                        <td>Chronic pain (finding)</td>\n                      </tr>\n                    \n                      <tr>\n                        <td>focus</td>\n                        <td>274663001</td>\n                        <td>Acute pain (finding)</td>\n                      </tr>\n                    \n                      <tr>\n                        <td>focus</td>\n                        <td/>\n                        <td/>\n                      </tr>\n                    \n                </table>\n            </td>\n        </tr>\n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Purpose: </b></th>\n            <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>\n</div></td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Usage: </b></th>\n            <td style=\"padding-left: 4px;\">Clinicians should not treat acute pain with ER/LA opioids or initiate opioid treatment for subacute or chronic pain with extended-release and long-acting (ER/LA) opioids, and clinicians should not prescribe ER/LA opioids for intermittent or as-needed use.</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Copyright: </b></th>\n            <td style=\"padding-left: 4px;\"><div><p>© CDC 2016+.</p>\n</div></td>\n        </tr>\n        \n        \n        \n        \n        \n        \n        <tr>\n          <th scope=\"row\"><b>Related Artifacts: </b></th>\n          <td style=\"padding-left: 4px;\">\n            \n            <p><b>Documentation</b></p>\n            <ul>\n              \n                  <li>\n                    <a href=\"https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm\"> 2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain</a>\n                  </li>\n              \n            </ul>\n            \n            \n            \n            \n            \n            \n            \n          </td>\n        </tr>\n        \n\n        \n        <tr>\n          <th scope=\"row\"><b>Libraries: </b></th>\n          <td style=\"padding-left: 4px;\">\n            <table class=\"grid-dict\">\n              \n                <tr><td><a href=\"Library-OpioidCDSREC03.html\">Library - Recommendation #3 - Opioid Immediate Release Form When Starting Opioid Therapy</a></td></tr>\n              \n            </table>\n          </td>\n        </tr>\n        \n\n        \n        <tr>\n          <th scope=\"row\"><b>Actions: </b></th>\n          <td style=\"padding-left: 4px;\">\n            <table class=\"grid-dict\">\n              \n                <tr>\n                  <td>\n                    <b> When Initiating Opioid Therapy, Utilize Immediate Release Opioids:</b> Recommend prescribing immediate release opioids instead of extended-release or long-acting opioids#xD;\n#xD;\n[For guidance regarding prescribing extended release/ long-acting opioids, see Recommendation 3 of the 2022 CDC Clinical Practice Guideline](https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm#Recommendation3).<br/>\n                    <b>When:</b> <i>Named Event:</i> order-sign<br/>\n                    <b>If:</b> <i>Applicability:</i> Check whether the current order is for an extended-release opioid with ambulatory misuse potential, the patient is opioid naive and if the 2022 CDC guideline general inclusion criteria is met <i>(Is Recommendation Applicable?)</i><br/>\n                    <b>Then:</b>\n                    \n                      <table class=\"grid-dict\">\n                        \n                          <tr>\n                            <td>\n                              <b> :</b> Document - Will prescribe immediate release opioid<br/>\n                              \n                              \n                              <b>Then:</b>\n                              \n                                \n                                \n                              \n                            </td>\n                          </tr>\n                        \n                          <tr>\n                            <td>\n                              <b> :</b> Snooze* - Benefits outweigh risks, snooze 3 months<br/>\n                              \n                              \n                              <b>Then:</b>\n                              \n                                \n                                \n                              \n                            </td>\n                          </tr>\n                        \n                          <tr>\n                            <td>\n                              <b> :</b> Snooze* N/A see comment, snooze 3 months<br/>\n                              \n                              \n                              <b>Then:</b>\n                              \n                                \n                                \n                              \n                            </td>\n                          </tr>\n                        \n                      </table>\n                    \n                  </td>\n                </tr>\n              \n            </table>\n          </td>\n        </tr>\n        \n    </table>\n</div>"^^rdf:XMLLiteral
  ] ; # 
  fhir:contained ( [
a fhir:Library ;
fhir:id [ fhir:v "effective-data-requirements" ] ;
fhir:name [ fhir:v "EffectiveDataRequirements" ] ;
fhir:status [ fhir:v "active" ] ;
fhir:type [
      ( fhir:coding [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/library-type"^^xsd:anyURI ] ;
fhir:code [ fhir:v "module-definition" ]       ] )     ] ;
    ( fhir:relatedArtifact [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Library Common" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSCommon|2022.1.0"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSCommon|2022.1.0>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Library FHIRHelpers" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/Library/FHIRHelpers|4.0.1"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/Library/FHIRHelpers|4.0.1>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Library Routines" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSRoutines|2022.1.0"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSRoutines|2022.1.0>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Library Config" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSCommonConfig|2022.1.0"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSCommonConfig|2022.1.0>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Opioid analgesics with ambulatory misuse potential" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-analgesics-with-ambulatory-misuse-potential"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-analgesics-with-ambulatory-misuse-potential>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Community" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/medicationrequest-category-community"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/medicationrequest-category-community>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Extended release opioid with ambulatory misuse potential" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/extended-release-opioid-with-ambulatory-misuse-potential"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/extended-release-opioid-with-ambulatory-misuse-potential>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Encounter Diagnosis Condition Category" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-encounter-diagnosis-category"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-encounter-diagnosis-category>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Problem List Condition Category" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-problem-list-category"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-problem-list-category>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set US Core Health Concern Condition Category" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-us-core-health-concern-category"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-us-core-health-concern-category>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Sickle Cell Diseases" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/sickle-cell-diseases"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/sickle-cell-diseases>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Active Condition" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-clinical-status-active"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-clinical-status-active>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set CDC malignant cancer conditions" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/cdc-malignant-cancer-conditions"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/cdc-malignant-cancer-conditions>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Conditions likely terminal for opioid prescribing" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/conditions-likely-terminal-for-opioid-prescribing"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/conditions-likely-terminal-for-opioid-prescribing>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Limited life expectancy conditions" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/limited-life-expectancy-conditions"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/limited-life-expectancy-conditions>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Hospice Finding Codes" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/hospice-finding"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/hospice-finding>       ]     ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Value set Hospice Disposition" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/hospice-disposition"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/hospice-disposition>       ]     ] ) ;
    ( fhir:parameter [
fhir:name [ fhir:v "ContextPrescriptions" ] ;
fhir:use [ fhir:v "in" ] ;
fhir:min [ fhir:v 0 ] ;
fhir:max [ fhir:v "*" ] ;
fhir:type [ fhir:v "MedicationRequest" ]     ] [
fhir:name [ fhir:v "Is Recommendation Applicable?" ] ;
fhir:use [ fhir:v "out" ] ;
fhir:min [ fhir:v 0 ] ;
fhir:max [ fhir:v "1" ] ;
fhir:type [ fhir:v "boolean" ]     ] ) ;
    ( fhir:dataRequirement [
fhir:type [ fhir:v "Medication" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Medication"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Medication>       ] ) ;
      ( fhir:mustSupport [ fhir:v "id" ] [ fhir:v "code" ] )     ] [
fhir:type [ fhir:v "Patient" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Patient"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Patient>       ] )     ] [
fhir:type [ fhir:v "Condition" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Condition"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Condition>       ] ) ;
      ( fhir:mustSupport [ fhir:v "category" ] [ fhir:v "code" ] [ fhir:v "clinicalStatus" ] ) ;
      ( fhir:codeFilter [
fhir:path [ fhir:v "category" ] ;
fhir:valueSet [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-us-core-health-concern-category"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-us-core-health-concern-category>         ]       ] )     ] [
fhir:type [ fhir:v "Condition" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Condition"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Condition>       ] ) ;
      ( fhir:mustSupport [ fhir:v "category" ] [ fhir:v "code" ] [ fhir:v "clinicalStatus" ] [ fhir:v "encounter" ] [ fhir:v "encounter.reference" ] ) ;
      ( fhir:codeFilter [
fhir:path [ fhir:v "category" ] ;
fhir:valueSet [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-encounter-diagnosis-category"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-encounter-diagnosis-category>         ]       ] )     ] [
fhir:type [ fhir:v "Condition" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Condition"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Condition>       ] ) ;
      ( fhir:mustSupport [ fhir:v "category" ] [ fhir:v "code" ] [ fhir:v "clinicalStatus" ] [ fhir:v "clinicalStatus.coding" ] ) ;
      ( fhir:codeFilter [
fhir:path [ fhir:v "category" ] ;
fhir:valueSet [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-problem-list-category"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/condition-problem-list-category>         ]       ] )     ] [
fhir:type [ fhir:v "Encounter" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Encounter"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Encounter>       ] ) ;
      ( fhir:mustSupport [ fhir:v "period" ] [ fhir:v "period.start" ] [ fhir:v "id" ] [ fhir:v "hospitalization" ] [ fhir:v "hospitalization.dischargeDisposition" ] [ fhir:v "hospitalization.dischargeDisposition.coding" ] [ fhir:v "status" ] [ fhir:v "status.value" ] )     ] [
fhir:type [ fhir:v "MedicationRequest" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/MedicationRequest"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/MedicationRequest>       ] ) ;
      ( fhir:mustSupport [ fhir:v "authoredOn" ] [ fhir:v "medication" ] [ fhir:v "medication.reference" ] [ fhir:v "id" ] [ fhir:v "status" ] [ fhir:v "intent" ] [ fhir:v "category" ] [ fhir:v "subject" ] [ fhir:v "recorder" ] [ fhir:v "dosageInstruction" ] [ fhir:v "dispenseRequest" ] [ fhir:v "status.value" ] )     ] [
fhir:type [ fhir:v "MedicationDispense" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/MedicationDispense"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/MedicationDispense>       ] ) ;
      ( fhir:mustSupport [ fhir:v "medication" ] [ fhir:v "whenHandedOver" ] [ fhir:v "status" ] ) ;
      ( fhir:codeFilter [
fhir:path [ fhir:v "medication" ] ;
fhir:valueSet [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-analgesics-with-ambulatory-misuse-potential"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/opioid-analgesics-with-ambulatory-misuse-potential>         ]       ] )     ] [
fhir:type [ fhir:v "MedicationDispense" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/MedicationDispense"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/MedicationDispense>       ] ) ;
      ( fhir:mustSupport [ fhir:v "medication.reference" ] [ fhir:v "whenHandedOver" ] [ fhir:v "status" ] )     ] [
fhir:type [ fhir:v "Observation" ] ;
      ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Observation"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Observation>       ] ) ;
      ( fhir:mustSupport [ fhir:v "code" ] [ fhir:v "status" ] [ fhir:v "status.value" ] ) ;
      ( fhir:codeFilter [
fhir:path [ fhir:v "code" ] ;
fhir:valueSet [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/ValueSet/hospice-finding"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/ValueSet/hospice-finding>         ]       ] )     ] )
  ] ) ; # 
  fhir:extension ( [
fhir:url [ fhir:v "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability"^^xsd:anyURI ] ;
fhir:value [
a fhir:code ;
fhir:v "shareable"     ]
  ] [
fhir:url [ fhir:v "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability"^^xsd:anyURI ] ;
fhir:value [
a fhir:code ;
fhir:v "computable"     ]
  ] [
fhir:url [ fhir:v "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability"^^xsd:anyURI ] ;
fhir:value [
a fhir:code ;
fhir:v "executable"     ]
  ] [
fhir:url [ fhir:v "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability"^^xsd:anyURI ] ;
fhir:value [
a fhir:code ;
fhir:v "publishable"     ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSREC03"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Chronic Pain Extended Release Opioid Analgesic with Ambulatory Misuse Potential Prescriptions"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Chronic Pain Extended Release Opioid Analgesic with Ambulatory Misuse Potential Prescriptions\":\n  ( Common.\"Is Opioid Analgesic with Ambulatory Misuse Potential?\"( ContextPrescriptions ) ) AmbulatoryOpioidPrescription\n    where Routines.\"Is Subacute or Chronic Pain Prescription?\"( AmbulatoryOpioidPrescription )\n      and AmbulatoryOpioidPrescription.medication in Common.\"Extended release opioid with ambulatory misuse potential\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 0       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSREC03"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Patient Is Being Prescribed Extended Release Opioid Analgesic with Ambulatory Misuse Potential"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Patient Is Being Prescribed Extended Release Opioid Analgesic with Ambulatory Misuse Potential\":\n  exists( \"Chronic Pain Extended Release Opioid Analgesic with Ambulatory Misuse Potential Prescriptions\" )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 1       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Age Less than 18 Years Is Enabled"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// CDC 2022 General Inclusion Criteria\ndefine \"Age Less than 18 Years Is Enabled\":\n  true"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 2       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Patient Age Less Than 18"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Patient Age Less Than 18\":\n  if (Config.\"Age Less than 18 Years Is Enabled\") then\n    AgeInYearsAt(Today()) < 18\n  else false"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 3       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Sickle Cell Check Enabled"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// Sickle Cell\ndefine \"Sickle Cell Check Enabled\":\n  true"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 4       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Sickle Cell Assumed Active"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Sickle Cell Assumed Active\":\n  true"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 5       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "US Core-Categorized Conditions"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// 3. Medications indicating end of life\n    /* or exists (\n      \"Medications Indicating End of Life\"\n    ) */\n\ndefine \"US Core-Categorized Conditions\":\n  [Condition: category in \"Encounter Diagnosis Condition Category\"]\n    union [Condition: category in \"Problem List Condition Category\"]\n    union [Condition: category in \"US Core Health Concern Condition Category\"]"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 6       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Positive Sickle Cell Condition"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Positive Sickle Cell Condition\":\n  if Config.\"Sickle Cell Check Enabled\" and not Config.\"Sickle Cell Assumed Active\"\n    then (\n      \"US Core-Categorized Conditions\" C\n        where C.code in \"Sickle Cell Diseases\"\n          and C.clinicalStatus in \"Active Condition\"\n    ) else if Config.\"Sickle Cell Check Enabled\" and Config.\"Sickle Cell Assumed Active\"\n        then (\n          \"US Core-Categorized Conditions\" C\n            where C.code in \"Sickle Cell Diseases\"\n        )\n      else null"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 7       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Condition Positive for Sickle Cell"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Condition Positive for Sickle Cell\":\n  if (Config.\"Sickle Cell Check Enabled\") then\n    exists(\n      Common.\"Positive Sickle Cell Condition\"\n    ) \n  else false"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 8       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Active Cancer Treatment Encounters Condition Is Enabled"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// Active Cancer Treatment\ndefine \"Active Cancer Treatment Encounters Condition Is Enabled\":\n  true"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 9       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Encounter Period"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// End of Opioid Naive Routine\n\n/*\n**  Routine #3\n**  Active Cancer Treatment Routine\n**\n**  Definition                    | Answer to Proceed   | Details                                    | Data (Terminology) Requirement\n**  ---------------------------------------------------------------------------------------------------------------------------------\n**  Two office visits within the  | No                  | Look for a minimum of two distinct         | Office Visit\n**  past 12 months                |                     | encounters within 12 months of the date    |\n**                                |                     | of the current visit for which each of the |\n**                                |                     | following is true:                         |\n**                                |                     |   - the encounter diagnosis (primary or    |\n**                                |                     |     secondary or co-morbidity diagnosis)   |\n**                                |                     |     is listed in the CDC Malignant Cancer  |\n**                                |                     |     Conditions value set                   |\n**  ---------------------------------------------------------------------------------------------------------------------------------\n**  Office visits with an         | No                  | The encounter is performed by an           | Oncology specialty\n**  oncology specialist           |                     | oncologist as defined in the oncology      | designations (NUCC)\n**  present                       |                     | specialty designations using the           |\n**                                |                     | National Uniform Claim Committee           |\n**                                |                     | (NUCC) classifications                     |\n**  ---------------------------------------------------------------------------------------------------------------------------------\n**  Office visits including CDC   | No                  | The encounter diagnosis (primary or        | CDC malignant cancer\n**  malignant cancer              |                     | secondary or co-morbidity diagnosis)       | conditions\n**  condition                     |                     | is listed in the CDC Malignant Cancer      |\n**                                |                     | Conditions value set                       |\n**  ----------------------------------------------------------------------------------------------------------------------------------\n**\n*/\n\ndefine \"Encounter Period\":\n  Interval[Today() - 12 months, Today())"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 10       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "USCore Encounter Cancer Diagnoses"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"USCore Encounter Cancer Diagnoses\":\n  [Condition: category in \"Encounter Diagnosis Condition Category\"] CancerDiagnoses\n    where CancerDiagnoses.code in \"CDC malignant cancer conditions\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 11       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Encounters with Cancer Diagnosis During Encounter Period"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// encounter-diagnosis, problem-list and health-concern Conditions\n// define \"US Core-Categorized Cancer Diagnoses\":\n//   Common.\"US Core-Categorized Conditions\" C\n//     where C.code in Common.\"CDC malignant cancer conditions\"\n\n// define \"Encounters with Cancer Diagnosis During Encounter Period\":\n//   [Encounter] Encounter\n//     with \"US Core-Categorized Cancer Diagnoses\" CancerDiagnosis\n//     such that date from Encounter.period.\"start\".value in day of \"Encounter Period\"\n//       and EndsWith(CancerDiagnosis.encounter.reference, Encounter.id)\n\ndefine \"Encounters with Cancer Diagnosis During Encounter Period\":\n  [Encounter] Encounters\n    where date from Encounters.period.\"start\" in day of \"Encounter Period\"\n      and exists (\n        Common.\"USCore Encounter Cancer Diagnoses\" CancerDiagnoses\n          where EndsWith(CancerDiagnoses.encounter.reference, Encounters.id)\n      )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 12       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Number of Encounters with Cancer Diagnosis During Encounter Period"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Number of Encounters with Cancer Diagnosis During Encounter Period\":\n  Count (\"Encounters with Cancer Diagnosis During Encounter Period\")"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 13       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Has Two or More Encounters with Cancer Diagnosis During Encounter Period"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Has Two or More Encounters with Cancer Diagnosis During Encounter Period\":\n  \"Number of Encounters with Cancer Diagnosis During Encounter Period\" >= 2"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 14       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "USCore Problem List Cancer Diagnoses"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"USCore Problem List Cancer Diagnoses\":\n  [Condition: category in \"Problem List Condition Category\"] CancerDiagnoses\n    where CancerDiagnoses.code in \"CDC malignant cancer conditions\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 15       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Has Active Cancer Diagnosis on Problem List"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Has Active Cancer Diagnosis on Problem List\":\n  exists (\n    Common.\"USCore Problem List Cancer Diagnoses\" CancerDiagnoses\n      where CancerDiagnoses.category in Common.\"Problem List Condition Category\"\n        and exists(\n          CancerDiagnoses.clinicalStatus.coding ClinicalStatus\n            where ClinicalStatus.code ~ 'active'\n        )\n  )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 16       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Is Active Cancer Treatment?"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Is Active Cancer Treatment?\":\n  if (Config.\"Active Cancer Treatment Encounters Condition Is Enabled\") \n    then \"Has Two or More Encounters with Cancer Diagnosis During Encounter Period\"\n      or \"Has Active Cancer Diagnosis on Problem List\"\n  else false"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 17       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "End-Stage Disease Criteria Enabled"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// CDC 2022 General Inclusion Criteria\ndefine \"End-Stage Disease Criteria Enabled\":\n  true"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 18       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Conditions Likely Terminal for Opioid Prescribing"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Conditions Likely Terminal for Opioid Prescribing\":\n  if (Config.\"End-Stage Disease Criteria Enabled\") then\n    exists (\n      Common.\"US Core-Categorized Conditions\" EOLC\n        where EOLC.code in Common.\"Conditions likely terminal for opioid prescribing\"\n          // and EOLC.clinicalStatus in Common.\"Active Condition\"\n    )\n  else false"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 19       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "CDC 2022 Guideline General Inclusion Criteria"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"CDC 2022 Guideline General Inclusion Criteria\":\n  not \"Patient Age Less Than 18\"\n    and not \"Condition Positive for Sickle Cell\"\n    and not \"Is Active Cancer Treatment?\"\n    and not \"Conditions Likely Terminal for Opioid Prescribing\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 20       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Opioid Naive Prescription Condition Is Enabled"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// Opioid Naive\ndefine \"Opioid Naive Prescription Condition Is Enabled\":\n  true"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 21       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Can the implementing EHR support queries for past medications by date range?"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// Subroutine 2 - Past Medications\ndefine \"Can the implementing EHR support queries for past medications by date range?\":\n  true"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 22       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Active Ambulatory Opioid Rx"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Active Ambulatory Opioid Rx\":\n    if Config.\"Can the implementing EHR support queries for past medications by date range?\" then\n      (\n        \"Get MedicationRequest Medication as Code\"(\"Get Active Ambulatory Medication Requests\"([MedicationRequest]))\n      ) Rx\n        where date from Rx.authoredOn 2 years or less on or before Today()\n          and Rx.medication in \"Opioid analgesics with ambulatory misuse potential\"\n    else\n        List<FHIR.MedicationRequest>{}"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 23       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Prescription/Dispense Inclusion Period"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// End of CDC 2022 General Inclusion Criteria Routine\n\n/*\n**  Routine #2\n**  Opioid Naive Routine\n**\n**  Definition                    | Answer to Proceed   | Details                                           | Data (Terminology) Requirement\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  Opioid analgesics with        | No                  | Look for an existing prescription (order) for     | Opioid analgesics with\n**  ambulatory misuse potential   |                     | opioid that is in the value set for opioid with   | ambulatory misuse potential\n**  prescription in past 90 days  |                     | ambulatory abuse potential authored               |\n**  excluding the previous 24     |                     | within the past 90 days (excluding previous 24    |\n**  hours                         |                     | hours)                                            |\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  Opioid analgesics with        | No                  | Look for evidence of active medication on         | Opioid analgesics with\n**  ambulatory misuse potential   |                     | the medication list that is in the value set      | ambulatory misuse potential\n**  reported in past 90 days      |                     | for opioid with ambulatory care abuse             |\n**  excluding previous 24 hours*  |                     | potential                                         |\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  Opioid analgesics with        | No                  | Look for evidence of a dispensing event for       | Opioid analgesics with\n**  ambulatory misuse potential   |                     | medication that is in the value set for opioid    | ambulatory misuse potential\n**  dispensing event in past 90   |                     | with ambulatory use potential occurring           |\n**  days excluding previous 24    |                     | within the past 90 days (excluding previous 24    |\n**  hours                         |                     | hours)                                            |\n**  ----------------------------------------------------------------------------------------------------------------------------------------\n**  *Future consideration: Current algorithm addresses only orders (prescriptions).\n**\n**  Note – orders use RxNorm, but medication lists and dispensed medication will\n**  require an NDC value set and/or local mapping of NDC to RxNorm to enable this element\n**\n*/\n\ndefine \"Prescription/Dispense Inclusion Period\":\n  Interval[Now() - 90 days, Now() - 24 hours]"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 24       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Opioid RX with Ambulatory Abuse Potential In Past 90 Days"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Opioid RX with Ambulatory Abuse Potential In Past 90 Days\":\n  Common.\"Active Ambulatory Opioid Rx\" Rx\n      where Rx.authoredOn during day of \"Prescription/Dispense Inclusion Period\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 25       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Has Opioid RX with Ambulatory Abuse Potential In Past 90 Days"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Has Opioid RX with Ambulatory Abuse Potential In Past 90 Days\":\n    if (Config.\"Opioid Naive Prescription Condition Is Enabled\") then\n      exists (\"Opioid RX with Ambulatory Abuse Potential In Past 90 Days\")\n    else false"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 26       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// NOTE: 2020-02-05: Review direction of MedicationStatement resource (US-Core focusing on MedicationRequest i/o Statement)\n// NOTE: 2020-04-21: MedicationStatement a) Shouldn't be use since guidance/direction from USCore is targeting MedicationUse in R5, and b) Breaks in the publisher\n/* define \"Reports of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\":\n    [MedicationStatement: Common.\"Opioid analgesics with ambulatory misuse potential\"] Statement\n        where Statement.status in {'active', 'completed'}\n            and Statement.effective during day of \"Report Inclusion Period\" */\n\n/* define \"Has Report of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\":\n    Config.\"Opioid Naive Report Condition Is Enabled\"\n        and exists (\"Reports of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\") */\n\ndefine \"Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\":\n    [MedicationDispense: Common.\"Opioid analgesics with ambulatory misuse potential\"] OpioidDispense\n        where OpioidDispense.whenHandedOver during day of \"Prescription/Dispense Inclusion Period\"\n            and OpioidDispense.status = 'completed'"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 27       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Has Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Has Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\":\n  if (Config.\"Opioid Naive Prescription Condition Is Enabled\") then\n    exists (\"Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\")\n  else false"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 28       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Is Opioid Naive?"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// NOTE: MedicationStatement-dependent logic comment out due to bug in Publisher not supporting MedicationStatement in AllTypes.\ndefine \"Is Opioid Naive?\":\n    not (\"Has Opioid RX with Ambulatory Abuse Potential In Past 90 Days\")\n    /* and not (\"Has Report of Opioid with Ambulatory Care Abuse Potential Reported in Past 90 Days\") */\n    and not (\"Has Opioid Dispense with Ambulatory Abuse Potential In Past 90 Days\")"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 29       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSREC03"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Inclusion Criteria"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Inclusion Criteria\":\n  \"Patient Is Being Prescribed Extended Release Opioid Analgesic with Ambulatory Misuse Potential\"\n      and Routines.\"CDC 2022 Guideline General Inclusion Criteria\"\n      and Routines.\"Is Opioid Naive?\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 30       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Conditions Indicating End of Life or With Limited Life Expectancy"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Conditions Indicating End of Life or With Limited Life Expectancy\":\n  (\n    \"US Core-Categorized Conditions\" C\n      where C.code in \"Conditions likely terminal for opioid prescribing\"\n        and C.clinicalStatus in \"Active Condition\"\n  )\n  union\n  (\n    \"US Core-Categorized Conditions\" C\n      where C.code in \"Limited life expectancy conditions\"\n        and C.clinicalStatus in \"Active Condition\"\n  )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 31       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommonConfig"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Hospice Findings Exclusion Enabled"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// OpioidCDSCommon\ndefine \"Hospice Findings Exclusion Enabled\":\n  false"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 32       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Admitted/Referred/Discharged to Hospice Care"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Admitted/Referred/Discharged to Hospice Care\":\n  (\n    if (Config.\"Hospice Findings Exclusion Enabled\") then\n      [Observation: code in \"Hospice Finding Codes\"] O\n        where not (O.status.value in { 'unknown', 'entered-in-error', 'cancelled' })\n    else\n      {}\n  )\n  union\n  (\n    [Encounter] E\n      where date from E.period.start 1 year or less on or before Today()\n        and (\n          if E.hospitalization.dischargeDisposition.coding is null\n              or not exists (E.hospitalization.dischargeDisposition.coding)\n            then false\n          else E.hospitalization.dischargeDisposition in \"Hospice Disposition\"\n        )\n        and E.status.value in { 'planned', 'arrived', 'in-progress', 'finished', 'onleave' }\n  )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 33       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "End of Life Assessment"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"End of Life Assessment\":\n    // 1. Conditions indicating end of life or with limited life expectancy\n    exists (\n      \"Conditions Indicating End of Life or With Limited Life Expectancy\"\n    )\n    // 2. Admitted/referred/discharged to hospice care\n    or exists (\n      \"Admitted/Referred/Discharged to Hospice Care\"\n    )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 34       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSREC03"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Exclusion Criteria"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Exclusion Criteria\":\n  Common.\"End of Life Assessment\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 35       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSREC03"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Is Recommendation Applicable?"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define \"Is Recommendation Applicable?\":\n  \"Inclusion Criteria\"\n    and not \"Exclusion Criteria\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 36       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Is Opioid Analgesic with Ambulatory Misuse Potential?"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function \"Is Opioid Analgesic with Ambulatory Misuse Potential?\"(value List<MedicationRequest>):\n  (\"Get MedicationRequest Medication as Code\"(value)) Rx\n    where Rx.medication in \"Opioid analgesics with ambulatory misuse potential\" \n      and Rx.category in \"Community\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 37       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Get MedicationRequest Medication as Code"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function \"Get MedicationRequest Medication as Code\"(value List<MedicationRequest>):\n  value Rx\n    let Med: \n      if Rx.medication is Reference then singleton from (\n        [Medication] M\n          where M.id = (Last(Split((Rx.medication as FHIR.Reference).reference, '/')))\n      ) else null\n    return \n      MedicationRequest {\n        id: Rx.id,\n        status: Rx.status,\n        intent: Rx.intent,\n        category: Rx.category,\n        medication: if Rx.medication is Reference then Med.code else Rx.medication as CodeableConcept,\n        subject: Rx.subject,\n        authoredOn: Rx.authoredOn,\n        recorder: Rx.recorder,\n        dosageInstruction: Rx.dosageInstruction,\n        dispenseRequest: Rx.dispenseRequest\n      }"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 38       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "FHIRHelpers"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "ToString"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function ToString(value string): value.value"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 39       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "FHIRHelpers"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "ToConcept"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function ToConcept(concept FHIR.CodeableConcept):\n    if concept is null then\n        null\n    else\n        System.Concept {\n            codes: concept.coding C return ToCode(C),\n            display: concept.text.value\n        }"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 40       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "FHIRHelpers"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "ToCode"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function ToCode(coding FHIR.Coding):\n    if coding is null then\n        null\n    else\n        System.Code {\n          code: coding.code.value,\n          system: coding.system.value,\n          version: coding.version.value,\n          display: coding.display.value\n        }"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 41       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Is Subacute or Chronic Pain Prescription?"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "// End of Active Cancer Treatment Routine\n\n/*\n**  Routine #4\n**  For Subacute or Chronic Pain Routine\n**\n**  Definition                  | Answer to Proceed   | Details                                        | Data (Terminology) Requirement\n**  -----------------------------------------------------------------------------------------------------------------------------------\n**  Order for opioid analgesic  | Yes                 | Order for opioid analgesics with ambulatory    | Opioid analgesics with\n**  with expected supply        |                     | misuse potential with a supply duration of >=  | ambulatory misuse potential\n**  duration >= 28 days         |                     | 28 days                                        |\n**                              |                     |                                                |\n**                              |                     | - Subacute definition = order for opioid       |\n**                              |                     |   analgesics with ambulatory misuse            |\n**                              |                     |   potential with a supply duration of one to   |\n**                              |                     |   two months.                                  |\n**                              |                     | - Chronic pain definition = order for opioid   |\n**                              |                     |   analgesics with ambulatory misuse            |\n**                              |                     |   potential with a supply duration of >= two   |\n**                              |                     |   months.                                      |\n**  -----------------------------------------------------------------------------------------------------------------------------------\n**\n*/\n\ndefine function \"Is Subacute or Chronic Pain Prescription?\"(prescription FHIR.MedicationRequest):\n  \"Is Subacute or Chronic Pain Using Expected Supply Duration\"(prescription)\n    or \"Is Subacute or Chronic Pain Using Validity Period\"(prescription)"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 42       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Is Subacute or Chronic Pain Using Expected Supply Duration"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function \"Is Subacute or Chronic Pain Using Expected Supply Duration\"(prescription FHIR.MedicationRequest):\n  (\n    prescription.dispenseRequest is not null\n      and prescription.dispenseRequest.expectedSupplyDuration is not null\n      and (\n        Common.GetDurationInDays(prescription.dispenseRequest.expectedSupplyDuration) >= 28 days \n      )\n  )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 43       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "GetDurationInDays"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function GetDurationInDays(value FHIR.Duration):\n  if value is null then null\n  else\n    case\n      when value.code.value ~ 'a' then System.Quantity{ value: value.value.value * 365.0, unit: 'days' }\n      when value.code.value ~ 'mo' then System.Quantity{ value: value.value.value * 30.0, unit: 'days' }\n      when value.code.value ~ 'wk' then System.Quantity{ value: value.value.value * 7.0, unit: 'days' }\n      when value.code.value ~ 'd' then System.Quantity{ value: value.value.value, unit: 'days' }\n      when value.code.value ~ 'h' then System.Quantity{ value: value.value.value / 24.0, unit: 'days' }\n      when value.code.value ~ 'min' then System.Quantity{ value: value.value.value / 60.0 / 24.0, unit: 'days' }\n      when value.code.value ~ 's' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0, unit: 'days' }\n      when value.code.value ~ 'ms' then System.Quantity{ value: value.value.value / 60.0 / 60.0 / 24.0 / 1000.0, unit: 'days' }\n      when value.code.value is null then Message(1000, true, 'Undefined', 'Error', 'Duration unit code is null')\n      else Message(1000, true, 'Undefined', 'Error', 'Unsupported duration unit code: ' + value.code.value)\nend"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 44       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSRoutines"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Is Subacute or Chronic Pain Using Validity Period"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function \"Is Subacute or Chronic Pain Using Validity Period\"(prescription FHIR.MedicationRequest):\n  (\n    prescription.dispenseRequest is not null\n      and prescription.dispenseRequest.validityPeriod is not null\n      and (\n        days between prescription.dispenseRequest.validityPeriod.start and prescription.dispenseRequest.validityPeriod.end >= 28 \n      )\n  )"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 45       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "FHIRHelpers"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "ToDateTime"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function ToDateTime(value dateTime): value.value"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 46       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "OpioidCDSCommon"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "Get Active Ambulatory Medication Requests"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function \"Get Active Ambulatory Medication Requests\" (value List<MedicationRequest>) returns List<MedicationRequest>:\n  value Rx\n    where Rx.status.value = 'active'\n      and Rx.category in \"Community\""       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 47       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
    ( fhir:extension [
fhir:url [ fhir:v "libraryName"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "FHIRHelpers"       ]     ] [
fhir:url [ fhir:v "name"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "ToString"       ]     ] [
fhir:url [ fhir:v "statement"^^xsd:anyURI ] ;
fhir:value [
a fhir:string ;
fhir:v "define function ToString(value MedicationDispenseStatus): value.value"       ]     ] [
fhir:url [ fhir:v "displaySequence"^^xsd:anyURI ] ;
fhir:value [
a fhir:integer ;
fhir:v 48       ]     ] ) ;
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"^^xsd:anyURI ]
  ] [
fhir:id [ fhir:v "effective-data-requirements" ] ;
fhir:url [ fhir:v "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements"^^xsd:anyURI ] ;
fhir:value [
a fhir:canonical ;
fhir:v "#effective-data-requirements"^^xsd:anyURI     ]
  ] [
fhir:url [ fhir:v "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem"^^xsd:anyURI ] ;
fhir:value [
a fhir:Reference ;
fhir:reference [ fhir:v "Device/cqf-tooling" ]     ]
  ] ) ; # 
  fhir:url [ fhir:v "http://fhir.org/guides/cdc/opioid-cds/PlanDefinition/opioidcds-03"^^xsd:anyURI] ; # 
  fhir:identifier ( [
fhir:use [ fhir:v "official" ] ;
fhir:value [ fhir:v "cdc-opioid-guidance" ]
  ] ) ; # 
  fhir:version [ fhir:v "2022.1.0"] ; # 
  fhir:name [ fhir:v "PlanDefinition_Recommendation_03_Order_Sign"] ; # 
  fhir:title [ fhir:v "Recommendation #3 - Opioid Immediate Release Form When Starting Opioid Therapy"] ; # 
  fhir:type [
    ( fhir:coding [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/plan-definition-type"^^xsd:anyURI ] ;
fhir:code [ fhir:v "eca-rule" ] ;
fhir:display [ fhir:v "ECA Rule" ]     ] )
  ] ; # 
  fhir:status [ fhir:v "draft"] ; # 
  fhir:experimental [ fhir:v true] ; # 
  fhir:date [ fhir:v "2025-08-06"^^xsd:date] ; # 
  fhir:publisher [ fhir:v "Centers for Disease Control and Prevention (CDC)"] ; # 
  fhir:contact ( [
    ( fhir:telecom [
fhir:system [ fhir:v "url" ] ;
fhir:value [ fhir:v "https://www.cdc.gov" ]     ] )
  ] ) ; # 
  fhir:description [ fhir:v "When starting opioid therapy for acute, subacute, or chronic pain, clinicians should prescribe immediate-release opioids instead of extended-release and long-acting (ER/LA) opioids."] ; # 
  fhir:useContext ( [
fhir:code [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/usage-context-type"^^xsd:anyURI ] ;
fhir:code [ fhir:v "focus" ] ;
fhir:display [ fhir:v "Clinical Focus" ]     ] ;
fhir:value [
a fhir:CodeableConcept ;
      ( fhir:coding [
a sct:182888003 ;
fhir:system [ fhir:v "http://snomed.info/sct"^^xsd:anyURI ] ;
fhir:code [ fhir:v "182888003" ] ;
fhir:display [ fhir:v "Medication requested (situation)" ]       ] )     ]
  ] [
fhir:code [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/usage-context-type"^^xsd:anyURI ] ;
fhir:code [ fhir:v "focus" ] ;
fhir:display [ fhir:v "Clinical Focus" ]     ] ;
fhir:value [
a fhir:CodeableConcept ;
      ( fhir:coding [
a sct:82423001 ;
fhir:system [ fhir:v "http://snomed.info/sct"^^xsd:anyURI ] ;
fhir:code [ fhir:v "82423001" ] ;
fhir:display [ fhir:v "Chronic pain (finding)" ]       ] )     ]
  ] [
fhir:code [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/usage-context-type"^^xsd:anyURI ] ;
fhir:code [ fhir:v "focus" ] ;
fhir:display [ fhir:v "Clinical Focus" ]     ] ;
fhir:value [
a fhir:CodeableConcept ;
      ( fhir:coding [
a sct:274663001 ;
fhir:system [ fhir:v "http://snomed.info/sct"^^xsd:anyURI ] ;
fhir:code [ fhir:v "274663001" ] ;
fhir:display [ fhir:v "Acute pain (finding)" ]       ] )     ]
  ] [
fhir:code [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/usage-context-type"^^xsd:anyURI ] ;
fhir:code [ fhir:v "focus" ] ;
fhir:display [ fhir:v "Clinical Focus" ]     ] ;
fhir:value [
a fhir:CodeableConcept ;
fhir:text [ fhir:v "Subacute pain" ]     ]
  ] ) ; # 
  fhir:purpose [ fhir:v "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."] ; # 
  fhir:usage [ fhir:v "Clinicians should not treat acute pain with ER/LA opioids or initiate opioid treatment for subacute or chronic pain with extended-release and long-acting (ER/LA) opioids, and clinicians should not prescribe ER/LA opioids for intermittent or as-needed use."] ; # 
  fhir:copyright [ fhir:v "© CDC 2016+."] ; # 
  fhir:topic ( [
fhir:text [ fhir:v "Opioid Prescribing" ]
  ] ) ; # 
  fhir:author ( [
fhir:name [ fhir:v "Kensaku Kawamoto, MD, PhD, MHS" ]
  ] [
fhir:name [ fhir:v "Bryn Rhodes" ]
  ] [
fhir:name [ fhir:v "Floyd Eisenberg, MD, MPH" ]
  ] [
fhir:name [ fhir:v "Robert McClure, MD, MPH" ]
  ] ) ; # 
  fhir:relatedArtifact ( [
fhir:type [ fhir:v "documentation" ] ;
fhir:display [ fhir:v "2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain" ] ;
fhir:url [ fhir:v "https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm"^^xsd:anyURI ] ;
fhir:document [
fhir:url [ fhir:v "https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm"^^xsd:anyURI ]     ]
  ] ) ; # 
  fhir:library ( [
fhir:v "http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSREC03"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSREC03>
  ] ) ; # 
  fhir:action ( [
    ( fhir:extension [
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-strengthOfRecommendation"^^xsd:anyURI ] ;
fhir:value [
a fhir:CodeableConcept ;
        ( fhir:coding [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/recommendation-strength"^^xsd:anyURI ] ;
fhir:code [ fhir:v "strong" ] ;
fhir:display [ fhir:v "Strong" ]         ] )       ]     ] [
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-qualityOfEvidence"^^xsd:anyURI ] ;
fhir:value [
a fhir:CodeableConcept ;
        ( fhir:coding [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/evidence-quality"^^xsd:anyURI ] ;
fhir:code [ fhir:v "very-low" ] ;
fhir:display [ fhir:v "Very Low quality" ]         ] )       ]     ] ) ;
fhir:title [ fhir:v "When Initiating Opioid Therapy, Utilize Immediate Release Opioids" ] ;
fhir:description [ fhir:v "Recommend prescribing immediate release opioids instead of extended-release or long-acting opioids\r\n\r\n[For guidance regarding prescribing extended release/ long-acting opioids, see Recommendation 3 of the 2022 CDC Clinical Practice Guideline](https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm#Recommendation3)." ] ;
fhir:priority [ fhir:v "urgent" ] ;
    ( fhir:trigger [
fhir:type [ fhir:v "named-event" ] ;
fhir:name [ fhir:v "order-sign" ]     ] ) ;
    ( fhir:condition [
fhir:kind [ fhir:v "applicability" ] ;
fhir:expression [
fhir:description [ fhir:v "Check whether the current order is for an extended-release opioid with ambulatory misuse potential, the patient is opioid naive and if the 2022 CDC guideline general inclusion criteria is met" ] ;
fhir:language [ fhir:v "text/cql.identifier" ] ;
fhir:expression [ fhir:v "Is Recommendation Applicable?" ]       ]     ] ) ;
fhir:groupingBehavior [ fhir:v "visual-group" ] ;
fhir:selectionBehavior [ fhir:v "any" ] ;
    ( fhir:action [
fhir:description [ fhir:v "Document - Will prescribe immediate release opioid" ]     ] [
fhir:description [ fhir:v "Snooze* - Benefits outweigh risks, snooze 3 months" ]     ] [
fhir:description [ fhir:v "Snooze* N/A see comment, snooze 3 months" ]     ] )
  ] ) . #