import json

references = [
  {"title": "Caring for the Hospitalized Child", "author": "Section on Hospital Medicine, American Academy of Pediatrics;Jeffrey C. Gershel;Daniel A. Rauch;", "pages": [120,122]},
  {"title": "Pediatrics for Practitioner (Sharad Thora)", "author": None, "pages": [150]},
  {"title": "Berkowitz's Pediatrics", "author": "Berkowitz, Carol D.;", "pages": [795,798,799]},
  {"title": "Algorithms in Pediatrics", "author": None, "pages": [357,359,361]},
  {"title": "Ghai Essential Pediatrics, 9e (Vinod K Paul, Arvind Bagga)", "author": "CamScanner", "pages": [401]},
  {"title": "Common Cardiac Issues in Pediatrics", "author": "Jonathan N. Johnson,Deepak M. Kamat", "pages": [292]}
]

short = [{"title": "In short", "content": """- CHF is the heart's inability to meet the body's metabolic demands — a syndrome from many causes, not a single disease. Most common pediatric causes: congenital heart disease (CHD), cardiomyopathies (genetic, acquired, infectious, drug/toxin, Kawasaki disease, autoimmune), post-surgical myocardial dysfunction, and multisystem inflammatory syndrome in children (MIS-C); also arrhythmias and valvular disease.
- Infant/toddler signs: tachycardia, tachypnea, hepatomegaly, sweating (especially with feeds), decreased feeding, irritability, easy fatigability, poor weight gain. Older-child signs: shortness of breath, exercise intolerance, peripheral edema, abdominal discomfort/hepatomegaly, orthopnea.
- Congenital tricuspid or mitral regurgitation can cause heart failure very early in life (unlike most left-to-right shunts, which typically produce CHF around 6–8 weeks of age as pulmonary vascular resistance falls); heart failure at an unexpectedly early age should prompt a search for coarctation of the aorta.
- Arrhythmia-driven CHF: heart rates above 180/min tend to precipitate failure; if sustained tachycardia persists 36 hours, about 20% of patients develop heart failure, rising to almost 50% by 48 hours.
- Broad classification: structural heart disease (most common) vs. functional heart disease (dilated cardiomyopathy, myocarditis, postoperative CHD, tachycardiomyopathy, chronic rheumatic heart disease with LV dysfunction) — each may be remediable or nonremediable.
- Differential diagnosis to rule out first: asthma (hyperinflation, no cardiomegaly), bronchiolitis (atelectasis/hyperinflation, no cardiomegaly), pneumonia (focal consolidation), gastroenteritis/dehydration, and sepsis — each can mimic tachypnea/tachycardia of CHF but has distinguishing features.
- Chronic (ambulatory) pharmacotherapy: cardiac glycosides (digoxin), diuretics (furosemide, spironolactone), ACE inhibitors (enalapril, captopril), ARBs (losartan), selective beta-blockers (carvedilol, metoprolol). Acute (inpatient) therapy: diuretics (furosemide, bumetanide), beta-agonist inotropes (dobutamine, dopamine), phosphodiesterase inhibitors (milrinone, amrinone), vasodilators (nitroprusside, oxygen, inhaled nitric oxide).
- Refractory CHF (not responding to diuretics, digoxin, ACE inhibitors) may require escalation to mechanical support — ECMO or a left ventricular assist device (LVAD).
- Prognosis is generally excellent: CHF from structural CHD is usually reversible with surgery or catheter-based intervention, catch-up growth follows remission, and children can reach their genetically determined height/weight. Untreated, CHF from a shunt lesion can also remit spontaneously (e.g., a VSD shrinking) — but it can also "remit" via development of Eisenmenger syndrome, where rising pulmonary vascular resistance reverses the shunt at the cost of worsening cyanosis and substantial morbidity/mortality."""}]

