import json, pathlib

sources = json.loads(pathlib.Path("/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/articles/tinea-versicolor.sources.json").read_text())

article = {
    "topic": "Tinea Versicolor",
    "slug": "tinea-versicolor",
    "category_id": 15900,
    "summary": "A common, benign Malassezia yeast infection causing scaly patches that fail to tan, why it is really \"pityriasis\" not \"tinea,\" and the topical treatments that clear but rarely cure it permanently.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Tinea versicolor (more accurately termed pityriasis versicolor) is a common, benign superficial skin infection caused by Malassezia, a lipid-dependent, dimorphic yeast that is part of normal human skin flora in 90-100% of people; it is not a true dermatophyte "tinea" despite the traditional name.
- Causative species include Malassezia furfur (also called Pityrosporum ovale/orbiculare depending on yeast form), M. globosa, M. restricta, and M. sympodialis; disease occurs when the organism converts from its yeast phase to its mycelial (hyphal) phase, favored by heat, humidity, sweating, and skin occlusion.
- Classic distribution: upper trunk, neck, chest, back, and upper arms, in areas rich in sebaceous glands; infants and children more often show facial involvement, particularly the bilateral temples; other possible sites include the scalp, genital area, thighs, forearms, and hands.
- Lesions are small oval scaly macules/patches (1-3 cm), often in a guttate/raindrop pattern, that can be white, pink, tan, or reddish-brown, with fine ("dusty") scale; color varies even within the same person, and darker-skinned individuals more often show hypo- or hyperpigmentation while lighter skin shows reddish-brown lesions.
- The name "versicolor" reflects lesions failing to tan in summer (appearing lighter than surrounding skin) while looking relatively darker in winter; the hypopigmentation results from azelaic acid, a fungal metabolite that inhibits dopatyrosinase in the melanin synthesis pathway.
- Most patients are asymptomatic, though some report mild pruritus; a papulopustular perifollicular variant with monomorphic pustules can occur on the back, chest, and sometimes extremities.
- Diagnosis: Wood's lamp exam typically shows yellowish-brown fluorescence; KOH preparation of skin scrapings classically shows short, stubby hyphae with clusters of spores — the "spaghetti and meatballs" appearance.
- Differential diagnosis includes pityriasis alba, vitiligo, seborrheic dermatitis, pityriasis rosea, progressive macular hypopigmentation, pityriasis lichenoides, secondary syphilis, and (rare) dyschromatosis universalis hereditaria.
- Treatment: selenium sulfide 2.5% suspension or zinc pyrithione shampoo applied to the whole body and left on overnight, repeated in 1 week then monthly (can be irritating — warn patients); topical antifungals applied twice daily for 1-2 weeks; or a single 400 mg dose of oral fluconazole. Recurrence is common, and the infection is often difficult to eradicate permanently."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Tinea versicolor — more accurately called pityriasis versicolor, since it is not caused by a true dermatophyte — is a common, benign superficial skin infection caused by Malassezia, a lipid-dependent, dimorphic yeast. It is the prototypic skin disease associated with Malassezia."},
        {"title": "Epidemiology",
         "content": "Malassezia is part of normal human skin flora in 90-100% of individuals. Most cases of tinea versicolor occur in the postpubertal period (adolescents and young adults), though it can occasionally occur in prepubertal children and, less commonly, infants. Infants and young children are more likely than adolescents to show facial involvement, particularly the bilateral temples."},
        {"title": "Etiology",
         "content": "Causative organisms include Malassezia furfur (also known as Pityrosporum ovale or Pityrosporum orbiculare, depending on the yeast form), M. globosa, M. restricta, and M. sympodialis. Disease develops when the organism converts from its yeast phase to its mycelial (hyphal) phase; this transformation is favored by heat, humidity, sweating, and skin occlusion, and individual host susceptibility and immunosuppression may also play a role. Warm, moist climates, pregnancy, immunodeficiency, and genetic factors are recognized predisposing factors. Infection localizes to skin areas rich in lipid-producing sebaceous glands, including the chest, back, and face, since Malassezia is lipid-dependent."},
        {"title": "Clinical features",
         "content": "Classic lesions are small, oval, scaly patches (1-3 cm), often arranged in a guttate or raindrop pattern on the upper chest, back, and proximal upper extremities, though the neck, scalp, genital area, thighs, forearms, and dorsum of the hands can also be involved. Lesions often begin in a perifollicular location, then enlarge and merge into confluent patches. Color varies widely, even within the same individual — reddish-brown in lighter skin, and hypopigmented or hyperpigmented in darker skin — with fine, dusty surface scale. The term \"versicolor\" reflects a striking feature: affected areas fail to tan with sun exposure, appearing lighter than surrounding skin in summer but relatively darker in winter, since uninvolved skin tans normally around them. This hypopigmentation results from azelaic acid, a fungal metabolite that inhibits dopatyrosinase, an enzyme in the melanin synthesis pathway. Most patients are asymptomatic, though some experience mild pruritus. A papulopustular perifollicular variant, with monomorphic pustules, can occur on the back, chest, and occasionally the extremities. Folliculitis can also occur, particularly in immunocompromised patients."},
        {"title": "Diagnostics",
         "content": "Wood's lamp examination typically shows yellowish-brown fluorescence of affected areas. A KOH preparation of skin scrapings shows short, stubby hyphae together with large clusters of spores, classically described as a \"spaghetti and meatballs\" appearance — a distinctive and reliable diagnostic finding."},
        {"title": "Differential diagnosis",
         "content": "Conditions commonly confused with tinea versicolor include pityriasis alba, vitiligo, seborrheic dermatitis, pityriasis rosea, progressive macular hypopigmentation, pityriasis lichenoides, secondary syphilis, and the rare dyschromatosis universalis hereditaria."},
        {"title": "Treatment",
         "content": "Treatment options include selenium sulfide 2.5% suspension or zinc pyrithione shampoo, applied to the whole body and left on overnight, repeated again in 1 week and then monthly thereafter — patients should be warned this can be somewhat irritating. Topical antifungal creams are applied twice daily for 1-2 weeks. A single 400 mg dose of oral fluconazole is an additional option. Recurrent infection is common, and the condition can be difficult to eradicate completely."},
        {"title": "Complications",
         "content": "The main lasting concern is cosmetic and psychological: pigmentary changes (hypopigmented or hyperpigmented patches) can persist for weeks to months after successful antifungal treatment, since resolution of the underlying infection does not immediately restore normal pigmentation, and treated skin still needs to re-tan evenly. Recurrence is common even after apparently successful treatment, given that the causative Malassezia species are normal skin flora that can revert to the pathogenic mycelial form whenever predisposing conditions (heat, humidity, sweating, occlusion) recur."},
    ],
    "clinical": [
        {"title": "Recognizing tinea versicolor at the bedside",
         "content": "Suspect tinea versicolor in an adolescent or young adult with multiple small, oval, scaly patches on the upper chest, back, or upper arms that vary in color (white, pink, tan, or reddish-brown) and notably fail to tan with sun exposure, appearing lighter than surrounding skin in summer. In an infant or young child, look instead for facial involvement, particularly the bilateral temples. Confirm with a Wood's lamp (yellowish-brown fluorescence) or KOH prep of a skin scraping, expecting the classic \"spaghetti and meatballs\" pattern of short hyphae and spore clusters. Distinguish from vitiligo (which shows depigmentation rather than fine scale and a positive KOH), pityriasis alba, seborrheic dermatitis, and pityriasis rosea based on distribution, scale character, and KOH findings; consider secondary syphilis in a sexually active adolescent with an atypical or resistant presentation."},
        {"title": "Treatment and counseling on recurrence",
         "content": "Start with selenium sulfide 2.5% suspension or zinc pyrithione shampoo applied to the entire affected area (and surrounding skin) and left on overnight, repeating in 1 week and then monthly to prevent recurrence; warn the patient about potential skin irritation from this regimen. Alternatively, prescribe a topical antifungal cream twice daily for 1-2 weeks, or a single 400 mg dose of oral fluconazole for a simpler regimen in an adolescent or adult. Counsel that pigmentary changes (light or dark patches) can take weeks to months to fully resolve even after the infection itself has cleared, since this reflects residual pigment abnormality rather than persistent infection — reassure the patient this is expected and not treatment failure. Since Malassezia is normal skin flora and recurrence is common, advise on minimizing predisposing factors (excess heat, humidity, sweating, occlusive clothing) where practical."},
    ],
}

for v in ("short", "long", "clinical"):
    for s in article[v]:
        assert s["title"].strip() and s["content"].strip()

out = pathlib.Path("/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/articles/tinea-versicolor.article.json")
out.write_text(json.dumps(article, indent=1))
print(out)
