Adrenal insufficiency medicine pg level create me ppt

Reading File
Reading File
Now let me search the medical library for adrenal insufficiency content and read the python-pptx guide in parallel.
Finding Sources
Reading File
Now let me fetch the most comprehensive medical content on adrenal insufficiency from multiple textbooks in parallel:
Reading File
Reading File
Finding Sources
Excellent content! Now let me get Harrison's detailed content on adrenal insufficiency and also read more from Goldman Cecil:
Reading File
Reading File
I now have very rich content. Let me get Harrison's specific adrenal insufficiency section and treatment details:
Finding Sources
Reading File
I have great diagrams and rich content. Now let me read Harrison's specific adrenal insufficiency section for symptoms/signs and treatment:
Reading File
Reading File
I have rich, comprehensive content from Harrison's and Goldman Cecil. Now I have enough to build an excellent PG-level PPT. Let me create it:
Running Command

mkdir -p /tmp/workspace/adrenal-insufficiency-ppt && ls /tmp/workspace/

Writing File

~/adrenal-insufficiency-ppt/create_ppt.py

from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.util import Inches, Pt
from io import BytesIO

# ─── Color Palette ───────────────────────────────────────────────────
NAVY       = RGBColor(0x0A, 0x2D, 0x5E)   # deep navy - headers/accent
TEAL       = RGBColor(0x00, 0x7A, 0x8A)   # teal - subheaders
GOLD       = RGBColor(0xE8, 0xA8, 0x00)   # gold - highlights
WHITE      = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_GRAY = RGBColor(0xF2, 0xF5, 0xF9)
DARK_GRAY  = RGBColor(0x2D, 0x2D, 0x2D)
RED_ALERT  = RGBColor(0xC0, 0x30, 0x30)
MID_BLUE   = RGBColor(0x1A, 0x5C, 0x9A)
LIGHT_TEAL = RGBColor(0xD0, 0xEE, 0xF3)
LIGHT_NAVY = RGBColor(0xD5, 0xE2, 0xF0)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
blank = prs.slide_layouts[6]

# ─── Helpers ─────────────────────────────────────────────────────────
def add_rect(slide, x, y, w, h, fill_color, alpha=None):
    shape = slide.shapes.add_shape(1, Inches(x), Inches(y), Inches(w), Inches(h))
    shape.fill.solid()
    shape.fill.fore_color.rgb = fill_color
    shape.line.fill.background()
    return shape

def add_textbox(slide, x, y, w, h, text, font_size=18, bold=False,
                color=DARK_GRAY, align=PP_ALIGN.LEFT, italic=False,
                wrap=True, v_anchor=MSO_ANCHOR.TOP):
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = wrap
    tf.vertical_anchor = v_anchor
    tf.margin_left = Pt(4)
    tf.margin_right = Pt(4)
    tf.margin_top = Pt(2)
    tf.margin_bottom = Pt(2)
    p = tf.paragraphs[0]
    p.alignment = align
    run = p.add_run()
    run.text = text
    run.font.size = Pt(font_size)
    run.font.bold = bold
    run.font.italic = italic
    run.font.color.rgb = color
    run.font.name = "Calibri"
    return tf

def add_para(tf, text, font_size=14, bold=False, color=DARK_GRAY,
             align=PP_ALIGN.LEFT, italic=False, space_before=Pt(4)):
    from pptx.util import Pt as _Pt
    p = tf.add_paragraph()
    p.alignment = align
    p.space_before = space_before
    run = p.add_run()
    run.text = text
    run.font.size = _Pt(font_size)
    run.font.bold = bold
    run.font.italic = italic
    run.font.color.rgb = color
    run.font.name = "Calibri"
    return p

def slide_header(slide, title, subtitle=None):
    """Dark navy top bar with title"""
    add_rect(slide, 0, 0, 13.333, 1.1, NAVY)
    add_rect(slide, 0, 1.1, 13.333, 0.06, GOLD)
    add_textbox(slide, 0.3, 0.08, 12.7, 0.85, title,
                font_size=28, bold=True, color=WHITE, align=PP_ALIGN.LEFT,
                v_anchor=MSO_ANCHOR.MIDDLE)
    if subtitle:
        add_rect(slide, 0, 1.16, 13.333, 0.45, LIGHT_NAVY)
        add_textbox(slide, 0.4, 1.16, 12.5, 0.45, subtitle,
                    font_size=15, bold=False, color=NAVY, italic=True,
                    v_anchor=MSO_ANCHOR.MIDDLE)

def bullet_box(slide, x, y, w, h, title, bullets, title_color=TEAL,
               title_size=16, bullet_size=13, bg_color=None):
    if bg_color:
        add_rect(slide, x, y, w, h, bg_color)
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = True
    tf.margin_left = Pt(6)
    tf.margin_right = Pt(4)
    tf.margin_top = Pt(4)
    tf.margin_bottom = Pt(4)
    p = tf.paragraphs[0]
    r = p.add_run()
    r.text = title
    r.font.size = Pt(title_size)
    r.font.bold = True
    r.font.color.rgb = title_color
    r.font.name = "Calibri"
    for b in bullets:
        p2 = tf.add_paragraph()
        r2 = p2.add_run()
        r2.text = "  \u2022  " + b
        r2.font.size = Pt(bullet_size)
        r2.font.color.rgb = DARK_GRAY
        r2.font.name = "Calibri"
        p2.space_before = Pt(3)
    return tf


# ════════════════════════════════════════════════════════════════════
# SLIDE 1 — Title Slide
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, NAVY)
add_rect(s, 0, 2.8, 13.333, 0.08, GOLD)
add_rect(s, 0, 2.88, 13.333, 0.08, TEAL)

# Decorative left accent bar
add_rect(s, 0, 0, 0.35, 7.5, TEAL)
add_rect(s, 0.35, 0, 0.07, 7.5, GOLD)

# Title
tb = s.shapes.add_textbox(Inches(0.9), Inches(0.9), Inches(11.5), Inches(1.8))
tf = tb.text_frame
tf.word_wrap = True
p = tf.paragraphs[0]
p.alignment = PP_ALIGN.LEFT
r = p.add_run(); r.text = "ADRENAL INSUFFICIENCY"
r.font.size = Pt(44); r.font.bold = True
r.font.color.rgb = WHITE; r.font.name = "Calibri"

