https://pharmdguru.com/gastroesophageal-reflux-disease/ write notes for topic of GERD therapeutics 3 it should include intro definition etiology pathophysiology in flowchart clinical features diagnosis treatment goals non pharmac treatment pharmacological treatment including drug short intro class short moa in flowchart drug interaction adr dose indication contraindication and summary chart for pharmacological treatment

Reading File
Finding Sources
Reading Web Page

https://pharmdguru.com/gastroesophageal-reflux-disease/

Searching PubMed

gastroesophageal reflux disease treatment management

Reading File
Reading File
Reading File
Finding Sources
Reading File
Reading File
Reading File
Running Command

mkdir -p /tmp/workspace/gerd-notes && ls /tmp/workspace/gerd-notes/

Writing File

~/gerd-notes/build_gerd_notes.py

from docx import Document
from docx.shared import Pt, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy

doc = Document()

# ── Page margins ──
for section in doc.sections:
    section.top_margin    = Inches(0.8)
    section.bottom_margin = Inches(0.8)
    section.left_margin   = Inches(0.9)
    section.right_margin  = Inches(0.9)

# ── Default font ──
normal = doc.styles["Normal"]
normal.font.name = "Calibri"
normal.font.size = Pt(11)

# ── Helper functions ──
def add_title(doc, text):
    p = doc.add_heading(text, level=0)
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    run = p.runs[0]
    run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
    # shade paragraph
    pPr = p._p.get_or_add_pPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), '1F4E79')
    pPr.append(shd)

def add_h1(doc, text):
    p = doc.add_heading(text, level=1)
    run = p.runs[0]
    run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
    pPr = p._p.get_or_add_pPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), '2E75B6')
    pPr.append(shd)

def add_h2(doc, text):
    p = doc.add_heading(text, level=2)
    run = p.runs[0]
    run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
    pPr = p._p.get_or_add_pPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), '5B9BD5')
    pPr.append(shd)

def add_h3(doc, text):
    p = doc.add_heading(text, level=3)
    run = p.runs[0]
    run.font.color.rgb = RGBColor(0x1F, 0x4E, 0x79)

def add_body(doc, text):
    p = doc.add_paragraph(text)
    p.style = doc.styles["Normal"]

def add_bullet(doc, text, level=0):
    p = doc.add_paragraph(text, style="List Bullet")
    p.paragraph_format.left_indent = Inches(0.3 * (level + 1))

def add_note(doc, text):
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Inches(0.4)
    run = p.add_run(text)
    run.font.italic = True
    run.font.color.rgb = RGBColor(0x75, 0x75, 0x75)

def shade_row(row, hex_color):
    for cell in row.cells:
        tc = cell._tc
        tcPr = tc.get_or_add_tcPr()
        shd = OxmlElement('w:shd')
        shd.set(qn('w:val'), 'clear')
        shd.set(qn('w:color'), 'auto')
        shd.set(qn('w:fill'), hex_color)
        tcPr.append(shd)

def add_table_header(table, headers, color='2E75B6'):
    hdr = table.rows[0]
    shade_row(hdr, color)
    for i, h in enumerate(headers):
        cell = hdr.cells[i]
        cell.text = h
        for para in cell.paragraphs:
            for run in para.runs:
                run.bold = True
                run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
                run.font.size = Pt(10)

def add_flowchart_box(doc, text, fill='D6E4F0', text_color='1F4E79', border='2E75B6'):
    """Simulate flowchart box using a shaded 1-cell table."""
    tbl = doc.add_table(rows=1, cols=1)
    tbl.style = 'Table Grid'
    cell = tbl.cell(0, 0)
    cell.text = text
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), fill)
    tcPr.append(shd)
    for para in cell.paragraphs:
        para.alignment = WD_ALIGN_PARAGRAPH.CENTER
        for run in para.runs:
            run.bold = True
            run.font.color.rgb = RGBColor(int(text_color[:2],16), int(text_color[2:4],16), int(text_color[4:],16))
            run.font.size = Pt(11)
    doc.add_paragraph()  # spacing

def add_arrow(doc, label=''):
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    run = p.add_run(f'  ▼  {label}' if label else '  ▼')
    run.font.size = Pt(14)
    run.font.bold = True
    run.font.color.rgb = RGBColor(0x2E, 0x75, 0xB6)

# ═══════════════════════════════════════════════════
# COVER / TITLE
# ═══════════════════════════════════════════════════
add_title(doc, "GASTROESOPHAGEAL REFLUX DISEASE (GERD)")
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("Pharmacotherapeutics – III  |  Comprehensive Study Notes")
run.font.size = Pt(13)
run.font.bold = True
run.font.color.rgb = RGBColor(0x2E, 0x75, 0xB6)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 1. INTRODUCTION
# ═══════════════════════════════════════════════════
add_h1(doc, "1. INTRODUCTION")
add_body(doc,
    "Gastroesophageal Reflux Disease (GERD) is one of the most prevalent chronic gastrointestinal disorders "
    "worldwide. It is characterised by the retrograde flow of gastric contents into the esophagus, causing "
    "troublesome symptoms and/or complications. GERD significantly impairs quality of life and, if left "
    "untreated, can progress to serious complications such as Barrett's esophagus and esophageal adenocarcinoma."
)
add_body(doc,
    "GERD affects approximately 10–30% of the Western population and has a rising prevalence globally. "
    "It is one of the most common reasons for gastroenterology referrals and carries a substantial economic "
    "burden due to medication costs, investigations, and lost productivity."
)

# ═══════════════════════════════════════════════════
# 2. DEFINITION
# ═══════════════════════════════════════════════════
add_h1(doc, "2. DEFINITION")
add_body(doc,
    "GERD is defined as a condition that develops when the reflux of stomach contents causes troublesome "
    "symptoms and/or complications."
)
add_body(doc, "– Montreal Consensus Definition (2006)")
add_body(doc,
    "More specifically, GERD results when the lower esophageal sphincter (LES) – the muscular valve between "
    "the esophagus and stomach – fails to maintain adequate pressure, allowing gastric acid and pepsin to "
    "repeatedly flow back into the esophagus and cause mucosal injury."
)

# ═══════════════════════════════════════════════════
# 3. ETIOLOGY
# ═══════════════════════════════════════════════════
add_h1(doc, "3. ETIOLOGY")
add_h2(doc, "3.1 Primary Causes")
causes = [
    ("Defective Lower Esophageal Sphincter (LES)", "Weak basal tone (<6 mmHg) or transient LES relaxations (TLESRs) – most important mechanism"),
    ("Hiatal Hernia", "Disrupts normal gastroesophageal junction anatomy; displaces LES above diaphragm, reducing its barrier function"),
    ("Impaired Esophageal Clearance", "Defective peristalsis fails to clear refluxed acid; reduced salivary bicarbonate reduces neutralisation"),
    ("Delayed Gastric Emptying", "Prolonged gastric distension increases pressure and TLESRs"),
    ("Abnormal Esophageal Mucosal Defense", "Reduced mucus, bicarbonate, and prostaglandin secretion"),
]
for title, detail in causes:
    p = doc.add_paragraph()
    run = p.add_run(f"• {title}: ")
    run.bold = True
    run.font.color.rgb = RGBColor(0x2E, 0x75, 0xB6)
    p.add_run(detail)

