Potential Drug-Drug Interaction (PDDI) Clinical Decision Support
1.0.0 - STU 1 International flag

Potential Drug-Drug Interaction (PDDI) Clinical Decision Support, published by HL7 International / Clinical Decision Support. This guide is not an authorized publication; it is the continuous build for version 1.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/PDDI-CDS/ and changes regularly. See the Directory of published versions

PlanDefinition: Digoxin Cyclosporine Order Sign Recommendation (Experimental)

Official URL: http://hl7.org/fhir/uv/pddi/PlanDefinition/digoxin-cyclosporine-cds-sign Version: 1.0.0
Standards status: Informative Computable Name: DigoxinCyclosporineOrderSignRecommendation

Drug-drug interaction recommendation for use on order sign of a digoxin or cyclosporine

Metadata
Title Digoxin Cyclosporine Order Sign Recommendation
Version 1.0.0
Experimental true
Jurisdiction 001 from http://unstats.un.org/unsd/methods/m49/m49.htm
Topic Digoxin Cyclosporine Prescribing
Steward (Publisher) HL7 International / Clinical Decision Support
Description

Drug-drug interaction recommendation for use on order sign of a digoxin or cyclosporine

Type ECA Rule
PlanDefinition Action
Trigger Type Named Event
Trigger Name order-sign
Condition Kind: Applicability
Logic Definition: Inclusion Criteria
PlanDefinition Sub-Action
Title Potential Drug-Drug Interaction between digoxin (product) and cyclosporine (product)
Description Increased risk of digoxin toxicity. Assess risk and take action if necessary. Digoxin toxicity is potentially serious. The clinical consequences may include anorexia, nausea, vomiting, visual changes, and cardiac arrhythmias. The mechanism of this interaction appears to be mediated through P-glycoprotein inhibition by cyclosporine. P-glycoprotein is a major transporter for digoxin efflux. unknown. unknown.
Dynamic Value Path: action.title
Logic Definition: Get Base Summary
Dynamic Value Path: action.description
Logic Definition: Get Base Detail
Dynamic Value Path: activity.extension
Logic Definition: Get Base Indicator
PlanDefinition Sub-Action (Parent Action Title: Potential Drug-Drug Interaction between digoxin (product) and cyclosporine (product))
Title Consultation
Description Request communication with digoxin prescriber
Condition Kind: Applicability
Logic Definition: Is Context medication digoxin
Type create from http://terminology.hl7.org/CodeSystem/action-type
Definition ActivityDefinition AD201
PlanDefinition Sub-Action (Parent Action Title: Potential Drug-Drug Interaction between digoxin (product) and cyclosporine (product))
Title Consultation
Description Request communication with cyclosporine prescriber
Condition Kind: Applicability
Logic Definition: Is Context medication cyclosporine
Type create from http://terminology.hl7.org/CodeSystem/action-type
Definition ActivityDefinition AD202
PlanDefinition Sub-Action (Parent Action Title: Potential Drug-Drug Interaction between digoxin (product) and cyclosporine (product))
Title Cancel digoxin
Description Discontinue digoxin order
Condition Kind: Applicability
Logic Definition: Is Context medication digoxin
Type remove from http://terminology.hl7.org/CodeSystem/action-type
PlanDefinition Sub-Action (Parent Action Title: Potential Drug-Drug Interaction between digoxin (product) and cyclosporine (product))
Title Cancel cyclosporine
Description Discontinue cyclosporine order
Condition Kind: Applicability
Logic Definition: Is Context medication cyclosporine
Type remove from http://terminology.hl7.org/CodeSystem/action-type
PlanDefinition Sub-Action (Parent Action Title: Potential Drug-Drug Interaction between digoxin (product) and cyclosporine (product))
Title Digoxin Level
Description Order digoxin trough within 24 hours from initiation
Condition Kind: Applicability
Logic Definition: Is new order for digoxin
Type create from http://terminology.hl7.org/CodeSystem/action-type
Definition ActivityDefinition AD203
PlanDefinition Sub-Action
Title Patient does (not) have digoxin level within 30 days that is below 0.9 ng/mL (SI: 1.2 nmol/L)
Description (Digoxin: level and date). For patients with a reliable plasma digoxin concentration in normal range, it is reasonable to anticipate an increase in plasma concentrations after the initiation of cyclosporine. Following initiation, close monitoring and adjusting the digoxin dose as needed is recommended. Initiating cyclosporine is expected to increase digoxin levels. For patients without a reliable plasma digoxin concentration in normal range, use only if benefits outweight risks. Extreme caution and close monitoring is necessary.
Condition Kind: Applicability
Logic Definition: Is digoxin in prefetch
Dynamic Value Path: action.title
Logic Definition: Get Card 2 Summary
Dynamic Value Path: action.description
Logic Definition: Get Card 2 Detail
Dynamic Value Path: activity.extension
Logic Definition: Get Card 2 Indicator
PlanDefinition Sub-Action (Parent Action Title: Patient does (not) have digoxin level within 30 days that is below 0.9 ng/mL (SI: 1.2 nmol/L))
Title Digoxin Level
Description Order digoxin trough within 24 hours from the initiation of cyclosporine
Type create from http://terminology.hl7.org/CodeSystem/action-type
Definition ActivityDefinition AD203
PlanDefinition Sub-Action (Parent Action Title: Patient does (not) have digoxin level within 30 days that is below 0.9 ng/mL (SI: 1.2 nmol/L))
Title New Digoxin
Description Preemptively reduce digoxin dose with new order
Condition Kind: Applicability
Logic Definition: Need to reduce Digoxin dose
Type create from http://terminology.hl7.org/CodeSystem/action-type
Definition ActivityDefinition AD204
PlanDefinition Sub-Action
Title Within 100 days, the patient has had electrolyte and serum creatinine levels checked, and they are not on a potassium sparing or loop diuretic.
Description (Potassium: level and date) (Magnesium: level and date) (Calcium: level and date) (Serum creatinine: level and date) Hypokalemia, hypomagnesemia, and hypercalcemia may potentiate digoxin toxicity. 50-70% of digoxin is excreted unchanged in the urine. Changing renal function may increase serum concentrations and risk of toxicity.
Dynamic Value Path: action.title
Logic Definition: Get Card 3 Summary
Dynamic Value Path: action.description
Logic Definition: Get Card 3 Detail
Dynamic Value Path: activity.extension
Logic Definition: Get Card 3 Indicator
PlanDefinition Sub-Action (Parent Action Title: Within 100 days, the patient has had electrolyte and serum creatinine levels checked, and they are not on a potassium sparing or loop diuretic.)
Title Serum Creatinine
Description Order for serum creatinine
Type create from http://terminology.hl7.org/CodeSystem/action-type
Definition ActivityDefinition AD205
PlanDefinition Sub-Action (Parent Action Title: Within 100 days, the patient has had electrolyte and serum creatinine levels checked, and they are not on a potassium sparing or loop diuretic.)
Title Electrolyte Panel
Description Order for electrolyte panel
Type create from http://terminology.hl7.org/CodeSystem/action-type
Definition ActivityDefinition AD206
PlanDefinition Logic
Primary Library Digoxin-cyclosporine CDS Logic
Dependency Description: FHIR model information
Resource: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Library FHIRCommon
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Dependency Description: Library Common
Resource: Potential Drug-Durg Interaction (PDDI) Clinical Decision Support (CDS) Common Logic version: 1.0.0
Canonical URL: http://hl7.org/fhir/uv/pddi/Library/PDDICDSCommon|1.0.0
Dependency Description: Value set Digoxin
Resource: Digoxin Medications Value Set
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-digoxin
Dependency Description: Value set Cyclosporine
Resource: Cyclosporine Medications Value Set
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-cyclosporine
Dependency Description: Value set Digoxin LOINC
Resource: LOINC Codes for Digoxin Concentration
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-digoxin-LOINC
Dependency Description: Value set Aldosterone Antagonists
Resource: Aldosterone Antagonists Drug Value Set
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-AAS
Dependency Description: Value set Loop Diuretics
Resource: Loop Diuretic Drug Value Set
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-LOOPDIURETIC
Dependency Description: Value set Potassium LOINC
Resource: LOINC Codes for Serum Potassium
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-potassium-LOINC
Dependency Description: Value set Magnesium LOINC
Resource: LOINC Codes for Serum Potassium
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-magnesium-LOINC
Dependency Description: Value set Calcium LOINC
Resource: LOINC Codes for Serum Calcium
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-calcium-LOINC
Dependency Description: Value set Renal LOINC
Resource: LOINC Codes for Renal Function
Canonical URL: http://hl7.org/fhir/uv/pddi/ValueSet/valueset-renal-LOINC
Parameter
Name Use Card. Type Documentation
ContextPrescriptions In 0..* MedicationRequest
Get Base Indicator Out 0..1 string
Get Card 2 Summary Out 0..1 string
Inclusion Criteria Out 0..1 boolean
Get Card 3 Summary Out 0..1 string
Is Context medication cyclosporine Out 0..1 boolean
Get Card 2 Detail Out 0..1 string
Is digoxin in prefetch Out 0..1 boolean
Is new order for digoxin Out 0..1 boolean
Get Card 3 Detail Out 0..1 string
Get Card 3 Indicator Out 0..1 string
Get Base Detail Out 0..1 string
Need to reduce Digoxin dose Out 0..1 boolean
Is Context medication digoxin Out 0..1 boolean
Get Card 2 Indicator Out 0..1 string
Get Base Summary Out 0..1 string
PlanDefinition Logic Data Requirements
Data Requirement Type: Patient
Profile(s): Patient
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, authoredOn
Code Filter(s):
Path: medication
ValueSet: Digoxin Medications Value Set
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, authoredOn
Code Filter(s):
Path: medication
ValueSet: Cyclosporine Medications Value Set
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, authoredOn
Code Filter(s):
Path: medication
ValueSet: Aldosterone Antagonists Drug Value Set
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, authoredOn
Code Filter(s):
Path: medication
ValueSet: Loop Diuretic Drug Value Set
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication.reference, medication, authoredOn
Data Requirement Type: Medication
Profile(s): Medication
Must Support Elements: id, code
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Digoxin Medications Value Set
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Cyclosporine Medications Value Set
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Aldosterone Antagonists Drug Value Set
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Loop Diuretic Drug Value Set
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication.reference, effective, medication
Data Requirement Type: MedicationDispense
Profile(s): MedicationDispense
Must Support Elements: medication, whenHandedOver
Code Filter(s):
Path: medication
ValueSet: Digoxin Medications Value Set
Data Requirement Type: MedicationDispense
Profile(s): MedicationDispense
Must Support Elements: medication, whenHandedOver
Code Filter(s):
Path: medication
ValueSet: Cyclosporine Medications Value Set
Data Requirement Type: MedicationDispense
Profile(s): MedicationDispense
Must Support Elements: medication, whenHandedOver
Code Filter(s):
Path: medication
ValueSet: Aldosterone Antagonists Drug Value Set
Data Requirement Type: MedicationDispense
Profile(s): MedicationDispense
Must Support Elements: medication, whenHandedOver
Code Filter(s):
Path: medication
ValueSet: Loop Diuretic Drug Value Set
Data Requirement Type: MedicationDispense
Profile(s): MedicationDispense
Must Support Elements: medication.reference, whenHandedOver, medication
Data Requirement Type: MedicationStatement
Profile(s): MedicationStatement
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Digoxin Medications Value Set
Data Requirement Type: MedicationStatement
Profile(s): MedicationStatement
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Cyclosporine Medications Value Set
Data Requirement Type: MedicationStatement
Profile(s): MedicationStatement
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Aldosterone Antagonists Drug Value Set
Data Requirement Type: MedicationStatement
Profile(s): MedicationStatement
Must Support Elements: medication, effective
Code Filter(s):
Path: medication
ValueSet: Loop Diuretic Drug Value Set
Data Requirement Type: MedicationStatement
Profile(s): MedicationStatement
Must Support Elements: medication.reference, effective, medication
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, effective, value
Code Filter(s):
Path: code
ValueSet: LOINC Codes for Serum Potassium
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, effective, value
Code Filter(s):
Path: code
ValueSet: LOINC Codes for Serum Potassium
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, effective, value
Code Filter(s):
Path: code
ValueSet: LOINC Codes for Serum Calcium
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, effective, value
Code Filter(s):
Path: code
ValueSet: LOINC Codes for Digoxin Concentration
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, effective, value
Code Filter(s):
Path: code
ValueSet: LOINC Codes for Renal Function
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Digoxin Prescription":
  ContextPrescriptions P
    where P.medication in "Digoxin"
    return P.medication as CodeableConcept
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is Context medication digoxin":
  exists ("Digoxin Prescription")
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Digoxin Rx":
    (
      [MedicationRequest: "Digoxin"] MR
        where MR.authoredOn.toInterval() during Interval[Today() - 100 days, null]
        return MR.medication as CodeableConcept
    )
    union (
      [MedicationAdministration: "Digoxin"] MA
        where MA.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MA.medication as CodeableConcept
    )
    union (
      [MedicationDispense: "Digoxin"] MD
        where MD.whenHandedOver.toInterval() during Interval[Today() - 100 days, null]
        return MD.medication as CodeableConcept
    )
    union (
      [MedicationStatement: "Digoxin"] MS
        where MS.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MS.medication as CodeableConcept
    )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is digoxin in prefetch":
  exists ("Digoxin Rx")
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is continuation order for digoxin":
  "Is Context medication digoxin"
      and "Is digoxin in prefetch"
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Cyclosporine Prescription":
  ContextPrescriptions P
    where P.medication in "Cyclosporine"
    return P.medication as CodeableConcept
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is Context medication cyclosporine":
  exists ("Cyclosporine Prescription")
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Cyclosporine Rx":
    (
      [MedicationRequest: "Cyclosporine"] MR
        where MR.authoredOn.toInterval() during Interval[Today() - 100 days, null]
        return MR.medication as CodeableConcept
    )
    union (
      [MedicationAdministration: "Cyclosporine"] MA
        where MA.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MA.medication as CodeableConcept
    )
    union (
      [MedicationDispense: "Cyclosporine"] MD
        where MD.whenHandedOver.toInterval() during Interval[Today() - 100 days, null]
        return MD.medication as CodeableConcept
    )
    union (
      [MedicationStatement: "Cyclosporine"] MS
        where MS.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MS.medication as CodeableConcept
    )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is cyclosporine in prefetch":
  exists ("Cyclosporine Rx")
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is continuation order for cyclosporine":
  "Is Context medication cyclosporine"
      and "Is cyclosporine in prefetch"
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Normal Digoxin Observation":
	Last (
    [Observation: "Digoxin LOINC"] O
      where O.effective.toInterval() during Interval[Today() - 30 days, null]
        and O.value < 0.9 'ng/mL'
      sort by start of effective.toInterval()
  )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is there a normal digoxin level in prefetch":
  "Normal Digoxin Observation" is not null
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Aldosterone Antagonists Rx":
    (
      [MedicationRequest: "Aldosterone Antagonists"] MR
        where MR.authoredOn.toInterval() during Interval[Today() - 100 days, null]
        return MR.medication as CodeableConcept
    )
    union (
      [MedicationAdministration: "Aldosterone Antagonists"] MA
        where MA.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MA.medication as CodeableConcept
    )
    union (
      [MedicationDispense: "Aldosterone Antagonists"] MD
        where MD.whenHandedOver.toInterval() during Interval[Today() - 100 days, null]
        return MD.medication as CodeableConcept
    )
    union (
      [MedicationStatement: "Aldosterone Antagonists"] MS
        where MS.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MS.medication as CodeableConcept
    )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Loop Diuretics Rx":
    (
      [MedicationRequest: "Loop Diuretics"] MR
        where MR.authoredOn.toInterval() during Interval[Today() - 100 days, null]
        return MR.medication as CodeableConcept
    )
    union (
      [MedicationAdministration: "Loop Diuretics"] MA
        where MA.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MA.medication as CodeableConcept
    )
    union (
      [MedicationDispense: "Loop Diuretics"] MD
        where MD.whenHandedOver.toInterval() during Interval[Today() - 100 days, null]
        return MD.medication as CodeableConcept
    )
    union (
      [MedicationStatement: "Loop Diuretics"] MS
        where MS.effective.toInterval() overlaps Interval[Today() - 100 days, null]
        return MS.medication as CodeableConcept
    )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Are diuretics in prefetch":
  exists ("Aldosterone Antagonists Rx")
    or exists("Loop Diuretics Rx")
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Normal Potassium Observation":
  Last (
    [Observation: "Potassium LOINC"] O
      where O.effective.toInterval() during Interval[Today() - 365 days, null]
        and O.value > 3.5 'meq/L'
        and O.value < 5.0 'meq/L'
      sort by start of effective.toInterval()
  )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Normal Magnesium Observation":
  Last (
    [Observation: "Magnesium LOINC"] O
      where O.effective.toInterval() during Interval[Today() - 365 days, null]
        and O.value > 0.7 'mmol/L'
        and O.value < 1.1 'mmol/L'
      sort by start of effective.toInterval()
  )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Normal Calcium Observation":
  Last (
    [Observation: "Calcium LOINC"] O
      where O.effective.toInterval() during Interval[Today() - 365 days, null]
        and O.value > 8.5 'mg/dL'
        and O.value < 10.2 'mg/dL'
      sort by start of effective.toInterval()
  )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is there a normal electrolyte observation in prefetch":
  "Normal Potassium Observation" is not null
  and "Normal Magnesium Observation" is not null
  and "Normal Calcium Observation" is not null
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Normal Renal Observation":
  Last (
    [Observation: "Renal LOINC"] O
      where O.effective.toInterval() during Interval[Today() - 365 days, null]
        and O.value > 0.6 'mg/dL'
        and O.value < 1.2 'mg/dL'
      sort by start of effective.toInterval()
  )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is there a normal renal observation in prefetch":
  "Normal Renal Observation" is not null
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is there a normal electrolyte and renal observation in prefetch":
  "Is there a normal electrolyte observation in prefetch"
    and "Is there a normal renal observation in prefetch"
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Are diuretics or abnormal electrolyte or abnormal renal observations in prefetch":
  "Are diuretics in prefetch"
    or not "Is there a normal electrolyte and renal observation in prefetch"
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Get Base Indicator":
  if "Is continuation order for digoxin"
    or "Is continuation order for cyclosporine"
    then if "Is there a normal digoxin level in prefetch"
        then if "Are diuretics or abnormal electrolyte or abnormal renal observations in prefetch"
            then 'warning'
          else 'info'
      else 'warning'
  else 'warning'
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Get Card 2 Summary":
  if "Is there a normal digoxin level in prefetch"
    then 'Patient has digoxin level within 30 days that is below 0.9 ng/mL (SI: 1.2 nmol/L)'
  else 'Patient does not have digoxin level on record within the last 30 days. '
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
/*
**
** Digoxin Cyclosporine CDS Recommendation
**
*/

