Approach to the Patient: Diagnosis of Cushing Syndrome Mesut Savas 1,b, Sonal Mehta 2,b, Nidhi Agrawal 3, Elisabeth F C van Rossum 4,✉, Richard A Feelders 5.....I want you to open this pubmed index and create me a flow chart with every basic concept inclusive

Searching PubMed

Savas Mehta Agrawal van Rossum Feelders diagnosis Cushing syndrome approach patient

Searching the Web

Savas Mehta Agrawal van Rossum Feelders "Approach to the Patient Diagnosis of Cushing Syndrome" PubMed

Reading Article

PMID: 36036941

Reading Web Page

https://pmc.ncbi.nlm.nih.gov/articles/PMC9681610

Generating Image

A detailed medical diagnostic flowchart titled "Approach to the Patient: Diagnosis of Cushing Syndrome" based on Savas, Mehta, Agrawal, van Rossum & Feelders (J Clin Endocrinol Metab, 2022). The flowchart should be clean, professional, white background, with color-coded boxes and arrows flowing top to bottom, covering ALL of the following stages: STAGE 1 — CLINICAL SUSPICION (blue header box): • High-risk features: central obesity, moon face, buffalo hump, purple striae >1cm, proximal myopathy, easy bruising, facial plethora, hypertension in young adults, early-onset osteoporosis, unexplained DM, hirsutism, menstrual irregularities, hypokalemia, adrenal incidentaloma, children with weight gain + growth arrest • Pseudo-Cushing States (red exclusion box): obesity, depression, alcoholism, poorly controlled DM, pregnancy, PCOS, stress STAGE 2 — STEP 0: EXCLUDE EXOGENOUS (yellow box): • Exclude ALL glucocorticoid use: oral, inhaled, nasal, topical, intra-articular, ophthalmic • If exogenous → Iatrogenic Cushing Syndrome (stop here) STAGE 3 — FIRST-LINE SCREENING (green boxes, 3 parallel tests): • 1mg Overnight Dexamethasone Suppression Test (1mg-DST): 1mg dex at 11pm, cortisol at 8am next day. Cutoff: >50 nmol/L (1.8 mcg/dL) = abnormal. Sensitivity 95%, Specificity 80% • 24-Hour Urinary Free Cortisol (UFC): ≥2 collections recommended. Cutoff: >ULN. Interfered by high fluid intake, CKD • Late-Night Salivary Cortisol (LNSC): 11pm sample. Cutoff varies by assay. Sensitivity >90%. Contamination risk • BONUS: Scalp Hair Cortisol/Cortisone (new tool): reflects 3 months of exposure; useful in cyclical CS STAGE 4 — INTERPRETATION (orange diamond decision box): • At least 2 abnormal tests → Endogenous CS confirmed • 1 abnormal test → Repeat or use additional tests • Consider false positives (obesity, CBG elevation from OCPs, stress, hospitalization, CYP3A4 inducers reducing dexamethasone) • Equivocal results → Dexamethasone-CRH test or 2mg 2-day DST for pseudo-Cushing differentiation STAGE 5 — ACTH MEASUREMENT (purple box): • Plasma ACTH: - ACTH <10 pg/mL (2.2 pmol/L) → ACTH-INDEPENDENT (15–20%) - ACTH >20 pg/mL → ACTH-DEPENDENT (80–85%) - ACTH 10–20 pg/mL → borderline → CRH stimulation test STAGE 6A — ACTH-INDEPENDENT CS (red branch): • Adrenal imaging: CT adrenals (first-line) - Unilateral adenoma → Adrenal adenoma - Bilateral macronodular adrenal hyperplasia (BMAH): ARMC5 mutation testing, aberrant receptor testing (GIP, vasopressin, LH, catecholamines) - Bilateral micronodular: PPNAD → Carney complex, PRKAR1A mutation - Adrenocortical carcinoma: large, irregular, HU>10 on CT • FDG-PET/CT or MRI adrenals if CT inconclusive STAGE 6B — ACTH-DEPENDENT CS (blue branch): • Pituitary MRI with gadolinium (first step): - Adenoma >6mm → Cushing's Disease (CD) likely - Normal or microadenoma <6mm → proceed to BIPSS • Bilateral Inferior Petrosal Sinus Sampling (BIPSS): - IPS:P ratio ≥2 basal or ≥3 after CRH → pituitary source (CD) - IPS:P ratio <2 → ectopic ACTH source • Ectopic ACTH workup: - CT chest/abdomen/pelvis - 68Ga-DOTATATE PET (somatostatin receptor scintigraphy) - FDG-PET/CT - Sources: bronchial carcinoid, SCLC, thymic carcinoid, pheochromocytoma, pancreatic NET, medullary thyroid cancer STAGE 7 — CYCLICAL CS (teal box): • Suspected when symptoms fluctuate • Multiple UFC or LNSC over time • Hair cortisol useful for detecting transient episodes STAGE 8 — FINAL DIAGNOSIS (bottom boxes in different colors): • Cushing's Disease (pituitary adenoma) — most common (65–70%) • Ectopic ACTH Syndrome (10–15%) • Adrenal Adenoma (10%) • BMAH / PPNAD / ACC (rare) • Cyclical Cushing Syndrome Include a small legend at bottom right showing color coding. Use connecting arrows with labeled decision branches (YES/NO, ABNORMAL/NORMAL, HIGH/LOW). Font should be legible (minimum 8pt). Layout: vertical with horizontal branches for ACTH-independent and ACTH-dependent. Citation at bottom: "Savas M et al. J Clin Endocrinol Metab. 2022;107(11):3162–3174. PMID: 36036941"

Not a flowchart but like a detailed so I don't have to read the actual index

Reading Web Page

https://pmc.ncbi.nlm.nih.gov/articles/PMC9681610

Reading Article

PMID: 36036941

Here is everything from the paper, structured so you don't need to open it.

Approach to the Patient: Diagnosis of Cushing Syndrome

Savas M, Mehta S, Agrawal N, van Rossum EFC, Feelders RA J Clin Endocrinol Metab. 2022;107(11):3162–3174 | PMID 36036941 | Full text PMC

1. What is Cushing Syndrome?

Cushing syndrome (CS) is the clinical state resulting from supraphysiological glucocorticoid exposure - either from outside the body or from the body's own overproduction. It carries serious morbidity (metabolic, cardiovascular, psychiatric, musculoskeletal) and elevated mortality if untreated. Early diagnosis is therefore important, but the condition is notoriously hard to diagnose because it mimics many common diseases.
Two broad categories:
TypeMechanismFrequency
Exogenous (Iatrogenic) CSGlucocorticoid medicationsMost common overall
Endogenous CSAutonomous cortisol overproductionRarer; requires full workup

2. Step 0 - Rule Out Exogenous Glucocorticoids First

Before doing any testing, ask about and check for:
  • Oral, inhaled, nasal, topical, intra-articular, ophthalmic, and rectal corticosteroids
  • Herbal/traditional medicines containing glucocorticoids
  • Anabolic steroids or megestrol acetate (can suppress the HPA axis)
If exogenous glucocorticoids are the cause → diagnosis is Iatrogenic CS. No further endogenous workup needed.

3. When to Screen - Clinical Suspicion

Screen patients who have multiple features from this list (especially if present in combination or at an unusually young age):
Classic signs/symptoms:
  • Central (truncal) obesity with thin limbs
  • Moon face (facial rounding and plethora)
  • Buffalo hump (dorsocervical fat pad)
  • Purple/violaceous striae wider than 1 cm
  • Proximal muscle weakness (difficulty rising from chair)
  • Easy bruising without trauma
  • Thin, fragile skin
Metabolic/systemic:
  • Hypertension (especially in patients under 40)
  • Diabetes mellitus or glucose intolerance disproportionate to weight
  • Dyslipidemia
  • Hypokalemia (especially in ectopic ACTH)
  • Osteoporosis/vertebral fractures in young patients
Other:
  • Menstrual irregularities / secondary amenorrhea
  • Hirsutism and acne in women
  • Decreased libido / erectile dysfunction
  • Depression, cognitive impairment, emotional lability
  • Growth arrest with weight gain in children (key pediatric clue)
  • Adrenal incidentaloma on imaging
The paper emphasizes: increased awareness among non-endocrinologists (family doctors, psychiatrists, neurologists) is key because these patients often present to other specialties first.

4. Pseudo-Cushing States - The Diagnostic Trap

Before confirming endogenous CS, you must exclude pseudo-Cushing states: conditions that activate the HPA axis and cause mild hypercortisolism WITHOUT true CS.
Pseudo-Cushing CauseNotes
Morbid obesityUFC mildly elevated, DST often abnormal
Major depression / melancholiaCortisol often elevated, late-night cortisol high
Chronic alcoholismFull clinical and biochemical CS picture possible
Poorly controlled type 2 diabetesUFC can be elevated
PregnancyCBG elevated, raises total cortisol
Polycystic ovary syndrome (PCOS)Clinical overlap (hirsutism, obesity)
Eating disorders (anorexia, bulimia)HPA activation
Chronic stress / critical illnessTransient hypercortisolism
Key distinction: Pseudo-Cushing resolves when the underlying cause resolves. The dexamethasone-CRH test or 2-day low-dose DST helps separate true CS from pseudo-Cushing in equivocal cases.

5. First-Line Screening Tests for Endogenous CS

At least 2 tests should be abnormal to confirm endogenous CS. No single test is perfect.

A. 1-mg Overnight Dexamethasone Suppression Test (1mg-DST)

  • Give 1 mg dexamethasone at 11 PM
  • Measure serum cortisol at 8–9 AM next morning
  • Normal: cortisol suppresses to ≤50 nmol/L (1.8 mcg/dL)
  • Abnormal (CS): cortisol >50 nmol/L
  • Sensitivity ~95%, Specificity ~80%
False positives (cortisol fails to suppress despite no CS):
  • CYP3A4 inducers reduce dexamethasone levels: rifampicin, phenytoin, carbamazepine, phenobarbital
  • Elevated CBG from oral contraceptive pills or pregnancy (raises total cortisol)
  • Obesity, depression, alcoholism
  • Poor compliance or absorption issues
False negatives (CS missed):
  • Cyclical CS (tested during a remission phase)
  • CYP3A4 inhibitors raise dexamethasone levels (e.g., ketoconazole, fluoxetine) - suppress cortisol even in true CS

B. 24-Hour Urinary Free Cortisol (UFC)

  • Collects unbound cortisol filtered by kidneys - reflects integrated daily cortisol production
  • Collect at least 2 samples (due to day-to-day variability)
  • Abnormal: above upper limit of normal (lab-dependent)
  • Very high UFC (>4x ULN) is highly specific for CS
Caveats and false results:
SituationEffect
High fluid intake (>5L/day)Falsely elevated UFC
Chronic kidney diseaseFalsely low UFC
Mild CSUFC can be normal in up to 20% of cases
Pseudo-Cushing (obesity, depression)Mildly elevated
Contamination of urine sampleArtificially elevated

C. Late-Night Salivary Cortisol (LNSC)

  • Exploits the fact that cortisol normally reaches its nadir around midnight
  • In CS, the normal diurnal rhythm is lost - cortisol remains elevated at 11 PM
  • Collect at 11 PM, 2 samples recommended
  • Sensitivity >90%, good specificity
  • Noninvasive and can be done at home - good for initial screening
Caveats:
  • Shift workers and those with disrupted sleep cycles have altered diurnal rhythms → false positives
  • Contamination (food, blood from gum disease) can raise levels
  • Some assays are not reliable - lab method matters
  • Critically ill patients have elevated nighttime cortisol

D. Scalp Hair Cortisol/Cortisone (Newer Tool)

  • Hair grows approximately 1 cm per month - the proximal 3 cm reflects the past 3 months
  • Captures long-term, integrated glucocorticoid exposure - unlike blood/urine/saliva which are snapshots
  • Particularly useful for:
    • Detecting cyclical CS (where blood/urine tests may be normal during remission phases)
    • Retrospective assessment - can detect a past hypercortisolism episode
    • High sensitivity for CS diagnosis
