import json

references = [
  {"title": "Cover", "author": "Vitalsource Download", "pages": [1593]},
  {"title": "2021_Fleisher_&_Ludwig's_Textbook_of_Pediatric_Emergency_Medicine.epub", "author": None, "pages": []},
  {"title": "Pediatric Board Study Guide", "author": None, "pages": [206]},
  {"title": "Algorithms in Pediatrics", "author": None, "pages": [348,732]},
  {"title": "Pediatric Clinical Practice Guidelines & Policies, 18th Edition", "author": "American Academy of Pediatrics", "pages": [137]},
  {"title": "Berkowitz's Pediatrics", "author": "Berkowitz, Carol D.;", "pages": [101]},
  {"title": "Pediatric Clinical Practice Guidelines and Policies", "author": "American Academy of Pediatrics (AAP);", "pages": [187]},
  {"title": "Kliegman R. Nelson Textbook of Pediatrics 2-Volume Set 22ed 2024", "author": None, "pages": [2037,2572,2623]}
]

short = [{"title": "In short", "content": """- Children average 5–10 upper respiratory infections (URIs) per year, especially under age 2; frequency is even higher in children with chronic illness or in day care.
- Typical viral URI: clear, nonpurulent nasal discharge, cough, and initial fever, usually resolving within 10–14 days; about 10% of children still have symptoms at day 14. Nasal sampling studies found new viruses present in 29% of prolonged "sinusitis" episodes, suggesting back-to-back URIs — not a single unresolving infection — explain many persistent cases.
- Differential for URI-like symptoms includes allergic rhinitis (look for nasal eosinophilia, often seasonal), nonallergic rhinitis, and nasal foreign body — not just viral infection.
- A quality metric (HEDIS-style) specifically tracks appropriate URI treatment: the percentage of children ages 3 months–18 years diagnosed with URI who were NOT dispensed an antibiotic prescription (relevant diagnosis codes: J00 acute nasopharyngitis, J06.0 acute laryngopharyngitis, J06.9 acute URI).
- Red flags that should prompt reconsidering "just a URI": a child on day 9 of a URI developing new fever, worsening nighttime cough, and increased sinus drainage suggests secondary bacterial sinusitis rather than ongoing viral illness.
- URI-mimicking upper airway infections to distinguish by history/exam: croup (barky cough, inspiratory stridor, fever), epiglottitis (toxic appearance, dysphagia, drooling, stridor), peritonsillar abscess (trismus, muffled voice, uvular deviation), and retropharyngeal abscess (neck stiffness/pain with extension, torticollis, drooling) — some can progress to airway-threatening complications like Lemierre syndrome.
- RSV incubation period is about 3–5 days; infected infants with lower respiratory illness typically shed virus for 1–2 weeks after hospital admission (occasionally 3+ weeks); RSV is usually introduced into a household by a school-age child, and within days 25–50% of older siblings/parents develop URIs while the infant develops more severe illness (fever, otitis media, or lower respiratory disease).
- Active URI symptoms at the time of scheduled surgery raise real perioperative risk: studies show increased risk of laryngospasm, bronchospasm, arterial oxygen desaturation, and postextubation stridor in children with an active URI undergoing anesthesia.
- Croup is a clinical diagnosis; routine imaging is not warranted (a steeple sign on neck x-ray may be absent even with disease), and viral testing should only be obtained if the result would change management, since testing itself can agitate the child and worsen airway obstruction."""}]

