Causes of Hospital acquired infections . Prevention of HAI in ice. Long question for MD Anaesthesia exam

Reading File
Finding Sources
Finding Sources
Searching PubMed

"hospital acquired infection" AND "intensive care unit" AND prevention

Finding Sources
Finding Sources
Searching PubMed

"healthcare associated infection" AND ICU AND prevention

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
I now have comprehensive, high-quality content from authoritative anaesthesia and surgery textbooks. Let me compile the full MD Anaesthesia exam answer.

Hospital-Acquired Infections (HAI): Causes and Prevention in ICU

Long Answer — MD Anaesthesia Examination


DEFINITION

A Hospital-Acquired Infection (HAI), also called a nosocomial infection, is an infection occurring in a hospitalised patient that was not present or incubating at the time of admission. In the ICU context, it includes infections developing ≥48 hours after admission. HAIs represent a major source of morbidity and mortality in critically ill patients and constitute a significant economic burden — estimated at $7.2–14.9 billion annually in the United States.

CLASSIFICATION OF HAI IN ICU

The major HAIs encountered in ICU anaesthetic practice are:
TypeAcronymDefinition
Ventilator-Associated PneumoniaVAPNew pneumonia ≥48 h after intubation
Catheter-Related Bloodstream InfectionCRBSI/CLABSIBSI attributed to intravascular catheter
Catheter-Associated Urinary Tract InfectionCAUTIUTI in a catheterised patient
Surgical Site InfectionSSIInfection at operative wound site
Clostridioides difficile InfectionCDIAntibiotic-associated colitis
ICU-Acquired SinusitisRelated to nasal/oral tubes
Invasive Fungal InfectionIFICandida/Aspergillus in susceptible hosts

PART I: CAUSES OF HOSPITAL-ACQUIRED INFECTIONS

A. Host-Related Factors

  1. Critical illness — altered immune defences, malnutrition, underlying comorbidities (diabetes, malignancy, renal failure, COPD)
  2. Extremes of age — neonates and the elderly have impaired immunity
  3. Immunosuppression — steroids, chemotherapy, immunomodulatory therapy
  4. Disrupted skin/mucosal barriers — surgical wounds, intravascular catheters, endotracheal tubes, urinary catheters
  5. Altered microbiome — broad-spectrum antibiotics promote colonisation with resistant organisms

B. Pathogen-Related Factors

Common organisms in ICU HAIs:
SourceEarly (< 48–72 h)Late (> 72 h)
VAPH. influenzae, S. pneumoniae, MSSA, oral floraMRSA, Pseudomonas aeruginosa, Acinetobacter
CRBSIS. epidermidis, S. aureusEnterococcus, Enteric GNRs, Pseudomonas, Candida
CAUTIStaphylococci, Enterococcus, Enteric GNRs, Pseudomonas
CDIClostridioides difficile (spore-forming)
Key pathogens of significance: MRSA, MDR Gram-negatives (Pseudomonas, Acinetobacter, Klebsiella — ESKAPE pathogens), extended-spectrum β-lactamase (ESBL) producers, VRE, and Candida species.

C. Device/Procedure-Related Factors

  1. Endotracheal tube — bypasses mucociliary clearance; pooling of secretions above the cuff leads to microaspiration → VAP
  2. Nasotracheal intubation — blocks sinus ostia; ~95% of patients develop radiographic sinusitis after 1 week (vs. ~25% with oral intubation)
  3. Central venous catheters — skin colonisation, hub contamination, hematogenous seeding, contaminated infusate; biofilm formation on catheter surface
  4. Urinary bladder catheter — bacteriuria increases with duration; ~5% develop bacteremia
  5. Nasogastric tube — disrupts gastroesophageal barrier; increases aspiration risk

D. Environmental and Healthcare System Factors

  1. Hand hygiene non-compliance — the single most important preventable cause of cross-transmission
  2. Contaminated equipment and surfaces — inadequate disinfection/sterilisation
  3. Crowding and understaffing — particularly relevant during surges (e.g., COVID-19 pandemic caused CLABSI rates to rise 28–91%)
  4. Hospital building infrastructure — HVAC systems (Legionella, Aspergillus), water distribution, construction dust
  5. Prolonged antibiotic use — selection pressure for resistant organisms and C. difficile
  6. Parenteral nutrition (PN) — a major risk factor for invasive Candida infection
  7. Acid suppression therapy — allows gastric bacterial overgrowth, increasing aspiration/VAP risk

E. Iatrogenic Factors

  • Emergency/unsterile device placement (field lines)
  • Unnecessary invasive procedures
  • Prolonged duration of indwelling devices without daily review
  • Inappropriate antibiotic prescribing promoting resistance

PART II: PREVENTION OF HAI IN ICU

Prevention is organised around evidence-based care bundles — structured sets of practices that, when applied consistently, produce better outcomes than any single measure alone.

1. PREVENTION OF VENTILATOR-ASSOCIATED PNEUMONIA (VAP)

VAP Bundle — "ABCDE" + additional measures:

Non-pharmacological Measures:

  • Semirecumbent positioning: Head-of-bed elevation ≥30° — reduces microaspiration of gastric contents (simple, no cost, strong evidence)
  • Strict hand hygiene between all patient contacts
  • Oral decontamination with chlorhexidine gluconate — reduces oropharyngeal bacterial burden; likely reduces VAP incidence
  • Subglottic suctioning endotracheal tubes — meta-analysis supports reduction in VAP incidence and shorter ICU/hospital length of stay
  • Ventilator circuit management — change only when visibly soiled; avoid unnecessary circuit breaks
  • Early weaning/extubation — minimise duration of mechanical ventilation; daily spontaneous breathing trials
  • Non-invasive ventilation (NIV) preference where clinically appropriate — avoids intubation altogether

