attachment
attachment
attachment
attachment
attachment

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
analyse_media
analyse_media
analyse_media
Reading Web Page

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

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

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

Writing File

~/gerd-notes/create_gerd_notes.py

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

doc = Document()

# ── Page margins ──────────────────────────────────────────────────────────────
section = doc.sections[0]
section.page_width  = Inches(8.5)
section.page_height = Inches(11)
section.left_margin = section.right_margin = Inches(0.9)
section.top_margin  = section.bottom_margin = Inches(0.8)

# ── Theme colours ─────────────────────────────────────────────────────────────
DARK_BLUE   = RGBColor(0x0D, 0x47, 0xA1)   # main heading
MED_BLUE    = RGBColor(0x15, 0x65, 0xC0)   # sub-heading
TEAL        = RGBColor(0x00, 0x69, 0x7B)   # section accent
ORANGE      = RGBColor(0xE6, 0x51, 0x00)   # drug name accent
DARK_TEXT   = RGBColor(0x21, 0x21, 0x21)
WHITE       = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_BLUE  = RGBColor(0xBB, 0xDE, 0xFB)   # table header bg
LIGHT_GREEN = RGBColor(0xC8, 0xE6, 0xC9)
LIGHT_YELLOW= RGBColor(0xFF, 0xF9, 0xC4)
LIGHT_ORANGE= RGBColor(0xFF, 0xE0, 0xB2)

# ── Helpers ───────────────────────────────────────────────────────────────────
def set_cell_bg(cell, rgb: RGBColor):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    hex_col = f"{rgb.red:02X}{rgb.green:02X}{rgb.blue:02X}"
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), hex_col)
    tcPr.append(shd)

def set_cell_border(cell, **kwargs):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcBorders = OxmlElement('w:tcBorders')
    for edge in ('top','left','bottom','right','insideH','insideV'):
        tag = OxmlElement(f'w:{{edge}}'.replace('{edge}',edge))
        tag.set(qn('w:val'), kwargs.get(edge, 'single'))
        tag.set(qn('w:sz'), '6')
        tag.set(qn('w:space'), '0')
        tag.set(qn('w:color'), '4472C4')
        tcBorders.append(tag)
    tcPr.append(tcBorders)

def para_bg(para, hex_str):
    pPr = para._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'), hex_str)
    pPr.append(shd)

def add_main_heading(doc, text):
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    para_bg(p, '0D47A1')
    run = p.add_run(text)
    run.bold = True
    run.font.size = Pt(16)
    run.font.color.rgb = WHITE
    run.font.name = 'Calibri'
    p.paragraph_format.space_before = Pt(10)
    p.paragraph_format.space_after  = Pt(6)
    return p

def add_section_heading(doc, text, color=MED_BLUE, size=13):
    p = doc.add_paragraph()
    run = p.add_run(text)
    run.bold = True
    run.font.size = Pt(size)
    run.font.color.rgb = color
    run.font.name = 'Calibri'
    p.paragraph_format.space_before = Pt(8)
    p.paragraph_format.space_after  = Pt(3)
    # bottom border
    pPr = p._p.get_or_add_pPr()
    pBdr = OxmlElement('w:pBdr')
    bottom = OxmlElement('w:bottom')
    bottom.set(qn('w:val'), 'single')
    bottom.set(qn('w:sz'), '8')
    bottom.set(qn('w:space'), '1')
    bottom.set(qn('w:color'), '1565C0')
    pBdr.append(bottom)
    pPr.append(pBdr)
    return p

def add_sub_heading(doc, text, color=TEAL, size=11.5):
    p = doc.add_paragraph()
    run = p.add_run(text)
    run.bold = True
    run.font.size = Pt(size)
    run.font.color.rgb = color
    run.font.name = 'Calibri'
    p.paragraph_format.space_before = Pt(5)
    p.paragraph_format.space_after  = Pt(2)
    return p

def add_body(doc, text, bold=False, italic=False, color=DARK_TEXT, size=10.5, bullet=False):
    p = doc.add_paragraph()
    if bullet:
        p.style = doc.styles['List Bullet']
    run = p.add_run(text)
    run.bold = bold
    run.italic = italic
    run.font.size = Pt(size)
    run.font.color.rgb = color
    run.font.name = 'Calibri'
    p.paragraph_format.space_after = Pt(2)
    return p

def add_numbered(doc, text, size=10.5):
    p = doc.add_paragraph(style='List Number')
    run = p.add_run(text)
    run.font.size = Pt(size)
    run.font.color.rgb = DARK_TEXT
    run.font.name = 'Calibri'
    p.paragraph_format.space_after = Pt(2)
    return p

def add_flowchart_box(doc, items, header=None, header_bg=DARK_BLUE, box_bg='EFF6FF', arrow=True):
    """Add a styled 'flowchart' as a 1-col table."""
    rows = len(items) + (1 if header else 0)
    tbl = doc.add_table(rows=rows, cols=1)
    tbl.style = 'Table Grid'
    tbl.alignment = WD_TABLE_ALIGNMENT.CENTER
    row_idx = 0
    if header:
        cell = tbl.cell(row_idx, 0)
        cell.width = Inches(6.2)
        set_cell_bg(cell, header_bg)
        cp = cell.paragraphs[0]
        cp.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run = cp.add_run(header)
        run.bold = True
        run.font.size = Pt(11)
        run.font.color.rgb = WHITE
        run.font.name = 'Calibri'
        row_idx += 1
    for i, item in enumerate(items):
        cell = tbl.cell(row_idx, 0)
        cell.width = Inches(6.2)
        bg = RGBColor(int(box_bg[0:2],16), int(box_bg[2:4],16), int(box_bg[4:6],16))
        set_cell_bg(cell, bg)
        cp = cell.paragraphs[0]
        cp.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run = cp.add_run(item)
        run.font.size = Pt(10.5)
        run.font.color.rgb = DARK_TEXT
        run.font.name = 'Calibri'
        cp.paragraph_format.space_before = Pt(3)
        cp.paragraph_format.space_after  = Pt(3)
        row_idx += 1
        # Add arrow row (except after last item)
        if arrow and i < len(items) - 1:
            tbl.add_row()
            arrow_cell = tbl.cell(row_idx, 0)
            set_cell_bg(arrow_cell, RGBColor(0xFF,0xFF,0xFF))
            ap = arrow_cell.paragraphs[0]
            ap.alignment = WD_ALIGN_PARAGRAPH.CENTER
            ar = ap.add_run('▼')
            ar.font.size = Pt(12)
            ar.font.color.rgb = MED_BLUE
            ap.paragraph_format.space_before = Pt(1)
            ap.paragraph_format.space_after  = Pt(1)
            row_idx += 1
    doc.add_paragraph()