long = [
 {"title": "Definition", "content": """Upper respiratory infection (URI) refers to infection of the nasal passages, pharynx, and related structures, distinct from lower respiratory tract disease (bronchiolitis, bronchitis, pneumonia). URIs are extremely common in children, averaging 5–10 episodes per year, with the highest frequency in children under age 2; prevalence is further increased in children with chronic illness and those attending day care. Diagnosis codes commonly used include acute nasopharyngitis (J00), acute laryngopharyngitis (J06.0), and acute URI, unspecified (J06.9)."""},
 {"title": "Etiology", "content": """Most URIs are viral. RSV is a well-characterized example: its incubation period is approximately 3–5 days, and viral shedding duration varies with illness severity and immune status — infants hospitalized with lower respiratory tract illness typically shed virus for 1–2 weeks after admission, occasionally 3 weeks or longer. RSV is usually introduced into a household by a school-age child experiencing reinfection; within days, 25–50% of older siblings and one or both parents typically develop URI symptoms themselves, while the exposed infant is more likely to develop severe disease — fever, otitis media, or lower respiratory tract involvement."""},
 {"title": "Clinical features", "content": """A typical viral URI produces clear, nonpurulent nasal discharge, cough, and an initial fever, with symptoms usually resolving within 10–14 days; roughly 10% of children still have some symptoms at the 14-day mark. Associated findings can include mild conjunctivitis, otitis media, and pharyngitis. When symptoms are genuinely persistent beyond the expected window, this often reflects a new, sequential URI rather than a single unresolved infection — nasal sampling studies have identified a newly acquired virus in 29% of episodes initially labeled as prolonged sinusitis. A change in the character of illness partway through a presumed URI course is an important clinical clue: new fever, worsening nighttime cough, and increased sinus drainage emerging around day 9 of a URI should raise concern for secondary bacterial sinusitis rather than ongoing viral illness."""},
 {"title": "Differential diagnosis", "content": """Nonspecific URI symptoms overlap with several other conditions that require different management: allergic rhinitis (which can be seasonal and shows significant eosinophilia on nasal secretion exam), nonallergic rhinitis, and nasal foreign body should all be considered, particularly with unilateral or unusually persistent symptoms. More urgent upper airway infections can mimic or coexist with URI and must be actively distinguished by age, history, and oropharyngeal exam: croup presents with URI symptoms plus a barky cough, fever, and inspiratory stridor; epiglottitis presents with toxic appearance, fever, dysphagia, drooling, and inspiratory stridor; peritonsillar abscess presents with fever, sore throat, trismus, dysphagia, drooling, voice change, and uvular displacement; and retropharyngeal abscess presents with fever, dysphagia, drooling, voice change, and neck stiffness or pain with extension, often with torticollis. While most upper airway infections are relatively benign (e.g., simple pharyngitis), some can progress to life-threatening complications such as Lemierre syndrome, so red-flag features warrant escalation rather than reassurance. Airway instrumentation in a child with suspected epiglottitis should be performed in the controlled setting of the operating room rather than at the bedside."""},
 {"title": "Treatment", "content": """Uncomplicated viral URI is managed supportively; antibiotics are not indicated and their avoidance is tracked as a formal quality measure — the percentage of children ages 3 months to 18 years diagnosed with URI who are NOT dispensed an antibiotic prescription on or within 3 days of the diagnosis. Croup, one of the conditions in the URI-mimicker differential, is itself a clinical diagnosis: routine neck imaging is not warranted (a subglottic "steeple sign" may be absent even in true croup), and viral testing (e.g., for influenza or SARS-CoV-2) should be obtained only when the result would actually change management, since the testing process itself can agitate the child and worsen airway obstruction and respiratory distress. Croup severity should instead be assessed clinically: mild disease shows normal respiratory effort; moderate disease shows stridor at rest that worsens with agitation, plus mild-to-moderate retractions and decreased aeration; severe disease/impending respiratory failure shows agitation, decreased mental status, continuous stridor, severe retractions, markedly decreased aeration, and cyanosis or hypoxemia."""}
]

clinical = [
 {"title": "Practical management points", "content": """When a child presents with a straightforward URI, manage supportively and do not prescribe antibiotics — this is the correct, guideline-concordant, and quality-tracked approach for isolated acute nasopharyngitis/laryngopharyngitis/URI. Educate families that typical symptoms last 10–14 days, and that persistence beyond this window more often reflects a new sequential viral infection than ongoing treatment failure of the first one.

Watch specifically for the clinical pattern that suggests secondary bacterial sinusitis rather than uncomplicated URI: new fever, worsening nighttime cough, and increased sinus drainage emerging around day 9 of an apparent URI course warrants reassessment and consideration of bacterial sinusitis rather than reassurance that "it's just a cold." Distinguish URI from its more dangerous mimics using history and oropharyngeal exam rather than reflexive imaging or labs: a barky cough with inspiratory stridor points to croup (a clinical diagnosis — skip routine imaging and only test for a specific virus if the result will change management, since testing can agitate the child and worsen obstruction); toxic appearance with drooling and dysphagia points to epiglottitis (manage the airway in the OR, not at bedside); trismus with uvular deviation points to peritonsillar abscess; and neck stiffness with torticollis points to retropharyngeal abscess — both abscess presentations need urgent ENT involvement given their potential to progress to airway compromise or spread to contiguous neck structures.

Before elective surgery, actively ask about current or recent URI symptoms: an active URI meaningfully raises perioperative risk of laryngospasm, bronchospasm, oxygen desaturation, and postextubation stridor, so this history should factor into the anesthesia team's decision about proceeding with or postponing a scheduled procedure."""}
]

article = {
 "topic": "Upper Respiratory Infection",
 "slug": "upper-respiratory-infection",
 "category_id": 15338,
 "summary": "The expected course of a typical pediatric URI, red flags for secondary bacterial sinusitis, distinguishing URI from dangerous upper-airway mimics, and perioperative risk.",
 "written_by": "claude-sonnet",
 "references": references,
 "short": short,
 "long": long,
 "clinical": clinical
}
with open("/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/articles/uri.article.json", "w") as f:
    json.dump(article, f, indent=1)
print("done")
