import json, pathlib

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

article = {
    "topic": "Short Bowel Syndrome",
    "slug": "short-bowel-syndrome",
    "category_id": 15019,
    "summary": "The leading cause of pediatric intestinal failure, most often from neonatal surgical resection for necrotizing enterocolitis, its prognostic factors, and the balance of parenteral and enteral nutrition that drives bowel adaptation.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Short bowel syndrome (SBS) is a state of reduced functional intestinal mass below what is needed to digest and absorb the nutrients and fluids required for normal growth, from congenital malformation or resection of the small bowel; it is the leading cause of intestinal failure in children, accounting for about 44-45% of pediatric cases.
- Intestinal failure (IF) is a critical reduction of gut mass or function below the minimum needed for adequate nutrient/fluid absorption and growth; a supplemental parenteral nutrition (PN) requirement lasting more than 2-3 months in the setting of SBS (or any other disorder) qualifies as intestinal failure.
- Most common pediatric causes: necrotizing enterocolitis (NEC, about 45%), intestinal atresia (about 23%), gastroschisis (about 15%), and volvulus (about 15%); less common causes include congenital short bowel, long-segment Hirschsprung disease (total intestinal aganglionosis), ischemic bowel, tumor, and radiation enteritis. Later in life, volvulus, trauma, and Crohn disease become the more common causes.
- SBS incidence rises with lower birthweight and earlier gestational age, estimated at 7 per 1,000 live births among US infants under 1,500 g.
- Normal small bowel length at birth is 200-250 cm, growing to 300-800 cm by adulthood; loss of more than 50% of the small bowel (with or without part of the large intestine) can cause generalized malabsorption or specific nutrient deficiencies. Functional definitions include massive resection of more than 75% of small bowel, or symptoms occurring when fewer than 150 cm of small bowel remain without a colon, or fewer than 70 cm remain with an intact colon (older children/adults).
- Infants tolerate bowel resection better than adults and have a better prognosis because of the intestine's capacity for postnatal growth and adaptation — an infant with as little as 15 cm of bowel (with additional favorable factors) may still do reasonably well.
- The single strongest prognostic factor is preservation of the ileum and ileocecal valve; other favorable factors include greater residual bowel length, colon preservation, type of enteral feeds used, early introduction of enteral feeding, the residual bowel's adaptive potential, lower infection frequency, and the health of other organs (stomach, pancreas, liver, colon).
- Contributing mechanisms behind persistent symptoms include decreased absorptive surface, altered intestinal motility, intraluminal bacterial overgrowth (causing bile salt deconjugation and fatty acid hydroxylation), bile salt malabsorption from terminal ileal resection, and disaccharidase deficiency; infants with NEC or gastroschisis as the underlying cause tend to have a more prolonged clinical course than other causes.
- Total parenteral nutrition is used in the immediate postoperative period after major small bowel loss, but early initiation of enteral feeding is important because it maximizes enteric hormonal stimulation and drives residual bowel adaptation through elongation, hypertrophy, and slowed peristalsis; multidisciplinary short bowel programs and improved management of catheter-related complications and PN-associated liver disease (PNALD) have raised survival to above 90% in recent years."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Short bowel syndrome (SBS), also called short gut syndrome, is a state of reduced functional intestinal mass lower than the amount required for adequate digestion, absorption of nutrients and fluids, and normal growth. It results from congenital malformation or resection of the small bowel, and by definition arises from intestinal malabsorption following removal of a significant portion of small intestine. Intestinal failure (IF) is a broader, related concept: a critical reduction of gut mass or function below the minimum needed for adequate nutrient and fluid absorption to support growth; a requirement for supplemental parenteral nutrition lasting more than 2-3 months in the setting of SBS (or another underlying disorder) meets the definition of intestinal failure. IF due to SBS may be reversible or irreversible depending on the underlying cause, the length of remaining intestine, preservation of the colon and ileocecal valve, and the treatments used to restore intestinal capacity."},
        {"title": "Epidemiology",
         "content": "Short bowel syndrome is the leading (single most frequent) cause of intestinal failure in children, accounting for about 44-45% of pediatric cases. Its incidence increases with lower birthweight and earlier gestational age, estimated at about 7 per 1,000 live births among US infants weighing under 1,500 g. The true incidence and prevalence of SBS in the US are not precisely known, but advances in neonatal intensive care and surgical technique have likely increased the frequency with which pediatricians encounter these patients."},
        {"title": "Etiology",
         "content": "The most common pediatric causes are necrotizing enterocolitis (about 45% of cases), intestinal atresia (about 23%), gastroschisis (about 15%), and midgut volvulus (about 15%); less common causes include congenital short bowel, total intestinal aganglionosis (long-segment Hirschsprung disease), ischemic bowel injury, tumor, and radiation enteritis. The vast majority of pediatric SBS patients have undergone neonatal surgical resection of intestine. Later in childhood and beyond, volvulus, trauma, and Crohn disease become the more common causes of short bowel syndrome."},
        {"title": "Pathophysiology",
         "content": "Normal small bowel length is 200-250 cm at birth, growing to 300-800 cm by adulthood. Depending on which portion of bowel is resected or absent, loss of more than 50% of the small bowel — with or without a portion of the large intestine — can produce generalized malabsorption or specific nutrient deficiencies. Functional thresholds cited for short gut syndrome include massive resection of more than 75% of the small bowel, dependence on parenteral nutrition for more than 6 weeks, or symptomatic short bowel when fewer than 150 cm of small bowel remain without a colon, or fewer than 70 cm remain with an intact colon (in older children/adults). Infants tolerate bowel resection better than adults, with a correspondingly better prognosis, because of the intestine's potential for postnatal growth and adaptation; an infant with as little as 15 cm of residual bowel, combined with other favorable factors, may still achieve reasonable function. Persistence of symptoms is driven by decreased absorptive surface area, altered intestinal motility, intraluminal bacterial overgrowth (with secondary bile salt deconjugation and fatty acid hydroxylation), bile salt malabsorption from terminal ileal resection, and disaccharidase deficiency."},
        {"title": "Clinical features",
         "content": "SBS most commonly begins in the newborn period in association with necrotizing enterocolitis or a congenital anomaly such as gastroschisis, intestinal atresia, or malrotation with secondary midgut volvulus, presenting with severe chronic diarrhea, malnutrition, and failure to thrive. Symptoms of colitis can occur during the initiation of enteral feedings in affected infants. Among neonatal causes, infants with necrotizing enterocolitis or gastroschisis tend to have a more prolonged clinical course than those with other underlying causes of short bowel."},
        {"title": "Complications",
         "content": "Prognosis in SBS depends on the length of residual bowel, presence or absence of the ileocecal valve (its preservation being the single strongest favorable factor, along with preservation of the duodenum and distal ileum), the type of enteral feeds used, early introduction of enteral feeding, the adaptive potential of the residual bowel, frequency of infections, and the health of other organs (stomach, pancreas, liver, colon). Recovery can be prolonged, sometimes requiring total parenteral nutrition (TPN) for the first several years of life. Delayed recognition, diagnosis, and treatment of severe short bowel syndrome can lead to serious complications or death; abdominal wall edema, cellulitis, distention, and crepitus can develop rapidly in severe, poorly managed cases. Encouragingly, recent advances in managing catheter-related complications and parenteral-nutrition-associated liver disease (PNALD), along with multidisciplinary short bowel syndrome programs, have improved survival to greater than 90%."},
        {"title": "Treatment",
         "content": "In the initial postoperative period after loss of a significant length of small bowel, total parenteral nutrition is used (universally, per some sources) to meet caloric, fluid, and electrolyte needs while the residual bowel is insufficient. Early initiation of enteral feeding is important because it maximizes enteric hormonal stimulation and drives adaptation of the residual bowel through elongation, hypertrophy, and reduction in peristaltic rate — improving the bowel's absorptive capacity over time. Long-term management often requires ongoing parenteral nutrition support, with intestinal transplantation considered in severe or refractory cases. Multidisciplinary programs specializing in short bowel syndrome care, together with improved management of catheter-related complications and PNALD, have substantially improved survival."},
    ],
    "clinical": [
        {"title": "Recognizing and assessing the newborn at risk",
         "content": "In a neonate who has undergone significant small bowel resection — most often for necrotizing enterocolitis, but also intestinal atresia, gastroschisis, or volvulus — anticipate short bowel syndrome and assess the specific prognostic factors early: residual bowel length, whether the ileocecal valve and ileum were preserved, whether the colon is intact, and the health of other digestive organs (stomach, pancreas, liver). Recognize that an NEC or gastroschisis etiology tends to predict a more prolonged clinical course than other causes. Watch for chronic diarrhea, malnutrition, and failure to thrive as the presenting pattern, and monitor closely for colitis-like symptoms when enteral feeding is initiated. If abdominal wall edema, cellulitis, distention, or crepitus develop, treat this as a sign of delayed recognition of a severe complication requiring urgent attention, since delay risks severe SBS or death."},
        {"title": "Nutritional management and monitoring",
         "content": "Start total parenteral nutrition in the immediate postoperative period to meet caloric, fluid, and electrolyte needs while the bowel is insufficient, but introduce enteral feeding as early as feasible, since this maximizes enteric hormonal stimulation and promotes bowel adaptation (elongation, hypertrophy, and slowed peristalsis) rather than leaving the bowel unstimulated. Anticipate that recovery can take years, sometimes requiring TPN for the first several years of life, and involve a multidisciplinary short bowel program early, given the substantial survival benefit these programs and improved catheter/PNALD management have demonstrated (over 90% survival in recent series). Track the specific prognostic factors over time — residual bowel adaptive potential, infection frequency, and the function of other organs — to guide the pace of weaning from parenteral nutrition and to identify children who may eventually need consideration for intestinal transplantation."},
    ],
}

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