create easily understandable notes with this

Asking for Preferences
Reading File
Running Command

ls -la "/home/daytona/workspace/attachments/0783a059-11f7-4ce0-9e21-21d3afce76e0/" && file "/home/daytona/workspace/attachments/0783a059-11f7-4ce0-9e21-21d3afce76e0/PATHO 7th.pages"

Running Command

mkdir -p /home/daytona/workspace/patho-notes && cd /home/daytona/workspace/patho-notes && unzip -o "/home/daytona/workspace/attachments/0783a059-11f7-4ce0-9e21-21d3afce76e0/PATHO 7th.pages" -d pages_extracted/ && ls pages_extracted/

Running Command

# Try to extract readable text from the binary .iwa files using strings strings /home/daytona/workspace/patho-notes/pages_extracted/Index/Document.iwa | head -200

Running Command

# Extract all readable text from all .iwa files strings /home/daytona/workspace/patho-notes/pages_extracted/Index/Document.iwa > /home/daytona/workspace/patho-notes/raw_text.txt wc -l /home/daytona/workspace/patho-notes/raw_text.txt

Reading File
Reading File
Reading File
Reading File
Reading File
Writing File

~/patho-notes/generate_notes.py

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, ListItem, ListFlowable
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY

OUTPUT = "/home/daytona/workspace/patho-notes/PATHO_7th_Week_Notes.pdf"

doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    rightMargin=2*cm, leftMargin=2*cm,
    topMargin=2*cm, bottomMargin=2*cm
)

# ── Colour palette ──────────────────────────────────────────────────
C_DARK_BLUE  = colors.HexColor("#1A3A5C")
C_MED_BLUE   = colors.HexColor("#2E6DA4")
C_LIGHT_BLUE = colors.HexColor("#D6E8F7")
C_ORANGE     = colors.HexColor("#E07B2A")
C_YELLOW_BG  = colors.HexColor("#FFF8DC")
C_GREEN_BG   = colors.HexColor("#E8F5E9")
C_RED_BG     = colors.HexColor("#FFEBEE")
C_PURPLE     = colors.HexColor("#6A1B9A")
C_GRAY_BG    = colors.HexColor("#F5F5F5")
C_WHITE      = colors.white
C_BLACK      = colors.black

styles = getSampleStyleSheet()

def sty(name, **kw):
    s = ParagraphStyle(name, **kw)
    return s

COVER_TITLE = sty("COVER_TITLE",
    fontName="Helvetica-Bold", fontSize=26, textColor=C_WHITE,
    alignment=TA_CENTER, spaceAfter=6)
COVER_SUB = sty("COVER_SUB",
    fontName="Helvetica", fontSize=14, textColor=C_LIGHT_BLUE,
    alignment=TA_CENTER, spaceAfter=4)

H1 = sty("H1",
    fontName="Helvetica-Bold", fontSize=16, textColor=C_WHITE,
    backColor=C_DARK_BLUE, alignment=TA_LEFT,
    spaceBefore=14, spaceAfter=6,
    leftIndent=0, rightIndent=0,
    borderPad=6)
H2 = sty("H2",
    fontName="Helvetica-Bold", fontSize=13, textColor=C_DARK_BLUE,
    spaceBefore=10, spaceAfter=4, borderWidth=0,
    leftIndent=0)
H3 = sty("H3",
    fontName="Helvetica-BoldOblique", fontSize=11, textColor=C_ORANGE,
    spaceBefore=8, spaceAfter=3)
BODY = sty("BODY",
    fontName="Helvetica", fontSize=10, textColor=C_BLACK,
    leading=16, spaceAfter=3, alignment=TA_JUSTIFY)
BULLET = sty("BULLET",
    fontName="Helvetica", fontSize=10, textColor=C_BLACK,
    leading=14, leftIndent=16, spaceAfter=2,
    bulletIndent=6, bulletFontSize=10)
SUBBULLET = sty("SUBBULLET",
    fontName="Helvetica", fontSize=9.5, textColor=colors.HexColor("#333333"),
    leading=13, leftIndent=30, spaceAfter=1,
    bulletIndent=20, bulletFontSize=9)
BOX_TITLE = sty("BOX_TITLE",
    fontName="Helvetica-Bold", fontSize=10, textColor=C_DARK_BLUE,
    spaceAfter=2)
BOX_TEXT  = sty("BOX_TEXT",
    fontName="Helvetica", fontSize=9.5, textColor=C_BLACK,
    leading=14, spaceAfter=2)
WARN = sty("WARN",
    fontName="Helvetica-Bold", fontSize=10, textColor=colors.HexColor("#B71C1C"),
    spaceAfter=2)
EXAM = sty("EXAM",
    fontName="Helvetica-BoldOblique", fontSize=9.5,
    textColor=colors.HexColor("#1B5E20"),
    leading=13, spaceAfter=2)
CAPTION = sty("CAPTION",
    fontName="Helvetica-Oblique", fontSize=8.5, textColor=colors.grey,
    alignment=TA_CENTER, spaceAfter=4)

def h1(text):
    return Paragraph(f"  {text}", H1)

def h2(text):
    return Paragraph(text, H2)

def h3(text):
    return Paragraph(text, H3)

def body(text):
    return Paragraph(text, BODY)

def bullet(text, level=0):
    s = BULLET if level == 0 else SUBBULLET
    return Paragraph(f"• {text}", s)

def warn(text):
    return Paragraph(f"⚠ {text}", WARN)

def exam(text):
    return Paragraph(f"&#10004; <b>Exam Point:</b> {text}", EXAM)

def spacer(h=6):
    return Spacer(1, h)

def hr():
    return HRFlowable(width="100%", thickness=0.5, color=C_MED_BLUE, spaceAfter=4, spaceBefore=4)

def info_box(title, items, bg=C_LIGHT_BLUE):
    rows = [[Paragraph(f"<b>{title}</b>", BOX_TITLE)]]
    for item in items:
        rows.append([Paragraph(f"&#8226; {item}", BOX_TEXT)])
    t = Table(rows, colWidths=[16*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,0), C_MED_BLUE),
        ("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
        ("BACKGROUND", (0,1), (-1,-1), bg),
        ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
        ("INNERGRID", (0,0), (-1,-1), 0.25, colors.HexColor("#BBBBBB")),
        ("LEFTPADDING", (0,0), (-1,-1), 8),
        ("RIGHTPADDING", (0,0), (-1,-1), 8),
        ("TOPPADDING", (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
    ]))
    return t

