import json

references = [
  {"title": "Pediatric Board Study Guide", "author": None, "pages": [831]},
  {"title": "The Harriet Lane Handbook (The Johns Hopkins Hospital)", "author": None, "pages": [550]},
  {"title": "The Harriet Lane Handbook 22nd Edition (2020) (The Johns Hopkins Hospital)", "author": None, "pages": [550]},
  {"title": "Pediatric Decision-Making Strategies", "author": "Pomeranz, Albert J.", "pages": [130]},
  {"title": "Kliegman R. Nelson Textbook of Pediatrics 2-Volume Set 22ed 2024", "author": None, "pages": [3298,3299]},
  {"title": "Caring for the Hospitalized Child", "author": "Section on Hospital Medicine, American Academy of Pediatrics;Jeffrey C. Gershel;Daniel A. Rauch;", "pages": [604,606]},
  {"title": "Diagnostic Imaging: Pediatrics", "author": "A. Carlson Merrow Jr. MD", "pages": [686]},
  {"title": "Ghai Essential Pediatrics, 9e (Vinod K Paul, Arvind Bagga)", "author": "CamScanner", "pages": [485]}
]

short = [{"title": "In short", "content": """- Pyelonephritis is upper urinary tract infection with renal parenchymal involvement; without parenchymal involvement the term pyelitis applies instead. It is the most common bacterial infection in febrile infants under 24 months without an obvious source.
- Young children present atypically: vague abdominal discomfort rather than classic adult flank pain; fever may be the only sign. Consider it for a temperature ≥39°C (102.2°F) without another source lasting more than 48 hours in infants. Newborns may show only poor feeding, irritability, jaundice, or weight loss. All neonatal UTIs are considered pyelonephritis.
- Higher-risk groups: infants younger than 6 months, females, uncircumcised males, and children with obstructive urologic abnormalities or bladder/bowel dysfunction.
- On exam, pyelonephritis typically causes a high fever (≥39.4°C/103°F) with costovertebral angle tenderness on gentle percussion; obtain urinalysis and culture before starting antibiotics, via straight catheterization if the child cannot provide a clean catch.
- Significant bacteriuria in infants/children is generally defined as ≥50,000 CFU/mL of a single urinary pathogen (the transition range where pyelonephritis becomes more likely than asymptomatic bacteriuria is 10,000–100,000 CFU/mL).
- Outpatient oral therapy: cephalexin or cefadroxil if tolerating PO. Inpatient IV therapy: ceftriaxone 50 mg/kg/day (max 2 g/day) or cefotaxime 150 mg/kg/day divided q8h (max 6 g/day), since most E. coli are ampicillin-resistant; add ciprofloxacin (IV 18–30 mg/kg/day divided q8h, max 1.2 g/day, or oral 20–30 mg/kg/day divided q12h, max 1.5 g/day) if increased Pseudomonas risk; add ampicillin 100 mg/kg/day divided q6h (max 4 g/day) if Enterococcus risk or gram-positive rods on Gram stain.
- Standard treatment duration is 7 days, with up to 14 days considered if not improving after 3 days of therapy; transition to oral antibiotics once clinically improved.
- Imaging: renal ultrasound detects hydronephrosis/anatomic anomalies and can be done even during UTI treatment; micturating cystourethrogram (VCUG) for VUR diagnosis/grading is done 2–4 weeks after UTI treatment; DMSA scan for renal scarring is done 3–4 months after treatment to distinguish permanent scars from reversible acute changes.
- Recurrent or unusual pyelonephritis with a renal mass, weight loss, and minimal urinary symptoms should raise concern for xanthogranulomatous pyelonephritis, associated with renal calculi, obstruction, and Proteus or E. coli infection, which usually requires total or partial nephrectomy."""}]