Pharmacological Controversies:

  • GI acid suppression — acid-suppressive agents increase gastric bacterial overgrowth and VAP risk; use only in high-risk patients (coagulopathy, mechanical ventilation). Sucralfate is an alternative with less acid suppression
  • Selective Digestive Decontamination (SDD) — nonabsorbable enteral antibiotics; growing evidence supports use but remains controversial due to antibiotic resistance concerns

Diagnostic Stewardship:

  • Invasive quantitative cultures (tracheal aspirate preferred per IDSA; BAL/protected brush as alternative): diagnose VAP only when ≥10⁴ CFU/mL (BAL) or ≥10³ CFU/mL (protected brush)
  • De-escalation therapy: Start broad spectrum empirically after cultures taken; narrow or stop based on 48–72 h culture results — reduces resistance emergence
  • Duration: 8-day course is effective; consider longer for non-lactose-fermenting GNRs (Pseudomonas)

2. PREVENTION OF CATHETER-RELATED BLOODSTREAM INFECTION (CRBSI/CLABSI)

CLABSI declined ~46% in the US (2008–2013) following bundle implementation. CLABSI rates increased 28–91% during COVID-19 pandemic.

Insertion Bundle:

  1. Hand hygiene — wash hands before insertion
  2. Maximal sterile barrier precautions: sterile gown, gloves, mask, cap + large full-body drape for the patient
  3. Chlorhexidine-alcohol skin antisepsis — superior to povidone-iodine or alcohol alone
  4. Optimal site selection:
    • Subclavian vein → lowest infection and DVT risk (but highest mechanical complication risk)
    • Internal jugular → intermediate
    • Femoral vein → highest infection risk; reserve for emergency/coagulopathy
  5. Ultrasound guidance — reduces attempts and trauma
  6. Replace any catheter placed under emergency/unsterile conditions as soon as patient allows

Maintenance Bundle:

ElementRecommendation
Daily necessity reviewRemove CVC as soon as no longer needed
Dressing changesGauze every 2 days; transparent film every 7 days (sooner if soiled/loose)
Hub/port access"Scrub the hub" before each access; sterile end-caps on all lumens
Chlorhexidine at dressing changesApply to catheter site at each dressing change
Avoid routine guidewire exchangeDoes NOT reduce infection; increases mechanical complications
IV set maintenancePer institutional guidelines
Antimicrobial-impregnated cathetersUse when expected duration > 5 days or local CRBSI rate > 3.3/1000 catheter-days (chlorhexidine/silver sulfadiazine OR minocycline/rifampin)
Staff educationStandardised competency-based training for all CVC-manipulating staff
Pathogen note: Coagulase-negative staphylococci are commonly isolated but rarely cause true CRBSI. When CRBSI is confirmed: remove catheter + minimum 7 days antibiotics (longer for S. aureus — endocarditis risk). Do not exchange over guidewire once CRBSI confirmed.

3. PREVENTION OF CATHETER-ASSOCIATED URINARY TRACT INFECTION (CAUTI)

The urinary tract is the second most common source of infection in the ICU (up to one-third of ICU patients).
Key Prevention Measures:
  • Strict aseptic technique during catheter insertion
  • Rigorous hand hygiene
  • Minimise duration of catheterisation — review necessity daily
  • Use bladder catheters only when strictly indicated (not for convenience)
  • Maintain closed drainage system; keep bag below bladder level
  • Antimicrobial/antiseptic catheter coatings — insufficient evidence to recommend routinely
  • Consider intermittent catheterisation as alternative to indwelling catheter where feasible

4. PREVENTION OF INVASIVE FUNGAL INFECTION (IFI)

Risk factors for Candida infection:
  • CVCs, PN, broad-spectrum antibiotics, recent abdominal surgery (anastomotic leak, GI perforation), dialysis-dependent renal failure, steroids
Prevention:
  • Limit risk factors: shorten CVC duration, minimise PN, restrict antibiotics
  • Prophylactic fluconazole — may be considered in high-risk surgical ICU patients
  • Prompt diagnosis: β-D-glucan assay (80% sensitive/specific for Candida/Aspergillus); whole-blood PCR (sensitivity >90%) for early detection
  • Candida in urine/sputum alone does not mandate treatment; often resolves with catheter removal
  • Treat promptly when invasive infection confirmed — delayed treatment increases dissemination and mortality

5. PREVENTION OF ICU-ACQUIRED SINUSITIS

  • Prefer orotracheal over nasotracheal intubation — reduces sinusitis from 95% to ~25% at one week
  • Remove nasal tubes (NG tube, nasotracheal tube) as early as possible
  • Suspect sinusitis as cause of fever of unknown origin in surgical ICU

6. PREVENTION OF C. DIFFICILE INFECTION (CDI)

  • Antibiotic stewardship — restrict broad-spectrum antibiotics; de-escalate rapidly
  • Contact precautions — gown and gloves; isolate affected patients
  • Hand hygiene with soap and water (alcohol gel is INEFFECTIVE against C. difficile spores — handwashing physically removes spores)
  • Environmental cleaning with sporicidal agents (e.g., bleach-based solutions)
  • Avoid proton pump inhibitors unless clearly indicated

7. GENERAL ICU INFECTION PREVENTION STRATEGIES

Care Bundles and Protocols:

  • Implementing a simple ventilator care bundle reduces VAP and antibiotic utilisation
  • Central line bundle (insertion + maintenance) → ~46% reduction in CLABSI nationally

Antimicrobial Stewardship:

  • Local antibiogram-guided empiric therapy
  • Routine de-escalation after 48–72 h culture results
  • Avoid unnecessary prophylactic antibiotics

Environmental and Structural Measures (Table 83.1 — Tietz):