def add_table(doc, headers, rows, header_bg=LIGHT_BLUE, alt_bg=LIGHT_YELLOW, col_widths=None):
    tbl = doc.add_table(rows=1+len(rows), cols=len(headers))
    tbl.style = 'Table Grid'
    tbl.alignment = WD_TABLE_ALIGNMENT.CENTER
    # Header row
    for j, h in enumerate(headers):
        cell = tbl.cell(0, j)
        set_cell_bg(cell, header_bg)
        p = cell.paragraphs[0]
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run = p.add_run(h)
        run.bold = True
        run.font.size = Pt(10)
        run.font.color.rgb = DARK_BLUE
        run.font.name = 'Calibri'
        if col_widths:
            cell.width = col_widths[j]
    # Data rows
    for i, row in enumerate(rows):
        bg = RGBColor(0xFF,0xFF,0xFF) if i%2==0 else alt_bg
        for j, val in enumerate(row):
            cell = tbl.cell(i+1, j)
            set_cell_bg(cell, bg)
            p = cell.paragraphs[0]
            p.alignment = WD_ALIGN_PARAGRAPH.CENTER
            run = p.add_run(str(val))
            run.font.size = Pt(9.5)
            run.font.color.rgb = DARK_TEXT
            run.font.name = 'Calibri'
            if col_widths:
                cell.width = col_widths[j]
    doc.add_paragraph()
    return tbl

def drug_box(doc, drug_name, drug_class, moa_steps, dose, indication, contraindications, adrs, interactions, note=None):
    """Render a styled drug info block."""
    # Drug name banner
    p = doc.add_paragraph()
    para_bg(p, 'E3F2FD')
    run = p.add_run(f'  {drug_name}')
    run.bold = True
    run.font.size = Pt(12)
    run.font.color.rgb = ORANGE
    run.font.name = 'Calibri'
    p.paragraph_format.space_before = Pt(6)
    p.paragraph_format.space_after  = Pt(2)
    # Class
    add_body(doc, f'Class: {drug_class}', bold=True, color=TEAL, size=10.5)
    # MOA flowchart
    add_sub_heading(doc, 'Mechanism of Action (MOA)', color=MED_BLUE, size=10.5)
    add_flowchart_box(doc, moa_steps, box_bg='E8F5E9')
    # Details in small table
    detail_headers = ['Dose', 'Indication', 'Contraindications', 'ADR', 'Drug Interactions']
    detail_rows = [[dose, indication, contraindications, adrs, interactions]]
    add_table(doc, detail_headers, detail_rows,
              header_bg=LIGHT_BLUE,
              alt_bg=RGBColor(0xFF,0xFF,0xFF),
              col_widths=[Inches(1.1), Inches(1.2), Inches(1.4), Inches(1.4), Inches(1.5)])
    if note:
        add_body(doc, f'Note: {note}', italic=True, color=TEAL, size=9.5)

# ══════════════════════════════════════════════════════════════════════════════
#  TITLE PAGE
# ══════════════════════════════════════════════════════════════════════════════
add_main_heading(doc, 'GERD THERAPEUTICS - 3')
add_main_heading(doc, 'GASTROESOPHAGEAL REFLUX DISEASE')
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run('Gastrointestinal System | Pharmacotherapy Notes')
run.italic = True
run.font.size = Pt(11)
run.font.color.rgb = TEAL
doc.add_paragraph()

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 1 – INTRODUCTION
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '1.  INTRODUCTION')
add_body(doc, (
    'Gastroesophageal Reflux Disease (GERD) is one of the most common chronic '
    'digestive disorders worldwide. It occurs when stomach acid or bile repeatedly '
    'flows back (refluxes) into the esophagus — the muscular tube connecting the '
    'mouth and stomach — irritating its lining and producing a wide spectrum of '
    'symptoms and complications.'
), size=10.5)
add_body(doc, (
    'Acid reflux and heartburn occurring more than TWICE a week is a clinical indicator '
    'of GERD. If untreated, it may progress to esophagitis, esophageal stricture, '
    "Barrett's esophagus, and even esophageal adenocarcinoma."
), size=10.5)

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 2 – DEFINITION
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '2.  DEFINITION')
add_body(doc, (
    'GERD is defined as a chronic condition in which stomach acid or bile flows '
    'into the esophagus, causing symptoms and/or mucosal damage at least twice '
    'per week, due to failure of the lower esophageal sphincter (LES) barrier.'
), bold=True, size=10.5)
doc.add_paragraph()

# Epidemiology box
add_sub_heading(doc, 'Epidemiology', color=TEAL)
epi_data = [
    ['Prevalence (Western countries)', 'About 10-20% of the population'],
    ['Weekly symptom frequency (US)', 'Approximately 20%'],
    ['Annual US hospital admissions', 'Approximately 110,000'],
    ['Most common age group', 'Older than 40 years'],
]
add_table(doc, ['Parameter', 'Data'], epi_data,
          header_bg=LIGHT_BLUE, alt_bg=LIGHT_YELLOW,
          col_widths=[Inches(3), Inches(3.5)])

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 3 – ETIOLOGY
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '3.  ETIOLOGY')
etiology_items = [
    '1. Defective LES (Lower Esophageal Sphincter) pressure',
    '2. Delayed gastric emptying',
    '3. Pregnancy',
    '4. Increased volume of gastric acid (pepsin, bile, pancreatic enzymes)',
    '5. Certain medications (e.g. calcium channel blockers, nitrates, anticholinergics)',
    '6. Smoking',
    '7. Obesity / high BMI',
    '8. Fatty / spicy foods — increase gastric volume & decrease LES pressure',
    '9. Achalasia, scleroderma, hiatal hernia',
]
for item in etiology_items:
    add_body(doc, item, bullet=True, size=10.5)

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 4 – PATHOPHYSIOLOGY (FLOWCHART)
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '4.  PATHOPHYSIOLOGY (Flowchart)')

