Contraceptive methods

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Loading Image
Reading File
Reading File
Reading File
I now have all the content needed for a comprehensive, well-structured answer. Let me compile it.

Contraceptive Methods

Contraception enables individuals and couples to avoid unwanted pregnancy. Methods can be classified by mechanism, duration, reversibility, or hormonal content.

Classification Overview

CategoryExamples
PermanentTubal sterilization, Vasectomy
Long-Acting Reversible (LARC)IUD (copper, levonorgestrel), Subdermal implant
Short-Acting HormonalCombined oral contraceptives, Progestin-only pills, Patch, Vaginal ring, Injectable
BarrierMale/female condom, Diaphragm, Cervical cap, Spermicide
Behavioral/NaturalLactational amenorrhea, Fertility awareness, Withdrawal
EmergencyCopper IUD, Ulipristal acetate, Levonorgestrel, Combined hormonal pills

Failure Rates (Typical Use)

The chart below, from Lippincott's Illustrated Reviews: Pharmacology, shows relative failure rates by method. Longer bars = more pregnancies per 100 women per year.
Comparison of contraceptive failure rates by method
From Harrison's (Table 408-3), the numbers with theoretical vs. actual effectiveness are:
MethodTheoretical Effectiveness (%)Actual Effectiveness (%)Use at 1 Year (%)
No method8585-
Fertility awareness967647
Withdrawal967846
Condom (male)988243
Diaphragm948257
Spermicides827243
Female sterilization99.5~99.5-
IUD (copper)>99>99High
Implant (etonogestrel)>99.9>99.9High
Injectable (DMPA)99.7~97Moderate
COC (pill)99.7~91Moderate

1. Permanent Methods

Vasectomy - outpatient procedure, failure rate 0.1 per 100 women/year. Not immediately effective; backup contraception needed for at least 3 months post-procedure.
Tubal sterilization - can be performed postpartum or as an interval procedure; failure rate 0.5 per 100 women/year. Globally represents ~23% of all methods used.

2. Long-Acting Reversible Contraceptives (LARC)

LARCs are the most effective reversible contraceptives because efficacy is not reliant on patient adherence. They have high continuation and satisfaction rates, making them an excellent choice for adolescents and nulliparous women.

Subdermal Implant (Etonogestrel)

  • Placed subdermally over the triceps/inner arm under local anesthesia
  • Lasts up to 3-5 years, failure rate <0.05 pregnancies per 100 women/year
  • Adverse effects: irregular menstrual bleeding, headaches
  • May be less effective in women >130% ideal body weight

Levonorgestrel IUD (Hormonal IUD)

  • Available in devices lasting 3-7 years depending on the device
  • Failure rate ~0.2 per 100 women/year
  • Additional benefit: highly effective treatment for heavy menstrual bleeding
  • Contraindicated in pelvic inflammatory disease (PID) or history of ectopic pregnancy
  • Breakthrough/unscheduled bleeding is common initially

Copper IUD (Non-hormonal)

  • Mechanism: spermicidal; no hormones
  • Effective for up to 10-12 years, failure rate <1 per 100 women/year
  • Can also be used as emergency contraception if inserted within 5 days of unprotected intercourse
  • Side effects: increased heavy vaginal bleeding and dysmenorrhea (higher discontinuation rates vs. levonorgestrel IUD)
  • Suitable for patients who cannot or prefer not to use hormones

3. Hormonal Methods

Mechanism of Action

Exogenously administered estrogen blunts FSH release (suppresses follicle development), while progestin inhibits LH secretion (prevents ovulation). Progestin also thickens cervical mucus, hindering sperm penetration. Withdrawal of progestin during the placebo interval triggers withdrawal bleeding.

Combination Oral Contraceptives (COC)

  • Contain ethinyl estradiol + a progestin (e.g., levonorgestrel, norethindrone, drospirenone)
  • Monophasic (constant dose) or triphasic (increasing progestin doses) formulations
  • Standard regimen: 21-24 active pills + 4-7 placebo pills per 28-day cycle
  • Extended-cycle: 84 active + 7 placebo days (fewer withdrawal bleeds per year)
  • Continuous: active pills every day (no withdrawal bleeding)
  • Typical use failure rate: ~9%

