35yr male pt chronic alcoholic with withdrowal symptom like tremors in both hand g weakness loss of apetite vomiting confusion should i give tb thiamine

Reading File
Finding Sources
Searching PubMed

thiamine Wernicke encephalopathy alcohol withdrawal treatment

Reading File
Finding Sources
Reading File
Reading File
Here is a thorough, textbook-backed answer for your clinical scenario:

Thiamine in a Chronic Alcoholic with Withdrawal + Confusion

Short Answer: Do NOT give tablet (oral) thiamine - give IV thiamine immediately


Why This Patient Needs Thiamine Urgently

This 35-year-old chronic alcoholic with tremors, weakness, loss of appetite, vomiting, and confusion has a clinical picture that overlaps two serious conditions:
  1. Alcohol Withdrawal (tremors, autonomic symptoms, GI symptoms)
  2. Wernicke Encephalopathy (thiamine deficiency - the confusion is a red flag)
Wernicke encephalopathy is not an alcohol withdrawal syndrome - it is caused by thiamine (B1) deficiency, which is nearly universal in chronic alcoholics due to poor dietary intake and impaired absorption.
  • Symptom to Diagnosis: An Evidence Based Guide, 4e

Why NOT Oral/Tablet Thiamine?

Oral thiamine (tablet) is inadequate here for two critical reasons:
  1. Intestinal absorption is unreliable in debilitated and alcoholic patients. Chronic alcohol use impairs thiamine absorption in the gut. An oral tablet will NOT achieve the serum levels needed.
  2. This patient has vomiting - he likely cannot absorb oral medications anyway.
"Parenteral administration is preferable over oral supplements because intestinal absorption is unreliable in debilitated and alcoholic patients."
  • Bradley and Daroff's Neurology in Clinical Practice

Correct Thiamine Protocol

StageDose & Route
Acute (suspected Wernicke / confusion present)500 mg IV (infused slowly over 30 min)
Maintenance (first week)100 mg IV/IM three times daily
After acute phase stabilizesOral thiamine 100 mg daily can continue
"A dose of 500 mg should be given IV in the acute stage, followed by 100 mg 3 times daily during the first week."
  • Bradley and Daroff's Neurology in Clinical Practice

Critical Rule: Thiamine BEFORE Glucose

If you need to give IV fluids or dextrose - always give thiamine FIRST.
Giving glucose to a thiamine-deficient patient can rapidly precipitate or worsen Wernicke encephalopathy by consuming the remaining thiamine stores for glucose metabolism.
"Patients suspected of having the disorder should receive thiamine before administration of glucose to avoid precipitation of symptom worsening."
  • Bradley and Daroff's Neurology in Clinical Practice

Classic Wernicke Triad (Suspect if ANY 1-2 features present)

  • Confusion / altered mental status ✅ (your patient has this)
  • Ophthalmoplegia / nystagmus / gaze palsy
  • Ataxia (cerebellar signs)
"It is important to recognize that Wernicke encephalopathy usually presents with only 1 or 2 of the features of the classic triad." Do not wait for all three.
  • Symptom to Diagnosis, 4e

Additional Management for This Patient

Along with thiamine, this patient also likely needs management for alcohol withdrawal itself:
  • Benzodiazepines (e.g., diazepam or lorazepam) - first-line for withdrawal symptoms including tremors, agitation, and to prevent seizures/delirium tremens
  • CIWA-Ar score to assess withdrawal severity and guide benzo dosing
  • IV fluids, electrolyte correction (hypomagnesemia is common in alcoholics and also contributes to thiamine-resistant cases)
  • Monitor for delirium tremens (confusion + autonomic hyperactivity - hypertension, tachycardia, fever) which can be fatal if untreated
  • Also consider Mg²⁺ supplementation - magnesium is needed for thiamine to work properly

Summary

PointRecommendation
Give thiamine?Yes, urgently
Which form?IV (parenteral), NOT oral tablet
Dose in acute setting500 mg IV
Before or after glucose?ALWAYS before glucose
Other treatment?Benzodiazepines for withdrawal, IV fluids, electrolytes
This patient's confusion is the most dangerous symptom - it suggests either early Wernicke encephalopathy or impending delirium tremens. Both require immediate inpatient management. Do not discharge or manage outpatient.

Create a reference guide for managing acute alcohol withdrawal

Asking for Preferences
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/alcohol-withdrawal-guide

Writing File

~/alcohol-withdrawal-guide/build_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import PageBreak

OUTPUT = "/home/daytona/workspace/alcohol-withdrawal-guide/Acute_Alcohol_Withdrawal_Reference_Guide.pdf"

# ─── Colour palette ───────────────────────────────────────────────────────────
DARK_BLUE   = colors.HexColor("#1A3A5C")
MED_BLUE    = colors.HexColor("#2C6FAC")
LIGHT_BLUE  = colors.HexColor("#D6E8F7")
ORANGE      = colors.HexColor("#E07B25")
ORANGE_LITE = colors.HexColor("#FDE9D4")
RED         = colors.HexColor("#C0392B")
RED_LITE    = colors.HexColor("#FADBD8")
GREEN       = colors.HexColor("#1E8449")
GREEN_LITE  = colors.HexColor("#D5F5E3")
YELLOW_LITE = colors.HexColor("#FEF9E7")
GREY        = colors.HexColor("#566573")
LIGHT_GREY  = colors.HexColor("#F2F3F4")
WHITE       = colors.white
BLACK       = colors.black

# ─── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, **kw)

cover_title = S("CoverTitle",
    fontSize=30, fontName="Helvetica-Bold",
    textColor=WHITE, alignment=TA_CENTER, spaceAfter=6)

cover_sub = S("CoverSub",
    fontSize=14, fontName="Helvetica",
    textColor=LIGHT_BLUE, alignment=TA_CENTER, spaceAfter=4)

cover_note = S("CoverNote",
    fontSize=9, fontName="Helvetica-Oblique",
    textColor=LIGHT_BLUE, alignment=TA_CENTER)

section_hdr = S("SectionHdr",
    fontSize=13, fontName="Helvetica-Bold",
    textColor=WHITE, alignment=TA_LEFT,
    spaceBefore=10, spaceAfter=4,
    leftIndent=6)

sub_hdr = S("SubHdr",
    fontSize=11, fontName="Helvetica-Bold",
    textColor=DARK_BLUE, spaceBefore=8, spaceAfter=3)