define "Inclusion Criteria":
  (
    "Is Context medication cyclosporine"
      and "Is digoxin in prefetch"
  )
  or (
    "Is Context medication digoxin"
      and "Is cyclosporine in prefetch"
  )
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Get Card 3 Summary":
  if "Is there a normal electrolyte and renal observation in prefetch"
    then 'Within 100 days, the patient has had electrolyte and serum creatinine levels checked, and they are not on a potassium sparing or loop diuretic.'
  else 'Within 100 days, the patient has not had an electrolyte panel. The patient does have serum creatinine level and is not on a potassium sparing or loop diuretic.'
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Get Card 2 Detail":
  if "Is there a normal digoxin level in prefetch"
    then '(Digoxin: '
    + Common.GetLevelAndDate("Normal Digoxin Observation")
    + '). \nFor patients with a reliable plasma digoxin concentration in normal range, it is reasonable to anticipate an increase in plasma concentrations after the initiation of cyclosporine. Following initiation, close monitoring and adjusting the digoxin dose as needed is recommended'
  else 'Initiating cyclosporine is expected to increase digoxin levels. For patients without a reliable plasma digoxin concentration in normal range, use only if benefits outweight risks. Extreme caution and close monitoring is necessary.'
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is new order for digoxin":
  "Is Context medication digoxin"
      and not "Is digoxin in prefetch"
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Get Card 3 Detail":
  if "Is there a normal electrolyte and renal observation in prefetch"
    then '(Potassium: '
    + Common.GetLevelAndDate("Normal Potassium Observation")
    + ')\n (Magnesium: '
    + Common.GetLevelAndDate("Normal Magnesium Observation")
    + ')\n (Calcium: '
    + Common.GetLevelAndDate("Normal Calcium Observation")
    + ')\n'
  else ''
  + '(Serum creatinine: '
  + Common.GetLevelAndDate("Normal Renal Observation")
  + ')\n Hypokalemia, hypomagnesemia, and hypercalcemia may potentiate digoxin toxicity. 50-70% of digoxin is excreted unchanged in the urine. Changing renal function may increase serum concentrations and risk of toxicity.'
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
// Card 3
define "Get Card 3 Indicator":
  if "Is there a normal electrolyte and renal observation in prefetch"
    then 'info'
  else 'warning'
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Get Base Detail":
  'Increased risk of digoxin toxicity. Assess risk and take action if necessary. \nDigoxin toxicity is potentially serious. The clinical consequences may include anorexia, nausea, vomiting, visual changes, and cardiac arrhythmias. \nThe mechanism of this interaction appears to be mediated through P-glycoprotein inhibition by cyclosporine. P-glycoprotein is a major transporter for digoxin efflux. \nunknown. \nunknown.'
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Need to reduce Digoxin dose":
  "Is Context medication cyclosporine"
    or not "Is there a normal digoxin level in prefetch"
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
define "Is new order for cyclosporine":
  "Is Context medication cyclosporine"
      and not "Is cyclosporine in prefetch"
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
// Card 2
define "Get Card 2 Indicator":
  if "Is new order for cyclosporine"
    then if "Is there a normal digoxin level in prefetch"
      then 'warning'
    else 'critical'
  else if "Is there a normal digoxin level in prefetch"
      then 'info'
    else 'warning'