long = [
 {"title": "Definition", "content": """Congestive heart failure (CHF) is the inability of the heart to meet the metabolic demands of the body. It is not a single disease but a constellation of signs and symptoms arising from many underlying processes. Heart failure can be classified broadly as arising from structural heart disease (the more common category) or functional heart disease, and within either category as remediable or nonremediable. It can also be characterized by which ventricle is predominantly affected: systemic ventricular failure produces one symptom/sign pattern, subpulmonary ventricular failure another, and congestive (biventricular) failure combines both."""},
 {"title": "Etiology", "content": """The most common causes of pediatric CHF are congenital heart disease, cardiomyopathies (genetic, acquired, and inherited metabolic or muscle disorders; infectious causes; drugs and toxins; Kawasaki disease; and autoimmune disease), myocardial dysfunction following surgical repair of heart defects, and multisystem inflammatory syndrome in children (MIS-C); arrhythmias and valvular disease are additional causes. A more mechanistic classification groups causes by the physiologic derangement: increased preload (fluid overload, left-to-right shunt), decreased myocardial contractility (myocarditis, cardiomyopathy, hypoplastic left heart syndrome), increased afterload (coarctation of the aorta, aortic or pulmonary stenosis, hypertension, cor pulmonale), heart rate/rhythm disturbance (SVT, ventricular tachycardia, complete heart block, hemolytic-uremic syndrome), decreased oxygen content (anemia), and increased oxygen demand (thyrotoxicosis, hypermetabolic states, asphyxia). Functional causes of CHF include dilated cardiomyopathy, myocarditis, postoperative CHD, tachycardiomyopathy, and chronic rheumatic heart disease with left ventricular dysfunction."""},
 {"title": "Clinical features", "content": """Presentation differs by age. Infants and toddlers show tachycardia, tachypnea, hepatomegaly, sweating (particularly with feeding), decreased feeding, irritability, easy fatigability, and poor weight gain. Older children more often report shortness of breath, exercise intolerance, peripheral edema, abdominal discomfort (from hepatomegaly), and orthopnea. Signs can be further separated by which ventricle fails: systemic ventricular failure produces fatigue, breathlessness, dry cough (especially lying flat), orthopnea, paroxysmal nocturnal dyspnea, and wheezing, with exam findings of a third or fourth heart sound (gallop), laterally displaced apical impulse, and absent breath sounds/dullness at the lung bases from pleural effusion. Subpulmonary ventricular failure produces fatigue, bloating, weight gain (>2 kg/week), loss of appetite, and reduced exercise tolerance, with exam findings of elevated jugular venous pressure, hepatomegaly, ascites, and pitting edema (legs, sacrum, scrotum). Congestive (biventricular) failure combines both symptom and sign sets. Timing can be a diagnostic clue: unlike most left-to-right shunt lesions, which typically produce CHF around 6–8 weeks of life as pulmonary vascular resistance falls, congenital mitral or tricuspid regurgitation can cause heart failure much earlier, and heart failure at an unexpectedly early age should prompt evaluation for coarctation of the aorta. Arrhythmia is an important cause of CHF in infancy: heart rates above 180/min tend to precipitate failure, and if sustained tachycardia persists 36 hours, about 20% of patients develop heart failure, rising to nearly 50% by 48 hours."""},
 {"title": "Differential diagnosis", "content": """Several common pediatric conditions can mimic the tachypnea and tachycardia of CHF and must be distinguished: asthma (previous episodes, wheezing, retractions; chest radiograph shows hyperinflation without cardiomegaly or pulmonary congestion), bronchiolitis (rales with or without wheezing, tachypnea, retractions; radiograph shows atelectasis and hyperinflation without cardiomegaly), pneumonia (fever, rales, tachypnea; radiograph shows focal consolidation), gastroenteritis or another GI process (abdominal pain, nausea, vomiting, diarrhea, with dehydration driving tachycardia/tachypnea and sometimes fever), and sepsis (fever, ill appearance, poor perfusion, tachypnea, tachycardia). Radiographic absence of cardiomegaly is a useful discriminator across most of these mimics. Echocardiography is used to characterize the specific underlying process: structural congenital lesions (coarctation, VSD), ventricular dysfunction (dilated cardiomyopathy, myocarditis), pulmonary arterial hypertension (persistent pulmonary hypertension of the newborn, idiopathic PAH), and mechanical valve disease (acute aortic or mitral regurgitation)."""},
 {"title": "Treatment", "content": """Chronic (ambulatory) pharmacotherapy for pediatric CHF includes cardiac glycosides (digoxin), diuretics (furosemide, spironolactone), ACE inhibitors (enalapril, captopril), angiotensin receptor blockers (losartan potassium), and selective beta-blockers (carvedilol, metoprolol). Acute (inpatient) management typically requires ICU admission, with general measures including temperature control, supplemental oxygen, alkali therapy, sepsis management, and metabolic correction, alongside specific IV therapies: diuretics (furosemide, bumetanide), beta-agonist inotropes (dobutamine, dopamine), phosphodiesterase inhibitors (milrinone, amrinone), and vasodilators (nitroprusside, oxygen, inhaled nitric oxide); targeted agents such as sildenafil, adenosine, or ibuprofen may be used according to specific indications. Refractory CHF — failure to respond favorably to conventional management with diuretics, digoxin, and ACE inhibitors — may require escalation to mechanical circulatory support, including ECMO or a left ventricular assist device. Where CHF is caused by structural CHD, the most common scenario, definitive treatment is surgical repair or interventional catheterization, either to correct the defect (e.g., VSD repair) or to palliate it (e.g., pulmonary artery banding for a large left-to-right shunt); prolonged, uncontrolled CHF should rarely be "tolerated" or managed medically at the expense of a major lifestyle change when a corrective or palliative procedure is available."""}
]

