import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from lib import build_and_save

references = [
 {"title": "MedStudy Pediatrics Core 11th Edition 2024-2025", "author": None, "pages": [527, 528]},
 {"title": "Common Cardiac Issues in Pediatrics", "author": "Jonathan N. Johnson,Deepak M. Kamat", "pages": [396, 397, 404, 541]},
 {"title": "Kliegman R. Nelson Textbook of Pediatrics 2-Volume Set 22ed 2024", "author": None, "pages": [2897]},
 {"title": "CURRENT Diagnosis and Treatment Pediatrics, Twenty-Fourth Edition", "author": "Hay, William W., Levin, Myron J., Deterding, Robin R., Abzug, Mark J.", "pages": [638]},
 {"title": "Illustrated Textbook of Paediatrics (Tom Lissauer, Will Carroll)", "author": "Lissauer, Tom,Carroll, Will", "pages": [355]},
 {"title": "Cover", "author": "Vitalsource Download", "pages": [7268]},
 {"title": "Pediatric Board Study Guide", "author": None, "pages": [668]},
 {"title": "2021_Fleisher_&_Ludwig's_Textbook_of_Pediatric_Emergency_Medicine.epub", "author": None, "pages": []},
]

short_md = """## In short

- Dilated cardiomyopathy (DCM) is the most common cardiomyopathy in children, defined by a dilated, poorly contracting (systolic dysfunction) left ventricle, with annual incidence of about 4-8 cases per 100,000 in the US and Europe.
- Most pediatric DCM is idiopathic, but identifiable causes include viral myocarditis, untreated tachyarrhythmias, left heart obstructive lesions, coronary artery anomalies (including anomalous origin of the left coronary artery from the pulmonary artery), medication toxicity (e.g., anthracyclines), genetic causes (dystrophin gene defects, sarcomeric mutations), and metabolic/mitochondrial disease.
- Up to 50% of cases are estimated to be genetic, usually autosomal dominant (some autosomal recessive or X-linked); in older children, myocarditis and neuromuscular disease (Duchenne/Becker muscular dystrophy) are among the most commonly identified causes.
- About 71% of children with DCM present with congestive heart failure at diagnosis; infants and toddlers show tachypnea, tachycardia, weak peripheral pulses, low blood pressure, and hepatomegaly (extreme cases present in shock), while older children/adolescents present more like adults - dyspnea on exertion, orthopnea, fatigue, dependent edema, rales, and elevated jugular venous pressure.
- Gastrointestinal symptoms (abdominal pain, vomiting) are notably common presenting features in children, and younger children may present primarily with failure to thrive or nonspecific symptoms rather than obvious fluid overload.
- Cardiac exam classically shows tachycardia, a gallop rhythm (typically S3, occasionally S4), and murmurs of mitral/tricuspid regurgitation from ventricular dilation.
- Diagnosis is based on echocardiography; endomyocardial biopsy is rarely needed but, when done, typically shows mononuclear infiltrates, and coronary anatomy should be confirmed normal (to exclude anomalous left coronary artery from the pulmonary artery), especially in younger children being evaluated for myocarditis.
- Treatment: diuretics, afterload reduction, and inotropic support (dopamine, dobutamine, milrinone) for acute decompensated heart failure; ACE inhibitors (or ARBs) and beta-blockers (e.g., carvedilol) for compensated heart failure; IVIG is sometimes used; some children ultimately require mechanical circulatory support and/or cardiac transplantation.
- DCM is a leading indication for pediatric cardiac transplantation; more than a third of patients (particularly those with a myocarditis component) can show significant improvement in cardiac function over time.
"""