body = S("Body",
    fontSize=9, fontName="Helvetica",
    textColor=BLACK, leading=13,
    spaceBefore=2, spaceAfter=2, alignment=TA_JUSTIFY)

body_bold = S("BodyBold",
    fontSize=9, fontName="Helvetica-Bold",
    textColor=BLACK, leading=13)

bullet = S("Bullet",
    fontSize=9, fontName="Helvetica",
    textColor=BLACK, leading=13,
    leftIndent=14, firstLineIndent=-10,
    spaceBefore=1, spaceAfter=1)

warn_style = S("Warn",
    fontSize=9, fontName="Helvetica-Bold",
    textColor=RED, leading=13, spaceBefore=2)

caption = S("Caption",
    fontSize=7.5, fontName="Helvetica-Oblique",
    textColor=GREY, alignment=TA_CENTER)

footer_style = S("Footer",
    fontSize=7, fontName="Helvetica",
    textColor=GREY, alignment=TA_CENTER)

tbl_hdr_style = S("TblHdr",
    fontSize=8.5, fontName="Helvetica-Bold",
    textColor=WHITE, alignment=TA_CENTER)

tbl_body_style = S("TblBody",
    fontSize=8.5, fontName="Helvetica",
    textColor=BLACK, alignment=TA_LEFT, leading=12)

tbl_body_ctr = S("TblBodyCtr",
    fontSize=8.5, fontName="Helvetica",
    textColor=BLACK, alignment=TA_CENTER, leading=12)

tbl_red = S("TblRed",
    fontSize=8.5, fontName="Helvetica-Bold",
    textColor=RED, alignment=TA_LEFT)

tbl_green = S("TblGreen",
    fontSize=8.5, fontName="Helvetica-Bold",
    textColor=GREEN, alignment=TA_LEFT)

# ─── Helper: section banner ───────────────────────────────────────────────────
def banner(text, bg=MED_BLUE):
    data = [[Paragraph(text, section_hdr)]]
    t = Table(data, colWidths=[17.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
        ("ROUNDEDCORNERS", [4,4,4,4]),
    ]))
    return t

def alert_box(text, bg=RED_LITE, border=RED):
    data = [[Paragraph(text, warn_style)]]
    t = Table(data, colWidths=[17.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0),(-1,-1), bg),
        ("LEFTPADDING",   (0,0),(-1,-1), 10),
        ("RIGHTPADDING",  (0,0),(-1,-1), 10),
        ("TOPPADDING",    (0,0),(-1,-1), 6),
        ("BOTTOMPADDING", (0,0),(-1,-1), 6),
        ("BOX",           (0,0),(-1,-1), 1.5, border),
        ("ROUNDEDCORNERS",[4,4,4,4]),
    ]))
    return t

def info_box(text, bg=LIGHT_BLUE, border=MED_BLUE):
    p = Paragraph(text, S("IB", fontSize=9, fontName="Helvetica",
                           textColor=DARK_BLUE, leading=13, alignment=TA_JUSTIFY))
    data = [[p]]
    t = Table(data, colWidths=[17.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0),(-1,-1), bg),
        ("LEFTPADDING",   (0,0),(-1,-1), 10),
        ("RIGHTPADDING",  (0,0),(-1,-1), 10),
        ("TOPPADDING",    (0,0),(-1,-1), 6),
        ("BOTTOMPADDING", (0,0),(-1,-1), 6),
        ("BOX",           (0,0),(-1,-1), 1, border),
        ("ROUNDEDCORNERS",[4,4,4,4]),
    ]))
    return t

def green_box(text, bg=GREEN_LITE, border=GREEN):
    p = Paragraph(text, S("GB", fontSize=9, fontName="Helvetica",
                           textColor=GREEN, leading=13, alignment=TA_JUSTIFY))
    data = [[p]]
    t = Table(data, colWidths=[17.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0),(-1,-1), bg),
        ("LEFTPADDING",   (0,0),(-1,-1), 10),
        ("RIGHTPADDING",  (0,0),(-1,-1), 10),
        ("TOPPADDING",    (0,0),(-1,-1), 6),
        ("BOTTOMPADDING", (0,0),(-1,-1), 6),
        ("BOX",           (0,0),(-1,-1), 1, border),
        ("ROUNDEDCORNERS",[4,4,4,4]),
    ]))
    return t

# ─── Page template with header/footer ────────────────────────────────────────
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate
from reportlab.lib.units import inch

def add_page_decorations(canvas, doc):
    canvas.saveState()
    w, h = A4
    # Top bar
    canvas.setFillColor(DARK_BLUE)
    canvas.rect(0, h - 22*mm, w, 22*mm, fill=1, stroke=0)
    canvas.setFillColor(WHITE)
    canvas.setFont("Helvetica-Bold", 11)
    canvas.drawString(1.5*cm, h - 14*mm, "ACUTE ALCOHOL WITHDRAWAL: MANAGEMENT REFERENCE GUIDE")
    canvas.setFont("Helvetica", 8)
    canvas.setFillColor(LIGHT_BLUE)
    canvas.drawRightString(w - 1.5*cm, h - 14*mm, "For General Practitioners")
    # Bottom bar
    canvas.setFillColor(DARK_BLUE)
    canvas.rect(0, 0, w, 12*mm, fill=1, stroke=0)
    canvas.setFillColor(LIGHT_BLUE)
    canvas.setFont("Helvetica", 7)
    canvas.drawCentredString(w/2, 5*mm,
        "Sources: Harrison's Principles of Internal Medicine 22e | Washington Manual | Rosen's EM | Bradley & Daroff Neurology | Maudsley Prescribing Guidelines 15e")
    # Page number
    canvas.setFillColor(WHITE)
    canvas.setFont("Helvetica-Bold", 8)
    canvas.drawRightString(w - 1.5*cm, 5*mm, f"Page {doc.page}")
    canvas.restoreState()

def first_page(canvas, doc):
    canvas.saveState()
    w, h = A4
    # Full-page gradient-style cover background
    canvas.setFillColor(DARK_BLUE)
    canvas.rect(0, 0, w, h, fill=1, stroke=0)
    # Accent stripe
    canvas.setFillColor(MED_BLUE)
    canvas.rect(0, h*0.38, w, h*0.24, fill=1, stroke=0)
    # Bottom strip
    canvas.setFillColor(ORANGE)
    canvas.rect(0, 0, w, 18*mm, fill=1, stroke=0)
    canvas.restoreState()