add_sub_heading(doc, '4A.  Lower Esophageal Sphincter (LES) Pressure Mechanism', color=TEAL)
add_flowchart_box(doc,
    [
        'Normal LES: maintained in TONIC (contracted) state → prevents gastric reflux',
        'LES pressure drops below 5 mmHg  OR  transient relaxations occur',
        'Triggers: spicy foods, coffee, orange/tomato juice, fatty meals, smoking, medications',
        'Increased intra-abdominal pressure (coughing, straining, bending, pregnancy)',
        'Atonic LES → free reflux of gastric acid & pepsin into esophagus',
        'Mucosal injury → inflammation → symptoms of GERD',
    ],
    header='LES Dysfunction Pathway', header_bg=DARK_BLUE, box_bg='E3F2FD'
)

add_sub_heading(doc, '4B.  Gastric Emptying Mechanism', color=TEAL)
add_flowchart_box(doc,
    [
        'High fat meal / smoking → delayed gastric emptying',
        'Increased gastric volume & prolonged acid exposure',
        'Increased frequency & amount of gastric fluid available for reflux',
        'Fatty foods additionally DECREASE LES pressure',
        'Combined effect: more acid reflux → GERD symptoms',
    ],
    header='Delayed Gastric Emptying Pathway', header_bg=MED_BLUE, box_bg='E8F5E9'
)

add_sub_heading(doc, '4C.  Overall Pathophysiology Summary', color=TEAL)
add_flowchart_box(doc,
    [
        'TRIGGERING FACTORS (diet, drugs, obesity, pregnancy, stress)',
        'LES dysfunction  +  Delayed gastric emptying',
        'Reflux of acid/pepsin/bile into esophagus',
        'Direct mucosal irritation  +  Impaired esophageal clearance',
        'Esophageal inflammation (esophagitis)',
        'Chronic GERD  →  Stricture / Barrett\'s Esophagus / Adenocarcinoma',
    ],
    header='GERD Pathophysiology — Master Flowchart', header_bg=RGBColor(0x1B,0x5E,0x20), box_bg='F1F8E9'
)

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 5 – CLINICAL FEATURES
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '5.  CLINICAL FEATURES')
add_sub_heading(doc, '5A. Typical (Esophageal) Symptoms', color=TEAL)
typical = [
    ('Heartburn', 'Burning sensation in chest/epigastrium — hallmark symptom'),
    ('Regurgitation', 'Sour/bitter taste in mouth due to acid backflow'),
    ('Water Brash', 'Hypersalivation — reflex salivation to dilute acid'),
    ('Dysphagia', 'Difficulty swallowing — due to esophageal narrowing/inflammation'),
    ('Odynophagia', 'Painful swallowing'),
    ('Chest Pain', 'Non-cardiac chest pain mimicking angina'),
]
add_table(doc, ['Symptom', 'Description'], typical,
          header_bg=LIGHT_BLUE, alt_bg=LIGHT_YELLOW,
          col_widths=[Inches(1.8), Inches(4.5)])

add_sub_heading(doc, '5B. Atypical (Extra-Esophageal) Symptoms', color=TEAL)
atypical = [
    'Chronic cough', 'Hoarseness / voice changes', 'Tachypnea', 'Weight loss',
    'Reflux-induced laryngitis', 'Asthma exacerbations', 'Dental corrosion (enamel erosion)',
]
for s in atypical:
    add_body(doc, s, bullet=True, size=10.5)

add_sub_heading(doc, '5C. Alarm Features (Require Urgent Evaluation)', color=RGBColor(0xC6,0x28,0x28))
alarms = ["Barrett's Esophagus", 'Progressive dysphagia', 'Significant weight loss',
          'GI bleeding / hematemesis', 'Anemia', 'Persistent vomiting']
for s in alarms:
    add_body(doc, s, bullet=True, size=10.5, color=RGBColor(0xC6,0x28,0x28))

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 6 – DIAGNOSIS
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '6.  DIAGNOSIS')
diag_data = [
    ['Esophageal Manometry',
     'Gold standard for LES pressure assessment.\nNarrow flexible pressure-sensitive catheter measures pressure created by esophageal muscles.\nAssesses coordinated muscle movement.'],
    ['Omeprazole Test (PPI Trial)',
     'Empirical PPI therapy × 2 weeks.\nSymptom relief confirms GERD diagnosis.\nSimple, cost-effective first-line diagnostic approach.'],
    ['Esophageal pH Monitoring (Impedance)',
     '24-hour pH probe detects acid reflux episodes.\nMultichannel intraluminal impedance (MII) detects both acid and non-acid reflux.\nGold standard for confirming pathological reflux.'],
    ['Upper GI Endoscopy (EGD)',
     'Visualizes esophageal mucosa directly.\nDiagnoses esophagitis, strictures, Barrett\'s esophagus.\nBiopsy to rule out malignancy.'],
    ['Upper GI Series (Barium Swallow)',
     'X-ray with barium contrast.\nIdentifies hiatal hernia, strictures, motility disorders.'],
]
add_table(doc, ['Diagnostic Test', 'Details'], diag_data,
          header_bg=LIGHT_BLUE, alt_bg=LIGHT_YELLOW,
          col_widths=[Inches(2.2), Inches(4.1)])

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 7 – TREATMENT GOALS
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '7.  TREATMENT GOALS')
goals = [
    'Reduce acid content and secretion in the stomach',
    'Relieve signs and symptoms (especially heartburn and regurgitation)',
    'Heal esophageal mucosa and prevent complications',
    'Minimize adverse drug reactions (ADRs) from therapy',
    'Prevent relapse / maintain remission',
    "Prevent progression to Barrett's esophagus or adenocarcinoma",
]
for g in goals:
    add_numbered(doc, g)

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 8 – NON-PHARMACOLOGICAL TREATMENT
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '8.  NON-PHARMACOLOGICAL TREATMENT (Lifestyle Modifications)')
non_pharm = [
    ('1. Maintain a healthy weight', 'BMI reduction decreases intra-abdominal pressure and LES stress'),
    ('2. Stop smoking and alcohol', 'Both decrease LES tone and increase acid secretion'),
    ('3. Elevate head of bed (6-8 inches)', 'Uses gravity to prevent nocturnal reflux'),
    ('4. Sleep on left side', 'Positions the stomach below the esophagus anatomically'),
    ('5. Do not lie down after meals', 'Wait at least 2-3 hours after eating before lying down'),
    ('6. Eat food slowly & small portions', 'Reduces gastric distension and reflux episodes'),
    ('7. Avoid trigger foods & drinks', 'Spicy food, coffee, tea, alcohol, citrus, tomato, carbonated drinks, chocolate'),
    ('8. Avoid tight-fitting clothing', 'Reduces external pressure on the abdomen'),
    ('9. Take protein-rich diet', 'Proteins increase LES pressure; avoid high-fat meals'),
]
add_table(doc, ['Measure', 'Rationale'], non_pharm,
          header_bg=LIGHT_GREEN, alt_bg=LIGHT_YELLOW,
          col_widths=[Inches(2.4), Inches(4.0)])

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 9 – PHARMACOLOGICAL TREATMENT
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '9.  PHARMACOLOGICAL TREATMENT')