# Subtitle
add_para(tf, "A Postgraduate Clinical Review", font_size=22, bold=False,
         color=GOLD, align=PP_ALIGN.LEFT, space_before=Pt(8))

# Bottom info box
add_rect(s, 0.9, 3.2, 11.5, 3.6, RGBColor(0x10, 0x3A, 0x70))

tb2 = s.shapes.add_textbox(Inches(1.1), Inches(3.35), Inches(11.1), Inches(3.3))
tf2 = tb2.text_frame; tf2.word_wrap = True
topics = [
    ("Definition & Epidemiology", "Classification: Primary, Secondary, Tertiary"),
    ("Etiology & Pathophysiology", "HPA axis, autoimmune, infections, drugs"),
    ("Clinical Features", "Signs, symptoms, adrenal crisis"),
    ("Diagnosis", "ACTH stimulation test, cortisol assays, imaging"),
    ("Management", "Glucocorticoid & mineralocorticoid replacement, sick day rules"),
]
for title_t, detail_t in topics:
    p3 = tf2.add_paragraph() if tf2.paragraphs[0].runs else tf2.paragraphs[0]
    if not p3.runs:
        r3 = p3.add_run()
    else:
        p3 = tf2.add_paragraph()
        r3 = p3.add_run()
    r3.text = f"  \u25B6  {title_t}  |  {detail_t}"
    r3.font.size = Pt(14); r3.font.color.rgb = LIGHT_TEAL
    r3.font.name = "Calibri"; p3.space_before = Pt(5)

# Source tag
add_textbox(s, 0.9, 7.1, 12, 0.35,
            "Sources: Harrison's Principles of Internal Medicine 22E (2025) | Goldman-Cecil Medicine | Current Surgical Therapy 14e",
            font_size=9, color=RGBColor(0x90, 0xB8, 0xD8), italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 2 — Definition & Classification
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Definition & Classification", "Adrenal Insufficiency (AI) — Failure of adequate cortisol production by the adrenal cortex")

# 3 Column Cards
cards = [
    ("PRIMARY AI\n(Addison's Disease)",
     NAVY, LIGHT_NAVY,
     ["Adrenal gland itself is destroyed",
      "Both cortisol AND aldosterone deficient",
      "ACTH elevated (no feedback)",
      "Hyperpigmentation (melanocyte stimulation by ACTH)",
      "Prevalence: 2 in 10,000",
      "Most common: autoimmune (80%)",
      "Also: TB, fungal, metastases, hemorrhage"]),
    ("SECONDARY AI",
     TEAL, LIGHT_TEAL,
     ["ACTH deficiency from pituitary",
      "Cortisol deficient, aldosterone usually NORMAL",
      "No hyperpigmentation (ACTH low/absent)",
      "Prevalence: 3 in 10,000",
      "Causes: pituitary tumors, surgery, Sheehan's",
      "Irradiation, pituitary apoplexy",
      "No salt wasting (RAAS intact)"]),
    ("TERTIARY AI",
     RGBColor(0x5B, 0x20, 0x8A), RGBColor(0xEB, 0xDF, 0xF5),
     ["CRH deficiency from hypothalamus",
      "Most common cause: exogenous glucocorticoids",
      "HPA axis suppression (0.5-2% of population!)",
      "Dose-, duration-, schedule-dependent",
      "Similar to secondary AI clinically",
      "Withdrawal from steroids key history",
      "ACTH low/normal, cortisol low"]),
]
for i, (title, hdr_col, bg_col, bullets) in enumerate(cards):
    x = 0.3 + i * 4.33
    add_rect(s, x, 1.75, 4.1, 5.45, bg_col)
    add_rect(s, x, 1.75, 4.1, 0.65, hdr_col)
    add_textbox(s, x+0.08, 1.75, 3.95, 0.65, title,
                font_size=13, bold=True, color=WHITE,
                v_anchor=MSO_ANCHOR.MIDDLE)
    tb = s.shapes.add_textbox(Inches(x+0.1), Inches(2.5), Inches(3.9), Inches(4.5))
    tf = tb.text_frame; tf.word_wrap = True
    tf.margin_left = Pt(4); tf.margin_top = Pt(4)
    for b in bullets:
        p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
        if not p2.runs:
            r2 = p2.add_run()
        else:
            p2 = tf.add_paragraph()
            r2 = p2.add_run()
        r2.text = "\u2022  " + b
        r2.font.size = Pt(12); r2.font.color.rgb = DARK_GRAY
        r2.font.name = "Calibri"; p2.space_before = Pt(3)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Harrison's 22E p.3110 | Goldman-Cecil Medicine p.2456",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 3 — Etiology (Primary AI)
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Etiology of Primary Adrenal Insufficiency",
             "Prevalence ~100–200 per million population; autoimmunity dominant in developed countries")

