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": [576]},
 {"title": "Gomella's Neonatology: Management, Procedures, On-Call Problems, Diseases, and Drugs, Eighth Edition", "author": "Tricia Lacy Gomella, Fabien G. Eyal and Fayez Bany-Mohammed", "pages": [39, 693, 891, 1050]},
 {"title": "Cover", "author": "Vitalsource Download", "pages": [733, 6702]},
 {"title": "Pediatric Board Study Guide", "author": None, "pages": [808]},
 {"title": "Diagnostic Imaging: Pediatrics", "author": "A. Carlson Merrow Jr. MD", "pages": [635, 657]},
 {"title": "Illustrated Textbook of Paediatrics (Tom Lissauer, Will Carroll)", "author": "Lissauer, Tom,Carroll, Will", "pages": [157]},
 {"title": "Zitelli and Davis' Atlas of Pediatric Physical Diagnosis: Expert Consult - Online", "author": None, "pages": [575]},
 {"title": "CURRENT Diagnosis and Treatment Pediatrics, Twenty-Fourth Edition", "author": "Hay, William W., Levin, Myron J., Deterding, Robin R., Abzug, Mark J.", "pages": [1152]},
]

short_md = """## In short

- Oligohydramnios is defined as a maximum vertical pocket (MVP) of amniotic fluid under 2 cm; MVP is now preferred over the amniotic fluid index (AFI) method because it is associated with fewer unnecessary interventions (e.g., induction) without worsening outcomes.
- The most common cause is spontaneous rupture of membranes; other causes include placental insufficiency, chronic hypertension, postdate gestation, and fetal anomalies such as renal agenesis, bladder outlet obstruction, cardiac disease, and karyotypic abnormalities.
- Because amniotic fluid is critical to lung development, oligohydramnios as early as the second trimester (severe cases as early as 18 weeks, from obstruction of the bladder outlet or urethra) can cause lung hypoplasia, a potentially fatal condition.
- Most oligohydramnios resulting in the classic sequence is from decreased fetal urine production, due to renal agenesis or a severe underlying renal structural/obstructive disorder; nonurinary causes (amniotic fluid leakage, placental pathology) can produce the same consequences.
- The oligohydramnios sequence (Potter sequence/syndrome) in its most severe form includes: characteristic facies (pseudoepicanthus, recessed chin, posteriorly rotated/flattened low-set ears, flattened/beaked nose, unusual facial creases), decreased fetal movement, clubfoot/clubhand, hip dislocation, joint contractures, wrinkled skin, growth restriction, and pulmonary hypoplasia with pneumothoraces; almost all affected infants die, usually of respiratory insufficiency.
- Associated anomalies in the broader oligohydramnios/renal-agenesis sequence can include absent abdominal musculature (prune belly), cryptorchidism, congenital heart defects, esophageal and duodenal atresia, imperforate anus, sirenomelia, Pierre Robin sequence, large fontanelles, and wide sutures.
- Bilateral renal agenesis and severe polycystic kidney disease are examples of primary malformations that lead to oligohydramnios and its downstream deformation sequence.
- On history-taking, oligohydramnios should specifically prompt consideration of renal anomalies and pulmonary insufficiency in the newborn, just as polyhydramnios should raise suspicion for fetal bowel obstruction.
- Posterior urethral valves (occurring only in males, incidence about 1 in 5,000-8,000 births) can present perinatally with oligohydramnios, hydronephrosis with or without renal dysplasia/failure, anuria, urinary ascites, urinoma, and pulmonary hypoplasia with respiratory distress; up to half of cases are now diagnosed in utero.
"""

