1 page cheat sheet for each given topics . Refer davidson , harrison, archith baloor . 1. Paracetamol 2. Aspirin 3. TCA 4. Digoxin 5. Lithium 6. Benzodiazapenes 7. Opiods

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
All 7 cheat sheets are ready. Here's a quick orientation guide to what's included:

What's Covered in Each Cheat Sheet

#DrugKey Antidote"Don't Miss" Point
1ParacetamolNAC (3-bag IV)4 stages; Rumack nomogram at 4 hrs; King's criteria for transplant
2AspirinNaHCO3 + HDBiphasic ABG (resp alkalosis → metabolic acidosis); ion trapping
3TCANaHCO3 bolusQRS >100 ms = danger; aVR R-wave; AVOID flumazenil + phenytoin
4DigoxinDigoxin Fab (Digibind)Any arrhythmia possible; Fab dose formula; AVOID Ca2+ in acute OD
5LithiumHaemodialysisCharcoal useless; post-HD rebound at 6-12 hrs; SILENT syndrome
6BenzodiazepinesFlumazenil (with caution)Rarely fatal alone; flumazenil CI with TCAs and BZD dependence
7OpioidsNaloxone ± infusionClassic triad: miosis + RD + coma; re-narcotization risk; methadone needs infusion
All content cross-referenced from Archith Baloor's Forensic Medicine & Toxicology (36th Ed.), Harrison's 22E, and Davidson's Principles.

Can you give it to me as document. Make it eye catchy if you can

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null && ls /home/daytona/skills/docx/scripts/office/ 2>/dev/null

Running Command

mkdir -p /home/daytona/workspace/toxicology-cheatsheets && node -e "require('docx'); console.log('docx ok')"

Writing File

~/toxicology-cheatsheets/generate.js

const {
  Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
  AlignmentType, HeadingLevel, BorderStyle, WidthType, ShadingType,
  VerticalAlign, PageBreak, PageOrientation, convertInchesToTwip,
  Header, Footer, PageNumber, NumberFormat
} = require('docx');
const fs = require('fs');

// Color palette
const COLORS = {
  paracetamol:  { header: 'F6C026', light: 'FFF8E1', accent: 'E65100' },
  aspirin:      { header: 'E55A2B', light: 'FBE9E7', accent: 'BF360C' },
  tca:          { header: '3F6BB5', light: 'E3F0FF', accent: '1A237E' },
  digoxin:      { header: '2E8B57', light: 'E8F5E9', accent: '1B5E20' },
  lithium:      { header: '7C4DBA', light: 'F3E5F5', accent: '4A148C' },
  benzo:        { header: '0097A7', light: 'E0F7FA', accent: '006064' },
  opioid:       { header: '8D4E4E', light: 'FDECEA', accent: '4E342E' },
};

const WHITE = 'FFFFFF';
const DARK  = '212121';
const SUBHEAD_BG = 'ECEFF1';

function border(color = '000000', size = 6) {
  return { style: BorderStyle.SINGLE, size, color };
}
function noBorder() {
  return { style: BorderStyle.NONE, size: 0, color: 'FFFFFF' };
}

// ─── Helper: big colored title cell ───────────────────────────────────────────
function titleCell(text, emoji, bgColor, colspan = 2) {
  return new TableCell({
    columnSpan: colspan,
    shading: { type: ShadingType.SOLID, color: bgColor },
    borders: { top: noBorder(), bottom: border(DARK,8), left: noBorder(), right: noBorder() },
    verticalAlign: VerticalAlign.CENTER,
    margins: { top: 120, bottom: 120, left: 200, right: 200 },
    children: [
      new Paragraph({
        alignment: AlignmentType.CENTER,
        children: [
          new TextRun({ text: emoji + '  ' + text, bold: true, size: 36, color: WHITE, font: 'Calibri' })
        ]
      })
    ]
  });
}

// ─── Helper: section sub-header ───────────────────────────────────────────────
function sectionHeader(text, bgColor, colspan = 2) {
  return new TableRow({
    children: [
      new TableCell({
        columnSpan: colspan,
        shading: { type: ShadingType.SOLID, color: bgColor },
        borders: { top: border(bgColor,4), bottom: border(bgColor,4), left: noBorder(), right: noBorder() },
        margins: { top: 60, bottom: 60, left: 160, right: 100 },
        children: [
          new Paragraph({
            children: [
              new TextRun({ text: '  ' + text, bold: true, size: 20, color: WHITE, font: 'Calibri' })
            ]
          })
        ]
      })
    ]
  });
}

// ─── Helper: label + value row ────────────────────────────────────────────────
function kvRow(label, value, lightBg, idx = 0) {
  const bg = idx % 2 === 0 ? lightBg : WHITE;
  return new TableRow({
    children: [
      new TableCell({
        width: { size: 2800, type: WidthType.DXA },
        shading: { type: ShadingType.SOLID, color: bg },
        borders: { top: border('DDDDDD',3), bottom: border('DDDDDD',3), left: noBorder(), right: border('CCCCCC',4) },
        margins: { top: 50, bottom: 50, left: 160, right: 80 },
        children: [new Paragraph({ children: [new TextRun({ text: label, bold: true, size: 18, color: DARK, font: 'Calibri' })] })]
      }),
      new TableCell({
        shading: { type: ShadingType.SOLID, color: bg },
        borders: { top: border('DDDDDD',3), bottom: border('DDDDDD',3), left: noBorder(), right: noBorder() },
        margins: { top: 50, bottom: 50, left: 120, right: 100 },
        children: [new Paragraph({ children: [new TextRun({ text: value, size: 18, color: DARK, font: 'Calibri' })] })]
      })
    ]
  });
}