add_body(doc, (
    'Pharmacotherapy of GERD targets reduction of intragastric acidity, promotion of '
    'esophageal mucosal healing, and improvement of gastric motility. The major drug '
    'classes are: Antacids, H2 Receptor Antagonists (H2RAs), Proton Pump Inhibitors (PPIs), '
    'Prokinetics, and Mucosal Protectants.'
), size=10.5)
doc.add_paragraph()

# ─── 9.1 ANTACIDS ────────────────────────────────────────────────────────────
add_sub_heading(doc, '9.1  ANTACIDS', color=MED_BLUE, size=12)
add_body(doc, (
    'Antacids are alkaline compounds that neutralize gastric acid directly and rapidly. '
    'They provide quick symptomatic relief (within minutes) but have a short duration '
    '(1-2 hours). They are the first-choice OTC agents for mild, infrequent GERD symptoms.'
), size=10.5)

add_flowchart_box(doc,
    [
        'Gastric HCl (pH 1-2) causes mucosal irritation',
        'Antacid (weak base) reacts with HCl in the stomach lumen',
        'Neutralization reaction: HCl + Antacid → Salt + Water  (or CO₂)',
        'Gastric pH rises to 4-5 → pepsin inactivated → reduced mucosal damage',
        'Symptom relief: rapid (within minutes)',
    ],
    header='ANTACID — Mechanism of Action (MOA)', header_bg=DARK_BLUE, box_bg='E3F2FD'
)

add_sub_heading(doc, 'Aluminium Hydroxide  [Al(OH)₃]', color=ORANGE, size=11)
al_data = [
    ['Dose', 'Indication', 'Contraindications', 'ADR', 'Drug Interactions'],
    ['600-1200 mg BD (2-4× daily, after meals & at bedtime)',
     'Mild-moderate GERD, heartburn, hyperacidity, peptic ulcer',
     'Hypophosphatemia, dialysis patients, aluminium toxicity, severe renal impairment',
     'Constipation (most common), phosphate depletion (long-term), hypophosphatemia, encephalopathy (renal patients)',
     'Reduces absorption of: tetracyclines, fluoroquinolones, iron, digoxin.\nMay reduce effect of isoniazid'],
]
tbl = doc.add_table(rows=2, cols=5)
tbl.style = 'Table Grid'
tbl.alignment = WD_TABLE_ALIGNMENT.CENTER
for j, h in enumerate(al_data[0]):
    cell = tbl.cell(0,j)
    set_cell_bg(cell, LIGHT_BLUE)
    p = cell.paragraphs[0]
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    r = p.add_run(h); r.bold=True; r.font.size=Pt(9.5); r.font.color.rgb=DARK_BLUE; r.font.name='Calibri'
for j, v in enumerate(al_data[1]):
    cell = tbl.cell(1,j)
    set_cell_bg(cell, RGBColor(0xFF,0xFF,0xFF))
    p = cell.paragraphs[0]
    r = p.add_run(v); r.font.size=Pt(9); r.font.color.rgb=DARK_TEXT; r.font.name='Calibri'
doc.add_paragraph()

add_sub_heading(doc, 'Magnesium Hydroxide  [Mg(OH)₂]', color=ORANGE, size=11)
mg_data = [
    ['400-1600 mg QID (4× daily)',
     'Mild-moderate GERD, heartburn, as laxative (higher doses)',
     'Severe renal failure (accumulation), appendicitis, intestinal obstruction',
     'Diarrhoea (most common), hypermagnesaemia (renal failure), laxative effect',
     'Reduces absorption of: tetracyclines, fluoroquinolones, digoxin, iron, ketoconazole'],
]
tbl2 = doc.add_table(rows=2, cols=5)
tbl2.style = 'Table Grid'
tbl2.alignment = WD_TABLE_ALIGNMENT.CENTER
for j, h in enumerate(al_data[0]):
    cell = tbl2.cell(0,j)
    set_cell_bg(cell, LIGHT_BLUE)
    p = cell.paragraphs[0]
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    r = p.add_run(h); r.bold=True; r.font.size=Pt(9.5); r.font.color.rgb=DARK_BLUE; r.font.name='Calibri'
for j, v in enumerate(mg_data[0]):
    cell = tbl2.cell(1,j)
    set_cell_bg(cell, RGBColor(0xFF,0xFF,0xFF))
    p = cell.paragraphs[0]
    r = p.add_run(v); r.font.size=Pt(9); r.font.color.rgb=DARK_TEXT; r.font.name='Calibri'
doc.add_paragraph()
add_body(doc, 'Clinical Note: Combinations of Al(OH)₃ + Mg(OH)₂ balance constipation and diarrhoea effects (e.g. Maalox, Mylanta).', italic=True, color=TEAL)

# ─── 9.2 H2 RECEPTOR ANTAGONISTS ─────────────────────────────────────────────
add_section_heading(doc, '9.2  H2 RECEPTOR ANTAGONISTS (H2RAs / H2 Blockers)')
add_body(doc, (
    'H2 receptor antagonists competitively block histamine H2 receptors on gastric '
    'parietal cells, reducing basal and meal-stimulated acid secretion. They work in '
    '30-60 minutes and have a duration of 6-10 hours. They are effective for mild-to-moderate '
    'GERD and can be taken prophylactically before meals.'
), size=10.5)

add_flowchart_box(doc,
    [
        'Histamine released from ECL cells in gastric mucosa',
        'Histamine binds to H2 receptors on parietal cells → activates adenylyl cyclase → ↑ cAMP',
        'cAMP activates protein kinase A → stimulates H⁺/K⁺-ATPase (proton pump)',
        'H2 Blocker competitively blocks H2 receptors on parietal cell',
        '↓ cAMP → ↓ Proton pump activity → ↓ HCl secretion (both basal and nocturnal)',
        'Gastric pH rises → symptom relief & mucosal healing',
    ],
    header='H2 RECEPTOR ANTAGONIST — MOA Flowchart', header_bg=MED_BLUE, box_bg='E3F2FD'
)