# ─── Build story ──────────────────────────────────────────────────────────────
story = []

# ══════════════════════════════════════════════════════════════════
# COVER PAGE
# ══════════════════════════════════════════════════════════════════
story.append(Spacer(1, 5.5*cm))
story.append(Paragraph("ACUTE ALCOHOL WITHDRAWAL", cover_title))
story.append(Spacer(1, 0.4*cm))
story.append(Paragraph("Management Reference Guide", cover_sub))
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("For General Practitioners", cover_sub))
story.append(Spacer(1, 3.5*cm))

cover_bullets = [
    "Clinical staging and symptom timeline",
    "CIWA-Ar scoring guide",
    "Pharmacological management: benzodiazepine protocols",
    "Thiamine & nutritional replacement",
    "Delirium tremens and seizure management",
    "Wernicke-Korsakoff syndrome",
    "Referral and admission criteria",
]
for cb in cover_bullets:
    story.append(Paragraph(f"<font color='#FDE9D4'>&#8226;</font>  <font color='#FFFFFF'>{cb}</font>",
                            S("CBul", fontSize=10, fontName="Helvetica",
                              textColor=WHITE, leading=16, leftIndent=60)))

story.append(Spacer(1, 3.2*cm))
story.append(Paragraph("June 2026  |  Evidence-based  |  Clinical Decision Support", cover_note))
story.append(Paragraph(
    "This guide is for educational and clinical decision-support purposes. "
    "Always apply clinical judgment to individual patient circumstances.",
    S("Disc", fontSize=8, fontName="Helvetica-Oblique",
      textColor=colors.HexColor("#AAAAAA"), alignment=TA_CENTER,
      spaceBefore=4)))

story.append(PageBreak())

# ══════════════════════════════════════════════════════════════════
# PAGE 2 – PATHOPHYSIOLOGY & STAGING
# ══════════════════════════════════════════════════════════════════
story.append(Spacer(1, 0.3*cm))
story.append(banner("1.  PATHOPHYSIOLOGY", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))
story.append(Paragraph(
    "Chronic alcohol acts as a CNS depressant by enhancing GABA-A receptor activity and inhibiting NMDA glutamate receptors. "
    "With prolonged use, the brain <b>down-regulates GABA activity</b> and <b>up-regulates excitatory glutamate pathways</b> to compensate. "
    "When alcohol is abruptly reduced or stopped, this neuroadaptation produces a state of <b>CNS hyperexcitability</b>, "
    "manifesting as the alcohol withdrawal syndrome (AWS). Only a <i>reduction</i>, not necessarily complete cessation, can trigger AWS.",
    body))
story.append(Spacer(1, 0.3*cm))

story.append(banner("2.  CLINICAL STAGING & SYMPTOM TIMELINE", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))

timeline_data = [
    [Paragraph("Stage", tbl_hdr_style),
     Paragraph("Hours After Last Drink", tbl_hdr_style),
     Paragraph("Key Features", tbl_hdr_style),
     Paragraph("Risk", tbl_hdr_style)],
    [Paragraph("Minor / Early", tbl_body_ctr),
     Paragraph("6 - 24 h\n(peaks 24-48 h)", tbl_body_ctr),
     Paragraph("Tremors, anxiety, irritability, nausea/vomiting, diaphoresis, tachycardia, hypertension, insomnia, anorexia", tbl_body_style),
     Paragraph("Low", S("G", fontSize=8.5, fontName="Helvetica-Bold", textColor=GREEN, alignment=TA_CENTER))],
    [Paragraph("Hallucinosis", tbl_body_ctr),
     Paragraph("8 - 48 h", tbl_body_ctr),
     Paragraph("Visual/auditory/tactile hallucinations with CLEAR sensorium (distinguishes from DTs)", tbl_body_style),
     Paragraph("Moderate", S("O", fontSize=8.5, fontName="Helvetica-Bold", textColor=ORANGE, alignment=TA_CENTER))],
    [Paragraph("Seizures", tbl_body_ctr),
     Paragraph("12 - 48 h\n(peaks ~24 h)", tbl_body_ctr),
     Paragraph("Generalised tonic-clonic seizures. Usually self-limiting (1-2 brief convulsions). Status epilepticus rare.", tbl_body_style),
     Paragraph("High", S("R", fontSize=8.5, fontName="Helvetica-Bold", textColor=RED, alignment=TA_CENTER))],
    [Paragraph("Delirium Tremens (DTs)", tbl_body_ctr),
     Paragraph("48 - 96 h\n(peaks 72 h)", tbl_body_ctr),
     Paragraph("Gross tremor, agitation, confusion/disorientation, autonomic storm (fever, marked tachycardia, hypertension, diaphoresis), visual hallucinations", tbl_body_style),
     Paragraph("CRITICAL\nMortality 5-15%", S("RC", fontSize=8.5, fontName="Helvetica-Bold", textColor=RED, alignment=TA_CENTER))],
]