Limitation: Hair treatments (bleaching, perming) may affect results. Less well-standardized than other tests.

Equivocal Results - What to Do

When 1 test is abnormal or results are borderline:
  • Dexamethasone-CRH test: 2-day low-dose DST followed by CRH injection. In true CS, ACTH and cortisol rise despite dexamethasone. In pseudo-Cushing, they stay suppressed. Helps differentiate the two.
  • 2-day 2 mg DST (Liddle test): 0.5 mg dexamethasone every 6 hours for 48 hours. Cortisol >50 nmol/L after = abnormal.
  • Repeat testing over time (especially if cyclical CS suspected)
  • Clinical correlation is always essential

6. Confirming Endogenous CS - Plasma ACTH Measurement

Once endogenous hypercortisolism is biochemically confirmed, measure plasma ACTH to determine whether the cause is ACTH-driven or not.
ACTH LevelInterpretation
<10 pg/mL (2.2 pmol/L)ACTH-independent CS (adrenal source) → 15–20% of CS
>20 pg/mL (4.4 pmol/L)ACTH-dependent CS (pituitary or ectopic) → 80–85%
10–20 pg/mL (borderline)Repeat; consider CRH stimulation test
Critical note: ACTH must be collected properly - into a pre-chilled EDTA tube, immediately placed on ice, rapidly processed. Degradation causes falsely low ACTH.

7. ACTH-Independent CS - Adrenal Causes (15–20%)

First step: CT of the adrenal glands
FindingDiagnosis
Unilateral adenoma (smooth, <4 cm, HU <10 on CT)Adrenal adenoma (most common adrenal cause)
Large irregular mass, HU >10, heterogeneousAdrenocortical carcinoma (ACC) - high suspicion
Bilateral enlargement with large nodulesBilateral Macronodular Adrenal Hyperplasia (BMAH)
Bilateral small nodular glandsPrimary Pigmented Nodular Adrenocortical Disease (PPNAD)
BMAH specifics:
  • Often have aberrant G-protein coupled receptors (food-dependent via GIP, vasopressin, LH/hCG, catecholamines) → autonomous cortisol when stimulated
  • ARMC5 gene mutation is the most common genetic cause - check family members
  • Upright posture test, mixed meal test, and receptor testing recommended
PPNAD specifics:
  • Associated with Carney Complex (autosomal dominant)
  • PRKAR1A gene mutation
  • Adrenal CT can look normal - small glands with tiny nodules
When CT is inconclusive:
  • MRI adrenals (better soft tissue characterization)
  • FDG-PET/CT (malignant vs. benign)
  • 11C-metomidate PET (adrenocortical tissue identification)

8. ACTH-Dependent CS - Pituitary vs. Ectopic (80–85%)

Step 1: Pituitary MRI with gadolinium

  • Look for pituitary adenoma
  • >6 mm adenoma consistent with Cushing's Disease (CD) - most common cause (65–70% of all CS)
  • Limitation: MRI is normal in ~40% of Cushing's Disease cases (many microadenomas are too small to see)
  • A pituitary adenoma on MRI does not confirm CD - incidentalomas are common (10% of population)

Step 2: Dynamic Tests - If MRI Is Equivocal

CRH Stimulation Test:
  • Inject CRH IV → measure ACTH and cortisol at multiple time points
  • In CD: ACTH rises >35%, cortisol rises >20% above baseline
  • In Ectopic ACTH Syndrome (EAS): typically no/blunted response
  • In adrenal causes: no ACTH response
High-Dose Dexamethasone Suppression Test (HDDST):
  • 8 mg dexamethasone overnight (or 2 mg every 6 hours x 2 days)
  • In CD: cortisol suppresses by >50% (pituitary is partially responsive to feedback)
  • In EAS: usually NO suppression (ectopic tumors are autonomous)
  • Caveat: up to 10% of EAS can suppress; not fully reliable

Step 3: Bilateral Inferior Petrosal Sinus Sampling (BIPSS)

This is the gold standard for distinguishing CD from EAS.
How it works:
  • Bilateral catheters placed in the inferior petrosal sinuses (drain the pituitary) + simultaneous peripheral blood sampling
  • CRH administered IV to stimulate ACTH release
  • Measure ACTH at baseline and after CRH
Interpretation:
IPS:Peripheral ACTH RatioInterpretation
≥2 at baseline OR ≥3 after CRHPituitary source → Cushing's Disease
<2 baseline and <3 after CRHEctopic ACTH source
  • Sensitivity 94–97%, Specificity ~95%
  • Lateralization: higher ACTH on one side suggests which half of the pituitary harbors the adenoma (helps surgeon)
  • Limitation: operator-dependent, requires experienced interventional radiologist, risk of thrombosis (low)
When to do BIPSS:
  • MRI negative or equivocal
  • MRI shows adenoma but dynamic tests are discordant
  • High clinical suspicion of EAS with normal MRI

Step 4: Ectopic ACTH Syndrome Workup

Sources of ectopic ACTH:
Tumor% of EAS
Bronchial carcinoid~40% (most common)
Small cell lung cancer (SCLC)~20%
Thymic carcinoid~10%
Pancreatic NET~5%
Pheochromocytoma<5%
Medullary thyroid cancer<5%
Other NETsRemainder
Imaging workup for EAS:
  • CT chest/abdomen/pelvis (first line)
  • ⁶⁸Ga-DOTATATE PET/CT - somatostatin receptor imaging - excellent for carcinoid tumors (sensitivity ~80–90%)
  • FDG-PET/CT - better for more aggressive tumors (SCLC)
  • ⁶⁸Ga-DOTATOC or DOTATOC alternatives
  • MRI chest/abdomen if CT inconclusive
  • Occult EAS: tumor may not be found for years - watchful waiting and repeat imaging every 6–12 months
Clinical clue for EAS:
  • Severe/rapid-onset hypercortisolism
  • Marked hypokalemia (due to mineralocorticoid effect of very high cortisol)
  • Hyperpigmentation (very high ACTH stimulating MSH receptors)
  • Less classic Cushingoid appearance (rapid onset)

9. Cyclical Cushing Syndrome

  • Characterized by alternating periods of hypercortisolism and normal/low cortisol
  • All three CS subtypes can be cyclical
  • Very hard to diagnose - tests can be normal during remission phase
  • Hair cortisol is particularly valuable here - captures historical hypercortisolism
  • Multiple UFC/LNSC measurements over weeks to months
  • Clinical suspicion must remain high despite normal tests

10. Mild (Subclinical) Autonomous Cortisol Secretion (MACS)

  • Increasingly diagnosed due to widespread abdominal imaging and detection of adrenal incidentalomas
  • Cortisol mildly elevated on DST but patient may have few or no classic Cushingoid features
  • Associated with metabolic syndrome, hypertension, DM, osteoporosis
  • DST 1 mg cutoff: cortisol >138 nmol/L (5 mcg/dL) = overt CS; 50–138 nmol/L = possible MACS
  • Management is debated - watchful monitoring vs. adrenalectomy based on comorbidities

11. Summary: The Three Core Questions (Paper's Own Framework)

The paper organizes the diagnostic approach around 3 explicit questions:

Q1: WHEN to screen?

Screen patients with multiple features suggestive of CS, especially those with unusual combinations (e.g., young hypertension + DM + osteoporosis), progressive features, or adrenal incidentaloma with metabolic comorbidities.

Q2: HOW to screen?

Use at least 2 first-line tests (1mg-DST, 24h UFC, LNSC). Add hair cortisol for suspected cyclical CS. Interpret in context of individual patient factors. Use second-line tests (dex-CRH, HDDST) for equivocal cases.

Q3: HOW to differentiate causes?

  • First: measure plasma ACTH
  • ACTH-independent → adrenal CT
  • ACTH-dependent → pituitary MRI → dynamic tests → BIPSS if needed
  • Confirmed pituitary adenoma → Cushing's Disease
  • BIPSS negative → ectopic workup with somatostatin-receptor and FDG-PET imaging

Quick Reference Summary Table

StageActionKey Tests/Tools
Step 0Exclude exogenous steroidsHistory, review medications
Step 1Clinical recognitionSigns, symptoms, high-risk groups
Step 2First-line screening1mg-DST, 24h UFC, LNSC (≥2 abnormal to confirm)
Step 2bCyclical/equivocalHair cortisol, Dex-CRH test, repeat testing
Step 3ACTH measurementPlasma ACTH - ACTH-dep vs. ACTH-indep
Step 4AACTH-indep workupCT adrenals ± MRI, ARMC5/PRKAR1A genetics
Step 4BACTH-dep workupPituitary MRI → CRH test/HDDST → BIPSS
Step 5Ectopic workup if needed⁶⁸Ga-DOTATATE PET, CT chest/abdomen/pelvis

You didn't miss anything

Glad it covered everything! That paper is dense but the framework really is logical once you lay it out - the three-question structure (when to screen, how to screen, how to differentiate) is what makes it click.
A few things worth remembering when you apply this clinically:
  • The 1mg-DST is your workhorse - high sensitivity means a normal result is reassuring, but always check for CBG elevators (OCPs) and enzyme inducers (rifampicin, phenytoin) before trusting it
  • BIPSS is irreplaceable when MRI is negative or equivocal - don't skip it just because the MRI looks normal, since ~40% of Cushing's Disease has a radiologically invisible adenoma
  • Hair cortisol is the underused gem - especially if a patient has episodic symptoms and keeps testing normal on UFC/LNSC
  • Hypokalemia + rapid onset + hyperpigmentation = think ectopic ACTH first, not pituitary
If you want, I can go deeper on any single section - such as BIPSS technique and interpretation, the genetics of adrenal CS, or how to manage the equivocal/borderline cases.

Make a more in-depth writeup and give me a pdf

Reading File
Reading Web Page

https://pmc.ncbi.nlm.nih.gov/articles/PMC9681610

Running Command

mkdir -p /home/daytona/workspace/cushing-writeup

Writing File

~/cushing-writeup/generate_pdf.py

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

OUTPUT = "/home/daytona/workspace/cushing-writeup/Cushing_Syndrome_Diagnosis_Writeup.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
DARK_BLUE   = colors.HexColor("#1a3a5c")
MID_BLUE    = colors.HexColor("#2a6099")
LIGHT_BLUE  = colors.HexColor("#d6e8f7")
TEAL        = colors.HexColor("#1b7a7a")
TEAL_LIGHT  = colors.HexColor("#d0eeee")
ORANGE      = colors.HexColor("#c05a00")
ORANGE_LIGHT= colors.HexColor("#fde8cc")
RED         = colors.HexColor("#8b1a1a")
RED_LIGHT   = colors.HexColor("#fde0e0")
GREEN       = colors.HexColor("#1a5c2a")
GREEN_LIGHT = colors.HexColor("#d6f0dd")
PURPLE      = colors.HexColor("#4a1a6e")
PURPLE_LIGHT= colors.HexColor("#ead6f5")
GRAY_LIGHT  = colors.HexColor("#f2f2f2")
GRAY_MED    = colors.HexColor("#cccccc")
WHITE       = colors.white
BLACK       = colors.black

doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=2*cm, rightMargin=2*cm,
    topMargin=2*cm, bottomMargin=2*cm,
    title="Diagnosis of Cushing Syndrome – In-Depth Clinical Writeup",
    author="Savas M, Mehta S, Agrawal N, van Rossum EFC, Feelders RA"
)

styles = getSampleStyleSheet()

def style(name, **kw):
    s = styles[name].clone(name + str(id(kw)))
    for k, v in kw.items():
        setattr(s, k, v)
    return s

# Custom styles
H0 = style("Heading1", fontSize=22, textColor=WHITE, backColor=DARK_BLUE,
           spaceAfter=6, spaceBefore=0, leading=28, alignment=TA_CENTER,
           leftIndent=-1*cm, rightIndent=-1*cm, borderPad=8)

H1 = style("Heading1", fontSize=15, textColor=WHITE, backColor=MID_BLUE,
           spaceAfter=4, spaceBefore=14, leading=20)

H2 = style("Heading2", fontSize=12, textColor=DARK_BLUE,
           spaceAfter=3, spaceBefore=10, leading=16)