add_sub_heading(doc, 'Ranitidine (Zantac)', color=ORANGE, size=11)
add_body(doc, 'Status Note: Ranitidine was withdrawn in many countries (2020) due to NDMA impurity concerns. Famotidine is now preferred.', italic=True, color=RGBColor(0xC6,0x28,0x28))
ran_data = [
    ['300 mg OD (or 150 mg BD)',
     'GERD, peptic ulcer disease, Zollinger-Ellison syndrome, stress ulcer prophylaxis',
     'Known hypersensitivity, porphyria',
     'Headache, dizziness, fatigue, diarrhoea, constipation; rare: gynaecomastia, hepatotoxicity, confusion (elderly)',
     'Reduces absorption of ketoconazole/itraconazole; increases levels of warfarin, theophylline, phenytoin (weak CYP interaction)'],
]
tbl3 = doc.add_table(rows=2, cols=5)
tbl3.style = 'Table Grid'
tbl3.alignment = WD_TABLE_ALIGNMENT.CENTER
for j, h in enumerate(al_data[0]):
    cell = tbl3.cell(0,j)
    set_cell_bg(cell, LIGHT_BLUE)
    p = cell.paragraphs[0]
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    r = p.add_run(h); r.bold=True; r.font.size=Pt(9.5); r.font.color.rgb=DARK_BLUE; r.font.name='Calibri'
for j, v in enumerate(ran_data[0]):
    cell = tbl3.cell(1,j)
    set_cell_bg(cell, RGBColor(0xFF,0xFF,0xFF))
    p = cell.paragraphs[0]
    r = p.add_run(v); r.font.size=Pt(9); r.font.color.rgb=DARK_TEXT; r.font.name='Calibri'
doc.add_paragraph()

add_sub_heading(doc, 'Famotidine (Pepcid)', color=ORANGE, size=11)
fam_data = [
    ['20-40 mg BD (for GERD)',
     'GERD, peptic ulcer disease, nocturnal acid breakthrough',
     'Hypersensitivity; dose-reduce in renal impairment',
     'Headache, dizziness, diarrhoea, constipation; QT prolongation (high doses)',
     'Minimal CYP450 interactions; less interaction than cimetidine; reduces absorption of atazanavir, dasatinib'],
]
tbl4 = doc.add_table(rows=2, cols=5)
tbl4.style = 'Table Grid'
tbl4.alignment = WD_TABLE_ALIGNMENT.CENTER
for j, h in enumerate(al_data[0]):
    cell = tbl4.cell(0,j)
    set_cell_bg(cell, LIGHT_BLUE)
    p = cell.paragraphs[0]
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    r = p.add_run(h); r.bold=True; r.font.size=Pt(9.5); r.font.color.rgb=DARK_BLUE; r.font.name='Calibri'
for j, v in enumerate(fam_data[0]):
    cell = tbl4.cell(1,j)
    set_cell_bg(cell, RGBColor(0xFF,0xFF,0xFF))
    p = cell.paragraphs[0]
    r = p.add_run(v); r.font.size=Pt(9); r.font.color.rgb=DARK_TEXT; r.font.name='Calibri'
doc.add_paragraph()

add_sub_heading(doc, 'Cimetidine (Tagamet)', color=ORANGE, size=11)
cim_data = [
    ['400-800 mg BD-QID',
     'GERD, peptic ulcer, Zollinger-Ellison syndrome',
     'Porphyria, renal/hepatic impairment, pregnancy, breastfeeding',
     'Gynaecomastia, impotence, confusion (elderly), diarrhoea, headache',
     'Strong CYP450 inhibitor: increases levels of warfarin, theophylline, phenytoin, diazepam, lidocaine, propranolol'],
]
tbl5 = doc.add_table(rows=2, cols=5)
tbl5.style = 'Table Grid'
tbl5.alignment = WD_TABLE_ALIGNMENT.CENTER
for j, h in enumerate(al_data[0]):
    cell = tbl5.cell(0,j)
    set_cell_bg(cell, LIGHT_BLUE)
    p = cell.paragraphs[0]
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    r = p.add_run(h); r.bold=True; r.font.size=Pt(9.5); r.font.color.rgb=DARK_BLUE; r.font.name='Calibri'
for j, v in enumerate(cim_data[0]):
    cell = tbl5.cell(1,j)
    set_cell_bg(cell, RGBColor(0xFF,0xFF,0xFF))
    p = cell.paragraphs[0]
    r = p.add_run(v); r.font.size=Pt(9); r.font.color.rgb=DARK_TEXT; r.font.name='Calibri'
doc.add_paragraph()

# ─── 9.3 PROTON PUMP INHIBITORS ───────────────────────────────────────────────
add_section_heading(doc, '9.3  PROTON PUMP INHIBITORS (PPIs)')
add_body(doc, (
    'PPIs are the MOST EFFECTIVE drugs for GERD. They irreversibly (covalently) block '
    'the H⁺/K⁺-ATPase (proton pump) on the parietal cell — the final common pathway of '
    'acid secretion — achieving >90% suppression of gastric acid. They are prodrugs '
    'activated in the acidic environment of secretory canaliculi. PPIs are superior to '
    'H2 blockers for healing erosive esophagitis and maintaining remission.'
), size=10.5)

add_flowchart_box(doc,
    [
        'PPI administered as an inactive PRODRUG (acid-labile; enteric-coated or delayed-release)',
        'Absorbed in small intestine → enters bloodstream → reaches parietal cell canaliculus',
        'In acid environment (pH < 2) of secretory canaliculus → prodrug is PROTONATED → active sulfenamide',
        'Sulfenamide reacts with cysteine residues of H⁺/K⁺-ATPase (proton pump) via disulfide bond',
        'IRREVERSIBLE inhibition of the proton pump → >90% suppression of gastric acid',
        'Acid suppression lasts 18-24 hours (until new pump molecules are synthesized)',
        'Best taken 30-60 min BEFORE first meal of the day for maximum efficacy',
    ],
    header='PROTON PUMP INHIBITOR — MOA Flowchart', header_bg=RGBColor(0x1A,0x23,0x7E), box_bg='EDE7F6'
)