def two_col_table(left_items, right_items, left_title="", right_title="", bg1=C_LIGHT_BLUE, bg2=C_GREEN_BG):
    def cell_content(title, items, bg):
        rows = []
        if title:
            rows.append(Paragraph(f"<b>{title}</b>", BOX_TITLE))
        for i in items:
            rows.append(Paragraph(f"&#8226; {i}", BOX_TEXT))
        return rows
    left = cell_content(left_title, left_items, bg1)
    right = cell_content(right_title, right_items, bg2)
    max_rows = max(len(left), len(right))
    while len(left) < max_rows: left.append(Paragraph("", BOX_TEXT))
    while len(right) < max_rows: right.append(Paragraph("", BOX_TEXT))
    data = [[l, r] for l, r in zip(left, right)]
    t = Table(data, colWidths=[8*cm, 8*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (0,-1), bg1),
        ("BACKGROUND", (1,0), (1,-1), bg2),
        ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
        ("INNERGRID", (0,0), (-1,-1), 0.25, colors.HexColor("#BBBBBB")),
        ("LEFTPADDING", (0,0), (-1,-1), 8),
        ("RIGHTPADDING", (0,0), (-1,-1), 8),
        ("TOPPADDING", (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))
    return t

# ═══════════════════════════════════════════════════════════════════
# COVER PAGE
# ═══════════════════════════════════════════════════════════════════
cover_data = [[
    Paragraph("PATHOLOGY", sty("ct1", fontName="Helvetica-Bold", fontSize=32,
        textColor=C_WHITE, alignment=TA_CENTER, spaceAfter=4)),
    Paragraph("7th Week — Easy Detailed Notes", sty("ct2", fontName="Helvetica",
        fontSize=16, textColor=C_LIGHT_BLUE, alignment=TA_CENTER, spaceAfter=4)),
    Paragraph("Clinical Presentations of Breast Disease", sty("ct3",
        fontName="Helvetica-Bold", fontSize=14, textColor=C_YELLOW_BG,
        alignment=TA_CENTER, spaceAfter=2)),
    Paragraph("Endocrine System &amp; Pituitary Gland", sty("ct4",
        fontName="Helvetica-Bold", fontSize=14, textColor=C_YELLOW_BG,
        alignment=TA_CENTER, spaceAfter=2)),
]]
cover_table = Table([[item] for item in cover_data[0]], colWidths=[16*cm])
cover_table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), C_DARK_BLUE),
    ("BOX", (0,0), (-1,-1), 2, C_MED_BLUE),
    ("TOPPADDING", (0,0), (-1,-1), 14),
    ("BOTTOMPADDING", (0,0), (-1,-1), 14),
    ("LEFTPADDING", (0,0), (-1,-1), 20),
    ("RIGHTPADDING", (0,0), (-1,-1), 20),
]))

# ═══════════════════════════════════════════════════════════════════
# BUILD STORY
# ═══════════════════════════════════════════════════════════════════
story = []

# ── Cover ─────────────────────────────────────────────────────────
story.append(spacer(40))
story.append(cover_table)
story.append(spacer(30))
story.append(Paragraph(
    "Compiled from PATHO 7th.pages &nbsp;|&nbsp; All chapters included",
    sty("footer", fontName="Helvetica-Oblique", fontSize=10,
        textColor=colors.grey, alignment=TA_CENTER)))
story.append(PageBreak())

# ══════════════════════════════════════════════════════════════════
# SECTION 1 – BREAST DISEASE
# ══════════════════════════════════════════════════════════════════
story.append(h1("SECTION 1: CLINICAL PRESENTATIONS OF BREAST DISEASE"))
story.append(spacer())

story.append(body(
    "<b>Key Principle:</b> Most breast symptoms are investigated primarily to <b>rule out cancer</b>. "
    "However, <b>more than 90% of breast complaints are benign (non-cancerous)</b>."
))
story.append(spacer(4))

story.append(info_box("Common Breast Symptoms", [
    "Pain (Mastalgia / Mastodynia)",
    "Inflammation",
    "Nipple discharge",
    "Lumpiness",
    "Palpable mass (felt lump)",
], bg=C_LIGHT_BLUE))
story.append(spacer(10))

# 1.1 Breast Pain
story.append(h2("1. BREAST PAIN (Mastalgia / Mastodynia)"))
story.append(body("<b>Definition:</b> Pain felt in the breast tissue."))
story.append(spacer(4))

story.append(h3("Causes"))
story.append(two_col_table(
    left_title="A. Cyclical Pain (Most Common)",
    left_items=[
        "Related to menstrual cycle",
        "Caused by: edema, swelling of breast tissue",
        "Usually occurs BEFORE periods (premenstrual)",
        "Bilateral, dull, aching",
        "Resolves after menstruation",
    ],
    right_title="B. Localized (Non-Cyclical) Pain",
    right_items=[
        "Occurs in one area only",
        "May be due to: ruptured cyst, trauma, fat necrosis",
        "Persistent, not cycle-related",
        "Can be sharp or burning",
    ],
    bg1=C_LIGHT_BLUE, bg2=C_GREEN_BG
))
story.append(spacer(6))
story.append(exam("Painful breast is almost always BENIGN. Pain is NOT a common feature of breast cancer."))
story.append(spacer(8))

# 1.2 Inflammation
story.append(h2("2. INFLAMMATION OF THE BREAST (Mastitis)"))
story.append(body(
    "Signs: <b>Erythema (redness), tenderness, warmth, swelling</b>. "
    "Usually an <b>infection</b>, most common during lactation/breastfeeding."
))
story.append(spacer(4))

story.append(info_box("Acute Mastitis / Breast Abscess", [
    "Organism: Staphylococcus aureus (most common)",
    "Entry point: Cracks/fissures in the nipple skin",
    "Collection: Abscess = neutrophils + bacteria inside a walled-off cavity",
    "If untreated: Can lead to fistula formation (= abnormal tract opening through skin)",
    "Treatment: Antibiotics + continue expressing milk",
    "Rarely: Surgical drainage needed",
], bg=C_RED_BG))
story.append(spacer(4))
story.append(warn("Differential: Always rule out Inflammatory Breast Carcinoma — it mimics mastitis (red, swollen breast). If no response to antibiotics, biopsy!"))
story.append(spacer(8))

# 1.3 Nipple Discharge
story.append(h2("3. NIPPLE DISCHARGE"))
story.append(body("Evaluate by: <b>amount, laterality (one vs both), and character</b>."))
story.append(spacer(4))