# Left: Autoimmune (biggest block)
add_rect(s, 0.3, 1.75, 5.8, 5.45, LIGHT_NAVY)
add_rect(s, 0.3, 1.75, 5.8, 0.5, NAVY)
add_textbox(s, 0.4, 1.75, 5.6, 0.5, "AUTOIMMUNE (80%)",
            font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb = s.shapes.add_textbox(Inches(0.4), Inches(2.35), Inches(5.6), Inches(4.7))
tf = tb.text_frame; tf.word_wrap = True
tf.margin_left = Pt(4)
autoimmune_pts = [
    "Isolated autoimmune adrenalitis: 30-40%",
    "Autoimmune Polyglandular Syndrome (APS): 60-70%",
    "  - APS1/APECED: AIRE gene mutations (AR); hypoparathyroidism + candidiasis",
    "  - APS2: HLA-DR3 linked; thyroid disease, vitiligo, type 1 DM, premature ovarian failure",
    "21-hydroxylase antibodies: marker of autoimmune AI",
    "Adrenal glands appear SMALL on imaging",
    "X-linked Adrenoleukodystrophy (ALD):",
    "  - 1:20,000 males; ABCD1 gene mutation",
    "  - Accumulation of very-long-chain fatty acids",
    "  - Phenotypes: cerebral ALD, adrenomyeloneuropathy",
]
for b in autoimmune_pts:
    p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf.add_paragraph(); r2 = p2.add_run()
    r2.text = ("\u2022 " if not b.startswith("  ") else "") + b
    r2.font.size = Pt(11.5); r2.font.color.rgb = DARK_GRAY
    r2.font.name = "Calibri"; p2.space_before = Pt(2)

# Right column: Other causes
causes_right = [
    ("INFECTIONS (15%)", TEAL, [
        "Tuberculosis — caseating granulomas",
        "Histoplasmosis, Coccidioidomycosis, Blastomycosis",
        "CMV, M. avium (HIV/AIDS patients)",
        "Adrenal glands LARGE on CT, may calcify"
    ]),
    ("INFILTRATIVE / HEMORRHAGE", MID_BLUE, [
        "Bilateral metastases: lung, breast, kidney, gut",
        "Primary adrenal lymphoma",
        "Intra-adrenal hemorrhage (Waterhouse-Friderichsen in sepsis)",
        "Anticoagulated hospitalized patients at risk"
    ]),
    ("CONGENITAL ADRENAL HYPERPLASIA", RGBColor(0x5B, 0x20, 0x8A), [
        "21-hydroxylase (CYP21A2) — most common",
        "11β-hydroxylase (CYP11B1) deficiency",
        "Salt-wasting crisis in neonates",
        "Girls: virilization in utero"
    ]),
]
y_start = 1.75
for title_c, col_c, bullets_c in causes_right:
    h = 0.45 + len(bullets_c) * 0.38
    add_rect(s, 6.4, y_start, 6.6, h, col_c)
    add_textbox(s, 6.5, y_start + 0.02, 6.4, 0.4,
                title_c, font_size=12, bold=True, color=WHITE,
                v_anchor=MSO_ANCHOR.MIDDLE)
    tb = s.shapes.add_textbox(Inches(6.5), Inches(y_start + 0.44),
                               Inches(6.4), Inches(h - 0.46))
    tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(4)
    for b in bullets_c:
        p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
        if not p2.runs: r2 = p2.add_run()
        else: p2 = tf.add_paragraph(); r2 = p2.add_run()
        r2.text = "\u2022  " + b; r2.font.size = Pt(11.5)
        r2.font.color.rgb = WHITE; r2.font.name = "Calibri"
        p2.space_before = Pt(2)
    y_start += h + 0.12

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Harrison's 22E p.3110–3111 | Goldman-Cecil p.2455–2456",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 4 — Pathophysiology
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Pathophysiology — The HPA Axis",
             "Understanding the feedback loop helps explain the different clinical features of primary vs secondary AI")