H3 = style("Heading3", fontSize=10.5, textColor=TEAL,
           spaceAfter=2, spaceBefore=8, leading=14)

BODY = style("Normal", fontSize=9.5, leading=14, spaceAfter=5,
             alignment=TA_JUSTIFY, textColor=colors.HexColor("#222222"))

BODY_SM = style("Normal", fontSize=8.5, leading=12, spaceAfter=4,
                alignment=TA_JUSTIFY, textColor=colors.HexColor("#333333"))

NOTE = style("Normal", fontSize=8.5, leading=12, spaceAfter=4,
             textColor=ORANGE, leftIndent=12, fontName="Helvetica-Oblique")

CAPTION = style("Normal", fontSize=8, leading=11, textColor=colors.HexColor("#555555"),
                alignment=TA_CENTER, fontName="Helvetica-Oblique")

SUB_HEAD = style("Normal", fontSize=10, textColor=WHITE, backColor=TEAL,
                 leading=14, spaceAfter=2, spaceBefore=6,
                 leftIndent=0, fontName="Helvetica-Bold")

BULLET = style("Normal", fontSize=9.5, leading=14, spaceAfter=3,
               leftIndent=18, textColor=colors.HexColor("#222222"))

def h1(txt): return Paragraph(f"&nbsp;&nbsp;{txt}", H1)
def h2(txt): return Paragraph(txt, H2)
def h3(txt): return Paragraph(txt, H3)
def body(txt): return Paragraph(txt, BODY)
def note(txt): return Paragraph(f"<b>Note:</b> {txt}", NOTE)
def small(txt): return Paragraph(txt, BODY_SM)
def spacer(h=0.3): return Spacer(1, h*cm)
def rule(c=MID_BLUE): return HRFlowable(width="100%", thickness=1, color=c, spaceAfter=4, spaceBefore=4)

def bullets(items, color=MID_BLUE):
    return ListFlowable(
        [ListItem(Paragraph(i, BULLET), bulletColor=color, bulletFontSize=8) for i in items],
        bulletType='bullet', leftIndent=12, spaceAfter=2
    )

def colored_box(text_paras, bg=LIGHT_BLUE, border=MID_BLUE, padding=8):
    inner = [[p] for p in text_paras]
    # Use a single-cell table as a colored box
    data = [[Paragraph(t, style("Normal", fontSize=9.5, leading=14,
                                alignment=TA_JUSTIFY,
                                textColor=colors.HexColor("#111111"))) if isinstance(t, str) else t]
            for t in text_paras]
    tbl = Table(data, colWidths=[16.5*cm])
    tbl.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), bg),
        ('BOX', (0,0), (-1,-1), 1, border),
        ('LEFTPADDING', (0,0), (-1,-1), padding),
        ('RIGHTPADDING', (0,0), (-1,-1), padding),
        ('TOPPADDING', (0,0), (-1,-1), 6),
        ('BOTTOMPADDING', (0,0), (-1,-1), 6),
        ('ROWBACKGROUNDS', (0,0), (-1,-1), [bg]),
    ]))
    return tbl

def data_table(headers, rows, col_widths=None, header_bg=MID_BLUE, alt_bg=GRAY_LIGHT):
    data = [headers] + rows
    if col_widths is None:
        col_widths = [16.5*cm / len(headers)] * len(headers)
    hstyle = style("Normal", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
                   leading=12, alignment=TA_CENTER)
    cstyle = style("Normal", fontSize=9, leading=12, alignment=TA_LEFT,
                   textColor=colors.HexColor("#111111"))
    fmt_data = [[Paragraph(str(c), hstyle) for c in headers]]
    for row in rows:
        fmt_data.append([Paragraph(str(c), cstyle) for c in row])
    tbl = Table(fmt_data, colWidths=col_widths, repeatRows=1)
    row_styles = [
        ('BACKGROUND', (0,0), (-1,0), header_bg),
        ('BOX', (0,0), (-1,-1), 0.5, GRAY_MED),
        ('INNERGRID', (0,0), (-1,-1), 0.3, GRAY_MED),
        ('VALIGN', (0,0), (-1,-1), 'TOP'),
        ('LEFTPADDING', (0,0), (-1,-1), 6),
        ('RIGHTPADDING', (0,0), (-1,-1), 6),
        ('TOPPADDING', (0,0), (-1,-1), 4),
        ('BOTTOMPADDING', (0,0), (-1,-1), 4),
    ]
    for i in range(1, len(fmt_data)):
        bg = WHITE if i % 2 == 1 else alt_bg
        row_styles.append(('BACKGROUND', (0,i), (-1,i), bg))
    tbl.setStyle(TableStyle(row_styles))
    return tbl

# ═══════════════════════════════════════════════════════════════════════════════
#  BUILD CONTENT
# ═══════════════════════════════════════════════════════════════════════════════
story = []

# ── COVER / TITLE ────────────────────────────────────────────────────────────
cover_title = Paragraph(
    "Diagnosis of Cushing Syndrome",
    style("Title", fontSize=28, textColor=WHITE, alignment=TA_CENTER, leading=34)
)
cover_sub = Paragraph(
    "An In-Depth Clinical Writeup",
    style("Normal", fontSize=16, textColor=LIGHT_BLUE, alignment=TA_CENTER, leading=20,
          fontName="Helvetica-Oblique")
)
cover_authors = Paragraph(
    "Savas M &bull; Mehta S &bull; Agrawal N &bull; van Rossum EFC &bull; Feelders RA",
    style("Normal", fontSize=10, textColor=LIGHT_BLUE, alignment=TA_CENTER, leading=14)
)
cover_journal = Paragraph(
    "J Clin Endocrinol Metab. 2022;107(11):3162–3174 &nbsp;|&nbsp; PMID: 36036941 &nbsp;|&nbsp; DOI: 10.1210/clinem/dgac492",
    style("Normal", fontSize=8.5, textColor=GRAY_LIGHT, alignment=TA_CENTER, fontName="Helvetica-Oblique")
)

cover_tbl = Table(
    [[cover_title], [Spacer(1,0.3*cm)], [cover_sub], [Spacer(1,0.2*cm)],
     [cover_authors], [Spacer(1,0.3*cm)], [cover_journal]],
    colWidths=[16.5*cm]
)
cover_tbl.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,-1), DARK_BLUE),
    ('LEFTPADDING', (0,0), (-1,-1), 20),
    ('RIGHTPADDING', (0,0), (-1,-1), 20),
    ('TOPPADDING', (0,0), (0,0), 30),
    ('BOTTOMPADDING', (0,-1), (-1,-1), 30),
    ('BOX', (0,0), (-1,-1), 2, MID_BLUE),
]))
story.append(cover_tbl)
story.append(spacer(0.8))

# ── INTRO BOX ────────────────────────────────────────────────────────────────
story.append(colored_box([
    Paragraph("<b>Purpose of this document:</b> A comprehensive clinical reference derived from the 2022 "
              "Endocrine Society \"Approach to the Patient\" article by Savas et al. It is structured to replace "
              "reading the primary article by covering every concept in the paper — pathogenesis, clinical recognition, "
              "biochemical testing with all caveats, differential diagnosis, imaging, BIPSS, ectopic workup, "
              "cyclical and subclinical CS, and special populations.", BODY)
], bg=LIGHT_BLUE, border=MID_BLUE))
story.append(spacer(0.5))

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 1 — OVERVIEW & PATHOGENESIS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("1.  Overview and Pathogenesis"))
story.append(body(
    "Cushing syndrome (CS) is the clinical state resulting from <b>chronic supraphysiological exposure to glucocorticoids</b>, "
    "whether from an exogenous source (administered corticosteroids) or from endogenous autonomous overproduction of cortisol. "
    "It is associated with significant morbidity — metabolic syndrome, cardiovascular disease, infections, psychiatric disorders, "
    "and musculoskeletal complications — and carries elevated all-cause mortality if untreated. "
    "Early diagnosis is therefore clinically important, yet the condition is notoriously difficult to identify in routine practice "
    "because it overlaps with many common conditions."
))

story.append(h2("1.1  Pathophysiology"))
story.append(body(
    "Under normal physiology, the hypothalamic–pituitary–adrenal (HPA) axis is tightly regulated by "
    "negative feedback. The hypothalamus releases corticotropin-releasing hormone (CRH), which stimulates the anterior pituitary "
    "to secrete adrenocorticotropic hormone (ACTH). ACTH acts on the adrenal cortex (zona fasciculata) to produce cortisol. "
    "Elevated cortisol feeds back to inhibit both CRH and ACTH secretion, maintaining homeostasis."
))
story.append(body(
    "In CS, this normal feedback is disrupted. The source of disruption determines the subtype:"
))

story.append(data_table(
    ["Type", "Mechanism", "ACTH Level", "Frequency"],
    [
        ["Exogenous (Iatrogenic)", "Administered glucocorticoids suppress HPA axis; adrenals atrophy", "Suppressed (<10 pg/mL)", "Most common overall"],
        ["Cushing's Disease (CD)", "ACTH-secreting pituitary adenoma (usually microadenoma) drives bilateral adrenal hyperplasia", "Elevated or normal-high (20–200 pg/mL)", "~65–70% of endogenous CS"],
        ["Ectopic ACTH Syndrome (EAS)", "Non-pituitary tumor secretes ACTH autonomously; often markedly elevated", "Very high (often >200 pg/mL)", "~10–15% of endogenous CS"],
        ["Adrenal Adenoma", "Unilateral benign tumor produces cortisol autonomously; contralateral adrenal atrophies", "Suppressed (<10 pg/mL)", "~10% of endogenous CS"],
        ["Bilateral Macronodular Adrenal Hyperplasia (BMAH)", "Bilateral autonomous cortisol via aberrant G-protein receptors or ARMC5 mutations", "Low-normal or suppressed", "~2–5%"],
        ["Primary Pigmented Nodular Adrenocortical Disease (PPNAD)", "Bilateral small pigmented nodules; associated with Carney complex (PRKAR1A mutation)", "Suppressed", "Rare"],
        ["Adrenocortical Carcinoma (ACC)", "Malignant adrenal tumor with autonomous cortisol production", "Suppressed", "Rare, ~1–2%"],
    ],
    col_widths=[3.5*cm, 5*cm, 3.5*cm, 4.5*cm],
    header_bg=DARK_BLUE
))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 2 — CLINICAL PRESENTATION
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("2.  Clinical Presentation and When to Screen"))
story.append(body(
    "No single clinical feature is pathognomonic for CS. The diagnosis should be considered when a patient presents "
    "with <b>multiple concurrent features</b>, particularly those that are unusual for the patient's age, progressive over time, "
    "or combined with metabolic comorbidities that are disproportionate to obesity alone. "
    "The paper emphasizes that increased physician awareness outside endocrinology — in primary care, psychiatry, neurology, "
    "rheumatology, and dermatology — is key to earlier diagnosis."
))

