import json, pathlib

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

article = {
    "topic": "Compartment Syndrome",
    "slug": "compartment-syndrome",
    "category_id": 15878,
    "summary": "A limb-threatening rise in pressure within a closed fascial compartment after trauma, recognized in children by the '3 As' rather than the classic '5 Ps', and treated with emergency fasciotomy.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Compartment syndrome develops when interstitial pressure inside a closed, unyielding fascial compartment exceeds capillary perfusion pressure — clinically, elevation to roughly 35-45 mmHg — obstructing venous outflow and then arteriolar/capillary flow, causing muscle and neurovascular ischemia.
- In children, the classic adult "5 Ps" (pain, pallor, paresthesia, pulselessness, paralysis) are unreliable; use the "3 As" instead — anxiety, agitation, and an increasing analgesia requirement — since pulselessness, pallor, and paralysis are late findings and their absence does not rule out the diagnosis.
- Pain out of proportion to the injury, or pain increasing despite analgesia, plus pain with passive stretch of the digits, is the most common and earliest presentation; a child may show only one sign or symptom.
- Lower leg (tibia/fibula) fractures cause about 60% of pediatric compartment syndromes; a displaced proximal tibial metaphyseal fracture is the single fracture most likely to be complicated by it, and supracondylar humerus and displaced forearm fractures are also well-documented causes.
- Displaced supracondylar fractures can injure the anterior interosseous artery and forearm flexor compartment, leading to the classic Volkmann contracture if unrecognized.
- Adolescents 14 years and older have a higher risk of compartment syndrome with tibial shaft fractures than younger children.
- Diagnosis can be supported by compartment pressure measurement: normal is about 8 mmHg in adults and 10-15 mmHg in children; an absolute pressure ≥30 mmHg, or a diastolic blood pressure minus compartment pressure under 30 mmHg, are indications for fasciotomy.
- Immediate treatment: remove or split any cast or splint, elevate the limb only to heart level (elevating above the heart reduces tissue perfusion and worsens ischemia), and obtain urgent orthopedic consultation; definitive treatment is prompt fasciotomy.
- Rare variants: abdominal compartment syndrome (from intra-abdominal hypertension, e.g., bowel obstruction or burns) is immediately life-threatening via IVC compression, and a distinct neonatal compartment syndrome can present in the delivery room as a swollen, paralyzed, dysvascular limb with a sentinel bullous or open forearm lesion."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Compartment syndrome is vascular insufficiency caused by elevated tissue pressure within an enclosed, unyielding fascial (osteofascial) compartment, most often after an injury causing hemorrhage or edema within that compartment. Because the fascial boundary cannot expand, rising interstitial pressure — clinically around 35-45 mmHg — comes to exceed capillary perfusion pressure, obstructing first venous outflow and then arteriolar and capillary flow, producing ischemia with potentially irreversible muscle and neurovascular damage. It is a limb-threatening, surgical emergency."},
        {"title": "Etiology",
         "content": "Compartment syndrome is usually associated with extremity fractures — tibia, supracondylar humerus, and distal radius fractures are classic examples — but also follows thermal and electrical injuries, rhabdomyolysis, coagulopathies, nephrotic syndrome, crush injuries, other soft tissue trauma without fracture, poisonous snakebite (especially pit vipers), and prolonged pressure on an extremity, as can occur in a comatose child lying on a limb for hours. Tight circumferential bandages or casts can limit expansion of already-swollen tissue and elevate pressures further, and pressure-driven fluid extravasation from an intravenous or intraosseous line can also raise compartment pressure. Direct arterial injury is a less common but recognized cause. Lower leg fractures of the tibia and/or fibula account for about 60% of pediatric compartment syndromes, with open fractures at greater risk, likely reflecting their higher-energy mechanism. A displaced fracture of the proximal tibial metaphysis is the single fracture most likely to be complicated by compartment syndrome. Displaced supracondylar humerus fractures can injure the anterior interosseous artery and the forearm flexor compartment; some evidence, though controversial, suggests delayed fracture reduction is itself a risk factor. Forearm fractures can also cause compartment syndrome of either the flexor or extensor compartment. Adolescents 14 years and older have a higher risk of compartment syndrome with tibial shaft fractures than younger children. A separate, rare, and distinct neonatal compartment syndrome develops during the antepartum period from an unclear mix of intrinsic thrombophilic mechanisms and extrinsic compression."},
        {"title": "Clinical features",
         "content": "Because the classic \"5 Ps\" — pain out of proportion, pallor, paresthesia, pulselessness, and paralysis — are less reliable signs in children, and pulselessness, pallor, and paralysis are late findings, the recommended framework is the \"3 As\": anxiety, agitation, and an increasing analgesia requirement, which are the ways pain manifests in children. Pain alone, or pain increasing despite analgesics, is often the only early sign, along with pain on passive stretch of the distal joints (toes or fingers) and paresthesias. On examination the limb may be pale, with muscular compartments that are swollen, hard, and tense (a \"tense, non-compressible swelling\"); pulses may be diminished or absent and there may be muscle weakness or paralysis, though a child may present with only a single sign or symptom, so the absence of most findings does not exclude the diagnosis. The neonatal variant presents in the delivery room as a swollen, paralyzed, dysvascular limb, typically with a sentinel bullous or open lesion on the forearm and visible discoloration. Abdominal compartment syndrome, from increased intra-abdominal pressure (e.g., intestinal obstruction or burns), is immediately life-threatening because of inferior vena cava compression and reduced venous return."},
        {"title": "Diagnostics",
         "content": "The diagnosis is primarily clinical, built from a high index of suspicion in any fracture or blunt tissue injury with pain out of proportion or increasing pain despite analgesia. When compartment syndrome is suspected, compartment pressure can be measured with a pressure needle, though this can be difficult in an awake young child, especially under age 5. Normal compartment pressure is about 8 mmHg in adults and 10-15 mmHg in children; an absolute pressure of 30 mmHg or more supports the diagnosis, though newer approaches interpret compartment pressure relative to systemic blood pressure — a compartment pressure within 30 mmHg of the diastolic blood pressure or mean arterial pressure is concerning. Urgent orthopedic consultation is warranted for any concern for compartment syndrome."},
        {"title": "Treatment",
         "content": "Once compartment syndrome is suspected, any cast or splint should be removed or split immediately, and the affected extremity elevated only to the level of the heart, since elevating it above the heart decreases tissue perfusion and worsens ischemia. Urgent orthopedic consultation should be obtained; definitive treatment is prompt, wide fasciotomy to release the affected compartments. In the rare neonatal variant, emergency surgical fasciotomy is the only treatment that may salvage some limb function. All children with an open fracture, or with concern for or diagnosis of compartment syndrome, should be admitted to the hospital for ongoing orthopedic care given the high risk of infection and neuromuscular injury."},
        {"title": "Complications",
         "content": "Unrelieved ischemia leads to muscle necrosis, cellular breakdown, hemoglobinuria, and permanent functional loss of the limb. Compartment syndrome after a displaced supracondylar humerus fracture, if unrecognized, classically leads to Volkmann contracture from ischemic injury to the forearm flexor compartment. Abdominal compartment syndrome causes life-threatening hemodynamic compromise through inferior vena cava compression and reduced venous return."},
    ],
    "clinical": [
        {"title": "Recognition in the child with a limb injury",
         "content": "Suspect compartment syndrome in any child with an extremity fracture or blunt/crush injury — especially a tibial shaft, proximal tibial metaphyseal, supracondylar humerus, or displaced forearm fracture — who has pain out of proportion to the injury, or pain that is increasing despite analgesic administration. In children, rely on the \"3 As\" — anxiety, agitation, and an escalating analgesia requirement — rather than the classic \"5 Ps\", since paresthesia, pallor, pulselessness, and paralysis are late findings and a child may show only a single sign. Examine for pain with passive stretch of the toes or fingers, and for a tense, non-compressible, swollen compartment. Consult orthopedics urgently for any such concern, and obtain compartment pressure measurement when feasible: an absolute pressure of 30 mmHg or more, or a value within 30 mmHg of the diastolic blood pressure or mean arterial pressure, supports the diagnosis."},
        {"title": "Immediate management",
         "content": "As soon as compartment syndrome is suspected, remove or split any cast or splint immediately, and elevate the affected extremity only to the level of the heart — not above it, since elevation above heart level reduces tissue perfusion and worsens ischemia. Obtain urgent orthopedic consultation without delay; definitive treatment is prompt, wide fasciotomy of the affected compartments. Admit all children with an open fracture, or with a diagnosis of or concern for compartment syndrome, for ongoing orthopedic care given the high risk of infection and neuromuscular injury. In the rare neonatal presentation of a swollen, paralyzed, dysvascular limb with a sentinel forearm lesion, emergency surgical fasciotomy is the only treatment that may salvage limb function."},
    ],
}

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