Logic Definition Library Name: DigoxinCyclosporineCDSLogic
// Card 1: Base
define "Get Base Summary":
  'Potential Drug-Drug Interaction between digoxin ('
    + (
      if "Is Context medication digoxin"
        then Common.GetDrugNames("Digoxin Prescription")
      else Common.GetDrugNames("Digoxin Rx")
    )
    + ') and cyclosporine ('
    + (
      if "Is Context medication cyclosporine"
        then Common.GetDrugNames("Cyclosporine Prescription")
      else Common.GetDrugNames("Cyclosporine Rx")
    )
    + ')'
Logic Definition Library Name: FHIRCommon
/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in FHIR, allowing this function to be used across any resource.

The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a dateTime, the result a DateTime Interval beginning and ending on that dateTime.
If the input is a Period, the result is a DateTime Interval.
If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.
If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.
If the input is a string, an error is raised indicating a single interval cannot be computed from a string.
If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,
and ending immediately prior to when the patient was the given Age plus one year.
If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given
by the low end of the Range, and ending immediately prior to when the patient was the Age given by the
high end of the Range plus one year.

NOTE: Due to the
complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used
with a Timing or String.
*/
define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):
  case
    when choice is FHIR.dateTime then
      Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
    when choice is FHIR.Period then
      FHIRHelpers.ToInterval(choice as FHIR.Period)
    when choice is FHIR.instant then
      Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
    when choice is FHIR.Age then
      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
    when choice is FHIR.Range then
      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
    when choice is FHIR.Timing then
      Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported')
    when choice is FHIR.string then
      Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
    else
      null as Interval<DateTime>
  end
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
*/
define function ToConcept(concept FHIR.CodeableConcept):
    if concept is null then
        null
    else
        System.Concept {
            codes: concept.coding C return ToCode(C),
            display: concept.text.value
        }
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }
Logic Definition Library Name: FHIRHelpers
define function ToString(value string): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value dateTime): value.value
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
value to a CQL DateTime Interval
@comment: If the start value of the given period is unspecified, the starting
boundary of the resulting interval will be open (meaning the start of the interval
is unknown, as opposed to interpreted as the beginning of time).
*/
define function ToInterval(period FHIR.Period):
    if period is null then
        null
    else
        if period."start" is null then
            Interval(period."start".value, period."end".value]
        else
            Interval[period."start".value, period."end".value]
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value instant): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDate(value date): value.value
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) 
value to a CQL Quantity
@comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity
has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`)
an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used.
@seealso: ToCalendarUnit
*/
define function ToQuantity(quantity FHIR.Quantity):
    case
        when quantity is null then null
        when quantity.value is null then null
        when quantity.comparator is not null then
            Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')
        when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
              or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
            System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
        else
            Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')
    end
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts a UCUM definite duration unit to a CQL calendar duration
unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities) 
topic of the CQL specification.
@comment: Note that for durations above days (or weeks), the conversion is understood to be approximate
*/
define function ToCalendarUnit(unit System.String):
    case unit
        when 'ms' then 'millisecond'
        when 's' then 'second'
        when 'min' then 'minute'
        when 'h' then 'hour'
        when 'd' then 'day'
        when 'wk' then 'week'
        when 'mo' then 'month'
        when 'a' then 'year'
        else unit
    end
Logic Definition Library Name: PDDICDSCommon
define function GetLevelAndDate(observation Observation):
  if observation is not null
    then ToString(ToQuantity(observation.value as Quantity))
      + ' and ' 
      + ToString(observation.effective.value)
  else 'NA'
Logic Definition Library Name: PDDICDSCommon
define function ToQuantity(quantity FHIR.Quantity):
  System.Quantity { value: quantity.value.value, unit: quantity.unit.value }
Logic Definition Library Name: PDDICDSCommon
define function GetDrugNames(codes List<FHIR.CodeableConcept>):
  Combine(
    flatten(
      codes C
        return C.coding coding
          return ToCode(coding).display
    )
    ,', '
  )
Logic Definition Library Name: PDDICDSCommon
define function ToCode(coding FHIR.Coding):
  System.Code {
    code: coding.code.value,
    system: coding.system.value,
    version: coding.version.value,
    display: coding.display.value
  }
Generated using version 0.5.6-cibuild of the sample-content-ig Liquid templates