// ─── Helper: build a mini-table ────────────────────────────────────────────────
function miniTable(headers, rows, accentColor, lightBg) {
  const headerRow = new TableRow({
    tableHeader: true,
    children: headers.map((h, i) => new TableCell({
      shading: { type: ShadingType.SOLID, color: accentColor },
      borders: { top: noBorder(), bottom: border(DARK,4), left: noBorder(), right: i < headers.length-1 ? border(WHITE,3) : noBorder() },
      margins: { top: 50, bottom: 50, left: 100, right: 100 },
      children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: h, bold: true, size: 17, color: WHITE, font: 'Calibri' })] })]
    }))
  });
  const dataRows = rows.map((row, ri) => new TableRow({
    children: row.map((cell, ci) => new TableCell({
      shading: { type: ShadingType.SOLID, color: ri % 2 === 0 ? lightBg : WHITE },
      borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: ci < row.length-1 ? border('CCCCCC',3) : noBorder() },
      margins: { top: 40, bottom: 40, left: 100, right: 100 },
      children: [new Paragraph({ children: [new TextRun({ text: cell, size: 17, color: DARK, font: 'Calibri' })] })]
    }))
  }));
  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder(), insideH: noBorder(), insideV: noBorder() },
    rows: [headerRow, ...dataRows]
  });
}

// ─── Helper: bullet paragraph ─────────────────────────────────────────────────
function bullet(text, color = DARK, bold = false) {
  return new Paragraph({
    indent: { left: 200, hanging: 200 },
    children: [
      new TextRun({ text: '• ', bold: true, size: 18, color, font: 'Calibri' }),
      new TextRun({ text, size: 18, color: DARK, bold, font: 'Calibri' })
    ]
  });
}
function subbullet(text) {
  return new Paragraph({
    indent: { left: 420, hanging: 200 },
    children: [
      new TextRun({ text: '◦ ', size: 17, color: '888888', font: 'Calibri' }),
      new TextRun({ text, size: 17, color: DARK, font: 'Calibri' })
    ]
  });
}
function plain(text, bold = false, size = 18, color = DARK) {
  return new Paragraph({ children: [new TextRun({ text, bold, size, color, font: 'Calibri' })] });
}
function spacer() { return new Paragraph({ children: [new TextRun({ text: '' })] }); }

// ─── Helper: warning box ──────────────────────────────────────────────────────
function warningBox(lines, bgColor = 'FFF3CD', borderColor = 'F9A825') {
  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    borders: { top: border(borderColor,8), bottom: border(borderColor,8), left: border(borderColor,10), right: border(borderColor,8), insideH: noBorder(), insideV: noBorder() },
    rows: [new TableRow({
      children: [new TableCell({
        shading: { type: ShadingType.SOLID, color: bgColor },
        margins: { top: 60, bottom: 60, left: 160, right: 100 },
        children: lines.map(l => new Paragraph({ children: [new TextRun({ text: l, size: 18, color: DARK, font: 'Calibri', bold: l.startsWith('⚠') || l.startsWith('✅') })] }))
      })]
    })]
  });
}