long_md = """## Definition

Dilated cardiomyopathy (DCM) is the most common form of cardiomyopathy in children, defined by dilation of the systemic (usually left) ventricle together with systolic dysfunction - weak contractility that, over time, can progress to involve all four cardiac chambers as the heart attempts to compensate for poor function.

## Epidemiology

DCM is the most common cardiomyopathy subtype in the pediatric population and occurs at all ages, with an annual incidence of about 4-8 cases per 100,000 population in the United States and Europe. It is a significant cause of morbidity and mortality in children and a common indication for cardiac transplantation.

## Etiology

Most pediatric DCM is idiopathic, but a substantial and growing list of identifiable causes exists. Unlike adults, ischemic causes are rare in children but include anomalous origin of the left coronary artery from the pulmonary artery, premature coronary atherosclerosis (as in homozygous familial hypercholesterolemia or progeria), and coronary inflammatory disease such as Kawasaki disease. Viral myocarditis is an important cause, sometimes described as "burned-out" myocarditis evolving into a DCM phenotype. Untreated tachyarrhythmias and left heart obstructive lesions can produce a reversible form of DCM once the arrhythmia or obstruction is corrected. Medication toxicity, particularly anthracycline chemotherapy, is a recognized cause. An estimated up to 50% of cases are genetic - usually autosomal dominant, though autosomal recessive and X-linked inheritance also occur - including dystrophin gene defects, sarcomeric mutations, and metabolic causes such as inborn errors of fatty acid oxidation and mitochondrial oxidative phosphorylation defects (including specific entities like Barth syndrome and carnitine deficiency). In older children, the most commonly identified causes are myocarditis and neuromuscular disease, particularly Duchenne and Becker muscular dystrophy. Other recognized causes include Kawasaki disease, rheumatic fever, and Lyme disease.

## Clinical Features

About 71% of children with DCM present with congestive heart failure at diagnosis. Presentation differs by age: infants and toddlers show tachypnea, tachycardia, weak peripheral pulses, low blood pressure, and hepatomegaly, with extreme cases presenting in shock. Adolescents tend to present more like adults, with exertional dyspnea, orthopnea, fatigue, dependent edema, pulmonary rales, and elevated jugular venous pressure. Notably, younger children in heart failure often lack obvious fluid retention or edema and instead present with failure to thrive or a range of nonspecific symptoms; gastrointestinal symptoms such as abdominal pain and vomiting are uniquely common in the pediatric presentation of DCM. Cardiac examination reveals tachycardia and a gallop rhythm (typically S3, occasionally S4), sometimes with murmurs of mitral or tricuspid regurgitation from ventricular dilation, and pulmonary hypertension when tricuspid regurgitation is present.

## Diagnostics

Diagnosis is based on echocardiographic findings. The degree of ventricular dilation can help distinguish myocarditis from established dilated cardiomyopathy. Especially in younger children being evaluated for possible myocarditis, it is important to confirm normal coronary artery anatomy on echocardiography to exclude an anomalous left coronary artery arising from the pulmonary artery, which can mimic this presentation. Endomyocardial biopsy is rarely needed but, when performed, typically demonstrates mononuclear infiltrates; further diagnostic testing may be pursued to identify specific infectious or inflammatory etiologies when clinically warranted.

## Differential Diagnosis

Cardiomyopathy in children is classified into five recognized forms: dilated, hypertrophic, restrictive, arrhythmogenic (right ventricular) cardiomyopathy, and left ventricular noncompaction - of which dilated, hypertrophic, and restrictive are the most common. Restrictive cardiomyopathy, the rarest pediatric phenotype, is characterized instead by severe diastolic dysfunction with impaired relaxation and filling, elevated filling pressures, and dilated atria with normal ventricular size and function - a distinct pattern from the dilated, poorly contracting ventricle of DCM.

## Treatment

For acute decompensated heart failure requiring hospital admission, treatment is supportive: diuretics, inotropic agents (milrinone, calcium chloride, vasopressin; some centers also use dopamine, dobutamine, epinephrine, or norepinephrine), and vasodilators/afterload reduction (e.g., sodium nitroprusside). For compensated heart failure, angiotensin-converting enzyme inhibitors (or angiotensin receptor blockers) and beta-blocker therapy (such as carvedilol) - with or without diuretics - are the treatment of choice. IVIG is used in some cases, though the role of steroids and immunoglobulin remains controversial for myocarditis-associated presentations. Some children with acute decompensated or chronic heart failure ultimately require cardiac transplantation and may need mechanical circulatory support beforehand, either as a bridge to transplant or as a bridge to recovery.

## Prognosis

Myocarditis-associated DCM usually improves spontaneously, though some children ultimately require transplantation; overall, more than a third of children treated for DCM/myocarditis-related presentations can show significant improvement in cardiac function over time.
"""

clinical_md = """## Recognizing Pediatric DCM Across Age Groups

In an infant or toddler with tachypnea, tachycardia, weak peripheral pulses, low blood pressure, and hepatomegaly - or in extreme cases frank shock - consider dilated cardiomyopathy and obtain an echocardiogram; do not expect the classic adult picture of edema and rales at this age, since gastrointestinal symptoms (abdominal pain, vomiting) and failure to thrive can be the dominant presenting features in young children with heart failure. In an adolescent presenting more like an adult - exertional dyspnea, orthopnea, fatigue, dependent edema, rales, elevated JVP - listen specifically for a gallop rhythm (usually S3) and murmurs of mitral or tricuspid regurgitation from ventricular dilation. On echocardiography, especially in a younger child being worked up for possible myocarditis, confirm normal coronary artery origins to rule out an anomalous left coronary artery from the pulmonary artery, which can present similarly to DCM but requires a completely different (surgical) approach.

## Managing Heart Failure in DCM

For acute decompensated heart failure, use diuretics, inotropic support (milrinone, or dopamine/dobutamine per center practice), and afterload reduction/vasodilators, and involve pediatric cardiology early given the potential need for mechanical circulatory support. Once a child is stabilized into compensated heart failure, transition to an ACE inhibitor (or ARB) and a beta-blocker such as carvedilol, with diuretics as needed. Reserve endomyocardial biopsy for cases where a specific infectious or inflammatory cause needs confirmation, since it is rarely required and most commonly shows nonspecific mononuclear infiltrates when performed. Counsel families that myocarditis-associated presentations often improve spontaneously and that over a third of children show significant improvement in cardiac function over time, while also preparing them that transplantation, with or without a bridging mechanical circulatory support device, remains a possible outcome for children who do not recover adequate function.
"""

build_and_save(
    topic="Dilated Cardiomyopathy",
    slug="dilated-cardiomyopathy",
    category_id=15603,
    summary="Pediatric dilated cardiomyopathy: age-dependent presentation (GI symptoms and failure to thrive in young children vs adult-like heart failure in adolescents), genetic and acquired causes, and the heart-failure treatment ladder toward transplantation.",
    references=references,
    short_md=short_md,
    long_md=long_md,
    clinical_md=clinical_md,
)