DomainMeasures
Hospital buildingHVAC systems, water distribution monitoring, construction barriers
Environmental cleaningRegular disinfection; sporicidal agents for CDI
SterilisationProper reprocessing of all reusable medical equipment
Food/laundry servicesSafe food handling; proper laundry handling
SurveillanceActive HAI surveillance (SSI, CAUTI, CLABSI, VAP, CDI) with public reporting

Infection Prevention and Control (IPC) Programme:

  • Led by physician hospital epidemiologist or trained IC nurse
  • Surveillance, outbreak investigation, isolation precautions
  • Staff education and competency-based training
  • Emergency preparedness for novel pathogens/bioterrorism

EMPIRIC ANTIBIOTIC REGIMENS FOR COMMON ICU INFECTIONS

(Barash, Cullen & Stoelting's Clinical Anesthesia, 9e)
InfectionRegimen
VAP — Early (<72h)Ceftriaxone + azithromycin; add vancomycin/linezolid if MRSA history
VAP — Late (>72h)Vancomycin OR linezolid + cefepime; consider ciprofloxacin if MDR GNRs
CRBSI/BSIVancomycin OR linezolid + cefepime ± ciprofloxacin
CAUTI — non-catheterCeftriaxone
CAUTI — catheter-associatedCeftazidime; add vancomycin if GPCs on Gram stain; meropenem if MDR/ESBL
CDIOral vancomycin; add IV metronidazole if shock/megacolon/ileus
Sepsis, unknown sourceVancomycin + meropenem ± ciprofloxacin
Antibiotic selection must account for local antibiograms. All regimens should be narrowed once culture results are available.

SUMMARY TABLE: HAI PREVENTION BUNDLES IN ICU

HAICore Bundle Elements
VAPHOB ≥30°, hand hygiene, oral CHX, subglottic suction ETT, early weaning, avoid unnecessary acid suppression
CLABSIHand hygiene, full sterile barrier, CHX-alcohol skin prep, optimal site, daily necessity review, "scrub the hub"
CAUTIAseptic insertion, closed system, daily necessity review, early removal
CDIAntibiotic stewardship, soap-and-water handwashing, contact precautions, sporicidal disinfection
IFILimit CVC/PN/antibiotics, fluconazole prophylaxis in high-risk, early diagnosis with β-D-glucan
SinusitisOral > nasal intubation, early tube removal

CONCLUSION

HAIs in the ICU are driven by the convergence of host vulnerability, invasive devices, and healthcare system factors. While some degree of nosocomial infection is inherent to intensive care, the majority are preventable through rigorous evidence-based bundles, antimicrobial stewardship, surveillance, and a culture of infection control. For the anaesthetist/intensivist, the key roles are: aseptic technique during device insertion, daily device necessity review, early de-escalation of antibiotics, and consistent bundle adherence.

Sources:
  • Barash, Cullen, and Stoelting's Clinical Anesthesia, 9e — Chapter 57 (Critical Care Medicine)
  • Miller's Anesthesia, 2-Volume Set, 10e — Infectious Complications of CVC
  • Current Surgical Therapy, 14e — CLABSI Chapter
  • Tietz Textbook of Laboratory Medicine, 7e — Infection Prevention and Control
  • Goldman-Cecil Medicine, International Edition — HAP/VAP Epidemiology

Create a summary PDF with HAI bundles and antibiotic regimens

Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"

Running Command

mkdir -p /home/daytona/workspace/hai-summary && python3 -c "from reportlab.lib i…

Writing File

~/hai-summary/build_pdf.py

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

OUTPUT = "/home/daytona/workspace/hai-summary/HAI_Bundles_Antibiotic_Regimens.pdf"

# ── Colour palette ────────────────────────────────────────────────────────────
DARK_BLUE  = HexColor("#1A3A5C")
MED_BLUE   = HexColor("#2563A8")
LIGHT_BLUE = HexColor("#D6E8FA")
TEAL       = HexColor("#0E7490")
TEAL_LT    = HexColor("#CCEFF5")
RED        = HexColor("#B91C1C")
RED_LT     = HexColor("#FEE2E2")
GREEN      = HexColor("#166534")
GREEN_LT   = HexColor("#DCFCE7")
ORANGE     = HexColor("#92400E")
ORANGE_LT  = HexColor("#FEF3C7")
PURPLE     = HexColor("#5B21B6")
PURPLE_LT  = HexColor("#EDE9FE")
GREY_DARK  = HexColor("#374151")
GREY_MID   = HexColor("#6B7280")
GREY_LT    = HexColor("#F3F4F6")
WHITE      = colors.white

doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    rightMargin=1.8*cm, leftMargin=1.8*cm,
    topMargin=2*cm, bottomMargin=2*cm,
    title="HAI Prevention Bundles & Antibiotic Regimens",
    author="Orris Clinical Summary"
)

W = A4[0] - 3.6*cm   # usable width

styles = getSampleStyleSheet()

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

# Custom styles
Title      = S("Title",      fontSize=22, leading=28, textColor=WHITE,
               alignment=TA_CENTER, fontName="Helvetica-Bold")
Subtitle   = S("Subtitle",   fontSize=11, leading=16, textColor=LIGHT_BLUE,
               alignment=TA_CENTER, fontName="Helvetica")
SecHead    = S("SecHead",    fontSize=13, leading=18, textColor=WHITE,
               fontName="Helvetica-Bold", spaceAfter=2)
SubHead    = S("SubHead",    fontSize=10, leading=14, textColor=DARK_BLUE,
               fontName="Helvetica-Bold", spaceBefore=6, spaceAfter=4)
Body       = S("Body",       fontSize=8.5, leading=13, textColor=GREY_DARK,
               fontName="Helvetica", spaceAfter=3)
BulletItem = S("BulletItem", fontSize=8.5, leading=13, textColor=GREY_DARK,
               fontName="Helvetica", leftIndent=12, bulletIndent=0, spaceAfter=2)
