Presentation on morphine with full details and all the doses

Reading File
Reading File
Reading File
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Reading File
Running Command

ls -la /home/daytona/workspace/ && mkdir -p /home/daytona/workspace/morphine-pptx

Writing File

~/morphine-pptx/morphine.js

const pptxgen = require("pptxgenjs");

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.author = "Orris Medical";
pres.title = "Morphine – Comprehensive Pharmacology";

// ─── COLOUR PALETTE ────────────────────────────────────────────────────────
const DARK_BG   = "0D1B2A";   // deep navy
const MID_BG    = "1B2A3B";   // slightly lighter navy
const ACCENT    = "E8A020";   // amber gold
const ACCENT2   = "3DA5D9";   // sky blue
const WHITE     = "FFFFFF";
const LIGHT     = "D8E8F4";
const SUBTEXT   = "B0C4D8";
const RED       = "E05C5C";
const GREEN     = "5CB85C";
const HEADING_FONT = "Calibri";
const BODY_FONT    = "Calibri";

// ─── HELPERS ────────────────────────────────────────────────────────────────
function darkSlide(pres) {
  const slide = pres.addSlide();
  slide.background = { color: DARK_BG };
  return slide;
}

function midSlide(pres) {
  const slide = pres.addSlide();
  slide.background = { color: MID_BG };
  return slide;
}

function sectionBanner(slide, text) {
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: DARK_BG } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 2.3, w: 10, h: 0.06, fill: { color: ACCENT } });
  slide.addText(text, {
    x: 0.5, y: 1.5, w: 9, h: 1.4,
    fontSize: 44, bold: true, color: WHITE,
    fontFace: HEADING_FONT, align: "center", valign: "middle"
  });
}

function slideTitle(slide, title, subtitle) {
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.0, fill: { color: "0A1520" } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.9, w: 10, h: 0.05, fill: { color: ACCENT } });
  slide.addText(title, {
    x: 0.4, y: 0.05, w: 9.2, h: 0.85,
    fontSize: 26, bold: true, color: WHITE,
    fontFace: HEADING_FONT, margin: 0
  });
  if (subtitle) {
    slide.addText(subtitle, {
      x: 0.4, y: 0.88, w: 9.2, h: 0.2,
      fontSize: 11, color: ACCENT, fontFace: BODY_FONT, margin: 0, italic: true
    });
  }
}

function bullet(text, level) {
  return { text, options: { bullet: { code: "2022" }, indentLevel: level || 0, breakLine: true } };
}