Transdermal Patch

  • Contains ethinyl estradiol + norelgestromin or levonorgestrel
  • One patch applied weekly x 3 weeks; no patch in week 4 (withdrawal bleed)
  • Less effective in women >90 kg
  • Total estrogen exposure is higher than with oral COCs, increasing VTE risk; contraindicated in BMI ≥30 kg/m²

Vaginal Ring

  • Contains ethinyl estradiol + etonogestrel
  • Inserted vaginally, left in place for 3 weeks; removed for week 4
  • Typical use failure rate ~9%; most common reason for discontinuation is device-related (vaginal irritation, expulsion)

Progestin-Only Pills ("Mini-pill")

  • Usually contain norethindrone (or drospirenone in newer formulations)
  • Taken daily continuously - no hormone-free interval
  • Less effective than COCs; more irregular cycles
  • Preferred in: breastfeeding mothers (progestins do not reduce milk production; estrogen can bind prolactin receptors and reduce supply), and women with contraindications to estrogen

Injectable Progestin (DMPA - Medroxyprogesterone Acetate)

  • IM or SC injection every 3 months
  • Failure rate ~3-6 per 100 women/year with typical use
  • Many women experience amenorrhea
  • Return to fertility may be delayed 6-9 months after stopping
  • Side effects: weight gain, irregular menses, mood changes
  • Important: associated with bone loss - should not be used >2 years unless alternatives are inappropriate

4. Barrier Methods

  • Male condom: failure rate 17-18 per 100 women/year (typical use); also provides STI protection
  • Female condom: failure rate ~21 per 100 women/year
  • Diaphragm/cervical cap: failure rate ~12 per 100 women/year; require fitting and use with spermicide
  • Spermicide alone: failure rate ~28 per 100 women/year; often combined with other barrier methods
  • Advantages: minimal side effects, lower cost, no prescription needed, STI protection (condoms)

5. Behavioral / Natural Methods

  • Lactational amenorrhea: effective for the first 6 postpartum months if exclusive breastfeeding and menses have not resumed; mechanism is suckling-induced suppression of GnRH pulsatility; failure rate as low as 0.5-1.5 per 100 women/year under ideal conditions
  • Fertility awareness (Standard Days Method): women with regular cycles avoid intercourse on days 8-19 of the cycle; failure rate ~24 per 100 women/year with typical use
  • Withdrawal (coitus interruptus): failure rate ~22 per 100 women/year with typical use

6. Emergency Contraception (EC)

Used after unprotected or inadequately protected intercourse. The probability of pregnancy from any single act of intercourse averages ~8%, but can reach 30% near ovulation.
EC OptionMechanismWindowNotes
Copper IUDPrevents fertilization + implantationWithin 5 daysMost effective EC; works in obese women
Ulipristal acetateProgesterone receptor antagonist; delays/inhibits ovulationWithin 5 daysRequires prescription; may be more effective than LNG near ovulation
Levonorgestrel (Plan B)Delays/inhibits ovulationWithin 72 hours (up to 120 hrs)OTC; less effective in obesity
Combined hormonal pills (Yuzpe)Delays ovulationWithin 72 hoursLess effective, more nausea than LNG alone

7. Adverse Effects Summary

ComponentCommon Adverse Effects
EstrogenBreast fullness, fluid retention, headache, nausea, increased BP, VTE risk
ProgestinDepression, libido changes, hirsutism, acne, irregular bleeding
Combined (estrogen + progestin)Rare: thromboembolism, MI, stroke - especially in women >35 who smoke

8. Contraindications to Estrogen-Containing Contraceptives (US MEC Category 4)