timeline_tbl = Table(timeline_data, colWidths=[3.2*cm, 3.2*cm, 7.8*cm, 2.6*cm])
timeline_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), DARK_BLUE),
    ("BACKGROUND",    (0,2), (-1,2), ORANGE_LITE),
    ("BACKGROUND",    (0,3), (-1,3), RED_LITE),
    ("BACKGROUND",    (0,4), (-1,4), colors.HexColor("#FDECEA")),
    ("ROWBACKGROUNDS",(0,1), (-1,1), [LIGHT_GREY]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(timeline_tbl)
story.append(Spacer(1, 0.15*cm))
story.append(Paragraph(
    "<i>Note: Symptoms may begin before blood alcohol reaches zero. "
    "A mild protracted syndrome can persist for 4-6 months after cessation.</i>",
    caption))

story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════
# PAGE 3 – CIWA-Ar + RISK STRATIFICATION
# ══════════════════════════════════════════════════════════════════
story.append(banner("3.  CIWA-Ar SCORING", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))
story.append(info_box(
    "<b>CIWA-Ar</b> (Clinical Institute Withdrawal Assessment for Alcohol - Revised) is the standard validated tool "
    "used to assess AWS severity and guide treatment decisions. Score 9 items (each 0-7) + 1 orientation item (0-4). "
    "<b>Maximum score = 67.</b>"))
story.append(Spacer(1, 0.2*cm))

ciwa_items = [
    ["#", "Domain", "What to Ask / Observe", "Max Score"],
    ["1", "Nausea / Vomiting", "Does your stomach feel sick? Have you vomited?", "7"],
    ["2", "Tremor", "Arms extended, fingers spread. Observe severity.", "7"],
    ["3", "Paroxysmal Sweats", "Observe for diaphoresis.", "7"],
    ["4", "Anxiety", "Do you feel nervous? Observe agitation.", "7"],
    ["5", "Tactile Disturbances", "Itching, pins/needles, burning, bugs under skin?", "7"],
    ["6", "Auditory Disturbances", "Do sounds seem harsh? Hearing things not there?", "7"],
    ["7", "Visual Disturbances", "Does light seem bright? Seeing things not there?", "7"],
    ["8", "Headache", "Band-like headache, different from usual?", "7"],
    ["9", "Agitation", "Observe patient behaviour during interview.", "7"],
    ["10", "Orientation / Clouding", "What day is it? Where are you? Who am I?", "4"],
]
ciwa_data = [[Paragraph(c, tbl_hdr_style if i==0 else
              (tbl_body_ctr if j in (0,3) else tbl_body_style))
              for j,c in enumerate(row)] for i,row in enumerate(ciwa_items)]

ciwa_tbl = Table(ciwa_data, colWidths=[0.8*cm, 3.5*cm, 10.3*cm, 2.0*cm])
ciwa_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), MED_BLUE),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LIGHT_GREY]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(ciwa_tbl)
story.append(Spacer(1, 0.2*cm))

# CIWA interpretation
ciwa_interp = [
    [Paragraph("CIWA-Ar Score", tbl_hdr_style),
     Paragraph("Severity", tbl_hdr_style),
     Paragraph("Typical Management", tbl_hdr_style)],
    [Paragraph("< 8", tbl_body_ctr),
     Paragraph("Mild", S("Mild", fontSize=8.5, fontName="Helvetica-Bold", textColor=GREEN, alignment=TA_CENTER)),
     Paragraph("Supportive care. Monitor every 4-8 h. Consider outpatient if criteria met.", tbl_body_style)],
    [Paragraph("8 - 15", tbl_body_ctr),
     Paragraph("Moderate", S("Mod", fontSize=8.5, fontName="Helvetica-Bold", textColor=ORANGE, alignment=TA_CENTER)),
     Paragraph("Benzodiazepines PRN or fixed schedule. Consider inpatient.", tbl_body_style)],
    [Paragraph("> 15", tbl_body_ctr),
     Paragraph("Severe", S("Sev", fontSize=8.5, fontName="Helvetica-Bold", textColor=RED, alignment=TA_CENTER)),
     Paragraph("Inpatient/ICU. Aggressive benzodiazepine therapy. Thiamine IV. Monitor closely.", tbl_body_style)],
]
ci2 = Table(ciwa_interp, colWidths=[3*cm, 3*cm, 11*cm])
ci2.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), DARK_BLUE),
    ("BACKGROUND",    (0,2), (-1,2), ORANGE_LITE),
    ("BACKGROUND",    (0,3), (-1,3), RED_LITE),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(ci2)
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════════
# PAGE 4 – PHARMACOLOGICAL MANAGEMENT
# ══════════════════════════════════════════════════════════════════
story.append(Spacer(1, 0.3*cm))
story.append(banner("4.  PHARMACOLOGICAL MANAGEMENT", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("4a.  Benzodiazepines - First-Line Treatment", sub_hdr))
story.append(info_box(
    "Benzodiazepines are <b>first-line therapy</b> for AWS at all severity levels. They reduce withdrawal symptoms, "
    "prevent seizures and delirium tremens, and reduce mortality. They work by substituting for alcohol's "
    "GABA-A receptor enhancement effect. Two approaches exist: <b>symptom-triggered</b> (preferred) or <b>fixed-schedule taper</b>."))
story.append(Spacer(1, 0.2*cm))

benzo_data = [
    [Paragraph("Drug", tbl_hdr_style),
     Paragraph("Route", tbl_hdr_style),
     Paragraph("Dose", tbl_hdr_style),
     Paragraph("Special Notes", tbl_hdr_style)],
    [Paragraph("Diazepam\n(preferred - long-acting)", tbl_body_style),
     Paragraph("PO / IV", tbl_body_ctr),
     Paragraph("10 mg PO/IV q4-6 h on day 1\nTaper to zero over 5 days\nIV: 10 mg q5-20 min until control", tbl_body_style),
     Paragraph("Long half-life provides smoother control. AVOID in severe liver disease.", tbl_body_style)],
    [Paragraph("Chlordiazepoxide\n(long-acting, PO-only)", tbl_body_style),
     Paragraph("PO", tbl_body_ctr),
     Paragraph("25-50 mg q4-6 h (day 1)\nMax 300 mg/day\nTaper over 5 days", tbl_body_style),
     Paragraph("Good for mild-moderate withdrawal. Avoid in liver impairment.", tbl_body_style)],
    [Paragraph("Lorazepam\n(intermediate, no active metabolites)", tbl_body_style),
     Paragraph("PO / IV / IM", tbl_body_ctr),
     Paragraph("2-4 mg IV/IM q15-20 min\nthen q4-6 h PO", tbl_body_style),
     Paragraph("Preferred in elderly, liver disease, respiratory disease. Shorter-acting - must be given regularly (q4 h) to avoid fluctuations.", tbl_body_style)],
    [Paragraph("Oxazepam\n(short-acting, renally cleared)", tbl_body_style),
     Paragraph("PO", tbl_body_ctr),
     Paragraph("15-30 mg q6-8 h PRN", tbl_body_style),
     Paragraph("<b>CHOICE in severe hepatic failure</b> (renally excreted, no liver metabolism). Safe in cirrhosis.", tbl_body_style)],
]

benzo_tbl = Table(benzo_data, colWidths=[3.8*cm, 1.8*cm, 5.5*cm, 6.5*cm])
benzo_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), MED_BLUE),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LIGHT_GREY, WHITE, LIGHT_GREY]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(benzo_tbl)
story.append(Spacer(1, 0.15*cm))
story.append(alert_box(
    "WARNING: Do NOT use IV fluids routinely - most withdrawing patients are normally or mildly over-hydrated. "
    "Use IV fluids only if significant vomiting, diarrhoea, fever/diaphoresis, or recent bleeding."))