long = [
 {"title": "Definition", "content": """Urinary tract infections are divided by anatomic level into lower tract infection (cystitis) and upper tract infection (pyelonephritis); distinguishing the two, especially in children under 2 years, is often clinically difficult. Pyelonephritis with involvement of the renal parenchyma is termed acute pyelonephritis; when there is no parenchymal involvement, the term pyelitis is used instead. Acute pyelonephritis can cause renal injury known as pyelonephritic scarring. In neonates, any UTI is considered pyelonephritis by convention, reflecting the higher risk of upper-tract and systemic involvement at this age."""},
 {"title": "Epidemiology", "content": """Pyelonephritis is the most common bacterial infection identified in infants younger than 24 months who present with fever without an obvious source. Patients at higher risk for pyelonephritis (as opposed to isolated cystitis) include infants younger than 6 months, females, uncircumcised males, and children with underlying obstructive urologic abnormalities or bladder and bowel dysfunction."""},
 {"title": "Clinical features", "content": """Classic features include abdominal, back, or flank pain, fever, malaise, nausea, vomiting, and occasionally diarrhea, but presentation varies markedly with age. Young children are far more likely to present with vague abdominal discomfort than the flank pain and costovertebral angle tenderness typical of adults, and fever may be the only manifestation — a temperature of 39°C (102.2°F) or higher without another identifiable source, persisting beyond 48 hours in an infant, should prompt consideration of pyelonephritis. Newborns often show only nonspecific signs: poor feeding, irritability, jaundice, or weight loss. On examination, pyelonephritis typically produces a high fever (≥39.4°C/103°F); costovertebral angle tenderness on gentle percussion is a supportive sign, while an abdominal or flank mass raises concern for an obstructive process or, rarely, xanthogranulomatous pyelonephritis (a chronic granulomatous process with giant cells and foamy histiocytes that can present as a renal mass with fever, flank pain, weight loss, and malaise but comparatively little dysuria, usually related to calculi, obstruction, or Proteus/E. coli infection, and typically requiring nephrectomy)."""},
 {"title": "Diagnostics", "content": """Obtain a urinalysis and urine culture before starting antibiotics; in a child too young to provide a reliable clean-catch specimen, collect urine via straight catheterization. Significant bacteriuria in infants and children is generally defined as at least 50,000 CFU/mL of a single urinary pathogen, with a transition zone of 10,000–100,000 CFU/mL where the likelihood of true pyelonephritis versus asymptomatic bacteriuria increases. Imaging is used selectively and sequenced to limit radiation exposure: renal ultrasonography detects hydronephrosis or bladder/urinary tract anomalies and can be performed even during acute treatment; a micturating cystourethrogram (VCUG) is used to diagnose and grade vesicoureteral reflux and define bladder/urethral anatomy, typically performed 2–4 weeks after UTI treatment; DMSA scintigraphy detects cortical renal scarring (regions of decreased uptake with loss of contour or cortical thinning) and is deferred 3–4 months after treatment specifically to distinguish permanent scarring from reversible acute pyelonephritic changes. On CT, pyelonephritis appears as foci of diminished cortical enhancement; on ultrasound, altered cortical echogenicity with adjacent perinephric fluid may be seen."""},
 {"title": "Treatment", "content": """For outpatient management in a child tolerating oral intake, cephalexin or cefadroxil is appropriate. For inpatient management, start intravenous antibiotics: ceftriaxone 50 mg/kg/day (maximum 2 g/day) or cefotaxime 150 mg/kg/day divided every 8 hours (maximum 6 g/day), since most E. coli are resistant to ampicillin. If there is increased risk for Pseudomonas (prior Pseudomonas UTI, chronic indwelling catheter, neurogenic bladder), use IV ciprofloxacin 18–30 mg/kg/day divided every 8 hours (maximum 1.2 g/day) or oral ciprofloxacin 20–30 mg/kg/day divided every 12 hours (maximum 1.5 g/day). If there is a risk factor for Enterococcus (genitourinary instrumentation, renal anomaly) or gram-positive rods are seen on Gram stain, add empiric ampicillin 100 mg/kg/day divided every 6 hours (maximum 4 g/day). If Staphylococcus aureus grows from urine culture, consider hematogenous spread as the source rather than an ascending UTI. Standard treatment duration is 7 days, with extension up to 14 days considered if the patient has not improved after 3 days of therapy; transition to oral antibiotics once the patient is clinically improving."""}
]

clinical = [
 {"title": "Management at the bedside", "content": """Assess vital signs (including temperature and blood pressure) and weight, examine the abdomen for tenderness or a mass, gently percuss the costovertebral angle for tenderness, and examine the external genitalia for anatomic anomalies or irritation. Obtain a urinalysis and culture before giving any antibiotic — use straight catheterization if the child cannot give a reliable clean-catch sample — and treat bacteriuria of at least 50,000 CFU/mL of a single pathogen as significant.

Choose therapy by clinical severity and risk factors. If the child tolerates oral intake and has no complicating risk factors, treat with oral cephalexin or cefadroxil. If the child needs inpatient IV therapy, start ceftriaxone 50 mg/kg/day (max 2 g/day) or cefotaxime 150 mg/kg/day divided every 8 hours (max 6 g/day) — do not rely on ampicillin alone given high rates of E. coli resistance. Add IV ciprofloxacin 18–30 mg/kg/day divided q8h (max 1.2 g/day) for Pseudomonas risk (prior Pseudomonas UTI, chronic catheter, neurogenic bladder), and add ampicillin 100 mg/kg/day divided q6h (max 4 g/day) empirically if there is an Enterococcus risk factor (GU instrumentation, renal anomaly) or gram-positive rods on Gram stain. Treat for 7 days total, extending to as long as 14 days if the child has not improved by day 3, and switch to oral therapy once clinically improving.

Sequence follow-up imaging to answer specific questions while minimizing radiation: get a renal ultrasound (even during acute treatment) to look for hydronephrosis or structural anomalies; if reflux is a concern, obtain a VCUG 2–4 weeks after treatment completes; if scarring is a concern, obtain a DMSA scan 3–4 months after treatment (not sooner, to avoid mistaking reversible acute changes for permanent scarring). If a child instead presents with a renal mass, weight loss, and minimal urinary symptoms, consider xanthogranulomatous pyelonephritis and involve urology, since this typically requires nephrectomy rather than antibiotics alone."""}
]

article = {
 "topic": "Pyelonephritis",
 "slug": "pyelonephritis",
 "category_id": 15215,
 "summary": "Recognizing atypical pediatric presentations of pyelonephritis, diagnostic thresholds, empiric antibiotic regimens with doses, and the correct timing of follow-up imaging.",
 "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/pyelo.article.json", "w") as f:
    json.dump(article, f, indent=1)
print("done")
