What is headache explain types and cure in details

Reading File
Finding Sources
Searching the Web

types of headache classification causes treatment 2024

Searching PubMed

"headache" AND "classification" AND "treatment"

Reading File
Reading File
Reading File
Finding Sources
Loading Image
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
I now have comprehensive information from multiple authoritative sources. Let me compose the full, detailed answer.

Headache: A Complete Medical Guide

What is a Headache?

A headache is defined as pain anywhere in the region of the head or neck. It is one of the most common symptoms encountered in clinical medicine and affects virtually everyone at some point in life. Pain arises from activation of pain-sensitive structures - the large intracranial vessels, the dura mater, and pericranial muscles are all innervated by the trigeminal nerve (the trigeminovascular system). The brain parenchyma itself has no pain receptors.
From the perspective of prevalence, Harrison's Principles of Internal Medicine (22nd Ed.) places tension-type headache at 69% of all headaches, migraine at 16%, while brain tumor causes headache in only 0.1% - meaning the vast majority of headaches are benign.

Classification: Primary vs Secondary

The most important clinical distinction is between primary and secondary headaches, per the International Classification of Headache Disorders, 3rd Edition (ICHD-3):
Headache classification mind map showing Primary (Tension, Migraine, Cluster) and Secondary (Intracranial: Vascular, Infectious, Tumor, CSF; and Extracranial) categories
CategoryDefinitionExamples
PrimaryHeadache IS the disorder; no underlying causeTension-type, Migraine, Cluster
SecondaryHeadache is a symptom of another conditionMeningitis, SAH, tumor, hypertension

Part I: Primary Headaches (Detailed)


1. Tension-Type Headache (TTH) - Most Common (69%)

Description: The classic "everyday headache" - a steady, dull, bilateral ache often described as a band tightening around the head. Renamed from "tension headache" because it is not primarily caused by muscle tension or stress.
Features:
  • Bilateral location
  • Quality: pressing, tightening (non-pulsating)
  • Mild to moderate intensity - does not stop daily activity
  • No nausea, no vomiting
  • May have mild photophobia OR phonophobia (not both)
  • Lasts 30 minutes to several days
Subtypes:
  • Infrequent episodic - less than 1 day/month
  • Frequent episodic - 1-14 days/month
  • Chronic - 15+ days/month for 3+ months; can run continuously for years and is associated with depression
Causes/Triggers: Stress, fatigue, poor posture, sleep deprivation, hunger, dehydration, eye strain, anxiety
Treatment:
ApproachOptions
Mild/acuteAcetaminophen (paracetamol), NSAIDs (ibuprofen, naproxen, aspirin)
Non-pharmacologicMuscle relaxation techniques, massage, moist heat, biofeedback, cognitive behavioral therapy
Chronic preventionTricyclic antidepressants (amitriptyline 10-25 mg at night, up to 1 mg/kg)
LifestyleRegular sleep, regular meals, regular exercise (150 min/week moderate aerobic activity), stress management
Note: Frequent use of over-the-counter analgesics (more than 10-15 days/month) leads to medication overuse headache (MOH), a major complication.

2. Migraine - Second Most Common (16%)

Description: Migraine is a brain disorder - not simply a vascular headache. It involves complex neurological sensitization and the trigeminovascular system. Functional neuroimaging shows it involves the brainstem and hypothalamus.
Diagnostic Features (ICHD-3 criteria - at least 2 of 4):
  • Unilateral location
  • Pulsating/throbbing quality
  • Moderate to severe intensity
  • Aggravated by routine physical activity
Plus at least 1 of:
  • Nausea and/or vomiting
  • Photophobia AND phonophobia
Duration: 4-72 hours (untreated)
Clinical tip (mnemonic = PIN): Migraine can be diagnosed with 93% positive predictive value when 2 of 3 features are present: Photosensitivity, Incapacitation, Nausea. (Neuroanatomy through Clinical Cases, 3rd Ed.)
Subtypes:
SubtypeKey Feature
Migraine without aura ("common migraine")Most common (80% of migraines); meets above criteria
Migraine with aura ("classic migraine")Preceded by reversible focal neurologic symptoms (aura) developing over 5-20 min, lasting <60 min; occurs in ~20% of migraineurs; most commonly visual (fortification spectra, scotomata)
Chronic migraine≥15 headache days/month, with migraine features on ≥8 days/month
Hemiplegic migraineMotor weakness as part of aura
Brainstem aura migraineDysarthria, vertigo, tinnitus, diplopia
Aura: Typically visual - zigzag patterns (fortification spectra), blind spots (scotomata), or sensory paresthesias spreading over 5-20 minutes. Aura without headache also occurs.
Triggers: Menstruation, stress, sleep changes (too much or too little), certain foods (aged cheese, red wine, caffeine withdrawal), weather changes, strong odors, bright lights
Phases of a Migraine Attack:
  1. Prodrome (hours to days before) - mood changes, yawning, neck stiffness, food cravings
  2. Aura (if present) - reversible neurologic symptoms
  3. Headache phase - the main pain
  4. Postdrome - fatigue, "migraine hangover"