story.append(Spacer(1, 0.25*cm))

story.append(Paragraph("4b.  Adjunct / Refractory Medications", sub_hdr))
adj_data = [
    [Paragraph("Drug", tbl_hdr_style),
     Paragraph("Indication", tbl_hdr_style),
     Paragraph("Notes", tbl_hdr_style)],
    [Paragraph("Propofol", tbl_body_style),
     Paragraph("Benzo-refractory DTs (ICU)", tbl_body_style),
     Paragraph("Requires intubation/ICU. Use only when benzodiazepines fail.", tbl_body_style)],
    [Paragraph("Dexmedetomidine", tbl_body_style),
     Paragraph("Benzo-refractory DTs (ICU)", tbl_body_style),
     Paragraph("Alpha-2 agonist. Adjunct to benzodiazepines in ICU.", tbl_body_style)],
    [Paragraph("Carbamazepine", tbl_body_style),
     Paragraph("Seizure prophylaxis (alternative)", tbl_body_style),
     Paragraph("Some guidelines recommend loading if seizures occur despite adequate benzos.", tbl_body_style)],
    [Paragraph("Haloperidol", tbl_body_style),
     Paragraph("Refractory hallucinations", tbl_body_style),
     Paragraph("Always combine with benzodiazepine - never use alone (lowers seizure threshold).", tbl_body_style)],
    [Paragraph("Phenytoin", tbl_body_style),
     Paragraph("<b>NOT recommended</b>", tbl_red),
     Paragraph("Phenytoin does NOT prevent alcohol withdrawal seizures. Do not use alone or with benzos.", tbl_body_style)],
]
adj_tbl = Table(adj_data, colWidths=[3.5*cm, 4.5*cm, 9.6*cm])
adj_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), DARK_BLUE),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LIGHT_GREY, WHITE, LIGHT_GREY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(adj_tbl)
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════════
# PAGE 5 – THIAMINE & NUTRITION
# ══════════════════════════════════════════════════════════════════
story.append(Spacer(1, 0.3*cm))
story.append(banner("5.  THIAMINE (VITAMIN B1) & NUTRITIONAL MANAGEMENT", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))
story.append(alert_box(
    "CRITICAL RULE: ALWAYS give Thiamine BEFORE glucose / dextrose-containing fluids. "
    "Giving glucose to a thiamine-deficient patient can precipitate or worsen Wernicke Encephalopathy."))
story.append(Spacer(1, 0.25*cm))

story.append(Paragraph(
    "Chronic alcoholics have near-universal thiamine (Vitamin B1) deficiency due to: poor dietary intake, "
    "impaired gut absorption (alcohol directly inhibits thiamine transport), reduced hepatic storage, and increased metabolic demand. "
    "<b>Oral thiamine tablets are NOT adequate</b> in this population - intestinal absorption is unreliable in debilitated and alcoholic patients, "
    "especially in the presence of vomiting.", body))
story.append(Spacer(1, 0.2*cm))

thia_data = [
    [Paragraph("Clinical Situation", tbl_hdr_style),
     Paragraph("Thiamine Dose & Route", tbl_hdr_style),
     Paragraph("Duration", tbl_hdr_style)],
    [Paragraph("Mild withdrawal, no confusion\n(thiamine deficiency suspected)", tbl_body_style),
     Paragraph("100-500 mg IM/IV\nthen 100 mg PO daily", tbl_body_style),
     Paragraph("At least 1 week PO continuation", tbl_body_style)],
    [Paragraph("Confusion / altered mental status\n(Wernicke suspected)", tbl_body_style),
     Paragraph("<b>500 mg IV</b> (over 30 min) STAT\nthen 100 mg IV/IM three times daily", S("Bold", fontSize=8.5, fontName="Helvetica-Bold", textColor=RED, alignment=TA_LEFT)),
     Paragraph("First week IV/IM\nThen oral once tolerating", tbl_body_style)],
    [Paragraph("Outpatient / mild stable patient", tbl_body_style),
     Paragraph("50-100 mg PO daily\n(ONLY if no vomiting, no confusion, reliable absorption)", tbl_body_style),
     Paragraph("Minimum 1 month", tbl_body_style)],
]
thia_tbl = Table(thia_data, colWidths=[5.5*cm, 7.0*cm, 5.1*cm])
thia_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), MED_BLUE),
    ("BACKGROUND",    (0,2), (-1,2), RED_LITE),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHT_GREY, RED_LITE, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(thia_tbl)
story.append(Spacer(1, 0.2*cm))
story.append(Paragraph("Additional Nutritional Replacement", sub_hdr))
nutr_items = [
    "Multivitamins (including <b>folic acid</b>) daily - oral or IV",
    "<b>Magnesium sulfate</b>: IV replacement if hypomagnesaemia present (common in alcoholics). Magnesium is required for thiamine to function - correct before expecting thiamine response.",
    "<b>Potassium</b>: Monitor and replace - hypokalaemia is common",
    "<b>Glucose</b>: Correct hypoglycaemia ONLY after thiamine has been given",
    "Balanced diet and nutritional support as tolerated",
    "<b>Fluid balance</b>: Most patients are normally or mildly over-hydrated - avoid routine IV fluids",
]
for ni in nutr_items:
    story.append(Paragraph(f"&#8226;  {ni}", bullet))
story.append(Spacer(1, 0.3*cm))

# Wernicke section
story.append(banner("6.  WERNICKE ENCEPHALOPATHY & KORSAKOFF SYNDROME", bg=colors.HexColor("#7B241C")))
story.append(Spacer(1, 0.2*cm))
story.append(alert_box(
    "Wernicke Encephalopathy is NOT an alcohol withdrawal syndrome - it is caused by thiamine deficiency. "
    "Only ~20% of cases are diagnosed during life. Do NOT wait for the full triad - treat empirically."))
story.append(Spacer(1, 0.2*cm))