def ppi_table(doc, name, dose, indication, contra, adr, interactions, headers):
    t = doc.add_table(rows=2, cols=5)
    t.style = 'Table Grid'
    t.alignment = WD_TABLE_ALIGNMENT.CENTER
    for j, h in enumerate(headers):
        cell = t.cell(0,j)
        set_cell_bg(cell, LIGHT_BLUE)
        p = cell.paragraphs[0]
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        r = p.add_run(h); r.bold=True; r.font.size=Pt(9.5); r.font.color.rgb=DARK_BLUE; r.font.name='Calibri'
    for j, v in enumerate([dose, indication, contra, adr, interactions]):
        cell = t.cell(1,j)
        set_cell_bg(cell, RGBColor(0xFF,0xFF,0xFF))
        p = cell.paragraphs[0]
        r = p.add_run(v); r.font.size=Pt(9); r.font.color.rgb=DARK_TEXT; r.font.name='Calibri'
    doc.add_paragraph()

ppi_headers = ['Dose', 'Indication', 'Contraindications', 'ADR', 'Drug Interactions']

add_sub_heading(doc, 'Omeprazole (Prilosec)', color=ORANGE, size=11)
add_body(doc, 'Prototype PPI — most widely used; first PPI to market.', italic=True, color=TEAL, size=9.5)
ppi_table(doc, 'Omeprazole',
    '20-40 mg OD (30-60 min before breakfast); up to 40 mg BD for severe GERD',
    'GERD, erosive esophagitis, PUD, H. pylori eradication (triple therapy), Zollinger-Ellison',
    'Hypersensitivity, severe hepatic impairment; avoid with HIV antiretrovirals (rilpivirine, atazanavir)',
    'Headache, diarrhoea, nausea, abdominal pain; long-term: hypomagnesaemia, C. diff infection, osteoporosis/fractures, B12 deficiency, community-acquired pneumonia',
    'Inhibits CYP2C19: increases clopidogrel, methotrexate, tacrolimus levels; reduces absorption of ketoconazole, atazanavir; increases digoxin levels',
    ppi_headers)

add_sub_heading(doc, 'Pantoprazole (Protonix)', color=ORANGE, size=11)
add_body(doc, 'Preferred PPI for IV use; fewer drug interactions.', italic=True, color=TEAL, size=9.5)
ppi_table(doc, 'Pantoprazole',
    '40 mg OD (oral) or IV; 40 mg BD for severe/refractory GERD',
    'GERD, erosive esophagitis, stress ulcer prophylaxis (IV), Zollinger-Ellison syndrome',
    'Hypersensitivity; caution in severe hepatic disease',
    'Headache, diarrhoea, flatulence; same class-effects as above (hypomagnesaemia, B12 deficiency, C. diff, fractures)',
    'Minimal CYP2C19 interaction; fewer interactions than omeprazole; monitor methotrexate',
    ppi_headers)

add_sub_heading(doc, 'Lansoprazole (Prevacid)', color=ORANGE, size=11)
ppi_table(doc, 'Lansoprazole',
    '15-30 mg OD (before breakfast)',
    'GERD, PUD, H. pylori eradication, NSAID-induced ulcer prophylaxis',
    'Hypersensitivity; reduce dose in severe hepatic impairment',
    'Diarrhoea, abdominal pain, headache, nausea; long-term class effects',
    'CYP2C19 substrate; increases levels of warfarin, theophylline; reduces ketoconazole absorption',
    ppi_headers)

add_sub_heading(doc, 'Rabeprazole (Aciphex)', color=ORANGE, size=11)
ppi_table(doc, 'Rabeprazole',
    '20 mg OD',
    'GERD, erosive esophagitis, PUD, Zollinger-Ellison',
    'Hypersensitivity, severe hepatic impairment',
    'Headache, nausea, diarrhoea; same class effects',
    'Less CYP2C19 metabolism than omeprazole; fewer interactions with clopidogrel',
    ppi_headers)

add_sub_heading(doc, 'Esomeprazole (Nexium)', color=ORANGE, size=11)
add_body(doc, 'S-isomer of omeprazole; slightly superior healing rates.', italic=True, color=TEAL, size=9.5)
ppi_table(doc, 'Esomeprazole',
    '20-40 mg OD',
    'GERD, erosive esophagitis, H. pylori eradication, NSAID ulcer prevention',
    'Hypersensitivity; avoid with rilpivirine, atazanavir',
    'Headache, diarrhoea, nausea; class effects with long-term use',
    'CYP2C19 inhibitor; may increase clopidogrel, methotrexate; reduces atazanavir levels',
    ppi_headers)

# ─── 9.4 PROKINETICS ──────────────────────────────────────────────────────────
add_section_heading(doc, '9.4  PROKINETIC AGENTS')
add_body(doc, (
    'Prokinetics enhance gastric motility and accelerate gastric emptying, reducing '
    'the volume of gastric contents available for reflux. They also increase LES tone. '
    'Used as adjuncts in GERD, especially when delayed gastric emptying is a contributing factor.'
), size=10.5)

add_flowchart_box(doc,
    [
        'Dopamine (D2 receptor) in the GI tract INHIBITS gastric motility',
        'Prokinetics BLOCK D2 receptors in the enteric nervous system',
        '↑ Acetylcholine release → enhanced gastric motility',
        '↑ Gastric emptying rate → ↓ gastric volume → ↓ reflux episodes',
        'Some agents (metoclopramide) also increase LES pressure',
    ],
    header='PROKINETIC AGENTS — MOA Flowchart', header_bg=RGBColor(0x33,0x69,0x1E), box_bg='F9FBE7'
)

add_sub_heading(doc, 'Metoclopramide (Reglan)', color=ORANGE, size=11)
ppi_table(doc, 'Metoclopramide',
    '10 mg TDS (3× daily, 30 min before meals)',
    'GERD with delayed gastric emptying, nausea/vomiting, gastroparesis',
    'GI obstruction, perforation, haemorrhage; pheochromocytoma; Parkinson\'s disease; prolactin-dependent tumours',
    'Extrapyramidal symptoms (EPS), tardive dyskinesia (long-term), drowsiness, restlessness, galactorrhoea, amenorrhoea',
    'Additive CNS depression with sedatives; antagonizes dopaminergic drugs (levodopa); affects absorption of other drugs by altering GI transit',
    ppi_headers)