// ─── Build a full cheat-sheet section ─────────────────────────────────────────
function buildSheet(drug) {
  switch(drug) {

    // ════════════════════════════════════════════════════════════════════════
    case 'paracetamol': {
      const c = COLORS.paracetamol;
      return [
        new Table({
          width: { size: 100, type: WidthType.PERCENTAGE },
          borders: { top: border(c.header,8), bottom: border(c.header,8), left: border(c.header,8), right: border(c.header,8), insideH: noBorder(), insideV: noBorder() },
          rows: [
            new TableRow({ children: [titleCell('PARACETAMOL POISONING', '🟡', c.header)] }),
            sectionHeader('TOXIC DOSE', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Category','Adults','Children'],
                [
                  ['Therapeutic','500–1000 mg/dose (max 4 g/day)','10–15 mg/kg/dose'],
                  ['Toxic','≥ 150 mg/kg single dose','150–200 mg/kg'],
                  ['Lethal','> 350 mg/kg','> 250–350 mg/kg'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('MECHANISM', c.accent),
            ...['Normal: 90% → glucuronide/sulfate conjugation (SAFE)', '10% via CYP2E1 → NAPQI (reactive toxic metabolite)', 'NAPQI + Glutathione → safe excretion (mercapturic acid)', 'OVERDOSE: Glutathione depleted → NAPQI accumulates → centrilobular hepatocyte necrosis', 'CYP2E1 INDUCERS worsen toxicity: alcohol, INH, rifampicin, phenytoin, carbamazepine'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('CLINICAL STAGES (Rumack-Matthew)', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Stage','Time','Features'],
                [
                  ['I','0–24 hrs','Nausea, vomiting, malaise, pallor — may be asymptomatic'],
                  ['II','24–72 hrs','RUQ pain, ↑ LFTs, ↑ PT, ↑ creatinine'],
                  ['III','72–96 hrs','Peak toxicity: jaundice, coagulopathy, encephalopathy, renal failure, hypoglycaemia'],
                  ['IV','4 days–2 wks','Recovery OR fulminant hepatic failure'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('MANAGEMENT', c.accent),
            ...['Decontamination: Activated charcoal 1 g/kg within 1–2 hrs of ingestion', 'Antidote: IV N-Acetylcysteine (NAC) — 3-bag regimen:', '  Bag 1: 150 mg/kg in 200 mL D5W over 60 min (loading dose)', '  Bag 2: 50 mg/kg in 500 mL D5W over 4 hrs', '  Bag 3: 100 mg/kg in 1000 mL D5W over 16 hrs', 'Oral NAC: 140 mg/kg load, then 70 mg/kg q4h × 17 doses', 'Start NAC if level plots ABOVE treatment line on nomogram', 'Start empirically if > 8 hrs post-ingestion (do not wait for level)'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: l.startsWith('  ') ? '    ↳ '+l.trim() : '• '+l, size: 18, color: DARK, font: 'Calibri', bold: l.includes('NAC') || l.includes('Antidote') })] })]
            })] })),
            sectionHeader("KING'S COLLEGE CRITERIA (Liver Transplant)", c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'FFF8E1' },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,8), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                new Paragraph({ children: [new TextRun({ text: 'Arterial pH < 7.3 after resuscitation   OR   ALL THREE of:', bold: true, size: 18, color: c.accent, font: 'Calibri' })] }),
                new Paragraph({ children: [new TextRun({ text: '  • PT > 100 sec   +   Creatinine > 300 µmol/L   +   Grade III–IV encephalopathy', size: 18, color: DARK, font: 'Calibri' })] }),
              ]
            })] }),
          ]
        }),
        new Paragraph({ children: [new PageBreak()] })
      ];
    }

    // ════════════════════════════════════════════════════════════════════════
    case 'aspirin': {
      const c = COLORS.aspirin;
      return [
        new Table({
          width: { size: 100, type: WidthType.PERCENTAGE },
          borders: { top: border(c.header,8), bottom: border(c.header,8), left: border(c.header,8), right: border(c.header,8), insideH: noBorder(), insideV: noBorder() },
          rows: [
            new TableRow({ children: [titleCell('ASPIRIN (SALICYLATE) POISONING', '🟠', c.header)] }),
            sectionHeader('TOXIC DOSE & KINETICS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Preparation','Fatal Dose'],
                [['Aspirin / Sodium salicylate','15–20 g'],['Methyl salicylate (oil of wintergreen)','5–15 mL (≈ 1 tsp)']],
                c.accent, c.light
              )]
            })] }),
            ...['Elimination t½: Therapeutic = 2–3 hrs | Toxic overdose > 20 hrs (zero-order kinetics)','Volume of distribution: increases in acidaemia (more drug enters CNS)'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('MECHANISM', c.accent),
            ...['Directly stimulates medullary respiratory centre → hyperventilation → Respiratory ALKALOSIS (EARLY)', 'Uncouples oxidative phosphorylation → ↑ organic acids + ↑ O₂ consumption → Metabolic ACIDOSIS (LATE)', 'Inhibits Krebs cycle enzymes → lactic acidosis', 'Each 300 mg tablet contributes 1.7 mEq acid'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('ABG EVOLUTION', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Stage','ABG Pattern'],
                [['Early','Respiratory alkalosis (hyperventilation)'],['Middle','Mixed: Resp alkalosis + Metabolic acidosis'],['Late','Pure Metabolic acidosis (dominant in children)']],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('CLINICAL FEATURES BY SEVERITY', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Severity','Level (mg/L)','Features'],
                [
                  ['Mild','< 300','Nausea, vomiting, TINNITUS, vertigo, hearing loss, lethargy'],
                  ['Moderate','300–700','Dehydration, restlessness, tachypnoea, diaphoresis, warm extremities'],
                  ['Severe','> 700','Pulmonary oedema, cerebral oedema, seizures, coma, renal failure, hyperpyrexia, arrhythmias'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('MANAGEMENT', c.accent),
            ...['Activated charcoal 1 g/kg within 2–4 hrs (repeat doses for enteric-coated tabs)','IV rehydration: D5W + NaHCO₃ — correct hypokalaemia first (essential for urine alkalinisation)','Urinary Alkalinisation (mainstay for moderate–severe): NaHCO₃ IV → target urine pH 7.5–8.5 → ion trapping → ↑ renal clearance 10–20x','Target serum pH 7.45–7.50','DO NOT use acetazolamide (acidifies blood) or NSAIDs'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri', bold: l.startsWith('DO') })] })]
            })] })),
            sectionHeader('HAEMODIALYSIS INDICATIONS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'FBE9E7' },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,8), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('Level > 700 mg/L (severe)  |  Renal failure  |  Pulmonary / cerebral oedema', true, 18, c.accent),
                plain('Persistent acidosis despite NaHCO₃  |  Level > 500 mg/L in elderly/impaired', false, 18, DARK),
              ]
            })] }),
          ]
        }),
        new Paragraph({ children: [new PageBreak()] })
      ];
    }

    // ════════════════════════════════════════════════════════════════════════
    case 'tca': {
      const c = COLORS.tca;
      return [
        new Table({
          width: { size: 100, type: WidthType.PERCENTAGE },
          borders: { top: border(c.header,8), bottom: border(c.header,8), left: border(c.header,8), right: border(c.header,8), insideH: noBorder(), insideV: noBorder() },
          rows: [
            new TableRow({ children: [titleCell('TRICYCLIC ANTIDEPRESSANT (TCA) POISONING', '🔵', c.header)] }),
            sectionHeader('COMMON AGENTS & TOXIC DOSE', c.accent),
            ...['Agents: Amitriptyline (most toxic), Imipramine, Clomipramine, Nortriptyline, Doxepin','Toxic: > 10 mg/kg | Potentially fatal: > 20 mg/kg | Amitriptyline: as little as 500 mg can be fatal in adults'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('MULTI-CHANNEL BLOCKADE (MECHANISM)', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Receptor/Channel','Effect'],
                [
                  ['Na+ channel block (fast INa)','Broad QRS, myocardial depression, arrhythmias ⚡'],
                  ['Muscarinic (M1) block','Anticholinergic syndrome'],
                  ['K+ channel block','QTc prolongation'],
                  ['α1-adrenoceptor block','Vasodilation, hypotension'],
                  ['GABA-A block','Seizures'],
                  ['H1 block','Sedation / coma'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('CLINICAL FEATURES — "SOAP" TOXIDROME', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: c.light },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,10), right: noBorder() },
              margins: { top: 70, bottom: 70, left: 160, right: 100 },
              children: [
                new Paragraph({ children: [new TextRun({ text: 'S  Seizures  |  O  QRS widening  |  A  Anticholinergic syndrome  |  P  Pressure ↓ (hypotension)', bold: true, size: 20, color: c.accent, font: 'Calibri' })] }),
                spacer(),
                new Paragraph({ children: [new TextRun({ text: 'Anticholinergic: "Dry as bone, blind as bat, red as beet, hot as hare, mad as hatter, full as flask"', size: 18, color: DARK, font: 'Calibri', italics: true })] }),
                new Paragraph({ children: [new TextRun({ text: '→ Dry mouth, urinary retention, mydriasis, flushing, hyperthermia, tachycardia, ileus, delirium', size: 18, color: DARK, font: 'Calibri' })] }),
              ]
            })] }),
            sectionHeader('CARDIAC DANGER SIGNS (ECG)', c.accent),
            ...['QRS > 100 ms → risk of arrhythmia; QRS > 160 ms → VT/VF imminent 💀','R wave in aVR > 3 mm  OR  R:S ratio in aVR > 0.7 → predictor of seizures & arrhythmias','Sinus tachycardia (most common early finding)','Brugada pattern may be unmasked'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri', bold: l.includes('💀') })] })]
            })] })),
            sectionHeader('MANAGEMENT', c.accent),
            ...['Activated charcoal within 1–2 hrs (NOT gastric lavage unless intubated)','Early intubation if GCS < 8, seizures, or haemodynamic instability','NaHCO₃ 50–100 mEq IV BOLUS for: QRS > 100 ms, hypotension, arrhythmias  →  Target pH 7.45–7.55','Mechanism of NaHCO₃: (1) Na+ loading overcomes Na-channel block; (2) Alkalosis ↑ protein binding of TCA','Seizures: Benzodiazepines (1st line) — AVOID phenytoin (also Na-channel blocker)','Hypotension: IV fluids → Noradrenaline (α-agonist preferred) — AVOID dopamine (β-effects)','Arrhythmias: NaHCO₃ 1st → Lidocaine 2nd — AVOID Class Ia/Ic, Amiodarone'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: l.includes('AVOID') ? c.accent : DARK, font: 'Calibri', bold: l.includes('AVOID') || l.includes('NaHCO') })] })]
            })] })),
            sectionHeader('⚠ CRITICAL CONTRAINDICATIONS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'FFF3E0' },
              borders: { top: noBorder(), bottom: noBorder(), left: border('E65100',10), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('Flumazenil — CONTRAINDICATED (precipitates seizures)', true, 18, 'C62828'),
                plain('Physostigmine — CONTRAINDICATED (asystole risk)', true, 18, 'C62828'),
                plain('Phenytoin — AVOID for seizures (worsens QRS widening)', true, 18, 'E65100'),
                plain('Haemodialysis — NOT useful (large Vd 10–20 L/kg, high protein binding)', true, 18, '37474F'),
              ]
            })] }),
          ]
        }),
        new Paragraph({ children: [new PageBreak()] })
      ];
    }

    // ════════════════════════════════════════════════════════════════════════
    case 'digoxin': {
      const c = COLORS.digoxin;
      return [
        new Table({
          width: { size: 100, type: WidthType.PERCENTAGE },
          borders: { top: border(c.header,8), bottom: border(c.header,8), left: border(c.header,8), right: border(c.header,8), insideH: noBorder(), insideV: noBorder() },
          rows: [
            new TableRow({ children: [titleCell('DIGOXIN POISONING', '🟢', c.header)] }),
            sectionHeader('DRUG LEVELS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Level','Value (ng/mL)'],
                [['Therapeutic','0.8 – 2.0'],['Toxic','> 2.0 (lower with hypokalaemia)'],['Acute OD — Life-threatening','> 10']],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('MECHANISM', c.accent),
            ...['Inhibits Na+/K+-ATPase → ↑ intracellular Na+ → ↑ intracellular Ca²⁺ (via Na+/Ca²⁺ exchanger)','Therapeutic: ↑ myocardial contractility + ↓ AV conduction (vagotonic)','Toxic: Triggered activity (delayed afterdepolarisations) → ↑ automaticity → arrhythmias','Acute OD → HYPERKALEMIA (ATPase inhibition); Chronic → HYPOKALAEMIA (diuretics) worsens toxicity'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('CLINICAL FEATURES', c.accent),
            ...['GI (EARLY, most common): Nausea, vomiting, anorexia, abdominal pain, diarrhoea','Neuro: Yellow-green halos (xanthopsia), blurred vision, confusion, fatigue','Cardiac: ANY arrhythmia possible — "regularise the irregular, irregularise the regular"','Pathognomonic: PAT with 2:1 AV block | Junctional tachycardia with AV block | Ventricular bigeminy','Acute OD: More AV block; Chronic: More ventricular ectopy'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: l.includes('Pathognomonic') ? c.accent : DARK, font: 'Calibri', bold: l.includes('Pathognomonic') })] })]
            })] })),
            sectionHeader('ECG SIGNS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: c.light },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,8), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('"Salvador Dalí moustache" = Reverse tick / Scoop sign (downsloping ST depression)', true, 18, c.accent),
                plain('Shortened QTc  |  T-wave inversion  |  U waves  |  Prolonged PR interval', false, 18, DARK),
              ]
            })] }),
            sectionHeader('MANAGEMENT', c.accent),
            ...['Activated charcoal if within 2 hrs (repeat doses for ongoing absorption)','Correct hypokalaemia aggressively with IV KCl (K+ < 3.5 mmol/L)','Correct hypomagnesaemia | AVOID calcium in acute OD (may cause stone heart)','Atropine 0.5–1 mg IV for symptomatic bradycardia (temporary measure)','MgSO₄ 1–2 g IV over 20 min for ventricular arrhythmias','Temporary pacing for refractory bradycardia/AV block'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: l.includes('AVOID') ? 'C62828' : DARK, font: 'Calibri', bold: l.includes('AVOID') })] })]
            })] })),
            sectionHeader('✅ ANTIDOTE — DIGOXIN-SPECIFIC Fab FRAGMENTS (Digibind / DigiFab)', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'E8F5E9' },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,10), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('INDICATIONS: Life-threatening arrhythmias | Haemodynamic instability', true, 18, c.accent),
                plain('Acute ingestion > 10 mg adults / > 4 mg children | K+ > 5.5 mmol/L (acute)', false, 18, DARK),
                spacer(),
                plain('DOSE: No. of vials = (serum digoxin ng/mL × weight kg) ÷ 100', true, 18, c.accent),
                plain('OR from known dose: mg ingested × 0.8 ÷ 0.5', false, 18, DARK),
                spacer(),
                plain('NOTE: Serum digoxin levels RISE post-Fab (measures bound + free) — do NOT recheck to guide re-dosing', false, 18, '37474F'),
                plain('Haemodialysis: NOT effective (large Vd, protein bound)', false, 18, '37474F'),
              ]
            })] }),
          ]
        }),
        new Paragraph({ children: [new PageBreak()] })
      ];
    }

    // ════════════════════════════════════════════════════════════════════════
    case 'lithium': {
      const c = COLORS.lithium;
      return [
        new Table({
          width: { size: 100, type: WidthType.PERCENTAGE },
          borders: { top: border(c.header,8), bottom: border(c.header,8), left: border(c.header,8), right: border(c.header,8), insideH: noBorder(), insideV: noBorder() },
          rows: [
            new TableRow({ children: [titleCell('LITHIUM TOXICITY', '🟣', c.header)] }),
            sectionHeader('THERAPEUTIC RANGE: 0.6 – 1.2 mmol/L', c.accent),
            sectionHeader('TYPES OF TOXICITY', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Type','Cause','Severity'],
                [
                  ['Acute','OD in non-user (naive)','GI symptoms prominent'],
                  ['Chronic','Accumulation in long-term user','Neurological features dominate'],
                  ['Acute-on-chronic','OD in established user','MOST SEVERE — mixed features'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('PRECIPITATING FACTORS (in therapeutic users)', c.accent),
            ...['Dehydration, Na⁺ restriction, diarrhoea, vomiting','NSAIDs — ↓ renal clearance of Li⁺','ACE inhibitors / ARBs — ↑ tubular reabsorption','Thiazide diuretics — Na⁺ depletion → compensatory Li⁺ retention','Renal failure'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('CLINICAL FEATURES BY SEVERITY', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Level (mmol/L)','Severity','Features'],
                [
                  ['1.5 – 2.0','Mild','Nausea, vomiting, diarrhoea, coarse tremor, polyuria/polydipsia'],
                  ['2.0 – 2.5','Moderate','Confusion, agitation, ataxia, drowsiness, dysarthria, myoclonus'],
                  ['> 2.5','Severe','Seizures, coma, hypotension, arrhythmias, renal failure'],
                  ['> 4.0','Life-threatening','Irreversible neurological damage, respiratory failure, death'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('SILENT SYNDROME', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'F3E5F5' },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,10), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('SILENT = Syndrome of Irreversible Lithium-Effectuated Neurotoxicity', true, 18, c.accent),
                plain('Cerebellar dysfunction | Dementia | Brainstem signs — PERSISTS even after normalization of serum levels', false, 18, DARK),
              ]
            })] }),
            sectionHeader('MANAGEMENT', c.accent),
            ...['Stop lithium immediately','Activated charcoal — NOT useful (Li⁺ is a small ionic molecule, not adsorbed)','Gastric lavage within 1 hr of acute ingestion','Whole Bowel Irrigation (PEG) for sustained-release preparations','IV 0.9% NaCl aggressively — Li+ clearance follows Na+ → volume expands → ↑ excretion','Avoid NSAIDs, ACEi/ARBs, thiazides'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: l.includes('NOT') || l.includes('Avoid') ? 'C62828' : DARK, font: 'Calibri', bold: l.includes('NOT') || l.includes('Avoid') })] })]
            })] })),
            sectionHeader('✅ HAEMODIALYSIS — KEY TREATMENT (EXTRIP Guidelines)', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'F3E5F5' },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,10), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('Indications:', true, 18, c.accent),
                plain('• Severe neurological features (seizures, coma, altered consciousness)', false, 18, DARK),
                plain('• Li+ ≥ 5.0 mmol/L regardless of symptoms', false, 18, DARK),
                plain('• Li+ ≥ 4.0 mmol/L with renal failure', false, 18, DARK),
                plain('• Li+ ≥ 2.5 mmol/L with severe neurological symptoms', false, 18, DARK),
                spacer(),
                plain('⚠ POST-HD REBOUND: Recheck levels 6–12 hrs post-session (tissue redistribution). Continue HD until Li+ < 1 mmol/L post-rebound.', true, 18, 'E65100'),
              ]
            })] }),
          ]
        }),
        new Paragraph({ children: [new PageBreak()] })
      ];
    }

    // ════════════════════════════════════════════════════════════════════════
    case 'benzo': {
      const c = COLORS.benzo;
      return [
        new Table({
          width: { size: 100, type: WidthType.PERCENTAGE },
          borders: { top: border(c.header,8), bottom: border(c.header,8), left: border(c.header,8), right: border(c.header,8), insideH: noBorder(), insideV: noBorder() },
          rows: [
            new TableRow({ children: [titleCell('BENZODIAZEPINE POISONING', '🔵', c.header)] }),
            sectionHeader('COMMON AGENTS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Class','Agents'],
                [
                  ['Short-acting (most toxic in OD)','Alprazolam, Triazolam, Temazepam'],
                  ['Long-acting','Diazepam, Chlordiazepoxide, Clonazepam'],
                  ['IV agents','Midazolam, Lorazepam'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('MECHANISM', c.accent),
            ...['Positive allosteric modulator of GABA-A receptor → ↑ frequency of Cl⁻ channel opening → CNS depression','Does NOT cause Na-channel blockade (unlike TCAs) → no QRS widening on ECG','Alprazolam is relatively more toxic than other BZDs in overdose'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('CLINICAL FEATURES', c.accent),
            ...['CNS: Drowsiness → slurred speech → ataxia → confusion → coma (rarely deep in isolated OD)','Respiratory depression: MILD in isolation — SEVERE when combined with opioids/alcohol 💀','Cardiovascular: Mild hypotension, mild bradycardia — NO QRS/QTc changes','Paradoxical reactions (rare, elderly/children): Agitation, aggression, disinhibition, hallucinations'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: l.includes('💀') ? 'C62828' : DARK, font: 'Calibri', bold: l.includes('💀') })] })]
            })] })),
            sectionHeader('MANAGEMENT', c.accent),
            ...['Airway: First priority — supportive ventilation if respiratory failure','Activated charcoal within 1 hr if airway is protected','Supportive: Monitor resp status, O₂ saturation, treat hypotension with IV fluids','Haemodialysis: NOT effective (high protein binding, large Vd)','Key principle: Isolated BZD OD rarely fatal — most recover with supportive care alone'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: DARK, font: 'Calibri' })] })]
            })] })),
            sectionHeader('✅ ANTIDOTE — FLUMAZENIL', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'E0F7FA' },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,10), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('Competitive BZD receptor antagonist', true, 18, c.accent),
                plain('Dose: 0.2 mg IV over 30 sec → repeat 0.1–0.2 mg q1 min → max 1–2 mg', false, 18, DARK),
                plain('Onset: 2 min | Duration: 30–60 min ⚠ RESEDATION RISK (shorter than BZDs)', false, 18, DARK),
              ]
            })] }),
            sectionHeader('⚠ FLUMAZENIL CONTRAINDICATIONS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'FFF3E0' },
              borders: { top: noBorder(), bottom: noBorder(), left: border('E65100',10), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('BZD-dependent patients → precipitates acute WITHDRAWAL / SEIZURES', true, 18, 'C62828'),
                plain('Co-ingestion with TCAs → precipitates SEIZURES (DO NOT USE)', true, 18, 'C62828'),
                plain('Raised ICP | History of epilepsy | Chronic BZD use', false, 18, 'E65100'),
              ]
            })] }),
          ]
        }),
        new Paragraph({ children: [new PageBreak()] })
      ];
    }

    // ════════════════════════════════════════════════════════════════════════
    case 'opioid': {
      const c = COLORS.opioid;
      return [
        new Table({
          width: { size: 100, type: WidthType.PERCENTAGE },
          borders: { top: border(c.header,8), bottom: border(c.header,8), left: border(c.header,8), right: border(c.header,8), insideH: noBorder(), insideV: noBorder() },
          rows: [
            new TableRow({ children: [titleCell('OPIOID POISONING', '🟤', c.header)] }),
            sectionHeader('COMMON AGENTS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Class','Agents','Special Notes'],
                [
                  ['Natural','Morphine, Codeine','Baseline agents'],
                  ['Semi-synthetic','Heroin, Oxycodone, Buprenorphine','Heroin: non-cardiogenic pulmonary oedema'],
                  ['Synthetic','Fentanyl (100x morphine), Methadone, Tramadol','Methadone: long t½ 24–36 hrs; Tramadol: seizures'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('MECHANISM', c.accent),
            ...['Agonists at μ (mu), κ (kappa), δ (delta) opioid receptors (GPCRs)','μ-receptor: analgesia, euphoria, respiratory depression, miosis, GI effects','↓ cAMP → hyperpolarisation → ↓ neuronal excitability','RESPIRATORY DEPRESSION = primary cause of death (brainstem respiratory centre)'].map((l,i) => new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: i%2===0 ? c.light : WHITE },
              borders: { top: border('DDDDDD',2), bottom: border('DDDDDD',2), left: noBorder(), right: noBorder() },
              margins: { top: 45, bottom: 45, left: 160, right: 100 },
              children: [new Paragraph({ children: [new TextRun({ text: '• '+l, size: 18, color: l.includes('RESPIRATORY') ? 'C62828' : DARK, font: 'Calibri', bold: l.includes('RESPIRATORY') })] })]
            })] })),
            sectionHeader('CLASSIC TRIAD (OPIOID TOXIDROME)', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: c.light },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,10), right: noBorder() },
              margins: { top: 70, bottom: 70, left: 160, right: 100 },
              children: [
                new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: '🔴  MIOSIS  +  RESPIRATORY DEPRESSION  +  CNS DEPRESSION (Coma)', bold: true, size: 24, color: c.accent, font: 'Calibri' })] }),
              ]
            })] }),
            sectionHeader('CLINICAL FEATURES', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Feature','Detail'],
                [
                  ['Pinpoint pupils (miosis)','Bilateral — even in hypoxia (key sign)'],
                  ['Respiratory depression','↓ RR < 12/min, shallow → apnoea'],
                  ['CNS depression','Drowsiness → stupor → coma'],
                  ['Hypothermia','Common'],
                  ['Bradycardia / Hypotension','Present'],
                  ['Pulmonary oedema (non-cardiac)','Especially heroin, methadone'],
                  ['Seizures','Tramadol, pethidine (norpethidine), propoxyphene'],
                  ['Muscle rigidity','High-dose fentanyl ("wooden chest")'],
                ],
                c.accent, c.light
              )]
            })] }),
            sectionHeader('✅ ANTIDOTE — NALOXONE (Narcan)', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: 'FDECEA' },
              borders: { top: noBorder(), bottom: noBorder(), left: border(c.accent,10), right: noBorder() },
              margins: { top: 60, bottom: 60, left: 160, right: 100 },
              children: [
                plain('Competitive μ-receptor antagonist', true, 18, c.accent),
                plain('IV: 0.4–2 mg bolus q2–3 min | IM/SC: 0.4–0.8 mg | Intranasal: 2–4 mg (pre-hospital)', false, 18, DARK),
                plain('Onset: IV 1–2 min | IM 5 min | Duration: 30–90 min', false, 18, DARK),
                spacer(),
                plain('⚠ RESEDATION RISK: Naloxone SHORTER-acting than most opioids', true, 18, 'E65100'),
                plain('Infusion: 2/3 of effective bolus per hour — especially for methadone, fentanyl, SR opioids', false, 18, DARK),
                plain('Titrate to ADEQUATE RESPIRATORY EFFORT (not full reversal — precipitates withdrawal)', false, 18, DARK),
                plain('Max dose: 10 mg — if no response, re-assess diagnosis', false, 18, '37474F'),
              ]
            })] }),
            sectionHeader('SPECIAL AGENT CONSIDERATIONS', c.accent),
            new TableRow({ children: [new TableCell({
              columnSpan: 2,
              shading: { type: ShadingType.SOLID, color: WHITE },
              borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
              margins: { top: 60, bottom: 40, left: 100, right: 100 },
              children: [miniTable(
                ['Agent','Special Consideration'],
                [
                  ['Methadone','Long t½ 24–36 hrs → admit 24 hrs, naloxone infusion needed, QTc prolongation'],
                  ['Tramadol','Seizures → treat with BZDs; partial response to naloxone'],
                  ['Buprenorphine','High receptor affinity → requires high-dose naloxone; RD less severe'],
                  ['Illicit fentanyl','Ultra-potent → multiple naloxone doses needed'],
                ],
                c.accent, c.light
              )]
            })] }),
          ]
        }),
        new Paragraph({ children: [new PageBreak()] })
      ];
    }

    default: return [];
  }
}