we_cols = [
    ["CLASSIC TRIAD\n(Only 1-2 features needed for diagnosis)",
     "RISK FACTORS",
     "TREATMENT"],
    ["1. Confusion / altered mental status\n2. Ophthalmoplegia / nystagmus / gaze palsy\n3. Ataxia (cerebellar signs)",
     "- Chronic alcohol use (most common)\n- Malnutrition / prolonged vomiting\n- Hyperemesis gravidarum\n- Post-bariatric surgery\n- Receiving IV glucose without thiamine",
     "500 mg Thiamine IV STAT (before any glucose)\nthen 100 mg IV TDS x 1 week\nTreat until symptoms resolve\n\nKorsakoff Syndrome = chronic form:\nmemory loss + confabulation\n(limited treatment options)"],
]
we_data = [[Paragraph(we_cols[0][i], S("WEH", fontSize=8.5, fontName="Helvetica-Bold",
                                       textColor=WHITE, alignment=TA_CENTER))
            for i in range(3)],
           [Paragraph(we_cols[1][i], S("WEB", fontSize=8.5, fontName="Helvetica",
                                       textColor=BLACK, leading=13))
            for i in range(3)]]

we_tbl = Table(we_data, colWidths=[5.8*cm, 5.8*cm, 6.0*cm])
we_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), colors.HexColor("#7B241C")),
    ("BACKGROUND",    (0,1), (-1,1), colors.HexColor("#FDFEFE")),
    ("BACKGROUND",    (2,1), (2,1), RED_LITE),
    ("GRID",          (0,0), (-1,-1), 0.8, colors.HexColor("#C0392B")),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ("TOPPADDING",    (0,0), (-1,-1), 6),
    ("BOTTOMPADDING", (0,0), (-1,-1), 6),
    ("LEFTPADDING",   (0,0), (-1,-1), 7),
    ("RIGHTPADDING",  (0,0), (-1,-1), 7),
]))
story.append(we_tbl)
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════════
# PAGE 6 – DTs, SEIZURES, OUTPATIENT CRITERIA, ADMISSION
# ══════════════════════════════════════════════════════════════════
story.append(Spacer(1, 0.3*cm))
story.append(banner("7.  DELIRIUM TREMENS (DTs) - EMERGENCY MANAGEMENT", bg=colors.HexColor("#922B21")))
story.append(Spacer(1, 0.2*cm))
story.append(info_box(
    "<b>Delirium Tremens</b> complicates ~5% of alcohol withdrawal cases. Mortality is 5-15% untreated, "
    "and requires ICU-level care. It typically begins 48-96 h after last drink and runs 3-5 days regardless of therapy. "
    "Always preceded by minor withdrawal (which may be missed in hospitalised or sedated patients)."))
story.append(Spacer(1, 0.15*cm))

dt_data = [
    [Paragraph("Clinical Feature", tbl_hdr_style),
     Paragraph("Detail", tbl_hdr_style)],
    [Paragraph("DSM-5 Criteria", tbl_body_style),
     Paragraph("Alcohol withdrawal + Delirium (confusion, disorientation, fluctuating consciousness, autonomic hyperactivity)", tbl_body_style)],
    [Paragraph("Hallmark Signs", tbl_body_style),
     Paragraph("Gross tremor, agitation, confusion, visual hallucinations, fever, tachycardia (HR >100), diaphoresis, hypertension", tbl_body_style)],
    [Paragraph("First-Line Tx", tbl_body_style),
     Paragraph("High-dose IV diazepam (10 mg q5-20 min) OR lorazepam IV (2-4 mg q15-20 min) until agitation controlled. Up to 800 mg/day chlordiazepoxide has been reported.", tbl_body_style)],
    [Paragraph("Refractory DTs", tbl_body_style),
     Paragraph("Propofol (requires intubation) or dexmedetomidine (ICU adjunct)", tbl_body_style)],
    [Paragraph("Supportive Care", tbl_body_style),
     Paragraph("Correct electrolytes (Mg, K, glucose), IV thiamine, monitor vital signs continuously, ICU admission", tbl_body_style)],
]
dt_tbl = Table(dt_data, colWidths=[4.5*cm, 13.1*cm])
dt_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), colors.HexColor("#922B21")),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LIGHT_GREY, WHITE, LIGHT_GREY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, RED),
]))
story.append(dt_tbl)
story.append(Spacer(1, 0.3*cm))

story.append(banner("8.  ALCOHOL WITHDRAWAL SEIZURES", bg=MED_BLUE))
story.append(Spacer(1, 0.2*cm))
sz_items = [
    "Occur in <b>12-48 h</b> after last drink. Usually 1-2 brief generalised tonic-clonic seizures.",
    "Risk increases with: older age, prior seizure history, higher alcohol intake, concurrent benzodiazepine/drug use.",
    "<b>Benzodiazepines</b> (especially long-acting, e.g. diazepam) are the primary prophylactic and treatment agent.",
    "<b>Phenytoin does NOT prevent alcohol withdrawal seizures</b> - do not use alone or as adjunct.",
    "After a first seizure: <b>investigate to exclude other causes</b> (head trauma, intracranial pathology, metabolic causes, idiopathic epilepsy).",
    "Standard antiepileptic drugs are <b>NOT required long-term</b> for alcohol withdrawal seizures.",
    "If seizures occur despite adequate benzodiazepine loading: consider carbamazepine loading.",
    "If hypoglycaemia is present: <b>give thiamine first, THEN glucose</b>.",
]
for si in sz_items:
    story.append(Paragraph(f"&#8226;  {si}", bullet))
story.append(Spacer(1, 0.3*cm))

story.append(banner("9.  ADMISSION & OUTPATIENT CRITERIA", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))