add_sub_heading(doc, 'Domperidone (Motilium)', color=ORANGE, size=11)
ppi_table(doc, 'Domperidone',
    '10 mg TDS (before meals)',
    'GERD, nausea/vomiting, gastroparesis; preferred over metoclopramide (does not cross BBB)',
    'Cardiac arrhythmias (QT prolongation), severe hepatic impairment, prolactin-secreting pituitary tumour',
    'QT prolongation (risk of arrhythmia), galactorrhoea, hyperprolactinaemia; minimal CNS effects (does not cross BBB)',
    'Avoid co-administration with QT-prolonging drugs (amiodarone, azithromycin); CYP3A4 substrate — levels increased by azole antifungals, macrolides',
    ppi_headers)

# ─── 9.5 MUCOSAL PROTECTANTS ──────────────────────────────────────────────────
add_section_heading(doc, '9.5  MUCOSAL PROTECTANTS / OTHERS')

add_sub_heading(doc, 'Sucralfate', color=ORANGE, size=11)
add_body(doc, 'Aluminium salt of sucrose octasulfate. Works locally — not systemically absorbed.', italic=True, color=TEAL, size=9.5)
add_flowchart_box(doc,
    [
        'Sucralfate (polyanionic) → In acid pH (< 4), forms viscous, sticky gel',
        'Gel adheres to ulcer/erosion craters (selective affinity for damaged mucosa)',
        'Forms protective physical barrier against acid, pepsin, and bile',
        'Additionally stimulates prostaglandin synthesis and mucus secretion',
        'Mucosal healing occurs under protective barrier',
    ],
    header='SUCRALFATE — MOA Flowchart', header_bg=RGBColor(0x4A,0x14,0x8C), box_bg='F3E5F5'
)
ppi_table(doc, 'Sucralfate',
    '1 g QID (1 hour before meals and at bedtime), on empty stomach',
    'Duodenal/gastric ulcers, GERD (adjunct), stress ulcer prophylaxis',
    'Aluminium accumulation (renal failure); avoid in dysphagia (tablet may obstruct)',
    'Constipation (most common), nausea, dry mouth, aluminium toxicity in renal failure',
    'Reduces absorption of: ciprofloxacin, norfloxacin, tetracyclines, ketoconazole, digoxin, warfarin, phenytoin (administer 2 hours apart)',
    ppi_headers)

add_sub_heading(doc, 'Alginate-based preparations (e.g. Gaviscon)', color=ORANGE, size=11)
add_body(doc, 'Alginate + antacid → forms viscous floating raft on gastric contents → physical barrier against reflux. Useful in pregnancy and mild GERD.', size=10.5)

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 10 – SUMMARY CHART
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '10.  SUMMARY CHART — PHARMACOLOGICAL TREATMENT OF GERD')
doc.add_paragraph()

summary_headers = ['Drug Class', 'Examples', 'Dose', 'MOA (Short)', 'Key ADR', 'Key Drug Interaction', 'Indication']
summary_rows = [
    ['Antacids', 'Aluminium Hydroxide', '600-1200 mg BD', 'Neutralises gastric HCl', 'Constipation, hypophosphatemia', 'Tetracyclines, fluoroquinolones, digoxin (↓ absorption)', 'Mild GERD, heartburn'],
    ['Antacids', 'Magnesium Hydroxide', '400-1600 mg QID', 'Neutralises gastric HCl', 'Diarrhoea, hypermagnesaemia (RF)', 'Tetracyclines, fluoroquinolones, digoxin (↓ absorption)', 'Mild GERD, constipation'],
    ['H2 Receptor Antagonist', 'Ranitidine', '300 mg OD', 'Blocks H2 receptor on parietal cell → ↓ acid', 'Headache, diarrhoea, confusion (elderly)', 'Ketoconazole ↓; weak CYP — warfarin, theophylline ↑', 'Mild-moderate GERD, PUD'],
    ['H2 Receptor Antagonist', 'Famotidine', '20-40 mg BD', 'Blocks H2 receptor → ↓ cAMP → ↓ acid', 'Headache, QT prolongation (high dose)', 'Atazanavir, dasatinib ↓ absorption', 'GERD, nocturnal acid'],
    ['H2 Receptor Antagonist', 'Cimetidine', '400-800 mg BD-QID', 'Blocks H2 receptor → ↓ acid', 'Gynaecomastia, confusion, diarrhoea', 'Strong CYP inhibitor: warfarin, phenytoin, theophylline ↑', 'GERD, PUD (less preferred)'],
    ['Proton Pump Inhibitor', 'Omeprazole', '20-40 mg OD', 'Irreversible H+/K+-ATPase inhibition', 'Hypomagnesaemia, B12↓, fractures, C. diff', 'Clopidogrel ↓ efficacy; ketoconazole ↓ absorption', 'Erosive GERD, PUD, H. pylori'],
    ['Proton Pump Inhibitor', 'Pantoprazole', '40 mg OD/BD', 'Irreversible H+/K+-ATPase inhibition', 'Same as above (class effects)', 'Fewer interactions; monitor methotrexate', 'GERD, IV stress ulcer ppx'],
    ['Proton Pump Inhibitor', 'Lansoprazole', '15-30 mg OD', 'Irreversible H+/K+-ATPase inhibition', 'Diarrhoea, headache, class effects', 'Warfarin ↑, ketoconazole ↓', 'GERD, PUD, H. pylori'],
    ['Proton Pump Inhibitor', 'Esomeprazole', '20-40 mg OD', 'Irreversible H+/K+-ATPase inhibition', 'Headache, nausea, class effects', 'Clopidogrel ↓; atazanavir ↓', 'GERD, erosive esophagitis'],
    ['Prokinetic', 'Metoclopramide', '10 mg TDS', 'D2 blockade → ↑ GI motility & LES tone', 'EPS, tardive dyskinesia, drowsiness', 'Additive CNS depression; ↓ levodopa efficacy', 'GERD + delayed gastric emptying'],
    ['Prokinetic', 'Domperidone', '10 mg TDS', 'D2 blockade (peripheral) → ↑ GI motility', 'QT prolongation, galactorrhoea', 'Avoid QT-prolonging drugs; CYP3A4 substrate', 'GERD, gastroparesis, nausea'],
    ['Mucosal Protectant', 'Sucralfate', '1 g QID', 'Forms protective gel barrier on mucosa', 'Constipation, Al toxicity (RF)', 'Fluoroquinolones, tetracyclines, digoxin (↓ absorption)', 'PUD, GERD adjunct, pregnancy'],
]

add_table(doc, summary_headers, summary_rows,
          header_bg=DARK_BLUE,
          alt_bg=LIGHT_YELLOW,
          col_widths=[Inches(1.2), Inches(1.0), Inches(0.8), Inches(1.3), Inches(1.2), Inches(1.4), Inches(1.0)])