FootNote   = S("FootNote",   fontSize=7,  leading=10, textColor=GREY_MID,
               fontName="Helvetica-Oblique", alignment=TA_CENTER)
CellBold   = S("CellBold",   fontSize=8,  leading=11, textColor=WHITE,
               fontName="Helvetica-Bold")
CellBody   = S("CellBody",   fontSize=7.8, leading=11, textColor=GREY_DARK,
               fontName="Helvetica")
CellBodySm = S("CellBodySm", fontSize=7.2, leading=10.5, textColor=GREY_DARK,
               fontName="Helvetica")
TblHdr     = S("TblHdr",     fontSize=8,  leading=11, textColor=WHITE,
               fontName="Helvetica-Bold", alignment=TA_CENTER)

def section_banner(text, bg=DARK_BLUE):
    """Full-width coloured banner for section headings."""
    tbl = Table([[Paragraph(text, SecHead)]], colWidths=[W])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("ROUNDEDCORNERS", [4]),
    ]))
    return tbl

def bullet(text, indent=12):
    return Paragraph(f"• &nbsp;{text}", BulletItem)

def sub_bullet(text):
    s = S("sub_b", fontSize=8, leading=12, textColor=GREY_DARK,
          fontName="Helvetica", leftIndent=24, bulletIndent=12, spaceAfter=1)
    return Paragraph(f"– {text}", s)

def hr(color=LIGHT_BLUE, thickness=0.8):
    return HRFlowable(width="100%", thickness=thickness, color=color, spaceAfter=4, spaceBefore=4)

def sp(h=0.3):
    return Spacer(1, h*cm)


# ═══════════════════════════════════════════════════════════════════════════════
# STORY
# ═══════════════════════════════════════════════════════════════════════════════
story = []

# ── COVER BANNER ─────────────────────────────────────────────────────────────
cover_data = [[
    Paragraph("Hospital-Acquired Infections", Title),
    Paragraph("Prevention Bundles &amp; Antibiotic Regimens", Subtitle),
    Paragraph("Quick-Reference Summary · ICU / MD Anaesthesia", FootNote),
]]
cover = Table(cover_data, colWidths=[W])
cover.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), DARK_BLUE),
    ("TOPPADDING",    (0,0), (-1,-1), 18),
    ("BOTTOMPADDING", (0,0), (-1,-1), 18),
    ("LEFTPADDING",   (0,0), (-1,-1), 16),
    ("RIGHTPADDING",  (0,0), (-1,-1), 16),
    ("ROUNDEDCORNERS", [6]),
]))
story.append(cover)
story.append(sp(0.5))

# ── DEFINITION BOX ───────────────────────────────────────────────────────────
def_box = Table([[
    Paragraph(
        "<b>Hospital-Acquired Infection (HAI)</b> — Also called <i>nosocomial infection</i>. "
        "An infection occurring ≥48 h after hospital admission, not present or incubating at admission. "
        "HAIs affect ~3% of hospitalised patients (CDC) and cost <b>$7.2–14.9 billion/year</b> (US). "
        "Many are <b>preventable</b> with evidence-based bundles.",
        S("defbox", fontSize=8.5, leading=13, textColor=DARK_BLUE,
          fontName="Helvetica", alignment=TA_JUSTIFY)
    )
]], colWidths=[W])
def_box.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), LIGHT_BLUE),
    ("BOX", (0,0), (-1,-1), 1, MED_BLUE),
    ("TOPPADDING",    (0,0), (-1,-1), 8),
    ("BOTTOMPADDING", (0,0), (-1,-1), 8),
    ("LEFTPADDING",   (0,0), (-1,-1), 10),
    ("RIGHTPADDING",  (0,0), (-1,-1), 10),
]))
story.append(def_box)
story.append(sp(0.5))

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 1: HAI OVERVIEW TABLE
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_banner("1. HAI Types in ICU — Overview", DARK_BLUE))
story.append(sp(0.3))

hai_hdr = [
    Paragraph("HAI Type", TblHdr),
    Paragraph("Acronym", TblHdr),
    Paragraph("Definition", TblHdr),
    Paragraph("Common Organisms", TblHdr),
]
hai_rows = [
    ["Ventilator-Associated Pneumonia",   "VAP",   "Pneumonia ≥48 h after intubation",
     "Early: H. influenzae, S. pneumoniae, MSSA\nLate: MRSA, Pseudomonas, Acinetobacter"],
    ["Catheter-Related Bloodstream Infx", "CRBSI/CLABSI", "BSI attributed to intravascular catheter (CVC ≥48 h in situ)",
     "S. epidermidis, S. aureus, Enterococcus, Enteric GNRs, Candida"],
    ["Catheter-Associated UTI",           "CAUTI", "UTI in catheterised patient",
     "Staphylococci, Enterococcus, Enteric GNRs, Pseudomonas"],
    ["C. difficile Infection",            "CDI",   "AAC; toxin-mediated colitis after antibiotics",
     "Clostridioides difficile (spore-forming)"],
    ["Surgical Site Infection",           "SSI",   "Infection at operative wound within 30 days",
     "S. aureus, MRSA, Enteric GNRs, Streptococci"],
    ["ICU-Acquired Sinusitis",            "—",     "Nasal/oral tubes block sinus ostia",
     "Same as VAP pathogens"],
    ["Invasive Fungal Infection",         "IFI",   "Candida/Aspergillus in susceptible host",
     "Candida albicans (~50%), C. tropicalis, C. glabrata, Aspergillus"],
]

hai_data = [hai_hdr]
for r in hai_rows:
    hai_data.append([Paragraph(x, CellBodySm) for x in r])