crit_data = [
    [Paragraph("SAFE FOR OUTPATIENT MANAGEMENT", S("OPH", fontSize=9, fontName="Helvetica-Bold",
               textColor=GREEN, alignment=TA_CENTER)),
     Paragraph("ADMIT TO HOSPITAL", S("IPH", fontSize=9, fontName="Helvetica-Bold",
               textColor=RED, alignment=TA_CENTER))],
    [Paragraph(
        "- Mild withdrawal (CIWA-Ar < 8)\n"
        "- Good physical condition\n"
        "- No prior history of DTs or seizures\n"
        "- Able to cooperate with outpatient protocol\n"
        "- No significant comorbidities\n"
        "- Reliable support person at home\n"
        "- Daily review possible for 4-5 days\n"
        "- Supply only 1-2 days of medications at a time",
        S("OP", fontSize=8.5, fontName="Helvetica", textColor=BLACK, leading=14)),
     Paragraph(
        "- Moderate-severe withdrawal (CIWA-Ar >= 8-12)\n"
        "- Prior history of withdrawal seizures or DTs\n"
        "- Current confusion / Wernicke signs\n"
        "- Unable to tolerate oral fluids (vomiting)\n"
        "- Comorbid psychiatric or medical conditions\n"
        "- Failed outpatient detoxification\n"
        "- Unable to cooperate with outpatient protocol\n"
        "- High alcohol intake (>15 units/day)\n"
        "- Concurrent drug use",
        S("IP", fontSize=8.5, fontName="Helvetica", textColor=BLACK, leading=14))],
]
crit_tbl = Table(crit_data, colWidths=[8.8*cm, 8.8*cm])
crit_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (0,0), GREEN_LITE),
    ("BACKGROUND",    (1,0), (1,0), RED_LITE),
    ("BACKGROUND",    (0,1), (0,1), colors.HexColor("#F9FFF9")),
    ("BACKGROUND",    (1,1), (1,1), colors.HexColor("#FFF9F9")),
    ("BOX",           (0,0), (0,-1), 1.5, GREEN),
    ("BOX",           (1,0), (1,-1), 1.5, RED),
    ("LINEBELOW",     (0,0), (-1,0), 1, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ("TOPPADDING",    (0,0), (-1,-1), 7),
    ("BOTTOMPADDING", (0,0), (-1,-1), 7),
    ("LEFTPADDING",   (0,0), (-1,-1), 8),
    ("RIGHTPADDING",  (0,0), (-1,-1), 8),
]))
story.append(crit_tbl)
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════════
# PAGE 7 – MONITORING, ELECTROLYTES, LABS, SPECIAL POPULATIONS
# ══════════════════════════════════════════════════════════════════
story.append(Spacer(1, 0.3*cm))
story.append(banner("10.  MONITORING & INVESTIGATIONS", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))

mon_data = [
    [Paragraph("Parameter", tbl_hdr_style),
     Paragraph("Frequency", tbl_hdr_style),
     Paragraph("Action Trigger", tbl_hdr_style)],
    [Paragraph("Vital signs (HR, BP, temp, RR, SpO2)", tbl_body_style),
     Paragraph("Every 1-4 h (inpatient)", tbl_body_ctr),
     Paragraph("HR >100, SBP >160, temp >38.5 - escalate treatment", tbl_body_style)],
    [Paragraph("CIWA-Ar score", tbl_body_style),
     Paragraph("Every 4-8 h or per protocol", tbl_body_ctr),
     Paragraph("Score >8 - initiate/increase benzodiazepine", tbl_body_style)],
    [Paragraph("Blood glucose", tbl_body_style),
     Paragraph("On admission + as needed", tbl_body_ctr),
     Paragraph("Hypoglycaemia: thiamine first, then glucose", tbl_body_style)],
    [Paragraph("Serum electrolytes (Na, K, Mg, PO4)", tbl_body_style),
     Paragraph("On admission + daily", tbl_body_ctr),
     Paragraph("Replace Mg and K aggressively - critical for thiamine efficacy and arrhythmia prevention", tbl_body_style)],
    [Paragraph("LFTs, FBC, coagulation (INR)", tbl_body_style),
     Paragraph("On admission", tbl_body_ctr),
     Paragraph("Liver failure: switch to renally-cleared benzo (oxazepam/lorazepam)", tbl_body_style)],
    [Paragraph("Urinalysis, blood cultures", tbl_body_style),
     Paragraph("If febrile or confused", tbl_body_ctr),
     Paragraph("Infection is a key trigger/precipitant - must be excluded", tbl_body_style)],
    [Paragraph("CT head / MRI brain", tbl_body_style),
     Paragraph("If first seizure or focal neurology", tbl_body_ctr),
     Paragraph("MRI: Wernicke lesions (T2/FLAIR - medial thalami, mammillary bodies, periaqueductal region)", tbl_body_style)],
]
mon_tbl = Table(mon_data, colWidths=[5.0*cm, 3.5*cm, 9.1*cm])
mon_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), MED_BLUE),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LIGHT_GREY, WHITE, LIGHT_GREY, WHITE, LIGHT_GREY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(mon_tbl)
story.append(Spacer(1, 0.3*cm))

story.append(banner("11.  SPECIAL POPULATIONS", bg=DARK_BLUE))
story.append(Spacer(1, 0.2*cm))

spec_data = [
    [Paragraph("Population", tbl_hdr_style),
     Paragraph("Key Considerations", tbl_hdr_style)],
    [Paragraph("Liver disease / Cirrhosis", tbl_body_style),
     Paragraph("Use OXAZEPAM or LORAZEPAM (renally cleared - not hepatically metabolised). "
               "Avoid diazepam and chlordiazepoxide. Risk of hepatic encephalopathy overlapping with DTs.", tbl_body_style)],
    [Paragraph("Elderly patients", tbl_body_style),
     Paragraph("Use SHORT-ACTING benzodiazepines (lorazepam, oxazepam). Increased sensitivity, risk of over-sedation and falls. "
               "Lower doses required. Higher risk of severe withdrawal.", tbl_body_style)],
    [Paragraph("Respiratory disease / COPD", tbl_body_style),
     Paragraph("Use benzodiazepines cautiously - respiratory depression risk. Lorazepam preferred. "
               "Monitor SpO2 continuously.", tbl_body_style)],
    [Paragraph("Pregnancy", tbl_body_style),
     Paragraph("Inpatient management recommended (American Society of Addiction Medicine). "
               "Benzodiazepines remain first-line. Thiamine replacement essential. "
               "Fetal monitoring required.", tbl_body_style)],
    [Paragraph("Concurrent benzodiazepine use", tbl_body_style),
     Paragraph("Higher doses of benzodiazepines likely required. Combined withdrawal syndrome may be more severe. "
               "Closely supervised inpatient detoxification.", tbl_body_style)],
]
spec_tbl = Table(spec_data, colWidths=[4.0*cm, 13.6*cm])
spec_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), DARK_BLUE),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LIGHT_GREY, WHITE, LIGHT_GREY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("LINEBELOW",     (0,0), (-1,0), 1.5, MED_BLUE),
]))
story.append(spec_tbl)
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════════
# PAGE 8 – QUICK REFERENCE SUMMARY
# ══════════════════════════════════════════════════════════════════
story.append(Spacer(1, 0.3*cm))
story.append(banner("12.  QUICK REFERENCE SUMMARY", bg=DARK_BLUE))
story.append(Spacer(1, 0.3*cm))