The US Medical Eligibility Criteria (USMEC) classifies conditions by the risk they pose when using each contraceptive method. Category 4 = unacceptable health risk:
  • Women ≥35 years who smoke ≥15 cigarettes/day
  • Known ischemic heart disease or multiple cardiovascular risk factors
  • Acute DVT or prior thromboembolic event with high recurrence risk
  • Stroke or known thrombogenic mutations
  • Complicated valvular heart disease
  • Hypertension (systolic ≥160 mmHg or diastolic ≥100 mmHg)
  • Systemic lupus erythematosus (positive/unknown antiphospholipid antibodies)
  • Breast cancer
  • Diabetes with neuropathy/retinopathy/nephropathy
  • Migraines with aura
  • Cirrhosis, hepatic adenoma, or hepatoma
  • Pregnancy; early postpartum (<21 days); breastfeeding <21 days postpartum

9. Selecting a Contraceptive Method - Key Questions

  1. Does the patient want hormonal contraception? If not -> copper IUD, condom, diaphragm, or fertility awareness
  2. Are there contraindications to estrogen? If yes -> progestin-only methods or nonhormonal options
  3. What is the desired duration? Long-term -> LARC (IUD or implant); short-term -> pills, patch, ring
  4. What is the patient's ability to adhere? Poor adherence -> LARC (highest efficacy regardless of compliance)
  5. Is STI protection needed? -> Condom (only method providing STI protection)

Sources: Goldman-Cecil Medicine, 2nd Vol. Set (Ch. 220) | Harrison's Principles of Internal Medicine 22E (Ch. 408) | Lippincott Illustrated Reviews: Pharmacology (Ch. 25)

Types in flow charts

Running Command

mkdir -p /tmp/workspace/contraceptives && ls /tmp/workspace/contraceptives/

Writing File

~/contraceptives/flowcharts.py

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
import matplotlib.patheffects as pe

# ─────────────────────────────────────────────────────────────────────────────
# Helper utilities
# ─────────────────────────────────────────────────────────────────────────────

def rounded_box(ax, x, y, w, h, text, facecolor, textcolor='white',
                fontsize=9, bold=False, edgecolor='white', lw=1.2, radius=0.04):
    box = FancyBboxPatch((x - w/2, y - h/2), w, h,
                         boxstyle=f"round,pad={radius}",
                         linewidth=lw, edgecolor=edgecolor,
                         facecolor=facecolor, zorder=3)
    ax.add_patch(box)
    weight = 'bold' if bold else 'normal'
    ax.text(x, y, text, ha='center', va='center', fontsize=fontsize,
            color=textcolor, fontweight=weight, zorder=4,
            wrap=True, multialignment='center')

def arrow(ax, x1, y1, x2, y2, color='#555555', lw=1.5):
    ax.annotate('', xy=(x2, y2), xytext=(x1, y1),
                arrowprops=dict(arrowstyle='->', color=color,
                                lw=lw, connectionstyle='arc3,rad=0'))


# ─────────────────────────────────────────────────────────────────────────────
# FIGURE 1 – Master Classification Flowchart
# ─────────────────────────────────────────────────────────────────────────────