story.append(two_col_table(
    left_title="Concerning Features (Possible Malignancy)",
    left_items=[
        "Spontaneous (no squeezing needed)",
        "Unilateral (one breast only)",
        "Bloody or serosanguineous",
        "Associated with a mass",
    ],
    right_title="Less Concerning Features",
    right_items=[
        "Only on squeezing",
        "Bilateral",
        "Milky / green / yellow",
        "No associated mass",
    ],
    bg1=C_RED_BG, bg2=C_GREEN_BG
))
story.append(spacer(4))
story.append(body(
    "<b>Intraductal Papilloma</b> — most common benign cause of bloody nipple discharge. "
    "Small papillary tumor inside a lactiferous duct."
))
story.append(spacer(8))

# 1.4 Lumpiness
story.append(h2("4. LUMPINESS (Nodularity / Fibrocystic Change)"))
story.append(body(
    "Diffuse nodularity of the glandular tissue. Common in reproductive-age women. "
    "Severe cases are investigated with imaging (ultrasound/mammography) "
    "to confirm no discrete mass is present."
))
story.append(spacer(8))

# 1.5 Palpable Mass
story.append(h2("5. PALPABLE MASS"))
story.append(body(
    "Detected on examination when size reaches <b>≥ 2–3 cm</b>. "
    "May arise from <b>stromal cells, epithelial cells, or fat</b>."
))
story.append(spacer(4))
story.append(info_box("Benign vs Malignant — Key Distinguishing Features", [
    "Benign: Well-circumscribed, smooth, mobile, soft/rubbery",
    "Malignant: Irregular edges, hard, fixed, skin dimpling/tethering",
    "ALL palpable masses must be evaluated — even benign-appearing ones",
], bg=C_YELLOW_BG))
story.append(spacer(8))

# 1.6 Gynecomastia
story.append(h2("6. GYNECOMASTIA (Male Breast Enlargement)"))
story.append(body(
    "= Benign increase in male breast glandular tissue due to <b>imbalance between estrogen and androgen</b> "
    "(relative estrogen excess)."
))
story.append(spacer(4))
story.append(info_box("Causes of Gynecomastia", [
    "Physiological: Neonatal, puberty, old age",
    "Liver disease (cirrhosis) — decreased androgen metabolism",
    "Drugs: Spironolactone, digoxin, cimetidine, anabolic steroids, marijuana",
    "Testicular tumors (Leydig cell) — excess estrogen production",
    "Klinefelter syndrome (47,XXY)",
    "Hyperthyroidism",
], bg=C_LIGHT_BLUE))
story.append(spacer(8))

# Mammography
story.append(h2("7. MAMMOGRAPHY"))
story.append(body(
    "<b>Purpose:</b> Detect early, <b>asymptomatic (pre-clinical)</b> breast cancer. "
    "Introduced in 1980s as a screening tool."
))
story.append(spacer(4))
story.append(two_col_table(
    left_title="Advantages",
    left_items=[
        "Detects tumors ~1 cm (before palpable)",
        "Only ~15% have lymph node spread at detection",
        "Identifies microcalcifications",
        "Best screening tool for older women",
    ],
    right_title="Limitations",
    right_items=[
        "Less effective in dense breast tissue (young women)",
        "Radiation exposure (low dose)",
        "False positives lead to unnecessary biopsies",
        "Does not detect all cancers",
    ],
    bg1=C_GREEN_BG, bg2=C_YELLOW_BG
))
story.append(spacer(6))
story.append(exam("Mammography is recommended for OLDER women (denser tissue in young women makes it less reliable). Ultrasound preferred in young women."))
story.append(spacer(10))

# Age and Risk
story.append(h2("8. AGE & RISK OF MALIGNANCY"))
story.append(body("<b>Key Rule: Risk increases with age.</b>"))
story.append(spacer(4))
story.append(two_col_table(
    left_title="Risk Factors for Breast Cancer",
    left_items=[
        "Female sex (99% of cases)",
        "Increasing age",
        "Family history / BRCA1 or BRCA2 mutation",
        "Nulliparity (never given birth)",
        "Late first pregnancy",
        "Early menarche / late menopause",
        "Hormone replacement therapy (HRT)",
        "Obesity (postmenopausal)",
        "Alcohol consumption",
        "Prior radiation (e.g., Hodgkin lymphoma treatment)",
        "Atypical hyperplasia on biopsy",
    ],
    right_title="Protective Factors",
    right_items=[
        "Early first pregnancy",
        "Multiparity",
        "Breastfeeding",
        "Exercise",
        "Oophorectomy (removes estrogen source)",
    ],
    bg1=C_RED_BG, bg2=C_GREEN_BG
))
story.append(spacer(10))

# ─── BENIGN LESIONS ───────────────────────────────────────────────
story.append(hr())
story.append(h1("BENIGN BREAST LESIONS"))
story.append(spacer())

story.append(body(
    "Benign lesions are common incidental findings. Classified into 3 groups based on "
    "<b>cancer risk</b>:"
))
story.append(spacer(6))

