~/antibiotic-guide/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import ListFlowable, ListItem
OUTPUT = "/home/daytona/workspace/antibiotic-guide/Antibiotic_Clinical_Guide.pdf"
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
rightMargin=2*cm, leftMargin=2*cm,
topMargin=2.5*cm, bottomMargin=2.5*cm,
title="Antibiotic Clinical Reference Guide",
author="Orris Medical AI"
)
styles = getSampleStyleSheet()
# Custom styles
title_style = ParagraphStyle("TitleStyle", parent=styles["Title"],
fontSize=22, textColor=colors.HexColor("#1a237e"),
spaceAfter=6, alignment=TA_CENTER, fontName="Helvetica-Bold")
subtitle_style = ParagraphStyle("SubTitle", parent=styles["Normal"],
fontSize=11, textColor=colors.HexColor("#455a64"),
spaceAfter=20, alignment=TA_CENTER, fontName="Helvetica-Oblique")
h1_style = ParagraphStyle("H1", parent=styles["Heading1"],
fontSize=16, textColor=colors.white,
backColor=colors.HexColor("#1a237e"),
spaceAfter=8, spaceBefore=18,
leftIndent=-10, rightIndent=-10,
borderPad=6, fontName="Helvetica-Bold")
h2_style = ParagraphStyle("H2", parent=styles["Heading2"],
fontSize=13, textColor=colors.HexColor("#1a237e"),
spaceAfter=4, spaceBefore=12,
fontName="Helvetica-Bold",
borderPad=2)
h3_style = ParagraphStyle("H3", parent=styles["Heading3"],
fontSize=11, textColor=colors.HexColor("#0277bd"),
spaceAfter=3, spaceBefore=8,
fontName="Helvetica-Bold")
body_style = ParagraphStyle("Body", parent=styles["Normal"],
fontSize=9.5, textColor=colors.HexColor("#212121"),
spaceAfter=4, leading=14, alignment=TA_JUSTIFY,
fontName="Helvetica")
bullet_style = ParagraphStyle("Bullet", parent=styles["Normal"],
fontSize=9.5, textColor=colors.HexColor("#212121"),
spaceAfter=2, leading=13,
leftIndent=14, bulletIndent=4,
fontName="Helvetica")
rationale_style = ParagraphStyle("Rationale", parent=styles["Normal"],
fontSize=9.5, textColor=colors.HexColor("#1b5e20"),
backColor=colors.HexColor("#f1f8e9"),
spaceAfter=6, spaceBefore=4, leading=13,
leftIndent=8, rightIndent=8, borderPad=6,
fontName="Helvetica-Oblique")
warning_style = ParagraphStyle("Warning", parent=styles["Normal"],
fontSize=9.5, textColor=colors.HexColor("#b71c1c"),
backColor=colors.HexColor("#fff8f8"),
spaceAfter=6, spaceBefore=4, leading=13,
leftIndent=8, rightIndent=8, borderPad=6,
fontName="Helvetica-Oblique")
note_style = ParagraphStyle("Note", parent=styles["Normal"],
fontSize=9, textColor=colors.HexColor("#4a148c"),
backColor=colors.HexColor("#f3e5f5"),
spaceAfter=6, spaceBefore=4, leading=13,
leftIndent=8, rightIndent=8, borderPad=6,
fontName="Helvetica")
source_style = ParagraphStyle("Source", parent=styles["Normal"],
fontSize=8, textColor=colors.HexColor("#546e7a"),
spaceAfter=3, leading=11, fontName="Helvetica-Oblique")
def section_header(text, color="#1a237e"):
return Paragraph(
f'<font color="white"><b>{text}</b></font>',
ParagraphStyle("SH", parent=styles["Normal"],
fontSize=14, backColor=colors.HexColor(color),
spaceAfter=10, spaceBefore=16,
leftIndent=-15, rightIndent=-15,
borderPad=8, fontName="Helvetica-Bold",
textColor=colors.white)
)
def scenario_header(text):
return Paragraph(
f'<b>{text}</b>',
ParagraphStyle("SCH", parent=styles["Normal"],
fontSize=11, textColor=colors.white,
backColor=colors.HexColor("#0277bd"),
spaceAfter=6, spaceBefore=10,
leftIndent=-10, rightIndent=-10,
borderPad=5, fontName="Helvetica-Bold")
)
def body(text):
return Paragraph(text, body_style)
def rationale(text):
return Paragraph(f"WHY: {text}", rationale_style)
def warning(text):
return Paragraph(f"AVOID: {text}", warning_style)
def note(text):
return Paragraph(f"NOTE: {text}", note_style)
def source(text):
return Paragraph(f"Source: {text}", source_style)
def spacer(h=0.2):
return Spacer(1, h*cm)
def hr():
return HRFlowable(width="100%", thickness=0.5, color=colors.HexColor("#b0bec5"), spaceAfter=4, spaceBefore=4)
def make_table(headers, rows, col_widths=None):
data = [headers] + rows
if not col_widths:
col_widths = [4*cm] * len(headers)
t = Table(data, colWidths=col_widths, repeatRows=1)
style = TableStyle([
('BACKGROUND', (0,0), (-1,0), colors.HexColor("#1a237e")),
('TEXTCOLOR', (0,0), (-1,0), colors.white),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ALIGN', (0,0), (-1,-1), 'LEFT'),
('VALIGN', (0,0), (-1,-1), 'TOP'),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('FONTSIZE', (0,1), (-1,-1), 8.5),
('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, colors.HexColor("#e8eaf6")]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#90a4ae")),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 5),
('RIGHTPADDING', (0,0), (-1,-1), 5),
])
t.setStyle(style)
return t
# =============================================
# BUILD DOCUMENT
# =============================================
story = []
# COVER
story.append(Spacer(1, 2*cm))
story.append(Paragraph("ANTIBIOTICS CLINICAL REFERENCE GUIDE", title_style))
story.append(Paragraph("Bacterial Infections by Body System — Pathogens, Rationale & Treatment", subtitle_style))
story.append(Paragraph("For Medical Students & Junior Doctors", subtitle_style))
story.append(spacer(0.5))
story.append(HRFlowable(width="80%", thickness=2, color=colors.HexColor("#1a237e"), hAlign='CENTER'))
story.append(spacer(0.3))
story.append(Paragraph("Sources: Harrison's Principles of Internal Medicine 22E (2025) · Washington Manual of Medical Therapeutics · Tintinalli's Emergency Medicine · Katzung's Basic & Clinical Pharmacology 16E · Rosen's Emergency Medicine · Campbell Walsh Wein Urology · Textbook of Family Medicine 9E · Medical Microbiology 9E · IDSA 2025 Guidelines", source_style))
story.append(spacer(0.5))
story.append(Paragraph(
"HOW TO USE THIS GUIDE: Each section explains WHAT bacteria cause a specific infection, WHY that specific antibiotic is chosen (mechanism, pharmacokinetics, tissue penetration, resistance profile), then gives a quick-reference table for bedside use.",
note_style))
story.append(PageBreak())
# =============================================
# SECTION 1: URINARY TRACT INFECTIONS
# =============================================
story.append(section_header("SECTION 1: URINARY TRACT INFECTIONS (UTI)", "#1a237e"))
story.append(body(
"The urinary tract is the most common site of bacterial infection in humans. The vast majority — about 80-85% — are caused by <b>Escherichia coli</b>, a gram-negative rod that normally lives in the bowel. It colonizes the periurethral area and ascends into the bladder. Other organisms include <b>Klebsiella pneumoniae</b>, <b>Staphylococcus saprophyticus</b> (especially in young sexually active women), <b>Proteus mirabilis</b>, <b>Enterococcus faecalis</b>, and <b>Pseudomonas aeruginosa</b> (in hospital/catheter settings)."
))
story.append(spacer())
# Scenario 1
story.append(scenario_header("SCENARIO 1: Uncomplicated Cystitis — Healthy Non-Pregnant Woman"))
story.append(body("<b>Who:</b> Young/middle-aged woman, no fever, no flank pain, no comorbidities. Symptoms: dysuria, frequency, urgency, suprapubic discomfort only."))
story.append(body("<b>Causative bacteria:</b> E. coli (80-85%), S. saprophyticus (5-15% in young women), Klebsiella, Proteus."))
story.append(spacer(0.1))
story.append(h3_style and Paragraph("<b>FIRST LINE: Nitrofurantoin 100 mg twice daily x 5 days</b>", h3_style))
story.append(rationale(
"Nitrofurantoin is bactericidal specifically in urine. After oral absorption, it is rapidly excreted and concentrated in the urine — reaching levels 200-400 times higher than serum levels. This means it kills E. coli right inside the bladder where the infection is. It works by damaging bacterial DNA through reactive oxygen intermediates. Crucially, it does NOT achieve therapeutic levels in blood or tissues, which is exactly why it is ONLY suitable for lower UTI (cystitis), not for pyelonephritis. "
"Resistance remains low globally because its mechanism of action is difficult for bacteria to overcome with single mutations. It is the safest first-line agent with minimal systemic side effects."
))
story.append(warning("Do NOT use if GFR < 45 mL/min — it won't reach therapeutic urine concentrations and may accumulate causing toxicity. Do NOT use if pyelonephritis is suspected."))
story.append(source("Katzung's Basic & Clinical Pharmacology 16E; Harrison's Principles of Internal Medicine 22E (2025)"))
story.append(spacer(0.1))
story.append(Paragraph("<b>FIRST LINE: TMP-SMX (Trimethoprim-Sulfamethoxazole) DS 1 tab twice daily x 3 days</b>", h3_style))
story.append(rationale(
"TMP-SMX works by a double-block mechanism on bacterial folate synthesis — sulfamethoxazole blocks PABA conversion (step 1) and trimethoprim blocks dihydrofolate reductase (step 2). Bacteria need their own folate and cannot take up human folate, so this dual block is highly bactericidal with excellent tissue penetration. "
"It is excreted in urine at high concentrations, making it effective for lower UTIs. The 3-day course is sufficient because this drug achieves very high urinary concentrations. However, E. coli resistance has been rising — if local resistance exceeds 20%, choose nitrofurantoin or fosfomycin instead."
))
story.append(warning("Avoid in 1st trimester of pregnancy (folate antagonism — risk of neural tube defects). Avoid near term (neonatal kernicterus). Monitor for hyperkalemia in patients on ACE inhibitors or ARBs."))
story.append(source("Washington Manual of Medical Therapeutics; IDSA Guidelines"))
story.append(spacer(0.1))
story.append(Paragraph("<b>FIRST LINE: Fosfomycin 3g single dose</b>", h3_style))
story.append(rationale(
"Fosfomycin inhibits the first step in bacterial cell wall synthesis (MurA enzyme), a target completely different from penicillins and cephalosporins. This unique mechanism means cross-resistance with other antibiotics is extremely rare. "
"A single oral dose achieves adequate bactericidal urinary concentrations for 24-48 hours — sufficient to eliminate the bacteria causing uncomplicated cystitis. This is the best option for patients who want a one-dose treatment or who are at high risk for resistant organisms."
))
story.append(note("Single-dose convenience improves compliance. Slightly lower efficacy than nitrofurantoin for recurrent/resistant infections, but excellent for first-episode uncomplicated cystitis."))
story.append(source("IDSA Guidelines; EAU Urological Infections Guidelines 2025"))
story.append(spacer(0.2))
# Scenario 2
story.append(scenario_header("SCENARIO 2: UTI in Diabetic or Elderly Woman"))
story.append(body("<b>Who:</b> Same lower UTI symptoms but in a woman with diabetes OR age > 65."))
story.append(body("<b>Why different:</b> Diabetic patients have impaired neutrophil function, delayed immune response, and higher risk of ascending infection to the kidneys. Elderly women have altered vaginal flora (lower estrogen), increased residual urine volume, and higher risk of resistant organisms. Both groups respond more slowly to short-course therapy."))
story.append(spacer(0.1))
story.append(rationale(
"Use the same first-line drugs (nitrofurantoin, TMP-SMX, fosfomycin) but EXTEND duration to 7 days. "
"The extended course compensates for the slower bacterial clearance and reduces the risk of relapse or ascent to pyelonephritis. "
"Always get a urine culture before starting treatment in these patients — they are more likely to harbor resistant organisms."
))
story.append(warning("Nitrofurantoin is often avoided in elderly patients with reduced kidney function — always check GFR first. If GFR < 45, use TMP-SMX or fosfomycin."))
story.append(source("Washington Manual of Medical Therapeutics, p.551; RxFiles UTI in Older Adults, Sept 2024"))
story.append(spacer(0.2))
# Scenario 3
story.append(scenario_header("SCENARIO 3: UTI in Men"))
story.append(body("<b>Who:</b> Any adult male with dysuria, frequency, urgency."))
story.append(body("<b>Key principle:</b> UTI in men is ALWAYS treated as complicated. The reason: the prostate sits right next to the bladder, and any bladder infection in a man can seed the prostate or involve it subclinically. The prostate is a deep tissue compartment with a blood-prostate barrier — most antibiotics do NOT penetrate it well."))
story.append(spacer(0.1))
story.append(Paragraph("<b>FIRST LINE: Ciprofloxacin 500mg twice daily OR TMP-SMX DS twice daily x 7-14 days</b>", h3_style))
story.append(rationale(
"Fluoroquinolones (ciprofloxacin, levofloxacin) are the drug of choice for male UTIs because they achieve very high concentrations in prostate tissue — prostate:plasma ratios are 1.5-2.5x. "
"They work by inhibiting bacterial DNA gyrase (topoisomerase II) and topoisomerase IV, enzymes essential for DNA replication. This bactericidal activity at tissue level ensures eradication of bacteria not just in urine but also in any involved prostate tissue. "
"TMP-SMX also penetrates prostate tissue well and is an acceptable alternative. Duration is 7-14 days (vs 3-5 days in women) because prostate tissue sterilization takes longer. "
"Harrison's (2025) confirms: fluoroquinolone penetration into prostate tissue is the key pharmacokinetic reason for their selection in male UTIs."
))
story.append(warning(
"DO NOT use Nitrofurantoin in men — it does not achieve adequate tissue concentrations in the prostate or kidneys. "
"DO NOT use beta-lactams (amoxicillin, cephalexin) as first-line — poor prostate penetration. "
"Studies show 7 days is non-inferior to 14 days for afebrile male UTI; use 14 days if febrile (possible prostatitis)."
))
story.append(source("Harrison's Principles of Internal Medicine 22E (2025); Campbell Walsh Wein Urology; IDSA 2025 cUTI Guidelines"))
story.append(spacer(0.2))
# Scenario 4
story.append(scenario_header("SCENARIO 4: Pyelonephritis — Outpatient (Mild-Moderate)"))
story.append(body("<b>Who:</b> Fever + flank pain + CVA tenderness, but stable, can take oral meds, not vomiting severely."))
story.append(body("<b>Causative bacteria:</b> E. coli (most common), Klebsiella, Proteus. Same organisms as cystitis but they have ascended to the kidney."))
story.append(body("<b>Key pharmacokinetic requirement:</b> Now you need an antibiotic that not only concentrates in urine but also achieves TISSUE levels inside the kidney parenchyma. Nitrofurantoin FAILS here — it does not reach kidney tissue at adequate levels."))
story.append(spacer(0.1))
story.append(Paragraph("<b>FIRST LINE: Ciprofloxacin 500-750mg twice daily x 7 days OR Levofloxacin 750mg once daily x 5-7 days</b>", h3_style))
story.append(rationale(
"Fluoroquinolones are concentration-dependent killers — the higher the peak concentration relative to the MIC (minimum inhibitory concentration), the more bacteria they kill. "
"They achieve excellent renal tissue penetration, high urinary concentrations, AND high serum/tissue concentrations simultaneously — making them ideal for infections that have spread from bladder to kidney. "
"Oral bioavailability is near 100%, meaning oral cipro gives the same blood levels as IV cipro — a huge advantage for outpatient management. "
"Duration 7 days for cipro is sufficient because of its concentration-dependent killing — shorter than TMP-SMX for the same infection."
))
story.append(warning("Fluoroquinolones have multiple serious side effects: tendon rupture (especially Achilles), peripheral neuropathy, QT prolongation (moxifloxacin especially), CNS effects (seizures, confusion), and worsening of myasthenia gravis. Use with caution in elderly, patients on steroids, and organ transplant recipients. Do NOT use in pregnancy."))
story.append(source("Harrison's Principles of Internal Medicine 22E (2025), Section on Fluoroquinolones"))
story.append(spacer(0.2))
# Scenario 5
story.append(scenario_header("SCENARIO 5: Pyelonephritis — Inpatient (Severe/Septic)"))
story.append(body("<b>Who:</b> High fever, rigors, vomiting, unable to take oral meds, sepsis criteria, pregnant, immunocompromised, or failed outpatient treatment within 48-72 hours."))
story.append(spacer(0.1))
story.append(Paragraph("<b>IV: Ceftriaxone 1-2g IV once daily</b>", h3_style))
story.append(rationale(
"Ceftriaxone is a 3rd-generation cephalosporin. It inhibits cell wall synthesis by binding to penicillin-binding proteins (PBPs), but unlike older penicillins, it is stable against most beta-lactamases that E. coli produces. "
"It covers the vast majority of gram-negative urinary pathogens (E. coli, Klebsiella, Proteus) effectively. Once daily dosing makes it convenient for hospital use. "
"After 48-72 hours when the patient becomes afebrile and can take oral medication, switch ('step down') to oral ciprofloxacin or TMP-SMX based on culture results to complete the total 10-14 day course. This IV-to-oral switch strategy saves costs and reduces hospital stay."
))
story.append(Paragraph("<b>IV: Piperacillin-Tazobactam 3.375-4.5g IV q6h (if broader coverage needed)</b>", h3_style))
story.append(rationale(
"Pip-tazo combines piperacillin (an extended-spectrum penicillin with anti-pseudomonal activity) with tazobactam (a beta-lactamase inhibitor). "
"Use when: Pseudomonas is suspected (hospital-acquired, recent instrumentation), polymicrobial infection, or Enterococcus coverage needed. "
"Tazobactam blocks the beta-lactamase enzymes that many gram-negative rods produce to destroy penicillins — this combination restores and extends the antibacterial spectrum."
))
story.append(Paragraph("<b>IV: Meropenem 1g IV q8h (for ESBL-producing organisms or MDR)</b>", h3_style))
story.append(rationale(
"Carbapenems are the last resort for ESBL (Extended-Spectrum Beta-Lactamase)-producing Enterobacteriaceae. ESBL enzymes destroy all cephalosporins and most penicillins. Carbapenems are resistant to ESBL degradation because of their unique bicyclic structure. "
"Use only when culture confirms ESBL or when the patient has failed cephalosporin therapy. Preserve carbapenems to maintain their effectiveness — overuse leads to carbapenem-resistant organisms (CRE), which are extremely difficult to treat."
))
story.append(source("Washington Manual of Medical Therapeutics; IDSA 2025 cUTI Guidelines; Harrison's 22E"))
story.append(spacer(0.2))
# Scenario 6 - CAUTI
story.append(scenario_header("SCENARIO 6: Catheter-Associated UTI (CAUTI)"))
story.append(body("<b>Who:</b> Patient with urinary catheter in place (or removed within 48 hours) + fever or local symptoms."))
story.append(body("<b>Bacteria:</b> More diverse than community UTI — E. coli still common but also Klebsiella, Pseudomonas, Enterococcus, Candida (especially in ICU patients on antibiotics)."))
story.append(spacer(0.1))
story.append(rationale(
"The catheter forms a surface for biofilm — bacteria embed in a protective polysaccharide matrix that makes them 100-1000x more resistant to antibiotics than planktonic bacteria. "
"This is why the FIRST step in CAUTI treatment is REMOVING or CHANGING the catheter — this disrupts the biofilm and dramatically improves antibiotic efficacy. "
"Antibiotic choice follows culture results. Empirically: Ciprofloxacin oral if stable (covers most gram-negatives), pip-tazo or meropenem IV if septic (covers Pseudomonas and resistant organisms). Duration 7 days if catheter removed; 14 days if catheter must remain in place."
))
story.append(warning("Do NOT treat asymptomatic bacteriuria in catheterized patients — bacteriuria is inevitable with catheters and treating it without symptoms drives resistance and provides no benefit. This is a common medical error."))
story.append(source("Rosen's Emergency Medicine; CDC CAUTI Guidelines; IDSA Guidelines"))
story.append(spacer(0.2))
# Scenario 7 - Pregnancy
story.append(scenario_header("SCENARIO 7: UTI in Pregnancy"))
story.append(body("<b>Key rule:</b> ALWAYS treat, even asymptomatic bacteriuria (ASB). Untreated ASB in pregnancy progresses to pyelonephritis in 20-30% of cases, which is associated with preterm labor, low birth weight, and maternal sepsis."))
story.append(spacer(0.1))
story.append(rationale(
"Drug selection in pregnancy is driven by two needs: efficacy against the causative organism AND fetal safety. "
"Nitrofurantoin: safe and effective in 1st and 2nd trimester. Avoid at term (>36 weeks) because the fetal red blood cells are deficient in glutathione and cannot handle oxidative stress — risk of neonatal hemolytic anemia. "
"Cephalexin / Cefuroxime: Beta-lactam cephalosporins are Category B in pregnancy — no teratogenicity shown. They achieve adequate urinary concentrations and cover E. coli. "
"Pyelonephritis in pregnancy: ALWAYS admit to hospital for IV ceftriaxone. The pregnant uterus compresses ureters, and infected kidney can rapidly deteriorate. Risk of ARDS and urosepsis is disproportionately high in pregnancy."
))
story.append(warning(
"TMP-SMX: AVOID in 1st trimester (folate antagonist, risk of neural tube defects) and at term (kernicterus). "
"Fluoroquinolones: AVOID throughout pregnancy — animal data shows cartilage damage to developing joints. "
"Aminoglycosides: AVOID — nephrotoxic and ototoxic to fetus."
))
story.append(source("Creasy & Resnik's Maternal-Fetal Medicine; Harrison's 22E; Washington Manual"))
story.append(spacer())
# UTI Summary Table
story.append(Paragraph("<b>UTI QUICK REFERENCE TABLE</b>", h2_style))
uti_headers = ["Scenario", "Key Bacteria", "First-Line Drug", "Dose & Duration", "Key Reason WHY"]
uti_rows = [
["Uncomplicated cystitis (woman)", "E. coli, S. saprophyticus", "Nitrofurantoin", "100mg BD x 5d", "Concentrated in urine; low resistance"],
["", "", "TMP-SMX DS", "1 tab BD x 3d", "Dual folate blockade; high urinary levels"],
["", "", "Fosfomycin", "3g single dose", "Unique MurA inhibition; no cross-resistance"],
["Diabetic/elderly woman", "E. coli (resistant strains more common)", "Same as above", "7 days (extend)", "Slower immune clearance; relapse risk"],
["Male UTI", "E. coli, Klebsiella, Enterococcus", "Ciprofloxacin or TMP-SMX", "7-14 days", "Prostate tissue penetration needed"],
["Pyelonephritis (outpatient)", "E. coli, Klebsiella", "Ciprofloxacin", "500mg BD x 7d", "Renal tissue + urine levels both needed"],
["Pyelonephritis (inpatient)", "E. coli, Klebsiella, Proteus", "Ceftriaxone IV", "1-2g/day IV then step-down", "Stable vs beta-lactamases; broad gram-neg"],
["CAUTI", "E. coli, Pseudomonas, Enterococcus", "Ciprofloxacin (mild); Pip-tazo or Meropenem (septic)", "7-14d", "Remove catheter first; biofilm disruption"],
["Pregnancy", "E. coli", "Nitrofurantoin or Cephalexin", "7 days", "Fetal safety profile; Category B"],
["ESBL/MDR UTI", "ESBL E. coli/Klebsiella", "Meropenem", "7-10d IV", "Carbapenem-stable structure vs ESBL"],
]
story.append(make_table(uti_headers, uti_rows, [3.5*cm, 3.5*cm, 3*cm, 3.5*cm, 3.5*cm]))
story.append(PageBreak())
# =============================================
# SECTION 2: RESPIRATORY TRACT INFECTIONS
# =============================================
story.append(section_header("SECTION 2: RESPIRATORY TRACT INFECTIONS", "#b71c1c"))
story.append(body(
"Respiratory infections are divided by anatomy (upper vs lower tract) and by acquisition setting (community vs hospital). "
"The most important distinction for antibiotic selection is whether the infection is typical (caused by bacteria with a cell wall — gram-positive streptococci, Haemophilus influenzae) or atypical (Mycoplasma, Chlamydophila, Legionella — organisms without a typical cell wall that DO NOT respond to beta-lactams)."
))
story.append(spacer())
story.append(scenario_header("SCENARIO 1: Community-Acquired Pneumonia (CAP) — Outpatient, Healthy Adult"))
story.append(body("<b>Causative bacteria:</b> Streptococcus pneumoniae (most common typical pathogen), Haemophilus influenzae, Moraxella catarrhalis, Mycoplasma pneumoniae, Chlamydophila pneumoniae, Legionella pneumophila (atypical)."))
story.append(spacer(0.1))
story.append(Paragraph("<b>Amoxicillin 500mg-1g three times daily x 5-7 days (for typical CAP)</b>", h3_style))
story.append(rationale(
"S. pneumoniae has a thick peptidoglycan cell wall. Amoxicillin (a beta-lactam) binds to penicillin-binding proteins (PBPs) on the bacterial cell wall, inhibiting cross-linking of peptidoglycan strands — causing cell lysis and bacterial death. "
"S. pneumoniae is highly susceptible to amoxicillin in most regions. High oral bioavailability (~90%), good lung tissue penetration, and cost-effectiveness make amoxicillin the ideal outpatient drug for typical bacterial pneumonia."
))
story.append(Paragraph("<b>Azithromycin 500mg once daily x 3-5 days (for atypical CAP)</b>", h3_style))
story.append(rationale(
"Mycoplasma, Chlamydophila, and Legionella have NO cell wall — beta-lactams (amoxicillin, cephalosporins) are completely ineffective because they work by targeting the cell wall. "
"Azithromycin is a macrolide that inhibits bacterial protein synthesis by binding the 50S ribosomal subunit (23S rRNA). It works INSIDE the cell, so cell-wall-less organisms are fully susceptible. "
"Azithromycin also concentrates dramatically in lung tissue — tissue:plasma ratio is approximately 200:1 in lung. A 3-5 day course maintains therapeutic lung levels for 7-10 days because of its exceptionally long half-life (~68 hours). "
"Atypical pneumonia is especially common in younger patients, college students, and military recruits."
))
story.append(Paragraph("<b>Amoxicillin + Azithromycin (for unknown CAP when both typical + atypical possible)</b>", h3_style))
story.append(rationale(
"When you cannot determine if pneumonia is typical or atypical clinically, combining amoxicillin (covers cell-walled bacteria) with azithromycin (covers atypical organisms) gives complete empiric coverage. "
"This is the combination recommended for outpatient CAP requiring dual coverage."
))
story.append(source("Harrison's Principles of Internal Medicine 22E (2025); Tintinalli's Emergency Medicine; IDSA/ATS CAP Guidelines"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 2: CAP — Inpatient (Non-ICU)"))
story.append(body("<b>Causative bacteria:</b> Same as outpatient CAP + higher likelihood of drug-resistant S. pneumoniae (DRSP) and gram-negative organisms."))
story.append(spacer(0.1))
story.append(Paragraph("<b>Beta-Lactam (Ceftriaxone 1-2g IV/day) + Azithromycin 500mg IV/oral</b>", h3_style))
story.append(rationale(
"Ceftriaxone is used over amoxicillin for inpatients because: (1) it can be given IV, (2) broader coverage of gram-negative organisms that may co-infect, (3) more resistant to beta-lactamases. "
"Azithromycin is added to cover atypical organisms (Mycoplasma, Legionella). "
"This dual approach covers both typical and atypical pathogens — the standard of care for admitted CAP patients."
))
story.append(Paragraph("<b>OR: Respiratory Fluoroquinolone (Levofloxacin 750mg/day OR Moxifloxacin 400mg/day) as MONOTHERAPY</b>", h3_style))
story.append(rationale(
"Respiratory fluoroquinolones (levofloxacin, moxifloxacin, gemifloxacin) have been enhanced with additional gram-positive activity compared to older fluoroquinolones like ciprofloxacin. "
"They cover S. pneumoniae (including DRSP), Haemophilus, AND all atypical organisms in a single drug — making them convenient monotherapy for CAP. "
"Harrison's (2025) confirms: levofloxacin and moxifloxacin have gram-positive activity including S. pneumoniae, making them suitable for CAP monotherapy. "
"Use when: allergy to beta-lactams, DRSP risk, or when combined coverage in one pill is preferred."
))
story.append(warning("Moxifloxacin prolongs QT interval — avoid in patients on other QT-prolonging drugs, with hypokalemia, or pre-existing cardiac arrhythmias. Note: Ciprofloxacin is NOT a respiratory fluoroquinolone and does NOT adequately cover S. pneumoniae — do not use it for CAP."))
story.append(source("Harrison's Principles of Internal Medicine 22E (2025), Fluoroquinolones section"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 3: CAP — ICU / Severe (including Legionella risk)"))
story.append(body("<b>Causative bacteria:</b> S. pneumoniae, Legionella pneumophila (major cause of severe CAP), gram-negative rods, S. aureus (including MRSA in post-influenza pneumonia)."))
story.append(spacer(0.1))
story.append(Paragraph("<b>Ceftriaxone IV + Levofloxacin IV (or Azithromycin IV)</b>", h3_style))
story.append(rationale(
"Legionella requires intracellular antibiotics — it lives inside macrophages. Only drugs that penetrate intracellularly (macrolides, fluoroquinolones, tetracyclines) work. "
"For severe CAP where Legionella is possible, a respiratory fluoroquinolone or macrolide MUST be included in the regimen. "
"If post-influenza pneumonia with suspected MRSA: add Vancomycin or Linezolid to the regimen."
))
story.append(source("Harrison's 22E; IDSA/ATS CAP Guidelines"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 4: Hospital-Acquired Pneumonia (HAP) / Ventilator-Associated (VAP)"))
story.append(body("<b>Key difference from CAP:</b> In hospital settings, bacteria are completely different — gram-negative rods dominate: Pseudomonas aeruginosa, Klebsiella pneumoniae, Acinetobacter baumannii, MRSA. These are inherently more resistant."))
story.append(spacer(0.1))
story.append(Paragraph("<b>Piperacillin-Tazobactam 4.5g IV q6h + Vancomycin IV</b>", h3_style))
story.append(rationale(
"Pip-tazo covers Pseudomonas and most gram-negative HAP organisms. "
"Vancomycin is added to cover MRSA — a gram-positive organism that has acquired resistance to all beta-lactams. Vancomycin inhibits cell wall synthesis at a different step (D-Ala-D-Ala binding) that MRSA's altered PBP2a cannot resist. "
"For carbapenem-resistant organisms: consult Infectious Disease — may require colistin, ceftazidime-avibactam, or cefiderocol."
))
story.append(source("IDSA HAP/VAP Guidelines; Harrison's 22E"))
story.append(spacer())
# Respiratory Table
story.append(Paragraph("<b>RESPIRATORY INFECTIONS QUICK REFERENCE TABLE</b>", h2_style))
resp_headers = ["Scenario", "Key Bacteria", "First-Line Drug", "Dose", "Reason WHY"]
resp_rows = [
["CAP — outpatient, typical", "S. pneumoniae, H. influenzae", "Amoxicillin", "500mg-1g TDS x 5-7d", "Cell wall synthesis inhibition; high lung penetration"],
["CAP — atypical (Mycoplasma, Legionella)", "Mycoplasma, Chlamydophila, Legionella", "Azithromycin", "500mg OD x 3-5d", "50S inhibitor; works on cell-wall-less organisms; 200:1 lung:plasma ratio"],
["CAP — unknown type", "Mixed typical + atypical", "Amoxicillin + Azithromycin", "Combined", "Covers both cell-walled and atypical organisms"],
["CAP — inpatient (non-ICU)", "S. pneumoniae + atypicals", "Ceftriaxone + Azithromycin", "1-2g IV/day + 500mg", "IV beta-lactam + atypical coverage"],
["CAP — monotherapy option", "S. pneumoniae + gram-neg + atypicals", "Levofloxacin or Moxifloxacin", "750mg or 400mg OD", "Respiratory FQ: covers gram+, gram-, AND atypicals"],
["CAP — severe/ICU", "As above + Legionella, MRSA", "Ceftriaxone + Levo/Azithromycin ± Vancomycin", "IV combination", "Intracellular coverage for Legionella; MRSA coverage"],
["HAP/VAP (hospital)", "Pseudomonas, MRSA, Klebsiella", "Pip-Tazo + Vancomycin", "4.5g q6h + weight-based", "Anti-pseudomonal + MRSA coverage"],
["Acute Exacerbation of COPD", "H. influenzae, S. pneumoniae, Moraxella", "Amoxicillin-Clavulanate or Doxycycline", "625mg TDS x 5d or 100mg BD x 5d", "Beta-lactamase stable; atypical coverage"],
["Pertussis (whooping cough)", "Bordetella pertussis", "Azithromycin", "500mg OD x 5d", "Macrolide: drug of choice; reduces transmission"],
]
story.append(make_table(resp_headers, resp_rows, [3.2*cm, 3.5*cm, 3.3*cm, 2.8*cm, 4.2*cm]))
story.append(PageBreak())
# =============================================
# SECTION 3: GASTROINTESTINAL INFECTIONS
# =============================================
story.append(section_header("SECTION 3: GASTROINTESTINAL (GI) INFECTIONS", "#1b5e20"))
story.append(body(
"An important principle in GI infections: most bacterial gastroenteritis is self-limiting and does NOT require antibiotics. The body's own immune response, combined with fluid replacement, resolves most cases. "
"Antibiotics are indicated when: (1) infection is severe or prolonged, (2) patient is immunocompromised or at extremes of age, (3) specific organisms that are dangerous untreated are identified, or (4) there is bacteremia."
))
story.append(spacer())
story.append(scenario_header("SCENARIO 1: Salmonella Gastroenteritis (Food Poisoning)"))
story.append(body("<b>Bacteria:</b> Salmonella enterica (non-typhoidal) — gram-negative rod, transmitted via poultry, eggs, reptiles."))
story.append(body("<b>Clinical:</b> Watery/bloody diarrhea, fever, cramps, 12-72 hours after ingestion. Usually self-limiting in healthy adults (3-7 days)."))
story.append(rationale(
"Do NOT give antibiotics routinely for non-typhoidal Salmonella in healthy adults — it paradoxically PROLONGS the carrier state by killing normal gut flora that helps clear Salmonella. "
"Treat only if: severe disease, bacteremia, immunocompromised, extremes of age (infants, elderly). "
"When treating: Ciprofloxacin 500mg BD x 5-7 days OR Azithromycin 500mg OD x 3 days (especially for resistant strains). Fluoroquinolones are chosen for their intracellular penetration (Salmonella hides inside macrophages)."
))
story.append(source("Harrison's 22E; Tintinalli's Emergency Medicine"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 2: Typhoid Fever (Enteric Fever)"))
story.append(body("<b>Bacteria:</b> Salmonella typhi or S. paratyphi — a systemic infection, not just gastroenteritis."))
story.append(body("<b>Clinical:</b> Step-ladder fever, relative bradycardia, rose spots, hepatosplenomegaly, constipation (not diarrhea)."))
story.append(Paragraph("<b>Azithromycin 1g OD x 5-7 days (uncomplicated, outpatient)</b>", h3_style))
story.append(rationale(
"S. typhi has developed widespread resistance to fluoroquinolones (reduced susceptibility), ampicillin, and chloramphenicol. Azithromycin has emerged as the preferred oral agent for uncomplicated typhoid in areas with high fluoroquinolone resistance. "
"It penetrates intracellularly (macrophages, intestinal epithelium where typhoid bacteria hide), achieves high tissue concentrations, and has a good safety profile."
))
story.append(Paragraph("<b>Ceftriaxone 2g IV OD x 10-14 days (severe/complicated typhoid)</b>", h3_style))
story.append(rationale(
"For severe typhoid with complications (intestinal perforation, severe bacteremia, altered consciousness): IV ceftriaxone provides bactericidal levels in blood and tissues. "
"Ceftriaxone resistance is still uncommon in S. typhi, making it the preferred IV agent globally."
))
story.append(source("Harrison's 22E; WHO Typhoid Guidelines"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 3: Shigella Dysentery"))
story.append(body("<b>Bacteria:</b> Shigella species — gram-negative rods; person-to-person transmission; very low infective dose."))
story.append(body("<b>Clinical:</b> Bloody, mucoid diarrhea, high fever, tenesmus (painful urge to defecate), cramping."))
story.append(Paragraph("<b>Azithromycin 500mg OD x 3 days OR Ciprofloxacin 500mg BD x 3 days</b>", h3_style))
story.append(rationale(
"Unlike Salmonella, Shigella infections ALWAYS benefit from antibiotics — they shorten illness duration, reduce shedding, and prevent complications (HUS from S. dysenteriae). "
"Azithromycin is now preferred in many regions because of rising fluoroquinolone resistance in Shigella. It concentrates well in gut mucosa where Shigella invades. "
"Always treat children and immunocompromised patients promptly."
))
story.append(source("Harrison's 22E; Tintinalli's EM"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 4: Campylobacter Enteritis"))
story.append(body("<b>Bacteria:</b> Campylobacter jejuni — most common bacterial cause of diarrhea worldwide; from undercooked poultry."))
story.append(body("<b>Clinical:</b> Bloody/watery diarrhea, fever, crampy abdominal pain, may mimic appendicitis."))
story.append(Paragraph("<b>Azithromycin 500mg OD x 3 days (when antibiotics needed)</b>", h3_style))
story.append(rationale(
"Most Campylobacter infections are self-limiting. Antibiotics are given if: severe disease, bacteremia, persistent symptoms >7 days, or immunocompromised patient. "
"Azithromycin is preferred over fluoroquinolones because Campylobacter has very high rates of fluoroquinolone resistance globally (>60% resistance in some regions due to overuse in poultry farming)."
))
story.append(source("Harrison's 22E"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 5: H. pylori Infection"))
story.append(body("<b>Bacteria:</b> Helicobacter pylori — gram-negative spiral rod; lives under the gastric mucus layer; causes peptic ulcer disease, gastric cancer, MALT lymphoma."))
story.append(Paragraph("<b>Triple Therapy: PPI + Amoxicillin 1g BD + Clarithromycin 500mg BD x 14 days</b>", h3_style))
story.append(rationale(
"H. pylori requires combination antibiotic therapy because monotherapy leads to rapid resistance development. "
"Amoxicillin attacks cell wall synthesis; Clarithromycin (macrolide) inhibits 50S ribosome protein synthesis. The PPI (omeprazole, pantoprazole) raises gastric pH — H. pylori needs acidic environment to survive; raising pH makes both antibiotics more effective AND directly inhibits H. pylori urease. "
"However, clarithromycin resistance has been rising globally. In areas with >15% clarithromycin resistance: use Quadruple Therapy instead."
))
story.append(Paragraph("<b>Bismuth Quadruple Therapy (if clarithromycin resistance suspected): PPI + Bismuth + Tetracycline + Metronidazole x 10-14 days</b>", h3_style))
story.append(rationale(
"Bismuth damages bacterial cell membranes and inhibits urease directly. Tetracycline inhibits 30S ribosome. Metronidazole disrupts anaerobic bacterial DNA. "
"This combination avoids clarithromycin entirely, making it effective against clarithromycin-resistant H. pylori strains."
))
story.append(source("Medical Microbiology 9E; Harrison's 22E (H. pylori section)"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 6: C. difficile Infection (CDI)"))
story.append(body("<b>Bacteria:</b> Clostridioides difficile — gram-positive spore-forming anaerobe; triggered by antibiotic use that disrupts normal gut flora."))
story.append(Paragraph("<b>Mild-Moderate: Vancomycin oral 125mg four times daily x 10 days</b>", h3_style))
story.append(rationale(
"Oral vancomycin is NOT absorbed from the gut — it stays entirely in the colon, achieving very high local concentrations right where C. diff is. It inhibits cell wall synthesis by binding D-Ala-D-Ala, killing C. diff vegetative cells. "
"Metronidazole (previously first-line) is now considered inferior to vancomycin and fidaxomicin — lower cure rates and higher recurrence."
))
story.append(Paragraph("<b>Fidaxomicin 200mg twice daily x 10 days (preferred — reduces recurrence)</b>", h3_style))
story.append(rationale(
"Fidaxomicin is a macrocyclic antibiotic with minimal systemic absorption, narrow spectrum specifically targeting C. diff, and importantly — it spares Bacteroides species (normal gut flora). "
"This selective activity means the normal gut microbiome recovers faster after fidaxomicin, dramatically reducing recurrence rates compared to vancomycin."
))
story.append(source("Harrison's 22E; IDSA/SHEA CDI Guidelines 2021"))
story.append(spacer())
# GI Table
story.append(Paragraph("<b>GI INFECTIONS QUICK REFERENCE TABLE</b>", h2_style))
gi_headers = ["Infection", "Bacteria", "Antibiotic", "Duration", "Key Reason"]
gi_rows = [
["Salmonella (non-typhoidal)", "Salmonella enterica", "Usually none; Cipro or Azithro if severe/immunocompromised", "5-7d", "Self-limiting; ABx prolong carrier state in mild cases"],
["Typhoid fever", "S. typhi", "Azithromycin (oral); Ceftriaxone (IV severe)", "5-7d oral; 10-14d IV", "Rising FQ resistance; intracellular penetration needed"],
["Shigella dysentery", "Shigella spp.", "Azithromycin or Ciprofloxacin", "3d", "Always treat; prevents HUS complication"],
["Campylobacter", "Campylobacter jejuni", "Azithromycin (if needed)", "3d", "High FQ resistance globally"],
["H. pylori", "H. pylori", "PPI + Amoxicillin + Clarithromycin", "14d", "Triple blockade prevents resistance"],
["C. difficile", "C. difficile", "Oral Vancomycin or Fidaxomicin", "10d", "Oral Vanc stays in colon; Fidaxomicin reduces recurrence"],
["Spontaneous Bacterial Peritonitis", "E. coli, Klebsiella, Streptococcus", "Ceftriaxone IV 2g OD", "5d", "Broad gram-neg coverage; IV needed"],
]
story.append(make_table(gi_headers, gi_rows, [3.5*cm, 3.5*cm, 3.5*cm, 2.5*cm, 4*cm]))
story.append(PageBreak())
# =============================================
# SECTION 4: CNS INFECTIONS
# =============================================
story.append(section_header("SECTION 4: CNS INFECTIONS — MENINGITIS & BRAIN ABSCESS", "#4a148c"))
story.append(body(
"CNS infections are neurological emergencies. DO NOT delay antibiotics waiting for CT or LP results if bacterial meningitis is clinically suspected — give antibiotics IMMEDIATELY after blood cultures are drawn. "
"The critical pharmacokinetic challenge: the Blood-Brain Barrier (BBB) excludes most antibiotics. Only antibiotics that penetrate the inflamed meninges adequately (high-dose beta-lactams, chloramphenicol, metronidazole, some fluoroquinolones) are effective."
))
story.append(spacer())
story.append(scenario_header("SCENARIO 1: Bacterial Meningitis — Adult (16-50 years)"))
story.append(body("<b>Causative bacteria:</b> Neisseria meningitidis (most common in adolescents/young adults — gram-negative diplococci), Streptococcus pneumoniae (most common overall — gram-positive diplococci)."))
story.append(body("<b>Classic triad:</b> Fever + Neck stiffness + Altered consciousness. Petechial rash = N. meningitidis until proven otherwise."))
story.append(spacer(0.1))
story.append(Paragraph("<b>Ceftriaxone 2g IV q12h + Vancomycin IV + Dexamethasone 0.15mg/kg IV q6h x 4 days</b>", h3_style))
story.append(rationale(
"Ceftriaxone crosses the inflamed BBB at adequate concentrations (CSF levels reach 1-10% of plasma in inflamed meninges). It covers both N. meningitidis and S. pneumoniae effectively by inhibiting PBP2x — the primary PBP of S. pneumoniae. "
"Vancomycin is added because of penicillin/cephalosporin-resistant S. pneumoniae (DRSP). Vancomycin provides backup coverage through its D-Ala-D-Ala binding mechanism that is unaffected by beta-lactam resistance. "
"Dexamethasone: Bacterial lysis by antibiotics releases cell wall fragments that trigger massive CNS inflammation. Dexamethasone given BEFORE or WITH the first antibiotic dose reduces this inflammatory cascade, decreasing risk of deafness and neurological sequelae. "
"Textbook of Family Medicine: 'Antibiotic therapy should be started as soon as possible, usually immediately after LP or after blood cultures if CT is needed first.'"
))
story.append(source("Textbook of Family Medicine 9E, Tables 41-17 to 41-19; Harrison's 22E"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 2: Bacterial Meningitis — Neonate (<3 months)"))
story.append(body("<b>Causative bacteria:</b> Group B Streptococcus (GBS), E. coli (K1 strain), Listeria monocytogenes (gram-positive rod; NOT covered by cephalosporins)."))
story.append(Paragraph("<b>Ampicillin IV + Gentamicin IV (OR Ampicillin + Cefotaxime)</b>", h3_style))
story.append(rationale(
"Ampicillin is essential because it covers Listeria monocytogenes — a critical neonatal pathogen that is NATURALLY RESISTANT to all cephalosporins. This is why ceftriaxone alone is never sufficient for neonatal meningitis. "
"Gentamicin is synergistic with ampicillin against gram-negative rods (E. coli) — the aminoglycoside disrupts outer membrane, allowing ampicillin to enter and reach PBPs. "
"Tintinalli's EM Table confirms: ampicillin + gentamicin is the standard neonatal meningitis regimen."
))
story.append(source("Tintinalli's Emergency Medicine (Neonatal Meningitis Table); Textbook of Family Medicine 9E"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 3: Bacterial Meningitis — Elderly (>50 years) or Immunocompromised"))
story.append(body("<b>Additional bacteria:</b> Listeria monocytogenes (second most common in elderly and immunocompromised — again NOT covered by cephalosporins) + all adult bacteria."))
story.append(Paragraph("<b>Ceftriaxone + Vancomycin + Ampicillin (to cover Listeria)</b>", h3_style))
story.append(rationale(
"Ampicillin is added specifically to cover Listeria. Risk factors for Listeria meningitis: age >50, pregnancy, alcoholism, immunosuppression (steroids, transplant, HIV), malignancy. "
"Listeria is inherently resistant to cephalosporins — if ampicillin is omitted in an elderly patient with meningitis who turns out to have Listeria, treatment will fail completely."
))
story.append(source("Textbook of Family Medicine 9E, Table 41-18"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 4: Brain Abscess"))
story.append(body("<b>Causative bacteria:</b> Streptococcus milleri group, anaerobes (Bacteroides, Fusobacterium), Staphylococcus aureus (post-trauma/neurosurgery), gram-negative rods."))
story.append(Paragraph("<b>Ceftriaxone 2g IV q12h + Metronidazole 500mg IV q8h (± Vancomycin if S. aureus/MRSA risk)</b>", h3_style))
story.append(rationale(
"Brain abscesses are almost always polymicrobial — a mix of streptococci, anaerobes, and gram-negative rods. "
"Ceftriaxone covers streptococci and gram-negative organisms. Metronidazole is essential to cover anaerobes — it is converted inside anaerobic bacteria to a toxic compound that breaks bacterial DNA. Metronidazole penetrates brain tissue and CSF well. "
"Duration is long (4-8 weeks) because antibiotics penetrate poorly into the abscess core, and surgical drainage is often needed alongside antibiotics."
))
story.append(source("Harrison's 22E; Tintinalli's EM"))
story.append(spacer())
story.append(Paragraph("<b>CNS INFECTIONS QUICK REFERENCE TABLE</b>", h2_style))
cns_headers = ["Scenario", "Key Bacteria", "Empiric Regimen", "Duration", "Key Reason"]
cns_rows = [
["Adult meningitis (16-50y)", "N. meningitidis, S. pneumoniae", "Ceftriaxone + Vancomycin + Dexamethasone", "14-21d", "BBB penetration; DRSP coverage; inflammation reduction"],
["Neonatal meningitis (<3mo)", "GBS, E. coli, Listeria", "Ampicillin + Gentamicin", "14-21d", "Ampicillin essential — only drug covering Listeria"],
["Elderly/immunocompromised meningitis", "S. pneumoniae, Listeria, gram-negs", "Ceftriaxone + Vancomycin + Ampicillin", "14-21d", "Add Ampicillin for Listeria coverage"],
["Brain abscess", "Streptococci, anaerobes, gram-negs", "Ceftriaxone + Metronidazole", "4-8 weeks", "Metronidazole for anaerobic coverage + good brain penetration"],
["Post-neurosurgery meningitis", "S. aureus, MRSA, gram-negs", "Vancomycin + Cefepime or Meropenem", "Variable", "Hospital pathogens: MRSA + Pseudomonas coverage"],
]
story.append(make_table(cns_headers, cns_rows, [3.5*cm, 3.5*cm, 4*cm, 2.5*cm, 3.5*cm]))
story.append(PageBreak())
# =============================================
# SECTION 5: SKIN & SOFT TISSUE INFECTIONS
# =============================================
story.append(section_header("SECTION 5: SKIN & SOFT TISSUE INFECTIONS (SSTIs)", "#e65100"))
story.append(body(
"Skin infections are caused predominantly by gram-positive cocci — S. aureus and Streptococcus pyogenes (Group A Streptococcus, GAS). The key distinction is whether MRSA is likely, which changes the antibiotic choice dramatically. "
"Always classify: non-purulent (cellulitis, erysipelas — usually Streptococcus) vs purulent (abscess, furuncle — usually S. aureus including MRSA)."
))
story.append(spacer())
story.append(scenario_header("SCENARIO 1: Cellulitis — Non-Purulent, No Abscess"))
story.append(body("<b>Bacteria:</b> Streptococcus pyogenes (Group A Strep) — most common. Beta-hemolytic streptococci spread through lymphatics, not via pus formation."))
story.append(Paragraph("<b>Cephalexin 500mg four times daily x 5-7 days (outpatient)</b>", h3_style))
story.append(rationale(
"Cephalexin (first-generation cephalosporin) is highly active against Group A Streptococcus. It inhibits PBP1 and PBP3, disrupting cell wall synthesis. "
"GAS has maintained near-complete susceptibility to beta-lactams for decades — no beta-lactam resistance in Group A Strep has been documented clinically. "
"Non-purulent cellulitis does NOT typically involve MRSA — so adding MRSA coverage is unnecessary and increases side effects and costs. "
"Rosen's EM: 'As Streptococcus spp. and Staphylococcus aureus are the predominant organisms causing cellulitis, first-generation cephalosporins are preferred.'"
))
story.append(Paragraph("<b>If penicillin allergy: Clindamycin 300-450mg three times daily x 5-7 days</b>", h3_style))
story.append(rationale(
"Clindamycin inhibits 50S ribosome (23S rRNA binding — same site as macrolides but different binding pocket), blocking protein synthesis. It has excellent activity against GAS and is a safe alternative for penicillin-allergic patients. "
"Check local resistance: inducible clindamycin resistance (D-zone test) occurs in some MRSA strains — use the D-zone test to confirm true susceptibility before treating MRSA with clindamycin."
))
story.append(source("Rosen's Emergency Medicine; IDSA SSTIs Guidelines"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 2: Purulent Cellulitis / Abscess / Furuncle — MRSA Likely"))
story.append(body("<b>Bacteria:</b> Staphylococcus aureus — especially Community-Acquired MRSA (CA-MRSA). MRSA has acquired the mecA gene producing an altered PBP2a with extremely low affinity for beta-lactams — making it resistant to all penicillins and cephalosporins."))
story.append(Paragraph("<b>Incision and Drainage (I&D) — Primary treatment for abscess</b>", h3_style))
story.append(rationale(
"For skin abscesses, I&D alone cures most cases. Pus draining means bacteria are removed mechanically — antibiotics are adjunctive, not primary, for uncomplicated abscesses. Studies show I&D alone has similar cure rates to I&D + antibiotics for small uncomplicated abscesses."
))
story.append(Paragraph("<b>TMP-SMX DS 1-2 tabs twice daily x 5-7 days (for CA-MRSA, when antibiotics needed)</b>", h3_style))
story.append(rationale(
"CA-MRSA remains highly susceptible to TMP-SMX in most regions. The dual folate synthesis blockade works regardless of the beta-lactam resistance mechanism — mecA gene does NOT affect folate synthesis. "
"TMP-SMX is the preferred oral agent for CA-MRSA SSTIs in most guidelines — cheap, widely available, and highly effective."
))
story.append(Paragraph("<b>Doxycycline 100mg twice daily x 5-7 days (alternative for CA-MRSA)</b>", h3_style))
story.append(rationale(
"Doxycycline (tetracycline class) inhibits 30S ribosome — prevents tRNA binding to mRNA-ribosome complex, blocking protein elongation. CA-MRSA retains susceptibility to doxycycline in most regions. "
"Preferred when TMP-SMX is contraindicated (sulfa allergy, renal failure, pregnancy) or resistance is suspected."
))
story.append(Paragraph("<b>Vancomycin IV (for severe/systemic MRSA — bacteremia, sepsis)</b>", h3_style))
story.append(rationale(
"When MRSA enters the bloodstream (bacteremia), IV therapy is mandatory. Vancomycin binds the D-Ala-D-Ala terminus of the peptidoglycan precursor — a completely different target from beta-lactams. MRSA's altered PBP2a does not affect this mechanism. "
"AUC/MIC-guided dosing is now recommended (target AUC 400-600 mg·h/L) to optimize efficacy and minimize nephrotoxicity."
))
story.append(source("IDSA SSTIs Guidelines; Rosen's EM"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 3: Necrotizing Fasciitis — Surgical Emergency"))
story.append(body("<b>Bacteria:</b> Type I: Polymicrobial (GAS + anaerobes + gram-negatives). Type II: Monomicrobial Group A Streptococcus (GAS) — can also be MRSA."))
story.append(body("<b>Key features:</b> Pain out of proportion to appearance, skin changes (discoloration, bullae), crepitus (gas in tissue), systemic toxicity. Rapidly lethal if not treated within hours."))
story.append(rationale(
"This is a SURGICAL emergency first — antibiotics alone cannot save the patient without wide surgical debridement. "
"Antibiotic regimen must cover everything: Pip-Tazo + Vancomycin + Clindamycin. "
"Clindamycin is specifically added because GAS produces exotoxins (toxic shock syndrome toxin). Clindamycin inhibits toxin production by blocking ribosomal protein synthesis — even though GAS may technically be 'susceptible' to penicillin, if the toxins are driving the shock, only clindamycin (not penicillin) suppresses toxin output. This is the Eagle Effect: bacteria in stationary phase (slowed growth, inside necrotic tissue) are not killed by penicillin, but clindamycin works regardless of growth phase."
))
story.append(source("Harrison's 22E; Tintinalli's EM; IDSA SSTIs Guidelines"))
story.append(spacer())
story.append(Paragraph("<b>SKIN & SOFT TISSUE INFECTIONS QUICK REFERENCE TABLE</b>", h2_style))
ssti_headers = ["Scenario", "Key Bacteria", "Drug of Choice", "Duration", "Reason WHY"]
ssti_rows = [
["Non-purulent cellulitis", "S. pyogenes (GAS)", "Cephalexin", "5-7d", "PBP inhibition; GAS remains fully beta-lactam susceptible"],
["Cellulitis — penicillin allergy", "GAS", "Clindamycin", "5-7d", "50S inhibitor; excellent GAS coverage"],
["CA-MRSA abscess/furuncle (oral)", "MRSA", "TMP-SMX DS (1st) or Doxycycline", "5-7d", "Acts outside beta-lactam mechanism; CA-MRSA susceptible"],
["Severe MRSA / bacteremia", "MRSA", "Vancomycin IV", "14-42d", "D-Ala-D-Ala binding; MRSA PBP2a does not affect this"],
["Erysipelas", "GAS (S. pyogenes)", "Phenoxymethylpenicillin or Cephalexin", "7-10d", "GAS always penicillin susceptible; superficial skin layers"],
["Necrotizing fasciitis", "Polymicrobial or GAS", "Surgery + Pip-Tazo + Vancomycin + Clindamycin", "Until clear margins", "Clindamycin suppresses GAS exotoxin (Eagle effect)"],
["Diabetic foot infection (mild)", "S. aureus, Streptococcus", "Amoxicillin-clavulanate", "7-14d", "Beta-lactamase stable; covers staph + strep + anaerobes"],
["Diabetic foot (severe, Pseudomonas risk)", "MRSA, Pseudomonas, anaerobes", "Pip-Tazo + Vancomycin", "14-28d", "Broad polymicrobial + anti-pseudomonal + MRSA coverage"],
]
story.append(make_table(ssti_headers, ssti_rows, [3.5*cm, 3.5*cm, 3.5*cm, 2.5*cm, 4*cm]))
story.append(PageBreak())
# =============================================
# SECTION 6: BONE & JOINT INFECTIONS
# =============================================
story.append(section_header("SECTION 6: BONE & JOINT INFECTIONS", "#37474f"))
story.append(body(
"Bone and joint infections require prolonged antibiotic therapy — 4-6 weeks for osteomyelitis, 2-4 weeks for septic arthritis — because bone has poor vascularity and antibiotics penetrate bone slowly. "
"The dominant pathogen across all age groups is S. aureus. Antibiotic choice must account for: patient age, MRSA risk, and whether there is prosthetic hardware."
))
story.append(spacer())
story.append(scenario_header("SCENARIO 1: Acute Hematogenous Osteomyelitis — Child (3 months to 14 years)"))
story.append(body("<b>Bacteria:</b> S. aureus (most common), Group A Streptococcus, H. influenzae (less common now due to vaccination)."))
story.append(Paragraph("<b>Empiric: Anti-staphylococcal penicillin (flucloxacillin) + 3rd-generation cephalosporin IV</b>", h3_style))
story.append(rationale(
"Flucloxacillin (an isoxazolyl penicillin) is resistant to staphylococcal beta-lactamase — the enzyme that MSSA produces to destroy regular penicillin. It specifically targets PBP2 and PBP3 of S. aureus. "
"Third-generation cephalosporin is added for gram-negative coverage (H. influenzae) in younger children. "
"If MRSA suspected: replace flucloxacillin with Vancomycin IV. Rosen's EM Table 125.2: 'Consider vancomycin instead of penicillinase-resistant penicillin for MRSA.'"
))
story.append(source("Rosen's Emergency Medicine, Table 125.2 — Microbiology and Initial Antibiotic Treatment of Bone and Joint Infection"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 2: Osteomyelitis — Adult"))
story.append(body("<b>Bacteria:</b> S. aureus (>50% of cases), gram-negative rods (in IV drug users, diabetic foot)."))
story.append(Paragraph("<b>MSSA: Flucloxacillin 2g IV q4-6h x 4-6 weeks, then oral step-down</b>", h3_style))
story.append(Paragraph("<b>MRSA: Vancomycin IV x 4-6 weeks</b>", h3_style))
story.append(rationale(
"Bone has a very slow antibiotic penetration rate — serum levels must be maintained at high concentrations continuously over weeks to achieve bactericidal concentrations inside bone matrix. "
"Rifampicin is sometimes added as adjunct therapy in chronic osteomyelitis or infections with orthopedic hardware — Harrison's (2025) confirms: 'Rifampin is used in combination regimens for staphylococcal infections, particularly prosthetic valve endocarditis and bone infections with retained hardware.' Rifampin penetrates biofilms on hardware surfaces."
))
story.append(source("Harrison's Principles of Internal Medicine 22E (2025) — Rifamycins section; Rosen's EM Table 125.2"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 3: Septic Arthritis — Sexually Active Adult"))
story.append(body("<b>Bacteria:</b> Neisseria gonorrhoeae — most common cause of septic arthritis in sexually active adults under 40. Gram-negative diplococci."))
story.append(Paragraph("<b>Ceftriaxone 1g IM/IV daily x 7-14 days</b>", h3_style))
story.append(rationale(
"N. gonorrhoeae has developed resistance to fluoroquinolones (now 60-70%+ resistant globally), penicillins, and tetracyclines. Ceftriaxone remains the only reliably effective agent for gonorrhea, including disseminated gonococcal infection (DGI) causing septic arthritis. "
"Rosen's EM: Ceftriaxone is listed as the treatment for septic arthritis in 'sexually active adolescents or adults' with N. gonorrhoeae."
))
story.append(source("Rosen's Emergency Medicine Table 125.2; CDC STI Treatment Guidelines 2021"))
story.append(spacer(0.2))
story.append(scenario_header("SCENARIO 4: Prosthetic Joint Infection (PJI)"))
story.append(body("<b>Bacteria:</b> S. aureus (acute), Staphylococcus epidermidis (coagulase-negative staph, delayed/chronic) — forms biofilm on prosthesis. Pseudomonas aeruginosa (rarer)."))
story.append(Paragraph("<b>Vancomycin IV + Fluoroquinolone (Ciprofloxacin)</b>", h3_style))
story.append(rationale(
"S. epidermidis biofilm on prosthetic surfaces is extremely difficult to eradicate. Vancomycin covers both MRSA and S. epidermidis. "
"Rifampicin is added specifically for biofilm penetration — it can penetrate the polysaccharide matrix of staphylococcal biofilms. "
"Rosen's EM: 'Vancomycin + fluoroquinolone, alternative: imipenem' for infected joint prostheses. Surgical removal of hardware is often required for definitive cure."
))
story.append(source("Rosen's Emergency Medicine Table 125.2; Harrison's 22E — Rifamycins"))
story.append(spacer())
story.append(Paragraph("<b>BONE & JOINT INFECTIONS QUICK REFERENCE TABLE</b>", h2_style))
bone_headers = ["Scenario", "Key Bacteria", "Antibiotic", "Duration", "Reason WHY"]
bone_rows = [
["Osteomyelitis — child", "S. aureus, GAS", "Flucloxacillin + 3rd-gen Ceph IV (add Vanc if MRSA)", "4-6 weeks total", "Flucloxacillin: beta-lactamase stable vs MSSA"],
["Osteomyelitis — adult (MSSA)", "S. aureus", "Flucloxacillin IV → oral step-down", "4-6 weeks", "Sustained high levels needed for bone penetration"],
["Osteomyelitis — adult (MRSA)", "MRSA", "Vancomycin IV", "4-6 weeks", "D-Ala-D-Ala binding; unaffected by mecA resistance"],
["Chronic osteomyelitis / hardware", "S. aureus (biofilm)", "Add Rifampicin to backbone therapy", "3-6 months", "Rifampicin penetrates biofilm on hardware"],
["Septic arthritis — adult", "S. aureus, Streptococcus", "Flucloxacillin IV", "2-4 weeks", "PBP inhibition; rapid bactericidal action needed"],
["Gonococcal septic arthritis", "N. gonorrhoeae", "Ceftriaxone IM/IV", "7-14d", "Only reliable coverage; FQ resistance very high"],
["Prosthetic joint infection", "S. epidermidis, S. aureus", "Vancomycin + Rifampicin", "Variable (often long)", "Biofilm penetration; coagulase-neg staph coverage"],
["Sickle cell osteomyelitis", "S. aureus + Salmonella", "Flucloxacillin + 3rd-gen Ceph", "4-6 weeks", "Salmonella uniquely common in sickle cell disease"],
]
story.append(make_table(bone_headers, bone_rows, [3.5*cm, 3.5*cm, 3.5*cm, 2*cm, 4.5*cm]))
story.append(PageBreak())
# =============================================
# SECTION 7: CARDIOVASCULAR + OTHERS
# =============================================
story.append(section_header("SECTION 7: CARDIOVASCULAR, STIs & MISCELLANEOUS", "#004d40"))
story.append(scenario_header("Infective Endocarditis (IE)"))
story.append(body("<b>Bacteria:</b> Streptococcus viridans group (subacute IE, dental origin), S. aureus (acute IE, IV drug users), Enterococcus spp., HACEK organisms (Haemophilus, Aggregatibacter, Cardiobacterium, Eikenella, Kingella)."))
story.append(Paragraph("<b>Streptococcal IE: Benzylpenicillin IV + Gentamicin x 2-4 weeks</b>", h3_style))
story.append(rationale(
"Gentamicin synergizes with beta-lactams against streptococci — the beta-lactam disrupts the cell wall, allowing gentamicin to enter and inhibit the 30S ribosome. This combination is bactericidal at lower concentrations than either drug alone, critical for sterilizing the cardiac vegetation."
))
story.append(Paragraph("<b>Staphylococcal IE (MSSA): Flucloxacillin IV x 4-6 weeks</b>", h3_style))
story.append(Paragraph("<b>MRSA IE: Vancomycin IV x 4-6 weeks</b>", h3_style))
story.append(source("Harrison's 22E; ESC Endocarditis Guidelines 2023"))
story.append(spacer(0.2))
story.append(scenario_header("Gonorrhea (Uncomplicated Urogenital)"))
story.append(body("<b>Bacteria:</b> Neisseria gonorrhoeae — gram-negative diplococcus; STI."))
story.append(Paragraph("<b>Ceftriaxone 500mg IM single dose (1g if weight >150kg)</b>", h3_style))
story.append(rationale(
"Gonorrhea has developed resistance to penicillins, tetracyclines, and fluoroquinolones. Ceftriaxone is the ONLY currently recommended single-agent treatment. WHO and CDC have moved to higher doses (500mg from 250mg) due to rising MICs. "
"Always also treat for Chlamydia co-infection: Doxycycline 100mg BD x 7 days (or Azithromycin 1g single dose). Dual treatment strategy."
))
story.append(source("CDC STI Treatment Guidelines 2021; WHO Guidelines"))
story.append(spacer(0.2))
story.append(scenario_header("Chlamydia"))
story.append(body("<b>Bacteria:</b> Chlamydia trachomatis — obligate intracellular organism; NO cell wall."))
story.append(Paragraph("<b>Doxycycline 100mg twice daily x 7 days</b>", h3_style))
story.append(rationale(
"No cell wall means all beta-lactams are useless — they have nothing to target. Doxycycline inhibits 30S ribosome protein synthesis — works intracellularly where Chlamydia lives inside epithelial cell inclusions. "
"Doxycycline (7 days) is now preferred over azithromycin (1g single dose) due to better cure rates for rectal chlamydia and reduced resistance selection."
))
story.append(source("CDC STI Treatment Guidelines 2021"))
story.append(spacer(0.2))
story.append(scenario_header("Syphilis"))
story.append(body("<b>Bacteria:</b> Treponema pallidum — spirochete; cannot be cultured."))
story.append(Paragraph("<b>Benzathine Penicillin G 2.4 million units IM single dose (primary/secondary syphilis)</b>", h3_style))
story.append(rationale(
"T. pallidum has maintained complete susceptibility to penicillin for 80+ years — no penicillin resistance has ever been documented. "
"Benzathine penicillin provides sustained, slow-release penicillin levels over 2-4 weeks from a single injection — ideal because T. pallidum divides slowly (30+ hour doubling time) and requires prolonged antibiotic exposure. "
"Neurosyphilis: IV penicillin G aqueous is needed (benzathine does not achieve adequate CSF levels)."
))
story.append(source("CDC STI Guidelines 2021; Harrison's 22E"))
story.append(spacer(0.2))
story.append(scenario_header("Tuberculosis (TB)"))
story.append(body("<b>Bacteria:</b> Mycobacterium tuberculosis — acid-fast bacillus; slow growing; thick waxy cell wall (mycolic acids) makes it resistant to most standard antibiotics."))
story.append(Paragraph("<b>RIPE Therapy: Rifampicin + Isoniazid + Pyrazinamide + Ethambutol x 2 months, then Rifampicin + Isoniazid x 4 months</b>", h3_style))
story.append(rationale(
"MTB's thick waxy mycolic acid cell wall is impenetrable to most beta-lactams. The RIPE combination works through different mechanisms: "
"Rifampicin inhibits RNA polymerase (unique bacterial beta subunit); "
"Isoniazid inhibits mycolic acid synthesis (InhA enzyme); "
"Pyrazinamide disrupts membrane potential (active in acidic pH of macrophage lysosomes); "
"Ethambutol inhibits arabinosyl transferase (arabinogalactan synthesis in cell wall). "
"Four drugs are used simultaneously to prevent resistance emergence — any single mutation giving resistance to one drug is overwhelmed by the other three drugs."
))
story.append(source("Harrison's 22E — Rifamycins and Antituberculosis drugs sections"))
story.append(spacer(2))
story.append(HRFlowable(width="100%", thickness=1, color=colors.HexColor("#1a237e")))
story.append(spacer(0.3))
story.append(Paragraph(
"This reference guide is based on: Harrison's Principles of Internal Medicine 22E (2025, McGraw Hill) · Washington Manual of Medical Therapeutics · Tintinalli's Emergency Medicine Comprehensive Study · Katzung's Basic & Clinical Pharmacology 16E · Rosen's Emergency Medicine · Campbell Walsh Wein Urology · Textbook of Family Medicine 9E · Medical Microbiology 9E · IDSA 2025 Complicated UTI Guidelines · EAU Urological Infections Guidelines 2025 · CDC STI Treatment Guidelines 2021 · ESC Endocarditis Guidelines 2023.",
source_style))
story.append(Paragraph(
"DISCLAIMER: This guide is for educational purposes. Always apply clinical judgment, consult local antibiograms, and follow your institution's protocols. Drug doses and guideline recommendations may change — verify with current references before prescribing.",
warning_style))
doc.build(story)
print(f"PDF created: {OUTPUT}")