Write about 25+ or as many as you know dermatology opd pt cases with their prescriptions for practice and education purposes also give reasons why are we prescribing it and make it in a pdf form

Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Finding Sources
Running Command

mkdir -p /home/daytona/workspace/dermatology-opd && ls /home/daytona/workspace/

Writing File

~/dermatology-opd/generate_pdf.py

#!/usr/bin/env python3
"""
Dermatology OPD Cases – PDF Generator
Uses reportlab to create a well-formatted educational PDF.
"""

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether, PageBreak
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import os

OUTPUT = "/home/daytona/workspace/dermatology-opd/Dermatology_OPD_Cases.pdf"

# ---------------------------------------------------------------------------
# CASE DATA
# ---------------------------------------------------------------------------
CASES = [
    {
        "no": 1,
        "title": "Acne Vulgaris (Mild)",
        "patient": "18-year-old male | Presenting complaint: Multiple comedones and a few papules on the face for 6 months",
        "diagnosis": "Mild Acne Vulgaris",
        "prescription": [
            ("Adapalene 0.1% gel", "Apply a pea-sized amount to entire face at night after washing", "12 weeks, review"),
            ("Benzoyl Peroxide 2.5% wash", "Use as face wash once daily in the morning", "12 weeks"),
            ("Clindamycin 1% lotion", "Apply to affected areas twice daily", "12 weeks (limit to prevent resistance)"),
            ("Sunscreen SPF 30+", "Apply every morning 20 min before sun exposure", "Ongoing"),
        ],
        "rationale": (
            "Adapalene (topical retinoid) normalises follicular keratinisation, prevents new comedone formation, "
            "and has anti-inflammatory properties. Benzoyl peroxide (BPO) is bactericidal against C. acnes and "
            "reduces antimicrobial resistance when combined with antibiotics. Topical clindamycin provides "
            "additional anti-inflammatory and antibacterial action. Sunscreen is mandatory because retinoids "
            "increase photosensitivity. (Dermatology 2-Vol Set 5e, Table 36.4)"
        ),
    },
    {
        "no": 2,
        "title": "Acne Vulgaris (Moderate-Severe)",
        "patient": "22-year-old female | Presenting complaint: Painful nodules, pustules, and scarring on face and back for 1 year; no response to topical agents",
        "diagnosis": "Moderate-to-Severe Nodular Acne Vulgaris",
        "prescription": [
            ("Isotretinoin 0.5 mg/kg/day orally", "Take with food (fatty meal enhances absorption)", "16–20 weeks; cumulative dose target 120–150 mg/kg"),
            ("Adapalene 0.1% + BPO 2.5% gel", "Apply to face at night", "Adjunct during treatment"),
            ("Pregnancy prevention counselling (iPLEDGE)", "Mandatory – two forms of contraception required", "Throughout course"),
            ("Moisturiser + SPF 30+", "Apply daily; isotretinoin causes dryness", "Throughout course"),
        ],
        "rationale": (
            "Isotretinoin (13-cis-retinoic acid) is the only drug that targets all four pathogenic factors of acne: "
            "sebum production, follicular keratinisation, C. acnes colonisation, and inflammation. It is indicated "
            "for nodular/cystic acne or acne unresponsive to conventional therapy. Teratogenicity mandates "
            "strict contraception. Lipid panel and LFTs should be monitored monthly. "
            "(Dermatology 2-Vol Set 5e, Table 36.4)"
        ),
    },
    {
        "no": 3,
        "title": "Atopic Dermatitis (Eczema)",
        "patient": "7-year-old boy | Presenting complaint: Intensely itchy, dry, scaly patches in antecubital and popliteal fossae; recurrent since age 2; family history of asthma",
        "diagnosis": "Atopic Dermatitis (Moderate)",
        "prescription": [
            ("Mometasone furoate 0.1% cream", "Apply thinly to inflamed areas once daily for 2 weeks (weekdays only – weekend holiday)", "2–4 weeks"),
            ("Tacrolimus 0.03% ointment", "Apply twice daily after steroid course; for maintenance and sensitive areas (face/folds)", "Ongoing as stepper"),
            ("Cetirizine syrup 5 mg (0.25 mg/kg)", "Once daily at night for itch", "4 weeks"),
            ("White soft paraffin / Emollient", "Apply liberally 2–3 times a day to entire body, especially after bath", "Lifelong"),
            ("Advice: lukewarm baths, cotton clothing, avoid triggers", "", ""),
        ],
        "rationale": (
            "Topical corticosteroids (TCS) are first-line anti-inflammatory therapy for atopic dermatitis flares. "
            "Mometasone is a mid-potency steroid suitable for children on the body. Tacrolimus (calcineurin inhibitor) "
            "is steroid-sparing and preferred for the face and flexures to avoid skin atrophy. Emollients are the "
            "cornerstone of AD management – they restore the skin barrier and reduce relapse frequency. "
            "Cetirizine helps with nocturnal itch and sleep. (Fitzpatrick's Dermatology, 9e; Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 4,
        "title": "Psoriasis Vulgaris (Plaque Type)",
        "patient": "35-year-old male | Presenting complaint: Well-defined, silvery scaly plaques on elbows, knees, and scalp for 3 years; PASI 8",
        "diagnosis": "Chronic Plaque Psoriasis (Moderate)",
        "prescription": [
            ("Calcipotriol 0.005% + Betamethasone dipropionate 0.064% ointment", "Apply once daily to plaques for 4 weeks, then weekends only", "4 weeks active, then maintenance"),
            ("Coal tar shampoo 2%", "Apply to scalp, leave for 5 min, then rinse; use 3 times/week", "Ongoing"),
            ("Salicylic acid 6% ointment", "Apply to thick plaques 30 min before topical steroids to aid penetration", "Until scaling resolves"),
            ("Emollient / white soft paraffin", "Apply liberally twice daily to all areas", "Lifelong"),
            ("Referral for NB-UVB phototherapy if no response at 8 weeks", "", ""),
        ],
        "rationale": (
            "Calcipotriol (vitamin D analogue) reduces keratinocyte proliferation. Betamethasone dipropionate "
            "suppresses inflammation. The fixed-dose combination is more effective than either alone. "
            "Salicylic acid is a keratolytic that removes scale and facilitates penetration of other agents. "
            "Coal tar is anti-proliferative and anti-inflammatory. NB-UVB is first-line phototherapy for "
            "moderate-to-severe psoriasis. (Dermatology 2-Vol Set 5e, Table 8.19)"
        ),
    },
    {
        "no": 5,
        "title": "Tinea Corporis (Ringworm)",
        "patient": "28-year-old male | Presenting complaint: Annular, scaly, itchy lesion with central clearing on the forearm for 3 weeks; KOH mount positive for fungal hyphae",
        "diagnosis": "Tinea Corporis",
        "prescription": [
            ("Clotrimazole 1% cream", "Apply to lesion and 2 cm beyond margin twice daily", "4 weeks"),
            ("Terbinafine 250 mg tablet", "Once daily orally (if extensive or resistant)", "2 weeks"),
            ("Advice: keep area dry, avoid sharing towels/clothing", "", ""),
        ],
        "rationale": (
            "Clotrimazole is an imidazole antifungal that inhibits ergosterol synthesis in the fungal cell "
            "membrane, causing cell death. It is effective against dermatophytes (Trichophyton spp.). "
            "Terbinafine (allylamine class) is fungicidal by inhibiting squalene epoxidase; it is indicated for "
            "extensive, recurrent, or topical-resistant tinea. Treatment should continue 1 week beyond clinical "
            "clearance to prevent relapse. (Andrews' Diseases of the Skin; Medical Microbiology 9e)"
        ),
    },
    {
        "no": 6,
        "title": "Tinea Capitis",
        "patient": "9-year-old girl | Presenting complaint: Patchy hair loss with broken hairs, scaling, and mild cervical lymphadenopathy; KOH positive",
        "diagnosis": "Tinea Capitis (likely Trichophyton tonsurans – endothrix type)",
        "prescription": [
            ("Griseofulvin 10–20 mg/kg/day (microsize) orally", "Take with fatty meal once daily", "6–8 weeks"),
            ("Selenium sulfide 2.5% shampoo", "Apply twice weekly as sporicidal adjunct; leave 5 min before rinsing", "6–8 weeks (treat household contacts too)"),
            ("Ibuprofen 10 mg/kg if kerion present (inflammation)", "3 times daily with food for 1–2 weeks", "1–2 weeks"),
        ],
        "rationale": (
            "Tinea capitis requires systemic antifungal therapy because topical agents cannot penetrate the hair "
            "follicle sufficiently. Griseofulvin accumulates in keratin and is fungistatic. Terbinafine is an "
            "alternative with shorter courses. Selenium sulfide shampoo reduces fungal shedding and prevents "
            "household spread. Kerion (inflammatory mass) may require short-course corticosteroids to reduce "
            "scarring alopecia risk. (Red Book 2021; Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 7,
        "title": "Tinea Pedis (Athlete's Foot)",
        "patient": "30-year-old male | Presenting complaint: Itchy, macerated, peeling skin between 3rd–4th toe spaces and sole, worse in summer; wears closed shoes all day",
        "diagnosis": "Tinea Pedis (Interdigital type)",
        "prescription": [
            ("Terbinafine 1% cream", "Apply to interdigital spaces twice daily", "1–2 weeks"),
            ("Miconazole 2% powder", "Dust inside shoes and socks daily", "Ongoing (prevents recurrence)"),
            ("Advice: dry feet thoroughly after bathing, cotton socks, open footwear", "", ""),
        ],
        "rationale": (
            "Terbinafine cream is fungicidal with a short treatment duration for tinea pedis. Antifungal powder "
            "in shoes reduces fungal load in the environment, which is the main source of re-infection. "
            "Moisture control is essential because Trichophyton rubrum thrives in warm, moist environments. "
            "(Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 8,
        "title": "Scabies",
        "patient": "25-year-old male | Presenting complaint: Intense nocturnal itching, papules, and linear burrows on finger webs, wrists, genitalia, and axillae; family members also itching",
        "diagnosis": "Scabies",
        "prescription": [
            ("Permethrin 5% cream", "Apply from neck downward to entire body including under nails; wash off after 8–10 hours; repeat after 1 week", "2 applications"),
            ("Ivermectin 200 µg/kg orally (alternative/adjunct)", "Take with water on empty stomach; repeat after 2 weeks", "2 doses"),
            ("Hydroxyzine 25 mg at night", "For post-scabietic itch (itch may persist 2–4 weeks after cure)", "2–4 weeks"),
            ("Wash all bedding and clothing in hot water >60°C", "", "Once (decontamination)"),
            ("Treat ALL household contacts simultaneously", "", ""),
        ],
        "rationale": (
            "Permethrin 5% cream is the first-line scabicide – it is neurotoxic to Sarcoptes scabiei mites by "
            "disrupting sodium channel function. Two applications are required because permethrin is not ovicidal; "
            "the second dose kills mites that hatched from eggs surviving the first treatment. Ivermectin (oral) "
            "is added for crusted scabies or when topical therapy fails. Post-treatment itch is due to residual "
            "antigen, not re-infection. Treating household contacts prevents ping-pong re-infestation. "
            "(Red Book 2021; Dermatology 2-Vol Set 5e; Goldman-Cecil Medicine)"
        ),
    },
    {
        "no": 9,
        "title": "Urticaria (Acute)",
        "patient": "32-year-old female | Presenting complaint: Sudden onset of multiple, wheals all over the body after taking NSAIDs; resolving within 24 hours; no angioedema",
        "diagnosis": "Acute Urticaria (Drug-induced – NSAIDs)",
        "prescription": [
            ("Cetirizine 10 mg tablet", "Once daily", "1 week; extend if wheals recur"),
            ("Levocetirizine 5 mg (alternative)", "Once daily at night", "1 week"),
            ("Ranitidine 150 mg (H2 blocker – adjunct)", "Twice daily", "5–7 days (adds benefit when combined with H1 antihistamine)"),
            ("Prednisolone 40 mg orally (if severe wheals)", "Once daily in morning with food", "3–5 days (short tapering course)"),
            ("STOP/AVOID the offending NSAID; document allergy", "", ""),
        ],
        "rationale": (
            "Urticaria is mediated by mast cell degranulation releasing histamine, causing vasodilation and "
            "increased vascular permeability. Second-generation H1 antihistamines (cetirizine, levocetirizine) "
            "are first-line; they are non-sedating and long-acting. H2 blockers added to H1 antihistamines "
            "provide modest additional benefit. Short-course corticosteroids reduce the duration of acute severe "
            "urticaria but are NOT recommended for chronic urticaria. Drug avoidance is the definitive treatment "
            "for drug-induced urticaria. (Fitzpatrick's Dermatology, 9e; Dermatology 2-Vol Set 5e)"
        ),
    },
    {
        "no": 10,
        "title": "Chronic Spontaneous Urticaria",
        "patient": "40-year-old female | Presenting complaint: Daily wheals for 8 weeks, no identifiable trigger; thyroid antibodies positive; Dermatology Life Quality Index (DLQI) score 14",
        "diagnosis": "Chronic Spontaneous Urticaria (CSU) with possible autoimmune basis",
        "prescription": [
            ("Bilastine 20 mg tablet", "Once daily", "4 weeks; up-dose to 4× if inadequate response"),
            ("Fexofenadine 180 mg (alternative)", "Once daily", "4 weeks"),
            ("Omalizumab 300 mg subcutaneous injection", "Every 4 weeks (if refractory to high-dose antihistamine after 4 weeks)", "3–6 months"),
            ("Thyroid function tests + anti-TPO antibodies", "Monitor thyroid status", "Every 6 months"),
        ],
        "rationale": (
            "Second-generation H1 antihistamines are first-line for CSU. Up-dosing up to 4× the standard dose is "
            "recommended before stepping up. Omalizumab (anti-IgE monoclonal antibody) is licensed for CSU "
            "refractory to antihistamines; it blocks free IgE and reduces mast cell activation. Thyroid "
            "autoimmunity is commonly associated with CSU and should be managed if overt thyroid disease is present. "
            "(Fitzpatrick's Dermatology 9e; EAACI/GA2LEN/EDF guidelines)"
        ),
    },
    {
        "no": 11,
        "title": "Contact Dermatitis (Allergic)",
        "patient": "45-year-old female | Presenting complaint: Intensely itchy, vesicular, weeping rash on the neck and earlobes 48 hours after wearing new metal jewellery; patch test positive for nickel",
        "diagnosis": "Allergic Contact Dermatitis – Nickel allergy",
        "prescription": [
            ("Hydrocortisone 1% cream", "Apply twice daily to affected area", "1 week"),
            ("Betamethasone valerate 0.1% cream (if severe)", "Apply once daily to non-facial areas", "1–2 weeks then taper"),
            ("Chlorphenamine 4 mg tablet (sedating antihistamine)", "At night for severe itch", "5–7 days"),
            ("Emollient (aqueous cream / petroleum jelly)", "Apply frequently to soothe and protect", "Ongoing"),
            ("Advice: avoid all nickel-containing jewellery; use stainless steel or gold", "", ""),
        ],
        "rationale": (
            "Allergic contact dermatitis is a Type IV (delayed-type) hypersensitivity reaction. Topical "
            "corticosteroids are the mainstay to suppress the T-cell-mediated inflammatory response. "
            "Mild-potency steroids (hydrocortisone) for the face/neck; moderate-potency (betamethasone) for the "
            "body. Antihistamines help with itch but do not affect the underlying immune reaction. "
            "Allergen avoidance is the only definitive treatment – this must be emphasised to the patient. "
            "(Andrews' Diseases of the Skin; Fitzpatrick's Dermatology 9e)"
        ),
    },
    {
        "no": 12,
        "title": "Seborrhoeic Dermatitis",
        "patient": "29-year-old male | Presenting complaint: Greasy, yellowish scales on the scalp and nasolabial folds, with mild erythema; dandruff for 2 years, worsens in winter",
        "diagnosis": "Seborrhoeic Dermatitis",
        "prescription": [
            ("Ketoconazole 2% shampoo", "Apply to scalp, leave 3–5 min, rinse; use 3 times/week for 4 weeks then once/week maintenance", "4 weeks active, then maintenance"),
            ("Ketoconazole 2% cream", "Apply to nasolabial folds and eyebrows twice daily", "2–4 weeks"),
            ("Hydrocortisone 1% cream (for facial erythema)", "Apply once daily for up to 2 weeks", "Max 2 weeks – avoid prolonged use on face"),
            ("Zinc pyrithione shampoo", "Use alternating days with ketoconazole shampoo", "Ongoing maintenance"),
        ],
        "rationale": (
            "Seborrhoeic dermatitis is driven by Malassezia (Pityrosporum) yeasts, which colonise sebum-rich areas "
            "and induce an inflammatory response. Ketoconazole is an imidazole antifungal that targets Malassezia "
            "by inhibiting ergosterol synthesis; it is both antifungal and anti-inflammatory. Low-potency topical "
            "corticosteroids reduce erythema and itch. Zinc pyrithione has antifungal and antibacterial properties "
            "for maintenance. Prolonged facial corticosteroid use must be avoided (perioral dermatitis, rosacea risk). "
            "(Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 13,
        "title": "Pityriasis Versicolor",
        "patient": "20-year-old male | Presenting complaint: Multiple hypopigmented and hyperpigmented scaly patches on chest, back, and upper arms; worse in summer; Wood's lamp shows yellow-green fluorescence",
        "diagnosis": "Pityriasis (Tinea) Versicolor",
        "prescription": [
            ("Ketoconazole 2% shampoo / Selenium sulfide 2.5% lotion", "Apply to affected areas, leave 10 min, rinse; daily for 2 weeks", "2 weeks"),
            ("Fluconazole 400 mg single oral dose (alternative)", "Single dose; may repeat in 1 week", "1–2 doses"),
            ("Itraconazole 200 mg daily", "For recurrent/extensive disease", "5–7 days"),
            ("Advice: pigment changes may take 1–3 months to fully resolve after cure", "", ""),
        ],
        "rationale": (
            "Pityriasis versicolor is caused by Malassezia furfur (and related species). Hypopigmentation results "
            "from azelaic acid produced by the yeast, which inhibits tyrosinase and reduces melanin synthesis in "
            "surrounding melanocytes. Selenium sulfide and ketoconazole shampoos are effective topical agents. "
            "Oral fluconazole or itraconazole is reserved for extensive disease or frequent relapse. The patient "
            "must understand that pigmentation normalises slowly even after fungal clearance. "
            "(Andrews' Diseases of the Skin; Medical Microbiology 9e)"
        ),
    },
    {
        "no": 14,
        "title": "Herpes Zoster (Shingles)",
        "patient": "60-year-old diabetic male | Presenting complaint: Painful, unilateral vesicular rash along T5 dermatome on the right side of chest; 2-day history; preceded by 3 days of burning pain",
        "diagnosis": "Herpes Zoster (VZV reactivation)",
        "prescription": [
            ("Acyclovir 800 mg tablet", "5 times daily (every 4 hours, omitting 1 night dose)", "7 days (start within 72 hours of rash onset)"),
            ("Valacyclovir 1 g (preferred – better bioavailability)", "3 times daily", "7 days"),
            ("Pregabalin 75 mg", "Twice daily (for neuropathic pain prevention and post-herpetic neuralgia)", "4–8 weeks"),
            ("Tramadol 50 mg", "Every 6–8 hours as needed for severe pain", "1–2 weeks"),
            ("Calamine lotion", "Apply to rash for soothing", "Until crusting"),
            ("Counselling: avoid contact with pregnant/immunocompromised individuals until all lesions crusted", "", ""),
        ],
        "rationale": (
            "Herpes zoster results from reactivation of latent varicella-zoster virus in dorsal root ganglia. "
            "Acyclovir/valacyclovir (nucleoside analogues) inhibit VZV DNA polymerase, reducing viral replication, "
            "rash severity, and the risk of post-herpetic neuralgia (PHN). Therapy is most effective if started "
            "within 72 hours of rash onset. Pregabalin is used for neuropathic pain both acutely and to prevent "
            "PHN. Diabetic patients have higher risk of complications and PHN. Zoster vaccine (recombinant subunit) "
            "is recommended for prevention in adults ≥50 years. (Harrison's Principles 22e)"
        ),
    },
    {
        "no": 15,
        "title": "Herpes Simplex (Labialis)",
        "patient": "24-year-old female | Presenting complaint: Recurrent painful vesicles on the lip with tingling prodrome; 5th episode this year; triggered by sun and stress",
        "diagnosis": "Recurrent Herpes Simplex Labialis (Orolabial HSV-1)",
        "prescription": [
            ("Acyclovir 5% cream", "Apply 5 times daily at first sign of tingling", "5 days (episodic therapy)"),
            ("Valacyclovir 500 mg orally", "Twice daily (for frequent recurrences >6/year – suppressive therapy)", "6–12 months"),
            ("Sunscreen lip balm SPF 30+", "Apply before sun exposure", "Ongoing (preventive)"),
        ],
        "rationale": (
            "Herpes simplex virus (HSV-1) causes recurrent orolabial herpes by periodically reactivating from "
            "trigeminal ganglia. Topical acyclovir reduces duration when applied at the prodromal stage. "
            "Oral valacyclovir given as suppressive therapy (daily) significantly reduces frequency of recurrences "
            "(≥6/year threshold for suppression). Sun exposure is a known trigger; UV protection prevents "
            "reactivation. (Harrison's Principles 22e)"
        ),
    },
    {
        "no": 16,
        "title": "Molluscum Contagiosum",
        "patient": "6-year-old girl | Presenting complaint: Multiple (>20) skin-coloured, dome-shaped, umbilicated papules on the trunk and axillae for 3 months; no immunodeficiency",
        "diagnosis": "Molluscum Contagiosum",
        "prescription": [
            ("Watchful waiting (observation)", "Reassure parents: self-limiting in immunocompetent children, usually resolves in 6–18 months", "First-line"),
            ("Imiquimod 5% cream (if cosmetically concerning or spreading)", "Apply 3 nights/week; leave overnight, wash off in morning", "Up to 16 weeks"),
            ("Cantharidin 0.7% solution (applied in clinic)", "Applied by physician to each lesion only; covered with occlusive tape for 4–6 hours", "Repeat every 3 weeks if needed"),
            ("Advice: avoid shared towels, do not scratch lesions", "", ""),
        ],
        "rationale": (
            "Molluscum contagiosum is caused by a poxvirus (Molluscipoxvirus) and is typically self-limiting in "
            "immunocompetent children. Active treatment is reserved for extensive, spreading lesions or social "
            "concerns. Imiquimod stimulates innate and adaptive immunity (TLR7/8 agonist) to clear the virus. "
            "Cantharidin is a blistering agent applied in clinic that mechanically destroys infected cells. "
            "Curettage is highly effective but requires local anaesthesia in children. (Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 17,
        "title": "Warts (Verruca Vulgaris)",
        "patient": "15-year-old male | Presenting complaint: Hard, rough, cauliflower-like growths on the fingers and periungual area for 6 months; 5 lesions",
        "diagnosis": "Common Warts (Verruca Vulgaris) – HPV (types 2, 4)",
        "prescription": [
            ("Salicylic acid 15–26% solution (Duofilm/Occlusal)", "File wart surface, apply solution, cover with tape; daily application", "12 weeks (60% clearance rate)"),
            ("Liquid nitrogen cryotherapy (clinic)", "Applied as 2 freeze-thaw cycles every 2–3 weeks", "4–8 sessions"),
            ("Advice: do not bite fingers; keep warts covered at school", "", ""),
        ],
        "rationale": (
            "Warts are caused by human papillomavirus (HPV). Salicylic acid is keratolytic – it softens and breaks "
            "down the wart tissue and stimulates a local immune response. Cryotherapy with liquid nitrogen destroys "
            "wart tissue by forming intracellular ice crystals that rupture infected cells; it also triggers a "
            "local inflammatory immune response. Combination of both methods has higher success rates. Most warts "
            "spontaneously resolve within 2 years in immunocompetent individuals. "
            "(Andrews' Diseases of the Skin; Fitzpatrick's Dermatology 9e)"
        ),
    },
    {
        "no": 18,
        "title": "Rosacea",
        "patient": "38-year-old fair-skinned female | Presenting complaint: Persistent facial flushing, central facial erythema, papules and pustules on nose and cheeks; no comedones; triggered by alcohol and heat",
        "diagnosis": "Rosacea (Papulopustular subtype)",
        "prescription": [
            ("Metronidazole 0.75% gel", "Apply twice daily to affected areas after washing", "8–12 weeks (maintenance thereafter)"),
            ("Azelaic acid 15% gel", "Apply twice daily (alternative to metronidazole)", "12 weeks"),
            ("Doxycycline 40 mg (sub-antimicrobial dose – modified release)", "Once daily orally in the morning", "12 weeks (anti-inflammatory dose)"),
            ("Brimonidine 0.33% gel (for erythema/flushing)", "Apply once daily to affected areas", "As needed"),
            ("Advice: high SPF sun protection, avoid triggers (heat, alcohol, spicy food)", "", ""),
        ],
        "rationale": (
            "Rosacea pathophysiology involves neurovascular dysregulation, innate immune activation, and "
            "Demodex mite overgrowth. Metronidazole and azelaic acid reduce papulopustular lesions via "
            "anti-inflammatory and anti-microbial mechanisms against Demodex. Sub-antimicrobial doxycycline "
            "(40 mg MR) inhibits matrix metalloproteinases and reduces inflammation without selecting for "
            "antibiotic resistance. Brimonidine is an alpha-2 adrenergic agonist that reduces erythema by "
            "vasoconstriction. Strict sun protection is essential as UV triggers flares. "
            "(Fitzpatrick's Dermatology 9e; Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 19,
        "title": "Vitiligo",
        "patient": "19-year-old female | Presenting complaint: Depigmented white patches on face, hands, and wrists; progressive for 1 year; no family history; Wood's lamp confirms depigmentation",
        "diagnosis": "Vitiligo (Non-segmental / Generalised)",
        "prescription": [
            ("Tacrolimus 0.1% ointment (face and neck)", "Apply twice daily to patches", "3–6 months; assess response"),
            ("Mometasone furoate 0.1% cream (body lesions)", "Apply once daily on weekdays (5-day-on/2-day-off schedule)", "3–4 months per course"),
            ("NB-UVB phototherapy (311 nm)", "2–3 sessions per week in dermatology unit", "6–12 months for significant repigmentation"),
            ("Vitamin D3 400 IU daily (adjunct)", "Oral supplementation", "Ongoing"),
            ("Counselling: camouflage cosmetics; avoid trauma to depigmented skin", "", ""),
        ],
        "rationale": (
            "Vitiligo results from autoimmune destruction of melanocytes in the epidermis. Topical calcineurin "
            "inhibitors (tacrolimus) and topical corticosteroids reduce the local autoimmune attack and allow "
            "melanocyte repopulation from follicular reservoirs. NB-UVB stimulates residual melanocytes to "
            "proliferate and migrate and also has immunomodulatory effects. Response is best in recently active "
            "patches on the face. Vitamin D deficiency is commonly associated with vitiligo. "
            "(Fitzpatrick's Dermatology 9e)"
        ),
    },
    {
        "no": 20,
        "title": "Melasma",
        "patient": "30-year-old pregnant female | Presenting complaint: Bilateral brown patches on the cheeks, forehead, and upper lip for 6 months; worsened during pregnancy and with sun exposure",
        "diagnosis": "Melasma (Chloasma Gravidarum)",
        "prescription": [
            ("Broad-spectrum SPF 50+ sunscreen", "Apply every 2 hours during sun exposure; re-apply after sweating", "Lifelong – most important intervention"),
            ("Azelaic acid 20% cream (safe in pregnancy)", "Apply twice daily", "Until delivery; continue postpartum"),
            ("Hydroquinone 4% cream (postpartum only)", "Apply twice daily to hyperpigmented areas at night", "3 months courses; avoid in pregnancy"),
            ("Triple combination cream: hydroquinone 4% + tretinoin 0.05% + fluocinolone 0.01% (Tri-Luma)", "Apply at night (postpartum, non-pregnant)", "8–24 weeks"),
            ("Physical sunscreen (zinc oxide/titanium dioxide) preferred", "Preferred over chemical UV filters in pregnancy", ""),
        ],
        "rationale": (
            "Melasma is caused by UV-induced upregulation of melanogenesis in genetically predisposed individuals; "
            "oestrogen and progesterone also stimulate melanocytes. Sun protection is the single most effective "
            "intervention and the cornerstone of management. Azelaic acid inhibits tyrosinase and is safe in "
            "pregnancy (Category B). Hydroquinone (tyrosinase inhibitor) is the gold standard for non-pregnant "
            "patients. The triple combination cream (hydroquinone + tretinoin + corticosteroid) produces faster "
            "and more complete depigmentation. (Fitzpatrick's Dermatology 9e)"
        ),
    },
    {
        "no": 21,
        "title": "Alopecia Areata",
        "patient": "25-year-old male | Presenting complaint: Sudden onset single circular patch of hair loss on scalp (5 cm diameter) for 2 months; no scarring; exclamation-mark hairs on dermoscopy",
        "diagnosis": "Alopecia Areata (Patchy type, <50% scalp involvement)",
        "prescription": [
            ("Intralesional triamcinolone acetonide 5 mg/mL", "Injected into scalp patch every 4–6 weeks (performed in clinic)", "3–6 sessions"),
            ("Mometasone furoate 0.1% scalp lotion", "Apply twice daily to patches", "3 months"),
            ("Minoxidil 5% solution or foam", "Apply twice daily to affected areas", "Minimum 6 months (promotes regrowth)"),
            ("Counselling: most cases spontaneously regrow within 1 year; discuss realistic expectations", "", ""),
        ],
        "rationale": (
            "Alopecia areata is an organ-specific autoimmune disease in which T-cells attack anagen hair follicles. "
            "Intralesional corticosteroids suppress the perifolicular inflammation and restore hair growth; "
            "triamcinolone 5 mg/mL is preferred for scalp (10 mg/mL for beard). Topical steroids and minoxidil "
            "are adjuncts to intralesional treatment. Minoxidil prolongs anagen phase and promotes regrowth via "
            "potassium channel opening. JAK inhibitors (tofacitinib, baricitinib) are emerging options for "
            "severe/refractory alopecia areata. (Fitzpatrick's Dermatology 9e)"
        ),
    },
    {
        "no": 22,
        "title": "Androgenetic Alopecia (Male Pattern Baldness)",
        "patient": "32-year-old male | Presenting complaint: Progressive bitemporal recession and crown thinning for 3 years; Norwood-Hamilton grade III vertex; no systemic disease",
        "diagnosis": "Male Androgenetic Alopecia (Norwood III-V)",
        "prescription": [
            ("Finasteride 1 mg tablet", "Once daily orally; take consistently at the same time", "Minimum 12 months to assess effect; continue long-term"),
            ("Minoxidil 5% topical solution", "Apply 1 mL twice daily to dry scalp", "Minimum 12 months; ongoing"),
            ("Ketoconazole 2% shampoo", "Twice weekly (reduces scalp inflammation/Malassezia)", "Ongoing adjunct"),
            ("Counselling: shedding may worsen in first 3 months (normal); results gradual; discontinuation = relapse", "", ""),
        ],
        "rationale": (
            "Androgenetic alopecia is driven by DHT (dihydrotestosterone) binding to androgen receptors in "
            "hair follicles, causing follicular miniaturisation. Finasteride inhibits 5-alpha-reductase type II, "
            "reducing scalp DHT by ~70%; it halts progression and can stimulate some regrowth. Minoxidil "
            "extends the anagen phase and increases follicle size by opening ATP-sensitive potassium channels "
            "and increasing VEGF. The combination of both agents has superior efficacy. PSA should be monitored "
            "and patients counselled about sexual side effects of finasteride. (Fitzpatrick's Dermatology 9e)"
        ),
    },
    {
        "no": 23,
        "title": "Onychomycosis (Nail Fungus)",
        "patient": "50-year-old diabetic female | Presenting complaint: Thickened, discoloured (yellow-brown), brittle toenails on both great toes for 1 year; KOH positive; nail plate scoring confirmed",
        "diagnosis": "Distal Subungual Onychomycosis (Trichophyton rubrum) – DLSO type",
        "prescription": [
            ("Terbinafine 250 mg tablet", "Once daily with food", "12 weeks for toenails, 6 weeks for fingernails"),
            ("Amorolfine 5% nail lacquer (adjunct)", "Apply to affected nails once weekly; file before application", "Duration of systemic treatment"),
            ("Urea 40% paste under occlusion", "Apply for 2 weeks before oral antifungal to soften and debulk thickened nail plate", "2 weeks pre-treatment"),
            ("Monitor LFTs at baseline and 4 weeks (terbinafine is hepatically metabolised)", "", ""),
        ],
        "rationale": (
            "Onychomycosis rarely responds to topical treatment alone because antifungals cannot adequately "
            "penetrate the nail plate. Oral terbinafine is fungicidal against dermatophytes (which cause 90% of "
            "cases) and accumulates in the nail plate at therapeutic concentrations. Amorolfine lacquer is a "
            "topical morpholine antifungal that adds localised activity and reduces relapse. Nail debulking with "
            "urea improves drug penetration. Diabetic patients need treatment due to risk of secondary bacterial "
            "infection. LFT monitoring is mandatory. (Andrews' Diseases of the Skin; Goldman-Cecil Medicine)"
        ),
    },
    {
        "no": 24,
        "title": "Pityriasis Rosea",
        "patient": "21-year-old male | Presenting complaint: 'Herald patch' followed 1–2 weeks later by multiple oval, salmon-coloured patches with 'collarette' scaling on the trunk; bilateral T2–L2 distribution; mild itch",
        "diagnosis": "Pityriasis Rosea",
        "prescription": [
            ("Cetirizine 10 mg", "Once daily at night for itch", "2–4 weeks (self-limiting condition)"),
            ("Emollient / calamine lotion", "Apply twice daily to soothe rash", "Until resolution"),
            ("Acyclovir 800 mg 5 times daily (if severe/early onset, <1 week)", "Oral; reduces severity and duration by ~50% if given early", "1 week (optional – evidence limited)"),
            ("Advice: reassure – rash resolves spontaneously in 6–8 weeks; avoid hot showers (can worsen rash)", "", ""),
        ],
        "rationale": (
            "Pityriasis rosea is associated with HHV-6 and HHV-7 reactivation. It is self-limiting and "
            "management is mainly symptomatic. Antihistamines reduce itch. Some evidence supports early "
            "acyclovir reducing duration of rash, likely by inhibiting HHV-6/7 replication. NB-UVB "
            "phototherapy can also be used for extensive or persistent cases. Patient education about the "
            "benign, self-limiting nature is essential to reduce anxiety. "
            "(Andrews' Diseases of the Skin; Fitzpatrick's Dermatology 9e)"
        ),
    },
    {
        "no": 25,
        "title": "Drug Rash (Maculopapular Drug Eruption)",
        "patient": "55-year-old female | Presenting complaint: Widespread symmetrical maculopapular rash starting 10 days after starting ampicillin for a tooth infection; mild itch; no mucosal involvement",
        "diagnosis": "Maculopapular Drug Eruption (Ampicillin exanthem)",
        "prescription": [
            ("STOP the offending drug (ampicillin) immediately", "", "Definitive management"),
            ("Chlorphenamine 4 mg tablet", "Every 6 hours for itch", "5–7 days"),
            ("Betamethasone valerate 0.1% cream", "Apply twice daily to rash on body", "1–2 weeks"),
            ("Prednisolone 30 mg orally (if extensive/severe)", "Once daily morning; taper over 7 days", "7–10 days"),
            ("Document allergy clearly in notes; advise patient to inform future prescribers", "", ""),
        ],
        "rationale": (
            "Maculopapular drug eruptions are the most common form of drug rash. Ampicillin rash occurs in "
            "~10% of patients and approaches 100% in patients with infectious mononucleosis (EBV). This is NOT "
            "a true allergy but a drug-virus interaction. Drug withdrawal is paramount. Topical corticosteroids "
            "and antihistamines are symptomatic. Any sign of mucosal involvement, blistering, or systemic "
            "symptoms warrants urgent reassessment for Stevens-Johnson Syndrome / TEN. "
            "(Andrews' Diseases of the Skin; Harrison's Principles 22e)"
        ),
    },
    {
        "no": 26,
        "title": "Erythema Multiforme (Minor)",
        "patient": "27-year-old male | Presenting complaint: Target lesions on palms and dorsum of hands appearing 10 days after herpes simplex labialis outbreak; no mucosal involvement",
        "diagnosis": "Erythema Multiforme Minor (HSV-associated)",
        "prescription": [
            ("Acyclovir 400 mg twice daily (suppressive dose)", "Once settled – to prevent future HSV outbreaks and thereby prevent EM recurrences", "6–12 months"),
            ("Cetirizine 10 mg at night", "Symptomatic relief of itch", "2–3 weeks"),
            ("Emollient / calamine lotion", "Apply to lesions for comfort", "Until resolution"),
            ("Reassure: self-limiting, resolves in 2–6 weeks", "", ""),
        ],
        "rationale": (
            "HSV is the trigger in the majority of recurrent EM minor cases. The mechanism involves HSV DNA "
            "deposition in the skin triggering a CD4+ T-cell-mediated immune response. Suppressive acyclovir "
            "is the most effective strategy to prevent recurrent HSV-associated EM – it reduces HSV shedding. "
            "Symptomatic treatment only is needed for the current episode. Severe or mucosal involvement "
            "suggests EM major or Stevens-Johnson Syndrome and requires urgent escalation. "
            "(Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 27,
        "title": "Lichen Planus",
        "patient": "40-year-old male | Presenting complaint: Intensely itchy, violaceous, polygonal flat-topped papules on wrists and ankles; lacy white network on buccal mucosa; Wickham's striae visible",
        "diagnosis": "Lichen Planus (Cutaneous + Oral)",
        "prescription": [
            ("Betamethasone dipropionate 0.05% ointment", "Apply twice daily to skin lesions under occlusion", "4 weeks; taper"),
            ("Triamcinolone acetonide 0.1% oral paste (Orabase)", "Apply to oral mucosal lesions 2–3 times daily after meals", "4–8 weeks"),
            ("Hydroxyzine 25 mg at night", "Sedating antihistamine for severe itch / sleep disturbance", "As needed"),
            ("Acitretin 25 mg (for extensive/resistant cases)", "Once daily orally with fatty meal; avoid pregnancy (teratogen)", "3–6 months"),
            ("Liver function tests, Hep B & C serology (LP can be associated with HCV)", "", "Baseline"),
        ],
        "rationale": (
            "Lichen planus is a T-cell-mediated autoimmune condition targeting basal keratinocytes expressing "
            "altered antigens. Potent topical corticosteroids are first-line for skin lesions; they suppress "
            "the inflammatory CD8+ T-cell response. Oral mucosal lesions require topical corticosteroid "
            "preparations in adhesive base. Acitretin (retinoid) modulates keratinocyte differentiation and "
            "immune response in resistant cases. HCV screening is important given the well-established "
            "association between hepatitis C and lichen planus. (Andrews' Diseases of the Skin; Fitzpatrick's 9e)"
        ),
    },
    {
        "no": 28,
        "title": "Hyperhidrosis (Axillary)",
        "patient": "23-year-old female | Presenting complaint: Excessive sweating from both axillae, embarrassing, present since teenage years; wets through clothing; no secondary cause identified",
        "diagnosis": "Primary Focal Axillary Hyperhidrosis",
        "prescription": [
            ("Aluminium chloride hexahydrate 20% solution (Driclor)", "Apply to dry axillae at night; wash off in morning; use every night for 1 week, then as needed", "Ongoing"),
            ("Botulinum toxin A 50–100 U per axilla (clinic procedure)", "Injected intradermally into axillae; repeat every 6–12 months", "Highly effective for 6–12 months"),
            ("Oxybutynin 5 mg (anticholinergic – if topical insufficient)", "Once daily; up-titrate to 7.5–10 mg if needed", "Trial of 4 weeks"),
            ("Advice: fragrance-free antiperspirant vs deodorant distinction", "", ""),
        ],
        "rationale": (
            "Hyperhidrosis results from overactivity of eccrine sweat glands under sympathetic cholinergic "
            "stimulation. Aluminium chloride hexahydrate precipitates within sweat ducts, physically blocking "
            "them – it is the most cost-effective first-line treatment. Botulinum toxin A blocks presynaptic "
            "acetylcholine release at the neuromuscular/neuroeccrine junction, preventing sweating for months. "
            "Oxybutynin is an anticholinergic that inhibits muscarinic receptors on sweat glands; limited by "
            "side effects (dry mouth, constipation). (Fitzpatrick's Dermatology 9e; Andrews' Diseases of the Skin)"
        ),
    },
    {
        "no": 29,
        "title": "Pemphigus Vulgaris",
        "patient": "45-year-old female | Presenting complaint: Painful oral erosions for 3 months, now flaccid blisters and erosions on the trunk; Nikolsky sign positive; biopsy shows intraepidermal acantholysis; ELISA: anti-desmoglein 3 antibodies positive",
        "diagnosis": "Pemphigus Vulgaris",
        "prescription": [
            ("Prednisolone 1 mg/kg/day orally", "Take with food; morning dose to minimise HPA axis suppression", "Tapering course – reduce by 10 mg every 4 weeks once in remission"),
            ("Azathioprine 1–3 mg/kg/day (steroid-sparing)", "Check TPMT enzyme level before starting; take with food", "Long-term adjunct – allows steroid reduction"),
            ("Rituximab 1000 mg IV (for refractory or severe disease)", "Two infusions 2 weeks apart; repeat at 6 months if needed", "As needed per disease activity"),
            ("Pantoprazole 40 mg", "Once daily in morning (gastric protection during steroid use)", "Throughout steroid course"),
            ("Calcium 500 mg + Vitamin D3 400 IU daily", "Bone protection during long-term steroids", "Throughout steroid course"),
        ],
        "rationale": (
            "Pemphigus vulgaris is an IgG autoimmune blistering disease caused by antibodies against "
            "desmoglein 1 and 3 (desmosomal proteins), disrupting keratinocyte adhesion and causing "
            "intraepidermal blister formation. High-dose corticosteroids are the cornerstone of acute treatment. "
            "Azathioprine (thiopurine) is a steroid-sparing immunosuppressant; TPMT testing prevents dangerous "
            "myelosuppression. Rituximab (anti-CD20) depletes B cells producing the pathogenic antibodies and "
            "is now considered first-line for moderate-severe PV per recent guidelines. Proton pump inhibitors "
            "and bone protection are essential co-medications with long-term steroids. (Fitzpatrick's 9e)"
        ),
    },
    {
        "no": 30,
        "title": "Bullous Pemphigoid",
        "patient": "72-year-old male | Presenting complaint: Pruritic urticarial plaques followed by large tense blisters on the trunk and limbs for 4 weeks; Nikolsky sign negative; IF: IgG at DEJ",
        "diagnosis": "Bullous Pemphigoid",
        "prescription": [
            ("Clobetasol propionate 0.05% cream", "Apply to entire body once daily (super-potent topical corticosteroid is first-line for BP)", "4 weeks then taper"),
            ("Doxycycline 100 mg twice daily + Niacinamide 500 mg 3 times daily", "Oral (steroid-sparing combination for milder disease)", "3–6 months"),
            ("Prednisolone 0.5 mg/kg/day (for severe/extensive disease)", "With gastric and bone protection", "Tapering over months"),
            ("Calcium 500 mg + Vitamin D3 400 IU daily", "Bone protection", "Throughout steroid course"),
        ],
        "rationale": (
            "Bullous pemphigoid is caused by IgG autoantibodies (anti-BP180/BP230) targeting hemidesmosomes "
            "at the dermoepidermal junction, causing subepidermal blistering. Unlike PV, BP blister is tense "
            "because it is subepidermal. Strong topical corticosteroid (clobetasol) is first-line and has "
            "fewer systemic side effects than oral prednisolone in the elderly – who are particularly vulnerable "
            "to steroid complications. Doxycycline + niacinamide inhibit blister formation via anti-inflammatory "
            "mechanisms (metalloproteinase inhibition). (Fitzpatrick's 9e; Andrews' Diseases of the Skin)"
        ),
    },
]

# ---------------------------------------------------------------------------
# PDF BUILD
# ---------------------------------------------------------------------------

def build_pdf():
    doc = SimpleDocTemplate(
        OUTPUT,
        pagesize=A4,
        rightMargin=18*mm,
        leftMargin=18*mm,
        topMargin=20*mm,
        bottomMargin=20*mm,
        title="Dermatology OPD Cases – Educational Reference",
        author="Orris Medical Education",
        subject="Dermatology Clinical Cases with Prescriptions and Rationale",
    )

    styles = getSampleStyleSheet()

    # Custom styles
    title_style = ParagraphStyle(
        "MainTitle",
        parent=styles["Title"],
        fontSize=22,
        textColor=colors.HexColor("#1a3a5c"),
        spaceAfter=6,
        alignment=TA_CENTER,
        fontName="Helvetica-Bold",
    )
    subtitle_style = ParagraphStyle(
        "Subtitle",
        parent=styles["Normal"],
        fontSize=12,
        textColor=colors.HexColor("#4a6fa5"),
        spaceAfter=4,
        alignment=TA_CENTER,
        fontName="Helvetica",
    )
    disclaimer_style = ParagraphStyle(
        "Disclaimer",
        parent=styles["Normal"],
        fontSize=8,
        textColor=colors.HexColor("#888888"),
        spaceAfter=16,
        alignment=TA_CENTER,
        fontName="Helvetica-Oblique",
    )
    case_header_style = ParagraphStyle(
        "CaseHeader",
        parent=styles["Heading2"],
        fontSize=13,
        textColor=colors.white,
        spaceAfter=4,
        spaceBefore=2,
        fontName="Helvetica-Bold",
        leftIndent=6,
    )
    section_label_style = ParagraphStyle(
        "SectionLabel",
        parent=styles["Normal"],
        fontSize=9,
        textColor=colors.HexColor("#1a3a5c"),
        fontName="Helvetica-Bold",
        spaceAfter=2,
        spaceBefore=4,
    )
    body_style = ParagraphStyle(
        "Body",
        parent=styles["Normal"],
        fontSize=9,
        textColor=colors.HexColor("#333333"),
        fontName="Helvetica",
        spaceAfter=4,
        leading=13,
        alignment=TA_JUSTIFY,
    )
    patient_style = ParagraphStyle(
        "Patient",
        parent=styles["Normal"],
        fontSize=9,
        textColor=colors.HexColor("#2c5f2e"),
        fontName="Helvetica",
        spaceAfter=4,
        leading=13,
    )
    dx_style = ParagraphStyle(
        "Diagnosis",
        parent=styles["Normal"],
        fontSize=10,
        textColor=colors.HexColor("#8b1a1a"),
        fontName="Helvetica-Bold",
        spaceAfter=6,
    )
    toc_style = ParagraphStyle(
        "TOC",
        parent=styles["Normal"],
        fontSize=9,
        textColor=colors.HexColor("#222222"),
        fontName="Helvetica",
        leading=14,
        spaceAfter=1,
    )
    toc_header_style = ParagraphStyle(
        "TOCHeader",
        parent=styles["Normal"],
        fontSize=13,
        textColor=colors.HexColor("#1a3a5c"),
        fontName="Helvetica-Bold",
        spaceBefore=8,
        spaceAfter=10,
    )

    story = []

    # --- COVER ---
    story.append(Spacer(1, 30*mm))
    story.append(Paragraph("DERMATOLOGY OPD", title_style))
    story.append(Paragraph("Clinical Cases for Practice &amp; Education", title_style))
    story.append(Spacer(1, 8*mm))
    story.append(HRFlowable(width="80%", thickness=2, color=colors.HexColor("#4a6fa5"), hAlign="CENTER"))
    story.append(Spacer(1, 8*mm))
    story.append(Paragraph("30 Real-World Cases with Full Prescriptions &amp; Pharmacological Rationale", subtitle_style))
    story.append(Spacer(1, 6*mm))
    story.append(Paragraph(
        "Conditions Covered: Acne · Eczema · Psoriasis · Tinea · Scabies · Urticaria · "
        "Contact Dermatitis · Seborrhoeic Dermatitis · Pityriasis Versicolor · "
        "Herpes Zoster &amp; Simplex · Molluscum · Warts · Rosacea · Vitiligo · Melasma · "
        "Alopecia · Onychomycosis · Drug Rash · Lichen Planus · Hyperhidrosis · "
        "Pemphigus Vulgaris · Bullous Pemphigoid · and more",
        subtitle_style
    ))
    story.append(Spacer(1, 14*mm))
    story.append(Paragraph(
        "Sources: Fitzpatrick's Dermatology (9e) · Andrews' Diseases of the Skin (13e) · "
        "Dermatology 2-Volume Set (5e) · Harrison's Principles of Internal Medicine (22e) · "
        "Goldman-Cecil Medicine · Red Book 2021",
        disclaimer_style
    ))
    story.append(Paragraph(
        "FOR EDUCATIONAL USE ONLY · Not for direct clinical application without clinical judgement · "
        "Doses must be verified against local formulary and patient-specific factors",
        disclaimer_style
    ))
    story.append(Spacer(1, 30*mm))
    story.append(PageBreak())

    # --- TABLE OF CONTENTS ---
    story.append(Paragraph("Table of Contents", toc_header_style))
    story.append(HRFlowable(width="100%", thickness=1, color=colors.HexColor("#cccccc")))
    story.append(Spacer(1, 4*mm))
    for case in CASES:
        story.append(Paragraph(f"Case {case['no']:02d}  ·  {case['title']}", toc_style))
    story.append(PageBreak())

    # --- CASES ---
    for case in CASES:
        block = []

        # Coloured header bar using a 1-row table
        header_data = [[Paragraph(
            f"CASE {case['no']:02d}  |  {case['title'].upper()}",
            case_header_style
        )]]
        header_table = Table(header_data, colWidths=[doc.width])
        header_table.setStyle(TableStyle([
            ("BACKGROUND", (0,0), (-1,-1), colors.HexColor("#1a3a5c")),
            ("ROWBACKGROUNDS", (0,0), (-1,-1), [colors.HexColor("#1a3a5c")]),
            ("TOPPADDING", (0,0), (-1,-1), 7),
            ("BOTTOMPADDING", (0,0), (-1,-1), 7),
            ("LEFTPADDING", (0,0), (-1,-1), 10),
            ("RIGHTPADDING", (0,0), (-1,-1), 10),
            ("ROUNDEDCORNERS", [3, 3, 0, 0]),
        ]))
        block.append(header_table)

        # Patient info
        block.append(Spacer(1, 3))
        block.append(Paragraph("PATIENT PRESENTATION", section_label_style))
        block.append(Paragraph(case["patient"], patient_style))

        # Diagnosis
        block.append(Paragraph(f"DIAGNOSIS:  {case['diagnosis']}", dx_style))

        # Prescription table
        block.append(Paragraph("PRESCRIPTION (Rx)", section_label_style))
        rx_data = [["Drug / Item", "Directions", "Duration"]]
        for drug, directions, duration in case["prescription"]:
            if drug and directions:
                rx_data.append([
                    Paragraph(drug, ParagraphStyle("D", parent=styles["Normal"], fontSize=8, fontName="Helvetica-Bold", textColor=colors.HexColor("#1a3a5c"))),
                    Paragraph(directions, ParagraphStyle("I", parent=styles["Normal"], fontSize=8, fontName="Helvetica")),
                    Paragraph(duration, ParagraphStyle("Du", parent=styles["Normal"], fontSize=8, fontName="Helvetica")),
                ])
            elif drug:
                # advice row – span all columns
                rx_data.append([
                    Paragraph(f"⚕ {drug}", ParagraphStyle("A", parent=styles["Normal"], fontSize=8, fontName="Helvetica-Oblique", textColor=colors.HexColor("#555555"))),
                    "", ""
                ])

        col_widths = [doc.width * 0.36, doc.width * 0.43, doc.width * 0.21]
        rx_table = Table(rx_data, colWidths=col_widths, repeatRows=1)
        rx_table.setStyle(TableStyle([
            ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#4a6fa5")),
            ("TEXTCOLOR", (0,0), (-1,0), colors.white),
            ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
            ("FONTSIZE", (0,0), (-1,0), 8),
            ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f5f7fa"), colors.white]),
            ("GRID", (0,0), (-1,-1), 0.3, colors.HexColor("#cccccc")),
            ("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"),
        ]))
        block.append(rx_table)

        # Rationale
        block.append(Spacer(1, 4))
        block.append(Paragraph("PHARMACOLOGICAL RATIONALE", section_label_style))
        rationale_data = [[Paragraph(case["rationale"], body_style)]]
        rationale_table = Table(rationale_data, colWidths=[doc.width])
        rationale_table.setStyle(TableStyle([
            ("BACKGROUND", (0,0), (-1,-1), colors.HexColor("#fdf6e3")),
            ("LEFTPADDING", (0,0), (-1,-1), 8),
            ("RIGHTPADDING", (0,0), (-1,-1), 8),
            ("TOPPADDING", (0,0), (-1,-1), 6),
            ("BOTTOMPADDING", (0,0), (-1,-1), 6),
            ("BOX", (0,0), (-1,-1), 0.5, colors.HexColor("#e8c870")),
        ]))
        block.append(rationale_table)
        block.append(Spacer(1, 10*mm))

        story.append(KeepTogether(block))

    # Build
    doc.build(story)
    print(f"PDF saved to: {OUTPUT}")

if __name__ == "__main__":
    build_pdf()
Running Command

cd /home/daytona/workspace/dermatology-opd && python3 generate_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/dermatology-opd/Dermatology_OPD_Cases.pdf

Your PDF is ready. Here's the download link:

Dermatology OPD Cases

PDF Document · PDF


What's inside (30 cases)

The PDF is structured with a cover page, table of contents, and one clearly formatted section per case. Each case contains:
SectionContent
Patient PresentationAge, sex, chief complaint, key clinical findings
DiagnosisWorking diagnosis with subtype
Prescription (Rx)Drug name + dose, directions for use, duration
Pharmacological RationaleWhy each drug is chosen - mechanism of action, pharmacokinetics, clinical reasoning

All 30 cases at a glance

#ConditionKey Drugs
1Acne Vulgaris (Mild)Adapalene, BPO, Clindamycin topical
2Acne Vulgaris (Moderate-Severe)Isotretinoin, Adapalene+BPO
3Atopic DermatitisMometasone, Tacrolimus, Cetirizine, Emollient
4Psoriasis (Plaque)Calcipotriol+Betamethasone, Coal tar, Salicylic acid
5Tinea CorporisClotrimazole cream, Terbinafine oral
6Tinea CapitisGriseofulvin, Selenium sulfide shampoo
7Tinea PedisTerbinafine cream, Miconazole powder
8ScabiesPermethrin 5%, Ivermectin, Hydroxyzine
9Acute UrticariaCetirizine, Ranitidine, Prednisolone
10Chronic Spontaneous UrticariaBilastine, Omalizumab
11Allergic Contact DermatitisHydrocortisone, Betamethasone, Chlorphenamine
12Seborrhoeic DermatitisKetoconazole shampoo+cream, Zinc pyrithione
13Pityriasis VersicolorSelenium sulfide, Fluconazole, Itraconazole
14Herpes ZosterValacyclovir, Pregabalin, Tramadol
15Herpes Simplex LabialisAcyclovir cream, Valacyclovir suppressive
16Molluscum ContagiosumImiquimod, Cantharidin
17Warts (Verruca Vulgaris)Salicylic acid, Cryotherapy
18RosaceaMetronidazole gel, Doxycycline 40 mg, Brimonidine
19VitiligoTacrolimus, Mometasone, NB-UVB
20MelasmaSPF50+, Azelaic acid, Hydroquinone, Triple combo
21Alopecia AreataIntralesional triamcinolone, Minoxidil
22Androgenetic AlopeciaFinasteride, Minoxidil 5%
23OnychomycosisTerbinafine oral, Amorolfine lacquer
24Pityriasis RoseaCetirizine, Acyclovir (optional)
25Drug Rash (Maculopapular)Stop offending drug, Chlorphenamine, Prednisolone
26Erythema Multiforme MinorAcyclovir suppressive, Cetirizine
27Lichen PlanusBetamethasone, Triamcinolone oral paste, Acitretin
28Hyperhidrosis (Axillary)Aluminium chloride, Botulinum toxin A, Oxybutynin
29Pemphigus VulgarisPrednisolone, Azathioprine, Rituximab
30Bullous PemphigoidClobetasol cream, Doxycycline+Niacinamide

Sources cited throughout: Dermatology 2-Volume Set 5e, Fitzpatrick's Dermatology 9e, Andrews' Diseases of the Skin 13e, Harrison's Principles 22e, Goldman-Cecil Medicine, Red Book 2021.
Educational disclaimer: All prescriptions are for study and teaching purposes. Doses must be confirmed against the local formulary and individualised for each patient based on weight, renal/hepatic function, comorbidities, and drug interactions.
This is a shared conversation. Sign in to Orris to start your own chat.