import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from lib import build_and_save

references = [
 {"title": "CURRENT Diagnosis and Treatment Pediatrics, Twenty-Fourth Edition", "author": "Hay, William W., Levin, Myron J., Deterding, Robin R., Abzug, Mark J.", "pages": [489, 810, 811]},
 {"title": "Berkowitz's Pediatrics", "author": "Berkowitz, Carol D.;", "pages": [588]},
 {"title": "2021_Fleisher_&_Ludwig's_Textbook_of_Pediatric_Emergency_Medicine.epub", "author": None, "pages": []},
 {"title": "Kliegman R. Nelson Textbook of Pediatrics 2-Volume Set 22ed 2024", "author": None, "pages": [3820]},
 {"title": "Netters Pediatrics (Florin Т., Ludwig St.)", "author": None, "pages": [88]},
 {"title": "Cover", "author": "Vitalsource Download", "pages": [1443, 9107]},
 {"title": "Signs and Symptoms in Pediatrics", "author": "Henry M. Adam,Jane Meschan Foy", "pages": [727]},
 {"title": "Pediatric Decision-Making Strategies", "author": "Pomeranz, Albert J.", "pages": [150]},
]

short_md = """## In short

- Idiopathic intracranial hypertension (IIH, formerly pseudotumor cerebri) is increased intracranial pressure with normal brain parenchyma, normal CSF constituents, and normal neuroimaging (MRI/MRV), without another identifiable cause.
- Overall prevalence is about 1-2 per 100,000, but roughly 20 times higher in adolescent girls with obesity; in adults, it is classically seen in obese women of reproductive age (15-45 years), while in prepubertal children, sex and weight are not prominent risk factors.
- Essential diagnostic features: signs/symptoms of raised ICP (chronic/progressive headache, tinnitus, cranial nerve VI palsy, papilledema, visual loss), normal MRI/MRV of the head, and elevated opening pressure on lumbar puncture performed in the lateral decubitus position.
- Additional symptoms can include visual obscurations (brief episodes of blindness), photopsia (light flashes), retrobulbar pain, and diplopia; papilledema is the hallmark sign, though not every patient with elevated ICP develops it (optic nerve atrophy or anatomic variation in the optic canal may prevent swelling even with severe ICP elevation).
- Medications and conditions associated with IIH include high-dose vitamin A/retinoids, tetracycline or doxycycline, growth hormone, oral contraceptives, and withdrawal of steroid therapy; venous sinus thrombosis from a clotting disorder or complicated otitis media/mastoiditis produces a similar physiology and must be excluded.
- Pathogenesis remains poorly understood, especially in children; obesity is the most commonly identified risk factor.
- A false-positive diagnosis of IIH is common in children with headache and papilledema who have a normal standard brain MRI - strategies to avoid misdiagnosis are needed, and mass lesions (optic glioma, craniopharyngioma) must be excluded as alternative causes of visual field loss and papilledema-like presentations.
- Initial treatment goals, beyond pain relief, are directed at preventing neurologic (especially visual) sequelae; most children can be managed as outpatients, with admission reserved for those needing continued parenteral therapy.
- Visual loss and visual field defects in IIH can be reversed with appropriate therapy, underscoring the importance of prompt recognition and follow-up ophthalmologic assessment.
"""