def fig1_master():
    fig, ax = plt.subplots(figsize=(18, 12))
    ax.set_xlim(0, 18)
    ax.set_ylim(0, 12)
    ax.axis('off')
    ax.set_facecolor('#F7F9FC')
    fig.patch.set_facecolor('#F7F9FC')

    ax.text(9, 11.5, 'CONTRACEPTIVE METHODS – Master Classification',
            ha='center', va='center', fontsize=14, fontweight='bold', color='#1a1a2e')

    # Root node
    rounded_box(ax, 9, 10.6, 3.2, 0.7, 'CONTRACEPTIVE METHODS',
                '#1a1a2e', fontsize=11, bold=True)

    # Level 1 branches  (x positions)
    L1 = [
        (1.5,  8.8, '#c0392b', 'PERMANENT'),
        (4.5,  8.8, '#8e44ad', 'LONG-ACTING\nREVERSIBLE (LARC)'),
        (8.0,  8.8, '#2471a3', 'SHORT-ACTING\nHORMONAL'),
        (12.5, 8.8, '#117a65', 'BARRIER'),
        (15.5, 8.8, '#d4800a', 'BEHAVIORAL /\nNATURAL'),
    ]

    for (x, y, col, lbl) in L1:
        arrow(ax, 9, 10.2, x, 9.15, color='#aaaaaa')
        rounded_box(ax, x, y, 2.6, 0.75, lbl, col, fontsize=9, bold=True)

    # ── PERMANENT children ──
    perm = [
        (0.9, 7.5, 'Vasectomy\n(male)'),
        (2.1, 7.5, 'Tubal\nSterilization'),
    ]
    for (x, y, lbl) in perm:
        arrow(ax, 1.5, 8.42, x, 7.75)
        rounded_box(ax, x, y, 1.0, 0.55, lbl, '#e74c3c', fontsize=7.5)

    # ── LARC children ──
    larc = [
        (3.4, 7.5, 'Copper\nIUD\n(10–12 yr)'),
        (4.5, 7.5, 'Levonorgestrel\nIUD\n(3–7 yr)'),
        (5.6, 7.5, 'Etonogestrel\nImplant\n(3–5 yr)'),
    ]
    for (x, y, lbl) in larc:
        arrow(ax, 4.5, 8.42, x, 7.85)
        rounded_box(ax, x, y, 1.05, 0.7, lbl, '#a569bd', fontsize=7)

    # ── SHORT-ACTING HORMONAL children ──
    short = [
        (6.0,  7.5, 'Combined\nOral\nContraceptive'),
        (7.2,  7.5, 'Progestin-\nOnly Pill\n(mini-pill)'),
        (8.4,  7.5, 'Transdermal\nPatch'),
        (9.6,  7.5, 'Vaginal\nRing'),
        (10.8, 7.5, 'Injectable\n(DMPA)\nevery 3 mo'),
    ]
    for (x, y, lbl) in short:
        arrow(ax, 8.0, 8.42, x, 7.85)
        rounded_box(ax, x, y, 1.1, 0.75, lbl, '#2e86c1', fontsize=7)

    # ── BARRIER children ──
    barrier = [
        (11.5, 7.5, 'Male\nCondom'),
        (12.5, 7.5, 'Female\nCondom'),
        (13.5, 7.5, 'Diaphragm\n/ Cerv. Cap'),
        (14.5, 7.5, 'Spermicide'),
    ]
    for (x, y, lbl) in barrier:
        arrow(ax, 12.5, 8.42, x, 7.75)
        rounded_box(ax, x, y, 0.95, 0.55, lbl, '#148f77', fontsize=7)

    # ── BEHAVIORAL children ──
    behav = [
        (14.8, 7.5, 'Fertility\nAwareness'),
        (15.9, 7.5, 'Lactational\nAmenorrhea'),
        (17.0, 7.5, 'Withdrawal'),
    ]
    for (x, y, lbl) in behav:
        arrow(ax, 15.5, 8.42, x, 7.75)
        rounded_box(ax, x, y, 1.0, 0.55, lbl, '#e67e22', fontsize=7)

    # ── EMERGENCY band ──
    rounded_box(ax, 9, 6.5, 16.5, 0.7,
                'EMERGENCY CONTRACEPTION  (post-coital / after unprotected intercourse)',
                '#922b21', fontsize=10, bold=True)

    ec = [
        (3.5,  5.5, '#c0392b', 'Copper IUD\n(within 5 days)\nMost effective'),
        (7.5,  5.5, '#8e44ad', 'Ulipristal Acetate\n(within 5 days)\nPx receptor antagonist'),
        (11.5, 5.5, '#2471a3', 'Levonorgestrel\n(Plan B)\nWithin 72–120 h'),
        (15.2, 5.5, '#117a65', 'Combined\nHormonal Pills\n(Yuzpe method)'),
    ]
    for (x, y, col, lbl) in ec:
        arrow(ax, 9, 6.15, x, 5.85, color='#c0392b')
        rounded_box(ax, x, y, 2.8, 0.75, lbl, col, fontsize=8)

    # ── Failure-rate legend strip ──
    ax.text(0.4, 4.6, 'Typical-use failure rate (pregnancies per 100 women/year):',
            fontsize=8.5, color='#333', fontweight='bold')
    items = [
        ('#1a1a2e', 'Implant <0.05'),
        ('#8e44ad', 'LNG-IUD 0.2'),
        ('#c0392b', 'Cu-IUD 0.8'),
        ('#2471a3', 'Injectable 6'),
        ('#117a65', 'COC/Patch/Ring 9'),
        ('#d4800a', 'Condom 18'),
        ('#e67e22', 'Withdrawal 22'),
        ('#922b21', 'Spermicide 28'),
    ]
    xpos = 0.4
    for col, lbl in items:
        patch = mpatches.Patch(color=col, label=lbl)
        ax.text(xpos, 4.1, '■', color=col, fontsize=14, va='center')
        ax.text(xpos + 0.35, 4.1, lbl, fontsize=7.5, va='center', color='#333')
        xpos += 2.1

    plt.tight_layout()
    plt.savefig('/tmp/workspace/contraceptives/fig1_master_classification.png',
                dpi=180, bbox_inches='tight')
    plt.close()
    print('Fig 1 saved.')


