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

references = [
 {"title": "Cover", "author": "Vitalsource Download", "pages": [7690]},
 {"title": "Pediatric Pulmonology", "author": "American Academy of Pediatrics Section on Pediatric Pulmonology and Sleep Medicine;Michael J Light;Kristin Van Hook;", "pages": [797]},
 {"title": "Signs and Symptoms in Pediatrics", "author": "Henry M. Adam,Jane Meschan Foy", "pages": [265]},
 {"title": "MedStudy Pediatrics Core 11th Edition 2024-2025", "author": None, "pages": [402, 677]},
 {"title": "Pediatric Asthma: a Clinical Support Chart", "author": "American Academy of Pediatrics (AAP);", "pages": [3, 40]},
 {"title": "CURRENT Diagnosis and Treatment Pediatrics, Twenty-Fourth Edition", "author": "Hay, William W., Levin, Myron J., Deterding, Robin R., Abzug, Mark J.", "pages": [1157, 1174]},
 {"title": "Your Childs Allergies and Asthma. The American Academy of Pediatrics Guide to Breathing Easy and Bringing up Healthy, Active... (American Academy of Pediatrics.Welch etc.).epub", "author": None, "pages": []},
 {"title": "Zitelli and Davis' Atlas of Pediatric Physical Diagnosis: Expert Consult - Online", "author": None, "pages": [143]},
]

short_md = """## In short

- Exercise-induced bronchoconstriction (EIB, also called exercise-induced asthma) is transient airway narrowing triggered by exertion, affecting an estimated 40-90% of children and adolescents with asthma, and about 80% of people with asthma overall report wheeze, cough, or chest tightness with exercise.
- Symptoms typically begin during or within minutes after stopping vigorous activity, peak about 5-10 minutes after stopping, and usually resolve over the following 20-30 minutes (one source cites gradual resolution over 30-60 minutes).
- The underlying mechanism is not fully understood; one proposed mechanism is that rapid breathing of large volumes of irritant, cold, dry air dries the airway mucosa during exercise.
- The gold-standard diagnostic test is a standardized exercise challenge, not a methacholine challenge test (MCT) - EIB cannot be diagnosed by MCT, and a negative methacholine response does not exclude it; avoid vigorous exercise for at least 4 hours before testing since prior exercise has a protective (refractory) effect.
- EIB is defined by a 15% or greater fall in FEV1 from the pre-exercise baseline at a postexercise interval, measured on a motor-driven treadmill or electromagnetically braked cycle ergometer.
- History alone can both underdiagnose and overdiagnose EIB; other causes of exercise-induced dyspnea to rule out include vocal cord dysfunction, exercise-induced laryngomalacia, exercise-induced hyperventilation, restrictive chest wall disease (scoliosis, pectus deformities), exercise-induced anaphylaxis or reflux, and cardiac arrhythmias occurring only with exertion.
- Poor exercise endurance or bronchospasm during usual play can indicate poorly controlled persistent asthma and warrants starting or stepping up long-term controller therapy; if EIB is the only manifestation in an otherwise well-controlled child, pre-exercise treatment alone is usually effective.
- SABAs and leukotriene modifiers are used for pre-exercise treatment; physical activity should be encouraged in children with asthma, with activity choice modified as needed based on severity and other triggers such as cold air.
- Roughly 80% of children with asthma have an allergic predisposition, and up to 85% of exacerbations in school-age children coincide with viral infection, the biggest risk factor for hospitalization - context relevant since exercise is one of several common asthma triggers alongside viral infection, allergen exposure, cold/dry air, and irritants.
"""