story.append(h2("2.1  Cardinal Clinical Features"))
story.append(data_table(
    ["Feature", "Clinical Notes", "Discriminating Value"],
    [
        ["Purple striae >1 cm wide", "Wide (>1 cm), violaceous, typically on abdomen, flanks, thighs, breasts", "High — thin skin + rapid fat deposition"],
        ["Easy bruising", "Spontaneous ecchymoses without significant trauma; especially in young patients", "High in young adults"],
        ["Proximal muscle weakness", "Difficulty rising from squat, climbing stairs; type II fiber atrophy", "High specificity when present"],
        ["Moon face (facial rounding/plethora)", "Rounded face with facial redness; fat redistribution", "Moderate — common in obesity too"],
        ["Central (truncal) obesity", "Fat deposition trunk + limbs spared; buffalo hump (dorsocervical fat)", "Moderate"],
        ["Hypertension, young age", "HTN in a patient under 40 without family history or other cause", "High suspicion trigger"],
        ["Unexplained DM or glucose intolerance", "Insulin resistance mediated by glucocorticoid excess", "Moderate"],
        ["Osteoporosis / vertebral fractures", "In young patients with no other risk factor; osteocalcin suppressed", "High in young patients"],
        ["Menstrual irregularity / amenorrhea", "Due to androgen excess and HPA suppression of LH/FSH", "Moderate"],
        ["Hirsutism and acne", "Adrenal androgen excess; more pronounced in EAS and ACC", "Moderate"],
        ["Hypokalemia", "Mineralocorticoid effect of very high cortisol saturating 11β-HSD2; especially in EAS", "Very high for EAS"],
        ["Hyperpigmentation", "Very elevated ACTH stimulates MSH receptors; only in ACTH-dependent CS", "High for EAS/severe CD"],
        ["Children: weight gain + growth arrest", "Weight gain with concurrent poor linear growth is a key pediatric clue", "Very high in children"],
        ["Adrenal incidentaloma on CT/MRI", "Found on imaging; requires exclusion of MACS", "Triggers subclinical workup"],
        ["Psychiatric symptoms", "Depression, emotional lability, cognitive impairment, insomnia, anxiety", "Low-moderate — non-specific"],
        ["Frequent infections", "Immune suppression from glucocorticoid excess", "Low-moderate"],
    ],
    col_widths=[4*cm, 7.5*cm, 5*cm],
    header_bg=TEAL
))
story.append(spacer())

story.append(h2("2.2  High-Priority Screening Groups"))
story.append(body("The Endocrine Society and the paper specifically recommend screening in these groups:"))
story.append(bullets([
    "Young patients with osteoporosis, especially vertebral fractures without adequate trauma",
    "Patients under 40 with hypertension, particularly if resistant to multiple agents",
    "Patients with adrenal incidentaloma — screen for MACS with 1mg-DST regardless of symptoms",
    "Children with unexplained weight gain combined with growth deceleration",
    "Patients with multiple early-onset metabolic features: DM + HTN + obesity + dyslipidemia",
    "Patients with cystic acne, hirsutism, and menstrual irregularities not explained by PCOS alone",
    "Patients with unexplained hypokalemia (especially severe) — consider EAS",
], color=TEAL))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 3 — PSEUDO-CUSHING STATES
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("3.  Pseudo-Cushing States — The Diagnostic Trap"))
story.append(body(
    "Pseudo-Cushing states (PCS) are conditions that activate the HPA axis — causing mild-to-moderate hypercortisolism "
    "with partial clinical features of CS — but are <b>not due to autonomous cortisol overproduction</b>. "
    "They are the most important diagnostic pitfall in CS workup. Mild CS and pseudo-Cushing can be clinically "
    "and biochemically indistinguishable, and only resolve with treatment of the underlying cause. "
    "The paper stresses that PCS should always be considered when CS testing results are equivocal."
))
story.append(data_table(
    ["Pseudo-Cushing Cause", "Mechanism of HPA Activation", "Key Differentiating Clue"],
    [
        ["Morbid obesity", "Increased cortisol production rate; altered cortisol metabolism", "UFC mildly elevated; LNSC often normal; CRH test helps"],
        ["Major depression / melancholia", "Increased CRH tone from limbic system; loss of circadian rhythm", "Clinical remission normalizes cortisol"],
        ["Chronic alcoholism", "Alcohol increases CRH; direct adrenal stimulation", "Cortisol normalizes with abstinence (2–4 weeks)"],
        ["Poorly controlled type 2 DM", "Insulin resistance increases cortisol; chronic stress activation", "Glucose control often normalizes UFC"],
        ["Pregnancy", "Elevated CBG raises total cortisol; placental CRH activates HPA", "Salivary or urine free cortisol must be interpreted trimester-specifically"],
        ["Polycystic ovary syndrome (PCOS)", "Adrenal androgen excess; obesity-related HPA activation", "Normal late-night salivary cortisol; ACTH usually normal"],
        ["Eating disorders (anorexia, bulimia)", "Starvation-induced HPA activation; high CRH", "Nutritional restoration normalizes axis"],
        ["Chronic stress / critical illness", "Physiological HPA activation", "Resolves with removal of stressor"],
        ["Hypothyroidism", "Slowed cortisol clearance raises measured levels", "TSH; treat hypothyroidism first"],
        ["Vigorous chronic exercise", "HPA activation; falsely elevated 24h UFC", "Contextual history"],
    ],
    col_widths=[4*cm, 6*cm, 6.5*cm],
    header_bg=RED
))
story.append(spacer())
story.append(colored_box([
    Paragraph("<b>Second-line tests to distinguish true CS from pseudo-Cushing (equivocal results):</b>", BODY),
    Paragraph("• <b>Dexamethasone–CRH test:</b> 2-day low-dose DST (0.5 mg every 6 h x 48 h) followed by IV CRH at 8 AM "
              "on day 3. In true CS, cortisol rises >38 nmol/L (1.4 mcg/dL) above baseline. In PCS, cortisol stays suppressed. "
              "This exploits the fact that true CS retains responsiveness to CRH even after dexamethasone.", BULLET),
    Paragraph("• <b>2-day low-dose DST (2 mg/day Liddle test):</b> 0.5 mg dexamethasone every 6 hours for 48 hours. "
              "Cortisol >50 nmol/L after = consistent with CS.", BULLET),
    Paragraph("• <b>Repeated testing over time:</b> If clinically suspicious but tests are equivocal, repeat UFC and LNSC on "
              "multiple occasions over several weeks. This is also the approach for suspected cyclical CS.", BULLET),
], bg=ORANGE_LIGHT, border=ORANGE))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 4 — FIRST-LINE SCREENING TESTS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("4.  First-Line Biochemical Screening Tests"))
story.append(body(
    "At least two first-line tests should be abnormal before confirming endogenous CS. No single test has 100% "
    "sensitivity and specificity. The choice of which tests to use first depends on clinical context, patient-specific "
    "factors, and local laboratory capabilities. The paper recommends using all three standard tests when feasible, "
    "with hair cortisol added in suspected cyclical CS."
))

# ── 4.1 1mg DST ─────────────────────────────────────────────────────────────
story.append(h2("4.1  1-mg Overnight Dexamethasone Suppression Test (1mg-DST)"))
story.append(body(
    "<b>Principle:</b> Dexamethasone is a synthetic glucocorticoid that suppresses ACTH (and hence cortisol) "
    "via negative feedback at the pituitary. In normal individuals, 1 mg dexamethasone given at 11 PM suppresses "
    "8 AM cortisol to &le;50 nmol/L. In CS, the feedback set-point is reset higher; cortisol fails to suppress."
))
story.append(data_table(
    ["Parameter", "Detail"],
    [
        ["Dose & Timing", "1 mg dexamethasone orally at 11:00 PM"],
        ["Blood draw", "Serum cortisol at 8:00–9:00 AM the following morning"],
        ["Normal (suppressed) result", "Cortisol ≤50 nmol/L (1.8 mcg/dL) — CS unlikely"],
        ["Abnormal (non-suppressed) result", "Cortisol >50 nmol/L — proceed with further testing"],
        ["Sensitivity", "~95% (high — good test to rule out CS if normal)"],
        ["Specificity", "~80% (moderate — significant false-positive rate)"],
    ],
    col_widths=[4.5*cm, 12*cm], header_bg=MID_BLUE
))
story.append(spacer(0.3))
story.append(h3("False Positives (cortisol does not suppress despite no true CS):"))
story.append(bullets([
    "<b>CYP3A4 inducers</b> accelerate dexamethasone metabolism → lower dex levels → cortisol fails to suppress. "
    "Examples: rifampicin, phenytoin, carbamazepine, phenobarbital, St John's Wort",
    "<b>Elevated CBG (corticosteroid-binding globulin)</b> raises measured total cortisol without increasing free cortisol. "
    "Causes: oral contraceptive pills, HRT, pregnancy (estrogen induces CBG synthesis)",
    "<b>Pseudo-Cushing states</b>: obesity, major depression, alcoholism, poorly controlled DM, PCOS",
    "<b>Poor compliance</b> or absorption failure — dex not taken at correct time or not absorbed",
    "<b>Hospitalization and critical illness</b> — stress-induced HPA activation",
]))
story.append(h3("False Negatives (CS missed — cortisol wrongly suppresses):"))
story.append(bullets([
    "<b>CYP3A4 inhibitors</b> slow dexamethasone metabolism → dex levels higher than expected → even true CS suppresses. "
    "Examples: ketoconazole, itraconazole, fluoxetine, fluvoxamine, diltiazem",
    "<b>Cyclical CS</b> — if tested during a remission phase, cortisol may suppress normally",
    "<b>Mild CS</b> — UFC is the better test here since feedback sensitivity may be preserved at mild excess",
]))
story.append(spacer())

# ── 4.2 UFC ──────────────────────────────────────────────────────────────────
story.append(h2("4.2  24-Hour Urinary Free Cortisol (UFC)"))
story.append(body(
    "<b>Principle:</b> Free (unbound) cortisol is filtered by the glomerulus and excreted in urine. "
    "The 24-hour UFC reflects integrated daily cortisol production and is independent of CBG. "
    "Once cortisol production exceeds the binding capacity of CBG (~700 nmol/L), free cortisol rises "
    "disproportionately, making UFC highly elevated in overt CS."
))
story.append(data_table(
    ["Parameter", "Detail"],
    [
        ["Collection", "Complete 24-hour urine in a boric acid or acid-preserved container"],
        ["Minimum collections", "At least 2 separate 24-hour samples recommended (day-to-day variability is high)"],
        ["Normal result", "Below upper limit of normal (ULN) for the assay — lab-specific; typically <280–330 nmol/day"],
        ["Abnormal result (high specificity threshold)", ">4× ULN is highly specific for CS; moderate elevations are equivocal"],
        ["Sensitivity", "~75–95% (lower in mild CS — can be normal in up to 20% of mild cases)"],
        ["Specificity", "~95% at >4×ULN threshold"],
        ["Method", "LC-MS/MS preferred; immunoassay overestimates UFC and is less reliable"],
    ],
    col_widths=[4.5*cm, 12*cm], header_bg=MID_BLUE
))
story.append(spacer(0.3))
story.append(h3("Key Caveats and Confounders:"))
story.append(data_table(
    ["Condition", "Effect on UFC", "Action"],
    [
        ["High fluid intake (>5 L/day)", "Falsely elevated — dilutes plasma cortisol but increases urine volume", "Check 24h urine volume; repeat if >3 L"],
        ["Chronic kidney disease (GFR <30)", "Falsely LOW — reduced cortisol filtration", "UFC unreliable in CKD — use other tests"],
        ["Mild CS", "Can be within normal range in up to 20% of cases", "Repeat collection; add LNSC and DST"],
        ["Pseudo-Cushing states", "Mildly elevated (1–3× ULN) — overlaps with mild CS", "Dex-CRH test to differentiate"],
        ["Incomplete collection", "Falsely low — check 24h urinary creatinine to verify completeness", "Verify: creatinine 10–20 mg/kg/day in women, 15–25 in men"],
        ["Synthetic glucocorticoids", "Some cross-react with immunoassay but not LC-MS/MS", "Specify assay method"],
    ],
    col_widths=[4*cm, 6.5*cm, 6*cm], header_bg=TEAL
))
story.append(spacer())