col_w = [W*0.22, W*0.11, W*0.32, W*0.35]
hai_tbl = Table(hai_data, colWidths=col_w, repeatRows=1)
hai_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), DARK_BLUE),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE, GREY_LT]),
    ("BOX",           (0,0), (-1,-1), 0.5, GREY_MID),
    ("INNERGRID",     (0,0), (-1,-1), 0.3, HexColor("#D1D5DB")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("RIGHTPADDING",  (0,0), (-1,-1), 5),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
]))
story.append(hai_tbl)
story.append(sp(0.6))

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 2: CAUSES
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_banner("2. Causes / Risk Factors for HAI", MED_BLUE))
story.append(sp(0.3))

causes_cols = [
    ("Host Factors", RED_LT, RED, [
        "Critical illness — altered immunity, malnutrition",
        "Extremes of age (neonates, elderly)",
        "Immunosuppression: steroids, chemo",
        "Disrupted skin/mucosal barriers",
        "Altered microbiome (broad antibiotics)",
    ]),
    ("Device / Procedure Factors", ORANGE_LT, ORANGE, [
        "Endotracheal tube — bypasses mucociliary clearance",
        "Nasotracheal intubation — blocks sinus ostia",
        "Central venous catheter — skin/hub colonisation, biofilm",
        "Urinary catheter — bacteriuria → bacteraemia 5%",
        "NG tube — aspiration risk",
    ]),
    ("Environmental / Systemic", GREEN_LT, GREEN, [
        "Poor hand hygiene (single most preventable cause)",
        "Contaminated equipment/surfaces",
        "Crowding, understaffing (COVID ↑CLABSI 28–91%)",
        "HVAC/water (Legionella, Aspergillus)",
        "Prolonged antibiotics → C. difficile, resistance",
        "Parenteral nutrition → Candida risk",
    ]),
]

cause_cells = []
for (title, bg, fg, items) in causes_cols:
    cell_content = [Paragraph(title, S("ch", fontSize=8.5, leading=12,
                                        fontName="Helvetica-Bold", textColor=fg,
                                        spaceAfter=4))]
    for it in items:
        cell_content.append(Paragraph(f"• {it}", CellBodySm))
    t = Table([[cell_content]], colWidths=[(W-0.6)/3])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX",        (0,0), (-1,-1), 0.5, fg),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    cause_cells.append(t)

cause_row = Table([cause_cells], colWidths=[(W-0.6)/3]*3,
                   hAlign="LEFT")
cause_row.setStyle(TableStyle([
    ("LEFTPADDING",  (0,0), (-1,-1), 3),
    ("RIGHTPADDING", (0,0), (-1,-1), 3),
    ("VALIGN",       (0,0), (-1,-1), "TOP"),
]))
story.append(cause_row)
story.append(sp(0.6))

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 3: PREVENTION BUNDLES
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_banner("3. ICU Prevention Bundles", TEAL))
story.append(sp(0.3))

# ── 3A: VAP Bundle ────────────────────────────────────────────────────────────
story.append(KeepTogether([
    Paragraph("3A. VAP Prevention Bundle", S("sh", fontSize=10, leading=14,
              fontName="Helvetica-Bold", textColor=TEAL, spaceBefore=4, spaceAfter=4)),
]))

vap_hdr = [Paragraph(x, TblHdr) for x in ["Measure", "Detail / Evidence"]]
vap_rows = [
    ("✔ Head-of-bed elevation ≥30°",
     "Reduces microaspiration of gastric contents. Simple, low-cost, strong evidence. Apply in ALL ventilated patients."),
    ("✔ Strict hand hygiene",
     "Between all patient contacts. Single most important cross-transmission prevention measure."),
    ("✔ Oral decontamination with chlorhexidine",
     "Reduces oropharyngeal bacterial burden; likely reduces VAP incidence. Use 0.12–0.2% CHX oral rinse."),
    ("✔ Subglottic suctioning ETT",
     "Meta-analysis supports reduction in VAP incidence + shorter ICU/hospital LOS. Use suction port ETTs in patients expected to be ventilated >72 h."),
    ("✔ Early weaning / extubation",
     "Daily spontaneous breathing trials (SBT). Minimise duration of mechanical ventilation. Prefer NIV where appropriate."),
    ("✔ Ventilator circuit management",
     "Change only when visibly soiled. Avoid unnecessary circuit breaks that increase contamination risk."),
    ("✔ Selective Digestive Decontamination (SDD)",
     "Non-absorbable enteral antibiotics; growing evidence but controversial (antibiotic resistance concerns)."),
    ("⚠ GI acid suppression",
     "Use only in HIGH-RISK patients (coagulopathy, MV). Acid suppression allows gastric bacterial overgrowth → ↑VAP risk. Consider sucralfate as alternative."),
    ("✔ Avoid routine ETT suctioning",
     "Only when clinically indicated; use closed suction systems."),
]
vap_data = [vap_hdr] + [[Paragraph(a, CellBodySm), Paragraph(b, CellBodySm)] for a,b in vap_rows]
vap_tbl = Table(vap_data, colWidths=[W*0.32, W*0.68], repeatRows=1)
vap_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), TEAL),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE, TEAL_LT]),
    ("BOX",           (0,0), (-1,-1), 0.5, TEAL),
    ("INNERGRID",     (0,0), (-1,-1), 0.3, HexColor("#A7D8E0")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
]))
story.append(vap_tbl)
story.append(sp(0.5))

# ── 3B: CLABSI Bundle ─────────────────────────────────────────────────────────
story.append(KeepTogether([
    Paragraph("3B. CLABSI Prevention Bundle  (↓46% in US after implementation)",
              S("sh2", fontSize=10, leading=14, fontName="Helvetica-Bold",
                textColor=MED_BLUE, spaceBefore=4, spaceAfter=4)),
]))