# ─────────────────────────────────────────────────────────────────────────────
# FIGURE 2 – Hormonal Methods Deep-Dive Flowchart
# ─────────────────────────────────────────────────────────────────────────────

def fig2_hormonal():
    fig, ax = plt.subplots(figsize=(16, 11))
    ax.set_xlim(0, 16)
    ax.set_ylim(0, 11)
    ax.axis('off')
    ax.set_facecolor('#EEF4FB')
    fig.patch.set_facecolor('#EEF4FB')

    ax.text(8, 10.6, 'HORMONAL CONTRACEPTIVES – Classification & Key Details',
            ha='center', va='center', fontsize=13, fontweight='bold', color='#1a1a2e')

    # Root
    rounded_box(ax, 8, 9.8, 3.5, 0.65, 'HORMONAL CONTRACEPTIVES',
                '#1a1a2e', fontsize=11, bold=True)

    # Two branches
    arrow(ax, 8, 9.47, 4, 8.75)
    arrow(ax, 8, 9.47, 12, 8.75)

    rounded_box(ax, 4, 8.45, 4.0, 0.55,
                'COMBINATION\n(Estrogen + Progestin)', '#154360', fontsize=9, bold=True)
    rounded_box(ax, 12, 8.45, 4.0, 0.55,
                'PROGESTIN-ONLY', '#4a235a', fontsize=9, bold=True)

    # ── Combination children ──
    combo = [
        (1.3, 7.2, 'Combined\nOral\nContraceptive\n(COC)',
         '• Ethinyl estradiol\n  + progestin\n• Monophasic /\n  Triphasic\n• 21-24 active +\n  4-7 placebo days\n• Failure: ~9%'),
        (4.1, 7.2, 'Transdermal\nPatch',
         '• EE + norelgestromin\n  or levonorgestrel\n• 1 patch/week × 3 wk\n• ↑ VTE risk vs COC\n• Less effective\n  if wt >90 kg\n• Failure: ~9%'),
        (6.9, 7.2, 'Vaginal\nRing',
         '• EE + etonogestrel\n• Insert 3 wk,\n  remove 1 wk\n• Failure: ~9%\n• d/c: vaginal\n  irritation'),
    ]
    for (x, y, title, detail) in combo:
        arrow(ax, 4, 8.17, x, 7.65)
        rounded_box(ax, x, 7.4, 1.6, 0.45, title, '#1f618d', fontsize=8, bold=True)
        rounded_box(ax, x, 6.35, 1.55, 1.75, detail, '#d6eaf8', textcolor='#1a1a2e',
                    fontsize=7, edgecolor='#1f618d', lw=1)

    # ── Progestin-only children ──
    prog = [
        (9.2,  7.2, 'Progestin-Only\nPill (Mini-pill)',
         '• Norethindrone\n  or drospirenone\n• Daily, no\n  hormone-free\n  interval\n• Safe in BF\n• Failure: ~9%'),
        (11.5, 7.2, 'Injectable\n(DMPA)',
         '• Medroxyprogesterone\n  acetate\n• IM/SC q 3 months\n• Amenorrhea common\n• Fertility return\n  delayed 6–9 mo\n• Bone loss risk\n• Failure: ~6%'),
        (13.8, 7.2, 'Implant\n(Etonogestrel)',
         '• Subdermal, inner arm\n• Duration 3–5 yr\n• As reliable as\n  sterilization\n• Failure: <0.05%\n• Irregular bleeding'),
        (15.5, 7.2, 'LNG-IUD',
         '• Levonorgestrel\n• 3–7 yr duration\n• Reduces heavy\n  menstrual bleeding\n• Avoid if PID or\n  ectopic Hx\n• Failure: 0.2%'),
    ]
    for (x, y, title, detail) in prog:
        arrow(ax, 12, 8.17, x, 7.65)
        rounded_box(ax, x, 7.4, 1.55, 0.45, title, '#6c3483', fontsize=8, bold=True)
        rounded_box(ax, x, 6.35, 1.5, 1.75, detail, '#e8daef', textcolor='#1a1a2e',
                    fontsize=7, edgecolor='#6c3483', lw=1)

    # ── Mechanism panel ──
    ax.add_patch(FancyBboxPatch((0.3, 3.95), 15.4, 1.55,
                                boxstyle='round,pad=0.05', facecolor='#fdfefe',
                                edgecolor='#1a1a2e', lw=1.5, zorder=2))
    ax.text(8, 5.35, 'MECHANISM OF ACTION', ha='center', fontsize=10,
            fontweight='bold', color='#1a1a2e', zorder=3)
    mech_items = [
        (2.2, 4.7, '#154360', 'Estrogen\n(−) FSH → suppresses\nfollicle development'),
        (6.0, 4.7, '#1f618d', 'Progestin\n(−) LH → prevents\novulation'),
        (9.8, 4.7, '#117a65', 'Progestin\nThickens cervical\nmucus → ↓ sperm'),
        (13.5, 4.7, '#8e44ad', 'Progestin\nDecidualized thin\nendometrium'),
    ]
    for (x, y, col, txt) in mech_items:
        rounded_box(ax, x, y, 2.8, 0.95, txt, col, fontsize=8)

    # ── Contraindications panel ──
    ax.add_patch(FancyBboxPatch((0.3, 0.35), 15.4, 3.45,
                                boxstyle='round,pad=0.05', facecolor='#fdedec',
                                edgecolor='#c0392b', lw=1.5, zorder=2))
    ax.text(8, 3.65, 'CONTRAINDICATIONS TO ESTROGEN-CONTAINING METHODS (US MEC Cat 4)',
            ha='center', fontsize=9, fontweight='bold', color='#c0392b', zorder=3)

    ci_col1 = ('Category 4 (Absolute):\n'
               '• Age ≥35 + smoking ≥15 cigs/day\n'
               '• Known ischemic heart disease\n'
               '• Acute DVT / high VTE risk\n'
               '• Stroke / thrombogenic mutations\n'
               '• Migraines with aura\n'
               '• Breast cancer')
    ci_col2 = ('• Complicated valvular heart disease\n'
               '• Hypertension ≥160/100 mmHg\n'
               '• SLE with +antiphospholipid Ab\n'
               '• Cirrhosis / hepatic adenoma\n'
               '• Diabetes with end-organ damage\n'
               '• Breastfeeding <21 days postpartum\n'
               '• Peripartum cardiomyopathy (<6 mo)')
    ci_col3 = ('Prefer PROGESTIN-ONLY or\nNONHORMONAL methods when:\n\n'
               '• Estrogen contraindicated\n'
               '• Breastfeeding\n'
               '• BMI ≥30 (patch CI)\n'
               '• Long-term need → LARC\n'
               '• Poor adherence → LARC\n'
               '• STI protection needed\n  → Add condom')
    ax.text(2.5, 3.25, ci_col1, fontsize=7.5, color='#7b241c', va='top', zorder=3)
    ax.text(7.5, 3.25, ci_col2, fontsize=7.5, color='#7b241c', va='top', zorder=3)
    ax.add_patch(FancyBboxPatch((11.2, 0.55), 4.2, 2.9,
                                boxstyle='round,pad=0.05', facecolor='#d5f5e3',
                                edgecolor='#117a65', lw=1.2, zorder=3))
    ax.text(13.3, 3.3, ci_col3, fontsize=7.5, color='#0e6655', va='top', zorder=4)

    plt.tight_layout()
    plt.savefig('/tmp/workspace/contraceptives/fig2_hormonal_deepdive.png',
                dpi=180, bbox_inches='tight')
    plt.close()
    print('Fig 2 saved.')