# ── 4.3 LNSC ─────────────────────────────────────────────────────────────────
story.append(h2("4.3  Late-Night Salivary Cortisol (LNSC)"))
story.append(body(
    "<b>Principle:</b> Normally, cortisol follows a diurnal rhythm with a morning peak and a nadir around 11 PM–midnight. "
    "In CS, the nadir is lost — cortisol remains elevated late at night. Salivary cortisol closely reflects "
    "free serum cortisol (salivary glands have 11β-HSD1), making it a noninvasive measure of the unbound fraction. "
    "This can be collected at home, making it practical for outpatient screening."
))
story.append(data_table(
    ["Parameter", "Detail"],
    [
        ["Collection time", "11:00 PM (midnight nadir)"],
        ["Number of samples", "2 separate collections on different nights recommended"],
        ["Method", "Salivette tube (cotton roll) — patient chews roll for 1–2 minutes"],
        ["Cutoff", "Assay-dependent; typically >4–8 nmol/L (LC-MS/MS); >3.6 nmol/L (Roche ECLIA) — check local lab"],
        ["Sensitivity", ">90%"],
        ["Specificity", "~90–96%"],
        ["Advantage", "Non-invasive, at-home collection, not affected by CBG, reflects free cortisol"],
    ],
    col_widths=[4.5*cm, 12*cm], header_bg=MID_BLUE
))
story.append(spacer(0.3))
story.append(h3("Key Caveats:"))
story.append(bullets([
    "<b>Shift workers and night workers</b> have disrupted circadian rhythms — their late-night cortisol can be elevated physiologically. LNSC is unreliable in this group.",
    "<b>Contamination</b> — eating, drinking, brushing teeth, or gum bleeding within 30 minutes before collection raises salivary cortisol artificially. Strict instructions required.",
    "<b>Critical illness and hospitalization</b> — stress-related HPA activation raises LNSC; unreliable in inpatients.",
    "<b>Smoking</b> — may elevate cortisol slightly.",
    "<b>Assay variability</b> — immunoassay and LC-MS/MS have different cutoffs; do not interchange thresholds.",
    "Certain medications (e.g., licorice-containing products) inhibit 11β-HSD2 and may affect salivary cortisol.",
]))
story.append(spacer())

# ── 4.4 Hair cortisol ────────────────────────────────────────────────────────
story.append(h2("4.4  Scalp Hair Cortisol and Cortisone (Newer Tool)"))
story.append(body(
    "Hair analysis represents a paradigm shift from snapshot testing to <b>long-term retrospective assessment</b>. "
    "Hair grows at approximately 1 cm per month. Cortisol and its metabolite cortisone are incorporated into "
    "the hair shaft during growth, encoding a month-by-month record of glucocorticoid exposure. "
    "The proximal 3 cm reflects approximately the past 3 months of systemic cortisol."
))
story.append(h3("Clinical Utility:"))
story.append(bullets([
    "<b>High sensitivity for CS diagnosis</b> — captures chronic hypercortisolism even when urine/saliva tests are normal",
    "<b>Cyclical CS detection</b> — the most valuable application: historical hypercortisolism episodes leave a biochemical 'scar' in hair even if current testing is normal",
    "<b>Long-term monitoring</b> — assessing treatment response over months",
    "<b>Assessment in patients unable to collect urine or saliva reliably</b>",
    "Can distinguish chronic CS from acute stress (which does not significantly elevate hair cortisol)",
]))
story.append(h3("Limitations:"))
story.append(bullets([
    "Hair treatments (bleaching, perming, dyeing) can degrade cortisol in the hair shaft — result may be falsely low",
    "Less standardized than other tests — cutoffs and methods vary between laboratories",
    "Hair grows at variable rates between individuals; exact month-to-month mapping is approximate",
    "Short hair or hair loss (alopecia) limits sample size",
    "Not yet included in major society guidelines as a standard first-line test, but increasingly referenced in the literature",
]))
story.append(spacer())

# ── Test Comparison Table ────────────────────────────────────────────────────
story.append(h2("4.5  Comparison of First-Line Tests"))
story.append(data_table(
    ["Test", "Sensitivity", "Specificity", "Best For", "Main Pitfall"],
    [
        ["1mg-DST", "~95%", "~80%", "Ruling out CS (high sensitivity)", "False positives: OCPs, enzyme inducers"],
        ["24h UFC", "~75–95%", "~95% at >4×ULN", "Confirming overt CS; monitoring", "Mild CS: can be normal; CKD: unreliable"],
        ["LNSC", ">90%", "~90–96%", "Outpatient screening; shift workers excluded", "Night workers, contamination, hospitalized patients"],
        ["Hair cortisol", "High (emerging data)", "High (emerging data)", "Cyclical CS, retrospective assessment", "Hair treatments, less standardized"],
        ["Dex-CRH test", "~98%", "~88%", "Distinguishing CS from pseudo-Cushing", "Requires 2-day protocol; not widely available"],
    ],
    col_widths=[2.8*cm, 2*cm, 2.5*cm, 5*cm, 4.2*cm],
    header_bg=PURPLE
))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 5 — CONFIRMING ENDOGENOUS CS: PLASMA ACTH
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("5.  Confirming Endogenous CS: Plasma ACTH"))
story.append(body(
    "Once two first-line screening tests are abnormal (or one is markedly abnormal), endogenous CS is established. "
    "The next step is to measure <b>plasma ACTH</b> to determine whether the driving force is ACTH-dependent "
    "(pituitary or ectopic tumor secreting ACTH) or ACTH-independent (autonomous adrenal overproduction of cortisol)."
))
story.append(colored_box([
    Paragraph("<b>Pre-analytical requirements for ACTH — critical:</b> ACTH is highly unstable in plasma. "
              "Collect into a pre-chilled EDTA tube, place immediately on ice, centrifuge within 30 minutes "
              "at 4°C, and process rapidly. Failure to do so causes ex vivo ACTH degradation, leading to "
              "falsely low ACTH levels — which can incorrectly suggest an adrenal source.", BODY)
], bg=RED_LIGHT, border=RED))
story.append(spacer(0.3))
story.append(data_table(
    ["ACTH Level", "Interpretation", "Next Step"],
    [
        ["<10 pg/mL (2.2 pmol/L)", "ACTH-INDEPENDENT CS — adrenal autonomous cortisol", "CT of adrenal glands"],
        ["10–20 pg/mL (borderline)", "Indeterminate — repeat; consider CRH stimulation test", "CRH stimulation; repeat ACTH"],
        [">20 pg/mL (4.4 pmol/L)", "ACTH-DEPENDENT CS — pituitary or ectopic", "Pituitary MRI; dynamic tests; BIPSS"],
    ],
    col_widths=[4*cm, 7*cm, 5.5*cm], header_bg=PURPLE
))
story.append(spacer(0.3))
story.append(body(
    "ACTH-dependent CS accounts for approximately <b>80–85%</b> of endogenous CS, and ACTH-independent CS for "
    "<b>15–20%</b>. Within ACTH-dependent CS, Cushing's Disease (pituitary adenoma) is the cause in about "
    "80% of cases, with ectopic ACTH in ~20%."
))

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 6 — ACTH-INDEPENDENT CS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("6.  ACTH-Independent Cushing Syndrome — Adrenal Causes"))
story.append(h2("6.1  CT of the Adrenal Glands — First-Line Imaging"))
story.append(body(
    "CT of the adrenal glands with thin slices (3 mm) and Hounsfield unit (HU) measurement is the standard "
    "first-line imaging for adrenal CS. Adrenal protocol CT includes unenhanced, portal venous, and delayed phases."
))
story.append(data_table(
    ["CT Finding", "Likely Diagnosis", "Key Features"],
    [
        ["Unilateral smooth nodule, HU ≤10 (lipid-rich)", "Benign adrenal adenoma", "Round, homogeneous, rapid contrast washout (>50% absolute)"],
        ["Unilateral nodule, HU >10, heterogeneous, >4 cm", "Adrenocortical carcinoma (ACC) or lipid-poor adenoma", "Irregular borders, calcifications, slow washout, possible local invasion"],
        ["Bilateral large nodules (>1 cm)", "Bilateral Macronodular Adrenal Hyperplasia (BMAH)", "Both adrenals enlarged; nodules of varying sizes"],
        ["Bilateral small glands / normal or tiny nodules", "Primary Pigmented Nodular Adrenocortical Disease (PPNAD)", "CT may appear normal or minimally abnormal"],
        ["Bilateral diffuse hyperplasia", "Severe/chronic ACTH-dependent CS", "Context: elevated ACTH expected in this case"],
    ],
    col_widths=[4*cm, 4.5*cm, 8*cm], header_bg=TEAL
))
story.append(spacer())

story.append(h2("6.2  Adrenal Adenoma"))
story.append(body(
    "The most common adrenal cause. A benign, unilateral, lipid-rich adenoma secretes cortisol autonomously. "
    "The contralateral adrenal typically atrophies from ACTH suppression. "
    "Treatment: unilateral adrenalectomy (laparoscopic). Post-op HPA axis suppression requires glucocorticoid "
    "replacement until the contralateral adrenal recovers (can take 6–24 months)."
))

story.append(h2("6.3  Adrenocortical Carcinoma (ACC)"))
story.append(body(
    "A rare but important diagnosis. Features suggesting ACC: size >4 cm, HU >10, heterogeneous texture, "
    "calcifications, irregular margins, delayed contrast washout. "
    "ACC often co-secretes multiple hormones (cortisol + androgens + aldosterone). "
    "Always image the liver and lung to stage. FDG-PET/CT detects metastases. "
    "Treatment: adrenalectomy ± mitotane. Prognosis is poor for advanced disease."
))

story.append(h2("6.4  Bilateral Macronodular Adrenal Hyperplasia (BMAH)"))
story.append(body(
    "BMAH is characterized by both adrenals developing large nodules that secrete cortisol independently of ACTH. "
    "A major mechanism is the expression of <b>aberrant G-protein coupled receptors</b> in the adrenal nodules "
    "that respond to non-ACTH stimuli:"
))
story.append(bullets([
    "<b>GIP (glucose-dependent insulinotropic peptide)</b> — food-dependent Cushing: cortisol rises after eating",
    "<b>Vasopressin V1/V2 receptors</b> — cortisol rises with vasopressin or its analogues",
    "<b>LH/hCG receptors</b> — cortisol rises during pregnancy or with LH surges (postmenopausal CS)",
    "<b>Beta-adrenergic receptors</b> — cortisol rises with catecholamine stimulation",
    "<b>Serotonin, angiotensin II, glucagon</b> receptors — variable",
]))
story.append(body(
    "<b>Genetic cause:</b> The most common germline mutation is in <b>ARMC5</b> (armadillo repeat containing 5), "
    "found in ~25–50% of BMAH cases. It follows an autosomal dominant pattern. "
    "Family screening with 1mg-DST is recommended for first-degree relatives. "
    "Somatic ARMC5 mutations also occur. Other mutations: KDM1A, MEN1, GNAS."
))
story.append(body(
    "<b>Diagnostic workup:</b> Aberrant receptor testing involves measuring cortisol before and after "
    "standardized stimuli (upright posture, mixed meal test, IV GnRH, IV vasopressin). "
    "A cortisol rise >25% with a stimulus confirms that receptor. "
    "<b>Treatment:</b> Bilateral adrenalectomy for florid CS; unilateral adrenalectomy for milder cases; "
    "receptor-targeted therapy (e.g., octreotide for GIP-dependent) in selected cases."
))

story.append(h2("6.5  Primary Pigmented Nodular Adrenocortical Disease (PPNAD)"))
story.append(body(
    "PPNAD is a rare bilateral adrenal condition characterized by small (<5 mm) pigmented (brown-black) micronodules "
    "in the adrenal cortex, causing autonomous cortisol overproduction. It is strongly associated with "
    "<b>Carney Complex</b>, an autosomal dominant syndrome caused by loss-of-function mutations in <b>PRKAR1A</b> "
    "(protein kinase A regulatory subunit 1A)."
))
story.append(body(
    "<b>Carney Complex features:</b> cardiac myxomas, cutaneous myxomas, spotty skin pigmentation (lentigines), "
    "Sertoli cell tumors, pituitary GH/PRL adenomas, thyroid tumors. "
    "Adrenal CT may appear <i>normal</i> or show only minimal bilateral enlargement — do not rule out PPNAD on CT alone. "
    "The diagnosis can be confirmed with paradoxical rise in UFC on high-dose dexamethasone (Liddle test — UFC increases rather than decreases). "
    "<b>Treatment:</b> Bilateral adrenalectomy."
))