function subBullet(text) {
  return { text, options: { bullet: { code: "2013" }, indentLevel: 1, breakLine: true, color: SUBTEXT } };
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 1 – TITLE
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  // background decorative bar
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  s.addShape(pres.ShapeType.rect, { x: 0.18, y: 0, w: 9.82, h: 5.625, fill: { color: DARK_BG } });
  // vertical label strip
  s.addText("PHARMACOLOGY", {
    x: -1.6, y: 4.1, w: 5.625, h: 0.18,
    fontSize: 8, bold: true, color: ACCENT, fontFace: HEADING_FONT,
    align: "center", charSpacing: 5, rotate: 270, margin: 0
  });
  // title block
  s.addText("MORPHINE", {
    x: 0.6, y: 0.5, w: 8.8, h: 2.0,
    fontSize: 72, bold: true, color: WHITE, fontFace: HEADING_FONT,
    align: "left", valign: "bottom", margin: 0
  });
  s.addShape(pres.ShapeType.rect, { x: 0.6, y: 2.5, w: 6, h: 0.05, fill: { color: ACCENT } });
  s.addText("Comprehensive Pharmacology, Dosing & Clinical Use", {
    x: 0.6, y: 2.6, w: 8.8, h: 0.55,
    fontSize: 20, color: LIGHT, fontFace: BODY_FONT, align: "left", margin: 0
  });
  s.addText("Opioid Analgesic  •  μ-Receptor Agonist  •  WHO Essential Medicine", {
    x: 0.6, y: 3.3, w: 8.8, h: 0.4,
    fontSize: 13, color: SUBTEXT, fontFace: BODY_FONT, align: "left", margin: 0, italic: true
  });
  s.addText("Sources: Goodman & Gilman 14e  •  Miller's Anesthesia 10e  •  Rosen's Emergency Medicine 9e  •  Barash Clinical Anesthesia 9e", {
    x: 0.6, y: 5.1, w: 9, h: 0.35,
    fontSize: 9, color: SUBTEXT, fontFace: BODY_FONT, align: "left", margin: 0
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 2 – OVERVIEW / TABLE OF CONTENTS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Presentation Overview");
  const topics = [
    ["01", "History & Classification"],
    ["02", "Chemistry & Structure-Activity Relationships"],
    ["03", "Mechanism of Action"],
    ["04", "Pharmacokinetics (ADME)"],
    ["05", "Pharmacodynamics – CNS & Systemic Effects"],
    ["06", "Clinical Uses"],
    ["07", "Dosing – All Routes"],
    ["08", "Special Populations"],
    ["09", "Adverse Effects"],
    ["10", "Contraindications & Precautions"],
    ["11", "Drug Interactions"],
    ["12", "Overdose & Reversal"],
    ["13", "Tolerance, Dependence & Withdrawal"],
  ];
  const col1 = topics.slice(0, 7);
  const col2 = topics.slice(7);
  col1.forEach((item, i) => {
    s.addText(item[0], { x: 0.4, y: 1.15 + i * 0.6, w: 0.5, h: 0.48, fontSize: 15, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
    s.addText(item[1], { x: 0.9, y: 1.15 + i * 0.6, w: 4.0, h: 0.48, fontSize: 14, color: WHITE, fontFace: BODY_FONT, margin: 0, valign: "middle" });
  });
  col2.forEach((item, i) => {
    s.addText(item[0], { x: 5.2, y: 1.15 + i * 0.6, w: 0.5, h: 0.48, fontSize: 15, bold: true, color: ACCENT2, fontFace: HEADING_FONT, margin: 0 });
    s.addText(item[1], { x: 5.7, y: 1.15 + i * 0.6, w: 4.1, h: 0.48, fontSize: 14, color: WHITE, fontFace: BODY_FONT, margin: 0, valign: "middle" });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 3 – HISTORY & CLASSIFICATION
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "History & Classification", "From opium poppy to WHO Essential Medicine");
  s.addText([
    bullet("Morphine isolated from opium (Papaver somniferum) by Friedrich Sertürner in 1804 – the first alkaloid isolated from a plant"),
    bullet("Named after Morpheus, the Greek god of dreams"),
    bullet("Commercial production began ~1827 (Merck); hypodermic needle introduced ~1853 accelerated clinical use"),
    bullet("Still considered the gold standard opioid analgesic against which all others are compared"),
  ], { x: 0.4, y: 1.05, w: 5.6, h: 2.2, fontSize: 14, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.3 });

  // Classification box
  s.addShape(pres.ShapeType.rect, { x: 6.3, y: 1.05, w: 3.5, h: 4.3, fill: { color: "0A1520" }, line: { color: ACCENT, width: 1.5 } });
  s.addText("CLASSIFICATION", { x: 6.3, y: 1.05, w: 3.5, h: 0.4, fontSize: 12, bold: true, color: ACCENT, fontFace: HEADING_FONT, align: "center", margin: 0 });
  const classItems = [
    ["Class", "Opioid analgesic"],
    ["Subclass", "Phenanthrene alkaloid"],
    ["Receptor", "μ (mu) > κ, δ agonist"],
    ["Schedule", "Schedule II (DEA)"],
    ["WHO", "Essential Medicine"],
    ["Source", "Natural (opium)"],
  ];
  classItems.forEach((item, i) => {
    s.addText(item[0] + ":", { x: 6.45, y: 1.5 + i * 0.6, w: 1.2, h: 0.45, fontSize: 11, bold: true, color: ACCENT2, fontFace: BODY_FONT, margin: 0 });
    s.addText(item[1], { x: 7.7, y: 1.5 + i * 0.6, w: 2.0, h: 0.45, fontSize: 11, color: WHITE, fontFace: BODY_FONT, margin: 0 });
  });

  s.addText([
    bullet("Other natural opioids: codeine, thebaine"),
    bullet("Semi-synthetic derivatives: heroin (3,6-diacetylmorphine), hydromorphone, oxymorphone, oxycodone, buprenorphine, naloxone, naltrexone"),
    bullet("Fully synthetic: fentanyl, methadone, meperidine, tramadol"),
  ], { x: 0.4, y: 3.15, w: 5.6, h: 2.2, fontSize: 13, color: LIGHT, fontFace: BODY_FONT, lineSpacingMultiple: 1.25 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 4 – CHEMISTRY & STRUCTURE-ACTIVITY
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Chemistry & Structure-Activity Relationships");
  s.addText([
    bullet("Molecular formula: C₁₇H₁₉NO₃  •  MW: 285.3 Da"),
    bullet("Pentacyclic structure with two hydroxyl groups: C-3 (phenolic) and C-6 (alcoholic)"),
    bullet("The phenolic –OH at C-3 is critical for opioid receptor binding"),
    subBullet("Methylation → codeine (10× less potent); acetylation → heroin (faster CNS entry)"),
    bullet("C-6 hydroxyl: oxidation increases potency (hydromorphone ~7× morphine)"),
    bullet("Tertiary nitrogen at position 17 (N-methyl)"),
    subBullet("Replace N-methyl with allyl/cyclopropylmethyl → naloxone/naltrexone (antagonists)"),
    subBullet("Replace N-methyl with lower efficacy group → buprenorphine (partial agonist)"),
    bullet("Double bond C7–C8: reduction increases potency"),
    bullet("14-OH addition (from thebaine) → oxymorphone, oxycodone, naloxone"),
    bullet("pKa = 8.0 → at physiologic pH, only 10–20% un-ionized → slower CNS penetration vs. fentanyl"),
    bullet("Lipid solubility: LOW relative to fentanyl; accounts for slower onset and longer duration"),
  ], { x: 0.4, y: 1.05, w: 9.3, h: 4.35, fontSize: 13, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 5 – MECHANISM OF ACTION
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Mechanism of Action", "μ-Opioid Receptor Agonist");
  // Left column
  s.addText("Receptor Binding", { x: 0.4, y: 1.1, w: 4.5, h: 0.4, fontSize: 16, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Binds preferentially to μ (mu) opioid receptors; also κ and δ"),
    bullet("All opioid receptors are Gi/Go-protein coupled receptors (GPCRs)"),
    subBullet("↓ adenylyl cyclase → ↓ cAMP"),
    subBullet("Opens K⁺ channels → hyperpolarization"),
    subBullet("Closes voltage-gated Ca²⁺ channels → ↓ neurotransmitter release"),
    bullet("Net effect: decreased neuronal excitability and reduced pain signal transmission"),
  ], { x: 0.4, y: 1.5, w: 4.5, h: 2.5, fontSize: 13, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });

  // Right column
  s.addText("Sites of Action", { x: 5.2, y: 1.1, w: 4.5, h: 0.4, fontSize: 16, bold: true, color: ACCENT2, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Supraspinal: periaqueductal gray (PAG), nucleus raphe magnus → descending inhibition"),
    bullet("Spinal: dorsal horn → inhibit substance P / glutamate release"),
    bullet("Peripheral: inflamed tissue sensory terminals → ↓ nociceptor sensitivity"),
    bullet("Limbic system: emotional/affective component of pain"),
  ], { x: 5.2, y: 1.5, w: 4.5, h: 2.5, fontSize: 13, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });

  // Receptor effect table
  s.addShape(pres.ShapeType.rect, { x: 0.4, y: 3.95, w: 9.2, h: 1.45, fill: { color: "0A1520" }, line: { color: ACCENT, width: 1 } });
  s.addText("μ Receptor Effects at a Glance", { x: 0.5, y: 4.0, w: 9, h: 0.3, fontSize: 12, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  const mrfx = [
    ["Analgesia (supraspinal + spinal)", ACCENT2],
    ["Respiratory depression", RED],
    ["Euphoria / sedation", SUBTEXT],
    ["Miosis", LIGHT],
    ["Reduced GI motility / constipation", RED],
    ["Physical dependence", RED],
  ];
  mrfx.forEach((item, i) => {
    const col = i < 3 ? 0 : 1;
    const row = i < 3 ? i : i - 3;
    s.addText("• " + item[0], {
      x: 0.5 + col * 4.65, y: 4.32 + row * 0.35, w: 4.5, h: 0.33,
      fontSize: 11, color: item[1], fontFace: BODY_FONT, margin: 0
    });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 6 – PHARMACOKINETICS (ADME)
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Pharmacokinetics (ADME)", "Goodman & Gilman 14e  •  Miller's Anesthesia 10e");
  const rows = [
    ["ABSORPTION", [
      "Oral bioavailability ~20–30% (extensive first-pass hepatic metabolism)",
      "IM/SC: bioavailability ~100%; peak 30–60 min",
      "IV: immediate; peak analgesia 15–20 min",
      "Rectal: ~20% bioavailability (similar to oral)",
      "Spinal/epidural: direct spinal cord effect",
    ]],
    ["DISTRIBUTION", [
      "Protein binding: ~20–40% (mainly albumin)",
      "Low lipid solubility → slow CNS penetration; pKa 8.0",
      "Only 10–20% un-ionized at pH 7.4 → slower onset vs. fentanyl",
      "Vd ~3–5 L/kg; crosses placenta and enters breast milk",
    ]],
    ["METABOLISM", [
      "Primarily hepatic conjugation (glucuronidation, UGT2B7)",
      "Morphine-3-glucuronide (M3G, ~60%): NO analgesic activity; may antagonize morphine; CNS excitatory (myoclonus, seizures) with accumulation",
      "Morphine-6-glucuronide (M6G, ~10%): MORE potent μ-agonist than morphine; major contributor to analgesia (especially oral/renal failure)",
      "Kidney contributes ~40% of morphine conjugation",
    ]],
    ["EXCRETION", [
      "Eliminated primarily as M3G by glomerular filtration",
      "~90% excreted within 24 hours",
      "Half-life (t½): 2–3 hours (parent drug); M6G longer",
      "Enterohepatic circulation → small amounts in feces/urine for days",
    ]],
  ];
  rows.forEach((row, ri) => {
    const y = 1.08 + ri * 1.1;
    s.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 1.55, h: 0.9, fill: { color: ACCENT }, line: { color: ACCENT } });
    s.addText(row[0], { x: 0.3, y, w: 1.55, h: 0.9, fontSize: 10, bold: true, color: DARK_BG, fontFace: HEADING_FONT, align: "center", valign: "middle", margin: 0 });
    const items = row[1].map(t => ({ text: t, options: { bullet: { code: "2022" }, breakLine: true } }));
    s.addText(items, { x: 2.0, y: y + 0.02, w: 7.7, h: 0.88, fontSize: 11.5, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.15, valign: "top" });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 7 – PK PARAMETERS TABLE
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Key Pharmacokinetic Parameters");
  const tableData = [
    [
      { text: "Parameter", options: { bold: true, color: DARK_BG, fill: ACCENT, align: "center" } },
      { text: "Value", options: { bold: true, color: DARK_BG, fill: ACCENT, align: "center" } },
      { text: "Parameter", options: { bold: true, color: DARK_BG, fill: ACCENT, align: "center" } },
      { text: "Value", options: { bold: true, color: DARK_BG, fill: ACCENT, align: "center" } },
    ],
    [{ text: "Oral bioavailability" }, { text: "20–30%" }, { text: "Half-life (t½)" }, { text: "2–3 hours" }],
    [{ text: "Protein binding" }, { text: "20–40%" }, { text: "M6G t½" }, { text: "~9 hours" }],
    [{ text: "Vd" }, { text: "3–5 L/kg" }, { text: "Onset IV" }, { text: "5 min (peak 15–20 min)" }],
    [{ text: "Onset IM/SC" }, { text: "10–15 min" }, { text: "Onset PO" }, { text: "30–45 min" }],
    [{ text: "Duration" }, { text: "3–6 hours (IR)" }, { text: "Duration ER" }, { text: "8–24 hours" }],
    [{ text: "pKa" }, { text: "8.0" }, { text: "Renal excretion" }, { text: ">90% as glucuronides" }],
    [{ text: "Metabolite M3G" }, { text: "~60% (inactive/excitatory)" }, { text: "Metabolite M6G" }, { text: "~10% (active, potent)" }],
  ];
  s.addTable(tableData, {
    x: 0.3, y: 1.1, w: 9.5, h: 4.25,
    border: { pt: 0.5, color: "2A4A6A" },
    fill: MID_BG,
    color: WHITE,
    fontSize: 13,
    fontFace: BODY_FONT,
    rowH: 0.48,
    align: "center",
    valign: "middle",
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 8 – PHARMACODYNAMICS: CNS EFFECTS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Pharmacodynamics – CNS Effects");
  s.addText([
    bullet("Analgesia: effective for moderate-to-severe pain; raises pain threshold at supraspinal and spinal levels"),
    bullet("Euphoria & sedation: activation of limbic μ-receptors; basis for reward and addiction"),
    bullet("Respiratory depression: direct action on brainstem respiratory center; reduced sensitivity to CO₂; DOSE-DEPENDENT; principal cause of opioid overdose death"),
    bullet("Miosis (pinpoint pupils): stimulation of Edinger-Westphal nucleus of CN III; no tolerance develops; diagnostic sign of opioid use"),
    bullet("Antitussive: suppresses cough center in medulla"),
    bullet("Nausea/vomiting: stimulates chemoreceptor trigger zone (CTZ) in area postrema"),
    bullet("Hypothermia: reset hypothalamic thermostat"),
    bullet("Hormonal effects: ↓ LH, FSH, ACTH, TSH; ↑ prolactin, growth hormone, ADH"),
    bullet("EEG changes: high-voltage slow waves; seizures possible at very high doses"),
    bullet("Sedation: dose-related; potentiated by other CNS depressants"),
  ], { x: 0.4, y: 1.05, w: 9.3, h: 4.4, fontSize: 13, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.15 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 9 – PHARMACODYNAMICS: SYSTEMIC EFFECTS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Pharmacodynamics – Systemic Effects");
  const systems = [
    { label: "CARDIOVASCULAR", color: RED, items: [
      "Vasodilation → orthostatic hypotension (histamine release, ↓ sympathetic tone)",
      "Heart rate usually unchanged (may see bradycardia at high doses)",
      "Dangerous in hypovolemia / hemorrhagic shock – use with extreme caution",
    ]},
    { label: "RESPIRATORY", color: RED, items: [
      "Dose-dependent respiratory depression – main toxic effect",
      "↓ Rate, tidal volume, and hypoxic/hypercapnic drive",
      "Bronchoconstriction (histamine release) – caution in asthma",
    ]},
    { label: "GI TRACT", color: ACCENT, items: [
      "↓ Gastric emptying, ↓ propulsive motility → constipation (tolerance does NOT develop)",
      "↑ Sphincter of Oddi tone (spasm) → biliary colic worsening possible",
      "Nausea/vomiting via CTZ; ↑ nausea on ambulation",
    ]},
    { label: "GENITOURINARY", color: ACCENT2, items: [
      "↑ Urinary bladder sphincter tone → urinary retention",
      "↑ Ureteral tone and amplitude of contractions",
    ]},
    { label: "ENDOCRINE / IMMUNE", color: SUBTEXT, items: [
      "Chronic use → hypogonadotropic hypogonadism (↓ LH, FSH, testosterone, estrogen)",
      "Immunosuppression reported with chronic use",
    ]},
  ];
  systems.forEach((sys, i) => {
    const col = i < 3 ? 0 : 1;
    const row = i < 3 ? i : i - 3;
    const x = col === 0 ? 0.3 : 5.2;
    const y = 1.05 + row * 1.5;
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.6, h: 0.3, fill: { color: sys.color }, line: { color: sys.color } });
    s.addText(sys.label, { x, y, w: 4.6, h: 0.3, fontSize: 11, bold: true, color: DARK_BG, fontFace: HEADING_FONT, align: "center", valign: "middle", margin: 0 });
    const items = sys.items.map(t => ({ text: t, options: { bullet: { code: "2022" }, breakLine: true } }));
    s.addText(items, { x: x + 0.1, y: y + 0.3, w: 4.5, h: 1.15, fontSize: 11, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.1, valign: "top" });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 10 – CLINICAL USES
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Clinical Uses / Indications");
  const uses = [
    { title: "Acute Severe Pain", color: ACCENT, items: ["Trauma, post-operative pain", "Myocardial infarction (IV morphine for acute pulmonary edema + pain)", "Renal/biliary colic (myth of worsening disproven)", "Burns, cancer pain crisis"] },
    { title: "Chronic Cancer Pain", color: RED, items: ["WHO analgesic ladder Step 3 drug", "Oral morphine (IR + ER) is standard of care for moderate-to-severe cancer pain", "Starting dose: 5–15 mg PO q4h (IR); convert to ER after dose titration"] },
    { title: "Acute Pulmonary Edema", color: ACCENT2, items: ["IV morphine: ↓ preload/afterload via venodilation", "↓ Anxiety and dyspnea perception", "Caution: evidence questioned in recent literature"] },
    { title: "Neuraxial Analgesia", color: GREEN, items: ["Epidural/intrathecal morphine for post-op and obstetric pain", "Long duration (up to 24 h IT; 12–24 h epidural)", "Risk of delayed respiratory depression (monitor 24 h)"] },
    { title: "Palliative Care", color: SUBTEXT, items: ["Dyspnea management in terminal illness", "Pain at end of life; subcutaneous infusion acceptable"] },
    { title: "Procedural Sedation", color: ACCENT, items: ["IV titration in ED/ICU", "Paired with benzodiazepine for sedation-analgesia"] },
  ];
  uses.forEach((use, i) => {
    const col = i < 3 ? 0 : 1;
    const row = i < 3 ? i : i - 3;
    const x = col === 0 ? 0.3 : 5.2;
    const y = 1.05 + row * 1.5;
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.6, h: 0.32, fill: { color: use.color }, line: { color: use.color } });
    s.addText(use.title, { x, y, w: 4.6, h: 0.32, fontSize: 12, bold: true, color: DARK_BG, fontFace: HEADING_FONT, align: "center", valign: "middle", margin: 0 });
    const items = use.items.map(t => ({ text: t, options: { bullet: { code: "2022" }, breakLine: true } }));
    s.addText(items, { x: x + 0.1, y: y + 0.32, w: 4.5, h: 1.1, fontSize: 11, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.1, valign: "top" });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 11 – DOSING: ORAL
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Dosing – Oral Routes", "Immediate Release (IR) & Extended Release (ER)");
  s.addText("ORAL IMMEDIATE RELEASE (Morphine Sulfate IR)", {
    x: 0.4, y: 1.05, w: 9.2, h: 0.38, fontSize: 15, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0
  });
  const irData = [
    [{ text: "Population", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Dose", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Frequency", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Notes", options: { bold: true, fill: ACCENT, color: DARK_BG } }],
    [{ text: "Adults (opioid-naive)" }, { text: "5–15 mg" }, { text: "q4h" }, { text: "Titrate to effect; 30–60 mg/day starting" }],
    [{ text: "Adults (severe pain)" }, { text: "10–30 mg" }, { text: "q4h" }, { text: "Monitor respiratory rate closely" }],
    [{ text: "Elderly (≥65 yrs)" }, { text: "2.5–5 mg" }, { text: "q4–6h" }, { text: "Start low; ↑ risk ADRs" }],
    [{ text: "Pediatric (>6 mo)" }, { text: "0.2–0.5 mg/kg" }, { text: "q4–6h" }, { text: "Max 15–20 mg/dose" }],
  ];
  s.addTable(irData, { x: 0.3, y: 1.45, w: 9.4, h: 1.95, border: { pt: 0.5, color: "2A4A6A" }, fill: DARK_BG, color: WHITE, fontSize: 12, fontFace: BODY_FONT, rowH: 0.38, align: "center", valign: "middle" });

  s.addText("ORAL EXTENDED RELEASE (MS Contin, Morphine ER)", {
    x: 0.4, y: 3.45, w: 9.2, h: 0.38, fontSize: 15, bold: true, color: ACCENT2, fontFace: HEADING_FONT, margin: 0
  });
  const erData = [
    [{ text: "Population", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Starting Dose", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Frequency", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Notes", options: { bold: true, fill: ACCENT2, color: DARK_BG } }],
    [{ text: "Opioid-naive adult" }, { text: "15 mg" }, { text: "q8–12h" }, { text: "Do NOT crush/chew/dissolve" }],
    [{ text: "Cancer pain (conversion)" }, { text: "Total 24-hr IR dose ÷ 2" }, { text: "q12h" }, { text: "Provide IR for breakthrough (10–15% of total daily dose)" }],
    [{ text: "Cancer pain (Swanson)" }, { text: "30–60 mg/day total" }, { text: "Divide q12h after 1 wk IR titration" }, { text: "Add breakthrough IR morphine" }],
  ];
  s.addTable(erData, { x: 0.3, y: 3.85, w: 9.4, h: 1.6, border: { pt: 0.5, color: "2A4A6A" }, fill: DARK_BG, color: WHITE, fontSize: 12, fontFace: BODY_FONT, rowH: 0.42, align: "center", valign: "middle" });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 12 – DOSING: PARENTERAL (IV / IM / SC)
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Dosing – Parenteral Routes (IV / IM / SC)", "Rosen's Emergency Medicine 9e  •  Miller's Anesthesia 10e");
  s.addText("INTRAVENOUS (IV)", { x: 0.4, y: 1.06, w: 9.2, h: 0.35, fontSize: 15, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  const ivData = [
    [{ text: "Indication", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Dose", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Notes", options: { bold: true, fill: ACCENT, color: DARK_BG } }],
    [{ text: "Acute severe pain (adults)" }, { text: "0.1–0.15 mg/kg IV (loading); then ~half dose q5–15 min" }, { text: "Titrate to pain relief; onset 5 min, peak 15–20 min" }],
    [{ text: "Intraoperative analgesia" }, { text: "0.05–0.2 mg/kg IV" }, { text: "Adjust for age, ASA status" }],
    [{ text: "Post-op analgesia" }, { text: "2–5 mg IV q2–4h PRN" }, { text: "PCA preferred for ongoing pain" }],
    [{ text: "ICU infusion" }, { text: "2–10 mg/h IV" }, { text: "Titrate to CPOT/NRS; ↓ dose in renal failure" }],
    [{ text: "Pediatric acute pain (>6 mo)" }, { text: "0.05–0.1 mg/kg IV; max 0.15 mg/kg" }, { text: "Repeat q2–4h; dilute; monitor SpO₂" }],
    [{ text: "Neonates (prem)" }, { text: "0.01–0.02 mg/kg q4–6h" }, { text: "↓ clearance with gestational age; caution" }],
  ];
  s.addTable(ivData, { x: 0.3, y: 1.42, w: 9.4, h: 2.45, border: { pt: 0.5, color: "2A4A6A" }, fill: MID_BG, color: WHITE, fontSize: 11.5, fontFace: BODY_FONT, rowH: 0.36, align: "center", valign: "middle" });

  s.addText("IM / SUBCUTANEOUS (SC)", { x: 0.4, y: 3.92, w: 9.2, h: 0.35, fontSize: 15, bold: true, color: ACCENT2, fontFace: HEADING_FONT, margin: 0 });
  const imData = [
    [{ text: "Route", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Adult Dose", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Pediatric Dose", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Notes", options: { bold: true, fill: ACCENT2, color: DARK_BG } }],
    [{ text: "IM" }, { text: "5–20 mg q4h" }, { text: "0.1–0.2 mg/kg q4h" }, { text: "Not preferred; unpredictable absorption" }],
    [{ text: "SC" }, { text: "5–15 mg q4h" }, { text: "0.1–0.15 mg/kg q4h" }, { text: "Good for palliative care SC infusions" }],
  ];
  s.addTable(imData, { x: 0.3, y: 4.3, w: 9.4, h: 1.1, border: { pt: 0.5, color: "2A4A6A" }, fill: MID_BG, color: WHITE, fontSize: 12, fontFace: BODY_FONT, rowH: 0.35, align: "center", valign: "middle" });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 13 – DOSING: NEURAXIAL (EPIDURAL / INTRATHECAL)
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Dosing – Neuraxial Routes (Epidural / Intrathecal)", "Preservative-free morphine only");
  s.addText("EPIDURAL", { x: 0.4, y: 1.06, w: 4.5, h: 0.35, fontSize: 15, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  s.addText("INTRATHECAL (SPINAL)", { x: 5.2, y: 1.06, w: 4.5, h: 0.35, fontSize: 15, bold: true, color: ACCENT2, fontFace: HEADING_FONT, margin: 0 });

  const epItems = [
    "Adults (post-op): 2–5 mg epidural q12–24h",
    "Obstetric (labor analgesia): 2–3 mg epidural",
    "Cesarean section: 3–5 mg single dose epidural",
    "Cancer/chronic pain infusion: 1–10 mg/day",
    "Duration of analgesia: 12–24 hours",
    "Extended-release epidural (DepoDur): 10–20 mg single dose for C/S",
    "Monitor for delayed respiratory depression (12–24 h)",
    "Must use PRESERVATIVE-FREE preparation",
  ];
  const itItems = [
    "Adults (post-op): 0.1–0.3 mg intrathecal single dose",
    "Cesarean section: 0.1–0.2 mg IT",
    "Chronic pain pump: variable (mcg/day titrated)",
    "Duration: up to 24 hours (longer than epidural)",
    "Onset: 45–60 min (hydrophilic; slow)",
    "Risk of delayed respiratory depression: monitor 24 h",
    "IT dose ~10× less than epidural dose",
    "PRESERVATIVE-FREE preparation mandatory",
  ];
  s.addText(epItems.map(t => ({ text: t, options: { bullet: { code: "2022" }, breakLine: true } })),
    { x: 0.4, y: 1.45, w: 4.5, h: 3.9, fontSize: 12.5, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });
  s.addText(itItems.map(t => ({ text: t, options: { bullet: { code: "2022" }, breakLine: true } })),
    { x: 5.2, y: 1.45, w: 4.5, h: 3.9, fontSize: 12.5, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });

  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 5.22, w: 9.4, h: 0.25, fill: { color: RED }, line: { color: RED } });
  s.addText("⚠ ALL neuraxial morphine requires monitoring for delayed respiratory depression for at least 12–24 h post-dose", {
    x: 0.3, y: 5.22, w: 9.4, h: 0.25, fontSize: 10, bold: true, color: WHITE, fontFace: BODY_FONT, align: "center", valign: "middle", margin: 0
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 14 – DOSING: PCA
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Dosing – Patient-Controlled Analgesia (PCA) & Infusions");
  s.addText("PCA – MORPHINE (IV)", { x: 0.4, y: 1.06, w: 9.2, h: 0.35, fontSize: 15, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  const pcaData = [
    [{ text: "Setting", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Typical Value", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Range", options: { bold: true, fill: ACCENT, color: DARK_BG } }],
    [{ text: "Demand (bolus) dose" }, { text: "1 mg" }, { text: "0.5–2.5 mg" }],
    [{ text: "Lockout interval" }, { text: "6 minutes" }, { text: "5–10 minutes" }],
    [{ text: "Basal rate" }, { text: "0 mg/h (opioid-naive)" }, { text: "0–2 mg/h (opioid-tolerant)" }],
    [{ text: "1-hour limit" }, { text: "10 mg" }, { text: "Per protocol" }],
  ];
  s.addTable(pcaData, { x: 0.3, y: 1.45, w: 9.4, h: 2.0, border: { pt: 0.5, color: "2A4A6A" }, fill: MID_BG, color: WHITE, fontSize: 13, fontFace: BODY_FONT, rowH: 0.4, align: "center", valign: "middle" });

  s.addText("CONTINUOUS IV INFUSION (ICU/Palliative)", { x: 0.4, y: 3.52, w: 9.2, h: 0.35, fontSize: 15, bold: true, color: ACCENT2, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Adults: typically 2–10 mg/h; titrate q15–30 min to target (CPOT ≤2 or NRS ≤3)"),
    bullet("Opioid-tolerant patients may require much higher rates"),
    bullet("Pediatric: 0.01–0.03 mg/kg/h IV (neonates/infants – see special populations)"),
    bullet("Reduce by 25–50% in renal impairment (M6G accumulation risk)"),
    bullet("Syringe pump: typically 1 mg/mL concentration for adults"),
  ], { x: 0.4, y: 3.88, w: 9.3, h: 1.65, fontSize: 13, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 15 – EQUIANALGESIC DOSES
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Equianalgesic Dose Table", "Morphine as the reference standard (10 mg IV)");
  const eqData = [
    [{ text: "Opioid", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "IV/IM (mg)", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Oral (mg)", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Notes", options: { bold: true, fill: ACCENT, color: DARK_BG } }],
    [{ text: "Morphine" }, { text: "10" }, { text: "30" }, { text: "Reference standard" }],
    [{ text: "Hydromorphone" }, { text: "1.5" }, { text: "7.5" }, { text: "~7× more potent IV" }],
    [{ text: "Oxycodone" }, { text: "—" }, { text: "20–30" }, { text: "No parenteral form in most countries" }],
    [{ text: "Codeine" }, { text: "130" }, { text: "200" }, { text: "Prodrug; CYP2D6 dependent" }],
    [{ text: "Fentanyl" }, { text: "0.1 (100 mcg)" }, { text: "—" }, { text: "~100× more potent than morphine" }],
    [{ text: "Methadone" }, { text: "Variable" }, { text: "Variable" }, { text: "Complex equianalgesic; specialist input required" }],
    [{ text: "Meperidine" }, { text: "75–100" }, { text: "300" }, { text: "Not recommended for chronic use (normeperidine)" }],
    [{ text: "Tramadol" }, { text: "—" }, { text: "150" }, { text: "Partial opioid; CYP2D6 dependent" }],
    [{ text: "Oxymorphone" }, { text: "1" }, { text: "10" }, { text: "~10× more potent than oral morphine" }],
  ];
  s.addTable(eqData, { x: 0.3, y: 1.08, w: 9.5, h: 4.4, border: { pt: 0.5, color: "2A4A6A" }, fill: DARK_BG, color: WHITE, fontSize: 13, fontFace: BODY_FONT, rowH: 0.43, align: "center", valign: "middle" });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 16 – SPECIAL POPULATIONS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Dosing in Special Populations", "Barash Clinical Anesthesia 9e  •  Miller's Anesthesia 10e");
  const pops = [
    { label: "ELDERLY", color: ACCENT, items: [
      "↑ Sensitivity to opioids; ↑ duration of action",
      "Start with 25–50% of usual adult dose",
      "↑ Risk of respiratory depression, confusion, falls",
      "Age correlates with increased duration of analgesia",
    ]},
    { label: "RENAL IMPAIRMENT", color: RED, items: [
      "M6G accumulates → prolonged analgesia + respiratory depression",
      "M3G accumulation → CNS excitation (myoclonus, seizures, delirium)",
      "Reduce dose and increase dosing intervals",
      "Monitor closely; consider fentanyl or hydromorphone instead",
    ]},
    { label: "HEPATIC IMPAIRMENT", color: ACCENT, items: [
      "Morphine metabolism dependent on liver; ↓ conjugation in cirrhosis",
      "Bioavailability ↑ (↓ first-pass effect)",
      "Use with caution; reduce dose by ~50% and titrate",
    ]},
    { label: "PEDIATRIC", color: ACCENT2, items: [
      "Neonates (esp. premature): ↓ clearance; dose q4–6h; 0.01–0.05 mg/kg/dose IV",
      "Infants/children: 0.05–0.1 mg/kg IV q2–4h; 0.2–0.5 mg/kg PO q4–6h",
      "M6G sensitivity increases with maturation",
      "Apnea risk in neonates – monitor SpO₂",
    ]},
    { label: "PREGNANCY", color: SUBTEXT, items: [
      "Crosses placenta; can cause neonatal respiratory depression",
      "Use lowest effective dose for shortest duration",
      "Chronic use: neonatal opioid withdrawal syndrome (NOWS)",
      "Labor analgesia: small IV doses (1–2 mg) acceptable",
    ]},
    { label: "OBESITY", color: GREEN, items: [
      "Use ideal body weight (IBW) for initial dosing calculations",
      "Loading dose: 0.1–0.15 mg/kg IBW IV",
      "Monitor for ↑ respiratory risk (OSA, positioning)",
    ]},
  ];
  pops.forEach((pop, i) => {
    const col = i < 3 ? 0 : 1;
    const row = i < 3 ? i : i - 3;
    const x = col === 0 ? 0.3 : 5.2;
    const y = 1.05 + row * 1.5;
    s.addShape(pres.ShapeType.rect, { x, y, w: 4.6, h: 0.3, fill: { color: pop.color }, line: { color: pop.color } });
    s.addText(pop.label, { x, y, w: 4.6, h: 0.3, fontSize: 11, bold: true, color: DARK_BG, fontFace: HEADING_FONT, align: "center", valign: "middle", margin: 0 });
    const items = pop.items.map(t => ({ text: t, options: { bullet: { code: "2022" }, breakLine: true } }));
    s.addText(items, { x: x + 0.05, y: y + 0.3, w: 4.55, h: 1.15, fontSize: 11, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.1, valign: "top" });
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 17 – ADVERSE EFFECTS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Adverse Effects");
  const adrData = [
    [{ text: "System", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Effect", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Management", options: { bold: true, fill: ACCENT, color: DARK_BG } }],
    [{ text: "RESPIRATORY" }, { text: "Respiratory depression (most dangerous; dose-dependent)" }, { text: "Naloxone 0.4 mg IV (titrate); O₂; mechanical ventilation if needed" }],
    [{ text: "CNS" }, { text: "Sedation, euphoria, dysphoria, confusion, myoclonus (M3G), seizures" }, { text: "Reduce dose; consider opioid rotation" }],
    [{ text: "CARDIOVASCULAR" }, { text: "Hypotension, bradycardia, vasodilation (histamine release)" }, { text: "IV fluids, positioning; diphenhydramine for histamine" }],
    [{ text: "GI" }, { text: "Constipation (NO tolerance), nausea/vomiting, delayed gastric emptying" }, { text: "Stimulant laxative (senna/bisacodyl) routinely; antiemetics (ondansetron)" }],
    [{ text: "GU" }, { text: "Urinary retention, bladder spasm" }, { text: "Catheterisation if needed; dose reduction" }],
    [{ text: "ENDOCRINE" }, { text: "Hypogonadism, ↓ libido (chronic use), ↑ ADH" }, { text: "Hormone replacement if symptomatic" }],
    [{ text: "SKIN" }, { text: "Pruritus (particularly neuraxial), sweating, flushing" }, { text: "Ondansetron, nalbuphine, low-dose naloxone" }],
    [{ text: "IMMUNE" }, { text: "Histamine release (IV bolus) → bronchoconstriction, urticaria" }, { text: "Slow IV infusion; antihistamines" }],
  ];
  s.addTable(adrData, { x: 0.3, y: 1.06, w: 9.5, h: 4.4, border: { pt: 0.5, color: "2A4A6A" }, fill: DARK_BG, color: WHITE, fontSize: 11.5, fontFace: BODY_FONT, rowH: 0.46, align: "center", valign: "middle" });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 18 – CONTRAINDICATIONS & PRECAUTIONS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Contraindications & Precautions");
  s.addText("ABSOLUTE CONTRAINDICATIONS", { x: 0.4, y: 1.06, w: 4.5, h: 0.35, fontSize: 14, bold: true, color: RED, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Severe respiratory depression / respiratory arrest"),
    bullet("Acute asthma or severe bronchospasm (relative – use with extreme caution)"),
    bullet("Paralytic ileus"),
    bullet("Hypersensitivity to morphine (true allergy, rare)"),
    bullet("Concomitant use of MAO inhibitors (within 14 days) – serotonin syndrome risk"),
    bullet("Head injury + raised intracranial pressure (relative – CO₂ retention worsens ICP)"),
  ], { x: 0.4, y: 1.44, w: 4.6, h: 2.5, fontSize: 13, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });

  s.addText("PRECAUTIONS / USE WITH CARE", { x: 5.2, y: 1.06, w: 4.5, h: 0.35, fontSize: 14, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Elderly: reduce dose by 25–50%"),
    bullet("Renal impairment: reduce dose / extend interval; monitor for M6G toxicity"),
    bullet("Hepatic failure: ↑ bioavailability; reduce dose"),
    bullet("Hypothyroidism: ↑ CNS/respiratory depression"),
    bullet("Adrenal insufficiency: additive hypotension"),
    bullet("Hypovolemia / shock: ↑ risk of severe hypotension"),
    bullet("Seizure disorders: M3G may lower threshold"),
    bullet("Pregnancy: neonatal depression; NOWS with chronic use"),
    bullet("Neonates/premature infants: ↓ clearance; monitor closely"),
    bullet("Concurrent CNS depressants: ↑ sedation + respiratory depression"),
  ], { x: 5.2, y: 1.44, w: 4.5, h: 3.9, fontSize: 12.5, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.15 });

  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 3.95, w: 4.6, h: 1.45, fill: { color: "1A1A2E" }, line: { color: RED, width: 1.5 } });
  s.addText("⚠ BLACK BOX WARNING (FDA)\nConcomitant use with benzodiazepines or CNS depressants increases risk of profound sedation, respiratory depression, coma, and death", {
    x: 0.4, y: 4.0, w: 4.5, h: 1.3, fontSize: 11.5, color: WHITE, fontFace: BODY_FONT, align: "center", valign: "middle"
  });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 19 – DRUG INTERACTIONS
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Drug Interactions");
  const diData = [
    [{ text: "Drug / Class", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Interaction", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Significance", options: { bold: true, fill: ACCENT, color: DARK_BG } }],
    [{ text: "Benzodiazepines / CNS depressants" }, { text: "↑ Respiratory depression, sedation, coma" }, { text: "MAJOR / Black Box" }],
    [{ text: "MAO Inhibitors (phenelzine, tranylcypromine)" }, { text: "Serotonin syndrome, hyperpyrexia, death" }, { text: "CONTRAINDICATED" }],
    [{ text: "Alcohol" }, { text: "↑ CNS/respiratory depression" }, { text: "MAJOR – avoid" }],
    [{ text: "Tricyclic antidepressants" }, { text: "↑ Sedation, ↑ respiratory depression" }, { text: "MODERATE" }],
    [{ text: "Phenothiazines (e.g. chlorpromazine)" }, { text: "↑ Sedation, hypotension; potentiation" }, { text: "MODERATE" }],
    [{ text: "Anticholinergic drugs" }, { text: "↑ Constipation, urinary retention, ileus" }, { text: "MODERATE" }],
    [{ text: "Muscle relaxants (e.g. baclofen)" }, { text: "↑ CNS depression, ↓ respiratory drive" }, { text: "MODERATE" }],
    [{ text: "Cimetidine" }, { text: "Inhibits morphine metabolism → ↑ plasma levels" }, { text: "MODERATE" }],
    [{ text: "Rifampicin" }, { text: "↑ Morphine metabolism → ↓ efficacy" }, { text: "MODERATE" }],
    [{ text: "Naloxone / Naltrexone" }, { text: "Competitive antagonism; precipitates withdrawal" }, { text: "Therapeutic / Caution" }],
  ];
  s.addTable(diData, { x: 0.3, y: 1.06, w: 9.5, h: 4.45, border: { pt: 0.5, color: "2A4A6A" }, fill: DARK_BG, color: WHITE, fontSize: 12, fontFace: BODY_FONT, rowH: 0.39, align: "center", valign: "middle" });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 20 – OVERDOSE & REVERSAL
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Overdose & Reversal (Naloxone)");
  s.addText("OPIOID OVERDOSE TRIAD", { x: 0.4, y: 1.06, w: 9.2, h: 0.35, fontSize: 15, bold: true, color: RED, fontFace: HEADING_FONT, margin: 0 });
  // triad boxes
  const triad = [
    ["Miosis\n(pinpoint pupils)", "1"],
    ["Respiratory\nDepression", "2"],
    ["Decreased\nConsciousness", "3"],
  ];
  triad.forEach((item, i) => {
    s.addShape(pres.ShapeType.rect, { x: 0.4 + i * 3.1, y: 1.44, w: 2.8, h: 0.95, fill: { color: RED }, line: { color: RED } });
    s.addText(item[0], { x: 0.4 + i * 3.1, y: 1.44, w: 2.8, h: 0.95, fontSize: 15, bold: true, color: WHITE, fontFace: HEADING_FONT, align: "center", valign: "middle", margin: 0 });
  });
  s.addText("Additional: cyanosis, bradycardia, hypotension, pulmonary edema, cardiac arrest", {
    x: 0.4, y: 2.42, w: 9.3, h: 0.35, fontSize: 12, color: SUBTEXT, fontFace: BODY_FONT, margin: 0, italic: true
  });

  s.addText("NALOXONE (Narcan) – Opioid Antagonist", { x: 0.4, y: 2.82, w: 9.2, h: 0.35, fontSize: 15, bold: true, color: ACCENT2, fontFace: HEADING_FONT, margin: 0 });
  const nxData = [
    [{ text: "Route", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Dose (Adults)", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Dose (Pediatric)", options: { bold: true, fill: ACCENT2, color: DARK_BG } },
     { text: "Notes", options: { bold: true, fill: ACCENT2, color: DARK_BG } }],
    [{ text: "IV" }, { text: "0.4–2 mg; repeat q2–3 min (max 10 mg)" }, { text: "0.01 mg/kg IV; repeat prn" }, { text: "Titrate; avoid precipitating acute withdrawal in dependent patients" }],
    [{ text: "IM/SC" }, { text: "0.4–2 mg" }, { text: "0.01 mg/kg" }, { text: "Slower onset than IV" }],
    [{ text: "Intranasal (IN)" }, { text: "4 mg IN; repeat in 2–3 min" }, { text: "0.1 mg/kg IN" }, { text: "Community setting (Narcan nasal spray)" }],
    [{ text: "Duration" }, { text: "30–90 min (shorter than morphine!)" }, { text: "Repeat dosing required" }, { text: "Monitor for re-narcotization after initial reversal" }],
  ];
  s.addTable(nxData, { x: 0.3, y: 3.2, w: 9.5, h: 2.2, border: { pt: 0.5, color: "2A4A6A" }, fill: MID_BG, color: WHITE, fontSize: 11.5, fontFace: BODY_FONT, rowH: 0.4, align: "center", valign: "middle" });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 21 – TOLERANCE, DEPENDENCE & WITHDRAWAL
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = midSlide(pres);
  slideTitle(s, "Tolerance, Dependence & Withdrawal");
  // Tolerance
  s.addText("TOLERANCE", { x: 0.4, y: 1.06, w: 3.0, h: 0.35, fontSize: 14, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Decreased drug effect with repeated dosing"),
    bullet("Develops to: analgesia, euphoria, sedation, respiratory depression, nausea"),
    bullet("Does NOT develop to: constipation, miosis"),
    bullet("Mechanisms: receptor desensitization, phosphorylation, internalization, G-protein uncoupling, downregulation"),
    bullet("Cross-tolerance within opioid class (rotation may be useful)"),
  ], { x: 0.4, y: 1.44, w: 4.5, h: 2.1, fontSize: 12.5, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });

  // Dependence
  s.addText("PHYSICAL DEPENDENCE", { x: 0.4, y: 3.58, w: 4.5, h: 0.35, fontSize: 14, bold: true, color: RED, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Physiologic adaptation – withdrawal on abrupt cessation or antagonist use"),
    bullet("NOT synonymous with addiction"),
    bullet("Withdrawal onset: 6–12 h after last dose (short-acting opioids)"),
    bullet("Taper dose by ≤10–20% per day to avoid severe withdrawal"),
  ], { x: 0.4, y: 3.95, w: 4.5, h: 1.5, fontSize: 12.5, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.2 });

  // Withdrawal symptoms box
  s.addShape(pres.ShapeType.rect, { x: 5.2, y: 1.06, w: 4.5, h: 4.45, fill: { color: "0A1520" }, line: { color: RED, width: 1.5 } });
  s.addText("WITHDRAWAL SIGNS & SYMPTOMS", { x: 5.2, y: 1.06, w: 4.5, h: 0.4, fontSize: 12, bold: true, color: RED, fontFace: HEADING_FONT, align: "center", margin: 0 });
  s.addText([
    bullet("Agitation, anxiety, dysphoria"),
    bullet("Hyperalgesia, myalgia, arthralgia"),
    bullet("Piloerection (gooseflesh), diaphoresis"),
    bullet("Mydriasis (dilated pupils)"),
    bullet("Lacrimation, rhinorrhea, yawning"),
    bullet("Nausea, vomiting, diarrhea, cramping"),
    bullet("Hypertension, tachycardia, hyperthermia"),
    bullet("Release of virtually all pituitary / adrenomedullary hormones"),
    bullet("Treatment: methadone/buprenorphine taper; clonidine (α₂-agonist) for autonomic symptoms; supportive care"),
  ], { x: 5.3, y: 1.5, w: 4.3, h: 4.0, fontSize: 12, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.15 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 22 – OPIOID USE DISORDER
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Opioid Use Disorder (OUD) & Safe Prescribing");
  s.addText([
    bullet("OUD: compulsive drug-seeking despite physical, emotional, or societal harm – NOT simply tolerance/dependence"),
    bullet("From 1999–2019: nearly 500,000 opioid overdose deaths in the US (prescription + illicit opioids)"),
    bullet("Cancer patients on long-term morphine develop tolerance and dependence but NOT necessarily OUD"),
    bullet("Risk factors: prior substance use disorder, mental health comorbidity, young age, high-dose/long-duration prescribing"),
  ], { x: 0.4, y: 1.05, w: 9.3, h: 2.0, fontSize: 13.5, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.25 });
  s.addText("SAFE PRESCRIBING PRINCIPLES", { x: 0.4, y: 3.05, w: 9.2, h: 0.38, fontSize: 15, bold: true, color: ACCENT, fontFace: HEADING_FONT, margin: 0 });
  s.addText([
    bullet("Use lowest effective dose for shortest duration"),
    bullet("Reassess pain regularly; taper and discontinue when appropriate"),
    bullet("Use multimodal analgesia (NSAIDs, acetaminophen, regional blocks) to reduce morphine requirements"),
    bullet("Prescription drug monitoring programs (PDMPs) and urine drug testing for chronic use"),
    bullet("Co-prescribe naloxone (Narcan) for patients on high-dose opioids or at overdose risk"),
    bullet("Avoid concurrent benzodiazepines when possible"),
    bullet("Use equianalgesic tables when rotating opioids; reduce dose by 25–50% due to incomplete cross-tolerance"),
  ], { x: 0.4, y: 3.46, w: 9.3, h: 2.0, fontSize: 13, color: WHITE, fontFace: BODY_FONT, lineSpacingMultiple: 1.15 });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 23 – SUMMARY CARD
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  slideTitle(s, "Quick Reference Summary – Morphine");
  const summaryData = [
    [{ text: "Category", options: { bold: true, fill: ACCENT, color: DARK_BG } },
     { text: "Key Information", options: { bold: true, fill: ACCENT, color: DARK_BG } }],
    [{ text: "Class / Receptor" }, { text: "Opioid analgesic; μ > κ, δ agonist; GPCR (Gi/Go)" }],
    [{ text: "Bioavailability" }, { text: "Oral 20–30% | IM/SC ~100% | Neuraxial: direct spinal action" }],
    [{ text: "Half-life" }, { text: "2–3 h (parent); M6G ~9 h; ↑ in renal failure" }],
    [{ text: "Adult IV dose (acute pain)" }, { text: "0.1–0.15 mg/kg IV loading; then q5–15 min titration" }],
    [{ text: "Adult PO dose (cancer pain)" }, { text: "5–15 mg q4h IR; 15 mg q12h ER (opioid-naive)" }],
    [{ text: "Epidural / IT dose" }, { text: "Epidural 2–5 mg; Intrathecal 0.1–0.3 mg (preservative-free)" }],
    [{ text: "Pediatric IV" }, { text: "0.05–0.1 mg/kg q2–4h; neonates 0.01–0.02 mg/kg q4–6h" }],
    [{ text: "Main ADRs" }, { text: "Respiratory depression, constipation, nausea, pruritus, urinary retention" }],
    [{ text: "Key contraindications" }, { text: "MAO inhibitors, severe respiratory depression, paralytic ileus" }],
    [{ text: "Reversal" }, { text: "Naloxone 0.4–2 mg IV (repeat q2–3 min); IN 4 mg" }],
    [{ text: "Equianalgesic" }, { text: "10 mg IV = 30 mg PO = 100 mcg fentanyl IV = 1.5 mg hydromorphone IV" }],
  ];
  s.addTable(summaryData, { x: 0.3, y: 1.06, w: 9.5, h: 4.4, border: { pt: 0.5, color: "2A4A6A" }, fill: MID_BG, color: WHITE, fontSize: 12, fontFace: BODY_FONT, rowH: 0.37, align: "left", valign: "middle" });
}

// ═══════════════════════════════════════════════════════════════════════════
// SLIDE 24 – CLOSING / REFERENCES
// ═══════════════════════════════════════════════════════════════════════════
{
  const s = darkSlide(pres);
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: ACCENT } });
  s.addText("REFERENCES", {
    x: 0.5, y: 0.4, w: 9, h: 0.5, fontSize: 28, bold: true, color: WHITE, fontFace: HEADING_FONT, margin: 0
  });
  s.addShape(pres.ShapeType.rect, { x: 0.5, y: 0.88, w: 5, h: 0.05, fill: { color: ACCENT } });
  const refs = [
    "Goodman & Gilman's The Pharmacological Basis of Therapeutics, 14th Edition – Chapter 23: Opioid Analgesics",
    "Miller's Anesthesia, 10th Edition – Chapter 22: Opioids; Chapter 16: Neuraxial Analgesia",
    "Barash, Cullen & Stoelting's Clinical Anesthesia, 9th Edition – Chapter 14: Pediatric Anesthesia",
    "Rosen's Emergency Medicine: Concepts and Clinical Practice, 9th Edition – Chapter 6: Analgesics",
    "Swanson's Family Medicine Review – Cancer Pain Management",
    "Harriet Lane Handbook, 23rd Edition – Opioid Tapering",
    "WHO Essential Medicines List – Morphine Sulfate",
  ];
  refs.forEach((ref, i) => {
    s.addText(`${i + 1}. ${ref}`, {
      x: 0.5, y: 1.05 + i * 0.6, w: 9.2, h: 0.52,
      fontSize: 12, color: i % 2 === 0 ? WHITE : LIGHT,
      fontFace: BODY_FONT, margin: 0
    });
  });
  s.addText("Prepared by Orris Medical AI • June 2026", {
    x: 0.5, y: 5.22, w: 9, h: 0.3, fontSize: 10, color: SUBTEXT, fontFace: BODY_FONT, margin: 0, italic: true
  });
}

// ─── WRITE FILE ─────────────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/morphine-pptx/Morphine_Pharmacology.pptx" })
  .then(() => console.log("Done: Morphine_Pharmacology.pptx"))
  .catch(e => { console.error(e); process.exit(1); });
Running Command

cd /home/daytona/workspace/morphine-pptx && node morphine.js 2>&1

Your presentation is ready!

Morphine Pharmacology

Presentation · PPTX


What's Inside (24 Slides)

The deck uses a deep navy + amber gold design and covers every major topic sourced directly from Goodman & Gilman 14e, Miller's Anesthesia 10e, Rosen's Emergency Medicine 9e, and Barash Clinical Anesthesia 9e:
SlideTopic
1Title slide
2Table of contents
3History & classification
4Chemistry & structure-activity relationships
5Mechanism of action (μ-receptor, GPCR pathways, sites of action)
6Pharmacokinetics – ADME (with M3G/M6G detail)
7Key PK parameters table
8CNS pharmacodynamics
9Systemic effects (CV, respiratory, GI, GU, endocrine)
10Clinical uses / indications
11Oral dosing – IR and ER tables (adults, elderly, pediatric)
12Parenteral dosing – IV, IM, SC tables (all age groups)
13Neuraxial dosing – epidural & intrathecal (preservative-free)
14PCA settings + continuous infusion doses
15Equianalgesic dose table (morphine vs. fentanyl, hydromorphone, oxycodone, etc.)
16Special populations (elderly, renal, hepatic, pediatric, pregnancy, obesity)
17Adverse effects table with management
18Contraindications, precautions, FDA Black Box Warning
19Drug interactions table
20Overdose triad + Naloxone dosing (IV/IM/IN)
21Tolerance, dependence & withdrawal
22Opioid use disorder & safe prescribing
23Quick reference summary card
24References

Create a dosing cheat sheet PDF for quick clinical reference

Reading File
Writing File

~/morphine-pptx/morphine_cheatsheet.py

from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.platypus import (
    SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer,
    HRFlowable, KeepTogether
)
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
from reportlab.platypus.flowables import BalancedColumns
from reportlab.pdfgen import canvas
from reportlab.lib.colors import HexColor
import io

# ── PALETTE ──────────────────────────────────────────────────────────────────
NAVY        = HexColor("#0D1B2A")
NAVY2       = HexColor("#1B2A3B")
AMBER       = HexColor("#E8A020")
AMBER_LIGHT = HexColor("#FDF0D5")
SKY         = HexColor("#3DA5D9")
SKY_LIGHT   = HexColor("#D6EEF8")
RED         = HexColor("#C0392B")
RED_LIGHT   = HexColor("#FDECEA")
GREEN       = HexColor("#1E7A3C")
GREEN_LIGHT = HexColor("#D6F0E0")
GREY_DARK   = HexColor("#4A4A5A")
GREY_MID    = HexColor("#7A8899")
GREY_LIGHT  = HexColor("#EEF2F6")
WHITE       = colors.white
BLACK       = colors.black

PAGE   = landscape(A4)
W, H   = PAGE   # 297 x 210 mm

# ── CANVAS-BASED DRAWING APPROACH ────────────────────────────────────────────
# We draw everything directly onto the canvas for pixel-perfect layout.

OUTPUT = "/home/daytona/workspace/morphine-pptx/Morphine_Dosing_CheatSheet.pdf"

c = canvas.Canvas(OUTPUT, pagesize=PAGE)
c.setTitle("Morphine Dosing Cheat Sheet")
c.setAuthor("Orris Medical")

# ── HELPERS ───────────────────────────────────────────────────────────────────
def rgb(h): return HexColor(h)

def rect_filled(c, x, y, w, h, fill, radius=0):
    c.setFillColor(fill)
    if radius:
        c.roundRect(x, y, w, h, radius, fill=1, stroke=0)
    else:
        c.rect(x, y, w, h, fill=1, stroke=0)

def rect_outline(c, x, y, w, h, stroke_col, lw=0.5, radius=0):
    c.setStrokeColor(stroke_col)
    c.setLineWidth(lw)
    if radius:
        c.roundRect(x, y, w, h, radius, fill=0, stroke=1)
    else:
        c.rect(x, y, w, h, fill=0, stroke=1)

def text(c, txt, x, y, font="Helvetica-Bold", size=8, color=BLACK, align="left"):
    c.setFont(font, size)
    c.setFillColor(color)
    if align == "center":
        c.drawCentredString(x, y, txt)
    elif align == "right":
        c.drawRightString(x, y, txt)
    else:
        c.drawString(x, y, txt)

def wrap_text(c, txt, x, y, max_w, font="Helvetica", size=7.5, color=BLACK, leading=10):
    """Very simple word-wrap for short strings."""
    from reportlab.pdfbase.pdfmetrics import stringWidth
    c.setFont(font, size)
    c.setFillColor(color)
    words = txt.split()
    line = ""
    cy = y
    for word in words:
        test = (line + " " + word).strip()
        if stringWidth(test, font, size) <= max_w:
            line = test
        else:
            c.drawString(x, cy, line)
            cy -= leading
            line = word
    if line:
        c.drawString(x, cy, line)
    return cy - leading  # return bottom y

def section_header(c, x, y, w, h, title, bg=NAVY, fg=WHITE, fsize=7.5):
    rect_filled(c, x, y, w, h, bg)
    text(c, title, x + w/2, y + h/2 - fsize*0.35, "Helvetica-Bold", fsize, fg, "center")

def cell(c, txt, x, y, w, h, bg=WHITE, fg=BLACK, font="Helvetica", fsize=7, bold=False,
         align="center", pad=1.5*mm):
    rect_filled(c, x, y, w, h, bg)
    fn = "Helvetica-Bold" if bold else font
    c.setFont(fn, fsize)
    c.setFillColor(fg)
    cx = x + w/2 if align == "center" else x + pad
    cy_base = y + h/2 - fsize * 0.35
    if align == "center":
        c.drawCentredString(cx, cy_base, txt)
    else:
        c.drawString(cx, cy_base, txt)

def grid_outline(c, x, y, w, h, col=GREY_MID, lw=0.3):
    rect_outline(c, x, y, w, h, col, lw)

# ── LAYOUT CONSTANTS ─────────────────────────────────────────────────────────
MAR   = 6*mm        # margin
CW    = W - 2*MAR   # content width
CH    = H - 2*MAR   # content height
X0    = MAR
Y_TOP = H - MAR

# ─── PAGE BACKGROUND ─────────────────────────────────────────────────────────
rect_filled(c, 0, 0, W, H, NAVY)
# white content area
rect_filled(c, X0-1*mm, MAR-1*mm, CW+2*mm, CH+2*mm, WHITE)

# ── HEADER BAR ────────────────────────────────────────────────────────────────
hdr_h = 11*mm
rect_filled(c, X0-1*mm, Y_TOP - hdr_h + 1*mm, CW+2*mm, hdr_h, NAVY)
# accent line
rect_filled(c, X0-1*mm, Y_TOP - hdr_h + 1*mm, 3*mm, hdr_h, AMBER)

text(c, "MORPHINE", X0 + 5*mm, Y_TOP - 6.5*mm, "Helvetica-Bold", 16, WHITE)
text(c, "Dosing & Clinical Quick Reference", X0 + 46*mm, Y_TOP - 5.5*mm, "Helvetica", 8, AMBER_LIGHT)
text(c, "Goodman & Gilman 14e  ·  Miller's Anesthesia 10e  ·  Rosen's Emergency Medicine 9e  ·  Barash 9e",
     X0 + 5*mm, Y_TOP - 10*mm, "Helvetica-Oblique", 6, GREY_MID)
text(c, "Orris Medical · June 2026", W - MAR - 1*mm, Y_TOP - 7*mm, "Helvetica", 6.5, GREY_MID, "right")

# Starting y below header
Y = Y_TOP - hdr_h - 1.5*mm

# ═══════════════════════════════════════════════════════════════════════════════
# COLUMN LAYOUT  (3 columns)
# Left (col1): ~100mm  Mid (col2): ~93mm  Right (col3): ~90mm
# ═══════════════════════════════════════════════════════════════════════════════
GAP   = 2.5*mm
COL1W = 101*mm
COL2W = 94*mm
COL3W = CW - COL1W - COL2W - 2*GAP
X1    = X0
X2    = X1 + COL1W + GAP
X3    = X2 + COL2W + GAP

# ═══════════════════════════════════════════════════════════════════════════════
# ── COL 1 ─ LEFT ──────────────────────────────────────────────────────────────
# ═══════════════════════════════════════════════════════════════════════════════
cy1 = Y

# ─── PHARMACOKINETIC SNAPSHOT ───────────────────────────────────────────────
pk_rows = [
    ("Bioavailability",  "PO 20–30%  |  IM/SC ~100%  |  Neuraxial: direct"),
    ("Protein binding",  "20–40% (albumin)"),
    ("Lipid solubility", "LOW (pKa 8.0; only 10–20% un-ionized at pH 7.4)"),
    ("Vd",               "3–5 L/kg"),
    ("t½ parent",        "2–3 hours"),
    ("t½ M6G",           "~9 h (↑ in renal failure)"),
    ("Onset IV",         "5 min (peak 15–20 min)"),
    ("Onset IM/SC",      "10–15 min"),
    ("Onset PO",         "30–45 min"),
    ("Duration IR",      "3–6 hours"),
    ("Duration ER",      "8–24 hours"),
    ("Metabolism",       "Hepatic glucuronidation (UGT2B7)"),
    ("M3G (~60%)",       "Inactive/excitatory – NO analgesia; CNS excitation"),
    ("M6G (~10%)",       "More potent μ-agonist; major active metabolite oral"),
    ("Excretion",        "Renal (>90% as glucuronides within 24 h)"),
]
pk_lbl_w  = 26*mm
pk_val_w  = COL1W - pk_lbl_w
pk_row_h  = 4.2*mm
pk_total  = len(pk_rows) * pk_row_h + 5*mm   # header + rows

section_header(c, X1, cy1 - pk_total, COL1W, 5*mm, "PHARMACOKINETICS", NAVY, WHITE, 7.5)
for i, (lbl, val) in enumerate(pk_rows):
    ry = cy1 - pk_total + (len(pk_rows) - 1 - i) * pk_row_h
    bg = GREY_LIGHT if i % 2 == 0 else WHITE
    cell(c, lbl, X1, ry, pk_lbl_w, pk_row_h, bg=NAVY2, fg=AMBER_LIGHT, font="Helvetica-Bold", fsize=6.5, align="left")
    cell(c, val, X1 + pk_lbl_w, ry, pk_val_w, pk_row_h, bg=bg, fg=GREY_DARK, font="Helvetica", fsize=6.5, align="left")
    grid_outline(c, X1, ry, COL1W, pk_row_h)
grid_outline(c, X1, cy1 - pk_total, COL1W, pk_total, NAVY, 0.8)
cy1 -= (pk_total + 2.5*mm)

# ─── MECHANISM OF ACTION ────────────────────────────────────────────────────
moa_lines = [
    "μ (mu) > κ, δ opioid receptor agonist  ·  Gi/Go GPCR",
    "↓ cAMP  ·  Opens K⁺ channels (hyperpolarisation)",
    "Closes Ca²⁺ channels → ↓ neurotransmitter release",
    "Sites: PAG (supraspinal), dorsal horn (spinal), periphery",
    "Miosis: Edinger-Westphal nucleus (CN III) – no tolerance",
]
moa_h = 5*mm + len(moa_lines)*4*mm
section_header(c, X1, cy1 - moa_h, COL1W, 5*mm, "MECHANISM OF ACTION", SKY, WHITE, 7.5)
for i, ln in enumerate(moa_lines):
    ry = cy1 - moa_h + (len(moa_lines) - 1 - i)*4*mm
    bg = SKY_LIGHT if i % 2 == 0 else WHITE
    cell(c, "• " + ln, X1, ry, COL1W, 4*mm, bg=bg, fg=GREY_DARK, font="Helvetica", fsize=6.5, align="left")
    grid_outline(c, X1, ry, COL1W, 4*mm)
grid_outline(c, X1, cy1 - moa_h, COL1W, moa_h, SKY, 0.8)
cy1 -= (moa_h + 2.5*mm)

# ─── KEY ADVERSE EFFECTS ────────────────────────────────────────────────────
adr_rows = [
    ("Respiratory depression",  "MOST DANGEROUS · dose-dependent · ↓ CO₂ sensitivity",  RED),
    ("Constipation",            "NO tolerance develops · give stimulant laxative routinely", RED),
    ("Nausea / Vomiting",       "CTZ stimulation · worse on ambulation · antiemetics",    AMBER),
    ("Sedation",                "Potentiated by CNS depressants / benzodiazepines",       AMBER),
    ("Hypotension",             "Histamine release + venodilation · caution hypovolaemia",AMBER),
    ("Urinary retention",       "↑ bladder sphincter tone · catheterise if needed",       AMBER),
    ("Pruritus (neuraxial)",    "Ondansetron or low-dose naloxone for treatment",         SKY),
    ("Miosis",                  "Diagnostic marker – no tolerance",                       SKY),
    ("M3G toxicity (renal)",    "Myoclonus, seizures, delirium · reduce dose or rotate",  RED),
]
adr_lbl_w = 31*mm
adr_val_w = COL1W - adr_lbl_w
adr_row_h = 4*mm
adr_total = 5*mm + len(adr_rows)*adr_row_h
section_header(c, X1, cy1 - adr_total, COL1W, 5*mm, "KEY ADVERSE EFFECTS", RED, WHITE, 7.5)
for i, (eff, mgmt, col) in enumerate(adr_rows):
    ry = cy1 - adr_total + (len(adr_rows) - 1 - i)*adr_row_h
    rect_filled(c, X1, ry, adr_lbl_w, adr_row_h, col)
    rect_outline(c, X1, ry, adr_lbl_w, adr_row_h, WHITE, 0.2)
    c.setFont("Helvetica-Bold", 6.3)
    c.setFillColor(WHITE)
    c.drawString(X1 + 1.5*mm, ry + adr_row_h/2 - 2.2, eff)
    bg = GREY_LIGHT if i % 2 == 0 else WHITE
    cell(c, mgmt, X1 + adr_lbl_w, ry, adr_val_w, adr_row_h, bg=bg, fg=GREY_DARK, font="Helvetica", fsize=6.2, align="left")
    grid_outline(c, X1, ry, COL1W, adr_row_h)
grid_outline(c, X1, cy1 - adr_total, COL1W, adr_total, RED, 0.8)
cy1 -= (adr_total + 2.5*mm)

# ═══════════════════════════════════════════════════════════════════════════════
# ── COL 2 ─ MIDDLE ────────────────────────────────────────────────────────────
# ═══════════════════════════════════════════════════════════════════════════════
cy2 = Y

# ─── ORAL DOSING ────────────────────────────────────────────────────────────
def dose_table(c, x, start_y, col_w, header, col_headers, rows, row_h=4.5*mm, hdr_col=NAVY, accent=AMBER):
    n_cols  = len(col_headers)
    col_ws  = [col_w * f for f in ([0.26, 0.22, 0.22, 0.30] if n_cols == 4 else
                                    [0.28, 0.26, 0.46] if n_cols == 3 else
                                    [0.25, 0.35, 0.40])]
    total_h = 5*mm + 5*mm + len(rows)*row_h   # section hdr + col hdr + rows
    section_header(c, x, start_y - total_h, col_w, 5*mm, header, hdr_col, WHITE, 7.5)
    # column headers
    cx = x
    for j, (ch, cw) in enumerate(zip(col_headers, col_ws)):
        cell(c, ch, cx, start_y - total_h + 5*mm, cw, 5*mm, bg=accent, fg=NAVY, font="Helvetica-Bold", fsize=6.5)
        grid_outline(c, cx, start_y - total_h + 5*mm, cw, 5*mm)
        cx += cw
    # data rows
    for i, row in enumerate(rows):
        ry = start_y - total_h + 5*mm + 5*mm + i*row_h
        cx = x
        for j, (val, cw) in enumerate(zip(row, col_ws)):
            bg = GREY_LIGHT if i % 2 == 0 else WHITE
            is_lbl = (j == 0)
            cell(c, val, cx, ry, cw, row_h, bg=NAVY2 if is_lbl else bg,
                 fg=AMBER_LIGHT if is_lbl else GREY_DARK,
                 font="Helvetica-Bold" if is_lbl else "Helvetica", fsize=6.5, align="left")
            grid_outline(c, cx, ry, cw, row_h)
            cx += cw
    grid_outline(c, x, start_y - total_h, col_w, total_h, hdr_col, 0.8)
    return start_y - total_h - 2.5*mm

# ORAL IR
cy2 = dose_table(c, X2, cy2, COL2W,
    "ORAL – IMMEDIATE RELEASE (q4h)",
    ["Population", "Dose", "Frequency", "Notes"],
    [
        ("Adult (opioid-naive)",  "5–15 mg",    "q4h",   "30–60 mg/day starting dose"),
        ("Adult (severe pain)",   "10–30 mg",   "q4h",   "Titrate; monitor RR"),
        ("Elderly (≥65 yr)",      "2.5–5 mg",   "q4–6h", "Start low; ↑ ADR risk"),
        ("Child (>6 mo)",         "0.2–0.5 mg/kg","q4–6h","Max 15–20 mg/dose"),
    ], row_h=4.3*mm, hdr_col=NAVY, accent=AMBER)

# ORAL ER
cy2 = dose_table(c, X2, cy2, COL2W,
    "ORAL – EXTENDED RELEASE (MS Contin) – Do NOT crush",
    ["Population", "Starting Dose", "Notes"],
    [
        ("Opioid-naive adult",   "15 mg q12h",    "Do not crush/chew; add IR breakthrough"),
        ("Cancer pain (convert)","24-hr IR ÷ 2",  "Give as q12h ER; IR for breakthrough"),
        ("Cancer (Swanson)",     "30–60 mg/day",  "Titrate IR × 1 wk → switch to ER"),
    ], row_h=4.3*mm, hdr_col=NAVY, accent=AMBER)

# IV TABLE
cy2 = dose_table(c, X2, cy2, COL2W,
    "INTRAVENOUS (IV) – Onset 5 min; Peak 15–20 min",
    ["Indication", "Dose", "Notes"],
    [
        ("Acute pain (adults)",  "0.1–0.15 mg/kg load; ½ dose q5–15 min", "Titrate to effect; onset 5 min"),
        ("Post-op PRN",          "2–5 mg q2–4h",       "PCA preferred for sustained need"),
        ("ICU infusion",         "2–10 mg/h",           "Titrate to CPOT ≤2 / NRS ≤3"),
        ("Pediatric (>6 mo)",    "0.05–0.1 mg/kg",      "q2–4h; dilute; SpO₂ monitor"),
        ("Neonate (premature)",  "0.01–0.02 mg/kg",     "q4–6h; ↓ clearance → accumulation risk"),
    ], row_h=4.3*mm, hdr_col=SKY, accent=SKY)

# IM/SC TABLE
cy2 = dose_table(c, X2, cy2, COL2W,
    "IM / SUBCUTANEOUS (SC)",
    ["Route", "Adult", "Pediatric"],
    [
        ("IM",  "5–20 mg q4h",  "0.1–0.2 mg/kg q4h  (unpredictable absorption)"),
        ("SC",  "5–15 mg q4h",  "0.1–0.15 mg/kg q4h  (palliative SC infusion)"),
    ], row_h=4.3*mm, hdr_col=GREY_DARK, accent=GREY_MID)

# PCA TABLE
cy2 = dose_table(c, X2, cy2, COL2W,
    "PCA – IV MORPHINE",
    ["Setting", "Typical", "Range"],
    [
        ("Demand (bolus)",   "1 mg",        "0.5–2.5 mg"),
        ("Lockout interval", "6 min",       "5–10 min"),
        ("Basal rate",       "0 mg/h",      "0–2 mg/h (opioid-tolerant)"),
        ("1-hour limit",     "10 mg",       "Per protocol"),
    ], row_h=4.3*mm, hdr_col=GREEN, accent=GREEN)

# ═══════════════════════════════════════════════════════════════════════════════
# ── COL 3 ─ RIGHT ─────────────────────────────────────────────────────────────
# ═══════════════════════════════════════════════════════════════════════════════
cy3 = Y

# NEURAXIAL
neuraxial_rows = [
    ("Epidural post-op",         "2–5 mg",           "q12–24h"),
    ("Epidural – labour",        "2–3 mg",           "Single dose"),
    ("Epidural – C/S",           "3–5 mg",           "Single dose"),
    ("DepoDur (Epidural ER)",     "10–20 mg",         "Single dose"),
    ("Intrathecal post-op",      "0.1–0.3 mg",       "Single dose"),
    ("Intrathecal – C/S",        "0.1–0.2 mg",       "Single dose"),
]
nr_h = 4.3*mm
nr_col_ws = [COL3W*0.38, COL3W*0.32, COL3W*0.30]
nr_total  = 5*mm + 5*mm + len(neuraxial_rows)*nr_h
section_header(c, X3, cy3 - nr_total, COL3W, 5*mm,
               "NEURAXIAL – Preservative-Free ONLY", NAVY, WHITE, 7.5)
# col headers
cx = X3
for j, (ch, cw) in enumerate(zip(["Indication","Dose","Frequency"], nr_col_ws)):
    cell(c, ch, cx, cy3 - nr_total + 5*mm, cw, 5*mm, bg=AMBER, fg=NAVY, font="Helvetica-Bold", fsize=6.5)
    grid_outline(c, cx, cy3 - nr_total + 5*mm, cw, 5*mm)
    cx += cw
for i, (ind, dose, freq) in enumerate(neuraxial_rows):
    ry = cy3 - nr_total + 5*mm + 5*mm + i*nr_h
    cx = X3
    for j, (val, cw) in enumerate(zip([ind, dose, freq], nr_col_ws)):
        bg = GREY_LIGHT if i % 2 == 0 else WHITE
        is_lbl = (j == 0)
        cell(c, val, cx, ry, cw, nr_h, bg=NAVY2 if is_lbl else bg,
             fg=AMBER_LIGHT if is_lbl else GREY_DARK,
             font="Helvetica-Bold" if is_lbl else "Helvetica", fsize=6.5, align="left")
        grid_outline(c, cx, ry, cw, nr_h)
        cx += cw
# warning bar
warn_y = cy3 - nr_total + 5*mm + 5*mm + len(neuraxial_rows)*nr_h
# It's at the top of the table actually (rows drawn bottom-up)
# Let's add warning at the very bottom
warn_y = cy3 - nr_total
rect_filled(c, X3, warn_y - 4.5*mm, COL3W, 4.5*mm, RED)
text(c, "⚠ Monitor respiratory depression for 12–24 h post neuraxial morphine",
     X3 + COL3W/2, warn_y - 3.2*mm, "Helvetica-Bold", 6.3, WHITE, "center")
grid_outline(c, X3, cy3 - nr_total, COL3W, nr_total, NAVY, 0.8)
cy3 -= (nr_total + 4.5*mm + 3*mm)

# EQUIANALGESIC TABLE
eq_rows = [
    ("MORPHINE",          "10 mg",    "30 mg",   "Reference standard"),
    ("Hydromorphone",     "1.5 mg",   "7.5 mg",  "~7× more potent IV"),
    ("Oxycodone",         "—",        "20–30 mg","No parenteral (most)"),
    ("Fentanyl",          "100 mcg",  "—",       "~100× more potent"),
    ("Codeine",           "130 mg",   "200 mg",  "CYP2D6 prodrug"),
    ("Meperidine",        "75–100 mg","300 mg",  "Not for chronic use"),
    ("Tramadol",          "—",        "150 mg",  "Partial opioid"),
    ("Oxymorphone",       "1 mg",     "10 mg",   "~10× PO morphine"),
]
eq_col_ws = [COL3W*0.27, COL3W*0.19, COL3W*0.18, COL3W*0.36]
eq_h      = 4.3*mm
eq_total  = 5*mm + 5*mm + len(eq_rows)*eq_h
section_header(c, X3, cy3 - eq_total, COL3W, 5*mm,
               "EQUIANALGESIC TABLE (equiv. to Morphine 10 mg IV)", RED, WHITE, 7.5)
cx = X3
for j, (ch, cw) in enumerate(zip(["Opioid","IV/IM","PO","Notes"], eq_col_ws)):
    cell(c, ch, cx, cy3 - eq_total + 5*mm, cw, 5*mm, bg=RED, fg=WHITE, font="Helvetica-Bold", fsize=6.5)
    grid_outline(c, cx, cy3 - eq_total + 5*mm, cw, 5*mm)
    cx += cw
for i, row in enumerate(eq_rows):
    ry = cy3 - eq_total + 5*mm + 5*mm + i*eq_h
    cx = X3
    for j, (val, cw) in enumerate(zip(row, eq_col_ws)):
        bg_is_morphine = (i == 0)
        if j == 0:
            bg2 = AMBER if bg_is_morphine else NAVY2
            fg2 = NAVY if bg_is_morphine else AMBER_LIGHT
        else:
            bg2 = AMBER_LIGHT if bg_is_morphine else (GREY_LIGHT if i % 2 == 0 else WHITE)
            fg2 = NAVY if bg_is_morphine else GREY_DARK
        cell(c, val, cx, ry, cw, eq_h, bg=bg2, fg=fg2,
             font="Helvetica-Bold" if j == 0 else "Helvetica", fsize=6.5, align="left")
        grid_outline(c, cx, ry, cw, eq_h)
        cx += cw
grid_outline(c, X3, cy3 - eq_total, COL3W, eq_total, RED, 0.8)
cy3 -= (eq_total + 2.5*mm)

# SPECIAL POPULATIONS
sp_rows = [
    ("Elderly ≥65 yr",     "Start at 25–50% usual adult dose; ↑ duration of action; ↑ ADR risk"),
    ("Renal impairment",   "Reduce dose + extend interval; M6G accumulates → prolong resp depression"),
    ("Hepatic failure",    "↑ Bioavailability; reduce dose ~50%; titrate slowly"),
    ("Neonate (prem)",     "0.01–0.02 mg/kg IV q4–6h; direct correlate with gestational age"),
    ("Infant/child",       "0.05–0.1 mg/kg IV q2–4h  |  0.2–0.5 mg/kg PO q4–6h"),
    ("Pregnancy",          "Crosses placenta; NOWS with chronic use; lowest dose + duration"),
    ("Obesity",            "Use ideal body weight (IBW) for initial dosing calculations"),
]
sp_h       = 4.3*mm
sp_lbl_w   = COL3W * 0.33
sp_val_w   = COL3W - sp_lbl_w
sp_total   = 5*mm + len(sp_rows)*sp_h
section_header(c, X3, cy3 - sp_total, COL3W, 5*mm,
               "SPECIAL POPULATIONS", GREEN, WHITE, 7.5)
for i, (pop, note) in enumerate(sp_rows):
    ry = cy3 - sp_total + (len(sp_rows) - 1 - i)*sp_h
    cell(c, pop, X3, ry, sp_lbl_w, sp_h, bg=GREEN, fg=WHITE, font="Helvetica-Bold", fsize=6.5, align="left")
    bg = GREEN_LIGHT if i % 2 == 0 else WHITE
    cell(c, note, X3 + sp_lbl_w, ry, sp_val_w, sp_h, bg=bg, fg=GREY_DARK, font="Helvetica", fsize=6.2, align="left")
    grid_outline(c, X3, ry, COL3W, sp_h)
grid_outline(c, X3, cy3 - sp_total, COL3W, sp_total, GREEN, 0.8)
cy3 -= (sp_total + 2.5*mm)

# OVERDOSE + REVERSAL
od_rows = [
    ("Triad",           "Miosis  ·  Respiratory depression  ·  ↓ Consciousness + cyanosis, bradycardia"),
    ("Naloxone IV",     "0.4–2 mg IV; repeat q2–3 min (max 10 mg); Peds: 0.01 mg/kg IV"),
    ("Naloxone IN",     "4 mg intranasal; repeat 2–3 min; Peds: 0.1 mg/kg  (Narcan nasal)"),
    ("Naloxone IM/SC",  "0.4–2 mg; slower onset than IV"),
    ("Duration warning","Naloxone t½ < morphine → re-narcotisation; repeat dosing / infusion may be needed"),
    ("Contraindications","MAO inhibitors (14 days) · Severe respiratory depression · Paralytic ileus"),
]
od_lbl_w = COL3W * 0.28
od_val_w = COL3W - od_lbl_w
od_h     = 4.3*mm
od_total = 5*mm + len(od_rows)*od_h
section_header(c, X3, cy3 - od_total, COL3W, 5*mm,
               "OVERDOSE TRIAD & REVERSAL (NALOXONE)", RED, WHITE, 7.5)
for i, (lbl, val) in enumerate(od_rows):
    ry = cy3 - od_total + (len(od_rows) - 1 - i)*od_h
    col = RED if (lbl == "Triad" or "Contraind" in lbl) else (AMBER if "Naloxone" in lbl else GREY_DARK)
    cell(c, lbl, X3, ry, od_lbl_w, od_h, bg=col, fg=WHITE, font="Helvetica-Bold", fsize=6.5, align="left")
    bg = RED_LIGHT if (lbl == "Triad" or "Contraind" in lbl) else (AMBER_LIGHT if "Naloxone" in lbl else (GREY_LIGHT if i % 2 == 0 else WHITE))
    cell(c, val, X3 + od_lbl_w, ry, od_val_w, od_h, bg=bg, fg=GREY_DARK, font="Helvetica", fsize=6.2, align="left")
    grid_outline(c, X3, ry, COL3W, od_h)
grid_outline(c, X3, cy3 - od_total, COL3W, od_total, RED, 0.8)
cy3 -= (od_total + 2.5*mm)

# ─── FOOTER ──────────────────────────────────────────────────────────────────
foot_y = MAR - 1*mm
rect_filled(c, X0-1*mm, foot_y, CW+2*mm, 5.5*mm, NAVY)
text(c, "FOR CLINICAL REFERENCE ONLY – Verify all doses against current institutional guidelines and patient-specific factors. Not a substitute for clinical judgment.",
     W/2, foot_y + 1.8*mm, "Helvetica-Oblique", 6, GREY_MID, "center")

c.save()
print("PDF created:", OUTPUT)
Running Command

cd /home/daytona/workspace/morphine-pptx && python morphine_cheatsheet.py 2>&1

Your cheat sheet is ready:

Morphine Dosing CheatSheet

PDF Document · PDF


What's on the sheet

Single-page A4 landscape - designed for printing and laminating. Three columns, color-coded sections:
ColumnSections
Left (navy/amber)Pharmacokinetics snapshot · Mechanism of action · Key adverse effects
Middle (multi-color)Oral IR dosing · Oral ER dosing · IV dosing · IM/SC dosing · PCA settings
Right (red/green)Neuraxial (epidural/intrathecal) · Equianalgesic table · Special populations · Overdose triad + Naloxone reversal doses
Color coding:
  • 🔴 Red = danger/warnings/overdose/reversal
  • 🟡 Amber = oral/PO dosing
  • 🔵 Blue = IV/parenteral
  • 🟢 Green = special populations
  • 🔷 Navy = pharmacokinetics/mechanism
This is a shared conversation. Sign in to Orris to start your own chat.