clabsi_hdr = [Paragraph(x, TblHdr) for x in ["Phase", "Bundle Element", "Recommendation"]]
clabsi_rows = [
    # INSERTION
    ("INSERTION", "Hand hygiene",
     "Wash hands before insertion. Don gloves and mask."),
    ("INSERTION", "Maximal sterile barrier (MSB)",
     "Sterile gown + gloves + cap + mask + FULL BODY drape for patient."),
    ("INSERTION", "Skin antisepsis",
     "Chlorhexidine-alcohol solution — superior to povidone-iodine or alcohol alone."),
    ("INSERTION", "Optimal site selection",
     "Subclavian → lowest infection/DVT risk (highest mechanical risk).\nInternal jugular → intermediate.\nFemoral → highest infection risk; reserve for emergency/coagulopathy."),
    ("INSERTION", "Ultrasound guidance",
     "Reduces insertion attempts and trauma; strongly recommended."),
    ("INSERTION", "Replace emergency lines",
     "Catheters placed without aseptic technique must be replaced as soon as patient condition allows."),
    # MAINTENANCE
    ("MAINTENANCE", "Daily necessity review",
     "Remove CVC as soon as it is no longer required. Document date of insertion and removal."),
    ("MAINTENANCE", "Dressing changes",
     "Gauze dressing: every 2 days.\nTransparent film: every 7 days (sooner if soiled/damp/loose)."),
    ("MAINTENANCE", "'Scrub the hub'",
     "Disinfect all ports/hubs before and after each access. Cover open lumens with sterile end-caps."),
    ("MAINTENANCE", "Chlorhexidine at dressing change",
     "Apply CHX solution to catheter exit site at every dressing change."),
    ("MAINTENANCE", "Antimicrobial-impregnated catheter",
     "Use when expected duration >5 days OR local CRBSI rate >3.3/1000 catheter-days.\nOptions: CHX/silver sulfadiazine OR minocycline/rifampin."),
    ("MAINTENANCE", "Avoid routine guidewire exchange",
     "Does NOT reduce infection. Increases mechanical complications. Replace catheter if CRBSI confirmed — do NOT exchange over guidewire."),
    ("MAINTENANCE", "Staff education",
     "Standardised competency-based training for all staff manipulating CVCs."),
]

clabsi_data = [clabsi_hdr]
prev_phase = None
for phase, elem, rec in clabsi_rows:
    display_phase = phase if phase != prev_phase else ""
    prev_phase = phase
    clabsi_data.append([
        Paragraph(display_phase, S("ph", fontSize=8, fontName="Helvetica-Bold",
                                    textColor=MED_BLUE if phase=="INSERTION" else TEAL,
                                    leading=11)),
        Paragraph(elem, CellBodySm),
        Paragraph(rec, CellBodySm),
    ])

ins_rows = [i+1 for i,(ph,_,_) in enumerate(clabsi_rows) if ph=="INSERTION"]
maint_rows = [i+1 for i,(ph,_,_) in enumerate(clabsi_rows) if ph=="MAINTENANCE"]

clabsi_tbl = Table(clabsi_data, colWidths=[W*0.13, W*0.27, W*0.60], repeatRows=1)
ts = TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), MED_BLUE),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE, GREY_LT]),
    ("BOX",           (0,0), (-1,-1), 0.5, MED_BLUE),
    ("INNERGRID",     (0,0), (-1,-1), 0.3, HexColor("#BFDBFE")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
])
# Background for insertion rows
for r in ins_rows:
    ts.add("BACKGROUND", (0,r), (0,r), HexColor("#DBEAFE"))
for r in maint_rows:
    ts.add("BACKGROUND", (0,r), (0,r), HexColor("#D1FAE5"))

clabsi_tbl.setStyle(ts)
story.append(clabsi_tbl)
story.append(sp(0.5))

# ── 3C: CAUTI + CDI side by side ──────────────────────────────────────────────
cauti_items = [
    ("✔", "Aseptic technique during insertion"),
    ("✔", "Closed drainage system; bag below bladder level"),
    ("✔", "Daily necessity review — remove ASAP"),
    ("✔", "Use only when strictly indicated (not for convenience)"),
    ("✔", "Consider intermittent catheterisation as alternative"),
    ("✔", "Hand hygiene before any catheter manipulation"),
    ("⚠", "Antimicrobial coatings — insufficient evidence for routine use"),
]
cdi_items = [
    ("✔", "Antibiotic stewardship — restrict broad-spectrum, de-escalate"),
    ("✔", "Soap-and-water handwashing (alcohol gel INEFFECTIVE vs spores)"),
    ("✔", "Contact precautions — gown + gloves; isolate patients"),
    ("✔", "Sporicidal environmental cleaning (bleach-based)"),
    ("✔", "Avoid PPIs unless clearly indicated"),
    ("✔", "Treat: oral vancomycin; add IV metronidazole if shock/megacolon"),
]

def mini_bundle_cell(title, bg, fg, items, width):
    content = [Paragraph(title, S("mbt", fontSize=9, fontName="Helvetica-Bold",
                                   textColor=fg, leading=13, spaceAfter=5))]
    for icon, text in items:
        content.append(Paragraph(
            f'<font color="{"#166534" if icon=="✔" else "#B91C1C"}">{icon}</font>  {text}',
            CellBodySm
        ))
    t = Table([[content]], colWidths=[width])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX",        (0,0), (-1,-1), 0.8, fg),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    return t

half = (W - 0.4) / 2
cauti_cell = mini_bundle_cell("3C. CAUTI Prevention", TEAL_LT, TEAL, cauti_items, half)
cdi_cell   = mini_bundle_cell("3D. C. difficile (CDI) Prevention", ORANGE_LT, ORANGE, cdi_items, half)

pair_row = Table([[cauti_cell, cdi_cell]], colWidths=[half, half])
pair_row.setStyle(TableStyle([
    ("LEFTPADDING",  (0,0), (-1,-1), 2),
    ("RIGHTPADDING", (0,0), (-1,-1), 2),
    ("VALIGN",       (0,0), (-1,-1), "TOP"),
]))
story.append(pair_row)
story.append(sp(0.5))