clinical = [
 {"title": "Management at the bedside", "content": """First distinguish CHF from its common mimics using history, exam, and chest radiograph: the absence of cardiomegaly on radiograph argues against CHF and toward asthma, bronchiolitis, or pneumonia, while hepatomegaly, gallop rhythm, and cardiomegaly support a cardiac cause. Use echocardiography early to identify the specific underlying lesion or process — structural CHD, ventricular dysfunction, pulmonary hypertension, or valve disease — since this determines definitive treatment. Note the age of onset as a clue: CHF appearing well before 6–8 weeks of life, or earlier than expected for a presumed shunt lesion, should prompt evaluation for coarctation of the aorta or congenital AV valve regurgitation. In an infant with a persistent heart rate above 180/min, treat the tachycardia proactively rather than waiting for overt failure, since risk of CHF rises sharply with duration — about 20% by 36 hours and nearly 50% by 48 hours of sustained tachycardia.

For chronic outpatient management, build the regimen around digoxin, a diuretic (furosemide or spironolactone), an ACE inhibitor (enalapril or captopril) or ARB (losartan), and a selective beta-blocker (carvedilol or metoprolol) as tolerated. For acute decompensated CHF, admit to a pediatric ICU and combine general supportive measures (temperature control, oxygen, correcting acidosis, sepsis management, metabolic correction) with targeted IV therapy — diuretics (furosemide, bumetanide), inotropes (dobutamine, dopamine), phosphodiesterase inhibitors (milrinone, amrinone), and vasodilators (nitroprusside, inhaled nitric oxide) as indicated by the hemodynamic picture. If the patient fails to respond to conventional therapy (diuretics, digoxin, ACE inhibitors), escalate promptly to mechanical circulatory support (ECMO or LVAD) rather than persisting with medical therapy alone. Whenever CHF is due to a structural, correctable or palliable lesion, pursue surgical or catheter-based intervention rather than accepting prolonged medical management as a long-term substitute, since surgical correction/palliation offers the best chance of the excellent prognosis and catch-up growth typically seen with treated pediatric CHF."""}
]

article = {
 "topic": "Congestive Heart Failure",
 "slug": "congestive-heart-failure",
 "category_id": 15009,
 "summary": "Age-specific presentation of pediatric CHF, distinguishing it from common respiratory mimics, and the stepwise chronic-to-acute-to-refractory pharmacologic and surgical management ladder.",
 "written_by": "claude-sonnet",
 "references": references,
 "short": short,
 "long": long,
 "clinical": clinical
}
with open("/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/articles/chf.article.json", "w") as f:
    json.dump(article, f, indent=1)
print("done")
