import json, pathlib

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

article = {
    "topic": "Hypoglycemia",
    "slug": "hypoglycemia",
    "category_id": 15212,
    "summary": "Low blood glucose in infants and children: definitions, causes from ketotic fasting hypoglycemia to hyperinsulinism, clinical recognition, and treatment goals.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Hypoglycemia in infants and children is a blood glucose below 60 mg/dL (3.3 mmol/L); always draw a critical sample if the value is below 50 mg/dL (2.8 mmol/L).
- Symptoms fall into two groups: autonomic (shakiness, sweating, pallor, dizziness) and neuroglycopenic (confusion, headache, seizures); newborns and infants are often subtler or entirely asymptomatic, showing cyanosis, apnea, hypothermia, hypotonia, jitteriness, or poor feeding.
- The most common cause in children with type 1 diabetes is insulin-induced hypoglycemia (defined there as glucose below 70 mg/dL), from excess insulin dosing, reduced intake, or exertion.
- In children without diabetes, ketotic fasting hypoglycemia is the most common cause overall and is a diagnosis of exclusion, usually provoked by fasting.
- Hyperinsulinism is the most common cause of persistent hypoglycemia in infants and children, with three forms: perinatal stress-induced (most common), congenital/monogenic, and syndromic (e.g., Beckwith-Wiedemann, from 11p15 deletions, mutations, or imprinting defects).
- A biochemical hyperinsulinism pattern is low ketones, low lactate, and inappropriately high insulin — an insulin level above 2 µU/mL at a glucose below 60 mg/dL is diagnostic.
- A fatty acid oxidation defect instead shows no ketonemia or ketonuria with an appropriately suppressed insulin level.
- Neonatal risk factors include intrauterine growth restriction, prematurity, being an infant of a diabetic mother, large-for-dates size, hypothermia, polycythemia, and any significant illness.
- The treatment goal is to keep glucose above 70 mg/dL; this is especially critical in hyperinsulinism because these infants cannot generate ketones as an alternative brain fuel when glucose is low. Diazoxide can be used for hyperinsulinism, including in Beckwith-Wiedemann syndrome.
- In type 1 diabetes, hypoglycemia is the second leading cause of morbidity and mortality after diabetic ketoacidosis, which has led to more liberal glycemic targets in young children because of concern for its neurodevelopmental effects."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Hypoglycemia is a low glucose value that produces a neuroendocrine response and characteristic symptoms, which resolve quickly once euglycemia is restored. In infants and children beyond the newborn period, it is defined as a blood glucose below 60 mg/dL (3.3 mmol/L). A critical sample should always be drawn when the glucose falls below 50 mg/dL (2.8 mmol/L), since this is the level typically used as the threshold for stopping a diagnostic fasting or provocative test. In children being treated for diabetes mellitus, hypoglycemia is instead defined at a higher threshold, below 70 mg/dL, reflecting the different clinical context of insulin therapy. Most hypoglycemia encountered in practice is physiological, tied to acute illness, fasting, sepsis, or poor oral intake, and needs no further workup once the child is stable and feeding."},
        {"title": "Etiology",
         "content": "Causes can be grouped by mechanism. Decreased glucose availability includes reduced intake from fasting, malnutrition, or illness; decreased absorption, as with acute diarrhea; and defects anywhere along glycogen handling or gluconeogenesis, including glucagon deficiency. Increased glucose utilization is dominated by hyperinsulinism — from an islet cell adenoma or hyperplasia, ingestion of an oral hypoglycemic agent, or insulin therapy — and, less commonly, large tumors such as Wilms tumor or neuroblastoma. Diminished availability of alternative fuels occurs when fat stores are low or when fatty acids cannot be oxidized because of an enzymatic defect. A further group of causes acts through less direct or combined mechanisms: sepsis and shock, Reye syndrome, salicylate or ethanol ingestion, adrenal insufficiency, hypothyroidism, and hypopituitarism. In children without diabetes, hypoglycemia is usefully split into ketotic fasting hypoglycemia, nonketotic (hypoketotic) fasting hypoglycemia, and reactive or postprandial hypoglycemia. Ketotic hypoglycemia of older children is the most common of these and is a diagnosis of exclusion. Nonketotic fasting causes include glycogen storage disease type 1, tyrosinemia, disorders of fatty acid oxidation and ketone synthesis (carnitine transport and metabolism, the beta-oxidation cycle, electron transfer, and HMG-CoA synthase or lyase deficiency), excess IGF-1 or IGF-2, insulinoma, sulfonylurea ingestion, exogenous insulin, and persistent hyperinsulinemic hypoglycemia of infancy. Reactive or postprandial hypoglycemia includes the \"metabolic dumping syndrome\" seen after fundoplication in young children, galactosemia, and fructose intolerance from fructose-1-phosphate aldolase deficiency; in adolescents it can also accompany obesity and a high-carbohydrate diet, and mild reactive hypoglycemia is common in otherwise healthy adolescents and is not itself a disease."},
        {"title": "Pathophysiology",
         "content": "Insulin-mediated disorders are characterized biochemically by low plasma beta-hydroxybutyrate and free fatty acids together with a positive glycemic response to glucagon, reflecting ongoing glycogen availability that inappropriate insulin prevents from being released as glucose. Hyperinsulinism (HI) is the most common cause of persistent hypoglycemia in infants and children and results from dysregulated insulin secretion by pancreatic beta cells. It takes three main forms: perinatal stress-induced HI, the most common form, which follows stress on the fetus in utero or during delivery; congenital or monogenic HI; and syndromic HI, as in Beckwith-Wiedemann syndrome, where deletion, mutation, or altered imprinting of the 11p15 region drives pancreatic beta-cell hyperplasia and hyperinsulinism. Newborn infants of diabetic mothers illustrate a related mechanism: they have adequate glycogen stores, but islet cell hyperplasia drives high insulin levels that keep glucose from being mobilized. In contrast, growth-restricted and preterm infants become hypoglycemic because their glycogen stores are simply poor."},
        {"title": "Clinical features",
         "content": "Clinical features fall into two categories: autonomic symptoms and signs from activation of the sympathetic nervous system and epinephrine release, and neuroglycopenic symptoms and signs from decreased cerebral glucose use. In newborns and infants, presentation is often subtler and includes cyanosis, apnea, hypothermia, hypotonia, irritability, jitteriness, poor feeding, lethargy, and seizures — and it is important to note that neonates and infants are frequently asymptomatic even while hypoglycemic. Hypoglycemia is particularly likely in the first 24 hours of life in infants who are growth-restricted, preterm, born to a mother with diabetes, large-for-dates, hypothermic, polycythemic, or otherwise ill. Older children more often report shakiness, dizziness, sweating, pallor, sudden moodiness, headache, irritability or lethargy, inattention, blurred vision, and dysarthria, in addition to seizures."},
        {"title": "Diagnostics",
         "content": "A critical sample should be obtained whenever the glucose is below 50 mg/dL, since this threshold is also used to stop a diagnostic fasting test. The pattern of ketones, lactate, and insulin at the time of hypoglycemia distinguishes the major categories: in hyperinsulinism, ketones and lactate are low while insulin is inappropriately high — an insulin level above 2 µU/mL when the glucose is below 60 mg/dL is considered diagnostic. In a fatty acid oxidation defect, there is no ketonemia or ketonuria, and insulin is appropriately suppressed rather than elevated."},
        {"title": "Treatment",
         "content": "The treatment goal is to keep blood glucose above 70 mg/dL, which is particularly important in hyperinsulinism because these children cannot use ketones as an alternative brain fuel when glucose is low. Initial symptomatic treatment preserves brain function, but long-term management depends on identifying and treating the underlying cause. In hyperinsulinism, including the syndromic hyperinsulinism of Beckwith-Wiedemann syndrome, the condition may respond to diazoxide. In children with diabetes, hypoglycemia should be treated immediately, and patients and families need education on recognizing signs and symptoms and on carrying a source of carbohydrate whenever away from home, aiming for rapid normalization of glucose without triggering rebound hyperglycemia from excess carbohydrate."},
        {"title": "Complications",
         "content": "In children and adolescents with type 1 diabetes, hypoglycemia is the second major cause of morbidity and mortality after diabetic ketoacidosis. Concern about the neurodevelopmental effects of hypoglycemia in young children has led to recommendations for more liberal glycemic control targets in early-onset disease."},
    ],
    "clinical": [
        {"title": "Recognizing and confirming hypoglycemia at the bedside",
         "content": "Suspect hypoglycemia in any infant or child with autonomic signs (shakiness, sweating, pallor, dizziness) or neuroglycopenic signs (irritability, lethargy, confusion, seizures), remembering that neonates and infants are frequently asymptomatic or show only subtle findings such as cyanosis, apnea, hypothermia, hypotonia, jitteriness, or poor feeding. A blood glucose below 60 mg/dL (3.3 mmol/L) confirms hypoglycemia in infants and children outside the first 72 hours of life. Whenever the glucose is below 50 mg/dL (2.8 mmol/L), obtain a critical sample before treating, since this is the point at which a diagnostic fasting or provocative test would also be stopped. A simultaneous insulin level above 2 µU/mL at a glucose below 60 mg/dL, together with low ketones and low lactate, points to hyperinsulinism; absent ketonemia and ketonuria with an appropriately suppressed insulin instead points to a fatty acid oxidation defect. In a patient with known diabetes, hypoglycemia is defined at a higher threshold, below 70 mg/dL, and does not need this same critical-sample workup."},
        {"title": "Immediate management",
         "content": "Treat hypoglycemia immediately once recognized or confirmed, with the goal of restoring and keeping glucose above 70 mg/dL — a target that matters most in hyperinsulinism, where the child cannot fall back on ketones as brain fuel while glucose is low. In a child with diabetes, this means prompt carbohydrate treatment, and patients and families should be taught to always carry a source of carbohydrate along with a glucose meter when away from home, aiming to normalize glucose quickly without giving so much carbohydrate that it rebounds into hyperglycemia. Diazoxide can be used for hyperinsulinism, including the syndromic hyperinsulinism of Beckwith-Wiedemann syndrome. Beyond the initial glucose correction, long-term management turns on identifying the underlying cause, since that determines the definitive treatment and the risk of recurrence."},
    ],
}

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