import json, pathlib

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

article = {
    "topic": "Asthma Exacerbation",
    "slug": "asthma-exacerbation",
    "category_id": 15151,
    "summary": "Acute worsening of airway obstruction in a child with asthma, from recognition and risk stratification through status asthmaticus, home action plans, and follow-up after discharge.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Asthma affects about 7% of American children, with significant racial, ethnic, and socioeconomic disparities, and acute exacerbations are among the leading causes of pediatric hospitalization.
- An acute exacerbation is progressive worsening of shortness of breath, cough, wheezing, and/or chest tightness; status asthmaticus is a severe exacerbation with bronchial obstruction that continues to worsen or fails to improve despite adequate standard therapy, risking respiratory fatigue and failure. "Critical asthma syndrome" is an umbrella term for acute severe asthma, refractory asthma, status asthmaticus, and near-fatal asthma.
- As many as 85% of exacerbations in school-age children coincide with viral infection, the single biggest risk factor for hospitalization; other common triggers include tobacco smoke (including secondhand), exercise, allergen exposure, cold/dry air, aspirin, aspiration, and acid reflux.
- Early warning signs include cough, chest tightness, and chest retractions or audible wheezing; hallmarks of an established attack are wheezing, respiratory distress, tachypnea, and accessory muscle use, though physical exam can be normal or show only a prolonged expiratory phase between attacks.
- Two exacerbation patterns exist: a slower, days-long pattern from progressive inflammation, epithelial sloughing, and small-airway mucus plugging (which can lead to fatigue-driven respiratory failure needing many days of mechanical ventilation), and an abrupt-onset ("asphyxial") pattern from extreme airway hyperresponsiveness, often occurring outside medical settings with very high initial arterial CO2.
- Risk factors for severe/life-threatening exacerbation: previous severe exacerbation, prior ICU admission or intubation, obesity, lower socioeconomic status, non-Caucasian race, poor controller adherence or inhaler technique, tobacco/air pollution exposure, indoor allergens, and comorbidities such as rhinosinusitis or confirmed food allergy.
- Prior severe exacerbations (respiratory distress, hypoxia, hospitalization, respiratory failure) are the best predictors of future life-threatening or fatal episodes.
- A written asthma action plan uses peak expiratory flow rate (PEFR) zones based on the child's personal best: green (over 80%), yellow (50-80%), red (under 50%) — with corresponding self-management steps, and prompt communication with the clinician for severe symptoms, a PEFR drop, or decreased response to short-acting beta-agonists (SABAs).
- Most exacerbations improve with frequent bronchodilator treatment and a course of systemic (oral or IV) corticosteroid; an SpO2 below 92% after an hour of therapy is a good predictor that hospitalization will be needed. Asthma deaths in children rarely occur in medical centers — most happen at home or in the community before care can be given — underscoring the importance of home/community management and early intervention; schedule follow-up within 1-2 weeks of hospital discharge to reinforce action plans and controller therapy."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Asthma is a chronic respiratory disease of airway inflammation and obstruction with a recurrent, reversible symptom pattern. An acute asthma exacerbation is an acute episode of progressively worsening shortness of breath, cough, wheezing, chest tightness, or a combination of these. Status asthmaticus is a severe exacerbation in which bronchial obstruction is severe and continues to worsen, or fails to improve, despite adequate standard therapy, leading to respiratory fatigue and ultimately respiratory failure. \"Critical asthma syndrome\" is used to describe any child at high risk of fatal asthma, encompassing acute severe asthma, refractory asthma, status asthmaticus, and near-fatal asthma."},
        {"title": "Epidemiology",
         "content": "Asthma is the most common chronic respiratory condition in children, affecting about 7% of American children, with significant racial, ethnic, and socioeconomic disparities. Acute exacerbations and status asthmaticus are among the leading causes of pediatric hospitalization. Unlike adults, who more often show a persistent symptom pattern, children more often show rapidly evolving, frequent, and sometimes severe exacerbations triggered by viral infection or allergen exposure, with symptom-free intervals between episodes; lung function measurements in children can appear within normal limits (e.g., an unimpaired FEV1) despite significant symptom burden, because distal airways are more affected in children, so other measures — FEV1/FVC, forced expiratory flow at 25-75%, or bronchodilator responsiveness — may better reflect severity. As many as 85% of exacerbations in school-age children coincide with a viral infection, the biggest risk factor for hospitalization in this age group."},
        {"title": "Etiology",
         "content": "Common triggers of asthma exacerbations include viral respiratory infection (especially RSV and rhinovirus, also linked to future asthma development), tobacco or wood smoke and other irritants, exercise, allergen exposure (house dust mites, pollens, cockroaches, molds, animal dander), cold/dry air or changes in weather and humidity, aspirin, aspiration, acid reflux, and strong emotion (crying, laughing). At least 80% of children with asthma have an allergic predisposition. Additional risk factors specifically for severe exacerbation include obesity, lower socioeconomic status, non-Caucasian race, a prior history of ICU admission or intubation, major psychosocial/socioeconomic stress, poor adherence to controller medication or incorrect inhaler technique, and comorbidities such as rhinosinusitis or confirmed food allergy. Asthma symptoms are more common in boys before puberty but become more severe in girls after puberty."},
        {"title": "Pathophysiology",
         "content": "Life-threatening exacerbations result from severe bronchospasm, excessive mucus secretion, airway inflammation, and airway edema. Infants and children are at particular risk of respiratory failure because of structural and mechanical features of the developing lung: less elastic recoil, thicker airway walls (increasing peripheral airway resistance for any degree of bronchoconstriction), increased airway reactivity, fewer collateral ventilation channels, and a more compliant chest wall that increases the work of breathing with airway obstruction. Two broad exacerbation patterns are recognized: one develops over days, driven by progressive inflammation, epithelial sloughing, and mucus cast impaction of small airways, which in extreme cases causes fatigue-driven respiratory failure requiring many days of mechanical ventilation; the other is abrupt in onset, related to extreme airway hyperresponsiveness and physiologic susceptibility to airway closure, is asphyxial in nature when extreme, often occurs outside medical settings, and is initially associated with a very high arterial carbon dioxide pressure."},
        {"title": "Clinical features",
         "content": "Early warning signs of an exacerbation include cough, chest tightness, and chest retractions or audible wheezing; caregivers should be taught to recognize these signs promptly. Established attacks show wheezing (high-pitched whistling on exhalation, which may or may not be present), respiratory distress, tachypnea, and use of accessory muscles, though the physical exam between attacks can be entirely normal or show only a prolonged expiratory phase. Suggestive history includes recurrent cough, wheeze, shortness of breath/rapid breathing, or chest tightness that worsens with viral infection, smoke or irritant exposure, exercise, allergens, weather changes, or strong emotion, and that occurs or worsens at night. Exacerbation patterns tend to vary between individual patients but be similar within the same patient over time; a prior severe exacerbation with respiratory distress, hypoxia, hospitalization, or respiratory failure is the best predictor of a future life-threatening or fatal episode."},
        {"title": "Differential diagnosis",
         "content": "Not all wheezing is asthma — if cough is the only symptom, or if chronic sputum production is reported, the differential diagnosis should be broadened rather than assuming asthma exacerbation."},
        {"title": "Treatment",
         "content": "Immediate management requires rapid assessment of obstruction severity and risk of further deterioration. Most exacerbations improve with frequent bronchodilator treatments and a course of systemic (oral or intravenous) corticosteroid; an SpO2 below 92% after an hour of therapy is a good predictor that hospitalization will be needed. Infrequent episodes with no exacerbation risk can be managed with as-needed salbutamol or terbutaline (oral route if inhalation is not feasible). For patients with moderate-to-severe persistent asthma or a history of severe exacerbations, a written action plan defines green/yellow/red zones by symptoms and (for those with poor symptom perception) PEFR relative to personal best — conventionally over 80% (green), 50-80% (yellow), and under 50% (red) — with corresponding self-management steps; prompt clinician communication is indicated for severe symptoms, a PEFR drop, or decreased SABA response, at which point a short course of oral corticosteroids may be added, and exposure to any contributing irritant or allergen should be removed. The most effective overall strategy is early recognition of warning signs paired with early treatment. In children, in-hospital management of severe exacerbations is usually successful, even when extreme measures are required."},
        {"title": "Complications",
         "content": "Status asthmaticus can progress to respiratory fatigue and failure, sometimes requiring many days of mechanical ventilation in the slower-onset inflammatory pattern, or presenting abruptly and asphyxially with very high initial arterial CO2 in the hyperresponsiveness-driven pattern. Notably, asthma deaths in children rarely occur in medical centers; most occur at home or in the community before lifesaving care can be administered, underscoring the importance of home and community management, early intervention, and measures to reduce overall asthma severity."},
        {"title": "Prevention",
         "content": "Assessment of exacerbation risk should be based on history — prior severe exacerbations, prior ICU admission or intubation, timing relative to the usual flare-up season, exposure to tobacco smoke or indoor/outdoor air pollution, indoor allergens, major psychosocial or socioeconomic stress, poor adherence or incorrect inhaler technique, and comorbidities like obesity, rhinosinusitis, or confirmed food allergy — with treatment intensity matched to that assessed risk. Inhaled corticosteroids are the most potent and effective medication for long-term control, and combined ICS-formoterol maintenance-and-reliever therapy is preferred in most adolescents. For exercise-induced symptoms, a short-acting beta-agonist before exercise prevents symptoms for about 2-3 hours in roughly 80% of patients. A follow-up appointment within 1-2 weeks of hospital discharge after an exacerbation should be used to monitor clinical improvement and reinforce action plans and controller medication use."},
    ],
    "clinical": [
        {"title": "Rapid assessment and initial treatment",
         "content": "On presentation with a possible exacerbation, rapidly assess the severity of obstruction and the risk of further deterioration, watching for wheezing, respiratory distress, tachypnea, and accessory muscle use, and asking about early warning signs the family may have already noticed (cough, chest tightness, retractions, audible wheeze). Start frequent bronchodilator treatments and a course of systemic (oral or intravenous) corticosteroid, which resolves most exacerbations. Track response with SpO2: a level below 92% after an hour of therapy is a good predictor that hospitalization will be needed. Remember that exacerbations can follow two patterns — a days-long course from progressive inflammation and mucus plugging, versus an abrupt, asphyxial pattern from extreme airway hyperresponsiveness with a very high initial arterial CO2 — so do not be falsely reassured by a rapid or recent onset. Identify and remove any ongoing irritant or allergen exposure contributing to the episode."},
        {"title": "Risk-based management and discharge planning",
         "content": "Identify high-risk features on history — a prior severe exacerbation, prior ICU admission or intubation, poor controller adherence or inhaler technique, ongoing tobacco/air pollution or allergen exposure, and comorbidities such as obesity, rhinosinusitis, or food allergy — since a prior severe exacerbation is the strongest predictor of a future life-threatening episode. Provide or update a written asthma action plan using PEFR zones relative to personal best (over 80% green, 50-80% yellow, under 50% red) with clear instructions for each zone and criteria for prompt clinician contact (severe symptoms, falling PEFR, or reduced SABA response). Emphasize that most pediatric asthma deaths occur at home or in the community before medical care can be reached, making early home recognition and action plan adherence critical. Schedule follow-up within 1-2 weeks of any hospital discharge to reassess control, reinforce the action plan, and review controller medication and inhaler technique."},
    ],
}

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