import json, pathlib

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

article = {
    "topic": "Group B Streptococcal Infection",
    "slug": "group-b-streptococcal-infection",
    "category_id": 15118,
    "summary": "Streptococcus agalactiae infection in neonates and young infants, its early- and late-onset patterns, maternal screening/prophylaxis, and the significant risk of neurodevelopmental impairment after meningitis.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Group B Streptococcus (GBS, Streptococcus agalactiae) is a gram-positive, aerobic diplococcus producing a narrow zone of beta-hemolysis on blood agar, and has been a common cause of invasive infection in neonates and young infants for decades.
- GBS colonizes the human GI and genitourinary tracts (and less often the pharynx); colonization rates in pregnant women range from 15-35%, and asymptomatic maternal vaginal/anorectal colonization is the source of most infant infections.
- Early-onset disease (EOD) usually occurs within the first 24 hours of life (range 0-6 days, most within 1 hour of delivery), presenting with respiratory distress, apnea, shock, pneumonia (chest x-ray can resemble hyaline membrane disease), and, less often, meningitis (5-10% of cases); it can progress to rapidly overwhelming sepsis.
- Late-onset disease (LOD) typically occurs at 3-4 weeks of age (range 7-89 days), commonly presenting as occult bacteremia or meningitis (about 30% of cases), with osteomyelitis, septic arthritis, necrotizing fasciitis, pneumonia, adenitis, and cellulitis occurring less often; cases beyond 90 days of age are rare.
- Universal culture-based screening of pregnant women plus intrapartum antibiotic prophylaxis for GBS-colonized mothers has reduced early-onset GBS neonatal infection incidence by 85% in the US — but this strategy has only significantly reduced early-onset, not late-onset, disease.
- GBS is classified into 10 capsular polysaccharide types; types Ia, Ib, II, III, and V account for about 95-98% of US infant invasive infections, with type III predominant in both early- and late-onset meningitis and the majority of late-onset infections; type IV, formerly uncommon, is emerging as a cause of invasive neonatal disease.
- GBS is also a major cause of maternal perinatal infection — bacteremia, endometritis, intra-amniotic infection (chorioamnionitis), and urinary tract infection during pregnancy and postpartum.
- Diagnosis is made by isolating GBS from a normally sterile site (blood, CSF, or a focal infection site like bone, joint, or abscess fluid); white blood cell abnormalities such as neutropenia or an elevated immature-to-total neutrophil ratio can accompany GBS infection as with other causes of neonatal sepsis.
- Nearly 50% of early-onset disease survivors and approximately 20% of survivors of neonatal GBS meningitis have moderate to severe neurodevelopmental impairment; ampicillin is included in empiric neonatal meningitis treatment partly to cover GBS (along with Listeria and enterococci in this age group)."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Group B Streptococcus (GBS), or Streptococcus agalactiae, is a gram-positive, aerobic diplococcus that produces a narrow zone of beta-hemolysis on 5% sheep blood agar. Invasive GBS disease in infants is classified by chronologic age at onset into early-onset disease (EOD), occurring within the first week of life, and late-onset disease (LOD), occurring from about 1 week to 89 days of age."},
        {"title": "Epidemiology",
         "content": "GBS is a common inhabitant of the human gastrointestinal and genitourinary tracts, and less commonly the pharynx; colonization rates in pregnant women range from 15-35%, and colonization during pregnancy can be constant or intermittent. Asymptomatic maternal vaginal or anorectal colonization is the source of most infant GBS infections. GBS has been a common cause of invasive infection in neonates and young infants for several decades and is also an important cause of maternal obstetric morbidity and fetal loss. The incidence of early-onset GBS neonatal infection has declined 85% in the United States, associated with universal culture-based screening of pregnant women and intrapartum antibiotic prophylaxis for those found to be colonized; this strategy has significantly reduced only early-onset, not late-onset, disease. Late-onset disease is rare beyond 90 days of age."},
        {"title": "Etiology",
         "content": "GBS is classified into 10 capsular polysaccharide types (Ia, Ib, and II through IX); capsular polysaccharides and pilus-like structures are important virulence factors and potential vaccine candidates. Types Ia, Ib, II, III, and V account for about 95-98% of infant invasive infections in the United States, with type III predominant in both early- and late-onset meningitis and accounting for the majority of late-onset infections overall. Type IV, formerly uncommon, is emerging as a cause of invasive disease in neonates and is becoming important in adult invasive infections as well."},
        {"title": "Clinical features",
         "content": "Early-onset disease usually occurs within the first 24 hours of life (range 0-6 days, most infections apparent within about 1 hour of delivery), characterized by rapidly progressing, potentially overwhelming sepsis with signs of systemic infection, respiratory distress, apnea, and shock; pneumonia with respiratory failure is frequent and its chest radiograph can resemble hyaline membrane disease. Meningitis occurs less often in early-onset disease (5-10% of cases). Late-onset disease typically occurs at 3-4 weeks of age (range 7-89 days) and commonly presents as occult bacteremia or meningitis (about 30% of cases); other focal infections — osteomyelitis, septic arthritis, necrotizing fasciitis, pneumonia, adenitis, and cellulitis — occur less commonly. GBS is also a major cause of maternal perinatal infection, including bacteremia, endometritis, intra-amniotic infection (chorioamnionitis), and urinary tract infection during pregnancy and immediately postpartum."},
        {"title": "Diagnostics",
         "content": "Diagnosis is confirmed by isolating GBS from a normally sterile body site, such as blood or cerebrospinal fluid, or from a focal infection site such as bone, joint, or abscess fluid. Abnormalities of the white blood cell count, including neutropenia or an elevated ratio of immature to total neutrophils, can be found with GBS infection, as with neonatal sepsis from other bacterial pathogens, but these are supportive rather than diagnostic findings."},
        {"title": "Treatment",
         "content": "Because GBS, Listeria, and enterococci are all important causes of infection in the neonatal and young infant age group, ampicillin is included in empiric antibiotic regimens for neonatal meningitis specifically to provide coverage against all three."},
        {"title": "Complications",
         "content": "Nearly 50% of survivors of early-onset GBS disease and about 20% of survivors of neonatal GBS meningitis have moderate to severe neurodevelopmental impairment, underscoring the seriousness of invasive GBS disease in this age group even with treatment."},
        {"title": "Prevention",
         "content": "Universal culture-based screening of pregnant women for GBS colonization, combined with intrapartum antibiotic prophylaxis for those found to be colonized, has reduced the incidence of early-onset GBS neonatal infection by 85% in the United States. This preventive strategy specifically targets early-onset disease, which arises from intrapartum exposure to maternal colonization, and has not had the same impact on late-onset disease."},
    ],
    "clinical": [
        {"title": "Recognizing early- versus late-onset disease",
         "content": "In a neonate presenting within the first week of life, especially within hours of delivery, with respiratory distress, apnea, or shock, consider early-onset GBS disease — pneumonia with respiratory failure is common and can look like hyaline membrane disease on chest x-ray, and meningitis, while less common in this presentation (5-10% of cases), should still be considered. In an infant presenting between about 1 week and 3 months of age (typically 3-4 weeks) with fever, bacteremia, or signs of meningitis, consider late-onset GBS disease, which accounts for meningitis or occult bacteremia in about 30% of cases; also examine for focal infection (bone/joint swelling or pain, skin/soft tissue findings, respiratory symptoms) since osteomyelitis, septic arthritis, necrotizing fasciitis, pneumonia, adenitis, and cellulitis can all occur, albeit less commonly than bacteremia or meningitis. Confirm the diagnosis by culturing blood, CSF, or a focal infection site, and note that white cell abnormalities like neutropenia support but do not confirm the diagnosis."},
        {"title": "Empiric treatment and counseling on prognosis",
         "content": "Include ampicillin in empiric therapy for suspected neonatal meningitis or sepsis in this age group, since it covers GBS along with Listeria and enterococci, the other major pathogens of concern at this age. When counseling families after a diagnosis of invasive GBS disease, be direct about the risk of long-term impact: nearly half of early-onset disease survivors, and about 1 in 5 survivors of GBS meningitis specifically, have moderate to severe neurodevelopmental impairment, so early recognition and treatment matter, and close developmental follow-up is warranted after recovery. When evaluating a pregnant patient's obstetric history, remember that maternal GBS colonization (present in 15-35% of pregnant women) combined with intrapartum antibiotic prophylaxis is the basis for the 85% reduction achieved in early-onset disease — a history of untested or unscreened maternal GBS status in labor should raise the index of suspicion for early-onset disease in a symptomatic newborn."},
    ],
}

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/group-b-streptococcal-infection.article.json")
out.write_text(json.dumps(article, indent=1))
print(out)