story.append(h2("6.6  When CT is Inconclusive — Additional Adrenal Imaging"))
story.append(bullets([
    "<b>MRI adrenals</b>: Chemical shift imaging distinguishes lipid-rich adenomas (signal drop on out-of-phase) from lipid-poor nodules or carcinoma",
    "<b>FDG-PET/CT</b>: Differentiates malignant (FDG-avid) from benign (low FDG uptake) adrenal lesions",
    "<b>¹¹C-metomidate PET</b>: Highly specific for adrenocortical tissue (binds 11β-hydroxylase); distinguishes adrenocortical from non-adrenocortical lesions",
    "<b>Adrenal vein sampling (AVS)</b>: Used when bilateral adrenal lesions are present and surgical lateralization is needed to decide unilateral vs. bilateral adrenalectomy",
]))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 7 — ACTH-DEPENDENT CS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("7.  ACTH-Dependent Cushing Syndrome"))
story.append(h2("7.1  Pituitary MRI — First Step"))
story.append(body(
    "In ACTH-dependent CS, a <b>pituitary MRI with gadolinium contrast</b> (thin cuts through the pituitary, "
    "dynamic contrast-enhanced sequences) is the first imaging step."
))
story.append(data_table(
    ["Finding", "Interpretation", "Action"],
    [
        ["Discrete adenoma >6 mm", "Strongly suggestive of Cushing's Disease (CD)", "Confirm with CRH test; proceed to neurosurgery if concordant"],
        ["Microadenoma <6 mm", "Consistent with CD but not diagnostic (incidentalomas common in 10% of population)", "Confirm with dynamic testing; consider BIPSS"],
        ["Normal pituitary MRI", "Does NOT rule out CD — up to 40% of CD have no visible adenoma", "Proceed to dynamic tests and BIPSS"],
        ["Macroadenoma >10 mm (rare in CD)", "Unusual for CD; consider other causes", "Confirm ACTH staining on pathology after surgery"],
        ["Cystic pituitary lesion / Rathke cleft cyst", "Not a functional adenoma — do not operate without BIPSS confirmation", "BIPSS mandatory"],
    ],
    col_widths=[4*cm, 5.5*cm, 7*cm], header_bg=MID_BLUE
))
story.append(note(
    "A normal MRI does not exclude CD. BIPSS remains the gold standard when MRI is negative or equivocal. "
    "Approximately 40% of CD patients have no adenoma visible on MRI."
))
story.append(spacer())

story.append(h2("7.2  Dynamic Biochemical Tests for ACTH-Dependent CS"))
story.append(body(
    "These tests exploit the partial preservation of feedback and stimulation responses in Cushing's Disease "
    "(pituitary adenoma) versus the autonomy of ectopic ACTH sources."
))

story.append(h3("A. CRH Stimulation Test"))
story.append(data_table(
    ["Parameter", "Detail"],
    [
        ["Protocol", "IV ovine or human CRH 1 mcg/kg or 100 mcg fixed dose; blood at -15, 0, +15, +30, +45, +60 min for ACTH and cortisol"],
        ["Positive result (CD)", "ACTH rise >35–50% above baseline AND/OR cortisol rise >14–20% above baseline"],
        ["Negative result (EAS)", "Blunted or no ACTH and cortisol response"],
        ["Sensitivity for CD", "~85–93%"],
        ["Specificity for CD vs EAS", "~100% (virtually no EAS shows CRH response)"],
        ["Note", "Some bronchial carcinoids express CRH receptors and may show a false positive — rare"],
    ],
    col_widths=[4*cm, 12.5*cm], header_bg=TEAL
))
story.append(spacer(0.3))

story.append(h3("B. High-Dose Dexamethasone Suppression Test (HDDST)"))
story.append(data_table(
    ["Parameter", "Detail"],
    [
        ["Protocol (overnight)", "8 mg dexamethasone at 11 PM; cortisol at 8 AM next morning"],
        ["Protocol (2-day)", "2 mg dexamethasone every 6 h for 48 h; cortisol at end"],
        ["Positive result (CD)", "Cortisol suppresses by >50% from baseline — pituitary adenoma retains partial sensitivity to glucocorticoid feedback"],
        ["Negative result (EAS)", "No suppression — ectopic tumors are autonomously secreting, no feedback sensitivity"],
        ["Sensitivity for CD", "~60–80%"],
        ["Specificity", "~60–90% — significant overlap; up to 10% of EAS suppress"],
        ["Current status", "Less relied upon than BIPSS; used in combination with CRH test and MRI for concordance"],
    ],
    col_widths=[4*cm, 12.5*cm], header_bg=TEAL
))
story.append(spacer(0.4))
story.append(colored_box([
    Paragraph("<b>Concordance principle:</b> Using CRH test + HDDST + MRI together improves accuracy. "
              "When all three point to pituitary (adenoma on MRI + CRH response + HDDST suppression), "
              "the positive predictive value for CD is very high, potentially reducing the need for BIPSS. "
              "When results are discordant, BIPSS is mandatory.", BODY)
], bg=LIGHT_BLUE, border=MID_BLUE))
story.append(spacer())

# ── BIPSS ─────────────────────────────────────────────────────────────────────
story.append(h2("7.3  Bilateral Inferior Petrosal Sinus Sampling (BIPSS) — Gold Standard"))
story.append(body(
    "BIPSS is the most accurate test available to distinguish <b>Cushing's Disease</b> (pituitary source) from "
    "<b>Ectopic ACTH Syndrome</b> (EAS), with sensitivity of 94–97% and specificity of approximately 95%. "
    "It is mandatory when MRI is normal or equivocal, or when dynamic test results are discordant."
))
story.append(h3("Procedure:"))
story.append(bullets([
    "Performed by an experienced interventional radiologist under fluoroscopic guidance",
    "Bilateral catheters are inserted via femoral veins and advanced to the <b>inferior petrosal sinuses</b> — the venous drainage of the pituitary gland",
    "Simultaneous blood samples are drawn from both inferior petrosal sinuses AND a peripheral vein at the same time",
    "Samples taken at baseline (before stimulation) and at 2, 5, and 10 minutes after IV CRH (100 mcg or 1 mcg/kg)",
    "ACTH is measured at each time point in all three sampling sites",
]))
story.append(spacer(0.3))
story.append(data_table(
    ["Ratio (IPS : Peripheral ACTH)", "Timing", "Interpretation"],
    [
        ["≥2.0", "Baseline (before CRH)", "Pituitary source (Cushing's Disease) — highly suggestive"],
        ["≥3.0", "After CRH stimulation", "Pituitary source (Cushing's Disease) — confirms"],
        ["<2.0 baseline AND <3.0 post-CRH", "Any time point", "Ectopic ACTH source — proceed with ectopic workup"],
        ["Lateralization: higher ACTH on one side", "After CRH", "Suggests adenoma in ipsilateral half of pituitary — guides surgeon"],
    ],
    col_widths=[4.5*cm, 3.5*cm, 8.5*cm], header_bg=DARK_BLUE
))
story.append(spacer(0.3))
story.append(h3("Limitations and Pitfalls of BIPSS:"))
story.append(bullets([
    "<b>Catheter position is critical</b> — misplacement in the jugular vein rather than the petrosal sinus causes false-negative results (appears to show ectopic source when it is CD). Prolactin co-sampling is used to verify correct placement (IPS:peripheral prolactin ratio should be >1.8 if correctly placed)",
    "<b>Intermittent ACTH secretion</b> in cyclical CS may cause false negatives if sampled during a low-ACTH period",
    "<b>Operator experience matters</b> — outcomes are significantly better at high-volume centers",
    "<b>Complications</b>: stroke (rare, <0.5%), vascular injury, groin hematoma, contrast reaction — low overall risk at experienced centers",
    "<b>Desmopressin (DDAVP)</b> can be used instead of CRH for stimulation if CRH is unavailable; IPS:P ratio ≥3 after DDAVP also indicates pituitary source",
    "Lateralization should guide surgery but is not perfectly reliable (~70% concordance with tumor location at surgery)",
]))
story.append(spacer())

# ── Ectopic ───────────────────────────────────────────────────────────────────
story.append(h2("7.4  Ectopic ACTH Syndrome (EAS) — Workup"))
story.append(body(
    "When BIPSS confirms an ectopic source (IPS:P <2 baseline, <3 post-CRH), a systematic search for the "
    "ectopic tumor must follow. Many ectopic tumors are small, slow-growing carcinoids that can be very hard to find."
))
story.append(data_table(
    ["Tumor Type", "Proportion of EAS", "Key Imaging Features"],
    [
        ["Bronchial carcinoid", "~40% (most common)", "Often small (<1 cm); CT chest with thin cuts; DOTATATE PET excellent"],
        ["Small cell lung cancer (SCLC)", "~20%", "Usually large, aggressive; FDG-PET/CT; rapid clinical onset"],
        ["Thymic carcinoid / thymoma", "~10%", "Anterior mediastinum on CT; DOTATATE PET"],
        ["Pancreatic NET", "~5%", "CT/MRI pancreas; DOTATATE PET"],
        ["Pheochromocytoma / paraganglioma", "<5%", "MIBG scan, DOTATATE PET, adrenal CT"],
        ["Medullary thyroid cancer", "<5%", "Thyroid ultrasound; calcitonin elevated"],
        ["GI NET (stomach, small bowel)", "~5%", "CT enterography; DOTATATE PET"],
        ["Occult / unknown primary", "~10–20%", "Annual imaging surveillance; DOTATATE PET most sensitive overall"],
    ],
    col_widths=[4.5*cm, 3.5*cm, 8.5*cm], header_bg=RED
))
story.append(spacer(0.3))
story.append(h3("Imaging Protocol for EAS:"))
story.append(bullets([
    "<b>CT chest/abdomen/pelvis</b> with contrast: first-line whole-body survey; thin cuts through chest for small bronchial carcinoids",
    "<b>⁶⁸Ga-DOTATATE PET/CT</b>: somatostatin receptor (SSTR2) imaging — excellent for well-differentiated NETs, especially bronchial and thymic carcinoids. Sensitivity ~80–90% for NETs. Now preferred over octreotide scintigraphy",
    "<b>FDG-PET/CT</b>: for aggressive, high-grade tumors (SCLC, poorly differentiated NETs) that are FDG-avid and DOTATATE-negative",
    "<b>MRI</b>: superior to CT for liver metastases, pancreatic NETs, pituitary (for BIPSS-positive patients)",
    "<b>¹²³I-MIBG scintigraphy</b>: for pheochromocytoma/paraganglioma if suspected",
    "If no source found after initial imaging: repeat imaging every 6–12 months; consider DOTATATE PET if not yet done; in truly occult EAS, bilateral adrenalectomy may be offered for severe hypercortisolism",
]))
story.append(spacer(0.3))
story.append(colored_box([
    Paragraph("<b>Clinical clues that favor EAS over CD:</b>", BODY),
    Paragraph("• Rapid onset of symptoms (weeks to months rather than years)", BULLET),
    Paragraph("• Severe hypokalemia (mineralocorticoid effect of very high cortisol saturating 11β-HSD2)", BULLET),
    Paragraph("• Hyperpigmentation (very high ACTH stimulates MSH receptors)", BULLET),
    Paragraph("• Markedly elevated UFC (>4× ULN) with very high plasma ACTH (>200 pg/mL)", BULLET),
    Paragraph("• Less classic Cushingoid appearance — rapid onset does not allow time for adipose redistribution", BULLET),
    Paragraph("• Profound metabolic alkalosis, glucose intolerance, and muscle wasting", BULLET),
], bg=RED_LIGHT, border=RED))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 8 — CYCLICAL CS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("8.  Cyclical Cushing Syndrome"))
story.append(body(
    "Cyclical CS (also called periodic or episodic CS) is characterized by <b>alternating periods of hypercortisolism "
    "and normal (or even low) cortisol</b>. The cycles may be regular or irregular, lasting days to weeks. "
    "All subtypes of CS — pituitary, ectopic, and adrenal — can be cyclical, though it is most commonly "
    "associated with Cushing's Disease."
))
story.append(h2("8.1  Diagnostic Challenges"))
story.append(bullets([
    "If a patient is tested during a remission phase, all standard tests (UFC, LNSC, 1mg-DST) may be completely normal",
    "This can lead to years of diagnostic delay and misdiagnosis as anxiety, depression, or functional disorder",
    "Clinical suspicion must remain high despite normal biochemistry when the clinical picture is compelling",
    "Patients may notice their symptoms wax and wane — this history should specifically be sought",
]))
story.append(h2("8.2  Diagnostic Strategy for Cyclical CS"))
story.append(bullets([
    "<b>Hair cortisol/cortisone</b>: The most valuable tool — historical hypercortisolism episodes are captured in hair even when current testing is normal. A markedly elevated hair cortisol with a normal current UFC strongly suggests cyclical CS.",
    "<b>Multiple UFC/LNSC collections</b>: Serial collections over several weeks to months — even monthly collections for 3–6 months — to catch an active phase",
    "<b>Symptom tracking</b>: Educate patient to collect 24h urine or salivary cortisol when symptoms are at their worst (moon face most prominent, blood pressure spikes, mood is worst)",
    "<b>Urinary free cortisol over time</b>: Plot values — characteristic sawtooth pattern confirms cyclical secretion",
    "Once an active phase is identified, full biochemical workup should proceed immediately (ACTH, imaging) while cortisol is elevated",
]))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 9 — SUBCLINICAL / MILD CS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("9.  Mild Autonomous Cortisol Secretion (MACS) and Subclinical CS"))
story.append(body(
    "With the widespread use of abdominal CT and MRI, adrenal incidentalomas are now found in ~4–6% of all "
    "abdominal imaging studies. A significant proportion of these secrete cortisol autonomously in amounts "
    "insufficient to cause full-blown Cushingoid features — this is termed <b>Mild Autonomous Cortisol Secretion (MACS)</b>, "
    "formerly called 'subclinical CS'. It is an important diagnosis because it is associated with "
    "metabolic complications and cardiovascular risk."
))
story.append(data_table(
    ["1mg-DST Cortisol Result", "Classification", "Clinical Implication"],
    [
        ["≤50 nmol/L (1.8 mcg/dL)", "Normal — CS excluded", "Reassure; repeat imaging in 6–12 months for incidentaloma surveillance"],
        ["51–138 nmol/L (1.8–5 mcg/dL)", "MACS / Possible autonomous cortisol secretion", "Correlate with clinical features; assess comorbidities; consider additional testing"],
        [">138 nmol/L (5 mcg/dL)", "Overt CS", "Full CS workup — ACTH, UFC, LNSC; treat underlying cause"],
    ],
    col_widths=[4.5*cm, 4.5*cm, 7.5*cm], header_bg=ORANGE
))
story.append(spacer(0.3))
story.append(body(
    "In patients with MACS, additional tests (UFC, LNSC, DHEA-S — which is suppressed in adrenal autonomy) "
    "help characterize the degree of excess. DHEA-S is suppressed because ACTH suppression reduces adrenal androgen "
    "production from the zona reticularis. A suppressed DHEA-S in conjunction with borderline DST supports MACS."
))
story.append(h2("9.1  Management of MACS"))
story.append(bullets([
    "<b>Conservative management (watchful waiting)</b>: Annual 1mg-DST, metabolic monitoring, BP, glucose, DEXA scan",
    "<b>Adrenalectomy</b>: Considered when comorbidities (HTN, DM, osteoporosis) are present and worsening, patient is relatively young, and surgical risk is acceptable. Studies suggest improvement of metabolic comorbidities post-adrenalectomy",
    "<b>Decision individualized</b>: Balance surgical risk vs. metabolic benefit; no universal recommendation yet",
    "All patients with adrenal incidentaloma should have annual clinical review for CS progression",
]))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 10 — SPECIAL SITUATIONS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("10.  Special Diagnostic Situations"))
story.append(h2("10.1  CS in Pregnancy"))
story.append(bullets([
    "Rare but dangerous — associated with preeclampsia, GDM, preterm delivery, and fetal loss",
    "Normal pregnancy activates the HPA axis — CBG rises 2–3×, raising total cortisol significantly",
    "1mg-DST is unreliable in pregnancy (elevated CBG); LNSC and UFC are preferred",
    "UFC upper limits of normal increase by trimester: use trimester-specific reference ranges",
    "Salivary cortisol (free fraction) is more reliable than serum total cortisol in pregnancy",
    "Adrenal adenoma is the most common cause of CS in pregnancy (not CD as in general population)",
    "MRI without gadolinium is preferred for imaging (CT avoided)",
]))
story.append(spacer(0.3))