// ─── Title / Cover Page ───────────────────────────────────────────────────────
function coverPage() {
  return [
    new Table({
      width: { size: 100, type: WidthType.PERCENTAGE },
      borders: { top: border('2C3E50',10), bottom: border('2C3E50',10), left: border('2C3E50',10), right: border('2C3E50',10), insideH: noBorder(), insideV: noBorder() },
      rows: [
        new TableRow({ children: [new TableCell({
          shading: { type: ShadingType.SOLID, color: '2C3E50' },
          borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
          margins: { top: 300, bottom: 80, left: 300, right: 300 },
          children: [
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: '💊', size: 72, font: 'Segoe UI Emoji' })] }),
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: 'TOXICOLOGY', bold: true, size: 64, color: 'F39C12', font: 'Calibri' })] }),
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: 'CHEAT SHEETS', bold: true, size: 56, color: WHITE, font: 'Calibri' })] }),
          ]
        })] }),
        new TableRow({ children: [new TableCell({
          shading: { type: ShadingType.SOLID, color: '34495E' },
          borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
          margins: { top: 100, bottom: 100, left: 300, right: 300 },
          children: [
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: 'Drug Poisoning & Overdose Management', size: 32, color: 'ECF0F1', font: 'Calibri' })] }),
          ]
        })] }),
        new TableRow({ children: [new TableCell({
          shading: { type: ShadingType.SOLID, color: '2C3E50' },
          borders: { top: border('F39C12',4), bottom: noBorder(), left: noBorder(), right: noBorder() },
          margins: { top: 80, bottom: 80, left: 300, right: 300 },
          children: [
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: '📚  Davidson  ·  Harrison  ·  Archith Baloor', size: 26, color: 'F39C12', font: 'Calibri', bold: true })] }),
          ]
        })] }),
        new TableRow({ children: [new TableCell({
          shading: { type: ShadingType.SOLID, color: '2C3E50' },
          borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
          margins: { top: 60, bottom: 300, left: 300, right: 300 },
          children: [
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: '1. Paracetamol    2. Aspirin    3. TCA    4. Digoxin', size: 22, color: 'BDC3C7', font: 'Calibri' })] }),
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: '5. Lithium    6. Benzodiazepines    7. Opioids', size: 22, color: 'BDC3C7', font: 'Calibri' })] }),
          ]
        })] }),
      ]
    }),
    new Paragraph({ children: [new PageBreak()] })
  ];
}