add_h2(doc, "3.2 Risk Factors / Predisposing Factors")
risk_cols = ["Risk Factor", "Mechanism"]
risk_data = [
    ("Obesity (BMI >30)", "Increased intra-abdominal pressure; OR for GERD rises to 1.94"),
    ("Pregnancy", "Elevated progesterone relaxes LES; mechanical compression of stomach"),
    ("Smoking", "Reduces LES tone; impairs salivary bicarbonate; delays gastric emptying"),
    ("Alcohol", "Directly irritates esophageal mucosa; reduces LES pressure"),
    ("High-fat / spicy / acidic diet", "Delays gastric emptying; stimulates acid secretion; relaxes LES"),
    ("Caffeine & carbonated drinks", "Relaxes LES; increases gastric acid secretion"),
    ("Large meals (especially at night)", "Increases gastric volume and pressure"),
    ("Certain medications", "Anticholinergics, nitrates, CCBs, benzodiazepines, opioids – reduce LES tone"),
    ("Stress & irregular sleep", "Increases acid secretion; alters esophageal sensitivity"),
    ("H. pylori (paradox)", "May be protective in some populations but role is debated"),
]
t = doc.add_table(rows=len(risk_data)+1, cols=2)
t.style = 'Table Grid'
add_table_header(t, risk_cols)
for i, (rf, mech) in enumerate(risk_data):
    row = t.rows[i+1]
    row.cells[0].text = rf
    row.cells[1].text = mech
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(10)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 4. PATHOPHYSIOLOGY (FLOWCHART)
# ═══════════════════════════════════════════════════
add_h1(doc, "4. PATHOPHYSIOLOGY (FLOWCHART)")
add_body(doc, "The pathophysiology of GERD is multifactorial. The key principle is an imbalance between aggressive factors (acid, pepsin, bile) and defensive mucosal factors.")
doc.add_paragraph()

steps = [
    ("TRIGGERING FACTORS\nObesity | Hiatal hernia | Diet | Drugs | Pregnancy | Smoking", "D6E4F0"),
    ("↓ LES Pressure / Transient LES Relaxations (TLESRs)\n(Normal basal LES pressure: 10–30 mmHg; in GERD <6 mmHg)", "D6EAF8"),
    ("Retrograde Flow of Gastric Contents into Esophagus\n(Acid + Pepsin ± Bile acids)", "D5E8D4"),
    ("Impaired Esophageal Clearance\n(Defective peristalsis + Reduced salivary neutralisation)", "FFF2CC"),
    ("Prolonged Acid Exposure of Esophageal Mucosa", "FCE4D6"),
    ("Mucosal Injury\nInflammation → Erosive Esophagitis → Ulceration", "F4CCCC"),
    ("COMPLICATIONS\nStrictures | Barrett's Esophagus | Esophageal Adenocarcinoma", "FFD7BE"),
]
colors_text = ['1F4E79','1F4E79','1A5E20','7D6608','843A0C','7B241C','6D4C41']
for i, (txt, fill) in enumerate(steps):
    add_flowchart_box(doc, txt, fill=fill, text_color=colors_text[i])
    if i < len(steps)-1:
        add_arrow(doc)

doc.add_paragraph()
add_note(doc, "Key: TLESRs = Transient Lower Esophageal Sphincter Relaxations — the primary mechanism in non-erosive GERD")

# ═══════════════════════════════════════════════════
# 5. CLINICAL FEATURES
# ═══════════════════════════════════════════════════
add_h1(doc, "5. CLINICAL FEATURES")
add_h2(doc, "5.1 Typical (Esophageal) Symptoms")
typical = [
    ("Heartburn", "Burning retrosternal sensation after meals; worsens on bending/lying down – CARDINAL symptom"),
    ("Acid regurgitation", "Sour or bitter taste of stomach contents reaching mouth or throat"),
    ("Water brash", "Reflex hypersalivation due to esophageal acid stimulation"),
    ("Dysphagia", "Difficulty swallowing – suggests stricture, motility disorder, or malignancy"),
    ("Odynophagia", "Painful swallowing – suggests severe esophagitis"),
    ("Chest discomfort", "Non-cardiac chest pain; may mimic angina"),
]
for sym, detail in typical:
    p = doc.add_paragraph()
    r = p.add_run(f"• {sym}: ")
    r.bold = True
    p.add_run(detail)

add_h2(doc, "5.2 Atypical (Extra-esophageal) Symptoms")
atypical = [
    "Chronic cough (GERD is a leading cause)",
    "Hoarseness / voice changes (laryngopharyngeal reflux)",
    "Asthma exacerbations (acid micro-aspiration)",
    "Dental erosion (acid exposure to teeth)",
    "Globus sensation (lump in throat)",
    "Recurrent sinusitis or otitis media (in children)",
]
for a in atypical:
    add_bullet(doc, a)

add_h2(doc, "5.3 Alarm Symptoms (Red Flags – Require Urgent Investigation)")
alarm = [
    "Unexplained significant weight loss",
    "Progressive dysphagia (especially to solids)",
    "Vomiting blood (haematemesis)",
    "Black tarry stools (melaena)",
    "Anaemia",
    "Palpable epigastric mass",
    "Age >55 with new-onset symptoms",
]
for a in alarm:
    p = doc.add_paragraph()
    r = p.add_run(f"⚠  {a}")
    r.font.color.rgb = RGBColor(0xC0, 0x00, 0x00)
    r.bold = True

# ═══════════════════════════════════════════════════
# 6. DIAGNOSIS
# ═══════════════════════════════════════════════════
add_h1(doc, "6. DIAGNOSIS")
add_body(doc,
    "GERD is primarily a clinical diagnosis based on characteristic symptoms. Investigations are reserved for "
    "patients with alarm symptoms, refractory symptoms, or to assess complications."
)
diag_data = [
    ("Clinical Evaluation", "History of heartburn + regurgitation ≥2×/week for >4 weeks; symptom questionnaires (GERD-Q, ReQuest)", "First-line"),
    ("Empirical PPI Trial", "Complete resolution of symptoms with 2–4 weeks of PPI supports diagnosis; sensitivity ~78%", "Diagnostic & therapeutic"),
    ("Upper GI Endoscopy (EGD)", "Detects erosive esophagitis, Barrett's, strictures, malignancy. Los Angeles Classification (Grade A–D)", "Alarm symptoms / complications"),
    ("Ambulatory 24-h pH Monitoring", "Gold standard for diagnosis. Measures acid exposure time (AET >6% = abnormal)", "Refractory / uncertain GERD"),
    ("pH-Impedance Monitoring", "Detects both acid and non-acid reflux events; best test for patients on PPI", "PPI-refractory GERD"),
    ("Esophageal Manometry", "Assesses LES pressure and peristalsis; used before anti-reflux surgery", "Pre-operative evaluation"),
    ("Barium Swallow", "Demonstrates hiatal hernia, strictures; less sensitive for GERD", "Structural assessment"),
]
t = doc.add_table(rows=len(diag_data)+1, cols=3)
t.style = 'Table Grid'
add_table_header(t, ["Investigation", "Details / Findings", "When Used"])
for i, (inv, det, when) in enumerate(diag_data):
    row = t.rows[i+1]
    row.cells[0].text = inv
    row.cells[1].text = det
    row.cells[2].text = when
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(10)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 7. TREATMENT GOALS
# ═══════════════════════════════════════════════════
add_h1(doc, "7. TREATMENT GOALS")
goals = [
    ("1", "Relieve symptoms", "Eliminate or significantly reduce heartburn, regurgitation, and associated discomfort"),
    ("2", "Heal esophageal mucosa", "Resolve erosive esophagitis and prevent mucosal damage"),
    ("3", "Prevent complications", "Prevent stricture formation, Barrett's esophagus, and malignant transformation"),
    ("4", "Maintain remission", "Prevent symptom relapse (GERD is a chronic relapsing condition)"),
    ("5", "Improve quality of life", "Restore normal daily activities, sleep, and dietary habits"),
    ("6", "Minimise adverse effects", "Use the lowest effective dose; avoid unnecessary long-term PPI use"),
]
t = doc.add_table(rows=len(goals)+1, cols=3)
t.style = 'Table Grid'
add_table_header(t, ["Priority", "Goal", "Rationale"])
for i, (num, goal, rat) in enumerate(goals):
    row = t.rows[i+1]
    row.cells[0].text = num
    row.cells[1].text = goal
    row.cells[2].text = rat
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(10)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 8. NON-PHARMACOLOGICAL TREATMENT
# ═══════════════════════════════════════════════════
add_h1(doc, "8. NON-PHARMACOLOGICAL TREATMENT")
add_h2(doc, "8.1 Lifestyle Modifications (First-Line for All Patients)")
lifestyle = [
    ("Dietary Changes", [
        "Avoid trigger foods: fatty/fried foods, chocolate, citrus, tomato products, spicy foods",
        "Avoid caffeine, carbonated drinks, and alcohol",
        "Eat smaller, more frequent meals",
        "Avoid eating 2–3 hours before lying down",
    ]),
    ("Weight Loss", [
        "BMI reduction significantly decreases GERD symptoms",
        "Even 5–10% weight loss can improve symptoms in overweight patients",
    ]),
    ("Positional Measures", [
        "Elevate head of bed by 15–20 cm (6–8 inches) using bed wedge or blocks",
        "Avoid lying flat immediately after meals",
        "Sleep on left side (reduces nocturnal reflux)",
    ]),
    ("Smoking Cessation", ["Smoking reduces LES tone and bicarbonate secretion"]),
    ("Alcohol Cessation / Reduction", ["Alcohol directly irritates esophageal mucosa"]),
    ("Clothing", ["Avoid tight-fitting clothes that increase abdominal pressure"]),
    ("Stress Management", ["Stress can increase acid secretion and alter pain perception"]),
]
for category, points in lifestyle:
    p = doc.add_paragraph()
    r = p.add_run(f"▶  {category}")
    r.bold = True
    r.font.color.rgb = RGBColor(0x2E, 0x75, 0xB6)
    for pt in points:
        add_bullet(doc, pt, level=0)