# ── 3E: Fungal + Sinusitis ────────────────────────────────────────────────────
fungal_items = [
    ("✔", "Limit CVC duration, PN use, broad-spectrum antibiotics"),
    ("✔", "Prophylactic fluconazole in high-risk surgical ICU patients"),
    ("✔", "β-D-glucan assay: ~80% sensitive/specific (Candida, Aspergillus)"),
    ("✔", "Whole-blood PCR: >90% sensitivity; result within hours"),
    ("✔", "Candiduria alone: usually resolves with catheter removal"),
    ("⚠", "Candida peritonitis: treat if clinical signs of infection (mortality ~50%)"),
]
sinus_items = [
    ("✔", "Prefer OROTRACHEAL over nasotracheal intubation"),
    ("✔", "Sinusitis rate: nasal ~95% vs oral ~25% at 1 week"),
    ("✔", "Remove nasal tubes (ETT, NG) as early as clinically possible"),
    ("✔", "Suspect sinusitis in ICU fever of unknown origin (~16% of FUO in surgical ICU)"),
    ("✔", "Quantitative cultures needed to confirm bacterial vs radiographic sinusitis"),
]

fungal_cell = mini_bundle_cell("3E. Invasive Fungal Infection Prevention", PURPLE_LT, PURPLE, fungal_items, half)
sinus_cell  = mini_bundle_cell("3F. ICU-Acquired Sinusitis Prevention", RED_LT, RED, sinus_items, half)

pair_row2 = Table([[fungal_cell, sinus_cell]], colWidths=[half, half])
pair_row2.setStyle(TableStyle([
    ("LEFTPADDING",  (0,0), (-1,-1), 2),
    ("RIGHTPADDING", (0,0), (-1,-1), 2),
    ("VALIGN",       (0,0), (-1,-1), "TOP"),
]))
story.append(pair_row2)
story.append(sp(0.6))

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 4: ANTIBIOTIC REGIMENS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(section_banner("4. Empiric Antibiotic Regimens for Common ICU Infections", RED))
story.append(sp(0.3))
story.append(Paragraph(
    "<i>Based on Barash, Cullen &amp; Stoelting's Clinical Anesthesia, 9e. "
    "Always tailor to LOCAL ANTIBIOGRAM. De-escalate after 48–72 h culture results.</i>",
    S("note", fontSize=8, fontName="Helvetica-Oblique", textColor=RED,
      leading=12, spaceAfter=6)
))

abx_hdr = [Paragraph(x, TblHdr) for x in
           ["Infection", "Sub-type / Notes", "Empiric Regimen", "Duration"]]
abx_rows = [
    # VAP
    ("VAP\n(Ventilator-Associated\nPneumonia)",
     "Early (<72 h of intubation)\nCommunity/sensitive flora",
     "Ceftriaxone + Azithromycin\n\n+ Vancomycin or Linezolid\nif MRSA history/risk",
     "5–8 days\n(narrow on\ncultures)"),
    ("VAP",
     "Late (>72 h)\nMDR organisms likely\n(MRSA, Pseudomonas,\nAcinetobacter)",
     "Vancomycin OR Linezolid\n+ Cefepime\n± Ciprofloxacin\n  (if MDR GNRs likely)",
     "8 days\n(14 days for\nPseudomonas)"),
    # BSI
    ("Bloodstream Infection\n(CRBSI/CLABSI/BSI)",
     "Cover MRSA + MDR GNRs;\nadd anti-Pseudomonal if high\nlocal incidence",
     "Vancomycin OR Linezolid\n+ Cefepime\n± Ciprofloxacin\n  (MDR GNRs / ESBLs)",
     "≥7 days\n(≥14 days for\nS. aureus)"),
    # CAUTI
    ("CAUTI\n(Urinary Tract Infection)",
     "Non-catheter-associated",
     "Ceftriaxone",
     "5–7 days"),
    ("CAUTI",
     "Catheter-associated;\nGPCs on Gram stain\nor MDR GNRs/ESBL risk",
     "Ceftazidime\n+ Vancomycin (if GPCs on stain)\nor Meropenem\n  (MDR/ESBL concern)",
     "7–14 days"),
    # CDI
    ("C. difficile Infection\n(CDI)",
     "Non-severe; first episode",
     "Oral Vancomycin 125 mg QDS × 10 days\n(alternative: oral Fidaxomicin)",
     "10 days"),
    ("CDI",
     "Severe (shock, megacolon,\nileus, peritonitis)",
     "Oral Vancomycin 500 mg QDS\n+ IV Metronidazole 500 mg TDS\n± surgical consult",
     "10–14 days"),
    # Meningitis
    ("Meningitis",
     "Non-surgical / community",
     "Dexamethasone + Ceftriaxone\n+ Vancomycin + Ampicillin\n+ Acyclovir",
     "10–21 days\n(per organism)"),
    ("Meningitis",
     "Post-surgical / post-trauma\n(GNRs + S. aureus likely)",
     "Cefepime + Metronidazole\n+ Vancomycin",
     "10–21 days"),
    # IAI
    ("Intra-Abdominal Infection\n(IAI)",
     "Community-acquired",
     "Ceftriaxone + Metronidazole",
     "4–7 days\nafter source\ncontrol"),
    ("IAI",
     "Hospital-acquired / post-op\nMDR risk",
     "Vancomycin\n+ Piperacillin-Tazobactam\nOR Meropenem",
     "5–7 days\nafter source\ncontrol"),
    # Sepsis
    ("Sepsis / Septic Shock\n(Unknown Source)",
     "Broad empiric cover;\nnarrow urgently on cultures",
     "Vancomycin + Meropenem\n± Ciprofloxacin\n  (MDR GNRs / ESBLs)",
     "Reassess at\n48–72 h;\nde-escalate"),
    # Fungal
    ("Invasive Candidiasis\n(Candidaemia)",
     "Non-neutropenic ICU patient;\nremove CVCs if feasible",
     "Echinocandin (Caspofungin,\nMicafungin, Anidulafungin)\nOR Fluconazole if sensitive,\nnon-critically ill",
     "14 days after\nlast positive\nculture"),
]