// ─── Quick Reference Antidote Summary ────────────────────────────────────────
function antidotePage() {
  return [
    new Table({
      width: { size: 100, type: WidthType.PERCENTAGE },
      borders: { top: border('2C3E50',8), bottom: border('2C3E50',8), left: border('2C3E50',8), right: border('2C3E50',8), insideH: noBorder(), insideV: noBorder() },
      rows: [
        new TableRow({ children: [new TableCell({
          columnSpan: 1,
          shading: { type: ShadingType.SOLID, color: '2C3E50' },
          borders: { top: noBorder(), bottom: border('F39C12',6), left: noBorder(), right: noBorder() },
          margins: { top: 120, bottom: 120, left: 200, right: 200 },
          children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: '⚡  QUICK REFERENCE — ANTIDOTES & KEY FACTS', bold: true, size: 32, color: 'F39C12', font: 'Calibri' })] })]
        })] }),
        new TableRow({ children: [new TableCell({
          shading: { type: ShadingType.SOLID, color: WHITE },
          borders: { top: noBorder(), bottom: noBorder(), left: noBorder(), right: noBorder() },
          margins: { top: 80, bottom: 80, left: 100, right: 100 },
          children: [miniTable(
            ['Drug','Antidote','Dose / Route','Key Pitfall'],
            [
              ['Paracetamol','N-Acetylcysteine (NAC)','IV 3-bag regimen OR oral 17-dose','Start if >8 hrs even before level returns'],
              ['Aspirin','NaHCO₃ + HD if severe','Urine pH 7.5–8.5 target','AVOID acetazolamide — acidifies blood'],
              ['TCA','Sodium Bicarbonate','50–100 mEq IV bolus','AVOID flumazenil, phenytoin, amiodarone'],
              ['Digoxin','Digoxin Fab (Digibind)','Vials = (level × wt) ÷ 100','AVOID calcium in acute OD'],
              ['Lithium','Haemodialysis','Serial sessions, target < 1 mmol/L','Charcoal useless; check rebound at 6–12 hrs'],
              ['Benzodiazepines','Flumazenil (with caution)','0.2 mg IV → max 2 mg','CI: TCA co-ingestion, BZD dependence'],
              ['Opioids','Naloxone ± infusion','0.4–2 mg IV; 2/3 bolus/hr infusion','Resedation risk; titrate gently'],
            ],
            '2C3E50', 'F8F9FA'
          )]
        })] }),
        new TableRow({ children: [new TableCell({
          shading: { type: ShadingType.SOLID, color: 'FFF8E1' },
          borders: { top: border('F39C12',4), bottom: noBorder(), left: noBorder(), right: noBorder() },
          margins: { top: 80, bottom: 80, left: 200, right: 200 },
          children: [
            new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: '📚  References: Archith Baloor — Essentials of Forensic Medicine & Toxicology (36th Ed. 2026)  |  Harrison\'s Principles of Internal Medicine 22E (2025)  |  Davidson\'s Principles & Practice of Medicine', size: 16, color: '666666', font: 'Calibri', italics: true })] }),
          ]
        })] }),
      ]
    })
  ];
}