Treatment:
Abortive (acute attack) therapy:
SeverityFirst-line Options
Mild-moderateNSAIDs (ibuprofen, naproxen, aspirin), caffeine-containing combination analgesics (e.g., Excedrin)
Moderate-severeTriptans (5-HT1B/D agonists): sumatriptan, rizatriptan, zolmitriptan, eletriptan - take at headache onset
Severe/refractoryErgotamine/dihydroergotamine (DHE), CGRP antagonists ("gepants": ubrogepant, rimegepant), ditans (lasmiditan - 5-HT1F agonist)
With nausea/vomitingMetoclopramide IV (also treats headache directly); prochlorperazine as second-line; dopamine blockers
Quiet environmentRest in dark, quiet room is effective for milder attacks
Preventive therapy (indicated when attacks are frequent or disabling):
Drug ClassExamples
Beta-blockersPropranolol, metoprolol
Calcium channel blockersFlunarizine, verapamil
AntiepilepticsTopiramate, valproate
Tricyclic antidepressantsAmitriptyline, nortriptyline
CGRP monoclonal antibodies (newest)Erenumab, fremanezumab, galcanezumab - effective and well-tolerated in chronic migraine
CGRP receptor antagonists (gepants)Atogepant (oral, daily)
Candesartan (ARB)Emerging evidence
Botulinum toxin (Botox)For chronic migraine (≥15 days/month)

3. Cluster Headache - Most Painful Primary Headache

Description: Cluster headache belongs to the Trigeminal Autonomic Cephalalgias (TACs) - primary headache disorders with unilateral trigeminal pain plus ipsilateral cranial autonomic features. It is less than 1/10th as common as migraine, but the pain is described as one of the most severe known to medicine (nicknamed "suicide headache").
Key Features:
  • Prevalence: ~0.1% of population; 4:1 male predominance
  • Unilateral, strictly one-sided retro-orbital or periorbital severe pain
  • Quality: boring, stabbing, "red hot poker through the eye"
  • Duration: 15-180 minutes per attack
  • Frequency: 1-8 attacks per day, occurring in "clusters" (daily attacks for weeks to months), then remission for months
