import json, pathlib

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

article = {
    "topic": "Hypocalcemia",
    "slug": "hypocalcemia",
    "category_id": 14940,
    "summary": "Low serum calcium in neonates and children, split into early- and late-onset neonatal patterns, its many causes, and when to reach for calcium replacement versus conservative monitoring.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Neonatal hypocalcemia is generally defined as total serum calcium under 2 mmol/L (8 mg/dL) in term infants or under 1.75 mmol/L (7 mg/dL) in preterm infants, or ionized calcium under 0.75-1.1 mmol/L (3.0-4.4 mg/dL); a total calcium under 7 mg/dL (3.5 mEq/L calcium activity) is another commonly used threshold, though ionized calcium — the biologically active fraction — should be measured whenever possible since total calcium levels do not reliably predict it.
- Calcium concentration normally falls in all infants immediately after birth, since fetal plasma calcium is higher than neonatal or adult levels; hypocalcemia is the most common calcium/magnesium disorder in newborns, affecting up to 30% of infants under 1500 g birthweight.
- Early-onset neonatal hypocalcemia occurs in the first 24-72 hours of life, is usually transient and not due to hypoparathyroidism, and is most commonly caused by prematurity; other causes include maternal diabetes, toxemia, maternal hyperparathyroidism, antiseizure medications, and infant issues like sepsis, IUGR, asphyxia, hypomagnesemia, and respiratory distress syndrome.
- Late-onset neonatal hypocalcemia occurs after the first week (typically 7-10 days), more often involves lasting pathology, and is linked to modified cow's milk or high-phosphorus formula, hypoparathyroidism (including DiGeorge/22q11 deletion syndrome), and severe maternal vitamin D deficiency; it is more common in developing countries where cow's milk or high-phosphate formula is used.
- Neonatal signs: hypotonia, respiratory distress, anorexia, jitteriness, tetany, clonus, and seizures, with a normal blood glucose and possibly a prolonged QT interval on ECG; dysmorphic features or congenital heart disease suggest DiGeorge syndrome. In older children, hypocalcemia may be asymptomatic or cause irritability, lethargy, muscular twitching, tremulousness, anorexia, and seizures.
- Hypomagnesemia should always be checked for and treated in hypocalcemia resistant to standard treatment; other causes beyond the neonatal period include severe vitamin D deficiency, chronic kidney disease (via secondary hyperparathyroidism), severe pancreatitis, rhabdomyolysis, increased chelation from high phosphate (renal failure, tumor lysis, hemolysis), and alkalosis (increases albumin binding of calcium).
- Vitamin D-dependent rickets presents with early-onset, severe hypocalcemia plus rickets; hypocalcemia can also occur during periods of rapid bone growth (4-8 weeks of life).
- Diagnostic approach uses phosphate, PTH, 25(OH)-D, and 1,25(OH)2-D levels together with albumin/ionized calcium to distinguish hypoparathyroidism, PTH resistance, vitamin D deficiency, 1-alpha-hydroxylase deficiency, vitamin D resistance, and magnesium deficiency.
- Most affected infants remain asymptomatic and can be managed conservatively with early nutrition and close monitoring; symptomatic neonates need IV or oral calcium replacement, and oral calcium (often with vitamin D) is preferred for chronic hypocalcemia from hypoparathyroidism. Hypocalcemia is more common in term infants receiving formula than those exclusively breastfed."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Neonatal hypocalcemia is generally defined as a total serum calcium concentration under 2 mmol/L (8 mg/dL) in term infants or under 1.75 mmol/L (7 mg/dL) in preterm infants, or an ionized calcium under 0.75-1.1 mmol/L (3.0-4.4 mg/dL). Another commonly cited threshold is a total serum calcium under 7 mg/dL (equivalent to a calcium activity of 3.5 mEq/L). Because total calcium levels do not reliably predict ionized calcium — the physiologically active fraction — ionized calcium should be measured whenever possible; in premature infants, a total calcium as low as 6 mg/dL can correspond to an ionized calcium above 3 mg/dL, making total calcium an unreliable sole criterion for true hypocalcemia."},
        {"title": "Epidemiology",
         "content": "Calcium concentration normally decreases in all infants in the immediate newborn period, since fetal plasma calcium is higher than neonatal or adult levels. Hypocalcemia is likely the most common disorder of calcium or magnesium in newborns, affecting both preterm and term infants, and occurs in up to 30% of infants with birthweight under 1500 g. Late-onset hypocalcemia is more common in developing countries where cow's milk or high-phosphate formulas are used."},
        {"title": "Etiology",
         "content": "Hypocalcemia is divided into early-onset (before 72 hours of life, some sources say first 24-48 hours or first 2 days) and late-onset (after 72 hours, typically 7-10 days) forms. Early-onset hypocalcemia is primarily a transient problem related to birth and pregnancy circumstances rather than hypoparathyroidism; the most common cause is prematurity, with other contributors including maternal diabetes mellitus, toxemia, maternal hyperparathyroidism, antiseizure medication use, and infant factors such as sepsis, intrauterine growth restriction, perinatal asphyxia/hypoxia, hypomagnesemia, and respiratory distress syndrome. Late-onset hypocalcemia more often involves lasting pathology and is associated with modified cow's milk or high-phosphorus formula intake, hypoparathyroidism (including DiGeorge syndrome/22q11 deletion), and severe maternal vitamin D deficiency. Beyond the neonatal period, hypocalcemia can also result from increased chelation of calcium — most often from high phosphate levels due to renal failure or release of intracellular phosphate from hemolysis, tumor lysis, or rhabdomyolysis — from increased phosphate intake via cow's milk or commercial formula, and from metabolic or respiratory alkalosis, which increases albumin binding of calcium. Vitamin D-dependent rickets causes early-onset, severe hypocalcemia with rickets. Other causes include severe vitamin D deficiency, chronic kidney disease (via secondary hyperparathyroidism from hyperphosphatemia and reduced renal conversion of 25-OH vitamin D to its active form), severe pancreatitis, and rhabdomyolysis. Hypomagnesemia should always be checked for and treated in hypocalcemia resistant to standard treatment. Hypocalcemia can also occur during periods of rapid bone growth, around 4-8 weeks of life."},
        {"title": "Clinical features",
         "content": "In the neonate, hypocalcemia can manifest as hypotonia, respiratory distress, anorexia, jitteriness, tetany, clonus, and seizures, typically with a normal blood glucose; electrocardiography can show a prolonged QT interval. Possible dysmorphic features or congenital heart disease should raise suspicion for DiGeorge syndrome. In the older child, hypocalcemia may be asymptomatic or present with irritability or lethargy, muscular twitching, tremulousness, anorexia, and seizures. Most affected infants remain asymptomatic and can be managed conservatively, while symptomatic neonates require calcium replacement. Notably, hypocalcemia is more common in term infants receiving formula than in those exclusively breastfed."},
        {"title": "Diagnostics",
         "content": "Evaluation is directed at identifying the underlying etiology and assessing illness severity, guided by a detailed history of age of onset, presenting features, frequency of episodes, and family history; neonates should be screened for prematurity, birth asphyxia, maternal hyperparathyroidism, and initiation of top (formula) feeds. The diagnostic approach uses phosphate, parathyroid hormone (PTH), 25(OH)-D, and 1,25(OH)2-D levels alongside albumin and ionized calcium: low phosphate with high PTH suggests parathyroid hormone resistance; low or normal PTH suggests primary hypoparathyroidism; low-normal magnesium suggests magnesium deficiency; and evaluation of 25(OH)-D and 1,25(OH)2-D helps distinguish vitamin D deficiency, 1-alpha-hydroxylase deficiency, and vitamin D resistance. Ionized calcium should be measured whenever possible rather than relying on total calcium alone."},
        {"title": "Treatment",
         "content": "Most infants with hypocalcemia remain asymptomatic and can be managed conservatively with early nutrition and close monitoring. Symptomatic neonates should receive intravenous or oral calcium replacement. For chronic hypocalcemia due to hypoparathyroidism, oral calcium salts, often combined with vitamin D, are the preferred treatment approach."},
        {"title": "Complications",
         "content": "Untreated symptomatic hypocalcemia in the neonate can progress to tetany and seizures, and a prolonged QT interval carries arrhythmia risk. When hypocalcemia is resistant to standard treatment, unrecognized hypomagnesemia is an important and specifically treatable contributing cause that must be checked for."},
    ],
    "clinical": [
        {"title": "Bedside recognition and initial workup",
         "content": "In a neonate with hypotonia, jitteriness, tetany, clonus, seizures, respiratory distress, or feeding difficulty, check ionized calcium (preferred over total calcium alone) and note the timing of onset: before 72 hours favors a transient, birth/pregnancy-related cause (prematurity, maternal diabetes, asphyxia, hypomagnesemia), while onset after the first week favors a more lasting pathology (hypoparathyroidism/DiGeorge, high-phosphate formula or cow's milk intake, severe maternal vitamin D deficiency). Look for dysmorphic features or congenital heart disease as clues to DiGeorge syndrome, and obtain an ECG to check for QT prolongation. In an older child with irritability, lethargy, muscular twitching, tremulousness, or seizures, screen similarly, and check phosphate, PTH, 25(OH)-D, and 1,25(OH)2-D to localize the cause — and always check magnesium, since coexisting hypomagnesemia can make hypocalcemia refractory to treatment until corrected."},
        {"title": "Treatment approach",
         "content": "Manage most infants conservatively with early nutrition and close monitoring, since the majority remain asymptomatic. Give intravenous or oral calcium replacement for symptomatic neonates. For chronic hypocalcemia due to hypoparathyroidism, use oral calcium salts, generally combined with vitamin D, as the preferred long-term approach. If hypocalcemia proves resistant to standard calcium/vitamin D replacement, check and correct magnesium status before escalating calcium therapy further. Favor breastfeeding over formula where relevant, since formula feeding is associated with a higher rate of hypocalcemia in term infants, and avoid high-phosphate cow's milk or formula in infants at risk for late-onset hypocalcemia."},
    ],
}

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