long_md = """## Definition

Oligohydramnios is defined as a maximum vertical pocket (MVP) of amniotic fluid less than 2 cm on ultrasound. MVP is now the preferred assessment method over the amniotic fluid index (AFI), since it is associated with fewer unnecessary interventions such as induction without an increase in adverse outcomes. The oligohydramnios sequence, also called Potter sequence or Potter syndrome, describes the complex pattern of fetal deformation that results from prolonged, severe oligohydramnios or anhydramnios.

## Etiology

The most common cause of oligohydramnios is spontaneous rupture of membranes. Other causes include placental insufficiency, chronic maternal hypertension, postdate gestation, and fetal anomalies including renal agenesis, bladder outlet obstruction, cardiac disease, and karyotypic abnormalities. Most cases severe enough to produce the classic oligohydramnios sequence arise from decreased fetal urine production, due to bilateral renal agenesis or a severe underlying renal structural or obstructive disorder (such as severe polycystic kidneys or urinary tract obstruction, including posterior urethral valves); nonurinary causes such as chronic amniotic fluid leakage and placental pathology can produce the identical downstream consequences. Obstruction of the bladder outlet or urethra can cause severe oligohydramnios as early as 18 weeks' gestation.

## Pathophysiology

Amniotic fluid is critical to normal lung development, so oligohydramnios occurring as early as the second trimester can result in pulmonary hypoplasia, a potentially fatal disorder. The reduced fluid volume also produces fetal compression: because there is little cushioning fluid, the fetus is compressed against the uterine wall, leading to characteristic deformations and disruptions - compression of the face and limbs, wrinkled skin, and growth restriction - in addition to the pulmonary effects.

## Clinical Features

In its most severe form, the oligohydramnios (Potter) sequence produces a typical facial appearance: pseudoepicanthus, a recessed chin (retrognathia), posteriorly rotated and flattened low-set ears, a flattened or beaked nose, and unusual facial creases (suborbital creases). Other features include decreased fetal movement, clubfoot and clubhand, hip dislocation, joint contractures, and pulmonary hypoplasia, sometimes with pneumothoraces. Absent abdominal musculature (prune belly) and cryptorchidism may also be present. Associated anomalies described in this broader sequence include congenital heart defects, esophageal and duodenal atresia, imperforate anus, sirenomelia, hypoplastic nails, Pierre Robin sequence, large fontanelles, wide sutures, flexion contractures, and clubfeet. Newborns with severe Potter syndrome usually die of respiratory insufficiency secondary to severe pulmonary hypoplasia and pneumothoraces; almost all infants with the complete sequence from bilateral renal agenesis die. Posterior urethral valves, a specific and important cause occurring only in males (incidence about 1 in 5,000-8,000 births), can present perinatally with oligohydramnios, hydronephrosis with or without renal dysplasia and renal failure, anuria, urinary ascites, urinoma, and pulmonary hypoplasia with respiratory distress; historically, about a third of cases presented at each life stage (perinatal, infancy, childhood), though up to half are now diagnosed in utero, with fewer cases now first identified in infancy or childhood.

## Diagnostics

A thorough maternal medical, antenatal, and obstetric history is essential, since specific findings direct the focus of the newborn physical exam: oligohydramnios should prompt consideration of renal anomalies and pulmonary insufficiency, just as polyhydramnios should raise suspicion for fetal bowel obstruction. On newborn examination, features suggesting bilateral renal agenesis include wide-set eyes, a parrot-beak nose, a receding chin, excess/dehydrated-appearing skin, large low-set floppy ears lacking cartilage, and deformities of the hands and feet. Fetal growth should be monitored by serial abdominal circumference, head circumference, and femur length measurements, supplemented by Doppler umbilical and fetal flow velocity studies when indicated. For suspected renal causes such as autosomal recessive polycystic kidney disease, marked bilateral renal enlargement may be detected on fetal imaging (most often after 24 weeks, though occasionally as early as 16 weeks in an at-risk fetus, since kidneys often look normal until late in the second trimester); delayed-onset oligohydramnios after 28 weeks has also been reported, and most fetuses diagnosed prenatally with this pattern are stillborn or die in the neonatal period. Marked fetal nephromegaly can itself cause dystocia at delivery.

## Differential Diagnosis

Oligohydramnios must be distinguished by cause: membrane rupture and placental insufficiency versus a primary fetal renal/urinary anomaly (renal agenesis, polycystic kidneys, posterior urethral valves or other obstructive uropathy) versus a nonurinary cause such as chronic fluid leakage. This distinction matters because the prognosis and associated anomaly risk differ substantially between an isolated obstetric cause and a severe underlying renal malformation.

## Complications

The central complications of significant oligohydramnios are pulmonary hypoplasia (often fatal) and the musculoskeletal and facial deformities of fetal compression. Marked renal enlargement (as in polycystic kidney disease) can cause pulmonary compromise both from the underlying oligohydramnios and from mass effect elevating the diaphragm. Developmental dysplasia of the hip is also more common in the setting of oligohydramnios, related to reduced fetal movement and intrauterine crowding; most minor ultrasound findings of hip dysplasia identified between 6 weeks and 4 months of age resolve without treatment, though infants with continued clinical instability (positive Barlow test) need orthopedic referral.
"""

clinical_md = """## Recognizing Oligohydramnios and Anticipating Neonatal Findings

When reviewing prenatal history, treat a documented MVP under 2 cm as oligohydramnios and specifically ask about the likely cause: membrane rupture, placental insufficiency, postdate gestation, chronic hypertension, or a suspected fetal renal/urinary anomaly. On the newborn exam, actively look for the Potter sequence facies (recessed chin, low-set posteriorly rotated ears, flattened or beaked nose, suborbital creases) and limb findings (clubfoot/clubhand, joint contractures, hip dislocation) whenever oligohydramnios was noted antenatally, and anticipate respiratory distress from pulmonary hypoplasia - have a low threshold for respiratory support and be prepared for pneumothorax. In a male newborn with prenatal oligohydramnios and hydronephrosis, evaluate for posterior urethral valves (voiding difficulty, poor stream, urinary ascites) as well as bilateral renal agenesis or severe cystic renal disease, since these differ substantially in management and prognosis despite a similar antenatal fluid picture.

## Counseling and Coordinating Care

Because severe oligohydramnios from bilateral renal agenesis or severe renal dysplasia carries an extremely high mortality risk (respiratory insufficiency from pulmonary hypoplasia), coordinate antenatal counseling with maternal-fetal medicine and neonatology as soon as significant oligohydramnios with a suspected renal cause is identified, so families understand the prognosis before delivery. For infants who survive the immediate perinatal period, screen for the broader pattern of associated anomalies (cardiac defects, GI atresias, imperforate anus, Pierre Robin sequence) rather than assuming an isolated renal or pulmonary problem. Screen for developmental dysplasia of the hip in any infant with a history of oligohydramnios, since intrauterine crowding increases this risk; most minor ultrasound findings between 6 weeks and 4 months resolve with observation, but refer to orthopedics if clinical instability (positive Barlow test) persists.
"""

build_and_save(
    topic="Oligohydramnios",
    slug="oligohydramnios",
    category_id=15181,
    summary="Oligohydramnios and the Potter sequence: MVP-based definition, renal versus non-renal causes, the pulmonary hypoplasia and compression-deformity consequences, and anticipated newborn findings.",
    references=references,
    short_md=short_md,
    long_md=long_md,
    clinical_md=clinical_md,
)