add_h2(doc, "8.2 Surgical Treatment")
add_body(doc, "Considered when pharmacological treatment fails, patient preference to avoid long-term medications, or for complications:")
surgical = [
    ("Laparoscopic Nissen Fundoplication", "Gold standard surgery. Wraps the gastric fundus 360° around the LES to strengthen it. Durable results in 85–90% of patients."),
    ("Partial Fundoplication (Toupet / Dor)", "180–270° wrap; preferred in patients with impaired esophageal motility to reduce dysphagia"),
    ("LINX Device (Magnetic Sphincter Augmentation)", "Small ring of magnetic titanium beads placed around LES. Minimally invasive; reversible. Allows normal swallowing."),
    ("Transoral Incisionless Fundoplication (TIF)", "Endoscopic reconstructive procedure; no external incisions. Suitable for mild-moderate GERD."),
    ("Roux-en-Y Gastric Bypass", "Preferred in obese GERD patients; addresses obesity and GERD simultaneously"),
]
for name, detail in surgical:
    p = doc.add_paragraph()
    r = p.add_run(f"• {name}: ")
    r.bold = True
    r.font.color.rgb = RGBColor(0x2E, 0x75, 0xB6)
    p.add_run(detail)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 9. PHARMACOLOGICAL TREATMENT
# ═══════════════════════════════════════════════════
add_h1(doc, "9. PHARMACOLOGICAL TREATMENT")
add_body(doc,
    "Pharmacotherapy is the cornerstone of GERD management. Drug classes used include antacids, H2 receptor antagonists (H2RAs), "
    "proton pump inhibitors (PPIs), potassium-competitive acid blockers (P-CABs), prokinetics, mucosal protective agents, and antireflux alginates. "
    "PPIs are the most effective agents and are the standard of care for erosive GERD."
)
doc.add_paragraph()

# ─── DRUG CLASS 1: ANTACIDS ───
add_h2(doc, "9.1  ANTACIDS")
add_body(doc,
    "Antacids are OTC agents used for rapid, short-term symptomatic relief of mild, infrequent heartburn. "
    "They do not heal esophageal mucosa and are not suitable for long-term management."
)

add_h3(doc, "MOA (Flowchart)")
add_flowchart_box(doc, "Gastric Acid (HCl) in Stomach Lumen", fill='FCE4D6', text_color='843A0C')
add_arrow(doc, "Antacid administered (Al(OH)₃, Mg(OH)₂, CaCO₃, NaHCO₃)")
add_flowchart_box(doc, "Chemical Neutralisation: Antacid + HCl → Salt + H₂O\n(Raises intragastric pH from ~2 to >4)", fill='D5E8D4', text_color='1A5E20')
add_arrow(doc, "Pepsin inactivated (inactive above pH 4)")
add_flowchart_box(doc, "Symptomatic Relief within 5–15 minutes\n(Duration: 1–2 hours)", fill='D6E4F0', text_color='1F4E79')
doc.add_paragraph()

t = doc.add_table(rows=6, cols=5)
t.style = 'Table Grid'
add_table_header(t, ["Drug", "Dose", "Indication", "ADR", "Contraindication"])
antacid_data = [
    ("Aluminium hydroxide", "400–800 mg after meals & HS", "Mild/infrequent heartburn", "Constipation, phosphate depletion (long-term), osteomalacia", "Hypophosphataemia, renal impairment"),
    ("Magnesium hydroxide", "400–1200 mg QID", "Mild/infrequent heartburn", "Diarrhoea, hypermagnesaemia (renal failure)", "Renal failure"),
    ("Calcium carbonate", "500–1500 mg PRN", "Rapid relief; also Ca supplement", "Constipation, milk-alkali syndrome (overuse), hypercalcaemia", "Hypercalcaemia, renal stones"),
    ("Aluminium-Magnesium combo (Maalox, Mylanta)", "5–30 mL or 1–4 tablets after meals & HS", "Balances constipation/diarrhoea effects", "Fewer than single agents", "Renal impairment (Mg component)"),
    ("Sodium bicarbonate", "300 mg–2 g PRN", "Rapid relief only", "Metabolic alkalosis, sodium loading, rebound acidity", "Hypertension, oedema, heart failure"),
]
for i, row_data in enumerate(antacid_data):
    row = t.rows[i+1]
    for j, val in enumerate(row_data):
        row.cells[j].text = val
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9.5)
doc.add_paragraph()

add_h3(doc, "Drug Interactions – Antacids")
antacid_di = [
    ("Fluoroquinolones (ciprofloxacin, levofloxacin)", "Chelation – reduced absorption of antibiotic", "Space by 2 hours"),
    ("Tetracyclines", "Chelation with Al³⁺/Mg²⁺/Ca²⁺ – reduced antibiotic absorption", "Space by 2 hours"),
    ("Iron supplements", "Reduced Fe²⁺ absorption", "Space by 2 hours"),
    ("Azithromycin / Ketoconazole", "Reduced absorption (pH-dependent)", "Separate administration"),
    ("Digoxin", "Al/Mg antacids may reduce digoxin absorption", "Monitor digoxin levels"),
    ("Levodopa", "Al(OH)₃ may increase gastric emptying, altering levodopa absorption", "Monitor"),
]
t2 = doc.add_table(rows=len(antacid_di)+1, cols=3)
t2.style = 'Table Grid'
add_table_header(t2, ["Interacting Drug", "Effect", "Management"], color='5B9BD5')
for i, (drug, eff, mgmt) in enumerate(antacid_di):
    row = t2.rows[i+1]
    row.cells[0].text = drug
    row.cells[1].text = eff
    row.cells[2].text = mgmt
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t2.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9.5)
doc.add_paragraph()

