@prefix fhir: <http://hl7.org/fhir/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sct: <http://snomed.info/sct/> .

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

[] a fhir:PlanDefinition;
  fhir:Resource.id [ fhir:value "opioidcds-11-order-select"], [ fhir:value "effective-data-requirements"];
  fhir:Resource.meta [
     fhir:Meta.profile [
       fhir:value "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-recommendationdefinition";
       fhir:index 0
     ], [
       fhir:value "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-publishableplandefinition";
       fhir:index 1
     ]
  ];
  fhir:DomainResource.extension [
     fhir:index 0;
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability" ];
     fhir:Extension.value [ fhir:value "shareable" ]
  ], [
     fhir:index 1;
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability" ];
     fhir:Extension.value [ fhir:value "computable" ]
  ], [
     fhir:index 2;
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability" ];
     fhir:Extension.value [ fhir:value "executable" ]
  ], [
     fhir:index 3;
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability" ];
     fhir:Extension.value [ fhir:value "publishable" ]
  ], [
     fhir:index 4;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSREC11OrderSelect" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Opioid Analgesic with Ambulatory Misuse Potential Prescriptions" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Opioid Analgesic with Ambulatory Misuse Potential Prescriptions\":\n  Common.\"Is Opioid Analgesic with Ambulatory Misuse Potential?\"( ContextPrescriptions )" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "0" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 5;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSREC11OrderSelect" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential\":\n  exists( \"Opioid Analgesic with Ambulatory Misuse Potential Prescriptions\" )" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "1" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 6;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommonConfig" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Can the implementing EHR support queries for past medications by date range?" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// Subroutine 2 - Past Medications\ndefine \"Can the implementing EHR support queries for past medications by date range?\":\n  true" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "2" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 7;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Active Medication List" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Active Medication List\":\n  [MedicationRequest: status in { 'active' }] ActiveMeds\n    where ActiveMeds.category in \"Community\"" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "3" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 8;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Active Ambulatory Benzodiazepine or CNS Depressant Rx" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Active Ambulatory Benzodiazepine or CNS Depressant Rx\":\n    if Config.\"Can the implementing EHR support queries for past medications by date range?\" then\n      (\n        \"Get MedicationRequest Medication as Code\"(\"Active Medication List\")\n      ) Rx\n        where date from Rx.authoredOn 2 years or less on or before Today()\n          and Rx.medication in \"Benzodiazepine medications\"\n          or  Rx.medication in \"CNS Depressant Medications\"\n    else\n         List<FHIR.MedicationRequest>{}" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "4" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 9;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSREC11OrderSelect" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Benzodiazepine or CNS Depressant Prescriptions" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Benzodiazepine or CNS Depressant Prescriptions\":\n  Common.\"Is Benzodiazepine or CNS Depressant?\"( ContextPrescriptions )" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "5" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 10;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSREC11OrderSelect" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Patient Is Being Prescribed Benzodiazepine or CNS Depressant" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Patient Is Being Prescribed Benzodiazepine or CNS Depressant\":\n  exists( \"Benzodiazepine or CNS Depressant Prescriptions\" )" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "6" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 11;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Active Ambulatory Opioid Rx" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "7" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 12;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommonConfig" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Age Less than 18 Years Is Enabled" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// CDC 2022 General Inclusion Criteria\ndefine \"Age Less than 18 Years Is Enabled\":\n  true" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "8" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 13;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Patient Age Less Than 18" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "9" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 14;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommonConfig" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Sickle Cell Check Enabled" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// Sickle Cell\ndefine \"Sickle Cell Check Enabled\":\n  true" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "10" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 15;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommonConfig" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Sickle Cell Assumed Active" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Sickle Cell Assumed Active\":\n  true" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "11" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 16;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "US Core-Categorized Conditions" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// 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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "12" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 17;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Positive Sickle Cell Condition" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "13" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 18;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Condition Positive for Sickle Cell" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "14" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 19;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommonConfig" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Active Cancer Treatment Encounters Condition Is Enabled" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// Active Cancer Treatment\ndefine \"Active Cancer Treatment Encounters Condition Is Enabled\":\n  true" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "15" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 20;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Encounter Period" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// 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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "16" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 21;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "USCore Encounter Cancer Diagnoses" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"USCore Encounter Cancer Diagnoses\":\n  [Condition: category in \"Encounter Diagnosis Condition Category\"] CancerDiagnoses\n    where CancerDiagnoses.code in \"CDC malignant cancer conditions\"" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "17" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 22;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Encounters with Cancer Diagnosis During Encounter Period" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// 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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "18" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 23;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Number of Encounters with Cancer Diagnosis During Encounter Period" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Number of Encounters with Cancer Diagnosis During Encounter Period\":\n  Count (\"Encounters with Cancer Diagnosis During Encounter Period\")" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "19" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 24;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Has Two or More Encounters with Cancer Diagnosis During Encounter Period" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Has Two or More Encounters with Cancer Diagnosis During Encounter Period\":\n  \"Number of Encounters with Cancer Diagnosis During Encounter Period\" >= 2" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "20" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 25;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "USCore Problem List Cancer Diagnoses" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "21" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 26;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Has Active Cancer Diagnosis on Problem List" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "22" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 27;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Is Active Cancer Treatment?" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "23" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 28;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommonConfig" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "End-Stage Disease Criteria Enabled" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// CDC 2022 General Inclusion Criteria\ndefine \"End-Stage Disease Criteria Enabled\":\n  true" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "24" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 29;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Conditions Likely Terminal for Opioid Prescribing" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "25" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 30;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSRoutines" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "CDC 2022 Guideline General Inclusion Criteria" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "26" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 31;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSREC11OrderSelect" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Inclusion Criteria" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Inclusion Criteria\":\n  (\n    (\n      \"Patient Is Being Prescribed Opioid Analgesic with Ambulatory Misuse Potential\"\n        and exists Common.\"Active Ambulatory Benzodiazepine or CNS Depressant Rx\"\n    )\n      or (\n        \"Patient Is Being Prescribed Benzodiazepine or CNS Depressant\"\n          and exists Common.\"Active Ambulatory Opioid Rx\"\n      )\n  )\n    and Routines.\"CDC 2022 Guideline General Inclusion Criteria\"" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "27" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 32;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Conditions Indicating End of Life or With Limited Life Expectancy" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "28" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 33;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommonConfig" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Hospice Findings Exclusion Enabled" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "// OpioidCDSCommon\ndefine \"Hospice Findings Exclusion Enabled\":\n  false" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "29" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 34;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Admitted/Referred/Discharged to Hospice Care" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "30" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 35;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "End of Life Assessment" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "31" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 36;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSREC11OrderSelect" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Exclusion Criteria" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Exclusion Criteria\":\n  Common.\"End of Life Assessment\"" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "32" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 37;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSREC11OrderSelect" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Is Recommendation Applicable?" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define \"Is Recommendation Applicable?\":\n  \"Inclusion Criteria\"\n    and not \"Exclusion Criteria\"" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "33" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 38;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Is Opioid Analgesic with Ambulatory Misuse Potential?" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "34" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 39;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Get MedicationRequest Medication as Code" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "35" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 40;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "FHIRHelpers" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "ToString" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define function ToString(value string): value.value" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "36" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 41;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "FHIRHelpers" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "ToConcept" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "37" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 42;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "FHIRHelpers" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "ToCode" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "38" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 43;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "FHIRHelpers" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "ToDateTime" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define function ToDateTime(value dateTime): value.value" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "39" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 44;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Is Benzodiazepine or CNS Depressant?" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "define function \"Is Benzodiazepine or CNS Depressant?\"(value List<MedicationRequest>):\n  (\"Get MedicationRequest Medication as Code\"(value)) Rx\n    where Rx.medication in \"Benzodiazepine medications\"\n      or Rx.medication in \"CNS Depressant Medications\"\n      and Rx.category in \"Community\"" ]
     ], [
       fhir:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "40" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 45;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "libraryName" ];
       fhir:Extension.value [ fhir:value "OpioidCDSCommon" ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "name" ];
       fhir:Extension.value [ fhir:value "Get Active Ambulatory Medication Requests" ]
     ], [
       fhir:index 2;
       fhir:Extension.url [ fhir:value "statement" ];
       fhir:Extension.value [ fhir:value "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:index 3;
       fhir:Extension.url [ fhir:value "displaySequence" ];
       fhir:Extension.value [ fhir:value "41" ]
     ];
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition" ]
  ], [
     fhir:index 46;
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem" ];
     fhir:Extension.value [
       fhir:Reference.reference [ fhir:value "Device/cqf-tooling" ]
     ]
  ], [
     fhir:index 47;
     fhir:Extension.url [ fhir:value "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements" ];
     fhir:Extension.value [ fhir:value "#effective-data-requirements" ]
  ];
  fhir:PlanDefinition.url [ fhir:value "http://fhir.org/guides/cdc/opioid-cds/PlanDefinition/opioidcds-11-order-select"];
  fhir:PlanDefinition.identifier [
     fhir:index 0;
     fhir:Identifier.use [ fhir:value "official" ];
     fhir:Identifier.value [ fhir:value "cdc-opioid-guidance" ]
  ];
  fhir:PlanDefinition.version [ fhir:value "2022.1.0"];
  fhir:PlanDefinition.name [ fhir:value "PlanDefinition_Recommendation_11_Order_Select"];
  fhir:PlanDefinition.title [ fhir:value "Recommendation #11 - Concurrent Use of Opioids and Benzodiazepines (order-select)"];
  fhir:PlanDefinition.type [
     fhir:CodeableConcept.coding [
       fhir:index 0;
       fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/plan-definition-type" ];
       fhir:Coding.code [ fhir:value "eca-rule" ];
       fhir:Coding.display [ fhir:value "ECA Rule" ]
     ]
  ];
  fhir:PlanDefinition.status [ fhir:value "draft"];
  fhir:PlanDefinition.experimental [ fhir:value "true"];
  fhir:PlanDefinition.date [ fhir:value "2025-08-06"];
  fhir:PlanDefinition.publisher [ fhir:value "Centers for Disease Control and Prevention (CDC)"];
  fhir:PlanDefinition.contact [
     fhir:index 0;
     fhir:ContactDetail.telecom [
       fhir:index 0;
       fhir:ContactPoint.system [ fhir:value "url" ];
       fhir:ContactPoint.value [ fhir:value "https://www.cdc.gov" ]
     ]
  ];
  fhir:PlanDefinition.description [ fhir:value "Clinicians should use particular caution when prescribing opioid pain medication and benzodiazepines concurrently and consider whether benefits outweigh risks of concurrent prescribing of opioids and other central nervous system depressants."];
  fhir:PlanDefinition.useContext [
     fhir:index 0;
     fhir:UsageContext.code [
       fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/usage-context-type" ];
       fhir:Coding.code [ fhir:value "focus" ];
       fhir:Coding.display [ fhir:value "Clinical Focus" ]
     ];
     fhir:UsageContext.value [
       a sct:182888003;
       fhir:CodeableConcept.coding [
         fhir:index 0;
         a sct:182888003;
         fhir:Coding.system [ fhir:value "http://snomed.info/sct" ];
         fhir:Coding.code [ fhir:value "182888003" ];
         fhir:Coding.display [ fhir:value "Medication requested (situation)" ]
       ]
     ]
  ], [
     fhir:index 1;
     fhir:UsageContext.code [
       fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/usage-context-type" ];
       fhir:Coding.code [ fhir:value "focus" ];
       fhir:Coding.display [ fhir:value "Clinical Focus" ]
     ];
     fhir:UsageContext.value [
       a sct:82423001;
       fhir:CodeableConcept.coding [
         fhir:index 0;
         a sct:82423001;
         fhir:Coding.system [ fhir:value "http://snomed.info/sct" ];
         fhir:Coding.code [ fhir:value "82423001" ];
         fhir:Coding.display [ fhir:value "Chronic pain (finding)" ]
       ]
     ]
  ];
  fhir:PlanDefinition.jurisdiction [
     fhir:index 0;
     fhir:CodeableConcept.coding [ fhir:index 0 ]
  ];
  fhir:PlanDefinition.purpose [ fhir:value "The 2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain is intended to improve communication between clinicians and patients about the benefits and risks of pain treatments, including opioid therapy; improve the effectiveness and safety of pain treatment; mitigate pain; improve function and quality of life for patients with pain; and reduce risks associated with opioid pain therapy, including opioid use disorder, overdose, and death. The recommendations do not apply to pain related to sickle cell disease or cancer or to patients receiving palliative or end-of-life care."];
  fhir:PlanDefinition.usage [ fhir:value "Clinicians should use particular caution when prescribing opioid pain medication and benzodiazepines concurrently. In addition, clinicians should consider whether benefits outweigh risks for concurrent use of opioids with other central nervous system depressants."];
  fhir:PlanDefinition.copyright [ fhir:value "© CDC 2016+."];
  fhir:PlanDefinition.topic [
     fhir:index 0;
     fhir:CodeableConcept.text [ fhir:value "Opioid Prescribing" ]
  ];
  fhir:PlanDefinition.author [
     fhir:index 0;
     fhir:ContactDetail.name [ fhir:value "Kensaku Kawamoto, MD, PhD, MHS" ]
  ], [
     fhir:index 1;
     fhir:ContactDetail.name [ fhir:value "Bryn Rhodes" ]
  ], [
     fhir:index 2;
     fhir:ContactDetail.name [ fhir:value "Floyd Eisenberg, MD, MPH" ]
  ], [
     fhir:index 3;
     fhir:ContactDetail.name [ fhir:value "Robert McClure, MD, MPH" ]
  ];
  fhir:PlanDefinition.relatedArtifact [
     fhir:index 0;
     fhir:RelatedArtifact.type [ fhir:value "documentation" ];
     fhir:RelatedArtifact.display [ fhir:value "2022 CDC Clinical Practice Guideline for Prescribing Opioids for Pain" ];
     fhir:RelatedArtifact.url [ fhir:value "https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm" ];
     fhir:RelatedArtifact.document [
       fhir:Attachment.url [ fhir:value "https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm" ]
     ]
  ];
  fhir:PlanDefinition.library [
     fhir:value "http://fhir.org/guides/cdc/opioid-cds/Library/OpioidCDSREC11OrderSelect";
     fhir:index 0
  ];
  fhir:PlanDefinition.action [
     fhir:index 0;
     fhir:Element.extension [
       fhir:index 0;
       fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-strengthOfRecommendation" ];
       fhir:Extension.value [
         fhir:CodeableConcept.coding [
           fhir:index 0;
           fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/recommendation-strength" ];
           fhir:Coding.code [ fhir:value "weak" ];
           fhir:Coding.display [ fhir:value "Weak" ]
         ]
       ]
     ], [
       fhir:index 1;
       fhir:Extension.url [ fhir:value "http://hl7.org/fhir/StructureDefinition/cqf-qualityOfEvidence" ];
       fhir:Extension.value [
         fhir:CodeableConcept.coding [
           fhir:index 0;
           fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/evidence-quality" ];
           fhir:Coding.code [ fhir:value "low" ];
           fhir:Coding.display [ fhir:value "Low quality" ]
         ]
       ]
     ];
     fhir:PlanDefinition.title [ fhir:value "Use Particular Caution When Prescribing Opioid Pain Medication and Benzodiazepines or Other CNS Depressants Concurrently" ];
     fhir:PlanDefinition.description [ fhir:value "Consider whether the benefits outweigh the risks of concurrently prescribing opioids and benzodiazepines, or other central nervous system depressant medications.\r\n\r\nWhen co-prescribing risks outweigh benefits, consult [Recommendation 11 of the 2022 CDC Clinical Practice Guideline](https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm#:~:text=evidence%20type%3A%203).-,Implementation%20Considerations,-Although%20in%20some) for further guidance.\r\n\r\n[For patients being treated for opioid use disorder who are also taking benzodiazepines or other medications that depress the central nervous system, the CDC recommends not withholding buprenorphine or methadone](https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm#:~:text=gabapentin%20and%20pregabalin).-,Buprenorphine%20or%20methadone%20for%20opioid%20use%20disorder%20should%20not%20be%20withheld%20from%20patients%20taking%20benzodiazepines%20or%20other%20medications%20that%20depress%20the%20central%20nervous%20system.,-Clinicians%20should%20check).\r\n\r\nIf the decision is made to taper benzodiazepine medications, [the CDC recommends tapering benzodiazepines gradually prior to discontinuation](https://www.cdc.gov/mmwr/volumes/71/rr/rr7103a1.htm#:~:text=Clinicians%20should%20taper%20benzodiazepines%20gradually%20before%20discontinuation%20because%20abrupt%20withdrawal%20can%20be%20associated%20with%20rebound%20anxiety%2C%20hallucinations%2C%20seizures%2C%20delirium%20tremens%2C%20and%2C%20rarely%2C%20death.%20The%20rate%20of%20tapering%20should%20be%20individualized)." ];
     fhir:PlanDefinition.priority [ fhir:value "urgent" ];
     fhir:PlanDefinition.trigger [
       fhir:index 0;
       fhir:TriggerDefinition.type [ fhir:value "named-event" ];
       fhir:TriggerDefinition.name [ fhir:value "order-select" ]
     ];
     fhir:PlanDefinition.condition [
       fhir:index 0;
       fhir:PlanDefinition.kind [ fhir:value "applicability" ];
       fhir:PlanDefinition.expression [
         fhir:Expression.description [ fhir:value "Check whether the current order results in the concurrent use of opioid pain medication and benzodiazepines or other central nervous system depressants and if the 2022 CDC guideline general inclusion criteria is met." ];
         fhir:Expression.language [ fhir:value "text/cql.identifier" ];
         fhir:Expression.expression [ fhir:value "Is Recommendation Applicable?" ]
       ]
     ];
     fhir:PlanDefinition.groupingBehavior [ fhir:value "visual-group" ];
     fhir:PlanDefinition.selectionBehavior [ fhir:value "any" ];
     fhir:PlanDefinition.action [
       fhir:index 0;
       fhir:PlanDefinition.description [ fhir:value "Document - Will modify prescription" ]
     ], [
       fhir:index 1;
       fhir:PlanDefinition.description [ fhir:value "Snooze* - Benefits outweigh risks, snooze 3 months" ]
     ], [
       fhir:index 2;
       fhir:PlanDefinition.description [ fhir:value "Snooze* - N/A see comments, snooze 3 months" ]
     ]
  ] .

# -------------------------------------------------------------------------------------