cat_data = [
    ["Category", "Cancer Risk", "Examples"],
    ["1. Nonproliferative", "No increased risk", "Cysts, mild hyperplasia, apocrine metaplasia, calcifications"],
    ["2. Proliferative WITHOUT Atypia", "Slightly increased (1.5–2×)", "Moderate/florid hyperplasia, sclerosing adenosis, papilloma"],
    ["3. Proliferative WITH Atypia (ADH/ALH)", "4–5× increased risk", "Atypical ductal hyperplasia, atypical lobular hyperplasia"],
]
cat_table = Table(cat_data, colWidths=[4.5*cm, 4.5*cm, 7*cm])
cat_table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), C_DARK_BLUE),
    ("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
    ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE", (0,0), (-1,-1), 9.5),
    ("BACKGROUND", (0,1), (-1,1), C_GRAY_BG),
    ("BACKGROUND", (0,2), (-1,2), C_YELLOW_BG),
    ("BACKGROUND", (0,3), (-1,3), C_RED_BG),
    ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
    ("INNERGRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("LEFTPADDING", (0,0), (-1,-1), 7),
    ("RIGHTPADDING", (0,0), (-1,-1), 7),
    ("TOPPADDING", (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(cat_table)
story.append(spacer(10))

# Nonproliferative
story.append(h2("A. Nonproliferative Lesions (Fibrocystic Change)"))
story.append(body("Components:"))
story.append(bullet("Cysts (lined by apocrine epithelium) — often show apocrine metaplasia"))
story.append(bullet("Calcifications — seen on mammography"))
story.append(bullet("Mild ductal hyperplasia (< 2 cell layers above basement membrane)"))
story.append(spacer(4))
story.append(exam("Apocrine metaplasia = cells look like sweat gland cells (big pink cytoplasm). Completely benign!"))
story.append(spacer(8))

# Proliferative without atypia
story.append(h2("B. Proliferative Lesions WITHOUT Atypia"))
story.append(body("Include:"))
story.append(bullet("Moderate to florid ductal hyperplasia — many cell layers, but no atypia"))
story.append(bullet("Sclerosing adenosis — increased number of acini, with stromal fibrosis; can mimic carcinoma"))
story.append(bullet("Complex sclerosing lesion (radial scar) — stellate, may mimic carcinoma on imaging"))
story.append(bullet("Papilloma — frond-like growth in a duct; main benign cause of nipple discharge"))
story.append(spacer(4))
story.append(exam("Sclerosing adenosis: myoepithelial cells are PRESENT (absent in carcinoma). This is the KEY differentiator."))
story.append(spacer(8))

# Proliferative with atypia
story.append(h2("C. Proliferative Lesions WITH Atypia"))
story.append(two_col_table(
    left_title="Atypical Ductal Hyperplasia (ADH)",
    left_items=[
        "Resembles low-grade DCIS but is less extensive",
        "Does NOT fully bridge ducts",
        "Does NOT have sharply defined cell borders throughout",
        "4–5× increased cancer risk",
        "If BRCA+ as well → risk up to 10×",
    ],
    right_title="Atypical Lobular Hyperplasia (ALH)",
    right_items=[
        "Resembles LCIS but does NOT fill/distend lobule",
        "Loss of E-cadherin (same as LCIS)",
        "4× increased cancer risk",
        "Bilateral risk marker",
    ],
    bg1=C_RED_BG, bg2=C_YELLOW_BG
))
story.append(spacer(10))

# Stromal Neoplasms
story.append(h2("D. STROMAL NEOPLASMS (Biphasic Tumors)"))
story.append(body("These tumors contain BOTH stromal and epithelial components (biphasic)."))
story.append(spacer(6))

story.append(h3("Fibroadenoma"))
story.append(bullet("Most common benign breast tumor in young women"))
story.append(bullet("Derived from intralobular stroma"))
story.append(bullet("Biphasic: stromal + epithelial components"))
story.append(bullet("Clinical: mobile, well-circumscribed, rubbery, non-tender ('breast mouse')"))
story.append(bullet("Microscopy: few mitoses, no atypia"))
story.append(bullet("Grows with estrogen → may enlarge during pregnancy"))
story.append(spacer(4))
story.append(exam("Fibroadenoma = most common breast tumor in women < 35 years old."))
story.append(spacer(8))

story.append(h3("Phyllodes Tumor (Cystosarcoma Phyllodes)"))
story.append(bullet("Leaf-like (phyllodes = leaf) projections on gross appearance"))
story.append(bullet("Stromal overgrowth is the key feature"))
story.append(bullet("Range from benign to malignant"))
story.append(bullet("High-grade phyllodes: sarcomatous stroma, many mitoses"))
story.append(bullet("Interlobular stroma proliferates (unlike fibroadenoma = intralobular)"))
story.append(spacer(4))
story.append(warn("High-grade Phyllodes tumor: May undergo sarcomatous transformation. Spreads hematogenously to lungs."))
story.append(spacer(10))

# ─── BREAST CARCINOMA ──────────────────────────────────────────────
story.append(PageBreak())
story.append(hr())
story.append(h1("BREAST CARCINOMA"))
story.append(spacer())

story.append(body(
    "Breast cancer is the <b>most common cancer worldwide in women</b> and a leading cause of cancer death. "
    "Incidence has been <b>rising</b> due to: delayed childbearing, limited breastfeeding, and improved detection."
))
story.append(spacer(6))

story.append(info_box("Lifetime Statistics", [
    "1 in 8 women develop breast cancer in their lifetime",
    "5-year survival with localized disease: >95%",
    "Late detection dramatically worsens prognosis",
], bg=C_YELLOW_BG))
story.append(spacer(10))

# Molecular Classification
story.append(h2("MOLECULAR CLASSIFICATION OF BREAST CANCER"))
story.append(body(
    "Based on receptor expression: <b>ER (estrogen receptor), PR (progesterone receptor), HER2</b>."
))
story.append(spacer(6))

mol_data = [
    ["Type", "Features", "Prognosis / Key Points"],
    ["1. ER-Positive (Luminal A/B)",
     "ER+, PR+, HER2−\nSlow growing",
     "Best prognosis\nResponds to hormone therapy (Tamoxifen, Aromatase inhibitors)\nLate recurrence possible (>10 yrs)\nBone metastases common\nPIK3CA mutations frequent"],
    ["2. HER2-Amplified",
     "ER−, PR−, HER2+\nAggressive",
     "Intermediate prognosis\nTreated with Trastuzumab (Herceptin)\nViseral metastases common\nTP53 mutations common"],
    ["3. Triple-Negative (TNBC)",
     "ER−, PR−, HER2−\nMost aggressive",
     "Worst prognosis\nNo targeted therapy available\nCommon in young women and BRCA1 carriers\nBASAL-like subtype\nChemotherapy only"],
]
mol_table = Table(mol_data, colWidths=[4*cm, 5*cm, 7*cm])
mol_table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), C_DARK_BLUE),
    ("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
    ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE", (0,0), (-1,-1), 9),
    ("BACKGROUND", (0,1), (-1,1), C_GREEN_BG),
    ("BACKGROUND", (0,2), (-1,2), C_YELLOW_BG),
    ("BACKGROUND", (0,3), (-1,3), C_RED_BG),
    ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
    ("INNERGRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("LEFTPADDING", (0,0), (-1,-1), 7),
    ("RIGHTPADDING", (0,0), (-1,-1), 7),
    ("TOPPADDING", (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("WORDWRAP", (0,0), (-1,-1), True),
]))
story.append(mol_table)
story.append(spacer(8))

story.append(exam(
    "Gene expression profiling (e.g., Oncotype DX) divides ER+ cancers into recurrence score groups to guide chemotherapy decision."
))
story.append(spacer(10))

# Risk Factors (genetic)
story.append(h2("GENETIC RISK FACTORS"))
story.append(two_col_table(
    left_title="BRCA1 and BRCA2 Mutations",
    left_items=[
        "BRCA1 (chr 17q) — associated with TNBC, ovarian cancer",
        "BRCA2 (chr 13q) — associated with male breast cancer",
        "Function: DNA repair (homologous recombination)",
        "Loss → genomic instability → cancer",
        "Lifetime risk: 50–85% for breast cancer",
    ],
    right_title="Other Genetic Syndromes",
    right_items=[
        "Li-Fraumeni: TP53 mutation — breast, sarcoma, brain",
        "Cowden: PTEN mutation — breast, thyroid, endometrium",
        "Lynch: MLH1/MSH2 — colorectal + breast risk",
        "ATM mutation — moderate breast cancer risk",
        "PARP inhibitors useful in BRCA-mutated cancers",
    ],
    bg1=C_LIGHT_BLUE, bg2=C_YELLOW_BG
))
story.append(spacer(10))

# Classification: In Situ vs Invasive
story.append(h2("CLASSIFICATION: IN SITU vs INVASIVE"))
story.append(body(
    "<b>In situ carcinomas</b> = confined within ducts/lobules; <b>basement membrane intact</b>. "
    "<b>Invasive carcinomas</b> = basement membrane breached; can metastasize."
))
story.append(spacer(6))

# DCIS
story.append(h3("Ductal Carcinoma In Situ (DCIS)"))
story.append(bullet("Malignant cells fill the ducts BUT do not cross the basement membrane"))
story.append(bullet("Often detected by mammography (microcalcifications)"))
story.append(bullet("Key event: HER2 amplification on chromosome 17q"))
story.append(bullet("Comedo type (most aggressive): central necrosis → calcifies → 'toothpaste-like' material on cut section"))
story.append(bullet("Non-comedo type: less necrosis, various growth patterns (cribriform, solid, micropapillary)"))
story.append(bullet("Precursor to invasive ductal carcinoma (97% of invasive cancers arise from ductal cells)"))
story.append(spacer(4))
story.append(exam("DCIS comedo type: calcifications on mammography + central necrosis = HIGH yield exam fact!"))
story.append(spacer(8))

# LCIS
story.append(h3("Lobular Carcinoma In Situ (LCIS)"))
story.append(bullet("Malignant cells distend and fill the lobular acini"))
story.append(bullet("NO basement membrane breach"))
story.append(bullet("Loss of E-cadherin (key molecular marker)"))
story.append(bullet("NOT usually calcified — not seen on mammography"))
story.append(bullet("Acts as a RISK MARKER (bilateral risk), not a direct precursor lesion"))
story.append(bullet("One-third become invasive (both ductal and lobular subtypes)"))
story.append(spacer(4))
story.append(exam("LCIS = Risk marker for BILATERAL breast cancer (not just same side!). E-cadherin LOST."))
story.append(spacer(10))

# Invasive carcinomas
story.append(h2("INVASIVE BREAST CARCINOMAS"))
story.append(body("Basement membrane BREACHED — can invade lymphatics and blood vessels."))
story.append(spacer(6))

inv_data = [
    ["Type", "Frequency", "Key Features"],
    ["Invasive Ductal Carcinoma (IDC) / NST",
     "~70–80%\n(most common)",
     "Hard, irregular mass; desmoplastic stroma; stellate shape\n'Scirrhous' appearance\nGrades 1–3; various subtypes possible"],
    ["Invasive Lobular Carcinoma (ILC)",
     "~10–15%",
     "Single-file ('Indian file') arrangement of cells\nLoss of E-cadherin\nHard to detect on mammography\nBilateral & multicentric\nMetastasizes to ovary, uterus, GI tract"],
    ["Medullary Carcinoma",
     "~5%",
     "Soft, well-circumscribed; abundant lymphocytes\nLarge pleomorphic nuclei\nER−, PR−, HER2−; BRCA1-associated\nParadoxically BETTER prognosis than IDC"],
    ["Mucinous (Colloid) Carcinoma",
     "~2–3%",
     "Clusters of cells floating in mucin pools\nSoft, gelatinous; well-circumscribed\nOlder women; GOOD prognosis"],
    ["Tubular Carcinoma",
     "~2%",
     "Well-formed tubules; very low-grade\nExcellent prognosis"],
    ["Paget Disease of Nipple",
     "~1–2%",
     "Malignant cells (Paget cells) spread through nipple epidermis\nAssociated with underlying DCIS or invasive carcinoma\nAppearance: crusty, eczematous nipple rash\nMarker: CK7+, HER2+"],
]
inv_table = Table(inv_data, colWidths=[4.5*cm, 2.5*cm, 9*cm])
inv_table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), C_DARK_BLUE),
    ("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
    ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE", (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [C_GRAY_BG, C_WHITE]),
    ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
    ("INNERGRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("LEFTPADDING", (0,0), (-1,-1), 7),
    ("RIGHTPADDING", (0,0), (-1,-1), 7),
    ("TOPPADDING", (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(inv_table)
story.append(spacer(8))

story.append(warn("Inflammatory Breast Carcinoma: NOT a histological type but a clinical presentation. Dermal lymphatic invasion → red, swollen, warm breast with peau d'orange skin. POOR prognosis."))
story.append(spacer(10))

# Grading & Staging
story.append(h2("GRADING & STAGING"))
story.append(two_col_table(
    left_title="Histological Grading (Nottingham / Elston-Ellis)",
    left_items=[
        "Based on: Tubule formation, Nuclear pleomorphism, Mitotic count",
        "Grade 1 (Low): Well differentiated — best prognosis",
        "Grade 2 (Intermediate): Moderately differentiated",
        "Grade 3 (High): Poorly differentiated — worst prognosis",
    ],
    right_title="TNM Staging System",
    right_items=[
        "T = Tumor size (T1: ≤2cm, T2: 2–5cm, T3: >5cm, T4: skin/chest wall involvement)",
        "N = Nodal status (N0: no nodes, N1–3: increasing nodal involvement)",
        "M = Metastasis (M0: none, M1: distant mets)",
        "Stage I–IV based on TNM combination",
    ],
    bg1=C_LIGHT_BLUE, bg2=C_YELLOW_BG
))
story.append(spacer(6))
story.append(exam("MOST IMPORTANT prognostic factor = Lymph node status (N). Then: tumor size, grade, receptor status."))
story.append(spacer(8))

# Metastasis
story.append(h2("METASTASIS PATTERNS"))
story.append(two_col_table(
    left_title="Routes of Spread",
    left_items=[
        "Lymphatic: axillary nodes (most common) → supraclavicular, internal mammary",
        "Hematogenous: bones (most common), lung, liver, brain, ovary",
        "Direct: skin, chest wall",
    ],
    right_title="Site Preferences by Subtype",
    right_items=[
        "ER+ (Luminal): bone metastases",
        "HER2+: brain, viscera",
        "Triple-negative: lung, brain",
        "ILC: ovary, uterus, GI tract",
    ],
    bg1=C_LIGHT_BLUE, bg2=C_RED_BG
))
story.append(spacer(10))

# Treatment
story.append(h2("TREATMENT OVERVIEW"))
story.append(info_box("Key Treatments", [
    "Surgery: Lumpectomy (breast-conserving) + radiotherapy, OR Mastectomy",
    "Hormonal therapy: Tamoxifen (premenopausal, ER+) | Aromatase inhibitors (postmenopausal, ER+)",
    "Targeted therapy: Trastuzumab/Herceptin (HER2+) | Pertuzumab | T-DM1",
    "Chemotherapy: All subtypes; essential for TNBC",
    "PARP inhibitors (Olaparib): BRCA1/2 mutated cancers",
    "PI3K-AKT pathway inhibitors: ER+ advanced disease",
    "Immunotherapy (checkpoint inhibitors): TNBC — PD-L1 positive",
    "Neoadjuvant therapy: Given before surgery to shrink tumor",
], bg=C_LIGHT_BLUE))
story.append(spacer(10))

# ══════════════════════════════════════════════════════════════════
# SECTION 2 – ENDOCRINE SYSTEM & PITUITARY
# ══════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("SECTION 2: ENDOCRINE SYSTEM & PITUITARY GLAND"))
story.append(spacer())

story.append(body(
    "The endocrine system maintains <b>body homeostasis and balance</b> by releasing hormones into the bloodstream "
    "to act on distant target organs."
))
story.append(spacer(6))

story.append(info_box("What is a Hormone?", [
    "Chemical messengers released by endocrine glands into blood",
    "Travel to target organs to produce specific effects",
    "Examples: TSH from pituitary → acts on thyroid; Cortisol from adrenal → acts on liver/immune system",
], bg=C_LIGHT_BLUE))
story.append(spacer(8))

# Hormone types
story.append(h2("TYPES OF HORMONES"))
story.append(two_col_table(
    left_title="Water-Soluble Hormones (Peptides / Amines)",
    left_items=[
        "Cannot cross cell membrane",
        "Bind to SURFACE receptors",
        "Use second messenger systems (cAMP, IP3)",
        "Examples: Insulin, TSH, GH, ACTH, glucagon, epinephrine",
        "Fast action",
    ],
    right_title="Lipid-Soluble Hormones (Steroids / Thyroid)",
    right_items=[
        "Cross cell membrane easily",
        "Bind to INTRACELLULAR (cytoplasmic/nuclear) receptors",
        "Hormone-receptor complex → enters nucleus → binds DNA",
        "Examples: Cortisol, aldosterone, estrogen, testosterone, T3/T4",
        "Slow, long-lasting action",
    ],
    bg1=C_LIGHT_BLUE, bg2=C_YELLOW_BG
))
story.append(spacer(8))

story.append(h2("FEEDBACK INHIBITION"))
story.append(body(
    "<b>Negative Feedback:</b> When a hormone level rises, it inhibits further release from the pituitary and hypothalamus. "
    "Example: ↑T4 → ↓TSH → ↓TRH. This keeps hormone levels in a narrow normal range."
))
story.append(spacer(4))
story.append(body(
    "<b>Causes of Endocrine Disease:</b>"
))
story.append(bullet("Hypersecretion — excess hormone (e.g., Cushing's, acromegaly)"))
story.append(bullet("Hyposecretion — deficient hormone (e.g., hypothyroidism, Addison's)"))
story.append(bullet("End-organ resistance — normal hormone but receptor defect (e.g., type 2 diabetes)"))
story.append(spacer(10))

# Pituitary gland
story.append(h2("THE PITUITARY GLAND (Hypophysis)"))
story.append(body(
    "Bean-shaped gland located in the <b>sella turcica</b> (Turkish saddle) of the sphenoid bone. "
    "Connected to the hypothalamus via the pituitary stalk."
))
story.append(spacer(6))

story.append(two_col_table(
    left_title="Anterior Pituitary (Adenohypophysis)",
    left_items=[
        "Makes up 75% of pituitary",
        "Cell types: Acidophils (GH, Prolactin) and Basophils (TSH, FSH, LH, ACTH)",
        "Controlled by hypothalamic releasing/inhibiting hormones via portal blood",
        "Hormones: GH, Prolactin, TSH, FSH, LH, ACTH, MSH",
    ],
    right_title="Posterior Pituitary (Neurohypophysis)",
    right_items=[
        "DOES NOT produce its own hormones",
        "Axons from hypothalamus (supraoptic & paraventricular nuclei) end here",
        "STORES and RELEASES: ADH (vasopressin) and Oxytocin",
        "ADH: water retention in kidney collecting ducts",
        "Oxytocin: uterine contractions, milk ejection",
    ],
    bg1=C_LIGHT_BLUE, bg2=C_GREEN_BG
))
story.append(spacer(8))

story.append(h3("Hypothalamic Control Summary"))
story.append(info_box("Hypothalamic Hormones → Pituitary Effect", [
    "GHRH → ↑GH | Somatostatin → ↓GH",
    "TRH → ↑TSH | Dopamine → ↓Prolactin",
    "GnRH → ↑LH + FSH",
    "CRH → ↑ACTH",
    "Dopamine (= Prolactin Inhibiting Factor) → ↓Prolactin",
    "Key: Dopamine normally INHIBITS prolactin — so dopamine antagonist drugs ↑ prolactin!",
], bg=C_YELLOW_BG))
story.append(spacer(10))

# Effects of pituitary lesions
story.append(h2("EFFECTS OF PITUITARY LESIONS"))
story.append(two_col_table(
    left_title="Mass Effects (from tumor pressing on structures)",
    left_items=[
        "Optic chiasm compression → Bitemporal hemianopia (loss of outer visual fields)",
        "Headache, vomiting",
        "Cranial nerve palsies (III, IV, VI)",
        "Seizures",
        "Hydrocephalus (if blocks CSF flow)",
    ],
    right_title="Hormonal Effects",
    right_items=[
        "Hypersecretion: from functional adenomas (excess GH, Prolactin, ACTH)",
        "Hyposecretion: from compression of normal tissue → panhypopituitarism",
        "Hormones fail in order: GH first, then LH/FSH, then TSH, then ACTH last",
    ],
    bg1=C_RED_BG, bg2=C_YELLOW_BG
))
story.append(spacer(6))
story.append(warn("Pituitary Apoplexy: Sudden hemorrhage/infarction into a pituitary adenoma → severe headache, visual loss, hormonal collapse → NEUROLOGICAL EMERGENCY."))
story.append(spacer(10))

# Pituitary Adenomas
story.append(h2("PITUITARY ADENOMAS"))
story.append(body(
    "Most common pituitary tumors. Usually <b>benign</b>. Classified by size: "
    "<b>Microadenoma</b> (&lt;1 cm) and <b>Macroadenoma</b> (&gt;1 cm)."
))
story.append(spacer(4))

aden_data = [
    ["Adenoma Type", "Hormone", "Clinical Syndrome", "Key Facts"],
    ["Prolactinoma\n(most common)", "Prolactin↑",
     "Women: Amenorrhea, galactorrhea, infertility\nMen: Erectile dysfunction, gynecomastia",
     "Treat with Dopamine agonists (Cabergoline, Bromocriptine)\nDopamine normally inhibits prolactin"],
    ["Somatotroph Adenoma", "GH↑",
     "Before puberty: Gigantism (excess height)\nAfter puberty (closed epiphyses): Acromegaly",
     "Acromegaly: enlarged jaw (prognathism), big hands/feet, broad face\nDiabetes (GH antagonizes insulin)\nDiagnosis: IGF-1 level + glucose suppression test"],
    ["Corticotroph Adenoma", "ACTH↑",
     "Cushing Disease\n(cortisol excess from bilateral adrenal hyperplasia)",
     "PAS+ cells (glycosylated ACTH)\nCrooke hyaline change in normal corticotrophs\nNelson Syndrome: after bilateral adrenalectomy → huge ACTH↑ + skin pigmentation"],
    ["Thyrotroph", "TSH↑", "Secondary hyperthyroidism", "Rare; TSH-secreting adenoma"],
    ["Gonadotroph", "LH/FSH↑", "Usually clinically silent\n(most common non-functioning)", "Causes hypogonadism paradoxically (continuous, non-pulsatile LH/FSH)"],
    ["Null Cell\n(Non-functioning)", "None",
     "Only mass effects\nHeadache, visual field defects",
     "Most common type overall in older patients\nNo hormone excess; press on normal pituitary → hypopituitarism"],
]
aden_table = Table(aden_data, colWidths=[3.5*cm, 2.5*cm, 4.5*cm, 5.5*cm])
aden_table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), C_DARK_BLUE),
    ("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
    ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE", (0,0), (-1,-1), 8.5),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [C_GRAY_BG, C_WHITE]),
    ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
    ("INNERGRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("LEFTPADDING", (0,0), (-1,-1), 6),
    ("RIGHTPADDING", (0,0), (-1,-1), 6),
    ("TOPPADDING", (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(aden_table)
story.append(spacer(8))

story.append(exam("Prolactinoma = most common functional pituitary adenoma. Treat with DOPAMINE AGONISTS (Cabergoline), NOT surgery first!"))
story.append(spacer(6))
story.append(exam("Nelson Syndrome: After bilateral adrenalectomy for Cushing disease → loss of cortisol feedback → massive ACTH + MSH elevation → hyperpigmentation. POMC is the precursor to both ACTH and MSH."))
story.append(spacer(10))

# Genetic syndromes
story.append(h2("GENETIC SYNDROMES ASSOCIATED WITH PITUITARY ADENOMAS"))
story.append(info_box("Key Genetic Associations", [
    "MEN1 (Multiple Endocrine Neoplasia Type 1): Menin gene mutation → Pituitary + Parathyroid + Pancreatic tumors (3 Ps)",
    "CDKN1B (MEN4): Similar to MEN1 but menin normal",
    "PRKAR1A (Carney Complex): Spotty pigmentation + cardiac myxoma + pituitary adenoma",
    "McCune-Albright: GNAS mutation → constitutive G-protein activation → autonomous GH/ACTH/TSH/prolactin secretion",
    "Familial Isolated Pituitary Adenoma (FIPA): AIP gene mutation → large somatotroph adenomas in young patients",
], bg=C_YELLOW_BG))
story.append(spacer(8))

# Hypopituitarism
story.append(h2("HYPOPITUITARISM (Pituitary Insufficiency)"))
story.append(body(
    "= Deficiency of one or more pituitary hormones. If ALL hormones deficient → <b>Panhypopituitarism</b>."
))
story.append(spacer(4))

story.append(info_box("Causes of Hypopituitarism", [
    "Pituitary adenoma (compression of normal tissue)",
    "Sheehan Syndrome: Postpartum pituitary infarction (due to hemorrhage, hypotension) — most common cause in women",
    "Craniopharyngioma: Benign tumor of Rathke pouch epithelium; common in children; cholesterol crystals + calcifications",
    "Empty Sella Syndrome: Arachnoid protrudes into sella, compresses pituitary",
    "Radiation, surgery, trauma",
    "Infiltrative diseases: Sarcoidosis, histiocytosis, hemochromatosis",
], bg=C_RED_BG))
story.append(spacer(6))
story.append(exam("Sheehan Syndrome: Postpartum woman unable to breastfeed (no prolactin) + failure to menstruate (no FSH/LH). Pituitary enlarged during pregnancy → vulnerable to infarction during hemorrhage."))
story.append(spacer(6))
story.append(exam("Craniopharyngioma: Children. Suprasellar. Adamantinomatous type has 'engine oil' fluid + calcifications on CT. Bitemporal hemianopia."))
story.append(spacer(10))

# Morphology
story.append(h2("MORPHOLOGY OF PITUITARY ADENOMAS"))
story.append(two_col_table(
    left_title="Gross Appearance",
    left_items=[
        "Soft, well-circumscribed",
        "May be cystic or hemorrhagic",
        "Macroadenomas may destroy sella",
        "Extend suprasellarly → compress optic chiasm",
    ],
    right_title="Microscopic Appearance",
    right_items=[
        "Monomorphic (all cells look the same) — KEY feature",
        "Cells in sheets, cords, or papillary patterns",
        "Loss of normal acinar (lobular) arrangement",
        "Reticulin staining shows absent normal lobular network",
        "IHC: stain for specific hormones to identify type",
    ],
    bg1=C_LIGHT_BLUE, bg2=C_GREEN_BG
))
story.append(spacer(10))

# ─── HIGH-YIELD SUMMARY ───────────────────────────────────────────
story.append(PageBreak())
story.append(hr())
story.append(h1("HIGH-YIELD QUICK REVIEW & MNEMONICS"))
story.append(spacer())

story.append(h2("BREAST DISEASE — KEY QUICK FACTS"))
quick_data = [
    ["Topic", "High-Yield Fact"],
    ["Most common benign tumor", "Fibroadenoma (young women)"],
    ["Most common benign cause of bloody nipple discharge", "Intraductal Papilloma"],
    ["Most common breast cancer", "Invasive Ductal Carcinoma (NST)"],
    ["Best prognosis subtype", "ER+/PR+ (Luminal A); also Mucinous, Tubular"],
    ["Worst prognosis subtype", "Triple-Negative (TNBC) / Inflammatory"],
    ["E-cadherin LOST in", "Lobular carcinoma (LCIS + ILC)"],
    ["Bilateral risk marker", "LCIS"],
    ["DCIS comedo type feature", "Central necrosis + calcifications on mammography"],
    ["Paget disease of nipple", "Eczema-like rash + underlying DCIS/invasive Ca; CK7+, HER2+"],
    ["BRCA1 → associated cancer type", "Triple-negative + ovarian"],
    ["BRCA2 → associated cancer type", "ER+; also male breast cancer"],
    ["ADH / ALH — cancer risk", "4–5× increased risk; with BRCA → up to 10×"],
    ["Sclerosing adenosis vs carcinoma", "Sclerosing adenosis: myoepithelial cells PRESENT (absent in carcinoma)"],
    ["Most important prognostic factor", "Lymph node status (axillary)"],
    ["Phyllodes tumor key feature", "Stromal overgrowth; leaf-like projections; risk of sarcoma"],
]
qt = Table(quick_data, colWidths=[6*cm, 10*cm])
qt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), C_DARK_BLUE),
    ("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
    ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE", (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [C_GRAY_BG, C_WHITE]),
    ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
    ("INNERGRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("LEFTPADDING", (0,0), (-1,-1), 7),
    ("RIGHTPADDING", (0,0), (-1,-1), 7),
    ("TOPPADDING", (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("FONTNAME", (0,1), (0,-1), "Helvetica-Bold"),
]))
story.append(qt)
story.append(spacer(14))

story.append(h2("ENDOCRINE / PITUITARY — KEY QUICK FACTS"))
pq_data = [
    ["Topic", "High-Yield Fact"],
    ["Most common pituitary adenoma", "Prolactinoma (most common functional); Null cell (most common overall)"],
    ["Prolactinoma treatment", "Dopamine agonists first (Cabergoline, Bromocriptine) — NOT surgery"],
    ["Bitemporal hemianopia cause", "Optic chiasm compression by pituitary macroadenoma"],
    ["Acromegaly vs Gigantism", "Acromegaly: after epiphyseal closure; Gigantism: before closure"],
    ["Diagnosis of acromegaly", "↑IGF-1 + glucose suppression test (GH not suppressed)"],
    ["Cushing Disease vs Syndrome", "Disease = ACTH from pituitary adenoma; Syndrome = any cause of cortisol excess"],
    ["Nelson Syndrome", "Post-bilateral adrenalectomy → ↑↑ACTH + skin pigmentation (MSH from POMC)"],
    ["Sheehan Syndrome", "Postpartum pituitary infarction → no breastfeeding, no periods"],
    ["Craniopharyngioma", "Children; suprasellar; Rathke pouch; cholesterol crystals + calcifications"],
    ["Pituitary apoplexy", "Sudden hemorrhage into adenoma → headache, visual loss, neurological emergency"],
    ["MEN1 (3 Ps)", "Pituitary + Parathyroid + Pancreatic tumors; Menin gene (chr 11q13)"],
    ["Order of hormone loss", "GH first → LH/FSH → TSH → ACTH last"],
    ["Dopamine role in pituitary", "Inhibits prolactin secretion (PIF = Prolactin Inhibiting Factor)"],
    ["POMC precursor", "Cleaved into ACTH + MSH + β-endorphin"],
]
pqt = Table(pq_data, colWidths=[6*cm, 10*cm])
pqt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), C_DARK_BLUE),
    ("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
    ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE", (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [C_GRAY_BG, C_WHITE]),
    ("BOX", (0,0), (-1,-1), 1, C_MED_BLUE),
    ("INNERGRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("LEFTPADDING", (0,0), (-1,-1), 7),
    ("RIGHTPADDING", (0,0), (-1,-1), 7),
    ("TOPPADDING", (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("FONTNAME", (0,1), (0,-1), "Helvetica-Bold"),
]))
story.append(pqt)
story.append(spacer(10))

story.append(h2("MNEMONICS"))
story.append(info_box("Memory Aids", [
    "BREAST CANCER RISK: 'Can Ladies Have Fibro-Adenoma, But Need BRCA Yearly' → Childbearing delay, Late menarche/menopause, HRT, Family hx, BRCA, Nulliparity, Biopsy (ADH), Radiation, Young age at first radiation",
    "MEN1 = 3 Ps: Pituitary + Parathyroid + Pancreas (Menin = chromosome 11)",
    "DCIS: 'Ductal = Don't Cross Into Stroma' — stays in duct",
    "LCIS: 'Lobular = Loss of E-Cadherin = Lateral risk (bilateral)' — risk marker, not direct precursor",
    "Prolactinoma: 'P-ro-L-actin → P-roL from the Pit → treat with DoPaminE Agonist first'",
    "ILC: 'Indian file Lobular loses E-cadherin → Loves Ovary/Uterus/GI metastases'",
    "Sheehan: 'She has a baby, bleeds big, pituitary dies — She cannot She-feed (breastfeed)'",
    "Order of pituitary hormone loss in hypopituitarism: 'GrowLH/FSHTACs' = GH → LH/FSH → TSH → ACTH",
], bg=C_YELLOW_BG))
story.append(spacer(10))

# Footer
story.append(hr())
story.append(Paragraph(
    "End of PATHO 7th Week Notes &nbsp;|&nbsp; Sections: Breast Disease + Endocrine/Pituitary",
    sty("end", fontName="Helvetica-Oblique", fontSize=9,
        textColor=colors.grey, alignment=TA_CENTER)
))

# BUILD
doc.build(story)
print(f"PDF saved to: {OUTPUT}")
You've run out of free credits. Sign up for a free account to continue using Orris.
This is a shared conversation. Sign in to Orris to start your own chat.