# ─────────────────────────────────────────────────────────────────────────────
# FIGURE 3 – Emergency Contraception Decision Flowchart
# ─────────────────────────────────────────────────────────────────────────────

def fig3_emergency():
    fig, ax = plt.subplots(figsize=(14, 10))
    ax.set_xlim(0, 14)
    ax.set_ylim(0, 10)
    ax.axis('off')
    ax.set_facecolor('#FEF9E7')
    fig.patch.set_facecolor('#FEF9E7')

    ax.text(7, 9.65, 'EMERGENCY CONTRACEPTION – Decision Flowchart',
            ha='center', fontsize=13, fontweight='bold', color='#1a1a2e')

    # Start
    rounded_box(ax, 7, 8.9, 5.5, 0.65,
                'Unprotected / Inadequately Protected Intercourse',
                '#922b21', fontsize=10, bold=True)

    # Q1
    arrow(ax, 7, 8.57, 7, 8.0)
    rounded_box(ax, 7, 7.75, 5.2, 0.5,
                'How much time has passed?',
                '#6e2f1a', fontsize=9, bold=True)

    # Timeline branches
    arrow(ax, 4.4, 7.75, 2.5, 7.0, color='#555')
    arrow(ax, 7, 7.5, 7, 7.0, color='#555')
    arrow(ax, 9.6, 7.75, 11.5, 7.0, color='#555')

    ax.text(2.5, 7.2, '≤ 72 hours', ha='center', fontsize=8.5, color='#555', style='italic')
    ax.text(7.0, 7.2, '≤ 120 hours\n(5 days)', ha='center', fontsize=8.5, color='#555', style='italic')
    ax.text(11.5, 7.2, '> 5 days', ha='center', fontsize=8.5, color='#555', style='italic')

    # ≤72 h options
    rounded_box(ax, 2.5, 6.5, 4.0, 0.55,
                'All 4 EC options available', '#1f618d', fontsize=9, bold=True)
    opts_72 = [
        (0.9, 5.6, 'Levonorgestrel\n(Plan B)\nOTC, most\nwidely used'),
        (2.5, 5.6, 'Ulipristal\nAcetate\nRx needed;\nbetter near\novulation'),
        (4.1, 5.6, 'Copper IUD\nMost effective\noption overall'),
    ]
    for (x, y, lbl) in opts_72:
        arrow(ax, 2.5, 6.22, x, 5.98)
        rounded_box(ax, x, y, 1.2, 0.75, lbl, '#2e86c1', fontsize=7.5)

    # 72h–5d options
    rounded_box(ax, 7, 6.5, 4.0, 0.55,
                'Copper IUD or Ulipristal', '#117a65', fontsize=9, bold=True)
    opts_5d = [
        (5.8, 5.6, 'Copper IUD\n≤5 days;\nmost effective\nany weight'),
        (8.2, 5.6, 'Ulipristal\nAcetate\n≤5 days;\nbetter than LNG\nnear ovulation'),
    ]
    for (x, y, lbl) in opts_5d:
        arrow(ax, 7, 6.22, x, 5.98)
        rounded_box(ax, x, y, 2.0, 0.9, lbl, '#148f77', fontsize=7.5)

    # >5 days
    rounded_box(ax, 11.5, 6.5, 3.5, 0.55,
                'EC no longer indicated', '#7b7d7d', fontsize=9, bold=True)
    rounded_box(ax, 11.5, 5.6, 3.2, 0.75,
                'Counsel on regular\ncontraception\n& pregnancy test',
                '#aab7b8', textcolor='#1a1a2e', fontsize=8)

    # Q2 – obesity check
    arrow(ax, 7, 6.22, 7, 4.65)  # from IUD/ulipristal box
    rounded_box(ax, 7, 4.4, 5.2, 0.5,
                'Is the patient obese / overweight?', '#6e2f1a', fontsize=9, bold=True)

    arrow(ax, 4.4, 4.4, 2.5, 3.7, color='#555')
    arrow(ax, 9.6, 4.4, 11.0, 3.7, color='#555')
    ax.text(2.5, 3.9, 'Yes', ha='center', fontsize=9, color='#922b21', fontweight='bold')
    ax.text(11.0, 3.9, 'No', ha='center', fontsize=9, color='#117a65', fontweight='bold')

    rounded_box(ax, 2.5, 3.35, 4.2, 0.75,
                'Prefer Copper IUD\n(effective regardless of weight)\nor Ulipristal > Levonorgestrel',
                '#c0392b', fontsize=8)
    rounded_box(ax, 11.0, 3.35, 3.8, 0.75,
                'Any appropriate\nEC method\ncan be used',
                '#117a65', fontsize=8)

    # Copper IUD box – can keep as ongoing contraception
    arrow(ax, 7, 4.15, 7, 3.3)
    rounded_box(ax, 7, 3.0, 5.8, 0.55,
                'If Copper IUD chosen: continue as ongoing contraception (up to 10–12 yr)',
                '#8e44ad', fontsize=8.5, bold=False)

    # Note panel
    ax.add_patch(FancyBboxPatch((0.4, 0.3), 13.2, 2.35,
                                boxstyle='round,pad=0.05', facecolor='#fdfefe',
                                edgecolor='#1a1a2e', lw=1.2, zorder=2))
    ax.text(7, 2.55, 'KEY PHARMACOLOGY NOTES', ha='center', fontsize=9,
            fontweight='bold', color='#1a1a2e', zorder=3)
    notes = [
        '• Levonorgestrel: delays/inhibits ovulation; OTC; less effective if taken >72 h or in obese women.',
        '• Ulipristal acetate (ella): progesterone receptor antagonist; maintains efficacy up to 120 h & closer to ovulation than LNG.',
        '• Copper IUD: spermicidal (copper ions) + prevents implantation; most effective EC; works for all body weights; can serve as ongoing contraception for 10–12 years.',
        '• Yuzpe (combined OCP) method: highest side effects (nausea/vomiting); least preferred; use only if other methods unavailable.',
        '• Probability of pregnancy from unprotected intercourse: average ~8%, but up to 30% near ovulation.',
    ]
    for i, note in enumerate(notes):
        ax.text(0.7, 2.25 - i * 0.37, note, fontsize=7.5, color='#2c3e50', va='top', zorder=3)

    plt.tight_layout()
    plt.savefig('/tmp/workspace/contraceptives/fig3_emergency_contraception.png',
                dpi=180, bbox_inches='tight')
    plt.close()
    print('Fig 3 saved.')