story.append(h2("10.2  CS in Children and Adolescents"))
story.append(bullets([
    "Key clue: weight gain with GROWTH ARREST (falling height percentile) — this combination is virtually diagnostic of CS in children",
    "In children <7 years: adrenal causes (adenoma, PPNAD, ACC) are more common",
    "In children >7 years: CD (pituitary adenoma) becomes progressively more common",
    "Salivary cortisol and UFC are the preferred first-line tests; DST cutoffs may differ by age",
    "MRI pituitary with dedicated pediatric protocol; BIPSS can be performed at experienced pediatric centers",
]))
story.append(spacer(0.3))

story.append(h2("10.3  CS with Concurrent Medications"))
story.append(data_table(
    ["Drug", "Effect on Testing", "Management"],
    [
        ["Oral contraceptive pills / HRT", "Elevate CBG → false positive DST; does not affect UFC or LNSC", "Discontinue for 4–6 weeks before DST; or use UFC/LNSC"],
        ["Rifampicin, phenytoin, carbamazepine, phenobarbital", "CYP3A4 inducers → rapid dex metabolism → false positive DST", "Switch drug if possible; use UFC/LNSC instead of DST"],
        ["Ketoconazole, itraconazole, fluconazole", "CYP3A4 inhibitors → elevated dex → false negative DST; also reduce cortisol synthesis", "UFC/LNSC preferred; aware that ketoconazole itself lowers cortisol"],
        ["Megestrol acetate, medroxyprogesterone", "Glucocorticoid agonist activity → iatrogenic CS + suppressed endogenous cortisol", "Withdraw medication; ACTH stimulation test to assess adrenal recovery"],
        ["Spironolactone", "Cross-reacts in some aldosterone immunoassays — not a major issue for cortisol testing", "Usually not a problem for cortisol"],
    ],
    col_widths=[4*cm, 6.5*cm, 6*cm], header_bg=TEAL
))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 11 — MASTER DIAGNOSTIC ALGORITHM
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("11.  Master Diagnostic Algorithm Summary"))
story.append(data_table(
    ["Step", "Action", "Test(s)", "Decision"],
    [
        ["0", "Exclude exogenous glucocorticoids", "Medication review — all routes", "If exogenous → Iatrogenic CS, STOP"],
        ["1", "Identify clinical suspicion", "Physical exam, symptoms, high-risk groups", "If classic features → SCREEN"],
        ["2", "First-line screening (≥2 tests)", "1mg-DST + UFC + LNSC ± Hair cortisol", "≥2 abnormal → Confirm endogenous CS\n1 abnormal → Repeat or Dex-CRH test\nAll normal + cyclical suspected → Hair cortisol"],
        ["3", "Equivocal results", "Dex-CRH test or 2mg/day 2-day DST", "Abnormal → CS confirmed\nNormal → Pseudo-Cushing likely"],
        ["4", "Plasma ACTH", "Pre-chilled EDTA tube, on ice, rapid processing", "ACTH <10 → ACTH-independent (adrenal)\nACTH >20 → ACTH-dependent (pit/ectopic)"],
        ["5A", "ACTH-independent pathway", "CT adrenals (thin slice, HU measurement)", "Adenoma / ACC / BMAH / PPNAD"],
        ["5A+", "Further adrenal characterization if needed", "MRI, FDG-PET, ¹¹C-metomidate PET, AVS, ARMC5/PRKAR1A genetics", "Guides surgical vs. medical management"],
        ["5B", "ACTH-dependent pathway", "Pituitary MRI with gadolinium", "Adenoma >6 mm → likely CD\nNormal/equivocal → dynamic tests + BIPSS"],
        ["6B", "Dynamic tests", "CRH stimulation test + HDDST", "Concordant with CD → likely Cushing's Disease\nDiscordant or negative → BIPSS mandatory"],
        ["7B", "BIPSS", "Bilateral IPS sampling ± CRH", "IPS:P ≥3 post-CRH → Cushing's Disease → surgery\nIPS:P <2 → Ectopic ACTH → EAS workup"],
        ["8B", "EAS workup", "CT chest/abdomen/pelvis + ⁶⁸Ga-DOTATATE PET ± FDG-PET", "Source found → targeted therapy\nOccult → surveillance; bilateral adrenalectomy if severe"],
    ],
    col_widths=[1*cm, 3.5*cm, 5*cm, 7*cm],
    header_bg=DARK_BLUE
))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 12 — KEY NUMBERS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("12.  Key Numbers to Know"))
story.append(data_table(
    ["Test / Parameter", "Value", "Significance"],
    [
        ["1mg-DST normal suppression", "≤50 nmol/L (1.8 mcg/dL)", "CS excluded if suppressed (sens ~95%)"],
        ["1mg-DST overt CS threshold", ">138 nmol/L (5 mcg/dL)", "High specificity for overt CS"],
        ["ACTH: ACTH-independent CS", "<10 pg/mL (2.2 pmol/L)", "Adrenal source; ACTH suppressed"],
        ["ACTH: ACTH-dependent CS", ">20 pg/mL (4.4 pmol/L)", "Pituitary or ectopic ACTH source"],
        ["ACTH: borderline", "10–20 pg/mL", "Repeat; CRH stimulation test"],
        ["CRH test — CD positive", "ACTH rise >35–50%; cortisol rise >14–20%", "Pituitary source likely"],
        ["HDDST — CD positive", "Cortisol suppresses >50%", "Pituitary adenoma (partial feedback sensitivity)"],
        ["BIPSS IPS:P — pituitary", "≥2 baseline; ≥3 post-CRH", "Cushing's Disease confirmed; sensitivity 94–97%"],
        ["BIPSS IPS:P — ectopic", "<2 baseline AND <3 post-CRH", "Ectopic ACTH source"],
        ["MACS DST range", "51–138 nmol/L (1.8–5 mcg/dL)", "Mild autonomous secretion; metabolic risk"],
        ["Hair cortisol: time window", "Proximal 3 cm = ~3 months", "Retrospective integrated exposure"],
        ["Hair growth rate", "~1 cm per month", "Basis for hair cortisol dating"],
        ["CD as % of endogenous CS", "~65–70%", "Most common endogenous CS"],
        ["ACTH-dependent CS total", "~80–85% of endogenous CS", "Majority are pituitary or ectopic-driven"],
        ["ACTH-independent CS total", "~15–20% of endogenous CS", "Adrenal autonomous cortisol production"],
        ["Bronchial carcinoid as EAS", "~40% of ectopic ACTH cases", "Most common ectopic ACTH source"],
        ["Normal MRI in CD", "~40% of cases", "Justifies BIPSS even with normal MRI"],
    ],
    col_widths=[5.5*cm, 4.5*cm, 6.5*cm],
    header_bg=PURPLE
))
story.append(spacer())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 13 — CLINICAL PEARLS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("13.  Clinical Pearls from the Paper"))
story.append(colored_box([
    Paragraph("1. <b>Always exclude exogenous glucocorticoids first</b> — including inhaled, topical, intra-articular, "
              "and ophthalmic steroids. These are the most common cause of Cushingoid features worldwide and are easily missed.", BULLET),
    Paragraph("2. <b>Two abnormal first-line tests are required</b> before committing to an endogenous CS diagnosis. "
              "One equivocal result should prompt repetition or a second-line test, not immediate referral for imaging.", BULLET),
    Paragraph("3. <b>MRI negativity does not exclude Cushing's Disease</b>. Up to 40% of CD has no visible adenoma on MRI. "
              "BIPSS is mandatory in this setting and should not be skipped.", BULLET),
    Paragraph("4. <b>ACTH sample handling is critical</b>. Improperly handled samples (not on ice, delayed centrifugation) "
              "cause ACTH degradation → falsely low ACTH → wrong classification as ACTH-independent CS → wrong imaging path.", BULLET),
    Paragraph("5. <b>Hair cortisol is the test for cyclical CS</b>. If a patient has compelling clinical history but "
              "normal blood/urine/saliva cortisol, hair cortisol can uncover historical hypercortisolism.", BULLET),
    Paragraph("6. <b>Rapid onset + severe hypokalemia + hyperpigmentation = think ectopic ACTH first</b>. "
              "These patients look less 'Cushingoid' because the disease is too rapid for fat redistribution.", BULLET),
    Paragraph("7. <b>BIPSS prolactin co-sampling verifies catheter placement</b>. An IPS:peripheral prolactin ratio <1.8 "
              "suggests the catheter is not in the petrosal sinus, and the result may be a false negative for EAS.", BULLET),
    Paragraph("8. <b>BMAH may not suppress ACTH completely</b> — ACTH levels in the low-normal range (not fully suppressed) "
              "in the presence of bilateral adrenal enlargement should raise suspicion for BMAH, not CD.", BULLET),
    Paragraph("9. <b>Increased awareness beyond endocrinology is key</b>. Many patients present first to family doctors, "
              "psychiatrists, or neurologists with depression, hypertension, or osteoporosis. Recognition in these "
              "settings is the only way to achieve earlier diagnosis.", BULLET),
    Paragraph("10. <b>Diagnosis and differential diagnosis of CS can still be extremely challenging</b> even with all "
              "modern tools — as explicitly stated in the paper. If uncertain, refer to a specialist center.", BULLET),
], bg=GREEN_LIGHT, border=GREEN))