# ─── DRUG CLASS 2: H2 RECEPTOR ANTAGONISTS ───
add_h2(doc, "9.2  H2 RECEPTOR ANTAGONISTS (H2RAs)")
add_body(doc,
    "H2RAs competitively block histamine H2 receptors on gastric parietal cells, reducing basal and meal-stimulated "
    "acid secretion. They are effective for mild-moderate GERD but are less potent than PPIs. Available OTC and by prescription. "
    "Famotidine is the preferred H2RA (ranitidine withdrawn due to NDMA contamination)."
)

add_h3(doc, "MOA (Flowchart)")
add_flowchart_box(doc, "Histamine released from ECL cells\n(Enterochromaffin-Like cells in gastric mucosa)", fill='FFF2CC', text_color='7D6608')
add_arrow(doc, "Normally binds H2 receptors on parietal cells")
add_flowchart_box(doc, "H2RA (e.g. Famotidine) COMPETITIVELY BLOCKS H2 receptors\n(Reversible competitive antagonism)", fill='D6E4F0', text_color='1F4E79')
add_arrow(doc, "Reduced cAMP → Reduced protein kinase A activation")
add_flowchart_box(doc, "↓ H⁺/K⁺-ATPase (Proton Pump) Activation\n→ Reduced gastric acid secretion (raises pH)", fill='D5E8D4', text_color='1A5E20')
add_arrow(doc)
add_flowchart_box(doc, "Effect: ↓ 24h gastric acid by ~70% (mainly suppresses nocturnal acid)\nOnset: 1h | Duration: 6–10 hours", fill='D6EAF8', text_color='1F4E79')
doc.add_paragraph()

t = doc.add_table(rows=5, cols=5)
t.style = 'Table Grid'
add_table_header(t, ["Drug", "Dose (GERD)", "ADR", "Drug Interactions", "Contraindications"])
h2ra_data = [
    ("Famotidine\n(PREFERRED)", "20 mg BD oral; 40 mg OD nocturnal", "Headache, dizziness, constipation/diarrhoea, fatigue; rarely QT prolongation (IV)", "Antacids (reduce absorption – space 2h); atazanavir (reduced absorption)", "Hypersensitivity; caution in renal impairment (reduce dose)"),
    ("Cimetidine\n(Oldest, multiple DIs)", "400 mg QID or 800 mg at HS", "Antiandrogenic: gynaecomastia, impotence, galactorrhoea; hepatotoxicity; CNS effects (elderly)", "MAJOR: warfarin, phenytoin, theophylline, lidocaine, metformin (CYP450 inhibition – increases levels)", "Avoid in pregnancy and with multiple drug interactions"),
    ("Ranitidine\n(Withdrawn)", "WITHDRAWN – NDMA contamination (carcinogen)", "–", "–", "No longer available"),
    ("Nizatidine", "150 mg BD or 300 mg HS", "Similar to famotidine; mild", "Minimal CYP interactions", "Renal impairment (dose adjust)"),
]
for i, row_data in enumerate(h2ra_data):
    row = t.rows[i+1]
    for j, val in enumerate(row_data):
        row.cells[j].text = val
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9.5)
doc.add_paragraph()

# ─── DRUG CLASS 3: PROTON PUMP INHIBITORS ───
add_h2(doc, "9.3  PROTON PUMP INHIBITORS (PPIs) ★ First-Line")
add_body(doc,
    "PPIs are the most effective drugs for GERD. They irreversibly inhibit the H⁺/K⁺-ATPase (proton pump) on "
    "parietal cells. They are prodrugs activated in the acidic canaliculi. PPIs suppress ~90–95% of acid secretion "
    "over 24 hours and are superior to H2RAs for healing erosive esophagitis. Must be taken 30–60 minutes BEFORE meals."
)

add_h3(doc, "MOA (Flowchart)")
add_flowchart_box(doc, "PPI administered as INACTIVE PRODRUG (weakly basic benzimidazole)\n(Omeprazole, Esomeprazole, Pantoprazole, Lansoprazole, Rabeprazole)", fill='EBF3FB', text_color='1F4E79')
add_arrow(doc, "Absorbed in small intestine → enters bloodstream")
add_flowchart_box(doc, "Accumulates in acidic secretory canaliculi of parietal cells\n(Low pH environment: ~1.0)", fill='FFF2CC', text_color='7D6608')
add_arrow(doc, "Acid-catalysed conversion to ACTIVE SULFENAMIDE (cyclic)")
add_flowchart_box(doc, "Active sulfenamide forms COVALENT (irreversible) disulfide bond\nwith CYSTEINE residue on H⁺/K⁺-ATPase (proton pump)", fill='FCE4D6', text_color='843A0C')
add_arrow(doc)
add_flowchart_box(doc, "IRREVERSIBLE inhibition of proton pump\n→ Blocks FINAL STEP of acid secretion regardless of stimulus\n(Suppresses >90% of 24h acid secretion)", fill='D5E8D4', text_color='1A5E20')
add_arrow(doc, "New pump synthesis required for recovery (~18–24h)")
add_flowchart_box(doc, "Sustained acid suppression\nOptimal effect achieved after 3–5 days of regular dosing", fill='D6E4F0', text_color='1F4E79')
doc.add_paragraph()

add_h3(doc, "PPI Pharmacokinetics Table (Katzung, 16th Ed.)")
t = doc.add_table(rows=8, cols=6)
t.style = 'Table Grid'
add_table_header(t, ["Drug", "Bioavailability", "t½ (h)", "Tmax (h)", "GERD Dose", "Notes"])
ppi_pk = [
    ("Omeprazole", "40–65%", "0.5–1.0", "1–3", "20–40 mg OD (AC)", "Prototype; most studied"),
    ("Esomeprazole\n(S-isomer of omeprazole)", ">80%", "1.5", "1.6", "20–40 mg OD (AC)", "IV available; highest bioavailability"),
    ("Lansoprazole", ">80%", "1.0–2.0", "1.7", "30 mg OD (AC)", "ODT form available"),
    ("Dexlansoprazole\n(R-isomer of lansoprazole)", "NA", "1.0–2.0", "5.0", "30–60 mg OD", "Dual-release; can be taken any time"),
    ("Pantoprazole", "77%", "1.0–1.9", "2.5–4.0", "40 mg OD (AC)", "IV available; fewer drug interactions"),
    ("Rabeprazole", "52%", "1.0–2.0", "3.1", "20 mg OD (AC)", "Non-enzymatic activation; less CYP interaction"),
]
for i, row_data in enumerate(ppi_pk):
    row = t.rows[i+1]
    for j, val in enumerate(row_data):
        row.cells[j].text = val
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9.5)
doc.add_paragraph()
add_note(doc, "AC = before meal (ante cibum). All PPIs best taken 30–60 min before first meal of day for maximum efficacy.")

add_h3(doc, "PPI Adverse Drug Reactions (ADRs)")
adr_data = [
    ("Short-term (weeks)", "Headache, nausea, diarrhoea, abdominal pain, constipation, flatulence (<5%)"),
    ("Long-term (months-years)", "Hypomagnesaemia (especially >1 year); Hypocalcaemia; Hyponatraemia"),
    ("Bone effects", "Increased risk of osteoporosis and hip/spine fractures (chronic use >1 year) – FDA warning"),
    ("Infection risk", "Increased risk of Clostridium difficile infection (↑ colonic pH favours colonisation)"),
    ("Pneumonia", "Small increased risk of community-acquired pneumonia"),
    ("Nutrient malabsorption", "Reduced absorption of: Vitamin B12, Iron, Calcium, Magnesium"),
    ("CKD", "Possible association with chronic kidney disease (observational data, mechanism unclear)"),
    ("Rebound hyperacidity", "On abrupt discontinuation: rebound acid hypersecretion; taper dose when stopping"),
    ("Hypergastrinaemia", "Elevated gastrin during PPI therapy → ECL cell hyperplasia (long-term)"),
    ("Clopidogrel interaction (specific)", "Omeprazole/esomeprazole inhibit CYP2C19 → reduced clopidogrel activation"),
]
t = doc.add_table(rows=len(adr_data)+1, cols=2)
t.style = 'Table Grid'
add_table_header(t, ["ADR Category", "Details"], color='C0504D')
for i, (cat, detail) in enumerate(adr_data):
    row = t.rows[i+1]
    row.cells[0].text = cat
    row.cells[1].text = detail
    if i % 2 == 0:
        shade_row(row, 'FDE9E9')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9.5)