Ipsilateral Autonomic Features (at least one required):
  • Lacrimation (tearing)
  • Conjunctival injection (red eye)
  • Ptosis and miosis (partial Horner's syndrome)
  • Rhinorrhea / nasal congestion
  • Facial sweating/flushing
  • Aural fullness
Pathophysiology: Functional neuroimaging shows posterior hypothalamic activation during attacks - the hypothalamus acts as the "pacemaker" of cluster cycles.
Subtypes:
  • Episodic - clusters separated by ≥1 month remission
  • Chronic - attacks for >1 year without remission, or remissions <1 month
Other TACs:
  • Paroxysmal hemicrania - like cluster but shorter (2-30 min), more frequent (>5/day), predominantly female; exquisitely responsive to indomethacin
  • SUNCT/SUNA - very short attacks (seconds to minutes), extremely frequent; often requires lamotrigine or gabapentin
  • Hemicrania continua - continuous unilateral headache, responds only to indomethacin
Treatment:
ApproachOptions
Acute abortion100% oxygen at 7-12 L/min via non-rebreather mask for 15-20 min (effective in ~70%)
AcuteSubcutaneous sumatriptan 6 mg (fastest onset), intranasal zolmitriptan or sumatriptan
Prevention during cluster periodVerapamil (first-line), oral corticosteroids (short bridge), lithium, topiramate, melatonin
RefractoryGreater occipital nerve block (GONB), sphenopalatine ganglion (SPG) stimulation

4. Other Primary Headache Types

TypeKey FeaturesTreatment
Hemicrania continuaContinuous moderate unilateral headache for ≥3 months; autonomic features; periods of exacerbationIndomethacin (diagnostic and therapeutic)
Ice pick headache (primary stabbing)Brief, intense stabs lasting seconds; "ice pick" in the eyeIndomethacin for prevention
Thunderclap headache (primary)Sudden maximal headache within <1 min; diagnosis of exclusion after ruling out SAHExclude secondary causes first (CT urgently); nimodipine for RCVS
Hypnic headacheAwakens from sleep ("alarm clock headache"); elderly; bilateralCaffeine before bed, lithium
Exertional headacheTriggered by physical activityIndomethacin, propranolol
Coital headacheSudden severe headache at orgasmExclude SAH; propranolol for prevention

Part II: Secondary Headaches

Secondary headaches are symptoms of underlying disease. The management is treatment of the underlying cause.

Red Flags ("SNOOP4" criteria) - Require urgent evaluation:

Warning SignConcern
Sudden-onset / "worst headache of life" / thunderclapSubarachnoid hemorrhage (SAH)
First severe headache everSAH, meningitis
Fever + stiff neck + altered consciousnessMeningitis, encephalitis
Progressive worsening over days/weeksTumor, subdural hematoma
New headache in cancer patient / HIVBrain metastasis, CNS infection
Onset after age 55Giant cell arteritis, tumor
Vomiting preceding headacheRaised intracranial pressure
Pain worsens on bending/coughing/ValsalvaRaised ICP, Chiari malformation
Abnormal neurologic examAny structural lesion
Pain over temporal artery (tender) in elderlyGiant cell arteritis

Key Secondary Headache Types:

1. Subarachnoid Hemorrhage (SAH)
  • "Worst headache of life," maximal within seconds
  • Stiff neck, but no fever
  • Caused by ruptured aneurysm
  • Emergency CT, then LP if CT negative → look for xanthochromia
2. Meningitis
  • Severe headache + stiff neck + fever + photophobia
  • LP is mandatory (after CT to rule out mass)
  • IV antibiotics immediately if suspected
3. Intracranial Tumor
  • Headache in ~50% of brain tumor patients
  • Typically bifrontal (worse on tumor side), similar to tension headache in quality
  • Worse on bending; associated with nausea/vomiting; may be worse in morning
  • MRI is investigation of choice
4. Medication Overuse Headache (MOH)
  • Paradoxically caused by frequent use of headache medications
  • Occurs with analgesics >15 days/month, or triptans/ergotamines >10 days/month
  • Daily or near-daily headache
  • Treatment: gradual withdrawal of offending medication
5. Giant Cell Arteritis (Temporal Arteritis)
  • Elderly patients (>50 years), new unilateral headache
  • Tender temporal artery, jaw claudication, elevated ESR/CRP
  • Risk of sudden blindness if untreated
  • Treat immediately with oral corticosteroids; confirm with temporal artery biopsy
6. Idiopathic Intracranial Hypertension (Pseudotumor Cerebri)
  • Obese young women; chronic daily headache; papilledema; normal MRI
  • Opening pressure >25 cm H2O on LP
  • Treatment: weight loss, acetazolamide, LP drainage, shunt surgery for refractory cases
7. Hypertensive Headache
  • Occurs with severe hypertension (BP >180/120 mmHg)
  • Occipital, present on waking
  • Resolves with blood pressure control
8. Post-Dural Puncture (Spinal) Headache
  • After lumbar puncture, epidural procedures
  • Orthostatic - worse when sitting/standing, better lying flat
  • CSF leak causes decreased intracranial pressure
  • Treatment: bed rest, hydration, caffeine; epidural blood patch for severe/persistent cases
9. Cervicogenic Headache
  • Pain referred from cervical spine/neck structures
  • Unilateral, starts in neck/occiput, radiates to forehead
  • Restricted cervical movement
  • Treatment: physiotherapy, NSAIDs, nerve blocks

Non-Pharmacologic Treatments (General)

Applicable across multiple headache types:
  • Regular sleep schedule (avoid both too much and too little sleep)
  • Regular meals (avoid skipping meals - hypoglycemia triggers headache)
  • Adequate hydration
  • Regular aerobic exercise (150 min/week)
  • Stress management, biofeedback, mindfulness
  • Identify and avoid personal triggers (keep a headache diary)
  • Acupuncture (evidence-based for tension and migraine prevention)
  • Cognitive behavioral therapy (CBT)
  • Physical therapy for cervicogenic and tension headaches

Summary Table: Quick Comparison of the 3 Major Primary Headaches

FeatureTension-TypeMigraineCluster
Prevalence69%16%0.1%
SexEqualF > M (3:1)M > F (4:1)
LocationBilateralUnilateral (often)Unilateral, periorbital
QualityPressing, tighteningThrobbing, pulsatingBoring, stabbing
SeverityMild-moderateModerate-severeSevere (worst possible)
Duration30 min - days4-72 hours15-180 min
NauseaNoYesUncommon
Autonomic featuresNoSometimesYES (defining)
ActivityNot worsenedWorsenedRestlessness, pacing
Acute treatmentNSAIDs, acetaminophenTriptans, NSAIDs, gepantsO2, subcutaneous sumatriptan
PreventionAmitriptylineBeta-blockers, topiramate, CGRP mAbsVerapamil

Latest Evidence (PubMed, 2024-2026)

A landmark 2024 BMJ network meta-analysis (PMID: 39293828) comparing drug interventions for acute migraine in adults confirmed triptans remain highly effective for aborting attacks, with newer CGRP antagonists (gepants) offering comparable efficacy with fewer cardiovascular concerns - important for patients who cannot take triptans.

Sources: Harrison's Principles of Internal Medicine 22E (2025); Neuroanatomy through Clinical Cases 3rd Ed.; Frameworks for Internal Medicine; Bradley and Daroff's Neurology in Clinical Practice; ICHD-3 classification; Karlsson et al., BMJ 2024 (PMID: 39293828)

Create a PDF quick reference guide for distinguishing migraine from tension headache

Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/headache-guide && ls /home/daytona/workspace/

Writing File

~/headache-guide/create_headache_guide.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame
from reportlab.lib.colors import HexColor

# ── Colour palette ──────────────────────────────────────────────────────────
MIGRAINE_DARK   = HexColor("#6B21A8")   # deep purple
MIGRAINE_MID    = HexColor("#9333EA")   # purple
MIGRAINE_LIGHT  = HexColor("#EDE9FE")   # lavender tint
TENSION_DARK    = HexColor("#0369A1")   # deep blue
TENSION_MID     = HexColor("#0EA5E9")   # sky blue
TENSION_LIGHT   = HexColor("#E0F2FE")   # light blue tint
HEADER_BG       = HexColor("#1E1B4B")   # dark indigo
ACCENT_RED      = HexColor("#DC2626")   # red for warnings
ACCENT_ORANGE   = HexColor("#EA580C")   # orange for caution
GREEN_DARK      = HexColor("#166534")
GREEN_LIGHT     = HexColor("#DCFCE7")
GREY_LIGHT      = HexColor("#F8FAFC")
GREY_MID        = HexColor("#E2E8F0")
GREY_DARK       = HexColor("#475569")
WHITE           = colors.white
BLACK           = colors.black

# ── Page setup ───────────────────────────────────────────────────────────────
PAGE_W, PAGE_H = A4
MARGIN = 18 * mm

def build_styles():
    base = getSampleStyleSheet()

    styles = {
        "title": ParagraphStyle(
            "title",
            fontName="Helvetica-Bold",
            fontSize=22,
            textColor=WHITE,
            alignment=TA_CENTER,
            spaceAfter=2,
        ),
        "subtitle": ParagraphStyle(
            "subtitle",
            fontName="Helvetica",
            fontSize=11,
            textColor=HexColor("#C4B5FD"),
            alignment=TA_CENTER,
            spaceAfter=0,
        ),
        "section_header": ParagraphStyle(
            "section_header",
            fontName="Helvetica-Bold",
            fontSize=10,
            textColor=WHITE,
            alignment=TA_CENTER,
            spaceAfter=0,
            leading=14,
        ),
        "migraine_col": ParagraphStyle(
            "migraine_col",
            fontName="Helvetica-Bold",
            fontSize=10,
            textColor=MIGRAINE_DARK,
            alignment=TA_CENTER,
        ),
        "tension_col": ParagraphStyle(
            "tension_col",
            fontName="Helvetica-Bold",
            fontSize=10,
            textColor=TENSION_DARK,
            alignment=TA_CENTER,
        ),
        "feature_label": ParagraphStyle(
            "feature_label",
            fontName="Helvetica-Bold",
            fontSize=8.5,
            textColor=HexColor("#1E293B"),
            alignment=TA_LEFT,
        ),
        "cell_text": ParagraphStyle(
            "cell_text",
            fontName="Helvetica",
            fontSize=8,
            textColor=HexColor("#1E293B"),
            alignment=TA_LEFT,
            leading=11,
        ),
        "cell_text_c": ParagraphStyle(
            "cell_text_c",
            fontName="Helvetica",
            fontSize=8,
            textColor=HexColor("#1E293B"),
            alignment=TA_CENTER,
            leading=11,
        ),
        "warn_title": ParagraphStyle(
            "warn_title",
            fontName="Helvetica-Bold",
            fontSize=9,
            textColor=ACCENT_RED,
            alignment=TA_LEFT,
        ),
        "warn_body": ParagraphStyle(
            "warn_body",
            fontName="Helvetica",
            fontSize=8,
            textColor=HexColor("#7F1D1D"),
            alignment=TA_LEFT,
            leading=12,
        ),
        "box_title": ParagraphStyle(
            "box_title",
            fontName="Helvetica-Bold",
            fontSize=9,
            textColor=HEADER_BG,
            alignment=TA_LEFT,
            spaceAfter=2,
        ),
        "box_body": ParagraphStyle(
            "box_body",
            fontName="Helvetica",
            fontSize=8,
            textColor=HexColor("#1E293B"),
            alignment=TA_LEFT,
            leading=12,
        ),
        "footer": ParagraphStyle(
            "footer",
            fontName="Helvetica",
            fontSize=7,
            textColor=GREY_DARK,
            alignment=TA_CENTER,
        ),
        "green_title": ParagraphStyle(
            "green_title",
            fontName="Helvetica-Bold",
            fontSize=9,
            textColor=GREEN_DARK,
            alignment=TA_LEFT,
            spaceAfter=2,
        ),
        "green_body": ParagraphStyle(
            "green_body",
            fontName="Helvetica",
            fontSize=8,
            textColor=HexColor("#14532D"),
            alignment=TA_LEFT,
            leading=12,
        ),
        "orange_title": ParagraphStyle(
            "orange_title",
            fontName="Helvetica-Bold",
            fontSize=9,
            textColor=ACCENT_ORANGE,
            alignment=TA_LEFT,
            spaceAfter=2,
        ),
        "orange_body": ParagraphStyle(
            "orange_body",
            fontName="Helvetica",
            fontSize=8,
            textColor=HexColor("#431407"),
            alignment=TA_LEFT,
            leading=12,
        ),
        "pin_title": ParagraphStyle(
            "pin_title",
            fontName="Helvetica-Bold",
            fontSize=9,
            textColor=MIGRAINE_DARK,
            alignment=TA_CENTER,
        ),
        "pin_big": ParagraphStyle(
            "pin_big",
            fontName="Helvetica-Bold",
            fontSize=20,
            textColor=MIGRAINE_MID,
            alignment=TA_CENTER,
            leading=24,
        ),
        "pin_body": ParagraphStyle(
            "pin_body",
            fontName="Helvetica",
            fontSize=8,
            textColor=MIGRAINE_DARK,
            alignment=TA_CENTER,
            leading=12,
        ),
    }
    return styles

# ── Helper: draw page border & header background via canvas ─────────────────
def draw_page_background(canvas, doc):
    canvas.saveState()
    # Header background band
    canvas.setFillColor(HEADER_BG)
    canvas.rect(0, PAGE_H - 42*mm, PAGE_W, 42*mm, fill=1, stroke=0)
    # Decorative accent line under header
    canvas.setStrokeColor(MIGRAINE_MID)
    canvas.setLineWidth(3)
    canvas.line(MARGIN, PAGE_H - 42*mm, PAGE_W - MARGIN, PAGE_H - 42*mm)
    # Footer
    canvas.setFillColor(GREY_LIGHT)
    canvas.rect(0, 0, PAGE_W, 12*mm, fill=1, stroke=0)
    canvas.setStrokeColor(GREY_MID)
    canvas.setLineWidth(0.5)
    canvas.line(MARGIN, 12*mm, PAGE_W - MARGIN, 12*mm)
    canvas.setFont("Helvetica", 7)
    canvas.setFillColor(GREY_DARK)
    canvas.drawCentredString(
        PAGE_W/2, 4.5*mm,
        "Quick Reference Guide | Migraine vs Tension-Type Headache  |  "
        "Sources: Harrison's 22E, Neuroanatomy Through Clinical Cases 3rd Ed., ICHD-3"
    )
    canvas.restoreState()

def make_pdf(output_path):
    S = build_styles()

    doc = BaseDocTemplate(
        output_path,
        pagesize=A4,
        leftMargin=MARGIN, rightMargin=MARGIN,
        topMargin=44*mm, bottomMargin=14*mm,
    )
    frame = Frame(MARGIN, 14*mm, PAGE_W - 2*MARGIN, PAGE_H - 58*mm, id="main")
    template = PageTemplate(id="main_page", frames=[frame], onPage=draw_page_background)
    doc.addPageTemplates([template])

    story = []
    usable_w = PAGE_W - 2*MARGIN

    # ── TITLE (drawn on canvas, so we just add a spacer to shift content down) ──
    # The header band is drawn by draw_page_background; put title text there via canvas
    # We'll overlay it using a transparent table at the top of the frame
    header_table = Table(
        [[
            Paragraph("MIGRAINE vs TENSION-TYPE HEADACHE", S["title"]),
        ]],
        colWidths=[usable_w],
        rowHeights=[12*mm],
    )
    header_table.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), colors.transparent),
        ("BOX", (0,0), (-1,-1), 0, colors.transparent),
        ("TOPPADDING", (0,0), (-1,-1), 0),
        ("BOTTOMPADDING", (0,0), (-1,-1), 0),
    ]))

    subtitle_table = Table(
        [[Paragraph("Clinical Quick Reference Guide  |  Differential Diagnosis & Management", S["subtitle"])]],
        colWidths=[usable_w],
        rowHeights=[7*mm],
    )
    subtitle_table.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), colors.transparent),
        ("TOPPADDING", (0,0), (-1,-1), 0),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
    ]))

    story.append(header_table)
    story.append(subtitle_table)
    story.append(Spacer(1, 3*mm))

    # ── Section: OVERVIEW COMPARISON TABLE ──────────────────────────────────
    col_feat = 38*mm
    col_mig  = (usable_w - col_feat) / 2
    col_ten  = col_mig

    # Column headers
    headers = [
        Paragraph("FEATURE", S["section_header"]),
        Paragraph("MIGRAINE", S["section_header"]),
        Paragraph("TENSION-TYPE", S["section_header"]),
    ]
    header_row = Table(
        [headers],
        colWidths=[col_feat, col_mig, col_ten],
        rowHeights=[8*mm],
    )
    header_row.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (0,0), GREY_DARK),
        ("BACKGROUND", (1,0), (1,0), MIGRAINE_DARK),
        ("BACKGROUND", (2,0), (2,0), TENSION_DARK),
        ("TEXTCOLOR", (0,0), (-1,-1), WHITE),
        ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
        ("ALIGN", (0,0), (-1,-1), "CENTER"),
        ("FONTNAME", (0,0), (-1,-1), "Helvetica-Bold"),
        ("FONTSIZE", (0,0), (-1,-1), 9),
        ("TOPPADDING", (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
    ]))
    story.append(header_row)

    # Comparison rows: (feature, migraine text, tension text, mig_bg, ten_bg)
    rows = [
        ("Prevalence",
         "~16% of all headaches",
         "~69% of all headaches (most common)",
         MIGRAINE_LIGHT, TENSION_LIGHT),
        ("Sex ratio",
         "Female : Male = 3:1",
         "Roughly equal (F slightly > M)",
         WHITE, WHITE),
        ("Location",
         "Unilateral (60–70%)\nCan be bilateral",
         "Bilateral — always\n'Band around head'",
         MIGRAINE_LIGHT, TENSION_LIGHT),
        ("Quality / Character",
         "Throbbing, pulsating\nPounding",
         "Pressing, tightening\nNon-pulsating, dull ache",
         WHITE, WHITE),
        ("Severity",
         "Moderate to severe\nOften incapacitating",
         "Mild to moderate\nRarely stops daily activity",
         MIGRAINE_LIGHT, TENSION_LIGHT),
        ("Duration",
         "4 – 72 hours\n(untreated / inadequately treated)",
         "30 min – several days",
         WHITE, WHITE),
        ("Nausea / Vomiting",
         "YES — characteristic\n(nausea in ~80%, vomiting in ~30%)",
         "NO (or very mild nausea in chronic type)",
         MIGRAINE_LIGHT, TENSION_LIGHT),
        ("Photophobia",
         "YES — prominent feature",
         "Mild, if present at all",
         WHITE, WHITE),
        ("Phonophobia",
         "YES — prominent feature",
         "Mild, if present at all",
         MIGRAINE_LIGHT, TENSION_LIGHT),
        ("Aura",
         "Present in ~20% (classic migraine)\nVisual most common; lasts 5–60 min",
         "ABSENT",
         WHITE, WHITE),
        ("Effect of activity",
         "WORSENED by routine\nphysical activity (e.g. walking)",
         "NOT worsened by activity",
         MIGRAINE_LIGHT, TENSION_LIGHT),
        ("Prodrome",
         "YES — yawning, mood changes,\nneck stiffness, food cravings (hrs before)",
         "Uncommon",
         WHITE, WHITE),
        ("Autonomic features",
         "Sometimes: photophobia,\nphonophobia, osmophobia",
         "None",
         MIGRAINE_LIGHT, TENSION_LIGHT),
        ("Associated factors",
         "Hormonal (menstrual), sleep changes,\nstress, certain foods, weather, odours",
         "Stress, poor posture,\nfatigue, eye strain, hunger",
         WHITE, WHITE),
        ("Pathophysiology",
         "Brain disorder — trigeminovascular\nactivation, cortical spreading depression",
         "Pericranial muscle tenderness,\ncentral sensitisation",
         MIGRAINE_LIGHT, TENSION_LIGHT),
    ]

    comp_data = []
    comp_styles_list = [
        ("GRID", (0,0), (-1,-1), 0.3, GREY_MID),
        ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
        ("TOPPADDING", (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("LEFTPADDING", (0,0), (-1,-1), 4),
        ("RIGHTPADDING", (0,0), (-1,-1), 4),
    ]

    for i, (feat, mig, ten, mig_bg, ten_bg) in enumerate(rows):
        feat_bg = HexColor("#F1F5F9") if i % 2 == 0 else WHITE
        comp_data.append([
            Paragraph(feat, S["feature_label"]),
            Paragraph(mig.replace("\n", "<br/>"), S["cell_text"]),
            Paragraph(ten.replace("\n", "<br/>"), S["cell_text"]),
        ])
        comp_styles_list.append(("BACKGROUND", (0,i), (0,i), feat_bg))
        comp_styles_list.append(("BACKGROUND", (1,i), (1,i), mig_bg))
        comp_styles_list.append(("BACKGROUND", (2,i), (2,i), ten_bg))

    comp_table = Table(comp_data, colWidths=[col_feat, col_mig, col_ten])
    comp_table.setStyle(TableStyle(comp_styles_list))
    story.append(comp_table)
    story.append(Spacer(1, 4*mm))

    # ── Three bottom boxes: PIN mnemonic | Red Flags | Treatment ─────────────
    box_w = (usable_w - 4*mm) / 3

    # -- PIN Mnemonic box
    pin_content = [
        Paragraph("PIN MNEMONIC", S["pin_title"]),
        Spacer(1, 1*mm),
        Paragraph("P · I · N", S["pin_big"]),
        Spacer(1, 1*mm),
        Paragraph(
            "<b>P</b>hotosensitivity<br/>"
            "<b>I</b>ncapacitation<br/>"
            "<b>N</b>ausea",
            S["pin_body"]
        ),
        Spacer(1, 1*mm),
        Paragraph(
            "2 of 3 features = 93% PPV for Migraine",
            S["pin_body"]
        ),
        Spacer(1, 1*mm),
        Paragraph(
            "<i>(Neuroanatomy Through Clinical Cases, 3rd Ed.)</i>",
            S["pin_body"]
        ),
    ]
    pin_table = Table(
        [[pin_content]],
        colWidths=[box_w],
    )
    pin_table.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), MIGRAINE_LIGHT),
        ("BOX", (0,0), (-1,-1), 1.5, MIGRAINE_MID),
        ("TOPPADDING", (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING", (0,0), (-1,-1), 6),
        ("RIGHTPADDING", (0,0), (-1,-1), 6),
        ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))

    # -- Red Flags box
    red_flags = [
        Paragraph("⚠  RED FLAGS — Investigate Urgently", S["warn_title"]),
        Spacer(1, 2*mm),
        Paragraph(
            "• Sudden-onset / 'thunderclap' headache<br/>"
            "• Worst headache of life<br/>"
            "• Fever + stiff neck (meningism)<br/>"
            "• New headache after age 50<br/>"
            "• Progressive worsening over days/weeks<br/>"
            "• Vomiting before headache begins<br/>"
            "• Pain worsened by bending / coughing<br/>"
            "• Wakes patient from sleep<br/>"
            "• Neurological deficit / papilloedema<br/>"
            "• Temporal artery tenderness (elderly)<br/>"
            "• New headache in cancer / HIV patient",
            S["warn_body"]
        ),
    ]
    red_table = Table(
        [[red_flags]],
        colWidths=[box_w],
    )
    red_table.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), HexColor("#FEF2F2")),
        ("BOX", (0,0), (-1,-1), 1.5, ACCENT_RED),
        ("TOPPADDING", (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING", (0,0), (-1,-1), 6),
        ("RIGHTPADDING", (0,0), (-1,-1), 6),
        ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))

    # -- Treatment box
    treat_content = [
        Paragraph("TREATMENT SUMMARY", S["box_title"]),
        Spacer(1, 1*mm),
        Paragraph("<b><font color='#6B21A8'>MIGRAINE — Acute</font></b>", S["box_body"]),
        Paragraph(
            "Mild-mod: NSAIDs + caffeine combinations<br/>"
            "Mod-severe: Triptans (sumatriptan, rizatriptan)<br/>"
            "With nausea: add metoclopramide IV/IM<br/>"
            "Newer: Gepants (ubrogepant, rimegepant)<br/>"
            "Ditans: Lasmiditan (5-HT1F agonist)",
            S["box_body"]
        ),
        Spacer(1, 1.5*mm),
        Paragraph("<b><font color='#6B21A8'>MIGRAINE — Prevention</font></b>", S["box_body"]),
        Paragraph(
            "Beta-blockers (propranolol, metoprolol)<br/>"
            "TCAs (amitriptyline 10–25 mg nightly)<br/>"
            "Antiepilpetics (topiramate, valproate)<br/>"
            "CGRP mAbs (erenumab, fremanezumab)<br/>"
            "Ca-channel blockers (flunarizine)",
            S["box_body"]
        ),
        Spacer(1, 1.5*mm),
        Paragraph("<b><font color='#0369A1'>TENSION — Acute</font></b>", S["box_body"]),
        Paragraph(
            "Acetaminophen or NSAIDs (first-line)<br/>"
            "Moist heat, massage, relaxation",
            S["box_body"]
        ),
        Spacer(1, 1.5*mm),
        Paragraph("<b><font color='#0369A1'>TENSION — Prevention</font></b>", S["box_body"]),
        Paragraph(
            "Amitriptyline / nortriptyline<br/>"
            "Biofeedback, CBT, exercise<br/>"
            "Avoid medication overuse (&gt;15 days/mo)",
            S["box_body"]
        ),
    ]
    treat_table = Table(
        [[treat_content]],
        colWidths=[box_w],
    )
    treat_table.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), GREY_LIGHT),
        ("BOX", (0,0), (-1,-1), 1.5, GREY_MID),
        ("TOPPADDING", (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING", (0,0), (-1,-1), 6),
        ("RIGHTPADDING", (0,0), (-1,-1), 6),
        ("VALIGN", (0,0), (-1,-1), "TOP"),
    ]))

    # Assemble three boxes side by side
    bottom_row = Table(
        [[pin_table, treat_table, red_table]],
        colWidths=[box_w, box_w, box_w],
        spaceBefore=0,
    )
    bottom_row.setStyle(TableStyle([
        ("LEFTPADDING",  (0,0), (-1,-1), 0),
        ("RIGHTPADDING", (0,0), (-1,-1), 0),
        ("TOPPADDING",   (0,0), (-1,-1), 0),
        ("BOTTOMPADDING",(0,0), (-1,-1), 0),
        ("ALIGN",        (0,0), (-1,-1), "CENTER"),
        ("VALIGN",       (0,0), (-1,-1), "TOP"),
        ("COLPADDING",   (0,0), (-1,-1), 2),
    ]))

    # Use a wrapper to add spacing between columns
    three_cols_data = [[pin_table, Spacer(2*mm, 1), treat_table, Spacer(2*mm, 1), red_table]]
    three_cols = Table(
        three_cols_data,
        colWidths=[box_w, 2*mm, box_w, 2*mm, box_w],
    )
    three_cols.setStyle(TableStyle([
        ("LEFTPADDING",  (0,0), (-1,-1), 0),
        ("RIGHTPADDING", (0,0), (-1,-1), 0),
        ("TOPPADDING",   (0,0), (-1,-1), 0),
        ("BOTTOMPADDING",(0,0), (-1,-1), 0),
        ("VALIGN",       (0,0), (-1,-1), "TOP"),
    ]))

    story.append(KeepTogether(three_cols))

    doc.build(story)
    print(f"PDF created: {output_path}")

