Generate a pdf in a colored style for me of GIT Pharmacology all topics covered for exam revision...
mkdir -p /tmp/workspace/git-pharmacology && ls /tmp/workspace/
~/git-pharmacology/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table,
TableStyle, HRFlowable, PageBreak, KeepTogether)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame
from reportlab.lib.colors import HexColor
# ─── Color Palette ───────────────────────────────────────────────────────────
NAVY = HexColor('#1A237E')
TEAL = HexColor('#00695C')
PURPLE = HexColor('#6A1B9A')
ORANGE = HexColor('#E65100')
RED = HexColor('#B71C1C')
GREEN = HexColor('#1B5E20')
BLUE = HexColor('#0D47A1')
AMBER = HexColor('#FF6F00')
CYAN_DARK = HexColor('#006064')
PINK = HexColor('#880E4F')
BG_NAVY = HexColor('#E8EAF6')
BG_TEAL = HexColor('#E0F2F1')
BG_PURPLE = HexColor('#F3E5F5')
BG_ORANGE = HexColor('#FFF3E0')
BG_RED = HexColor('#FFEBEE')
BG_GREEN = HexColor('#E8F5E9')
BG_AMBER = HexColor('#FFFDE7')
BG_CYAN = HexColor('#E0F7FA')
BG_PINK = HexColor('#FCE4EC')
BG_BLUE = HexColor('#E3F2FD')
WHITE = colors.white
BLACK = colors.black
LIGHT_GRAY = HexColor('#F5F5F5')
MID_GRAY = HexColor('#BDBDBD')
# ─── Document Setup ──────────────────────────────────────────────────────────
OUTPUT = '/tmp/workspace/git-pharmacology/GIT_Pharmacology_Revision.pdf'
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
rightMargin=1.5*cm, leftMargin=1.5*cm,
topMargin=2*cm, bottomMargin=2*cm,
title='GIT Pharmacology – Exam Revision',
author='Orris Medical'
)
W, H = A4
# ─── Styles ──────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def make_style(name, parent='Normal', **kwargs):
s = ParagraphStyle(name, parent=styles[parent])
for k, v in kwargs.items():
setattr(s, k, v)
return s
# Title / cover
title_style = make_style('TitlePage', fontSize=30, textColor=WHITE,
alignment=TA_CENTER, fontName='Helvetica-Bold', leading=36)
subtitle_style = make_style('SubTitle', fontSize=14, textColor=WHITE,
alignment=TA_CENTER, fontName='Helvetica', leading=20)
# Chapter heading (big colored bar)
ch_style = make_style('ChapterHead', fontSize=16, textColor=WHITE,
fontName='Helvetica-Bold', leading=22, alignment=TA_LEFT,
leftIndent=8)
# Section heading
sec_style = make_style('SecHead', fontSize=12, textColor=WHITE,
fontName='Helvetica-Bold', leading=16, alignment=TA_LEFT,
leftIndent=6)
# Sub-section
sub_style = make_style('SubHead', fontSize=10.5, textColor=NAVY,
fontName='Helvetica-Bold', leading=14, spaceBefore=6)
# Body
body_style = make_style('Body', fontSize=9.5, textColor=BLACK,
fontName='Helvetica', leading=14, alignment=TA_JUSTIFY,
spaceBefore=3)
# Bullet
bullet_style = make_style('Bullet', fontSize=9.5, textColor=BLACK,
fontName='Helvetica', leading=13,
leftIndent=14, bulletIndent=4, spaceBefore=2)
# Drug name inline highlight
drug_style = make_style('Drug', fontSize=9.5, textColor=PURPLE,
fontName='Helvetica-Bold', leading=13)
# Warning / note box
note_style = make_style('Note', fontSize=9, textColor=RED,
fontName='Helvetica-Oblique', leading=13, leftIndent=6)
# Table header
th_style = make_style('TH', fontSize=9, textColor=WHITE,
fontName='Helvetica-Bold', leading=12, alignment=TA_CENTER)
td_style = make_style('TD', fontSize=8.5, textColor=BLACK,
fontName='Helvetica', leading=12, alignment=TA_CENTER)
td_left = make_style('TDL', fontSize=8.5, textColor=BLACK,
fontName='Helvetica', leading=12, alignment=TA_LEFT)
# ─── Helper builders ─────────────────────────────────────────────────────────
def chapter_header(text, color=NAVY, bg=None):
"""Returns a colored chapter-title block."""
if bg is None:
bg = color
data = [[Paragraph(text, ch_style)]]
t = Table(data, colWidths=[doc.width])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), bg),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
('TOPPADDING', (0,0), (-1,-1), 10),
('LEFTPADDING', (0,0), (-1,-1), 12),
('RIGHTPADDING', (0,0), (-1,-1), 12),
('ROUNDEDCORNERS', [6,6,6,6]),
]))
return t
def section_header(text, color=TEAL):
data = [[Paragraph(text, sec_style)]]
t = Table(data, colWidths=[doc.width])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), color),
('BOTTOMPADDING', (0,0), (-1,-1), 6),
('TOPPADDING', (0,0), (-1,-1), 6),
('LEFTPADDING', (0,0), (-1,-1), 10),
]))
return t
def colored_box(content_paragraphs, bg_color=BG_TEAL, border_color=TEAL):
"""Wrap paragraphs in a colored border box."""
rows = [[p] for p in content_paragraphs]
t = Table(rows, colWidths=[doc.width - 4])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), bg_color),
('BOX', (0,0), (-1,-1), 1.2, border_color),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 8),
('RIGHTPADDING', (0,0), (-1,-1), 8),
]))
return t
def drug_table(headers, rows, header_color=NAVY):
"""Build a nicely styled drug comparison table."""
th_row = [Paragraph(h, th_style) for h in headers]
body_rows = []
for i, r in enumerate(rows):
bg = LIGHT_GRAY if i % 2 == 0 else WHITE
body_rows.append([Paragraph(str(c), td_left) for c in r])
all_rows = [th_row] + body_rows
col_w = doc.width / len(headers)
col_widths = [col_w] * len(headers)
t = Table(all_rows, colWidths=col_widths, repeatRows=1)
style = [
('BACKGROUND', (0,0), (-1,0), header_color),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,-1), 8.5),
('ROWBACKGROUNDS', (0,1), (-1,-1), [LIGHT_GRAY, WHITE]),
('GRID', (0,0), (-1,-1), 0.5, MID_GRAY),
('VALIGN', (0,0), (-1,-1), 'TOP'),
('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(TableStyle(style))
return t
def bullet(text, color=TEAL):
return Paragraph(f'<font color="#{color.hexval()[2:]}">►</font> {text}', bullet_style)
def sp(n=1):
return Spacer(1, n * 4 * mm)
def hr(color=MID_GRAY):
return HRFlowable(width='100%', thickness=0.5, color=color, spaceAfter=3, spaceBefore=3)
# ─── Content ─────────────────────────────────────────────────────────────────
story = []
# ══════════════════════════════════════════════════════════════════
# COVER PAGE
# ══════════════════════════════════════════════════════════════════
cover_data = [[
Paragraph('GIT PHARMACOLOGY', title_style),
Paragraph('Complete Exam Revision Guide', subtitle_style),
Paragraph('Based on Goodman & Gilman\'s Pharmacological Basis of Therapeutics', subtitle_style),
Paragraph('Chapters 53 • 54 • 55', subtitle_style),
]]
cover_table = Table([[Paragraph('GIT PHARMACOLOGY', title_style)],
[Paragraph('Complete Exam Revision Guide', subtitle_style)],
[Paragraph("Based on Goodman & Gilman's Pharmacological Basis of Therapeutics", subtitle_style)],
[Paragraph('Chapters 53 \u2022 54 \u2022 55', subtitle_style)],
[sp(3)],
[Paragraph('\u2022 Acid-Peptic Disease \u2022 GERD \u2022 H. pylori \u2022 Motility Drugs', subtitle_style)],
[Paragraph('\u2022 Antiemetics \u2022 Laxatives \u2022 Antidiarrheals \u2022 IBD Therapy', subtitle_style)],
],
colWidths=[doc.width])
cover_table.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), NAVY),
('TOPPADDING', (0,0), (-1,-1), 8),
('BOTTOMPADDING', (0,0), (-1,-1), 8),
('LEFTPADDING', (0,0), (-1,-1), 20),
('RIGHTPADDING', (0,0), (-1,-1), 20),
('ROUNDEDCORNERS', [10,10,10,10]),
]))
story.append(sp(4))
story.append(cover_table)
story.append(sp(2))
# TOC preview
toc_items = [
('1', 'Physiology of Gastric Secretion', NAVY),
('2', 'Proton Pump Inhibitors (PPIs)', TEAL),
('3', 'H2-Receptor Antagonists', PURPLE),
('4', 'Potassium-Competitive Acid Blockers (P-CABs)', ORANGE),
('5', 'Agents Enhancing Mucosal Defense', RED),
('6', 'Antacids', GREEN),
('7', 'Therapeutic Strategies (GERD, PUD, H. pylori, ZES)', BLUE),
('8', 'GI Motility & Prokinetics', AMBER),
('9', 'Antiemetics', CYAN_DARK),
('10', 'Laxatives & Cathartics', PINK),
('11', 'Antidiarrheals', TEAL),
('12', 'IBD Pharmacotherapy', NAVY),
('13', 'Quick Reference Tables', PURPLE),
]
toc_rows = [[Paragraph(f'<font color="#FFFFFF"><b>{n}</b></font>', td_style),
Paragraph(f'<font color="{c.hexval()}">{t}</font>', td_left)]
for n, t, c in toc_items]
toc_t = Table([[Paragraph('TABLE OF CONTENTS', th_style)]] +
[[Paragraph('', td_style), Paragraph('', td_left)]] +
toc_rows,
colWidths=[1.2*cm, doc.width - 1.2*cm])
toc_t.setStyle(TableStyle([
('BACKGROUND', (0,0), (1,0), NAVY),
('SPAN', (0,0), (1,0)),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 6),
('FONTSIZE', (0,2), (-1,-1), 9.5),
('ROWBACKGROUNDS', (0,2), (-1,-1), [BG_NAVY, WHITE]),
('GRID', (0,0), (-1,-1), 0.4, MID_GRAY),
]))
story.append(toc_t)
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 1 – PHYSIOLOGY OF GASTRIC SECRETION
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('1. PHYSIOLOGY OF GASTRIC SECRETION', NAVY))
story.append(sp())
story.append(section_header('1.1 Parietal Cell & Proton Pump', TEAL))
story.append(sp(0.5))
story.append(Paragraph(
'The parietal cell (oxyntic cell) is the acid-secreting cell located in the body and fundus of the stomach. '
'It contains <b>H⁺/K⁺-ATPase</b> (proton pump) on its apical membrane, which exchanges H⁺ for K⁺, '
'generating the largest ion gradient in vertebrates (intracellular pH ~7.3 vs intracanalicular pH ~0.8). '
'This pump is the final common pathway for gastric acid secretion and the key target of PPIs.',
body_style))
story.append(sp())
story.append(section_header('1.2 Stimuli for Acid Secretion', PURPLE))
story.append(sp(0.5))
stim_data = [
['Stimulus', 'Mediator', 'Receptor on Parietal Cell', 'Signaling Pathway'],
['Neural (vagus)', 'Acetylcholine (ACh)', 'M3 muscarinic', 'G_q → PLC → IP₃ → Ca²⁺↑'],
['Endocrine', 'Gastrin (from G cells)', 'CCK2 / CCKB', 'G_q → PLC → IP₃ → Ca²⁺↑'],
['Paracrine', 'Histamine (from ECL cells)', 'H2', 'G_s → adenylyl cyclase → cAMP↑ → PKA'],
['All three', 'Converge on proton pump', 'H⁺/K⁺-ATPase activation', '→ HCl secretion'],
]
story.append(drug_table(stim_data[0], stim_data[1:], NAVY))
story.append(sp())
story.append(section_header('1.3 Mucosal Defense Mechanisms', GREEN))
story.append(sp(0.5))
defense_items = [
'Mucus layer: secreted by surface epithelial cells; physical barrier',
'Bicarbonate secretion: creates alkaline microenvironment at epithelial surface',
'Mucosal blood flow: delivers O₂ and nutrients; removes acid that back-diffuses',
'Prostaglandins (PGE₂, PGI₂): stimulate mucus & HCO₃⁻, increase blood flow, inhibit acid via EP3',
'Nitric oxide (NO): vasodilation; supports mucosal integrity',
'Epithelial restitution: rapid migration of surface cells to repair minor injury',
'Tight junctions: prevent H⁺ back-diffusion',
]
for item in defense_items:
story.append(bullet(item, TEAL))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Key Point:</b> NSAIDs inhibit COX → ↓PG synthesis → impaired mucosal defense → peptic ulcers. '
'Selective COX-2 inhibitors reduce GI risk but still carry cardiovascular risk.', note_style)
], BG_RED, RED))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 2 – PROTON PUMP INHIBITORS
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('2. PROTON PUMP INHIBITORS (PPIs)', TEAL))
story.append(sp())
story.append(section_header('2.1 Mechanism of Action', TEAL))
story.append(sp(0.5))
story.append(Paragraph(
'PPIs are <b>benzimidazole pro-drugs</b> that require acid activation. They diffuse into the secretory canaliculus '
'of the parietal cell where the acidic environment converts them to sulfenamide (active form). '
'The sulfenamide covalently and irreversibly binds cysteines on the luminal surface of H⁺/K⁺-ATPase, '
'blocking acid secretion. <b>Acid suppression lasts 24–48 h</b> (beyond drug half-life) because new pump '
'synthesis is required to restore secretion (t½ recovery ~18 h).',
body_style))
story.append(sp())
story.append(section_header('2.2 Individual PPIs – Pharmacokinetics', PURPLE))
story.append(sp(0.5))
ppi_data = [
['Drug', 'Dose (typical)', 'Bioavailability', 'Half-life', 'Metabolism', 'Special Notes'],
['Omeprazole', '20–40 mg OD', '~40-60%', '0.5–1 h', 'CYP2C19, CYP3A4', 'First PPI; S-isomer = esomeprazole'],
['Esomeprazole', '20–40 mg OD', '~64-90%', '1–1.5 h', 'CYP2C19 (less)', 'Longer acid suppression than omeprazole'],
['Lansoprazole', '15–30 mg OD', '~80-85%', '1.5 h', 'CYP2C19, CYP3A4', 'Available as ODT & IV'],
['Pantoprazole', '40 mg OD', '~77%', '1 h', 'CYP2C19, sulfotransferase', 'Fewer drug interactions; IV form available'],
['Rabeprazole', '20 mg OD', '~52%', '1–2 h', 'Non-enzymatic + CYP2C19', 'Less CYP2C19 dependent; fewer interactions'],
['Dexlansoprazole', '30–60 mg OD', '~NA', '1–2 h', 'CYP2C19, CYP3A4', 'Dual delayed-release; can take w/o food'],
]
story.append(drug_table(ppi_data[0], ppi_data[1:], TEAL))
story.append(sp())
story.append(section_header('2.3 Clinical Uses', BLUE))
story.append(sp(0.5))
ppi_uses = [
'<b>GERD</b>: Healing of erosive esophagitis (4–8 weeks); maintenance therapy',
'<b>Peptic Ulcer Disease</b>: Duodenal ulcer (4 wks); Gastric ulcer (8 wks)',
'<b>H. pylori eradication</b>: Component of triple/quadruple therapy',
'<b>NSAID-induced ulcer</b>: Prevention and healing (better than H2 blockers)',
'<b>Zollinger-Ellison Syndrome</b>: High-dose PPI (60–120 mg/day)',
'<b>Stress ulcer prophylaxis</b>: IV PPIs in ICU patients',
'<b>Functional dyspepsia</b>: Empirical 4–8 week trial',
'<b>Laryngopharyngeal reflux</b>: Off-label, evidence limited',
]
for u in ppi_uses:
story.append(bullet(u, TEAL))
story.append(sp())
story.append(section_header('2.4 Adverse Effects & Drug Interactions', RED))
story.append(sp(0.5))
ae_data = [
['Adverse Effect', 'Mechanism / Notes'],
['Headache, diarrhea, nausea, abdominal pain', 'Common; usually mild (~1-5%)'],
['Hypomagnesemia', 'Long-term use (>1 yr); can cause hypokalemia, hypocalcemia; monitor Mg²⁺'],
['Vitamin B12 deficiency', 'Impaired intrinsic factor–independent absorption; long-term'],
['Community-acquired pneumonia', 'Gastric acid suppression may allow bacterial overgrowth / aspiration'],
['C. difficile infection', 'Altered gut microbiome; acid normally bactericidal to C. difficile'],
['Osteoporosis / fractures', 'Impaired Ca²⁺ absorption; FDA warning for long-term use'],
['Rebound acid hypersecretion', 'On abrupt discontinuation; taper recommended'],
['Drug interaction: Clopidogrel', 'Omeprazole/esomeprazole inhibit CYP2C19 → ↓ clopidogrel activation; prefer pantoprazole'],
['Drug interaction: Methotrexate', 'PPIs reduce renal MTX excretion → toxicity'],
]
story.append(drug_table(ae_data[0], ae_data[1:], RED))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Exam Tip:</b> PPIs are pro-drugs activated in acid. They work best taken 30–60 min before a meal. '
'Irreversible binding means duration of action exceeds plasma half-life. CYP2C19 polymorphisms '
'affect response ("poor metabolizers" have higher drug levels and better acid suppression).', note_style)
], BG_AMBER, AMBER))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 3 – H2 RECEPTOR ANTAGONISTS
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('3. H2-RECEPTOR ANTAGONISTS (H2RAs)', PURPLE))
story.append(sp())
story.append(section_header('3.1 Mechanism of Action', PURPLE))
story.append(sp(0.5))
story.append(Paragraph(
'H2RAs are <b>competitive, reversible antagonists</b> of histamine H2 receptors on parietal cells. '
'Blockade of H2 receptors prevents histamine-stimulated cAMP production, reducing activation of H⁺/K⁺-ATPase. '
'They inhibit basal acid secretion (including nocturnal acid) more than meal-stimulated acid. '
'Tolerance ("tachyphylaxis") develops within days due to upregulation of H2 receptors.',
body_style))
story.append(sp())
story.append(section_header('3.2 Individual H2RAs', PURPLE))
story.append(sp(0.5))
h2_data = [
['Drug', 'Dose', 'Bioavailability', 'Half-life', 'Excretion', 'Notes'],
['Cimetidine', '400–800 mg BD', '~60-70%', '2 h', 'Renal (75%)', 'Potent CYP inhibitor; antiandrogenic effects; multiple drug interactions'],
['Ranitidine', '150 mg BD / 300 mg HS', '~50%', '2–3 h', 'Renal', 'Withdrawn (2020) – NDMA contamination'],
['Famotidine', '20–40 mg OD/BD', '~40-45%', '2.5–4 h', 'Renal', 'Most potent H2RA; no CYP2C19 interaction; DOC among H2RAs'],
['Nizatidine', '150–300 mg OD', '~90%', '1–2 h', 'Renal (>90%)', 'Highest oral bioavailability; minimal drug interactions'],
]
story.append(drug_table(h2_data[0], h2_data[1:], PURPLE))
story.append(sp())
story.append(section_header('3.3 Clinical Uses', BLUE))
for item in [
'Duodenal and gastric ulcers (healing; less effective than PPIs)',
'GERD: mild to moderate, non-erosive; nocturnal acid suppression',
'Zollinger-Ellison Syndrome (high doses needed)',
'Prevention of aspiration pneumonitis (pre-anesthesia)',
'OTC: heartburn, dyspepsia (low doses)',
]:
story.append(bullet(item, PURPLE))
story.append(sp())
story.append(section_header('3.4 Adverse Effects', RED))
story.append(sp(0.5))
ae_h2 = [
('Cimetidine – Antiandrogenic effects', 'Gynecomastia, impotence, decreased libido; inhibits androgen receptor'),
('Cimetidine – CNS effects', 'Confusion, agitation, depression (especially elderly/high dose)'),
('Cimetidine – Drug interactions', 'Inhibits CYP1A2, 2C9, 2D6, 3A4; ↑ warfarin, theophylline, phenytoin levels'),
('All H2RAs – Tolerance', '"Tachyphylaxis" within 3 days; H2 receptor upregulation'),
('Renal adjustment', 'All H2RAs require dose reduction in renal failure'),
]
for ef, desc in ae_h2:
story.append(Paragraph(f'<b><font color="#{RED.hexval()[2:]}">▸ {ef}:</font></b> {desc}', bullet_style))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Cimetidine Mnemonic – GAGS:</b> Gynecomastia, Antiandrogenic, Galactorrhea (↑prolactin), '
'Sex effects (impotence) + enzyme inhibition (CYP).', note_style)
], BG_PURPLE, PURPLE))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 4 – P-CABs
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('4. POTASSIUM-COMPETITIVE ACID BLOCKERS (P-CABs)', ORANGE))
story.append(sp())
story.append(Paragraph(
'P-CABs reversibly block the K⁺-binding site of H⁺/K⁺-ATPase in a potassium-competitive manner. '
'Unlike PPIs, they do NOT require acid activation (not prodrugs), act more rapidly, and provide '
'consistent acid suppression independent of CYP2C19 genotype.',
body_style))
story.append(sp())
pcab_data = [
['Drug', 'Approval Region', 'Indications', 'Dose', 'Key Advantage'],
['Vonoprazan', 'Japan, USA (2022)', 'Erosive esophagitis, H. pylori (+ amoxicillin ± clarithromycin)', '20 mg OD (10 mg maintenance)', 'Faster onset; H. pylori eradication non-inferior to PPI triple'],
['Tegoprazan', 'South Korea', 'Erosive esophagitis, NERD', '50 mg OD', 'Rapid onset; no food effect'],
['Revaprazan', 'India, South Korea', 'Gastric/duodenal ulcer, gastritis', '200 mg OD', 'Available in India'],
]
story.append(drug_table(pcab_data[0], pcab_data[1:], ORANGE))
story.append(sp())
story.append(colored_box([
Paragraph('<b>P-CABs vs PPIs:</b> P-CABs are more potent for nocturnal acid suppression. '
'Vonoprazan-based dual therapy (vonoprazan + amoxicillin) showed >80% H. pylori eradication. '
'Adverse effects: diarrhea, dyspepsia, headache.', note_style)
], BG_ORANGE, ORANGE))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 5 – MUCOSAL DEFENSE AGENTS
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('5. AGENTS ENHANCING MUCOSAL DEFENSE', RED))
story.append(sp())
story.append(section_header('5.1 Misoprostol', RED))
story.append(sp(0.5))
story.append(Paragraph(
'<b>Misoprostol</b> is a synthetic PGE₁ analogue. It binds EP3 receptors on parietal cells → ↑G_i → '
'↓cAMP → ↓acid secretion. Also stimulates mucus and bicarbonate secretion via EP2/EP4.', body_style))
story.append(sp(0.5))
miso_rows = [
('Indication', 'Prevention of NSAID-induced gastric/duodenal ulcers (FDA-approved); also used in obstetrics'),
('Dose', '200 µg QID (with food to reduce diarrhea)'),
('ADME', 'Rapidly absorbed; deesterified to active misoprostol acid; t½ 20–40 min; renal excretion'),
('Adverse Effects', 'Diarrhea (30%), abdominal cramps, nausea; uterine contractions → CONTRAINDICATED in pregnancy'),
('Contraindications', 'Pregnancy (FDA Category X – causes miscarriage/birth defects); IBD exacerbation'),
]
for k, v in miso_rows:
story.append(Paragraph(f'<b><font color="#{RED.hexval()[2:]}">• {k}:</font></b> {v}', bullet_style))
story.append(sp())
story.append(section_header('5.2 Sucralfate', RED))
story.append(sp(0.5))
story.append(Paragraph(
'<b>Sucralfate</b> = aluminum sucrose sulfate. In acidic environment (pH <4), it polymerizes into '
'a viscous gel that adheres to ulcer base (binds positively charged proteins in necrotic tissue), '
'forming a protective barrier for up to 6 hours. Also stimulates mucosal PG production.', body_style))
story.append(sp(0.5))
suc_rows = [
('Uses', 'Duodenal ulcer healing; stress ulcer prophylaxis; esophagitis'),
('Dose', '1 g QID on empty stomach (1 hour before meals)'),
('Adverse effects', 'Constipation (most common); binds drugs → must separate doses by 2 hours'),
('Drug interactions', 'Reduces absorption of fluoroquinolones, digoxin, phenytoin, warfarin, tetracyclines'),
('Caution', 'Aluminum accumulation in renal failure'),
]
for k, v in suc_rows:
story.append(Paragraph(f'<b><font color="#{RED.hexval()[2:]}">• {k}:</font></b> {v}', bullet_style))
story.append(sp())
story.append(section_header('5.3 Bismuth Compounds', RED))
story.append(sp(0.5))
story.append(Paragraph(
'<b>Bismuth subsalicylate (BSS) / Bismuth subcitrate:</b> Antimicrobial effect on H. pylori; '
'forms protective coat over ulcer; antisecretory and anti-inflammatory (salicylate component). '
'Used in quadruple therapy for H. pylori. '
'<b>Adverse:</b> Black stool/tongue (harmless), tinnitus (from salicylate). '
'<b>Caution:</b> Avoid in renal failure; aspirin-sensitive patients.', body_style))
story.append(sp())
story.append(section_header('5.4 Antacids', GREEN))
story.append(sp(0.5))
story.append(Paragraph(
'Antacids neutralize gastric acid by reacting with HCl to raise gastric pH above 4, '
'inactivating pepsin (inactive above pH 4). They provide rapid symptom relief but have short duration.', body_style))
story.append(sp(0.5))
antacid_data = [
['Antacid', 'Mechanism', 'Onset', 'Constipation / Diarrhea', 'Special Concerns'],
['Aluminum hydroxide Al(OH)₃', 'Neutralizes HCl; forms AlCl₃', 'Slow', 'Constipation +++', 'Phosphate binding → hypophosphatemia; encephalopathy in renal failure'],
['Magnesium hydroxide Mg(OH)₂', 'Neutralizes HCl; osmotic', 'Rapid', 'Diarrhea +++', 'Magnesium toxicity in renal failure (CNS depression, hypotension)'],
['Calcium carbonate CaCO₃', 'Rapidly neutralizes; CO₂ released', 'Rapid', 'Constipation +', 'Acid rebound (calcium stimulates gastrin); milk-alkali syndrome with high doses'],
['Sodium bicarbonate NaHCO₃', 'Fast neutralization; systemic absorption', 'Fastest', 'Neutral', 'Systemic alkalosis; CO₂ belching; avoid in hypertension / heart failure; not for peptic ulcers'],
['Magaldrate (Mg + Al)', 'Combines both', 'Moderate', 'Balanced', 'Fewer GI effects; releases antacid in acid medium'],
]
story.append(drug_table(antacid_data[0], antacid_data[1:], GREEN))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Antacid Clinical Tips:</b> (1) "Al constipates, Mg purges, Ca rebounds, Na alters" — '
'Maalox/Mylanta combine Al + Mg to balance constipation vs diarrhea. '
'(2) Antacids interfere with absorption of many drugs — take drugs 2 hours apart. '
'(3) Never use NaHCO₃ long-term.', note_style)
], BG_GREEN, GREEN))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 6 – THERAPEUTIC STRATEGIES
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('6. THERAPEUTIC STRATEGIES FOR ACID-PEPTIC DISORDERS', BLUE))
story.append(sp())
story.append(section_header('6.1 GERD Management', BLUE))
story.append(sp(0.5))
gerd_data = [
['Severity', 'Treatment'],
['Lifestyle modifications (all)', 'Elevate HOB 15–20 cm; avoid late meals, acidic foods, alcohol, tobacco, tight clothing; weight loss'],
['Mild / Non-erosive GERD', 'Step-up: antacids PRN → H2RA OD → PPI OD'],
['Moderate-Severe / Erosive', 'PPI BID × 4–8 weeks; maintenance PPI OD long-term'],
['Refractory GERD', 'PPI BID + H2RA at bedtime; Nissen fundoplication'],
['Barrett\'s esophagus', 'Long-term PPI; endoscopic surveillance / ablation'],
]
story.append(drug_table(gerd_data[0], gerd_data[1:], BLUE))
story.append(sp())
story.append(section_header('6.2 Peptic Ulcer Disease', BLUE))
story.append(sp(0.5))
pud_data = [
['Ulcer Type', 'Duration', 'Drug of Choice', 'Notes'],
['Duodenal ulcer (not H. pylori, not NSAID)', 'PPI × 4 weeks', 'Omeprazole / pantoprazole', 'Healing rate ~95%'],
['Gastric ulcer', 'PPI × 8 weeks', 'PPI OD (+ H. pylori tx if +ve)', 'Endoscopy at 8–12 wks to confirm healing (rule out malignancy)'],
['H. pylori positive ulcer', 'Eradication + PPI × 4–8 wks', 'Triple/Quad therapy', 'Test-of-cure 4 wks after therapy completion'],
['NSAID-induced ulcer', '4–8 weeks', 'PPI (superior to H2RA or misoprostol)', 'Stop NSAID; switch to COX-2 inhibitor + PPI if must continue'],
['Stress ulcer prophylaxis', 'ICU admission', 'IV PPI or IV H2RA', 'Indicated: mechanical ventilation, coagulopathy'],
['ZES (Zollinger-Ellison)', 'Long-term', 'High-dose PPI (60–120 mg/day)', 'Titrate to maintain basal acid output <10 mEq/h'],
]
story.append(drug_table(pud_data[0], pud_data[1:], BLUE))
story.append(sp())
story.append(section_header('6.3 H. pylori Eradication Regimens', AMBER))
story.append(sp(0.5))
hp_data = [
['Regimen', 'Drugs', 'Duration', 'Eradication Rate', 'Notes'],
['Standard Triple Therapy', 'PPI + Clarithromycin + Amoxicillin (or metronidazole)', '14 days (preferred)', '70–85%', 'Declining due to clarithromycin resistance; avoid if local resistance >15%'],
['Bismuth Quadruple', 'PPI + Bismuth + Metronidazole + Tetracycline (PBMT)', '10–14 days', '85–95%', 'First-line in high clarithromycin resistance areas; salvage therapy'],
['Concomitant (non-bismuth quad)', 'PPI + Clarithromycin + Amoxicillin + Metronidazole', '10–14 days', '~90%', 'All 4 drugs together'],
['Sequential', 'PPI + Amoxicillin × 5 days → PPI + Clarithro + Tinidazole × 5 days', '10 days total', '~85-90%', 'Prevents clarithromycin resistance selection'],
['Vonoprazan Dual', 'Vonoprazan + Amoxicillin (high dose)', '14 days', '>90%', 'FDA-approved 2022; effective even with clarithromycin resistance'],
['Levofloxacin Triple', 'PPI + Levofloxacin + Amoxicillin', '10–14 days', '~80-90%', 'Second-line / salvage therapy'],
['Rifabutin Triple', 'PPI + Rifabutin + Amoxicillin', '10 days', '~75-90%', 'Third-line; myelotoxicity risk'],
]
story.append(drug_table(hp_data[0], hp_data[1:], AMBER))
story.append(sp())
story.append(colored_box([
Paragraph('<b>H. pylori Tx Notes:</b> Always do test-of-cure (urea breath test or stool antigen) ≥4 weeks after therapy + ≥2 weeks off PPI. '
'Bismuth quadruple = preferred first-line when clarithromycin resistance >15%. '
'Compliance is critical – short-course = treatment failure = resistance.', note_style)
], BG_AMBER, AMBER))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 7 – GI MOTILITY & PROKINETICS
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('7. GI MOTILITY & PROKINETIC AGENTS', AMBER))
story.append(sp())
story.append(section_header('7.1 Overview of GI Motility Regulation', AMBER))
story.append(sp(0.5))
story.append(Paragraph(
'GI motility is controlled by the <b>enteric nervous system (ENS)</b> — a "brain in the gut" with '
'~500 million neurons. Key neurotransmitters: acetylcholine (↑motility), substance P, 5-HT (↑motility), '
'nitric oxide (↓motility/relaxation), vasoactive intestinal peptide (VIP). '
'Prokinetics act primarily through <b>5-HT4 agonism, D2 antagonism, or motilin agonism</b>.', body_style))
story.append(sp())
story.append(section_header('7.2 Prokinetic Agents', AMBER))
story.append(sp(0.5))
prok_data = [
['Drug', 'Mechanism', 'Uses', 'Key Adverse Effects'],
['Metoclopramide', 'D2 antagonist + 5-HT4 agonist; also 5-HT3 antagonist at high doses', 'Gastroparesis, GERD, N&V (chemo, post-op, diabetic)', 'Extrapyramidal (tardive dyskinesia with long-term use); ↑prolactin → galactorrhea; QTc prolongation; CNS (drowsiness)'],
['Domperidone', 'Peripheral D2 antagonist (does not cross BBB)', 'Gastroparesis, N&V, functional dyspepsia', 'QTc prolongation (FDA restricted); ↑prolactin; minimal CNS effects (does not cross BBB)'],
['Prucalopride', 'Selective 5-HT4 agonist (high affinity)', 'Chronic constipation (especially women), gastroparesis', 'Headache, diarrhea, abdominal pain; no cardiac risk (unlike cisapride)'],
['Cisapride', '5-HT4 agonist + 5-HT3 antagonist', 'WITHDRAWN from market', 'Fatal cardiac arrhythmias – QT prolongation → Torsades de Pointes (removed from most markets)'],
['Erythromycin', 'Motilin receptor agonist', 'Gastroparesis, acute colonic pseudo-obstruction (Ogilvie)', 'GI cramping, nausea; tachyphylaxis (down-regulation); avoid long-term'],
['Neostigmine', 'AChE inhibitor → ↑ACh', 'Acute colonic pseudo-obstruction (Ogilvie syndrome)', 'Bradycardia, bronchospasm, increased secretions; must monitor heart rate'],
['Linaclotide', 'GC-C receptor agonist → ↑cGMP → ↑Cl⁻/water secretion', 'IBS-C, chronic constipation', 'Diarrhea (dose-limiting); contraindicated in pediatric patients (<6 yrs)'],
['Lubiprostone', 'ClC-2 chloride channel activator', 'Chronic constipation, IBS-C, opioid-induced constipation', 'Nausea (most common), diarrhea; teratogenic – avoid in pregnancy'],
]
story.append(drug_table(prok_data[0], prok_data[1:], AMBER))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Exam Alert – Cisapride vs Prucalopride:</b> Cisapride was withdrawn due to QT prolongation '
'(non-selective 5-HT4 + hERG channel block). Prucalopride is highly selective for 5-HT4 with minimal '
'cardiac risk. Metoclopramide: max 12 weeks continuous use (FDA black box – tardive dyskinesia).', note_style)
], BG_AMBER, AMBER))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 8 – ANTIEMETICS
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('8. ANTIEMETICS', CYAN_DARK))
story.append(sp())
story.append(section_header('8.1 Vomiting Pathway & Receptor Targets', CYAN_DARK))
story.append(sp(0.5))
story.append(Paragraph(
'Vomiting is coordinated by the <b>vomiting center (VC)</b> in the lateral reticular formation of the medulla. '
'The <b>chemoreceptor trigger zone (CTZ)</b> lies in the area postrema (outside BBB), rich in D2 and 5-HT3 receptors. '
'Other inputs: GI tract (vagal afferents via 5-HT3 on enterochromaffin cells), vestibular apparatus (H1, M1), '
'cortex/limbic (anticipatory nausea). Receptor targets: D2 (CTZ), 5-HT3 (CTZ + GI vagal), H1 (vestibular), '
'M1 (vestibular), NK1 (VC, cortex), cannabinoid CB1.', body_style))
story.append(sp())
story.append(section_header('8.2 Classification of Antiemetics', CYAN_DARK))
story.append(sp(0.5))
ae_class_data = [
['Class', 'Drug(s)', 'Mechanism', 'Main Use', 'Key Side Effects'],
['5-HT3 Antagonists\n("Setrons")', 'Ondansetron, Granisetron, Palonosetron, Dolasetron', 'Block 5-HT3 on vagal afferents and CTZ', 'CINV (acute & delayed), post-op N&V, radiation', 'Headache, constipation, QTc prolongation; Palonosetron has longer t½ (~40h) – better for delayed CINV'],
['D2 Antagonists\n(Phenothiazines)', 'Prochlorperazine, Chlorpromazine, Promethazine', 'Block D2 in CTZ; also H1, M1 block', 'General N&V, CINV, motion sickness', 'EPS, sedation, anticholinergic effects, hypotension'],
['D2 Antagonists\n(Butyrophenones)', 'Droperidol, Haloperidol', 'Block D2 in CTZ', 'Post-op N&V; refractory CINV', 'QTc prolongation (droperidol – black box); EPS'],
['Substituted\nBenzamides', 'Metoclopramide, Domperidone', 'D2 + 5-HT4 + 5-HT3 (high dose)', 'CINV, gastroparesis, post-op', 'Tardive dyskinesia (metoclopramide); ↑prolactin'],
['NK1 Antagonists', 'Aprepitant, Fosaprepitant, Netupitant, Rolapitant', 'Block substance P/NK1 receptors in VC & brainstem', 'Delayed CINV (highly emetogenic chemo)', 'Hiccups, fatigue, ↑CYP3A4 (aprepitant); Fosaprepitant = IV prodrug'],
['Antihistamines\n(H1)', 'Promethazine, Diphenhydramine, Cyclizine, Meclizine', 'Block H1 in vestibular nucleus', 'Motion sickness, vertigo, morning sickness', 'Sedation, anticholinergic (dry mouth, urinary retention), avoid in pregnancy (promethazine)'],
['Anticholinergics', 'Scopolamine (hyoscine) transdermal patch', 'Block M1 in vestibular nucleus', 'Motion sickness', 'Dry mouth, blurred vision, urinary retention; patch lasts 72h'],
['Corticosteroids', 'Dexamethasone', 'Anti-inflammatory; enhances 5-HT3 antagonist effect; mechanism unclear', 'CINV (augment 5-HT3 + NK1 therapy)', 'Hyperglycemia, insomnia, GI upset (short-course usually well tolerated)'],
['Cannabinoids', 'Dronabinol, Nabilone', 'CB1 agonism (CNS)', 'CINV refractory to other agents', 'Euphoria, dysphoria, dizziness, ↑appetite; psychoactive'],
['Ginger', 'Zingiber officinale', 'Possible 5-HT3 antagonism + anti-inflammatory', 'Morning sickness (pregnancy safe)', 'Safe in pregnancy; limited evidence for CINV'],
]
story.append(drug_table(ae_class_data[0], ae_class_data[1:], CYAN_DARK))
story.append(sp())
story.append(section_header('8.3 CINV Prophylaxis Guidelines', CYAN_DARK))
story.append(sp(0.5))
cinv_data = [
['Emetogenic Risk', 'Regimen'],
['High (cisplatin, AC)', 'NK1 antagonist + 5-HT3 antagonist + Dexamethasone ± Olanzapine'],
['Moderate (carboplatin, oxaliplatin)', '5-HT3 antagonist + Dexamethasone ± NK1 antagonist'],
['Low', 'Dexamethasone or metoclopramide or prochlorperazine'],
['Minimal', 'No prophylaxis routinely'],
]
story.append(drug_table(cinv_data[0], cinv_data[1:], CYAN_DARK))
story.append(sp())
story.append(colored_box([
Paragraph('<b>5-HT3 Setrons Quick Compare:</b> Ondansetron (short t½, OD/BD); Palonosetron (t½ ~40h, '
'best for delayed CINV; also binds receptor allosterically); Granisetron (patch available for extended '
'release). Avoid with QTc-prolonging drugs (domperidone + ondansetron = dangerous combo).', note_style)
], BG_CYAN, CYAN_DARK))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 9 – LAXATIVES
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('9. LAXATIVES & CATHARTICS', PINK))
story.append(sp())
story.append(Paragraph(
'Constipation is defined as <3 spontaneous bowel movements/week with straining, hard stools, or sensation '
'of incomplete evacuation. Laxatives are classified by mechanism:', body_style))
story.append(sp(0.5))
lax_data = [
['Class', 'Examples', 'Mechanism', 'Onset', 'Notes'],
['Bulk-Forming', 'Psyllium, Methylcellulose, Ispaghula', 'Absorb water → increase stool bulk → stimulate peristalsis', '12–72 h', 'Safest; must take with plenty of water; risk of obstruction if inadequate fluid'],
['Osmotic – Saline', 'Magnesium hydroxide (Milk of Magnesia), Mg sulfate, Na phosphate', 'Non-absorbable ions retain water in lumen → distension → peristalsis', '0.5–3 h', 'Rapid onset; Mg toxicity in renal failure; Na phosphate risk of hyperphosphatemia'],
['Osmotic – PEG', 'PEG 3350 (Miralax, GoLYTELY)', 'Polyethylene glycol retains water osmotically; not absorbed', '1–2 days', 'Preferred for chronic constipation; bowel prep (high dose); safe in pregnancy'],
['Osmotic – Lactulose', 'Lactulose, Sorbitol', 'Non-absorbable disaccharide; colonic bacteria produce organic acids → ↓pH → osmosis', '24–48 h', 'Also used in hepatic encephalopathy (↓ammonia absorption); GI flatulence'],
['Stimulant / Irritant', 'Senna, Bisacodyl, Castor oil', 'Stimulate ENS; ↑intestinal motility; ↑water/electrolyte secretion', '6–12 h (oral) / 15–60 min (rectal)', 'Effective but risk of dependence, electrolyte imbalance, melanosis coli (senna); avoid long-term'],
['Emollient / Stool Softener', 'Docusate sodium (DOSS), Docusate calcium', 'Surfactant action; allows water and fat to penetrate stool', '12–72 h', 'For patients who must avoid straining (post-MI, post-surgery); minimal efficacy alone'],
['Lubricant', 'Liquid paraffin (mineral oil)', 'Coats stool; reduces friction; ↓water absorption in colon', '6–8 h', 'Risk of lipid pneumonia if aspirated; impairs fat-soluble vitamin absorption (A, D, E, K); avoid long-term'],
['Secretagogues', 'Linaclotide, Lubiprostone, Plecanatide', 'Activate GC-C or Cl⁻ channels → ↑Cl⁻/water secretion', '24–48 h', 'IBS-C and CIC; linaclotide: contraindicated <6 yrs; lubiprostone: nausea common'],
]
story.append(drug_table(lax_data[0], lax_data[1:], PINK))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Melanosis Coli:</b> Pigmentation of colonic mucosa caused by long-term anthraquinone laxatives '
'(senna, cascara). Appears black/brown on colonoscopy. Reversible. Indicates anthraquinone use '
'but not harmful per se.', note_style)
], BG_PINK, PINK))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 10 – ANTIDIARRHEALS
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('10. ANTIDIARRHEAL AGENTS', TEAL))
story.append(sp())
story.append(Paragraph(
'Diarrhea = >3 loose stools/day. Causes: secretory, osmotic, inflammatory, motility-related. '
'<b>Caution:</b> antidiarrheals are CONTRAINDICATED in infectious diarrhea with bloody stool (may worsen by '
'prolonging pathogen contact time) and in severe colitis.', body_style))
story.append(sp(0.5))
antid_data = [
['Drug', 'Mechanism', 'Uses', 'Adverse Effects / Notes'],
['Loperamide', 'μ-opioid receptor agonist in gut wall (does not cross BBB at therapeutic dose) → ↓peristalsis, ↑sphincter tone, ↓secretion', 'Acute non-specific diarrhea, IBS-D, chronic diarrhea, ileostomy output ↓', 'Abdominal cramping, constipation; QTc prolongation at high/supratherapeutic doses; can cause toxic megacolon in severe colitis'],
['Diphenoxylate + Atropine', 'Opioid receptor agonist (μ); atropine added to discourage abuse (anticholinergic effects at high doses)', 'Acute diarrhea; requires prescription', 'Paralytic ileus, sedation; atropine effects (dry mouth, urinary retention, tachycardia); avoid in infections/children'],
['Bismuth Subsalicylate', 'Antimicrobial + antisecretory + anti-inflammatory', 'Traveler\'s diarrhea (tx & prevention), H. pylori adjunct', 'Black stool/tongue (harmless); tinnitus (salicylate); avoid in aspirin-sensitive, Reye\'s risk in children'],
['Codeine / Morphine', 'Opioid receptor agonist; ↓GI motility', 'Severe refractory diarrhea (e.g. post-surgical, AIDS)', 'CNS depression, addiction potential; constipation when used as antidiarrheal is desired effect'],
['Racecadotril (Acetorphan)', 'Enkephalinase inhibitor → ↑enkephalins → ↓cAMP → ↓secretion (anti-secretory, NOT antimotility)', 'Secretory diarrhea (especially children); acute diarrhea', 'Well tolerated; no motility effects; safe in infants'],
['Octreotide', 'Somatostatin analogue → ↓GI secretion, ↓motility, ↓splanchnic blood flow', 'VIPoma, carcinoid syndrome diarrhea, short bowel syndrome, Zollinger-Ellison', 'Gallstone formation (long-term), steatorrhea, bradycardia, hyperglycemia'],
['Cholestyramine', 'Bile acid sequestrant', 'Bile acid malabsorption diarrhea (post-cholecystectomy, Crohn\'s)', 'Constipation, bloating; binds many drugs → separate by 4-6 hours'],
['Oral Rehydration Salts (ORS)', 'Na-glucose co-transport maintains water absorption even in secretory diarrhea', 'First-line all diarrheas, especially pediatric; cholera', 'None; life-saving in cholera; WHO ORS formula'],
['Rifaximin', 'Non-absorbable rifamycin antibiotic; ↓gut bacteria', 'Traveler\'s diarrhea, IBS-D (alternating), HE prevention', 'Generally safe; rare GI symptoms; minimal systemic absorption'],
]
story.append(drug_table(antid_data[0], antid_data[1:], TEAL))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Loperamide:</b> OTC for non-infectious diarrhea. Does NOT cross BBB at standard doses. '
'Contraindicated in: infectious bloody diarrhea (E. coli O157, Salmonella, Shigella – '
'may precipitate hemolytic-uremic syndrome or toxic megacolon), pediatric infectious diarrhea. '
'Preferred first-line for traveler\'s diarrhea.', note_style)
], BG_TEAL, TEAL))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 11 – IBD PHARMACOTHERAPY
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('11. INFLAMMATORY BOWEL DISEASE (IBD) PHARMACOTHERAPY', NAVY))
story.append(sp())
story.append(section_header('11.1 Overview', NAVY))
story.append(sp(0.5))
story.append(Paragraph(
'IBD = chronic relapsing-remitting inflammatory disease of the GI tract. '
'<b>Crohn\'s Disease (CD):</b> transmural; any segment; skip lesions; granulomas; perianal disease. '
'<b>Ulcerative Colitis (UC):</b> mucosal/submucosal; continuous; rectum upward; no granulomas. '
'Goals: <b>induce remission → maintain remission → achieve mucosal healing → prevent complications.</b>',
body_style))
story.append(sp())
story.append(section_header('11.2 5-Aminosalicylates (5-ASA / Mesalamine)', TEAL))
story.append(sp(0.5))
asa_data = [
['Drug', 'Formulation', 'Target Site', 'Indication'],
['Sulfasalazine', '5-ASA + sulfapyridine (carrier)', 'Colon (colonic bacteria cleave the prodrug)', 'Mild-moderate UC; mild Crohn\'s colitis; RA'],
['Mesalamine (oral – Asacol)', 'pH-sensitive coating (releases at pH >7)', 'Terminal ileum + colon', 'Mild-moderate UC; mild Crohn\'s ileocolitis'],
['Mesalamine (oral – Pentasa)', 'Microspheres; sustained release', 'Small intestine + colon', 'Small bowel Crohn\'s; UC'],
['Mesalamine (rectal suppository)', 'Local delivery', 'Rectum', 'Proctitis'],
['Mesalamine (enema)', 'Local delivery', 'Rectum + left colon', 'Left-sided colitis; proctosigmoiditis'],
['Balsalazide', '5-ASA + carrier (colonic release)', 'Colon', 'Mild-moderate UC'],
['Olsalazine', '2 × 5-ASA linked', 'Colon', 'Maintenance of UC remission'],
]
story.append(drug_table(asa_data[0], asa_data[1:], TEAL))
story.append(sp(0.5))
story.append(Paragraph(
'<b>Mechanism:</b> 5-ASA inhibits COX and lipoxygenase, ↓prostaglandins and leukotrienes; also NF-κB inhibition → '
'anti-inflammatory at colonic mucosa. '
'<b>Sulfasalazine side effects:</b> hemolytic anemia (G6PD), hepatotoxicity, agranulocytosis, '
'oligospermia (reversible), folate deficiency (supplement folic acid), nausea/headache (sulfa moiety). '
'<b>Mesalamine side effects:</b> nephrotoxicity (rare but monitor renal function), '
'interstitial nephritis, paradoxical worsening (rare).', body_style))
story.append(sp())
story.append(section_header('11.3 Corticosteroids', ORANGE))
story.append(sp(0.5))
cs_data = [
['Drug', 'Route', 'Use', 'Notes'],
['Prednisone / Prednisolone', 'Oral', 'Induce remission in moderate-severe UC/CD', 'NOT for maintenance (long-term AEs: osteoporosis, DM, Cushing\'s, adrenal suppression)'],
['Hydrocortisone', 'IV / enema', 'Severe UC (IV); left-sided colitis (enema)', 'IV = first-line for severe UC flare'],
['Budesonide', 'Oral (Entocort capsule) / rectal foam', 'CD involving terminal ileum/ascending colon; microscopic colitis; mild UC', 'First-pass metabolism >90% → fewer systemic effects; DOC for mild-moderate Crohn\'s ileitis'],
['Methylprednisolone', 'IV', 'Severe acute UC induction', 'Often combined with cyclosporine or infliximab if no response in 3–5 days'],
]
story.append(drug_table(cs_data[0], cs_data[1:], ORANGE))
story.append(sp())
story.append(section_header('11.4 Immunomodulators (Maintenance)', PURPLE))
story.append(sp(0.5))
imm_data = [
['Drug', 'Class', 'MOA', 'Uses', 'Key Toxicities'],
['Azathioprine (AZA)', 'Thiopurine', 'Prodrug → 6-MP → 6-TGN → ↓purine synthesis, apoptosis of lymphocytes', 'Steroid-sparing; maintenance of remission in UC and CD; combine with biologics', 'Myelosuppression (check TPMT genotype before starting); pancreatitis (~3%), hepatotoxicity; lymphoma risk (long-term); nausea'],
['6-Mercaptopurine (6-MP)', 'Thiopurine', 'Active form of AZA', 'Same as AZA', 'Same as AZA; lower dose than AZA (0.75-1 mg/kg vs 2-2.5 mg/kg)'],
['Methotrexate', 'Antimetabolite', 'Inhibits DHFR → ↓folate → ↓DNA synthesis; anti-inflammatory via adenosine', 'CD (steroid-sparing, maintenance); NOT effective in UC', 'Hepatotoxicity (monitor LFTs; cirrhosis with long-term); pulmonary fibrosis; teratogenic (CONTRAINDICATED in pregnancy); myelosuppression; supplement folic acid'],
['Cyclosporine', 'Calcineurin inhibitor', 'Inhibits calcineurin → ↓IL-2 → ↓T-cell activation', 'Severe steroid-refractory UC (bridge to colectomy or biologics)', 'Nephrotoxicity, hypertension, seizures, hypertrichosis, gingival hyperplasia; narrow therapeutic window; monitor levels'],
['Tacrolimus', 'Calcineurin inhibitor', 'Same as cyclosporine but more potent', 'Severe refractory UC; refractory CD perianal disease', 'Similar to cyclosporine; diabetogenic'],
]
story.append(drug_table(imm_data[0], imm_data[1:], PURPLE))
story.append(sp())
story.append(section_header('11.5 Biological Therapies', BLUE))
story.append(sp(0.5))
bio_data = [
['Class', 'Drug', 'Target', 'Indication', 'Key Points'],
['Anti-TNF-α', 'Infliximab (chimeric IgG1)', 'TNF-α', 'Moderate-severe UC & CD; fistulizing CD', '5 mg/kg IV wks 0,2,6 then q8wks; check TB (Quantiferon) before starting; risk of reactivation TB, HBV, fungal infections; demyelinating disease contraindicated'],
['Anti-TNF-α', 'Adalimumab (fully human)', 'TNF-α', 'Moderate-severe UC & CD', '160/80/40 mg SC; similar to infliximab; preferred for self-injection'],
['Anti-TNF-α', 'Certolizumab pegol', 'TNF-α (Fab fragment)', 'Moderate-severe CD', 'Pegylated Fab; minimal placental transfer → safest anti-TNF in pregnancy (3rd trimester)'],
['Anti-TNF-α', 'Golimumab', 'TNF-α', 'Moderate-severe UC', 'Monthly SC after loading'],
['Anti-integrin', 'Vedolizumab', 'α4β7 integrin → MAdCAM-1 (gut-selective)', 'Moderate-severe UC & CD', 'Gut-selective: minimal systemic immunosuppression; safer for infections; PML risk very low'],
['Anti-integrin', 'Natalizumab', 'α4 integrin', 'Severe CD (2nd line)', 'PML risk (JC virus) – requires REMS program and monthly MRI monitoring'],
['Anti-IL-12/23', 'Ustekinumab', 'p40 subunit of IL-12 and IL-23', 'Moderate-severe CD & UC', 'SC q8wks maintenance; favorable safety profile; no TB reactivation risk (unlike anti-TNF)'],
['Anti-IL-23', 'Risankizumab, Mirikizumab', 'p19 subunit of IL-23', 'Moderate-severe CD & UC', 'More selective than ustekinumab; emerging first-line options'],
['JAK Inhibitors (small molecule)', 'Tofacitinib, Upadacitinib, Filgotinib', 'JAK1/3 (intracellular)', 'Moderate-severe UC ± CD', 'Oral; rapid onset; risk of VTE, herpes zoster, malignancy; avoid in high cardiovascular risk; Tofacitinib approved UC; Upadacitinib approved UC and CD'],
['S1P Modulators', 'Ozanimod, Etrasimod', 'Sphingosine-1-phosphate receptor', 'Moderate-severe UC', 'Sequesters lymphocytes in lymph nodes; oral; first-dose bradycardia; ophthalmologic screening needed'],
]
story.append(drug_table(bio_data[0], bio_data[1:], BLUE))
story.append(sp())
story.append(colored_box([
Paragraph('<b>Before starting biologics:</b> Screen for TB (IGRA/Quantiferon + CXR), HBV (HBsAg, anti-HBc), '
'HIV. Check varicella and influenza vaccination status. Anti-TNF agents are associated with '
'reactivation of latent TB and HBV. Vedolizumab: gut-selective (safest infectious profile). '
'JAK inhibitors: check lipids, CBC regularly.', note_style)
], BG_BLUE, BLUE))
story.append(sp())
story.append(section_header('11.6 IBD Treatment Algorithm Summary', NAVY))
story.append(sp(0.5))
algo_data = [
['Disease', 'Mild', 'Moderate', 'Severe', 'Maintenance'],
['Ulcerative Colitis', '5-ASA oral + rectal', '5-ASA + oral steroids or budesonide MMX; consider anti-TNF', 'IV steroids → if no response: IV cyclosporine or infliximab; colectomy if refractory', '5-ASA (mild); AZA or 6-MP or biologics (moderate-severe)'],
['Crohn\'s Disease\n(ileocecal)', 'Budesonide; mesalamine (limited)', 'Budesonide or prednisone + immunomodulator (AZA/MTX)', 'IV steroids + biologic (infliximab/adalimumab/vedolizumab); surgery if complicated', 'AZA/6-MP or MTX + biologic (combination)'],
['Crohn\'s Perianal', 'Antibiotics (metro + cipro)', 'Antibiotics + seton', 'Infliximab + seton; fistulotomy for simple fistulas', 'Infliximab maintenance'],
]
story.append(drug_table(algo_data[0], algo_data[1:], NAVY))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 12 – QUICK REFERENCE TABLES
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('12. QUICK REFERENCE – DRUG COMPARISONS', PURPLE))
story.append(sp())
story.append(section_header('12.1 PPI vs H2RA Comparison', PURPLE))
story.append(sp(0.5))
comp_data = [
['Feature', 'PPI', 'H2RA'],
['Mechanism', 'Irreversible H⁺/K⁺-ATPase inhibition', 'Competitive H2 receptor block'],
['Acid suppression', '90–95% (superior)', '50–70%'],
['Speed of onset', 'Slow (full effect day 2–5)', 'Rapid (within 1–3h)'],
['Nocturnal acid', 'Moderate control', 'Better for nocturnal baseline acid'],
['Tolerance', 'Rare (upregulates receptor long-term)', 'Yes – tachyphylaxis within 2–3 days'],
['GERD healing', '>90% at 8 wks', '~50–75% at 8 wks'],
['H. pylori', 'Part of all regimens', 'Not part of eradication'],
['Drug interaction (CYP)', 'Omeprazole/esomeprazole (significant)', 'Cimetidine (significant); others minimal'],
['Pregnancy', 'Generally considered safe (Category B-C)', 'Famotidine preferred (safest H2RA)'],
['Long-term concerns', 'Hypomagnesemia, B12, fractures, CDAD', 'Minimal (dose-adjust in renal failure)'],
]
story.append(drug_table(comp_data[0], comp_data[1:], PURPLE))
story.append(sp())
story.append(section_header('12.2 High-Yield Drug Facts for Exams', AMBER))
story.append(sp(0.5))
hiy_facts = [
('<b>Omeprazole</b> – interacts with clopidogrel (CYP2C19 – use pantoprazole instead)', TEAL),
('<b>Cimetidine</b> – most drug interactions (CYP inhibitor + antiandrogenic)', RED),
('<b>Famotidine</b> – most potent H2RA; safest in pregnancy', GREEN),
('<b>Misoprostol</b> – PGE1 analogue; CONTRAINDICATED in pregnancy (causes abortion); use in NSAID ulcer prophylaxis', RED),
('<b>Sucralfate</b> – works at pH <4; binds many drugs (separate by 2h); constipation', ORANGE),
('<b>Antacids</b> – Al=constipation; Mg=diarrhea; Ca=acid rebound; Na=alkalosis', BLUE),
('<b>Metoclopramide</b> – tardive dyskinesia (black box, max 12 wks); crosses BBB; ↑prolactin', RED),
('<b>Domperidone</b> – does NOT cross BBB (no EPS); ↑QTc (FDA restricted)', ORANGE),
('<b>Cisapride</b> – WITHDRAWN; fatal QT prolongation (Torsades de Pointes)', RED),
('<b>Ondansetron</b> – 5-HT3 antagonist; constipation + headache + QTc prolongation', TEAL),
('<b>Palonosetron</b> – longest t½ (~40h); best for delayed CINV; allosteric 5-HT3 binding', CYAN_DARK),
('<b>Aprepitant</b> – NK1 antagonist; delayed CINV; CYP3A4 inducer/inhibitor; hiccups', PURPLE),
('<b>Senna</b> – stimulant laxative; melanosis coli (chronic use)', PINK),
('<b>Lactulose</b> – osmotic laxative; also for hepatic encephalopathy (↓NH₃)', GREEN),
('<b>Loperamide</b> – μ-opioid (gut, no BBB penetration); contraindicated in infectious/bloody diarrhea', TEAL),
('<b>Octreotide</b> – somatostatin analogue; VIPoma, carcinoid diarrhea, ZES', NAVY),
('<b>Infliximab</b> – chimeric anti-TNF; screen TB/HBV before use; IV; risk opportunistic infections', BLUE),
('<b>Vedolizumab</b> – gut-selective α4β7 integrin antagonist; safest infection profile among biologics', GREEN),
('<b>Tofacitinib</b> – oral JAK1/3 inhibitor; UC; risk VTE, zoster, malignancy', ORANGE),
('<b>Ustekinumab</b> – anti-IL-12/23 (p40); UC + CD; no TB reactivation risk', AMBER),
('<b>Azathioprine</b> – check TPMT before starting; risk myelosuppression, pancreatitis, lymphoma', PURPLE),
('<b>Methotrexate</b> – effective in CD (not UC); hepatotoxic; CONTRAINDICATED in pregnancy; supplement folate', RED),
('<b>Rifaximin</b> – non-absorbable antibiotic; IBS-D, traveler\'s diarrhea, hepatic encephalopathy', CYAN_DARK),
('<b>Vonoprazan</b> – P-CAB; does not need acid activation; faster onset than PPIs; dual therapy with amoxicillin for H. pylori', TEAL),
]
for fact, color in hiy_facts:
story.append(Paragraph(f'<font color="#{color.hexval()[2:]}">▸</font> {fact}', bullet_style))
story.append(sp())
story.append(PageBreak())
# ══════════════════════════════════════════════════════════════════
# CHAPTER 13 – MECHANISM SUMMARY TABLES
# ══════════════════════════════════════════════════════════════════
story.append(chapter_header('13. MECHANISM SUMMARY & MNEMONICS', GREEN))
story.append(sp())
story.append(section_header('13.1 Drug Receptor/Target Summary', GREEN))
story.append(sp(0.5))
mech_data = [
['Drug / Class', 'Receptor / Target', 'Effect'],
['PPIs (omeprazole etc.)', 'H⁺/K⁺-ATPase (irreversible covalent)', '↓Acid secretion (most potent acid suppressant)'],
['P-CABs (vonoprazan)', 'H⁺/K⁺-ATPase (reversible K-competitive)', '↓Acid; faster onset; genotype independent'],
['H2RAs (famotidine)', 'H2 receptor on parietal cell (competitive, reversible)', '↓cAMP → ↓Acid; good for nocturnal acid'],
['Misoprostol', 'EP3 on parietal cell (Gi) + EP2/4 (↑mucus)', '↓Acid + ↑mucosal defense; PGE1 analogue'],
['Sucralfate', 'Binds ulcer base (physical barrier)', 'Cytoprotection; needs pH <4'],
['Antacids', 'Neutralizes HCl directly (not receptor)', 'Rapid symptom relief; raises gastric pH'],
['Metoclopramide', 'D2 antagonist + 5-HT4 agonist', '↑GI motility + antiemetic (CTZ)'],
['Ondansetron', '5-HT3 antagonist (vagal + CTZ)', 'Antiemetic; no EPS; constipation'],
['Aprepitant', 'NK1 (neurokinin-1) antagonist', 'Blocks substance P; delayed CINV'],
['Scopolamine', 'M1 muscarinic antagonist (vestibular)', 'Motion sickness'],
['Loperamide', 'μ-opioid receptor (gut-selective)', '↓Peristalsis; ↑sphincter tone; antidiarrheal'],
['Octreotide', 'Somatostatin receptor (SSTR2,5)', '↓GI secretion; ↓splanchnic blood flow; antidiarrheal'],
['Mesalamine (5-ASA)', 'COX/LOX inhibition + NF-κB (colonic mucosa)', 'Anti-inflammatory; UC maintenance'],
['Infliximab/Adalimumab', 'TNF-α neutralization', 'Anti-inflammatory; moderate-severe UC/CD'],
['Vedolizumab', 'α4β7 integrin (gut-selective)', 'Prevents lymphocyte homing to gut; gut-selective'],
['Azathioprine/6-MP', 'Purine synthesis inhibition (after activation by HGPRT)', 'Steroid-sparing; lymphocyte apoptosis'],
['Tofacitinib', 'JAK1/3 inhibition (intracellular)', 'Blocks JAK-STAT → ↓cytokine signaling; oral'],
]
story.append(drug_table(mech_data[0], mech_data[1:], GREEN))
story.append(sp())
story.append(section_header('13.2 Mnemonics & Memory Aids', AMBER))
story.append(sp(0.5))
mnemonics = [
('<b>PUMP Inhibitors (PPIs)</b>: <u>P</u>antoprazole, <u>O</u>meprazole (esomeprazole), <u>M</u>eprazole (rabeprazole), <u>P</u>ick lansoprazole, dexlansoprazole. "Pro-drug PUMP" – activated in parietal cell acid canaliculus', TEAL),
('<b>H2RA = CRFN</b>: <u>C</u>imetidine (1st; CYP inhibitor; antiandrogenic), <u>R</u>anitidine (withdrawn – NDMA), <u>F</u>amotidine (most potent; preferred), <u>N</u>izatidine (highest oral bioavailability)', PURPLE),
('<b>Antacids = MACON</b>: <u>M</u>g (diarrhea), <u>A</u>l (constipation), <u>C</u>a (acid rebound), <u>O</u>smotic, <u>N</u>a (alkalosis)', GREEN),
('<b>H. pylori triple = PAC/PMC</b>: PPI + Amoxicillin + Clarithromycin; OR PPI + Metronidazole + Clarithromycin', AMBER),
('<b>Bismuth quad = PBMT</b>: PPI + Bismuth + Metronidazole + Tetracycline', ORANGE),
('<b>Antiemetic targets: DUNK</b>: <u>D</u>opamine D2 (CTZ), <u>U</u>ps (5-HT3 on vagal), <u>N</u>K1 (substance P, VC), <u>H</u>1+M1 (vestibular = motion sickness)', CYAN_DARK),
('<b>Setrons ("ondansetron family")</b>: Onda-gran-palo-dola-setron – all end in "-setron"; 5-HT3 antagonists; CINV, post-op N&V; constipation + headache + QTc', CYAN_DARK),
('<b>Laxative Ladder</b>: Bulk → Osmotic → Stimulant → Secretagogue (in increasing potency, use safest first)', PINK),
('<b>IBD biologics = VISA-TUR</b>: Vedolizumab (integrin), Infliximab/adalimumab (anti-TNF), Secukinumab (IL-17, not IBD), Adalimumab, Tofacitinib (JAK), Ustekinumab (IL-12/23), Risankizumab (IL-23)', BLUE),
('<b>Before biologics = TBH</b>: Screen <u>T</u>B, <u>B</u>HV (HBV), <u>H</u>IV + vaccination review', RED),
('<b>Methotrexate in IBD</b>: Works in Crohn\'s only (NOT UC); hepatotoxic; CONTRA in pregnancy; supplement folic acid', RED),
('<b>TPMT testing</b>: Always before azathioprine/6-MP; low TPMT activity = risk of fatal myelosuppression', ORANGE),
]
for fact, color in mnemonics:
story.append(Paragraph(f'<font color="#{color.hexval()[2:]}">◆</font> {fact}', bullet_style))
story.append(sp(0.5))
story.append(sp())
# Footer
story.append(hr(NAVY))
story.append(Paragraph(
'<b>Source:</b> Goodman & Gilman\'s The Pharmacological Basis of Therapeutics – '
'Chapters 53 (Acid-Peptic Disease), 54 (GI Motility, Emesis, Biliary/Pancreatic), '
'55 (Inflammatory Bowel Disease). Compiled for examination revision.',
make_style('Footer', fontSize=8, textColor=HexColor('#757575'), alignment=TA_CENTER)
))
# ─── Build ────────────────────────────────────────────────────────────────────
def add_page_number(canvas, doc):
canvas.saveState()
canvas.setFont('Helvetica', 8)
canvas.setFillColor(HexColor('#9E9E9E'))
canvas.drawRightString(A4[0] - 1.5*cm, 1.2*cm, f'Page {doc.page}')
canvas.drawString(1.5*cm, 1.2*cm, 'GIT Pharmacology – Exam Revision | Orris Medical')
canvas.restoreState()
doc.build(story, onFirstPage=add_page_number, onLaterPages=add_page_number)
print(f'PDF generated: {OUTPUT}')
Wgen will my credits renew?