doc.add_paragraph()

add_h3(doc, "PPI Drug Interactions")
ppi_di = [
    ("Clopidogrel", "Omeprazole/Esomeprazole inhibit CYP2C19 → ↓ active metabolite of clopidogrel → ↑ cardiovascular risk", "Use pantoprazole or rabeprazole instead"),
    ("Atazanavir / Nelfinavir (HIV)", "PPIs reduce gastric acid → impair absorption of these antiretrovirals", "Avoid PPIs; use H2RA if needed"),
    ("Methotrexate", "PPIs inhibit renal tubular secretion → ↑ methotrexate toxicity", "Monitor; consider PPI suspension"),
    ("Ketoconazole / Itraconazole", "pH-dependent absorption – PPI reduces antifungal absorption significantly", "Monitor antifungal levels"),
    ("Warfarin", "Omeprazole inhibits CYP2C19 → ↑ warfarin effect (minor) with some PPIs", "Monitor INR"),
    ("Digoxin", "Slight increase in digoxin levels (reduced gut metabolism at higher pH)", "Monitor levels"),
    ("Iron / Calcium / B12 supplements", "Reduced absorption with prolonged PPI use (acid required for absorption)", "Supplement if on long-term PPI"),
    ("Rilpivirine (HIV)", "Requires acidic environment for absorption; PPIs significantly reduce levels", "Contraindicated combination"),
    ("Tacrolimus", "CYP3A4 inhibition by some PPIs → increased tacrolimus levels", "Monitor trough levels"),
]
t = doc.add_table(rows=len(ppi_di)+1, cols=3)
t.style = 'Table Grid'
add_table_header(t, ["Interacting Drug", "Mechanism / Effect", "Management"], color='5B9BD5')
for i, (drug, eff, mgmt) in enumerate(ppi_di):
    row = t.rows[i+1]
    row.cells[0].text = drug
    row.cells[1].text = eff
    row.cells[2].text = mgmt
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9.5)
doc.add_paragraph()

# ─── DRUG CLASS 4: P-CABs ───
add_h2(doc, "9.4  POTASSIUM-COMPETITIVE ACID BLOCKERS (P-CABs) – New Generation")
add_body(doc,
    "P-CABs are a newer class of acid suppressants that reversibly block the potassium-binding site of the "
    "H⁺/K⁺-ATPase. Unlike PPIs, they do not require acid activation, have a faster onset, and provide "
    "more consistent acid suppression. Currently approved: Vonoprazan (Japan, USA, EU 2022–2024)."
)

add_h3(doc, "MOA (Flowchart)")
add_flowchart_box(doc, "P-CAB (e.g. Vonoprazan) – STABLE ACTIVE DRUG (not a prodrug)\n(Imidazopyridine structure – highly basic; accumulates in canaliculi)", fill='EBF3FB', text_color='1F4E79')
add_arrow(doc, "Accumulates in acidic canaliculi immediately")
add_flowchart_box(doc, "REVERSIBLY blocks the K⁺-binding site of H⁺/K⁺-ATPase\n(Potassium-competitive inhibition)", fill='D6E4F0', text_color='1F4E79')
add_arrow(doc)
add_flowchart_box(doc, "Faster onset, longer duration than PPIs\nNot dependent on meals (can be taken at any time)\nEffective on first dose | No lag period", fill='D5E8D4', text_color='1A5E20')
doc.add_paragraph()

t = doc.add_table(rows=3, cols=5)
t.style = 'Table Grid'
add_table_header(t, ["Drug", "Dose", "Indication", "ADR", "Notes"])
pcab_data = [
    ("Vonoprazan (Voquezna)", "20 mg OD for erosive GERD; 10–20 mg for NERD", "Erosive esophagitis (FDA approved 2023); H. pylori eradication", "Hypomagnesaemia, ↑ gastrin, CYP2C19 inhibition, nausea", "Faster onset than PPIs; no need to take before meals; reversible"),
    ("Tegoprazan", "50 mg OD", "GERD (approved in Korea/Asia)", "Similar to vonoprazan", "Available in select markets"),
]
for i, row_data in enumerate(pcab_data):
    row = t.rows[i+1]
    for j, val in enumerate(row_data):
        row.cells[j].text = val
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9.5)
doc.add_paragraph()

# ─── DRUG CLASS 5: PROKINETICS ───
add_h2(doc, "9.5  PROKINETIC AGENTS")
add_body(doc,
    "Prokinetics enhance esophageal peristalsis, increase LES tone, and accelerate gastric emptying, "
    "thereby reducing the amount and duration of reflux. Used as adjunctive therapy in patients with "
    "delayed gastric emptying or when combined with acid suppression is needed."
)

add_h3(doc, "MOA (Flowchart)")
add_flowchart_box(doc, "Delayed gastric emptying + ↓ LES tone → prolonged acid exposure", fill='FCE4D6', text_color='843A0C')
add_arrow(doc, "Prokinetic agent administered")
add_flowchart_box(doc, "D2 receptor antagonism (Metoclopramide, Domperidone)\nor 5-HT4 agonism → Enhanced ACh release from enteric neurons", fill='D6E4F0', text_color='1F4E79')
add_arrow(doc)
add_flowchart_box(doc, "↑ LES pressure | ↑ Esophageal peristalsis | ↑ Gastric emptying\n→ Reduced reflux episodes and acid contact time", fill='D5E8D4', text_color='1A5E20')
doc.add_paragraph()

t = doc.add_table(rows=4, cols=6)
t.style = 'Table Grid'
add_table_header(t, ["Drug", "Class/MOA", "Dose", "ADR", "Drug Interactions", "Contraindications"])
proki_data = [
    ("Metoclopramide", "D2 antagonist + 5HT4 agonist; also crosses BBB", "10 mg TID-QID AC (short-term only)", "EXTRAPYRAMIDAL: tardive dyskinesia (long-term), akathisia, drowsiness, restlessness; hyperprolactinaemia; QT prolongation", "Antipsychotics (↑ EPS); opioids (oppose effect); MAOIs", "Parkinson's disease, epilepsy, GI obstruction/haemorrhage, tardive dyskinesia Hx"),
    ("Domperidone", "D2 antagonist; does NOT cross BBB (peripheral)", "10–20 mg TID-QID AC", "QT prolongation (RISK); hyperprolactinaemia (galactorrhoea, gynaecomastia); headache; Less CNS effects than metoclopramide", "QT-prolonging drugs (DANGEROUS combination); azole antifungals (CYP3A4)", "QT prolongation/cardiac disease; hepatic impairment; hyperprolactinaemia"),
    ("Itopride", "D2 antagonist + cholinesterase inhibitor", "50 mg TID AC", "Mild: diarrhoea, headache, gynaecomastia; Fewer QT effects", "Less significant interactions", "GI obstruction, haemorrhage"),
]
for i, row_data in enumerate(proki_data):
    row = t.rows[i+1]
    for j, val in enumerate(row_data):
        row.cells[j].text = val
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9)
doc.add_paragraph()