# Central HPA Axis Text-Box
add_rect(s, 0.3, 1.75, 8.5, 5.45, WHITE)
add_rect(s, 0.3, 1.75, 8.5, 0.5, NAVY)
add_textbox(s, 0.4, 1.75, 8.3, 0.5, "HPA Axis — Normal Physiology",
            font_size=15, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

tb = s.shapes.add_textbox(Inches(0.45), Inches(2.35), Inches(8.3), Inches(4.7))
tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(6)

steps = [
    ("HYPOTHALAMUS", "Releases CRH (corticotropin-releasing hormone)"),
    ("ANTERIOR PITUITARY", "CRH stimulates ACTH (adrenocorticotropic hormone) secretion from corticotropes"),
    ("ADRENAL CORTEX", "ACTH activates zona fasciculata -> cortisol synthesis and secretion"),
    ("NEGATIVE FEEDBACK", "Cortisol suppresses both CRH and ACTH (short/long loop) maintaining homeostasis"),
    ("STRESS ACTIVATION", "Physical/physiological stress amplifies the axis: cortisol rises to mobilize glucose, maintain BP, suppress immune response"),
    ("CORTISOL FUNCTIONS", "Gluconeogenesis (liver), insulin resistance (muscle), vascular tone (catecholamine sensitivity), immune suppression"),
]
for label, desc in steps:
    p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf.add_paragraph(); r2 = p2.add_run()
    r2.text = f"\u25B6 {label}: "
    r2.font.size = Pt(12.5); r2.font.bold = True; r2.font.color.rgb = NAVY
    r2.font.name = "Calibri"; p2.space_before = Pt(5)
    r3 = p2.add_run(); r3.text = desc
    r3.font.size = Pt(12.5); r3.font.bold = False; r3.font.color.rgb = DARK_GRAY
    r3.font.name = "Calibri"

# Right: Consequences box
add_rect(s, 9.1, 1.75, 3.9, 5.45, LIGHT_TEAL)
add_rect(s, 9.1, 1.75, 3.9, 0.5, TEAL)
add_textbox(s, 9.2, 1.75, 3.7, 0.5, "CONSEQUENCES OF AI",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

tb2 = s.shapes.add_textbox(Inches(9.2), Inches(2.35), Inches(3.6), Inches(4.7))
tf2 = tb2.text_frame; tf2.word_wrap = True; tf2.margin_left = Pt(4)
cons = [
    ("Cortisol deficiency:", ["Hypoglycemia", "Hypotension", "Fatigue, weakness", "Weight loss"]),
    ("Aldosterone deficiency\n(Primary AI only):", ["Hyponatremia", "Hyperkalemia", "Salt craving", "Volume depletion"]),
    ("ACTH excess\n(Primary AI only):", ["Hyperpigmentation", "Skin creases, buccal mucosa", "Scars, areolae"]),
]
for heading, items in cons:
    p = tf2.add_paragraph() if tf2.paragraphs[0].runs else tf2.paragraphs[0]
    if not p.runs: r = p.add_run()
    else: p = tf2.add_paragraph(); r = p.add_run()
    r.text = heading; r.font.size = Pt(12); r.font.bold = True
    r.font.color.rgb = NAVY; r.font.name = "Calibri"; p.space_before = Pt(6)
    for item in items:
        p2 = tf2.add_paragraph(); r2 = p2.add_run()
        r2.text = "  \u2022 " + item; r2.font.size = Pt(11.5)
        r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"
        p2.space_before = Pt(2)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Current Surgical Therapy 14e | Harrison's 22E | Goldman-Cecil p.2456",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 5 — Clinical Features
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Clinical Features of Adrenal Insufficiency",
             "Symptoms are often nonspecific and insidious — high clinical suspicion is key")

# 4 feature cards
feature_data = [
    ("GENERAL / SYSTEMIC", NAVY, [
        "Fatigue and weakness (most common)",
        "Anorexia, nausea, vomiting",
        "Weight loss",
        "Malaise, depression, cognitive impairment",
        "Fever (during crisis)",
    ]),
    ("CARDIOVASCULAR", TEAL, [
        "Orthostatic hypotension",
        "Volume depletion / dehydration",
        "Refractory hypotension (crisis)",
        "Increased pulse rate",
        "Salt craving (primary AI)",
    ]),
    ("METABOLIC / LABORATORY", MID_BLUE, [
        "Hyponatremia (dilutional + mineralocorticoid deficiency)",
        "Hyperkalemia (primary AI: aldosterone deficiency)",
        "Hypoglycemia (especially in secondary AI)",
        "Elevated BUN/creatinine (prerenal)",
        "Mild normocytic anemia, eosinophilia",
        "Elevated plasma renin activity (primary AI)",
    ]),
    ("SKIN / SPECIFIC FEATURES", RGBColor(0x5B, 0x20, 0x8A), [
        "Hyperpigmentation: primary AI ONLY",
        "  - Skin folds, buccal mucosa",
        "  - Scars, lips, areolae, knuckles",
        "  - Due to ACTH/MSH excess",
        "Loss of axillary/pubic hair (women)",
        "Vitiligo (if autoimmune etiology)",
        "NO hyperpigmentation in secondary/tertiary AI",
    ]),
]
for i, (title_f, col_f, blist) in enumerate(feature_data):
    x = 0.3 + (i % 2) * 6.5
    y = 1.75 + (i // 2) * 2.75
    h = 2.55
    add_rect(s, x, y, 6.2, h, WHITE)
    add_rect(s, x, y, 6.2, 0.45, col_f)
    add_textbox(s, x+0.1, y, 6.0, 0.45, title_f,
                font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    tb = s.shapes.add_textbox(Inches(x+0.12), Inches(y+0.48), Inches(5.95), Inches(h-0.52))
    tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(4)
    for b in blist:
        p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
        if not p2.runs: r2 = p2.add_run()
        else: p2 = tf.add_paragraph(); r2 = p2.add_run()
        r2.text = ("\u2022 " if not b.startswith("  ") else "") + b
        r2.font.size = Pt(11.5); r2.font.color.rgb = DARK_GRAY
        r2.font.name = "Calibri"; p2.space_before = Pt(2)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Harrison's 22E Table 398-9 | Goldman-Cecil Table 208-5",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 6 — Adrenal Crisis
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Adrenal Crisis — A Medical Emergency",
             "Life-threatening acute adrenal insufficiency requiring immediate recognition and treatment")

# Red alert banner
add_rect(s, 0.3, 1.75, 12.7, 0.55, RED_ALERT)
add_textbox(s, 0.5, 1.75, 12.5, 0.55,
            "ADRENAL CRISIS: Acute cortisol deficiency precipitated by physiologic stress in a patient with chronic or undiagnosed AI",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

# Precipitants
add_rect(s, 0.3, 2.4, 3.8, 4.8, LIGHT_NAVY)
add_rect(s, 0.3, 2.4, 3.8, 0.45, NAVY)
add_textbox(s, 0.4, 2.4, 3.6, 0.45, "PRECIPITANTS",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
bullet_lines = ["Infection / sepsis (most common)",
                "Surgery / trauma",
                "Major illness / fever",
                "Missed steroid doses",
                "Gastrointestinal illness (vomiting)",
                "Bilateral adrenal hemorrhage",
                "Waterhouse-Friderichsen syndrome\n  (meningococcal septicemia)"]
tb = s.shapes.add_textbox(Inches(0.4), Inches(2.92), Inches(3.6), Inches(4.1))
tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(4)
for b in bullet_lines:
    p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf.add_paragraph(); r2 = p2.add_run()
    r2.text = "\u2022 " + b; r2.font.size = Pt(12)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(3)

# Clinical features
add_rect(s, 4.3, 2.4, 4.1, 4.8, LIGHT_TEAL)
add_rect(s, 4.3, 2.4, 4.1, 0.45, TEAL)
add_textbox(s, 4.4, 2.4, 3.9, 0.45, "CLINICAL FEATURES",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
cf_lines = ["Severe hypotension / shock",
            "Altered consciousness / confusion",
            "Abdominal pain (may mimic acute abdomen)",
            "Vomiting, profound nausea",
            "Hyperpyrexia or hypothermia",
            "Hypoglycemia",
            "Dehydration and volume depletion",
            "Hyponatremia, hyperkalemia (primary AI)"]
tb2 = s.shapes.add_textbox(Inches(4.4), Inches(2.92), Inches(3.9), Inches(4.1))
tf2 = tb2.text_frame; tf2.word_wrap = True; tf2.margin_left = Pt(4)
for b in cf_lines:
    p2 = tf2.add_paragraph() if tf2.paragraphs[0].runs else tf2.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf2.add_paragraph(); r2 = p2.add_run()
    r2.text = "\u2022 " + b; r2.font.size = Pt(12)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(3)

# Immediate treatment
add_rect(s, 8.6, 2.4, 4.4, 4.8, RGBColor(0xFF, 0xF0, 0xF0))
add_rect(s, 8.6, 2.4, 4.4, 0.45, RED_ALERT)
add_textbox(s, 8.7, 2.4, 4.2, 0.45, "EMERGENCY TREATMENT",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
rx_lines = [
    "\u2460  Hydrocortisone 100 mg IV/IM STAT bolus",
    "\u2461  Followed by 200 mg hydrocortisone over 24h",
    "    (continuous infusion preferred)",
    "\u2462  IV Normal Saline 1 L/hour (volume resuscitation)",
    "\u2463  Dextrose if hypoglycemic (5-10% glucose IV)",
    "\u2464  Identify and treat precipitating cause",
    "\u2465  Cardiac monitoring (risk of arrhythmia)",
    "",
    "Note: Dexamethasone 4 mg IV can be used if",
    "cortisol assay needed (does not interfere with assay)",
    "DO NOT DELAY TREATMENT for test results!",
]
tb3 = s.shapes.add_textbox(Inches(8.7), Inches(2.92), Inches(4.1), Inches(4.2))
tf3 = tb3.text_frame; tf3.word_wrap = True; tf3.margin_left = Pt(4)
for b in rx_lines:
    p2 = tf3.add_paragraph() if tf3.paragraphs[0].runs else tf3.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf3.add_paragraph(); r2 = p2.add_run()
    r2.text = b; r2.font.size = Pt(11.5)
    r2.font.color.rgb = RED_ALERT if b.startswith("\u2460") or b.startswith("\u2461") or b.startswith("\u2462") else DARK_GRAY
    r2.font.bold = b.startswith("\u2460") or b.startswith("\u2461") or b.startswith("\u2462")
    r2.font.name = "Calibri"; p2.space_before = Pt(2)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Harrison's 22E p.3113 | ROSEN's Emergency Medicine | Goldman-Cecil p.2457",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 7 — Diagnosis
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Diagnosis of Adrenal Insufficiency",
             "Biochemical confirmation required — random cortisol alone is insufficient for chronic AI")

# Screening / suspicion
add_rect(s, 0.3, 1.75, 6.2, 2.5, LIGHT_NAVY)
add_rect(s, 0.3, 1.75, 6.2, 0.48, NAVY)
add_textbox(s, 0.4, 1.75, 6.0, 0.48, "STEP 1: INITIAL BIOCHEMISTRY",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb = s.shapes.add_textbox(Inches(0.4), Inches(2.3), Inches(6.0), Inches(1.8))
tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(4)
for b in ["Morning serum cortisol (08:00–09:00 h): Best initial test",
          "  >18 mcg/dL (>500 nmol/L) = Normal, AI unlikely",
          "  <3 mcg/dL (<83 nmol/L) = Highly suggestive of AI",
          "  3-18 mcg/dL = Indeterminate -> Proceed to stimulation test",
          "Plasma ACTH: Elevated in primary AI; Low/undetectable in secondary",
          "Urine/salivary cortisol: Less reliable for diagnosis"]:
    p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf.add_paragraph(); r2 = p2.add_run()
    r2.text = b; r2.font.size = Pt(11.5)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(2)

# ACTH Stimulation
add_rect(s, 6.75, 1.75, 6.25, 2.5, LIGHT_TEAL)
add_rect(s, 6.75, 1.75, 6.25, 0.48, TEAL)
add_textbox(s, 6.85, 1.75, 6.05, 0.48, "STEP 2: ACTH STIMULATION TEST (Gold Standard)",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb2 = s.shapes.add_textbox(Inches(6.85), Inches(2.3), Inches(6.05), Inches(1.8))
tf2 = tb2.text_frame; tf2.word_wrap = True; tf2.margin_left = Pt(4)
for b in ["Standard dose: Cosyntropin (Synacthen) 250 mcg IV",
          "Measure cortisol at 0, 30, and 60 minutes",
          "Peak cortisol <18 mcg/dL (immunoassay) = AI confirmed",
          "More specific assay (mass spectrometry): cutoff ~14 mcg/dL",
          "Low-dose test: 1 mcg ACTH — equally sensitive if done in the morning",
          "Metyrapone test: useful for mild/recent secondary AI"]:
    p2 = tf2.add_paragraph() if tf2.paragraphs[0].runs else tf2.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf2.add_paragraph(); r2 = p2.add_run()
    r2.text = b; r2.font.size = Pt(11.5)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(2)

# Additional tests
add_rect(s, 0.3, 4.45, 6.2, 2.75, WHITE)
add_rect(s, 0.3, 4.45, 6.2, 0.48, MID_BLUE)
add_textbox(s, 0.4, 4.45, 6.0, 0.48, "STEP 3: DETERMINE PRIMARY vs SECONDARY",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb3 = s.shapes.add_textbox(Inches(0.4), Inches(5.0), Inches(6.0), Inches(2.0))
tf3 = tb3.text_frame; tf3.word_wrap = True; tf3.margin_left = Pt(4)
for b in ["Plasma ACTH: HIGH = primary AI; LOW = secondary/tertiary AI",
          "21-hydroxylase antibodies: specific for autoimmune etiology",
          "Plasma renin activity: elevated in primary AI (aldosterone deficiency)",
          "Aldosterone: low in primary; normal/high in secondary AI",
          "17-hydroxyprogesterone: elevated in congenital adrenal hyperplasia",
          "Very long chain fatty acids: for adrenoleukodystrophy screening in males"]:
    p2 = tf3.add_paragraph() if tf3.paragraphs[0].runs else tf3.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf3.add_paragraph(); r2 = p2.add_run()
    r2.text = "\u2022 " + b; r2.font.size = Pt(11.5)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(2)

# Imaging
add_rect(s, 6.75, 4.45, 6.25, 2.75, WHITE)
add_rect(s, 6.75, 4.45, 6.25, 0.48, RGBColor(0x5B, 0x20, 0x8A))
add_textbox(s, 6.85, 4.45, 6.05, 0.48, "STEP 4: IMAGING",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb4 = s.shapes.add_textbox(Inches(6.85), Inches(5.0), Inches(6.05), Inches(2.0))
tf4 = tb4.text_frame; tf4.word_wrap = True; tf4.margin_left = Pt(4)
for b in ["CT adrenal glands: Small = autoimmune; Large = infection/metastasis",
          "Calcification suggests TB or old hemorrhage",
          "MRI pituitary: Mandatory in secondary AI (pituitary tumor, Sheehan's)",
          "FDG-PET: Lack of uptake = benign; ACC invariably FDG avid",
          "Bilateral adrenal hemorrhage: hyperintense on MRI (acute blood)"]:
    p2 = tf4.add_paragraph() if tf4.paragraphs[0].runs else tf4.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf4.add_paragraph(); r2 = p2.add_run()
    r2.text = "\u2022 " + b; r2.font.size = Pt(11.5)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(2)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Goldman-Cecil p.2457 | Harrison's 22E p.3112–3113 | Henry's Clinical Diagnosis",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 8 — Chronic Management
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Chronic Management — Glucocorticoid Replacement",
             "Goal: Mimic physiologic cortisol secretion while avoiding over- and under-replacement")

# GC Replacement drugs table
add_rect(s, 0.3, 1.75, 8.4, 0.48, NAVY)
add_textbox(s, 0.4, 1.75, 8.2, 0.48, "GLUCOCORTICOID REPLACEMENT DOSES & EQUIVALENCY",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

# Table headers
headers = ["Drug", "Daily Dose", "Relative Potency", "Duration", "Preferred?"]
col_widths = [2.2, 1.8, 1.9, 1.7, 1.0]
x_pos = [0.3, 2.5, 4.3, 6.2, 7.9]
for i, (h, w) in enumerate(zip(headers, col_widths)):
    add_rect(s, x_pos[i], 2.27, w-0.05, 0.42, MID_BLUE)
    add_textbox(s, x_pos[i]+0.05, 2.27, w-0.1, 0.42, h,
                font_size=11, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE,
                align=PP_ALIGN.CENTER)

rows = [
    ["Hydrocortisone", "15-25 mg/day\n(2-3 doses)", "1x", "Short (8h)", "YES (1st line)"],
    ["Cortisone acetate", "20-35 mg/day\n(2 doses)", "0.8x", "Short (8h)", "Alternative"],
    ["Prednisolone", "3-5 mg/day\n(1-2 doses)", "4x", "Intermediate", "If available"],
    ["Prednisone", "3-5 mg/day\n(1-2 doses)", "4x", "Intermediate", "Not preferred"],
    ["Dexamethasone", "0.25-0.5 mg/day\n(1 dose)", "25-30x", "Long (36h)", "Avoid (excess)"],
]
row_colors = [LIGHT_NAVY, WHITE, LIGHT_NAVY, WHITE, RGBColor(0xFF, 0xEB, 0xEB)]
for ri, (row, rc) in enumerate(zip(rows, row_colors)):
    for ci, (cell, w) in enumerate(zip(row, col_widths)):
        add_rect(s, x_pos[ci], 2.73 + ri*0.52, w-0.05, 0.5, rc)
        add_textbox(s, x_pos[ci]+0.05, 2.73 + ri*0.52, w-0.1, 0.5, cell,
                    font_size=10.5, color=DARK_GRAY, v_anchor=MSO_ANCHOR.MIDDLE,
                    align=PP_ALIGN.CENTER)

# Right column: Key principles
add_rect(s, 8.9, 1.75, 4.1, 5.5, LIGHT_TEAL)
add_rect(s, 8.9, 1.75, 4.1, 0.48, TEAL)
add_textbox(s, 9.0, 1.75, 3.9, 0.48, "KEY PRINCIPLES",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb = s.shapes.add_textbox(Inches(9.0), Inches(2.3), Inches(3.9), Inches(4.7))
tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(4)
for b in [
    "At least 50% of total daily dose in the MORNING (on awakening)",
    "Mimic diurnal rhythm: Higher morning, lower evening doses",
    "Long-acting GCs (dexamethasone) cause excess exposure at night -> avoid",
    "Equipotency guide:\n  1 mg HC = 1.6 mg cortisone acetate\n  = 0.2 mg prednisolone\n  = 0.025 mg dexamethasone",
    "Modified-release hydrocortisone: Better mimics circadian rhythm",
    "Pregnancy: Increase dose by 50% in 3rd trimester",
    "Monitor: Weight, BP, signs of over/under-replacement",
    "Bone health: Doses >=30 mg HC equivalent -> DEXA scan",
]:
    p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf.add_paragraph(); r2 = p2.add_run()
    r2.text = "\u2022  " + b; r2.font.size = Pt(11)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(4)

# Bottom note on mineralocorticoids
add_rect(s, 0.3, 7.0, 8.4, 0.38, LIGHT_NAVY)
add_textbox(s, 0.4, 7.0, 8.2, 0.38,
            "Mineralocorticoid (Fludrocortisone 0.05-0.15 mg/day): Required in PRIMARY AI only | Start when HC dose <50 mg/day",
            font_size=10.5, bold=True, color=NAVY, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox(s, 9.0, 7.1, 4.0, 0.35,
            "Harrison's 22E p.3112-3113 | Lippincott Pharmacology",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 9 — Sick Day Rules & Monitoring
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Sick Day Rules & Long-Term Monitoring",
             "Patient education on dose adjustment during illness is life-saving — all patients must carry emergency information")

# Sick day rules left
add_rect(s, 0.3, 1.75, 6.3, 5.45, WHITE)
add_rect(s, 0.3, 1.75, 6.3, 0.5, NAVY)
add_textbox(s, 0.4, 1.75, 6.1, 0.5, "SICK DAY RULES (Steroid Sick Day Guidelines)",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb = s.shapes.add_textbox(Inches(0.4), Inches(2.32), Inches(6.1), Inches(4.7))
tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(4)
sick_day_rules = [
    ("MILD ILLNESS (fever, bed rest):", ["DOUBLE the usual oral glucocorticoid dose", "Maintain doubled dose until fever resolves", "Never reduce dose during active illness"]),
    ("MODERATE ILLNESS / VOMITING:", ["If unable to retain oral medications ->", "Immediate IM/IV hydrocortisone injection", "100 mg hydrocortisone IM/IV STAT", "Then 200 mg/24h by infusion"]),
    ("SURGERY / MAJOR TRAUMA:", ["Minor surgery: Hydrocortisone 25 mg IV at induction", "Moderate surgery: 25 mg IV + 100 mg over 24h", "Major surgery: 100 mg IV at induction + 200 mg/24h x 1-3 days", "Resume oral dose when tolerating oral intake"]),
    ("EMERGENCY KIT:", ["All patients should carry:", "  - Medical alert card/bracelet", "  - Prednisolone/hydrocortisone tablets",  "  - Hydrocortisone self-injection kit (100 mg)", "  - Especially important for travelers to remote areas"]),
]
for heading_s, items_s in sick_day_rules:
    p = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
    if not p.runs: r = p.add_run()
    else: p = tf.add_paragraph(); r = p.add_run()
    r.text = heading_s; r.font.size = Pt(12); r.font.bold = True
    r.font.color.rgb = NAVY; r.font.name = "Calibri"; p.space_before = Pt(7)
    for item in items_s:
        p2 = tf.add_paragraph(); r2 = p2.add_run()
        r2.text = "  \u2022 " + item; r2.font.size = Pt(11.5)
        r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"
        p2.space_before = Pt(2)

# Monitoring right
add_rect(s, 6.85, 1.75, 6.15, 5.45, LIGHT_TEAL)
add_rect(s, 6.85, 1.75, 6.15, 0.5, TEAL)
add_textbox(s, 6.95, 1.75, 5.95, 0.5, "LONG-TERM MONITORING",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb2 = s.shapes.add_textbox(Inches(6.95), Inches(2.32), Inches(5.95), Inches(4.7))
tf2 = tb2.text_frame; tf2.word_wrap = True; tf2.margin_left = Pt(4)
monitoring_pts = [
    ("Clinical Assessment:", ["Body weight (underreplacement -> weight loss; overreplacement -> gain)", "Blood pressure and orthostatic BP", "Symptoms of over- or underreplacement", "Fatigue, quality of life assessment"]),
    ("Biochemical:", ["Plasma ACTH does NOT guide dose adjustments reliably", "24h urinary free cortisol: confirms compliance, not dose quality", "Serum cortisol day curves: shows HC absorption pattern", "Electrolytes: Na/K in primary AI (adjust fludrocortisone)", "Plasma renin activity: guide fludrocortisone dosing"]),
    ("Autoimmune Screening\n(Primary AI):", ["Autoimmune thyroid disease (annual TSH, anti-TPO)", "Premature ovarian failure screening in women", "Pernicious anemia (B12 levels)", "Type 1 diabetes (HbA1c)"]),
    ("Bone Health:", ["DEXA scan if dose equivalent to >=30 mg HC/day", "Vitamin D and calcium supplementation"]),
]
for heading_m, items_m in monitoring_pts:
    p = tf2.add_paragraph() if tf2.paragraphs[0].runs else tf2.paragraphs[0]
    if not p.runs: r = p.add_run()
    else: p = tf2.add_paragraph(); r = p.add_run()
    r.text = heading_m; r.font.size = Pt(12); r.font.bold = True
    r.font.color.rgb = NAVY; r.font.name = "Calibri"; p.space_before = Pt(7)
    for item in items_m:
        p2 = tf2.add_paragraph(); r2 = p2.add_run()
        r2.text = "  \u2022 " + item; r2.font.size = Pt(11.5)
        r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"
        p2.space_before = Pt(2)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Harrison's 22E p.3113 | Goldman-Cecil p.2458 | Current Surgical Therapy 14e",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 10 — Glucocorticoid-Induced AI + Special Scenarios
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
slide_header(s, "Glucocorticoid-Induced AI & Special Scenarios",
             "Most common cause of AI worldwide — affects 0.5-2% of the population in developed countries")

add_rect(s, 0.3, 1.75, 6.3, 5.45, WHITE)
add_rect(s, 0.3, 1.75, 6.3, 0.5, NAVY)
add_textbox(s, 0.4, 1.75, 6.1, 0.5, "GLUCOCORTICOID-INDUCED (TERTIARY) AI",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb = s.shapes.add_textbox(Inches(0.4), Inches(2.32), Inches(6.1), Inches(4.7))
tf = tb.text_frame; tf.word_wrap = True; tf.margin_left = Pt(4)
for b in [
    "Suppression of HPA axis by exogenous glucocorticoids",
    "Depends on: Dose, duration, schedule, route of administration",
    "Inhaled, topical, intra-articular steroids also can cause suppression",
    "High-risk: >20 mg prednisolone equivalent daily for >3 weeks",
    "Manifestation: Adrenal crisis during illness or following abrupt withdrawal",
    "ACTH is low/undetectable; adrenal glands are small",
    "Recovery of HPA axis: weeks to months after stopping steroids",
    "Gradual tapering reduces risk; monitor cortisol before stopping",
    "Perioperative steroid cover essential for all patients on steroids",
    "Test HPA axis after steroid withdrawal before declaring recovery",
]:
    p2 = tf.add_paragraph() if tf.paragraphs[0].runs else tf.paragraphs[0]
    if not p2.runs: r2 = p2.add_run()
    else: p2 = tf.add_paragraph(); r2 = p2.add_run()
    r2.text = "\u2022  " + b; r2.font.size = Pt(12)
    r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"; p2.space_before = Pt(3)

add_rect(s, 6.85, 1.75, 6.15, 5.45, LIGHT_NAVY)
add_rect(s, 6.85, 1.75, 6.15, 0.5, MID_BLUE)
add_textbox(s, 6.95, 1.75, 5.95, 0.5, "SPECIAL SCENARIOS IN AI",
            font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
tb2 = s.shapes.add_textbox(Inches(6.95), Inches(2.32), Inches(5.95), Inches(4.7))
tf2 = tb2.text_frame; tf2.word_wrap = True; tf2.margin_left = Pt(4)
special_scenarios = [
    ("CRITICAL ILLNESS / SEPTIC SHOCK (CIRCI):", [
        "Critical illness-related corticosteroid insufficiency",
        "No reliable clinical/lab test to confirm CIRCI",
        "Suspect with refractory hypotension despite fluids + vasopressors",
        "ACTH stim test delta cortisol <9 mcg/dL = RAI",
        "Hydrocortisone 200-300 mg/day + fludrocortisone 50 mcg/day x 7 days",
        "2018 meta-analysis: No/limited mortality benefit; reduces vasopressor duration"
    ]),
    ("PREGNANCY:", [
        "Requirement increases by 50% in 3rd trimester",
        "Hydrocortisone preferred (does not cross placenta as much as dexamethasone)",
        "Adrenal crisis risk during labor and delivery -> IV hydrocortisone cover"
    ]),
    ("CONGENITAL ADRENAL HYPERPLASIA:", [
        "21-hydroxylase deficiency most common",
        "Neonatal screening programs detect affected newborns",
        "Salt-wasting crisis in neonates -> emergency hydrocortisone + saline",
        "Long-term: HC replacement to suppress ACTH and excess androgens"
    ]),
]
for heading_sp, items_sp in special_scenarios:
    p = tf2.add_paragraph() if tf2.paragraphs[0].runs else tf2.paragraphs[0]
    if not p.runs: r = p.add_run()
    else: p = tf2.add_paragraph(); r = p.add_run()
    r.text = heading_sp; r.font.size = Pt(12); r.font.bold = True
    r.font.color.rgb = TEAL; r.font.name = "Calibri"; p.space_before = Pt(6)
    for item in items_sp:
        p2 = tf2.add_paragraph(); r2 = p2.add_run()
        r2.text = "  \u2022 " + item; r2.font.size = Pt(11.5)
        r2.font.color.rgb = DARK_GRAY; r2.font.name = "Calibri"
        p2.space_before = Pt(2)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Harrison's 22E p.3113-3114 | Current Surgical Therapy 14e (CIRCI) | Goldman-Cecil p.2455",
            font_size=9, color=TEAL, italic=True)


# ════════════════════════════════════════════════════════════════════
# SLIDE 11 — Summary / Key Takeaways
# ════════════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, NAVY)
add_rect(s, 0, 0, 13.333, 1.1, RGBColor(0x10, 0x3A, 0x70))
add_rect(s, 0, 1.1, 13.333, 0.06, GOLD)

add_textbox(s, 0.4, 0.1, 12.5, 0.9, "KEY TAKEAWAYS — Adrenal Insufficiency",
            font_size=28, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

takeaways = [
    ("EPIDEMIOLOGY", "AI prevalence: ~500/million total (primary 2/10,000; secondary 3/10,000). GC-induced tertiary AI affects 0.5-2% population."),
    ("DIAGNOSIS", "ACTH stimulation test with cosyntropin 250 mcg is the gold standard. Peak cortisol <18 mcg/dL (immunoassay) confirms AI. Morning cortisol <3 mcg/dL is highly specific."),
    ("PRIMARY vs SECONDARY", "Elevated ACTH + low aldosterone + hyperpigmentation = PRIMARY. Low ACTH + normal aldosterone + no hyperpigmentation = SECONDARY/TERTIARY."),
    ("ACUTE CRISIS", "Hydrocortisone 100 mg IV STAT + 200 mg/24h infusion + 1L/h saline. Do not delay treatment for test results. Use dexamethasone if cortisol assay needed."),
    ("CHRONIC REPLACEMENT", "Hydrocortisone 15-25 mg/day in 2-3 divided doses. Biggest dose in the morning. Add fludrocortisone 0.05-0.15 mg/day for primary AI."),
    ("SICK DAY RULES", "Double oral dose for fever/minor illness. IM/IV hydrocortisone if vomiting. All patients carry emergency kit + medical alert."),
    ("STEROID-INDUCED AI", "Most common form worldwide. Gradual taper + HPA testing before discontinuation. Perioperative cover essential."),
    ("MONITORING", "Annual autoimmune screening in primary AI. DEXA if high-dose steroids. Guide fludrocortisone with plasma renin activity."),
]
# Arrange in 2 columns
for i, (heading_t, detail_t) in enumerate(takeaways):
    col = i % 2
    row = i // 2
    x = 0.3 + col * 6.5
    y = 1.3 + row * 1.45
    add_rect(s, x, y, 6.2, 1.32, RGBColor(0x10, 0x3A, 0x70))
    add_rect(s, x, y, 6.2, 0.38, RGBColor(0x1A, 0x5C, 0x9A))
    add_textbox(s, x+0.1, y, 6.0, 0.38, f"\u25B6  {heading_t}",
                font_size=12, bold=True, color=GOLD, v_anchor=MSO_ANCHOR.MIDDLE)
    add_textbox(s, x+0.1, y+0.4, 6.0, 0.9, detail_t,
                font_size=11, color=WHITE, wrap=True, v_anchor=MSO_ANCHOR.TOP)

add_textbox(s, 0.3, 7.1, 12.7, 0.35,
            "Compiled from: Harrison's 22E | Goldman-Cecil Medicine | Current Surgical Therapy 14e | Lippincott Pharmacology | ROSEN's Emergency Medicine",
            font_size=9, color=RGBColor(0x80, 0xB0, 0xD8), italic=True)


# ─── Save ────────────────────────────────────────────────────────────
out = "/tmp/workspace/adrenal-insufficiency-ppt/Adrenal_Insufficiency_PG.pptx"
buf = BytesIO()
prs.save(buf)
with open(out, "wb") as f:
    f.write(buf.getvalue())
print(f"Saved: {out}")
print(f"Slides: {len(prs.slides)}")
Running Command

cd /tmp/workspace/adrenal-insufficiency-ppt && python create_ppt.py

Running Command

ls -lh /tmp/workspace/adrenal-insufficiency-ppt/

Your PG-level presentation on Adrenal Insufficiency is ready:

Adrenal Insufficiency PG

Presentation · PPTX


What's inside — 11 slides, professional design (navy/teal/gold theme):
SlideContent
1Title Slide with topic overview
2Definition & Classification (Primary / Secondary / Tertiary)
3Etiology of Primary AI — autoimmune, infections, CAH, hemorrhage
4Pathophysiology — HPA axis, cortisol functions, consequences of AI
5Clinical Features — systemic, cardiovascular, metabolic, skin/hyperpigmentation
6Adrenal Crisis — precipitants, clinical features, emergency treatment protocol
7Diagnosis — cortisol cutoffs, ACTH stimulation test, differentiating primary vs secondary, imaging
8Chronic Management — GC dose equivalency table, fludrocortisone, key principles
9Sick Day Rules & Long-term Monitoring — steroid doubling, IM injection protocols, autoimmune screening
10Glucocorticoid-Induced AI + Special Scenarios (CIRCI/sepsis, pregnancy, CAH)
11Key Takeaways Summary slide
All content is sourced directly from Harrison's Principles of Internal Medicine 22E (2025), Goldman-Cecil Medicine, Current Surgical Therapy 14e, Lippincott Pharmacology, and ROSEN's Emergency Medicine.
This is a shared conversation. Sign in to Orris to start your own chat.