// ─── ASSEMBLE DOCUMENT ────────────────────────────────────────────────────────
const sections = [
  ...coverPage(),
  ...buildSheet('paracetamol'),
  ...buildSheet('aspirin'),
  ...buildSheet('tca'),
  ...buildSheet('digoxin'),
  ...buildSheet('lithium'),
  ...buildSheet('benzo'),
  ...buildSheet('opioid'),
  ...antidotePage(),
];

const doc = new Document({
  styles: {
    default: {
      document: {
        run: { font: 'Calibri', size: 18 }
      }
    }
  },
  sections: [{
    properties: {
      page: {
        margin: { top: convertInchesToTwip(0.5), bottom: convertInchesToTwip(0.5), left: convertInchesToTwip(0.6), right: convertInchesToTwip(0.6) }
      }
    },
    children: sections
  }]
});

Packer.toBuffer(doc).then(buf => {
  fs.writeFileSync('/home/daytona/workspace/toxicology-cheatsheets/Toxicology_Cheatsheets.docx', buf);
  console.log('Done!');
}).catch(e => { console.error(e); process.exit(1); });
Running Command

cd /home/daytona/workspace/toxicology-cheatsheets && node generate.js 2>&1

Running Command

python /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/toxicology-cheatsheets/Toxicology_Cheatsheets.docx 2>&1 && ls -lh /home/daytona/workspace/toxicology-cheatsheets/