# ─────────────────────────────────────────────────────────────────────────────
# RUN ALL
# ─────────────────────────────────────────────────────────────────────────────
fig1_master()
fig2_hormonal()
fig3_emergency()
print('All figures saved to /tmp/workspace/contraceptives/')
Running Command

cd /tmp/workspace/contraceptives && python flowcharts.py

All three flowcharts are ready. Here they are:

Flowchart 1 - Master Classification (all types at a glance)

fig1 master classification

Image · PNG

Shows the full tree: Permanent → LARC → Short-acting Hormonal → Barrier → Behavioral/Natural, plus the Emergency Contraception band at the bottom with a failure-rate legend.

Flowchart 2 - Hormonal Methods Deep-Dive

fig2 hormonal deepdive

Image · PNG

Breaks hormonal contraceptives into Combination (COC, Patch, Ring) vs. Progestin-Only (Mini-pill, DMPA, Implant, LNG-IUD), with key details for each, the mechanism of action panel, and the contraindications/when-to-prefer-progestin-only section.

Flowchart 3 - Emergency Contraception Decision Tree

fig3 emergency contraception

Image · PNG

Step-by-step decision flow starting from unprotected intercourse → time elapsed → obesity check → method selection, with pharmacology notes at the bottom.
This is a shared conversation. Sign in to Orris to start your own chat.