# ─── DRUG CLASS 6: MUCOSAL PROTECTIVE AGENTS ───
add_h2(doc, "9.6  MUCOSAL PROTECTIVE / CYTOPROTECTIVE AGENTS")
add_body(doc,
    "These agents protect the esophageal and gastric mucosa from acid damage, forming physical barriers or "
    "stimulating endogenous defensive mechanisms."
)

t = doc.add_table(rows=4, cols=6)
t.style = 'Table Grid'
add_table_header(t, ["Drug", "Class/MOA", "Dose", "ADR", "Drug Interactions", "Notes/CI"])
mucosal_data = [
    ("Sucralfate", "Aluminium salt of sulphated sucrose; binds to ulcer base forming protective coating; stimulates PGE2 & mucus", "1 g QID (30 min AC & HS)", "Constipation (Al content); nausea; bezoar formation (rare)", "Reduces absorption of: fluoroquinolones, tetracyclines, digoxin, phenytoin (space 2h)", "Requires acid for activation; less effective with PPIs; caution in renal failure (Al accumulation)"),
    ("Alginate-antacid (Gaviscon)", "Alginate + antacid: forms viscous raft on top of gastric contents → physical barrier against reflux", "10–20 mL or 2–4 tablets after meals & HS", "Well tolerated; sodium content (sodium alginate form) – caution in hypertension/HF", "Minimal", "Effective for post-prandial reflux; good for pregnancy (safe)"),
    ("Bismuth subsalicylate", "Coats mucosa; antimicrobial; anti-secretory", "524 mg QID", "Black stools, tongue discolouration; salicylate toxicity (overuse)", "Warfarin (↑ anticoagulation), tetracyclines", "Avoid in aspirin allergy; Reye's syndrome risk in children"),
]
for i, row_data in enumerate(mucosal_data):
    row = t.rows[i+1]
    for j, val in enumerate(row_data):
        row.cells[j].text = val
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 10. SUMMARY CHART – PHARMACOLOGICAL TREATMENT
# ═══════════════════════════════════════════════════
add_h1(doc, "10. SUMMARY CHART – PHARMACOLOGICAL TREATMENT OF GERD")

t = doc.add_table(rows=8, cols=7)
t.style = 'Table Grid'
add_table_header(t, ["Drug Class", "Key Drugs", "MOA (Brief)", "Dose", "Key ADRs", "Key DIs", "First-Line?"])
summary_data = [
    ("Antacids", "Al(OH)₃, Mg(OH)₂, CaCO₃, NaHCO₃", "Chemical neutralisation of HCl", "PRN; 400–1200 mg after meals", "Constipation/diarrhoea (Al/Mg), metabolic alkalosis (NaHCO₃)", "Chelation with FQs, tetracyclines, iron (space 2h)", "Mild/PRN only"),
    ("H2 Receptor Antagonists", "Famotidine ★, Cimetidine, Nizatidine", "Competitive block H2 receptor → ↓ cAMP → ↓ acid", "Famotidine 20 mg BD", "Headache, fatigue; Cimetidine: antiandrogenic, multiple DIs (CYP inhibitor)", "Cimetidine: warfarin, phenytoin, theophylline (CYP450)", "Mild-moderate GERD; PRN"),
    ("PPIs ★★★ GOLD STANDARD", "Omeprazole, Esomeprazole, Pantoprazole, Lansoprazole, Rabeprazole", "Irreversible covalent inhibition of H⁺/K⁺-ATPase", "20–40 mg OD 30-60 min AC", "Hypomagnesaemia, fractures, C. diff ↑, B12/Fe/Ca absorption ↓, rebound hyperacidity", "Clopidogrel (use pantoprazole), atazanavir, rilpivirine, methotrexate", "YES – ALL GERD (esp. erosive)"),
    ("P-CABs (Vonoprazan)", "Vonoprazan (Voquezna)", "Reversible K⁺-competitive H⁺/K⁺-ATPase block", "20 mg OD (no meal timing needed)", "Hypomagnesaemia, hypergastrinaemia", "CYP2C19 inhibition (similar to PPIs)", "Emerging first-line; erosive GERD"),
    ("Prokinetics", "Metoclopramide, Domperidone, Itopride", "D2 antagonism → ↑ LES tone, ↑ peristalsis, ↑ gastric emptying", "10–20 mg TID-QID AC", "Metoclopramide: EPS, tardive dyskinesia; Domperidone: QT prolongation", "QT-prolonging drugs (domperidone), antipsychotics (metoclopramide)", "Adjunct (delayed gastric emptying)"),
    ("Mucosal Protectives", "Sucralfate, Alginate-antacid, Bismuth", "Physical barrier/coating; stimulate mucosal defence", "Sucralfate 1g QID; Gaviscon 10-20 mL after meals", "Constipation (sucralfate); sodium load (alginate)", "Sucralfate: chelation with FQs, digoxin (space 2h)", "Adjunct; alginate preferred in pregnancy"),
    ("Baclofen (GABA-B agonist)", "Baclofen", "GABA-B agonist → ↓ TLESRs (reduces reflux episodes)", "5–10 mg TID (titrate)", "CNS: sedation, dizziness, confusion; nausea; muscle weakness", "CNS depressants (additive sedation)", "Refractory GERD; reduces TLESRs"),
]
for i, row_data in enumerate(summary_data):
    row = t.rows[i+1]
    for j, val in enumerate(row_data):
        row.cells[j].text = val
    if i % 2 == 0:
        shade_row(row, 'EBF3FB')
for col in t.columns:
    for cell in col.cells:
        for para in cell.paragraphs:
            for run in para.runs:
                run.font.size = Pt(9)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 11. STEP-UP TREATMENT ALGORITHM
# ═══════════════════════════════════════════════════
add_h1(doc, "11. GERD TREATMENT STEP-UP ALGORITHM")
steps_tx = [
    ("STEP 1 – ALL PATIENTS\nLifestyle Modifications\n(Weight loss, dietary changes, head-of-bed elevation, stop smoking/alcohol)", "D6E4F0"),
    ("STEP 2 – MILD / INTERMITTENT SYMPTOMS (<3×/week)\nAntacids PRN  OR  Alginate-antacid (Gaviscon)\nOR  Famotidine 10–20 mg PRN (OTC)", "D5E8D4"),
    ("STEP 3 – MODERATE SYMPTOMS (≥3×/week) or NERD\nPPI OD x 4–8 weeks (FIRST LINE)\ne.g. Omeprazole 20 mg OD or Pantoprazole 40 mg OD (30–60 min before breakfast)", "FFF2CC"),
    ("STEP 4 – EROSIVE ESOPHAGITIS (LA Grade C/D)\nPPI BID x 8–12 weeks\nConfirm healing by endoscopy → Maintenance PPI", "FCE4D6"),
    ("STEP 5 – REFRACTORY GERD (incomplete response to PPI BID)\nOptimise timing (30–60 min before meals); switch PPI; add H2RA at HS\nConsider: Vonoprazan | Baclofen | pH-impedance monitoring", "F4CCCC"),
    ("STEP 6 – SURGICAL REFERRAL\nFundoplication / LINX if: confirmed GERD, refractory symptoms, patient preference, complications", "FFD7BE"),
]
colors_tx = ['1F4E79','1A5E20','7D6608','843A0C','7B241C','6D4C41']
for i, (txt, fill) in enumerate(steps_tx):
    add_flowchart_box(doc, txt, fill=fill, text_color=colors_tx[i])
    if i < len(steps_tx)-1:
        add_arrow(doc)
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# 12. ROLE OF THE PHARMACIST
# ═══════════════════════════════════════════════════
add_h1(doc, "12. ROLE OF THE PHARMACIST IN GERD")
roles = [
    "Educate patients on lifestyle modifications as essential first-line management",
    "Guide proper use of PPIs (take 30–60 min before meals; explain importance of timing for efficacy)",
    "Counsel on signs of alarm symptoms requiring medical referral",
    "Identify and manage drug interactions (especially clopidogrel-PPI, domperidone-QT prolongation)",
    "Monitor for long-term PPI adverse effects: hypomagnesaemia, fracture risk, B12 deficiency",
    "Advise against unnecessary long-term use of PPIs; encourage periodic step-down attempts",
    "Counsel on safe use of antacids (avoid overuse; counsel on chelation interactions)",
    "Recognise NDMA issue with ranitidine; counsel patients on switch to famotidine",
    "Provide OTC guidance: antacids for PRN use; famotidine for prophylactic pre-meal use",
    "Document GERD in medication therapy management reviews; ensure adherence to prescribed therapy",
]
for i, role in enumerate(roles):
    add_bullet(doc, f"{i+1}. {role}")