abx_data = [abx_hdr]
prev_infx = ""
for infx, sub, reg, dur in abx_rows:
    display_infx = infx if infx != prev_infx else ""
    prev_infx = infx
    abx_data.append([
        Paragraph(display_infx, S("ai", fontSize=8, fontName="Helvetica-Bold",
                                   textColor=DARK_BLUE, leading=11)),
        Paragraph(sub, CellBodySm),
        Paragraph(reg, S("reg", fontSize=8, fontName="Helvetica", leading=11.5,
                          textColor=GREY_DARK)),
        Paragraph(dur, CellBodySm),
    ])

abx_tbl = Table(abx_data, colWidths=[W*0.20, W*0.22, W*0.38, W*0.20], repeatRows=1)
abx_ts = TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), RED),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE, RED_LT]),
    ("BOX",           (0,0), (-1,-1), 0.5, RED),
    ("INNERGRID",     (0,0), (-1,-1), 0.3, HexColor("#FECACA")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("RIGHTPADDING",  (0,0), (-1,-1), 5),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
])
abx_tbl.setStyle(abx_ts)
story.append(abx_tbl)
story.append(sp(0.5))

# ── De-escalation box ─────────────────────────────────────────────────────────
deesc = Table([[
    Paragraph(
        "<b>De-Escalation Principle:</b> "
        "Start empiric broad-spectrum antibiotics AFTER cultures are sent. "
        "Narrow or discontinue based on 48–72 h culture + sensitivity results. "
        "This approach ensures adequate initial treatment while minimising "
        "antibiotic resistance and Clostridioides difficile risk.",
        S("deesc", fontSize=8.5, leading=13, fontName="Helvetica",
          textColor=DARK_BLUE, alignment=TA_JUSTIFY)
    )
]], colWidths=[W])
deesc.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), LIGHT_BLUE),
    ("BOX",        (0,0), (-1,-1), 1.2, MED_BLUE),
    ("LEFTPADDING",  (0,0), (-1,-1), 10),
    ("RIGHTPADDING", (0,0), (-1,-1), 10),
    ("TOPPADDING",   (0,0), (-1,-1), 8),
    ("BOTTOMPADDING",(0,0), (-1,-1), 8),
]))
story.append(deesc)
story.append(sp(0.6))

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 5: MASTER SUMMARY TABLE
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_banner("5. Master Summary — HAI Bundles at a Glance", DARK_BLUE))
story.append(sp(0.3))

sum_hdr = [Paragraph(x, TblHdr) for x in ["HAI", "Core Bundle Elements"]]
sum_rows = [
    ("VAP",
     "HOB ≥30° | Hand hygiene | Oral CHX | Subglottic suctioning ETT | Early weaning/SBT | Minimise acid suppression | Closed suction"),
    ("CLABSI",
     "Hand hygiene | Full sterile barrier | CHX-alcohol skin prep | Optimal site (subclavian preferred) | Daily necessity review | 'Scrub the hub' | Antimicrobial catheter if >5 days"),
    ("CAUTI",
     "Aseptic insertion | Closed drainage | Bag below bladder | Daily review | Shortest duration possible | Prefer intermittent catheterisation"),
    ("CDI",
     "Antibiotic stewardship | Soap-and-water handwashing (not alcohol) | Contact precautions + isolation | Sporicidal cleaning | Avoid unnecessary PPIs"),
    ("Invasive Fungal",
     "Limit CVC / PN / antibiotics | Fluconazole prophylaxis (high-risk) | Early β-D-glucan / PCR diagnosis | Prompt antifungal treatment"),
    ("Sinusitis",
     "Oral > nasal intubation | Early removal of nasal tubes | Suspect in ICU FUO"),
    ("General",
     "Care bundles | Antimicrobial stewardship | Daily device review | Active IPC surveillance | Staff education | Environmental cleaning"),
]

sum_data = [sum_hdr] + [[Paragraph(a, S("sk", fontSize=8.5, fontName="Helvetica-Bold",
                                         textColor=DARK_BLUE, leading=12)),
                          Paragraph(b, CellBodySm)] for a,b in sum_rows]
sum_tbl = Table(sum_data, colWidths=[W*0.15, W*0.85], repeatRows=1)
sum_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), DARK_BLUE),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE, LIGHT_BLUE]),
    ("BOX",           (0,0), (-1,-1), 0.5, DARK_BLUE),
    ("INNERGRID",     (0,0), (-1,-1), 0.3, HexColor("#D1D5DB")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
]))
story.append(sum_tbl)
story.append(sp(0.6))

# ── Footer note ───────────────────────────────────────────────────────────────
footer = Table([[
    Paragraph(
        "Sources: Barash, Cullen &amp; Stoelting's Clinical Anesthesia 9e · Miller's Anesthesia 10e · "
        "Current Surgical Therapy 14e · Tietz Textbook of Laboratory Medicine 7e · Goldman-Cecil Medicine. "
        "Generated by Orris Clinical AI · May 2026",
        FootNote
    )
]], colWidths=[W])
footer.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), GREY_LT),
    ("BOX",        (0,0), (-1,-1), 0.5, HexColor("#D1D5DB")),
    ("TOPPADDING",   (0,0), (-1,-1), 6),
    ("BOTTOMPADDING",(0,0), (-1,-1), 6),
]))
story.append(footer)

# ── BUILD ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF created: {OUTPUT}")
Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.
This is a shared conversation. Sign in to Orris to start your own chat.