long_md = """## Definition

Exercise-induced bronchoconstriction (EIB), also called exercise-induced asthma or exercise-induced bronchospasm, is a transient narrowing of the airways triggered by physical exertion. It affects an estimated 40-90% of children and adolescents who have asthma, and about 80% of people with asthma report wheezing, coughing, or chest tightness during exercise. Left unaddressed, it limits participation in daily activities for as many as 30% of affected children.

## Epidemiology

Asthma itself is the most common chronic respiratory condition in children, affecting an estimated 7.1 million children and adolescents in the US, causing more hospitalizations than any other pediatric medical condition, with onset before age 5 in about 80% of affected children. Exercise ranks alongside viral infection and allergen exposure as one of the most prominent asthma triggers. As many as 85% of asthma exacerbations in school-age children coincide with a viral infection, the single biggest risk factor for hospitalization, providing important context for how exercise interacts with other common triggers (cigarette smoke, cold/dry air, allergen exposure, aspirin, and gastroesophageal reflux).

## Pathophysiology

The precise mechanism underlying EIB/EIA is not fully understood. One proposed explanation is that during vigorous exercise, a child breathes more rapidly and deeply, drawing a large volume of relatively cold, dry, irritating air through the airways, which dries the airway mucous membranes and triggers bronchoconstriction.

## Clinical Features

Symptoms typically begin during exercise or within minutes of stopping vigorous activity, reach peak severity about 5-10 minutes after stopping, and then resolve over the following 20-30 minutes (some sources describe a broader 30-60 minute resolution window); in some children symptoms begin just a few minutes into exercise rather than afterward. In children being formally evaluated for exercise-induced dyspnea, a range of alternative or overlapping diagnoses can be found on treadmill testing with physiologic monitoring, including exercise-induced bronchospasm, vocal cord dysfunction, exercise-induced laryngomalacia, exercise-induced hyperventilation, restrictive chest wall limitation, exercise-induced supraventricular tachycardia, and normal physiologic exertional limitation without any underlying abnormality.

## Diagnostics

The optimal diagnostic approach is a standardized exercise challenge test, since EIB cannot be diagnosed using a methacholine challenge test (MCT), and a negative methacholine response does not exclude EIB. Vigorous exercise should be avoided for at least 4 hours before testing, because preceding exercise has a protective (refractory) effect on the subsequent bronchoconstrictive response. Preferred exercise modes are a motor-driven treadmill with adjustable speed and grade, or an electromagnetically braked cycle ergometer. EIB is identified by plotting FEV1 as a percentage of the pre-exercise baseline at each post-exercise time interval; a fall of 15% or more from baseline is an accepted diagnostic threshold. Because history alone can lead to both underdiagnosis and overdiagnosis of EIB, objective testing (and ruling out other origins) is important; a complete family history, including asthma or atopy in relatives, should also be obtained.

## Differential Diagnosis

When exercise-induced dyspnea is severe, occurs after only minimal exertion, or is troublesome, asthma/EIB is the most common pathologic cause, but other causes must be considered - particularly when other asthma signs/symptoms are absent or when beta-agonist pretreatment fails to prevent symptoms. Alternatives include vocal cord dysfunction, exercise-induced laryngomalacia, exercise-induced hyperventilation, restrictive airway limitation from skeletal abnormalities (scoliosis, pectus deformities), exercise-induced anaphylaxis, exercise-induced reflux, central airway obstruction, cardiac arrhythmias occurring only during exercise, and pulmonary or cardiac shunt.

## Treatment

Exercise-induced bronchospasm should be anticipated in all children with asthma; it typically occurs during or in the minutes following vigorous activity, peaks 5-10 minutes after stopping, and usually resolves over 20-30 minutes. Physical activity should still be encouraged in children with asthma, with the specific activity modified as needed based on asthma severity, the presence of other triggers such as cold air, and rarely other confounding factors. Poor exercise endurance or bronchospasm occurring during usual play can be a sign of poorly controlled persistent asthma, and this pattern should prompt initiation or step-up of long-term controller therapy rather than only symptomatic treatment. For children whose asthma is otherwise well controlled but who have exercise-induced bronchospasm as their only manifestation, treatment given immediately before vigorous activity - short-acting beta-agonists (SABAs) or leukotriene modifiers - is usually effective.
"""

clinical_md = """## Evaluating Exercise-Induced Symptoms

When a child reports cough, wheeze, or chest tightness with exercise, first determine whether beta-agonist pretreatment controls the symptoms and whether other asthma features are present; if so, EIB is likely and formal exercise challenge testing is not always necessary. If symptoms are severe, occur with only minimal exertion, or persist despite beta-agonist pretreatment, pursue further evaluation rather than assuming asthma - consider vocal cord dysfunction, exercise-induced laryngomalacia, exercise-induced hyperventilation, restrictive chest wall disease, exercise-induced arrhythmia, exercise-induced anaphylaxis or reflux, and cardiac shunt lesions. When objective confirmation is needed, arrange a standardized exercise challenge (treadmill or cycle ergometer) rather than a methacholine challenge, since MCT cannot diagnose or exclude EIB; instruct the child to avoid vigorous exercise for at least 4 hours beforehand to avoid a falsely negative result from the exercise refractory period. A drop in FEV1 of 15% or more from pre-exercise baseline at a postexercise interval confirms the diagnosis.

## Managing EIB and Encouraging Activity

Do not restrict physical activity in children with asthma - encourage participation and instead adjust the specific activity or environment (for example, avoiding very cold, dry air) as needed based on asthma severity. Distinguish between two clinical patterns: bronchospasm or poor endurance appearing during ordinary play, which signals poorly controlled persistent asthma and calls for starting or stepping up daily controller therapy; versus exercise-induced bronchospasm as the sole manifestation in an otherwise well-controlled child, for which pre-exercise treatment with a SABA or a leukotriene modifier taken shortly before vigorous activity is usually sufficient. Symptoms typically peak 5-10 minutes after stopping exercise and resolve over the next 20-30 minutes, which is useful to set expectations with families and coaches about timing around practices and competitions.
"""

build_and_save(
    topic="Exercise-Induced Asthma",
    slug="exercise-induced-asthma",
    category_id=15885,
    summary="Exercise-induced bronchoconstriction: the exercise-challenge (not methacholine) diagnostic pathway, the 15% FEV1 drop criterion, mimicking conditions, and pre-exercise versus controller-step-up treatment decisions.",
    references=references,
    short_md=short_md,
    long_md=long_md,
    clinical_md=clinical_md,
)
