import json, pathlib

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

article = {
    "topic": "Absence Seizure",
    "slug": "absence-seizure",
    "category_id": 15023,
    "summary": "Brief generalized seizures of staring and impaired awareness with a classic 3-Hz spike-and-wave EEG pattern, typically presenting as childhood absence epilepsy with an excellent prognosis.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Absence seizures (formerly "petit mal") are brief generalized seizures of staring and behavioral arrest, lasting about 2-20 seconds, with abrupt onset and offset, no aura, no postictal period, and often subtle facial automatisms (eye flutter, lip smacking, mouth movements).
- Childhood absence epilepsy (CAE) typically begins between ages 4-10 (peak around 5-6, or 3-8 by another source) and accounts for 8-15% of all childhood epilepsies; onset can occasionally occur in adolescence.
- Seizures can occur many times a day (10 to over 100), are frequently unnoticed by the child or caregivers, and are often mistaken for daydreaming, inattention, or ADHD — sometimes presenting first as school performance problems.
- The classic ictal EEG finding is a 3-Hz generalized spike-and-slow-wave discharge; hyperventilation for 3-4 minutes is a simple, reliable way to provoke an absence seizure and is used routinely during EEG to help confirm the diagnosis.
- Children with typical absence seizures have normal intelligence and a normal neurologic examination; atypical absences instead show 1-2 Hz spike-and-wave discharges with head atonia and myoclonus, occur in syndromes like Lennox-Gastaut, and carry a poor prognosis, while juvenile absences show 4-5 Hz discharges and are linked to juvenile myoclonic epilepsy.
- Distinguishing feature versus focal seizures with impaired awareness: focal seizures usually last longer (over 30 seconds), have an aura, and have a slow return to awareness postictally, whereas absence seizures have none of these.
- First-line treatment is ethosuximide; alternatives are valproate or lamotrigine. Carbamazepine can worsen absence seizures and should be avoided.
- Prognosis is excellent: more than 90% of patients become seizure-free with treatment, and remission typically occurs by age 12.
- Absence status epilepticus, though rare, presents as a prolonged confused or dreamy state that can last hours to days; the treatment of choice is a benzodiazepine."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Absence seizures are generalized, nonconvulsive seizures consisting of sudden staring, unresponsiveness, and often eye flutter, typically lasting only a few seconds (commonly cited ranges are 2-15, 4-20, or 5-20 seconds), with abrupt onset and offset and no aura, warning, or postictal confusion."},
        {"title": "Epidemiology",
         "content": "Absence seizures are most commonly seen in childhood absence epilepsy (CAE), which occurs in children roughly 4-12 years of age, with typical onset around age 5-6 (ranges cited as 4-10 or, by incidence peak, 3-8 years); onset can occasionally occur in adolescence. CAE accounts for about 8-15% of all childhood epilepsies. Seizures can occur very frequently — from about 10 to over 100 times per day — and are often unnoticed by the child, family, or teachers because of their brief, subtle nature."},
        {"title": "Etiology",
         "content": "Typical absence epilepsy has a strong genetic predisposition. It should be distinguished from atypical absences, which are associated with 1- to 2-Hz spike-and-slow-wave discharges, head atonia, and myoclonus, occur in epileptic encephalopathies such as Lennox-Gastaut syndrome, and carry a poor prognosis; and from juvenile absences, which resemble typical absences but show 4- to 5-Hz spike-and-wave discharges and are often part of juvenile myoclonic epilepsy."},
        {"title": "Clinical features",
         "content": "A typical absence seizure presents as sudden staring or arrest of activity, often mid-conversation or mid-activity, with brief loss of awareness and amnesia for the episode but no loss of postural tone. Subtle associated findings can include rapid eye blinking, lip smacking, twitching of the eyelids/eyebrows/mouth, other simple motor or oroalimentary automatisms (in up to two-thirds of cases), pupillary dilation, skin-color change, tachycardia, and, uncommonly, incontinence; slumping from reduced axial tone can occur, but true falls (as in atonic seizures) do not happen in CAE and should prompt neurology referral if seen. There is no preictal or postictal period — the child resumes activity immediately. Because episodes are so brief and subtle, they are frequently missed, and children may instead present with decreased school performance, poor attention, or symptoms suggesting ADHD; an observant teacher often first raises the concern. About 35% of children with CAE may have at least one generalized tonic-clonic seizure at some point."},
        {"title": "Diagnostics",
         "content": "Hyperventilation for 3-4 minutes reliably provokes an absence seizure and is performed routinely during EEG to help confirm the diagnosis; photic stimulation can also precipitate seizures. The classic ictal EEG finding is a 3-Hz generalized spike-and-slow-wave discharge. Children with typical absence seizures have normal intelligence and a normal neurologic examination. Historical clues — a known distant brain insult, hereditary predisposition, or consanguinity — can suggest an underlying cause, and progressive loss of skills, vision, hearing, coordination, strength, or cognition should prompt evaluation for an underlying degenerative disease masquerading as epilepsy."},
        {"title": "Differential diagnosis",
         "content": "Absence seizures can be confused with focal seizures with impaired awareness, but focal seizures typically last longer (usually more than 30 seconds), are preceded by an aura, and have a slow return to awareness afterward — none of which occur with absence seizures. Atonic (akinetic) seizures, or \"drop attacks,\" are a distinct entity with sudden, complete loss of tone in the limbs, neck, and trunk without warning, sometimes preceded by myoclonic jerks, and are more common in epileptic encephalopathies such as Lennox-Gastaut syndrome; true drop attacks do not occur in CAE."},
        {"title": "Treatment",
         "content": "Ethosuximide is the treatment of choice for absence seizures; valproate and lamotrigine are alternatives. Carbamazepine should be avoided, as it can worsen absence seizures. Prognosis with treatment is excellent, with more than 90% of patients becoming seizure-free, and remission typically occurring by age 12."},
        {"title": "Complications",
         "content": "Although individual absence seizures are brief and seemingly benign, their frequent recurrence throughout the day can adversely affect learning and carries a risk of injury, since the child briefly loses awareness. Rarely, a child can present in absence status epilepticus, sitting in a confused or dreamy state that can persist for hours to days; the treatment of choice for absence status is a benzodiazepine."},
    ],
    "clinical": [
        {"title": "Recognizing absence seizures at the bedside or in clinic",
         "content": "Suspect absence seizures in a child, typically 4-12 years old, with brief (a few seconds to about 20 seconds) episodes of staring or behavioral arrest, abrupt in onset and offset, without aura or postictal confusion, sometimes with subtle eye flutter, lip smacking, or other automatisms. Because episodes are often missed by the child and family, ask specifically about frequent daydreaming, inattention, or new school performance problems, since these can be the presenting complaint. Confirm with EEG showing the classic 3-Hz generalized spike-and-slow-wave discharge; hyperventilation for 3-4 minutes is a simple office and EEG-lab maneuver that reliably provokes the seizure and supports the diagnosis. Expect a normal neurologic exam and normal intelligence in typical CAE — a finding of true falls, myoclonus, or developmental regression should instead raise concern for atypical absence or another epilepsy syndrome and prompt neurology referral."},
        {"title": "Starting and monitoring treatment",
         "content": "Start ethosuximide as first-line therapy for confirmed absence seizures; valproate or lamotrigine are reasonable alternatives. Avoid carbamazepine, which can worsen absence seizures. Counsel families that the prognosis is excellent — over 90% of children become seizure-free with treatment, with remission typically by age 12 — but that seizures can occur many times a day until controlled, which can affect learning and carries some injury risk in the interim. If a child presents in a prolonged confused or dreamy state lasting hours, consider absence status epilepticus and treat with a benzodiazepine."},
    ],
}

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/absence-seizure.article.json")
out.write_text(json.dumps(article, indent=1))
print(out)