summary_items = [
    ("<b>ALL alcoholic patients:</b>", "Thiamine BEFORE any glucose. Multivitamins. Check electrolytes."),
    ("<b>Mild AWS (CIWA &lt; 8):</b>", "Supportive care. Monitor CIWA. Consider outpatient if safe criteria met."),
    ("<b>Moderate AWS (CIWA 8-15):</b>", "Benzodiazepines PRN (diazepam 10 mg PO or chlordiazepoxide 25-50 mg PO). Inpatient recommended."),
    ("<b>Severe AWS / DTs (CIWA &gt; 15):</b>", "IV diazepam 10 mg q5-20 min or IV lorazepam 2-4 mg q15-20 min until control. ICU."),
    ("<b>Confusion / Wernicke signs:</b>", "500 mg IV Thiamine STAT. Then 100 mg IV TDS x 1 week. Never oral in acute setting."),
    ("<b>Withdrawal seizures:</b>", "Benzodiazepines first-line. NOT phenytoin. Investigate first seizure. No long-term AEDs needed."),
    ("<b>Liver disease:</b>", "Oxazepam or lorazepam ONLY (renally cleared)."),
    ("<b>IV fluids:</b>", "Do NOT give routinely. Only if vomiting, bleeding, or haemodynamically compromised."),
    ("<b>Outpatient treatment:</b>", "Only if CIWA &lt; 8, no prior DTs/seizures, no confusion, able to comply, daily review possible."),
]

for label, text in summary_items:
    row_data = [[Paragraph(label, S("SumL", fontSize=9, fontName="Helvetica-Bold",
                                    textColor=DARK_BLUE, alignment=TA_LEFT)),
                 Paragraph(text, S("SumR", fontSize=9, fontName="Helvetica",
                                   textColor=BLACK, leading=13, alignment=TA_LEFT))]]
    rt = Table(row_data, colWidths=[5.5*cm, 12.1*cm])
    rt.setStyle(TableStyle([
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
        ("LINEBELOW",     (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
    ]))
    story.append(rt)

story.append(Spacer(1, 0.4*cm))
story.append(HRFlowable(width="100%", thickness=1, color=MED_BLUE))
story.append(Spacer(1, 0.2*cm))
story.append(Paragraph(
    "<b>References:</b> Harrison's Principles of Internal Medicine 22e (2025) | The Washington Manual of Medical Therapeutics | "
    "Rosen's Emergency Medicine 9e | Bradley and Daroff's Neurology in Clinical Practice | "
    "The Maudsley Prescribing Guidelines in Psychiatry 15e | Kaplan and Sadock's Synopsis of Psychiatry | "
    "DSM-5 (American Psychiatric Association)",
    S("Refs", fontSize=7.5, fontName="Helvetica-Oblique", textColor=GREY, leading=11)))

story.append(Spacer(1, 0.2*cm))
story.append(Paragraph(
    "This reference guide is for educational and clinical decision-support purposes only. "
    "Individual clinical judgment must always be applied. Refer to current local guidelines and formularies for prescribing decisions.",
    S("Disc2", fontSize=7.5, fontName="Helvetica-Oblique", textColor=GREY,
      alignment=TA_CENTER, leading=11)))

# ─── Build the document ───────────────────────────────────────────────────────
doc = BaseDocTemplate(
    OUTPUT,
    pagesize=A4,
    rightMargin=1.5*cm, leftMargin=1.5*cm,
    topMargin=2.8*cm, bottomMargin=2.0*cm,
)

content_frame = Frame(
    1.5*cm, 2.0*cm,
    A4[0] - 3.0*cm,
    A4[1] - 4.8*cm,
    id="content"
)

cover_frame = Frame(
    1.5*cm, 2.0*cm,
    A4[0] - 3.0*cm,
    A4[1] - 3.0*cm,
    id="cover"
)

doc.addPageTemplates([
    PageTemplate(id="Cover", frames=[cover_frame], onPage=first_page),
    PageTemplate(id="Interior", frames=[content_frame], onPage=add_page_decorations),
])

from reportlab.platypus import NextPageTemplate
story.insert(0, NextPageTemplate("Interior"))
story.insert(0, NextPageTemplate("Cover"))

# Insert page template switch after cover page break
# Find the first PageBreak and insert a NextPageTemplate before it
for i, el in enumerate(story):
    if isinstance(el, PageBreak) and i > 5:
        story.insert(i, NextPageTemplate("Interior"))
        break

doc.build(story)
print(f"PDF created: {OUTPUT}")
Running Command

cd /home/daytona/workspace/alcohol-withdrawal-guide && python build_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/alcohol-withdrawal-guide/Acute_Alcohol_Withdrawal_Reference_Guide.pdf

Your reference guide is ready. Here's the download link:

Acute Alcohol Withdrawal Reference Guide

PDF Document · PDF


Here's what the 8-page guide covers, sourced from 6 major medical textbooks (Harrison's, Washington Manual, Rosen's EM, Bradley & Daroff Neurology, Maudsley Prescribing Guidelines, Kaplan & Sadock):
SectionContent
1. PathophysiologyGABA/NMDA neuroadaptation mechanism
2. Staging & TimelineColour-coded table: minor withdrawal → hallucinosis → seizures → DTs, with exact hour ranges
3. CIWA-Ar ScoringFull 10-item scoring table + interpretation guide (mild/moderate/severe)
4. Pharmacological ManagementBenzodiazepine comparison table (diazepam, chlordiazepoxide, lorazepam, oxazepam) with doses and special notes; adjunct/refractory agents
5. Thiamine & NutritionDosing table by clinical situation; CRITICAL rule box: thiamine before glucose
6. Wernicke-KorsakoffClassic triad, risk factors, treatment - emphasising empirical treatment without full triad
7. DTs + SeizuresEmergency management protocols
8-10. Admission Criteria, Monitoring, Special PopulationsLiver disease, elderly, pregnancy, COPD benzo guidance
11. Quick Reference SummarySingle-glance decision card covering all key rules
This is a shared conversation. Sign in to Orris to start your own chat.