This page is part of the FHIR Specification (v4.3.0-snapshot1: Release 4B Snapshot #1). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B R4
Clinical Decision Support Work Group | Maturity Level: N/A | Standards Status: Informative | Compartments: Not linked to any defined compartments |
This is the narrative for the resource. See also the XML, JSON or Turtle format. This example conforms to the profile Library.
Author | Kensaku Kawamoto, MD, PhD, MHS |
Author | Bryn Rhodes |
Author | Floyd Eisenberg, MD, MPH |
Author | Robert McClure, MD, MPH |
Documentation | CDC guideline for prescribing opioids for chronic pain | https://guidelines.gov/summaries/summary/50153/cdc-guideline-for-prescribing-opioids-for-chronic-pain---united-states-2016#420 |
Depends On | http://example.org/fhir/Library/omtk-logic | |
Documentation | MME Conversion Tables | https://www.cdc.gov/drugoverdose/pdf/calculating_total_daily_dose-a.pdf |
application/elm+xml
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns="urn:hl7-org:elm:r1" xmlns:t="urn:hl7-org:elm-types:r1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fhir="http://hl7.org/fhir" xmlns:qdm43="urn:healthit-gov:qdm:v4_3" xmlns:qdm53="urn:healthit-gov:qdm:v5_3" xmlns:a="urn:hl7-org:cql-annotations:r1">
<identifier id="OpioidCDS_STU4_Common" version="0.1.0"/>
<schemaIdentifier id="urn:hl7-org:elm" version="r1"/>
<usings>
<def localIdentifier="System" uri="urn:hl7-org:elm-types:r1"/>
<def localIdentifier="FHIR" uri="http://hl7.org/fhir" version="3.2.0"/>
</usings>
<includes>
<def localIdentifier="OMTKLogic" path="OMTKLogic" version="0.1.0"/>
</includes>
<valueSets>
<def name="Benzodiazepines" id="benzodiazepines" accessLevel="Public"/>
<def name="Naloxone" id="naloxone" accessLevel="Public"/>
<def name="Ambulatory Abuse Potential Opioids" id="opioids-abused-in-ambulatory-care" accessLevel="Public"/>
<def name="End Of Life Opioids" id="opioids-indicating-end-of-life" accessLevel="Public"/>
<def name="Long Acting Opioids" id="long-acting-opioids" accessLevel="Public"/>
<def name="Illicit Drug Screening" id="illicit-drug-urine-screening" accessLevel="Public"/>
<def name="Opioid Drug Screening" id="opioid-urine-screening" accessLevel="Public"/>
<def name="Opioids" id="opioids" accessLevel="Public"/>
<def name="Codeine Cough Meds" id="opioids-codeine-cough-meds" accessLevel="Public"/>
<def name="Short Acting Opioids" id="short-acting-opioids" accessLevel="Public"/>
</valueSets>
<statements>
<def name="IsForChronicPain" context="Patient" accessLevel="Public">
<expression valueType="t:Boolean" value="true" xsi:type="Literal"/>
</def>
<def name="HasMetastaticCancer" context="Patient" accessLevel="Public">
<expression valueType="t:Boolean" value="false" xsi:type="Literal"/>
</def>
<def name="ToCode" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression classType="t:Code" xsi:type="Instance">
<element name="code">
<value path="value" xsi:type="Property">
<source path="code" xsi:type="Property">
<source name="coding" xsi:type="OperandRef"/>
</source>
</value>
</element>
<element name="system">
<value path="value" xsi:type="Property">
<source path="system" xsi:type="Property">
<source name="coding" xsi:type="OperandRef"/>
</source>
</value>
</element>
<element name="version">
<value path="value" xsi:type="Property">
<source path="version" xsi:type="Property">
<source name="coding" xsi:type="OperandRef"/>
</source>
</value>
</element>
<element name="display">
<value path="value" xsi:type="Property">
<source path="display" xsi:type="Property">
<source name="coding" xsi:type="OperandRef"/>
</source>
</value>
</element>
</expression>
<operand name="coding">
<operandTypeSpecifier name="fhir:Coding" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="ToQuantity" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression classType="t:Quantity" xsi:type="Instance">
<element name="value">
<value path="value" xsi:type="Property">
<source path="value" xsi:type="Property">
<source name="quantity" xsi:type="OperandRef"/>
</source>
</value>
</element>
<element name="unit">
<value path="value" xsi:type="Property">
<source path="unit" xsi:type="Property">
<source name="quantity" xsi:type="OperandRef"/>
</source>
</value>
</element>
</expression>
<operand name="quantity">
<operandTypeSpecifier name="fhir:Quantity" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="Prescriptions" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="Query">
<source alias="O">
<expression name="Orders" xsi:type="OperandRef"/>
</source>
<let identifier="rxNormCode">
<expression name="ToCode" xsi:type="FunctionRef">
<operand xsi:type="Indexer">
<operand path="coding" xsi:type="Property">
<source path="medication" scope="O" xsi:type="Property"/>
</operand>
<operand valueType="t:Integer" value="0" xsi:type="Literal"/>
</operand>
</expression>
</let>
<let identifier="medicationName">
<expression name="GetMedicationName" libraryName="OMTKLogic" xsi:type="FunctionRef">
<operand name="rxNormCode" xsi:type="QueryLetRef"/>
</expression>
</let>
<let identifier="dosageInstruction">
<expression xsi:type="Indexer">
<operand path="dosageInstruction" scope="O" xsi:type="Property"/>
<operand valueType="t:Integer" value="0" xsi:type="Literal"/>
</expression>
</let>
<let identifier="repeat">
<expression path="repeat" xsi:type="Property">
<source path="timing" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</expression>
</let>
<let identifier="frequency">
<expression xsi:type="Coalesce">
<operand path="value" xsi:type="Property">
<source path="frequencyMax" xsi:type="Property">
<source name="repeat" xsi:type="QueryLetRef"/>
</source>
</operand>
<operand path="value" xsi:type="Property">
<source path="frequency" xsi:type="Property">
<source name="repeat" xsi:type="QueryLetRef"/>
</source>
</operand>
</expression>
</let>
<let identifier="period">
<expression classType="t:Quantity" xsi:type="Instance">
<element name="value">
<value path="value" xsi:type="Property">
<source path="period" xsi:type="Property">
<source name="repeat" xsi:type="QueryLetRef"/>
</source>
</value>
</element>
<element name="unit">
<value path="value" xsi:type="Property">
<source path="periodUnit" xsi:type="Property">
<source name="repeat" xsi:type="QueryLetRef"/>
</source>
</value>
</element>
</expression>
</let>
<let identifier="doseDescription">
<expression xsi:type="Coalesce">
<operand xsi:type="ToList">
<operand xsi:type="If">
<condition asType="t:Boolean" xsi:type="As">
<operand xsi:type="Is">
<operand path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</operand>
<isTypeSpecifier name="fhir:Range" xsi:type="NamedTypeSpecifier"/>
</operand>
</condition>
<then xsi:type="Concatenate">
<operand xsi:type="Concatenate">
<operand xsi:type="Concatenate">
<operand xsi:type="ToString">
<operand name="ToQuantity" xsi:type="FunctionRef">
<operand path="low" xsi:type="Property">
<source path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</operand>
</operand>
</operand>
<operand valueType="t:String" value="-" xsi:type="Literal"/>
</operand>
<operand xsi:type="ToString">
<operand name="ToQuantity" xsi:type="FunctionRef">
<operand path="high" xsi:type="Property">
<source path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</operand>
</operand>
</operand>
</operand>
<operand path="value" xsi:type="Property">
<source path="unit" xsi:type="Property">
<source path="high" xsi:type="Property">
<source path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</source>
</source>
</operand>
</then>
<else xsi:type="ToString">
<operand name="ToQuantity" xsi:type="FunctionRef">
<operand asType="fhir:Quantity" xsi:type="As">
<operand path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</operand>
</operand>
</operand>
</else>
</operand>
</operand>
</expression>
</let>
<let identifier="frequencyDescription">
<expression xsi:type="Concatenate">
<operand xsi:type="ToString">
<operand path="value" xsi:type="Property">
<source path="frequency" xsi:type="Property">
<source path="repeat" xsi:type="Property">
<source path="timing" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</source>
</source>
</operand>
</operand>
<operand xsi:type="Coalesce">
<operand xsi:type="Concatenate">
<operand valueType="t:String" value="-" xsi:type="Literal"/>
<operand xsi:type="ToString">
<operand path="value" xsi:type="Property">
<source path="frequencyMax" xsi:type="Property">
<source path="repeat" xsi:type="Property">
<source path="timing" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</source>
</source>
</operand>
</operand>
</operand>
<operand valueType="t:String" value="" xsi:type="Literal"/>
</operand>
</expression>
</let>
<return>
<expression xsi:type="Tuple">
<element name="rxNormCode">
<value name="rxNormCode" xsi:type="QueryLetRef"/>
</element>
<element name="isDraft">
<value xsi:type="Equal">
<operand path="value" xsi:type="Property">
<source path="status" scope="O" xsi:type="Property"/>
</operand>
<operand valueType="t:String" value="draft" xsi:type="Literal"/>
</value>
</element>
<element name="isPRN">
<value path="value" xsi:type="Property">
<source path="asNeeded" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</value>
</element>
<element name="prescription">
<value xsi:type="If">
<condition asType="t:Boolean" xsi:type="As">
<operand xsi:type="Not">
<operand xsi:type="IsNull">
<operand path="text" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</operand>
</operand>
</operand>
</condition>
<then xsi:type="Concatenate">
<operand xsi:type="Concatenate">
<operand name="medicationName" xsi:type="QueryLetRef"/>
<operand valueType="t:String" value=" " xsi:type="Literal"/>
</operand>
<operand path="value" xsi:type="Property">
<source path="text" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</operand>
</then>
<else xsi:type="Concatenate">
<operand xsi:type="Concatenate">
<operand xsi:type="Concatenate">
<operand xsi:type="Concatenate">
<operand xsi:type="Concatenate">
<operand name="medicationName" xsi:type="QueryLetRef"/>
<operand valueType="t:String" value=" " xsi:type="Literal"/>
</operand>
<operand name="doseDescription" xsi:type="QueryLetRef"/>
</operand>
<operand valueType="t:String" value=" q" xsi:type="Literal"/>
</operand>
<operand name="frequencyDescription" xsi:type="QueryLetRef"/>
</operand>
<operand xsi:type="If">
<condition asType="t:Boolean" xsi:type="As">
<operand path="value" xsi:type="Property">
<source path="asNeeded" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</operand>
</condition>
<then valueType="t:String" value=" PRN" xsi:type="Literal"/>
<else valueType="t:String" value="" xsi:type="Literal"/>
</operand>
</else>
</value>
</element>
<element name="dose">
<value xsi:type="If">
<condition asType="t:Boolean" xsi:type="As">
<operand xsi:type="Is">
<operand path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</operand>
<isTypeSpecifier name="fhir:Range" xsi:type="NamedTypeSpecifier"/>
</operand>
</condition>
<then name="ToQuantity" xsi:type="FunctionRef">
<operand path="high" xsi:type="Property">
<source path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</source>
</operand>
</then>
<else name="ToQuantity" xsi:type="FunctionRef">
<operand asType="fhir:Quantity" xsi:type="As">
<operand path="dose" xsi:type="Property">
<source name="dosageInstruction" xsi:type="QueryLetRef"/>
</operand>
</operand>
</else>
</value>
</element>
<element name="dosesPerDay">
<value xsi:type="Coalesce">
<operand name="ToDaily" libraryName="OMTKLogic" xsi:type="FunctionRef">
<operand name="frequency" xsi:type="QueryLetRef"/>
<operand name="period" xsi:type="QueryLetRef"/>
</operand>
<operand valueType="t:Decimal" value="1.0" xsi:type="Literal"/>
</value>
</element>
</expression>
</return>
</expression>
<operand name="Orders">
<operandTypeSpecifier xsi:type="ListTypeSpecifier">
<elementType name="fhir:MedicationRequest" xsi:type="NamedTypeSpecifier"/>
</operandTypeSpecifier>
</operand>
</def>
<def name="MME" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="Query">
<source alias="P">
<expression name="Prescriptions" xsi:type="FunctionRef">
<operand name="prescriptions" xsi:type="OperandRef"/>
</expression>
</source>
<let identifier="mme">
<expression xsi:type="SingletonFrom">
<operand name="CalculateMMEs" libraryName="OMTKLogic" xsi:type="FunctionRef">
<operand xsi:type="List">
<element xsi:type="Tuple">
<element name="rxNormCode">
<value path="rxNormCode" scope="P" xsi:type="Property"/>
</element>
<element name="doseQuantity">
<value path="dose" scope="P" xsi:type="Property"/>
</element>
<element name="dosesPerDay">
<value path="dosesPerDay" scope="P" xsi:type="Property"/>
</element>
</element>
</operand>
</operand>
</expression>
</let>
<return>
<expression xsi:type="Tuple">
<element name="rxNormCode">
<value path="rxNormCode" scope="P" xsi:type="Property"/>
</element>
<element name="isDraft">
<value path="isDraft" scope="P" xsi:type="Property"/>
</element>
<element name="isPRN">
<value path="isPRN" scope="P" xsi:type="Property"/>
</element>
<element name="prescription">
<value path="prescription" scope="P" xsi:type="Property"/>
</element>
<element name="dailyDose">
<value path="dailyDoseDescription" xsi:type="Property">
<source name="mme" xsi:type="QueryLetRef"/>
</value>
</element>
<element name="conversionFactor">
<value path="conversionFactor" xsi:type="Property">
<source name="mme" xsi:type="QueryLetRef"/>
</value>
</element>
<element name="mme">
<value path="mme" xsi:type="Property">
<source name="mme" xsi:type="QueryLetRef"/>
</value>
</element>
</expression>
</return>
</expression>
<operand name="prescriptions">
<operandTypeSpecifier xsi:type="ListTypeSpecifier">
<elementType name="fhir:MedicationRequest" xsi:type="NamedTypeSpecifier"/>
</operandTypeSpecifier>
</operand>
</def>
<def name="TotalMME" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression classType="t:Quantity" xsi:type="Instance">
<element name="value">
<value xsi:type="Sum">
<source xsi:type="Query">
<source alias="M">
<expression name="MME" xsi:type="FunctionRef">
<operand name="prescriptions" xsi:type="OperandRef"/>
</expression>
</source>
<return>
<expression path="value" xsi:type="Property">
<source path="mme" scope="M" xsi:type="Property"/>
</expression>
</return>
</source>
</value>
</element>
<element name="unit">
<value valueType="t:String" value="mg/d" xsi:type="Literal"/>
</element>
</expression>
<operand name="prescriptions">
<operandTypeSpecifier xsi:type="ListTypeSpecifier">
<elementType name="fhir:MedicationRequest" xsi:type="NamedTypeSpecifier"/>
</operandTypeSpecifier>
</operand>
</def>
<def name="GetPeriodDays" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="Case">
<caseItem>
<when xsi:type="StartsWith">
<operand name="value" xsi:type="OperandRef"/>
<operand valueType="t:String" value="year" xsi:type="Literal"/>
</when>
<then valueType="t:Decimal" value="365.0" xsi:type="Literal"/>
</caseItem>
<caseItem>
<when xsi:type="StartsWith">
<operand name="value" xsi:type="OperandRef"/>
<operand valueType="t:String" value="month" xsi:type="Literal"/>
</when>
<then valueType="t:Decimal" value="30.0" xsi:type="Literal"/>
</caseItem>
<caseItem>
<when xsi:type="StartsWith">
<operand name="value" xsi:type="OperandRef"/>
<operand valueType="t:String" value="hour" xsi:type="Literal"/>
</when>
<then xsi:type="Divide">
<operand valueType="t:Decimal" value="1.0" xsi:type="Literal"/>
<operand valueType="t:Decimal" value="24.0" xsi:type="Literal"/>
</then>
</caseItem>
<caseItem>
<when xsi:type="StartsWith">
<operand name="value" xsi:type="OperandRef"/>
<operand valueType="t:String" value="minute" xsi:type="Literal"/>
</when>
<then xsi:type="Multiply">
<operand xsi:type="Divide">
<operand valueType="t:Decimal" value="1.0" xsi:type="Literal"/>
<operand valueType="t:Decimal" value="24.0" xsi:type="Literal"/>
</operand>
<operand valueType="t:Decimal" value="60.0" xsi:type="Literal"/>
</then>
</caseItem>
<else valueType="t:Decimal" value="1.0" xsi:type="Literal"/>
</expression>
<operand name="value">
<operandTypeSpecifier name="t:String" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="GetDurationInDays" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="Case">
<caseItem>
<when xsi:type="StartsWith">
<operand path="value" xsi:type="Property">
<source path="unit" xsi:type="Property">
<source name="value" xsi:type="OperandRef"/>
</source>
</operand>
<operand valueType="t:String" value="year" xsi:type="Literal"/>
</when>
<then xsi:type="Multiply">
<operand path="value" xsi:type="Property">
<source path="value" xsi:type="Property">
<source name="value" xsi:type="OperandRef"/>
</source>
</operand>
<operand valueType="t:Decimal" value="365.0" xsi:type="Literal"/>
</then>
</caseItem>
<caseItem>
<when xsi:type="StartsWith">
<operand path="value" xsi:type="Property">
<source path="unit" xsi:type="Property">
<source name="value" xsi:type="OperandRef"/>
</source>
</operand>
<operand valueType="t:String" value="month" xsi:type="Literal"/>
</when>
<then xsi:type="Multiply">
<operand path="value" xsi:type="Property">
<source path="value" xsi:type="Property">
<source name="value" xsi:type="OperandRef"/>
</source>
</operand>
<operand valueType="t:Decimal" value="30.0" xsi:type="Literal"/>
</then>
</caseItem>
<else path="value" xsi:type="Property">
<source path="value" xsi:type="Property">
<source name="value" xsi:type="OperandRef"/>
</source>
</else>
</expression>
<operand name="value">
<operandTypeSpecifier name="fhir:Duration" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="ProbableDaysInRange" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="Query">
<source alias="orders">
<expression name="Orders" xsi:type="OperandRef"/>
</source>
<let identifier="frequency">
<expression path="value" xsi:type="Property">
<source path="frequency" xsi:type="Property">
<source path="repeat" xsi:type="Property">
<source path="timing" xsi:type="Property">
<source xsi:type="Indexer">
<operand path="dosageInstruction" scope="orders" xsi:type="Property"/>
<operand valueType="t:Integer" value="0" xsi:type="Literal"/>
</source>
</source>
</source>
</source>
</expression>
</let>
<let identifier="period">
<expression path="value" xsi:type="Property">
<source path="period" xsi:type="Property">
<source path="repeat" xsi:type="Property">
<source path="timing" xsi:type="Property">
<source xsi:type="Indexer">
<operand path="dosageInstruction" scope="orders" xsi:type="Property"/>
<operand valueType="t:Integer" value="0" xsi:type="Literal"/>
</source>
</source>
</source>
</source>
</expression>
</let>
<let identifier="periodDays">
<expression name="GetPeriodDays" xsi:type="FunctionRef">
<operand path="value" xsi:type="Property">
<source path="periodUnit" xsi:type="Property">
<source path="repeat" xsi:type="Property">
<source path="timing" xsi:type="Property">
<source xsi:type="Indexer">
<operand path="dosageInstruction" scope="orders" xsi:type="Property"/>
<operand valueType="t:Integer" value="0" xsi:type="Literal"/>
</source>
</source>
</source>
</source>
</operand>
</expression>
</let>
<let identifier="dosesPerDay">
<expression xsi:type="If">
<condition asType="t:Boolean" xsi:type="As">
<operand xsi:type="GreaterOrEqual">
<operand xsi:type="Divide">
<operand xsi:type="ToDecimal">
<operand name="frequency" xsi:type="QueryLetRef"/>
</operand>
<operand xsi:type="Multiply">
<operand name="period" xsi:type="QueryLetRef"/>
<operand name="periodDays" xsi:type="QueryLetRef"/>
</operand>
</operand>
<operand valueType="t:Decimal" value="1.0" xsi:type="Literal"/>
</operand>
</condition>
<then valueType="t:Decimal" value="1.0" xsi:type="Literal"/>
<else xsi:type="Divide">
<operand xsi:type="ToDecimal">
<operand name="frequency" xsi:type="QueryLetRef"/>
</operand>
<operand xsi:type="Multiply">
<operand name="period" xsi:type="QueryLetRef"/>
<operand name="periodDays" xsi:type="QueryLetRef"/>
</operand>
</else>
</expression>
</let>
<let identifier="repeat">
<expression path="value" xsi:type="Property">
<source path="numberOfRepeatsAllowed" xsi:type="Property">
<source path="dispenseRequest" scope="orders" xsi:type="Property"/>
</source>
</expression>
</let>
<let identifier="supplyDuration">
<expression name="GetDurationInDays" xsi:type="FunctionRef">
<operand path="expectedSupplyDuration" xsi:type="Property">
<source path="dispenseRequest" scope="orders" xsi:type="Property"/>
</operand>
</expression>
</let>
<let identifier="validityPeriod">
<expression precision="Day" xsi:type="DurationBetween">
<operand path="value" xsi:type="Property">
<source path="start" xsi:type="Property">
<source path="validityPeriod" xsi:type="Property">
<source path="dispenseRequest" scope="orders" xsi:type="Property"/>
</source>
</source>
</operand>
<operand xsi:type="Today"/>
</expression>
</let>
<let identifier="endDifference">
<expression xsi:type="If">
<condition asType="t:Boolean" xsi:type="As">
<operand xsi:type="Less">
<operand path="value" xsi:type="Property">
<source path="end" xsi:type="Property">
<source path="validityPeriod" xsi:type="Property">
<source path="dispenseRequest" scope="orders" xsi:type="Property"/>
</source>
</source>
</operand>
<operand xsi:type="Today"/>
</operand>
</condition>
<then precision="Day" xsi:type="DurationBetween">
<operand path="value" xsi:type="Property">
<source path="end" xsi:type="Property">
<source path="validityPeriod" xsi:type="Property">
<source path="dispenseRequest" scope="orders" xsi:type="Property"/>
</source>
</source>
</operand>
<operand xsi:type="Today"/>
</then>
<else valueType="t:Integer" value="0" xsi:type="Literal"/>
</expression>
</let>
<return>
<expression xsi:type="GreaterOrEqual">
<operand xsi:type="Multiply">
<operand xsi:type="Multiply">
<operand name="dosesPerDay" xsi:type="QueryLetRef"/>
<operand xsi:type="Divide">
<operand xsi:type="Multiply">
<operand xsi:type="ToDecimal">
<operand name="repeat" xsi:type="QueryLetRef"/>
</operand>
<operand name="supplyDuration" xsi:type="QueryLetRef"/>
</operand>
<operand xsi:type="ToDecimal">
<operand name="validityPeriod" xsi:type="QueryLetRef"/>
</operand>
</operand>
</operand>
<operand xsi:type="ToDecimal">
<operand xsi:type="Subtract">
<operand name="daysPast" xsi:type="OperandRef"/>
<operand name="endDifference" xsi:type="QueryLetRef"/>
</operand>
</operand>
</operand>
<operand xsi:type="ToDecimal">
<operand name="numDaysInDaysPast" xsi:type="OperandRef"/>
</operand>
</expression>
</return>
</expression>
<operand name="Orders">
<operandTypeSpecifier xsi:type="ListTypeSpecifier">
<elementType name="fhir:MedicationRequest" xsi:type="NamedTypeSpecifier"/>
</operandTypeSpecifier>
</operand>
<operand name="daysPast">
<operandTypeSpecifier name="t:Integer" xsi:type="NamedTypeSpecifier"/>
</operand>
<operand name="numDaysInDaysPast">
<operandTypeSpecifier name="t:Integer" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="IsNaloxone" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="InValueSet">
<code name="rxNormCode" xsi:type="OperandRef"/>
<valueset name="Naloxone"/>
</expression>
<operand name="rxNormCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="IsBenzodiazepine" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="InValueSet">
<code name="rxNormCode" xsi:type="OperandRef"/>
<valueset name="Benzodiazepines"/>
</expression>
<operand name="rxNormCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="IsOpioidWithAmbulatoryAbusePotential" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="InValueSet">
<code name="rxNormCode" xsi:type="OperandRef"/>
<valueset name="Ambulatory Abuse Potential Opioids"/>
</expression>
<operand name="rxNormCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="IsLongActingOpioid" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="InValueSet">
<code name="rxNormCode" xsi:type="OperandRef"/>
<valueset name="Long Acting Opioids"/>
</expression>
<operand name="rxNormCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="IsEndOfLifeOpioid" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="InValueSet">
<code name="rxNormCode" xsi:type="OperandRef"/>
<valueset name="End Of Life Opioids"/>
</expression>
<operand name="rxNormCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="IsOpioidDrugScreen" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="InValueSet">
<code name="observationCode" xsi:type="OperandRef"/>
<valueset name="Opioid Drug Screening"/>
</expression>
<operand name="observationCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="IsIllicitDrugScreen" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="InValueSet">
<code name="observationCode" xsi:type="OperandRef"/>
<valueset name="Illicit Drug Screening"/>
</expression>
<operand name="observationCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
<def name="GetIngredient" context="Patient" accessLevel="Public" xsi:type="FunctionDef">
<expression xsi:type="Query">
<source alias="$this">
<expression name="GetIngredients" libraryName="OMTKLogic" xsi:type="FunctionRef">
<operand name="rxNormCode" xsi:type="OperandRef"/>
</expression>
</source>
<where xsi:type="Not">
<operand xsi:type="IsNull">
<operand path="ingredientName" xsi:type="Property">
<source name="$this" xsi:type="AliasRef"/>
</operand>
</operand>
</where>
<return>
<expression path="ingredientName" xsi:type="Property">
<source name="$this" xsi:type="AliasRef"/>
</expression>
</return>
</expression>
<operand name="rxNormCode">
<operandTypeSpecifier name="t:Code" xsi:type="NamedTypeSpecifier"/>
</operand>
</def>
</statements>
</library>
Usage note: every effort has been made to ensure that the examples are correct and useful, but they are not a normative part of the specification.