long_md = """## Definition

Idiopathic intracranial hypertension (IIH), formerly called pseudotumor cerebri or benign intracranial hypertension, is a poorly understood primary cause of increased intracranial pressure occurring in the presence of normal brain parenchyma, normal cerebrospinal fluid constituents, and normal neuroimaging. It is characterized by increased intracranial pressure with the absence of neurologic signs except, sometimes, a cranial nerve VI (abducens) palsy, and often without a discernible underlying cause.

## Epidemiology

Overall prevalence is about 1-2 per 100,000, but roughly 20 times higher in adolescent girls with obesity. In adults, IIH is classically seen in obese females of reproductive age (commonly cited as 15-45 years). In children, IIH is often divided into prepubertal and pubertal groups, since sex and body weight are not prominent risk factors in prepubertal patients, unlike the pattern seen in adolescents and adults.

## Etiology

The pathogenesis of IIH remains essentially unknown, and this is particularly true in children. Obesity is the most commonly identified risk factor. IIH often occurs spontaneously, but has also been associated with high doses of vitamin A (retinol/retinoic acid), tetracycline or doxycycline, growth hormone, oral contraceptives, and withdrawal of steroid therapy. A similar clinical physiology of increased intracranial pressure can be produced by venous sinus thrombosis, whether from an underlying clotting diathesis or as a complication of otitis media or mastoiditis, and this must be distinguished from true IIH.

## Pathophysiology

The exact mechanism of papilledema development in IIH is not completely understood. It is speculated that transmission of elevated intracranial pressure to the optic nerve sheath causes axoplasmic flow stasis, producing papilledema. Not every patient with elevated intracranial pressure develops papilledema: anatomic variation in the optic canal may be protective in some individuals, and optic nerves that are already atrophic may fail to swell even with severely elevated pressure.

## Clinical Features

Symptoms and signs reflect increased intracranial pressure: chronic or progressive headache, tinnitus, cranial nerve VI palsy, papilledema, and visual loss or visual field defects, as well as visual obscurations (brief episodes of blindness), photopsia (light flashes), retrobulbar pain, and diplopia. Visual loss and visual field defects associated with IIH can be reversed with appropriate treatment. While papilledema is very commonly seen, some children present without it.

## Diagnostics

Diagnosis requires signs/symptoms of raised intracranial pressure, a normal MRI/MRV of the head, and an elevated opening pressure on lumbar puncture performed in the lateral decubitus position. IIH is frequently considered as a potential explanation for headache with papilledema in a child with normal standard brain MRI findings, but false-positive diagnosis is common in this setting, and deliberate strategies are needed to avoid over-diagnosing IIH. Alternative structural causes of raised pressure and visual field loss must be actively excluded, particularly a neoplastic lesion compressing the optic nerve such as an optic glioma (which can occur anywhere along the optic nerves, chiasm, or optic tract, tends to be slow growing, and presents with proptosis, unilateral or bilateral visual loss, strabismus, optic atrophy, or nystagmus) or a craniopharyngioma (which often presents with nonspecific headache or progressive visual loss, sometimes with endocrine abnormalities from pituitary dysfunction).

## Differential Diagnosis

Because elevated intracranial pressure and papilledema have many possible causes, the differential for a child presenting this way includes mass lesions (hemorrhage, tumor, abscess), hydrocephalus, cerebral edema (from trauma, infection, hepatic encephalopathy, inborn errors of metabolism, status epilepticus, stroke, or tumor), and venous sinus thrombosis - all of which should be excluded by neuroimaging (normal in true IIH) before attributing the presentation to idiopathic disease.

## Treatment

Beyond pain relief, initial treatment of IIH is directed at preventing neurologic sequelae, chiefly permanent visual loss. Most children with IIH, as with pediatric migraine, can be managed successfully as outpatients; admission is reserved for those requiring continued parenteral therapy to control symptoms, and children with chronic or recurrent symptoms needing prophylactic treatment should be referred to a neurologist.

## Complications

Untreated or inadequately treated IIH carries risk of permanent visual loss from sustained papilledema and optic nerve compromise, which is why prevention of neurologic (particularly visual) sequelae is the central treatment goal alongside symptomatic pain control.
"""

clinical_md = """## Evaluating Suspected IIH

In a child or adolescent with chronic or progressive headache, particularly with visual symptoms (obscurations, photopsia, diplopia), tinnitus, or a cranial nerve VI palsy, examine for papilledema and obtain MRI/MRV of the head before proceeding to lumbar puncture, since IIH is a diagnosis of exclusion requiring normal neuroimaging. Actively rule out structural causes - mass lesion, hydrocephalus, optic glioma, craniopharyngioma, or venous sinus thrombosis (especially with a history of clotting risk, or complicated otitis media/mastoiditis) - since papilledema and raised pressure from these causes can be mistaken for IIH, and false-positive IIH diagnosis is common when this step is skipped. Once neuroimaging is normal, confirm with an elevated opening pressure on lumbar puncture performed in the lateral decubitus position. Take a directed medication and exposure history: recent high-dose vitamin A/retinoid use, tetracycline or doxycycline (common in adolescents being treated for acne), growth hormone therapy, oral contraceptive use, or recent steroid withdrawal are all recognized associations. Remember that prepubertal children with IIH do not show the same female-and-obesity risk pattern seen in adolescents and adults, so do not use the absence of obesity to lower suspicion in a younger child.

## Managing and Following IIH

Direct initial treatment at both symptomatic pain relief and, more importantly, prevention of visual loss, since reversible visual deficits can become permanent without timely intervention - arrange prompt ophthalmologic assessment of papilledema and visual fields. Most children can be managed as outpatients; reserve admission for those needing continued parenteral therapy to control symptoms. Refer to neurology for any child with chronic or recurrent symptoms requiring prophylactic treatment, and arrange close follow-up of visual function given the reversible-but-time-sensitive nature of IIH-associated visual loss.
"""

build_and_save(
    topic="Idiopathic Intracranial Hypertension",
    slug="idiopathic-intracranial-hypertension",
    category_id=15269,
    summary="Pediatric IIH/pseudotumor cerebri: the normal-imaging-plus-elevated-opening-pressure diagnostic criteria, why false-positive diagnosis is common, medication/obesity associations, and the vision-preservation treatment goal.",
    references=references,
    short_md=short_md,
    long_md=long_md,
    clinical_md=clinical_md,
)