# Fix header text color to white
tbl_sum = doc.tables[-1]
for j in range(len(summary_headers)):
    cell = tbl_sum.cell(0,j)
    for para in cell.paragraphs:
        for run in para.runs:
            run.font.color.rgb = WHITE
            run.bold = True

# ══════════════════════════════════════════════════════════════════════════════
#  SECTION 11 – SURGICAL TREATMENT (brief)
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, '11.  SURGICAL TREATMENT (Brief Note)')
add_body(doc, 'Considered when pharmacological treatment fails, patient cannot tolerate medications, or complications develop.', size=10.5)
surgical = [
    ('Nissen Fundoplication', 'Laparoscopic — wrap of gastric fundus around lower esophagus to strengthen LES. Most common surgical approach.'),
    ('LINX Magnetic Sphincter Augmentation', 'Magnetic ring placed around LES to augment closure; minimally invasive.'),
    ('Transoral Incisionless Fundoplication (TIF)', 'Endoscopic procedure; no external incision.'),
    ('Bariatric Surgery', 'For morbidly obese patients — weight loss significantly reduces GERD.'),
]
add_table(doc, ['Procedure', 'Description'], surgical,
          header_bg=TEAL, alt_bg=LIGHT_YELLOW,
          col_widths=[Inches(2.4), Inches(4.0)])

# Fix header text color
tbl_surg = doc.tables[-1]
for j in range(2):
    cell = tbl_surg.cell(0,j)
    for para in cell.paragraphs:
        for run in para.runs:
            run.font.color.rgb = WHITE
            run.bold = True

# ══════════════════════════════════════════════════════════════════════════════
#  FOOTER NOTE
# ══════════════════════════════════════════════════════════════════════════════
doc.add_paragraph()
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
para_bg(p, '0D47A1')
run = p.add_run('Sources: Pharmdguru.com | Katzung Basic & Clinical Pharmacology 16e | Sleisenger & Fordtran GI Disease')
run.font.size = Pt(8.5)
run.font.color.rgb = WHITE
run.font.name = 'Calibri'
run.italic = True

# ── SAVE ──────────────────────────────────────────────────────────────────────
doc.save('/tmp/workspace/gerd-notes/GERD_Therapeutics_3_Notes.docx')
print('SAVED OK')
Running Command

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

Editing File

~/gerd-notes/create_gerd_notes.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/gerd-notes/create_gerd_notes.py'
Running Command

cd /tmp/workspace/gerd-notes && python3 -c "from docx.shared import RGBColor; c=RGBColor(0x0D,0x47,0xA1); print(type(c)); print(dir(c))"

Running Command

python3 -c "from docx.shared import RGBColor; c=RGBColor(0x0D,0x47,0xA1); print(str(c)); print(c[0],c[1],c[2])"

Editing File

~/gerd-notes/create_gerd_notes.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/gerd-notes/create_gerd_notes.py'
Editing File

~/gerd-notes/create_gerd_notes.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/gerd-notes/create_gerd_notes.py'
Editing File

~/gerd-notes/create_gerd_notes.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/gerd-notes/create_gerd_notes.py'
Running Command

grep -n "RGBColor(0xFF" /tmp/workspace/gerd-notes/create_gerd_notes.py | head -30

Running Command

cd /tmp/workspace/gerd-notes && sed -i "s/RGBColor(0xFF,0xFF,0xFF)/RGBColor.from_string('FFFFFF')/g" create_gerd_notes.py && sed -i "s/RGBColor(0xFF, 0xFF, 0xFF)/RGBColor.from_string('FFFFFF')/g" create_gerd_notes.py && python3 create_gerd_notes.py 2>&1

Running Command

ls -lh /tmp/workspace/gerd-notes/ && python3 -c " from docx import Document doc = Document('/tmp/workspace/gerd-notes/GERD_Therapeutics_3_Notes.docx') headings = [p.text for p in doc.paragraphs if p.style.name.startswith('Heading') or p.text.strip().startswith(('1.','2.','3.','4.','5.','6.','7.','8.','9.','10.','11.'))] print('Paragraphs total:', len(doc.paragraphs)) print('Tables total:', len(doc.tables)) print() print('Sample headings/sections:') for h in headings[:20]: if h.strip(): print(' -', h[:80]) "

Your comprehensive GERD Therapeutics 3 notes are ready:

GERD Therapeutics 3 Notes

Word Document · DOCX


What's Inside the Document

The notes cover all 11 sections you requested, fully formatted with colored headings, flowcharts as styled tables, and drug detail tables:
SectionContent
1. IntroductionWhat GERD is, clinical indicator (>2x/week), complications
2. DefinitionFormal definition + Epidemiology table (10-20% prevalence, 110,000 US admissions/yr)
3. EtiologyAll 9 causes: defective LES, delayed gastric emptying, pregnancy, gastric acid volume, medications, smoking, obesity, fatty foods, achalasia/scleroderma
4. Pathophysiology3 separate flowcharts: LES dysfunction pathway, delayed gastric emptying pathway, master summary flowchart
5. Clinical FeaturesTypical symptoms table + atypical extra-esophageal symptoms + alarm features
6. Diagnosis5 tests: Esophageal Manometry, Omeprazole Test, pH monitoring (impedance), Endoscopy, Barium swallow
7. Treatment Goals6 goals listed
8. Non-Pharmacological9-point lifestyle table with rationale for each
9. Pharmacological TreatmentFull drug info for each:
Antacids - Al(OH)₃, Mg(OH)₂ with MOA flowchart + dose/indication/contraindication/ADR/interactions
H2 Blockers - Ranitidine, Famotidine, Cimetidine with MOA flowchart
PPIs - Omeprazole, Pantoprazole, Lansoprazole, Rabeprazole, Esomeprazole with detailed MOA flowchart (prodrug activation mechanism)
Prokinetics - Metoclopramide, Domperidone with D2 blockade MOA flowchart
Mucosal Protectants - Sucralfate with gel barrier MOA flowchart
10. Summary ChartMaster table covering all 12 drugs across all classes (dose, MOA, key ADR, drug interactions, indication)
11. Surgical TreatmentFundoplication, LINX, TIF, bariatric surgery
Sources: Your textbook images (PharmD Guru), Katzung Basic & Clinical Pharmacology 16e, Sleisenger & Fordtran GI Disease.
This is a shared conversation. Sign in to Orris to start your own chat.