Running Command

ls -lh /home/daytona/workspace/toxicology-cheatsheets/ && python3 -c "import zipfile; z=zipfile.ZipFile('/home/daytona/workspace/toxicology-cheatsheets/Toxicology_Cheatsheets.docx'); print('Valid ZIP, files:', z.namelist()[:5])"

The document is valid and ready. Here you go:

Toxicology Cheatsheets

Word Document · DOCX


Here's what's inside the document (22 KB, 9 pages total):
PageContent
CoverDark navy cover with title, subtitle, and 7 drug list in gold accent
Pages 2–8One full page per drug, each with a unique color theme
Page 9Quick-reference antidote summary table for all 7 drugs

Color scheme per drug:

  • 🟡 Paracetamol - Amber/Gold
  • 🟠 Aspirin - Burnt Orange
  • 🔵 TCA - Steel Blue
  • 🟢 Digoxin - Forest Green
  • 🟣 Lithium - Purple
  • 🔵 Benzodiazepines - Teal
  • 🟤 Opioids - Burgundy/Brown
Each cheat sheet has color-coded section headers, alternating row shading in tables, highlighted "danger boxes" for contraindications, and green "antidote boxes" for treatment — designed to be scannable at a glance during revision or clinical reference.

Do me a favour and change it into a pdf please 🥺

Running Command

python /home/daytona/skills/docx/scripts/office/soffice.py --headless --convert-to pdf /home/daytona/workspace/toxicology-cheatsheets/Toxicology_Cheatsheets.docx --outdir /home/daytona/workspace/toxicology-cheatsheets/ 2>&1

Running Command

cp /home/daytona/workspace/toxicology-cheatsheets/Toxicology_Cheatsheets.docx /tmp/tox.docx && python /home/daytona/skills/docx/scripts/office/soffice.py --headless --convert-to pdf /tmp/tox.docx --outdir /tmp/ 2>&1 && ls -lh /tmp/tox.pdf

Running Command

cp /tmp/tox.pdf /home/daytona/workspace/toxicology-cheatsheets/Toxicology_Cheatsheets.pdf && ls -lh /home/daytona/workspace/toxicology-cheatsheets/

Done! Here's your PDF:

Toxicology Cheatsheets

PDF Document · PDF

240 KB, all 9 pages - cover, 7 color-coded cheat sheets, and the antidote summary. Good luck with your studies! 🩺
This is a shared conversation. Sign in to Orris to start your own chat.