# ── Reference ─────────────────────────────────────────────────────────────────
story.append(spacer(0.8))
story.append(rule(GRAY_MED))
story.append(Paragraph(
    "<b>Source:</b> Savas M, Mehta S, Agrawal N, van Rossum EFC, Feelders RA. "
    "Approach to the Patient: Diagnosis of Cushing Syndrome. "
    "<i>J Clin Endocrinol Metab.</i> 2022;107(11):3162–3174. "
    "DOI: 10.1210/clinem/dgac492. PMID: 36036941. PMC: PMC9681610.",
    style("Normal", fontSize=8.5, textColor=colors.HexColor("#444444"),
          fontName="Helvetica-Oblique", leading=12)
))
story.append(Paragraph(
    "This document is a clinical educational summary. It does not constitute medical advice. "
    "All clinical decisions should be made in consultation with qualified specialists using current guidelines.",
    style("Normal", fontSize=8, textColor=colors.HexColor("#888888"),
          fontName="Helvetica-Oblique", leading=11, spaceBefore=4)
))

# ── BUILD ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved to: {OUTPUT}")
Running Command

cd /home/daytona/workspace/cushing-writeup && python generate_pdf.py

Running Command

ls -lh /home/daytona/workspace/cushing-writeup/Cushing_Syndrome_Diagnosis_Writeu…

Your PDF is ready:

Cushing Syndrome Diagnosis Writeup

PDF Document · PDF

Here is what is inside, section by section:
  1. Overview and Pathogenesis - Full HPA axis physiology, mechanism breakdown, and a complete table of all CS subtypes with ACTH levels and frequency
  2. Clinical Presentation - Detailed table of 16 cardinal features with discriminating value; specific high-priority screening groups
  3. Pseudo-Cushing States - 10-cause table with mechanisms and differentiating clues; second-line tests (Dex-CRH, 2mg Liddle) explained in full
  4. First-Line Screening Tests - Each of the 4 tests (1mg-DST, UFC, LNSC, Hair cortisol) covered with protocol, cutoffs, sensitivity/specificity, false positive/negative causes, and a comparison table
  5. Plasma ACTH - Pre-analytical requirements, interpretation table, borderline handling
  6. ACTH-Independent CS - CT interpretation, adrenal adenoma, ACC, BMAH (aberrant receptors, ARMC5 genetics), PPNAD/Carney complex, additional imaging modalities
  7. ACTH-Dependent CS - MRI interpretation table, CRH stimulation test, HDDST, concordance principle; full BIPSS procedure, ratios, pitfalls (prolactin co-sampling, lateralization), EAS tumor table with imaging protocol and clinical clues for EAS vs CD
  8. Cyclical CS - Diagnostic challenges, hair cortisol strategy, serial testing approach
  9. MACS/Subclinical CS - DST thresholds, DHEA-S use, management debate
  10. Special Situations - Pregnancy, children, concurrent medications (drug-by-drug table)
  11. Master Algorithm - 11-step decision table covering the entire workup
  12. Key Numbers - 17 numbers/thresholds to memorize
  13. Clinical Pearls - 10 high-yield takeaway points from the paper

What are the side effects of growth hormone therapy in a growth hormone deficiency chuld

Reading File
Finding Sources
Finding Sources
Searching PubMed

"growth hormone" AND "side effects" AND deficiency AND children

Finding Sources
Finding Sources
Searching PubMed

"growth hormone therapy" AND adverse AND pediatric

Reading File
Reading File
Reading File
Reading File
Reading File
Excellent - I have comprehensive textbook content. Here is the full answer:

Side Effects of Growth Hormone Therapy in a Growth Hormone-Deficient Child

Source: Katzung's Basic & Clinical Pharmacology 16e | Lippincott Illustrated Reviews: Pharmacology
The drug used is somatropin - recombinant human GH (rhGH) given as a daily subcutaneous injection, typically at 0.025–0.05 mg/kg/day. The good news first: children with GH deficiency generally tolerate GH therapy well, and true adverse events are uncommon. This is in contrast to adults, who experience more frequent side effects (edema, myalgias, arthralgias). That said, the following side effects are documented:

1. Local Injection Site Reactions

  • Pain, redness, swelling, or lipohypertrophy at the injection site
  • Usually mild and resolves with rotation of injection sites
  • Most common complaint in practice, especially in young children

2. Pseudotumor Cerebri (Benign Intracranial Hypertension)

  • GH increases CSF production and can raise intracranial pressure
  • Presents with: headache, blurred vision, diplopia, papilledema, vomiting
  • Onset typically within the first few months of starting therapy
  • Management: stop GH immediately → symptoms usually resolve; GH can be restarted at a lower dose with careful monitoring
  • More common in patients with underlying risk factors (CKD, Turner syndrome)

3. Slipped Capital Femoral Epiphysis (SCFE)

  • The rapid bone growth stimulated by GH can stress the hip growth plate
  • Presents with: hip or knee pain, limping, limited internal rotation of the hip
  • Must be recognized early - untreated SCFE causes avascular necrosis of the femoral head
  • Action: stop GH, orthopedic referral; surgical pinning usually required
  • More common in obese children receiving GH

4. Progression of Pre-Existing Scoliosis

  • GH accelerates skeletal growth, which can worsen an existing spinal curve
  • Scoliosis is not caused by GH, but pre-existing curves should be monitored regularly during therapy
  • Screen annually with clinical exam; refer to orthopedics if curve progresses

5. Hyperglycemia / Glucose Intolerance

  • GH is counter-regulatory to insulin - it promotes lipolysis and reduces insulin sensitivity
  • Can cause insulin resistance and elevated blood glucose during therapy
  • Rarely progresses to frank diabetes in otherwise healthy GHD children, but blood glucose should be monitored
  • Children with pre-existing diabetes or family history of T2DM are at higher risk
  • Note: there is a paradox - hypoglycemia can occur in very young GHD children before starting GH (GH deficiency itself causes hypoglycemia), but GH therapy itself causes hyperglycemia/insulin resistance

6. Fluid Retention / Edema

  • GH has sodium-retaining properties, similar to insulin
  • Can cause peripheral edema, particularly early in treatment
  • Usually mild and transient; resolve with continued treatment or dose reduction
  • More pronounced in adults than in children

7. Arthralgias and Myalgias

  • Joint and muscle pain, especially in hands and wrists
  • Much more common in adults receiving GH than in children
  • If significant: reduce dose; usually self-limiting

8. Carpal Tunnel Syndrome

  • Related to fluid retention and soft tissue swelling around the wrist
  • Rare in children; more of an adult side effect
  • Presents with: tingling, numbness in the hand, especially at night

9. Gynecomastia

  • Reported in some male patients receiving GH
  • Mechanism: GH may increase conversion of androgens to estrogens via IGF-1 mediated pathways
  • Usually benign and resolves with dose reduction

10. Pancreatitis

  • A rare but documented adverse event
  • Presents with: severe epigastric pain, nausea, vomiting
  • Mechanism not fully established - may relate to lipid metabolism changes
  • Monitor if abdominal pain develops during therapy

11. Naevus (Mole) Growth

  • GH and IGF-1 can stimulate melanocyte activity
  • New moles may appear or existing ones may enlarge
  • Annual skin exam is reasonable; suspicious lesions should be assessed by dermatology
  • There is no proven increased malignancy risk from GH in otherwise healthy children

12. Otitis Media (Turner Syndrome-Specific)

  • Girls with Turner syndrome on GH therapy have an increased risk of otitis media (middle ear infections)
  • Related to the underlying anatomy of Turner syndrome rather than a direct GH effect, but GH treatment increases the overall growth activity that may affect Eustachian tube function

13. Prader-Willi Syndrome - Specific Warning

  • In severely obese children with Prader-Willi syndrome who also have upper airway obstruction or sleep apnea, GH therapy carries an increased risk of sudden death due to respiratory compromise
  • GH is not absolutely contraindicated in PWS but requires mandatory sleep study and ENT assessment before starting; obese PWS children with respiratory compromise should not receive GH

14. Concurrent Pituitary Hormone Deficiencies Unmasked

  • This is a very important and often overlooked "side effect" in the clinical sense
  • In a child with GH deficiency, periodic monitoring of other anterior pituitary hormones is required during GH therapy
  • GH replacement can unmask (reveal) concurrent deficiencies in:
    • Cortisol (secondary adrenal insufficiency - GH opposes cortisol action; once GH is replaced, cortisol insufficiency may become clinically apparent)
    • TSH / Thyroid hormone (central hypothyroidism)
    • Gonadotropins (LH/FSH)
  • This is not strictly a drug toxicity but a consequence of replacing one axis while others remain deficient

15. Theoretical Long-Term Concerns

ConcernCurrent Evidence
Cancer riskNo increased incidence of primary cancer in GHD children treated with rhGH (GeNeSIS study, large prospective observational study). Contraindicated in known active malignancy.
Cardiovascular mortalityThe French SAGHE study arm showed higher all-cause cardiovascular mortality in long-term GH-treated patients; however, Swedish data and other European arms showed no increased mortality. The matter is not fully resolved.
Leukemia riskHistorical concern with cadaveric pituitary GH; not seen with recombinant GH in children without underlying cancer risk
Effect on prior malignancyChildren with history of prior malignancy (e.g., childhood brain tumors treated with irradiation who later develop GHD) have elevated baseline mortality. GH is used with caution in this group; it does not appear to increase cancer recurrence when used in remission.

Key Monitoring Points During Therapy

ParameterFrequencyReason
Height, weight, growth velocityEvery 3–6 monthsAssess response to therapy
Fasting glucose / HbA1cEvery 6–12 monthsInsulin resistance
IGF-1 levelsEvery 6 monthsDose optimization; avoid over-replacement
Thyroid function (TSH, FT4)Every 6–12 monthsUnmask central hypothyroidism
Morning cortisol / ACTH stimIf clinically indicatedUnmask secondary adrenal insufficiency
Scoliosis screenAnnuallyProgression risk
Hip pain assessmentEach visitSCFE
Fundoscopy / papilledema checkIf headache developsPseudotumor cerebri

Summary: Rare vs. Common

FrequencySide Effect
Common / expectedInjection site reactions, transient edema
Uncommon but clinically importantPseudotumor cerebri, SCFE, scoliosis progression, hyperglycemia, unmasking of pituitary deficiencies
RarePancreatitis, gynecomastia, carpal tunnel, naevus growth
Condition-specificRespiratory risk (PWS + obesity), otitis media (Turner syndrome)
Long-term / still debatedCardiovascular mortality, cancer risk
  • Katzung's Basic and Clinical Pharmacology 16e, p.1048–1049
  • Lippincott Illustrated Reviews: Pharmacology, p.769–770
This is a shared conversation. Sign in to Orris to start your own chat.