doc.add_paragraph()

# ═══════════════════════════════════════════════════
# REFERENCES
# ═══════════════════════════════════════════════════
add_h1(doc, "REFERENCES")
refs = [
    "Katzung BG. Basic & Clinical Pharmacology, 16th ed. McGraw-Hill, 2022. Chapter 62: Drugs Used in the Treatment of Gastrointestinal Diseases.",
    "Sleisenger & Fordtran's Gastrointestinal and Liver Disease, 11th ed. Elsevier.",
    "Vakil N, van Zanten SV, Kahrilas P, et al. The Montreal definition and classification of gastroesophageal reflux disease. Am J Gastroenterol. 2006.",
    "Patel A, Laine L, Moayyedi P. AGA Clinical Practice Update on Integrating Potassium-Competitive Acid Blockers Into Clinical Practice. Gastroenterology. 2024 Nov. PMID: 39269391.",
    "Savarino EV, Barberio B, Scarpignato C. Italian guidelines for the diagnosis and management of GERD. Dig Liver Dis. 2025. PMID: 40450492.",
    "PharmD Guru. Gastroesophageal Reflux Disease – Pharmacotherapeutics III. https://pharmdguru.com/gastroesophageal-reflux-disease/",
]
for i, ref in enumerate(refs):
    add_bullet(doc, f"{i+1}. {ref}")

# ── Save ──
output_path = "/tmp/workspace/gerd-notes/GERD_Therapeutics_Notes.docx"
doc.save(output_path)
print(f"Saved: {output_path}")
Running Command

cd /tmp/workspace/gerd-notes && python3 build_gerd_notes.py 2>&1

Running Command

ls -lh /tmp/workspace/gerd-notes/

Your comprehensive GERD Pharmacotherapeutics-III notes are ready!
Download the Word document here:

GERD Therapeutics Notes

Word Document · DOCX


What's Inside the Notes (12 Sections):


1. INTRODUCTION

Overview of GERD as the most common GI disorder, prevalence (10-30% in Western populations), and economic burden.

2. DEFINITION

GERD is defined as a condition that develops when the reflux of stomach contents causes troublesome symptoms and/or complications. (Montreal Consensus, 2006)

3. ETIOLOGY

Primary Causes:
  • Defective LES (basal tone <6 mmHg) / TLESRs (most important mechanism)
  • Hiatal hernia - displaces LES above diaphragm
  • Impaired esophageal clearance
  • Delayed gastric emptying
  • Defective mucosal defense
Risk Factors Table: Obesity (OR 1.94), pregnancy (progesterone relaxes LES), smoking, alcohol, high-fat diet, medications (anticholinergics, nitrates, CCBs, opioids).

4. PATHOPHYSIOLOGY (FLOWCHART)

TRIGGERING FACTORS (Obesity | Hiatal hernia | Diet | Drugs | Pregnancy)
                        ▼
↓ LES Pressure / Transient LES Relaxations (TLESRs)
(Normal: 10–30 mmHg; in GERD: <6 mmHg)
                        ▼
Retrograde flow of Gastric Contents → Acid + Pepsin ± Bile
                        ▼
Impaired Esophageal Clearance (defective peristalsis + ↓ salivary neutralisation)
                        ▼
Prolonged acid exposure of esophageal mucosa
                        ▼
Mucosal Injury → Inflammation → Erosive Esophagitis → Ulceration
                        ▼
COMPLICATIONS: Strictures | Barrett's Esophagus | Adenocarcinoma

5. CLINICAL FEATURES

Typical (Esophageal):
  • Heartburn - cardinal symptom; burning retrosternal sensation, worse on bending/lying
  • Acid regurgitation - sour/bitter taste
  • Water brash, dysphagia, odynophagia, chest discomfort
Atypical (Extra-esophageal):
  • Chronic cough, hoarseness, asthma exacerbations, dental erosion, globus sensation
Alarm Symptoms (Red Flags):
  • ⚠ Weight loss, progressive dysphagia, haematemesis, melaena, anaemia, age >55 with new onset

6. DIAGNOSIS

InvestigationDetailsWhen Used
Clinical evaluationGERD-Q questionnaire; heartburn ≥2×/week >4 weeksFirst-line
Empirical PPI trial2-4 weeks; symptom resolution confirms diagnosis (~78% sensitivity)Diagnostic & therapeutic
Endoscopy (EGD)LA Classification A-D; detects Barrett's, stricturesAlarm symptoms
24-hr pH monitoringGold standard; AET >6% = abnormalRefractory GERD
pH-ImpedanceDetects acid + non-acid reflux on PPIPPI-refractory GERD
Esophageal manometryLES pressure + peristalsisPre-surgery

7. TREATMENT GOALS

  1. Relieve symptoms
  2. Heal esophageal mucosa
  3. Prevent complications
  4. Maintain remission
  5. Improve quality of life
  6. Minimise adverse effects of therapy

8. NON-PHARMACOLOGICAL TREATMENT

Lifestyle modifications:
  • Avoid triggers: fatty/fried, chocolate, citrus, caffeine, carbonated drinks
  • Smaller, more frequent meals; avoid eating 2-3 hours before bedtime
  • Elevate head of bed 15-20 cm; sleep on left side
  • Lose weight (5-10% reduction significantly reduces symptoms)
  • Stop smoking and alcohol
Surgical:
  • Laparoscopic Nissen Fundoplication (gold standard, 360° wrap, 85-90% success)
  • LINX device (magnetic sphincter augmentation - reversible)
  • TIF (endoscopic, no incision)
  • Roux-en-Y (preferred in obese patients)

9. PHARMACOLOGICAL TREATMENT (Full Detail)

9.1 ANTACIDS

Class intro: OTC agents for rapid, short-term relief. Do not heal mucosa.
MOA flowchart:
Gastric acid (HCl) in stomach lumen
        ▼ (antacid administered)
Chemical neutralisation: Antacid + HCl → Salt + H₂O
(Raises intragastric pH to >4; pepsin inactivated above pH 4)
        ▼
Symptomatic relief in 5–15 min | Duration: 1–2 hours
DrugDoseKey ADRKey DICI
Al(OH)₃400-800 mg after mealsConstipation, phosphate depletionChelation with FQs, tetracyclines, iron (space 2h)Renal impairment, hypophosphataemia
Mg(OH)₂400-1200 mg QIDDiarrhoea, hypermagnesaemiaSame chelationRenal failure
CaCO₃500-1500 mg PRNConstipation, milk-alkali syndromeSame chelationHypercalcaemia
Al-Mg combo5-30 mL after mealsBalanced effectsSameRenal impairment
NaHCO₃300 mg-2 g PRNMetabolic alkalosis, rebound acidityMinimalHypertension, HF, oedema

9.2 H2 RECEPTOR ANTAGONISTS (H2RAs)

Class intro: Competitively block H2 receptors on parietal cells. Reduce nocturnal acid. Famotidine is preferred (ranitidine WITHDRAWN due to NDMA contamination).
MOA flowchart:
Histamine released from ECL cells → Binds H2 receptor
        ▼ (H2RA blocks competitively - reversible)