if __name__ == "__main__":
    out = "/home/daytona/workspace/headache-guide/Migraine_vs_Tension_Headache_QuickRef.pdf"
    make_pdf(out)
Running Command

cd /home/daytona/workspace/headache-guide && python create_headache_guide.py 2>&1

Running Command

ls -lh /home/daytona/workspace/headache-guide/

The PDF generated successfully. Here's your download link:

Migraine vs Tension Headache QuickRef

PDF Document · PDF


Here's what's packed into this single A4 quick reference guide:
Layout - 3 zones:
  1. Header band (dark indigo) - Title and subtitle in white/lavender
  2. Main comparison table (15 rows) - Color-coded columns:
    • Purple = Migraine column
    • Blue = Tension-type column
    • Covers: Prevalence, Sex, Location, Quality, Severity, Duration, Nausea, Photophobia, Phonophobia, Aura, Effect of activity, Prodrome, Autonomic features, Triggers, Pathophysiology
  3. Three side-by-side boxes at the bottom:
    • PIN Mnemonic (lavender) - Photosensitivity + Incapacitation + Nausea = 93% PPV for migraine
    • Treatment Summary - Acute and preventive options for both headache types, including gepants and CGRP monoclonal antibodies
    • Red Flags (red) - 11 warning signs requiring urgent investigation (SAH, meningitis, tumor, etc.)
Sources cited in the footer: Harrison's Principles of Internal Medicine 22E, Neuroanatomy Through Clinical Cases 3rd Ed., ICHD-3.
This is a shared conversation. Sign in to Orris to start your own chat.