H2RA competitively blocks H2 receptor on parietal cell
        ▼
↓ cAMP → ↓ protein kinase A activation
        ▼
↓ H⁺/K⁺-ATPase activation → ↓ Acid secretion
(↓ 24h acid by ~70%; mainly suppresses NOCTURNAL acid)
Duration: 6–10 hours
DrugDoseKey ADRKey DICI
Famotidine ★20 mg BDHeadache, fatigue; rare QT (IV)Antacids (space 2h)Renal impairment (dose adjust)
Cimetidine400 mg QIDAntiandrogenic (gynaecomastia, impotence), CNS effectsMAJOR: Warfarin, phenytoin, theophylline (CYP450 inhibitor)Pregnancy, multiple drug patients
Nizatidine150 mg BDMild, similar to famotidineMinimal CYPRenal impairment

9.3 PROTON PUMP INHIBITORS (PPIs) ★ GOLD STANDARD

Class intro: Most effective GERD drugs. Irreversibly inhibit H⁺/K⁺-ATPase. Prodrugs activated in acidic canaliculi. Must be taken 30-60 min before meals. Suppress >90-95% of 24h acid.
MOA flowchart:
PPI administered as INACTIVE PRODRUG (substituted benzimidazole)
        ▼ (absorbed → bloodstream)
Accumulates in acidic secretory canaliculi of parietal cells (pH ~1)
        ▼ (acid-catalysed conversion)
Active SULFENAMIDE formed
        ▼
Forms IRREVERSIBLE covalent disulfide bond with CYSTEINE on H⁺/K⁺-ATPase
        ▼
Complete block of FINAL STEP of acid secretion (regardless of stimulus)
>90% suppression of 24h gastric acid
        ▼
New pump synthesis required for recovery (~18–24h)
Optimal effect after 3–5 days of regular dosing
PPI Pharmacokinetics (Katzung 16th Ed.):
DrugBioavailabilityt½ (h)Dose
Omeprazole40-65%0.5-1.020-40 mg OD (AC)
Esomeprazole>80%1.520-40 mg OD (AC)
Lansoprazole>80%1.0-2.030 mg OD (AC)
DexlansoprazoleNA1.0-2.030-60 mg OD (any time)
Pantoprazole77%1.0-1.940 mg OD (AC)
Rabeprazole52%1.0-2.020 mg OD (AC)
Key ADRs:
  • Short-term: headache, nausea, diarrhoea, constipation
  • Long-term: hypomagnesaemia, fractures (hip/spine - FDA warning), C. difficile infection, B12/Fe/Ca/Mg malabsorption, rebound hyperacidity on discontinuation, hypergastrinaemia
Key Drug Interactions:
  • Clopidogrel: Omeprazole/esomeprazole inhibit CYP2C19 → ↓ clopidogrel activation → ↑ CV risk → Use pantoprazole or rabeprazole instead
  • Atazanavir/Rilpivirine: acid required for absorption → PPIs dramatically reduce levels → Avoid/contraindicated
  • Methotrexate: PPIs inhibit renal tubular secretion → ↑ MTX toxicity
  • Ketoconazole/itraconazole: ↓ antifungal absorption

9.4 POTASSIUM-COMPETITIVE ACID BLOCKERS (P-CABs)

Class intro: Newer class - reversibly block the K⁺-binding site of H⁺/K⁺-ATPase. Faster onset, not a prodrug, no meal timing required. Vonoprazan FDA-approved 2023 for erosive GERD.
MOA flowchart:
Vonoprazan - ACTIVE drug (not a prodrug)
        ▼ (accumulates in canaliculi immediately)
Reversibly blocks K⁺-binding site of H⁺/K⁺-ATPase
(K⁺-competitive inhibition)
        ▼
Faster onset than PPIs | Effective on first dose
No lag period | Can be taken any time (not meal-dependent)
DrugDoseADRNotes
Vonoprazan (Voquezna)20 mg OD (erosive); 10 mg OD (NERD)Hypomagnesaemia, ↑gastrin, CYP2C19 inhibitionNo meal timing needed; reversible

9.5 PROKINETICS

Class intro: Enhance LES tone, peristalsis, and gastric emptying. Used as adjuncts, especially with delayed gastric emptying.
MOA flowchart:
Delayed gastric emptying + ↓ LES tone → prolonged acid exposure
        ▼ (prokinetic administered)
D2 receptor antagonism → disinhibits ACh release from enteric neurons
+ 5-HT4 agonism (metoclopramide) → further ↑ ACh
        ▼
↑ LES pressure | ↑ Esophageal peristalsis | ↑ Gastric emptying
→ Reduced reflux episodes
DrugDoseKey ADRKey CI
Metoclopramide10 mg TID-QID AC (short-term only)Tardive dyskinesia (long-term), EPS, akathisia, drowsiness, QT prolongationParkinson's, epilepsy, GI obstruction
Domperidone10-20 mg TID-QID ACQT prolongation (serious risk), hyperprolactinaemiaCardiac disease/QT prolongation, hepatic impairment
Itopride50 mg TID ACMild: diarrhoea, gynaecomastiaGI obstruction

9.6 MUCOSAL PROTECTIVE AGENTS

DrugMOADoseADRDI
SucralfateBinds ulcer base → protective coating; stimulates PGE2 & mucus1 g QID (30 min AC & HS)Constipation, bezoar (rare)Chelation: FQs, tetracyclines, digoxin (space 2h); needs acid for activation
Gaviscon (alginate-antacid)Forms viscous raft on gastric contents → physical barrier against reflux10-20 mL after mealsWell tolerated; Na contentMinimal; safe in pregnancy
Bismuth subsalicylateCoats mucosa; antimicrobial524 mg QIDBlack stools; salicylate toxicityWarfarin; avoid in aspirin allergy

10. SUMMARY CHART – ALL DRUG CLASSES

Drug ClassKey DrugsMOA BriefFirst-Line?
AntacidsAl(OH)₃, Mg(OH)₂, CaCO₃Chemical neutralisationPRN/mild only
H2RAsFamotidine ★, CimetidineCompetitive H2 block → ↓ cAMPMild-moderate/PRN
PPIs ★★★Omeprazole, Pantoprazole, EsomeprazoleIrreversible H⁺/K⁺-ATPase inhibitionYES - all GERD
P-CABsVonoprazanReversible K⁺-competitive blockEmerging first-line
ProkineticsMetoclopramide, DomperidoneD2 antagonism → ↑ LES, peristalsisAdjunct only
Mucosal protectivesSucralfate, GavisconPhysical barrier / PGE2 stimulationAdjunct/pregnancy
BaclofenBaclofenGABA-B agonist → ↓ TLESRsRefractory GERD

11. STEP-UP TREATMENT ALGORITHM

STEP 1: Lifestyle modifications (ALL patients)
        ▼
STEP 2: Mild/intermittent (<3×/week) → Antacids PRN or Famotidine PRN
        ▼
STEP 3: Moderate/NERD (≥3×/week) → PPI OD × 4–8 weeks (FIRST-LINE)
        ▼
STEP 4: Erosive esophagitis (LA C/D) → PPI BID × 8–12 weeks → Maintenance PPI
        ▼
STEP 5: Refractory → Optimise PPI timing → Switch PPI → Add H2RA at HS → Vonoprazan → Baclofen
        ▼
STEP 6: Surgery (fundoplication / LINX)

12. ROLE OF THE PHARMACIST

Key responsibilities including counselling on PPI timing, identifying the clopidogrel-PPI interaction, monitoring long-term PPI effects, and recognising alarm symptoms for referral.

Sources consulted:
This is a shared conversation. Sign in to Orris to start your own chat.