import json

data = {
 "topic": "Functional Constipation",
 "slug": "functional-constipation",
 "category_id": 15678,
 "summary": "Functional constipation, accounting for about 90% of pediatric constipation, arises from a self-perpetuating cycle of painful defecation and voluntary stool withholding, diagnosed by history/exam using validated criteria and distinguished from Hirschsprung disease by rectal exam findings.",
 "written_by": "claude-sonnet",
 "references": [
  {"title": "Update in Pediatrics", "author": None, "pages": [369, 372]},
  {"title": "Signs and Symptoms in Pediatrics", "author": "Henry M. Adam,Jane Meschan Foy", "pages": [145, 151]},
  {"title": "Netters Pediatrics (Florin Т., Ludwig St.)", "author": None, "pages": [734, 735]},
  {"title": "2021_Fleisher_&_Ludwig's_Textbook_of_Pediatric_Emergency_Medicine.epub", "author": None, "pages": []},
  {"title": "Textbook of Pediatric Gastroenterology, Hepatology and Nutrition (Stefano Guandalini, Anil Dhawan)", "author": None, "pages": [70, 304]},
  {"title": "Kliegman R. Nelson Textbook of Pediatrics 2-Volume Set 22ed 2024", "author": None, "pages": [2402]},
  {"title": "Pediatrics for Practitioner (Sharad Thora)", "author": None, "pages": [401, 405]},
  {"title": "Berkowitz's Pediatrics", "author": "Berkowitz, Carol D.;", "pages": [950]}
 ],
 "short": [
  {"title": "In short", "content": (
   "- Functional (idiopathic) constipation accounts for approximately 90% of childhood constipation; organic causes make up only about 10%\n"
   "- Diagnostic criteria (infants up to age 4) require at least 1 month with at least 2 of: ≤2 defecations/week, history of excessive stool retention, history of painful/hard bowel movements, history of large-diameter stools, or a large fecal mass palpable in the rectum; in toilet-trained children, add at least 1 episode/week of fecal incontinence after toileting skills are acquired, or a history of large-diameter stools that may obstruct the toilet\n"
   "- Core mechanism: a painful or negative defecation experience (e.g., a hard stool from a diet change) triggers voluntary stool withholding to avoid pain; retained stool sits in the colon, water continues to be absorbed, and stool becomes harder and more painful to pass - a self-perpetuating cycle\n"
   "- Common onset triggers: weaning/dietary transition in infants, toilet training in toddlers, or starting school in older children (where play may distract from the urge to defecate)\n"
   "- Supporting findings for functional (versus organic) constipation: onset after infancy, stool-withholding behavior, absence of red flags, and episodic passage of large-caliber stools\n"
   "- On exam: palpable stool in the abdomen, an enlarged rectum with stool palpable just beyond the anal verge, and (per one comparison table) an open, distended anal tone - versus Hirschsprung disease's tight anal tone with an empty rectal vault\n"
   "- Key differentiators from Hirschsprung disease: functional constipation is rare in infancy, delayed passage of meconium is rare, encopresis is common, stool is very large-caliber, and failure to thrive is rare - Hirschsprung disease is common in infancy, delayed meconium passage and failure to thrive are common, encopresis is unusual, and stool is small/ribbon-like\n"
   "- Must consider painful defecation from streptococcal perianal disease or sexual abuse in a child presenting with new stool withholding; functional constipation can also be associated with dysfunctional voiding and recurrent UTIs\n"
   "- Functional non-retentive fecal incontinence (FNRFI) is a distinct, less common entity (only 5-10% of children with fecal incontinence) in which normal stools are passed in inappropriate places without withholding, pain, or difficulty defecating\n"
   "- Management combines regular bowel/toilet training, dietary modification, sitz baths to relax perineal muscles, local lubricants, and laxatives given for a sufficient duration - insufficient treatment duration is the most common cause of treatment failure and relapse, and relapses are common if management is inadequate, potentially persisting into adolescence"
  )}
 ],
 "long": [
  {"title": "Definition", "content": (
   "Functional constipation is constipation occurring in the absence of any identifiable organic disease, resulting from a child's repeated voluntary attempts to withhold feces to avoid defecation, typically due to fear of pain based on a prior negative experience with bowel movements. It accounts for roughly 90% of pediatric constipation cases, with organic causes making up the remaining approximately 10%. Diagnostic criteria (based on the Rome/Benninga classification) for infants up to 4 years of age require at least 1 month with at least 2 of the following: 2 or fewer defecations per week; history of excessive stool retention; history of painful or hard bowel movements; history of large-diameter stools; or presence of a large fecal mass in the rectum. In toilet-trained children, at least 1 episode per week of fecal incontinence after toileting skills are acquired, or a history of large-diameter stools that may obstruct the toilet, can also be used as criteria."
  )},
  {"title": "Etiology", "content": (
   "The pathophysiologic basis of functional constipation is not fully understood and may represent a final common pathway for several distinct underlying processes: a disorder of defecation dynamics, a problem with rectal sensation, or a disorder of colonic transit leading to impacted, overly desiccated stool. It can also arise purely from a learned behavioral aversion to the process of defecation. In many cases, one episode of painful stool passage - often triggered by a dietary change - becomes the initial negative experience that leads to future stool withholding, independent of the original cause. Functional constipation typically begins after the neonatal period and commonly develops around specific transition points: weaning or dietary change in infants, toilet training in toddlers, or starting school in older children (where play activities may distract a child from the urge to defecate). Painful defecation from streptococcal perianal disease or, importantly, sexual abuse must also be considered as possible triggers for new-onset stool withholding."
  )},
  {"title": "Pathophysiology", "content": (
   "Stool withholding - the voluntary act of deferring defecation to avoid pain - significantly contributes to the chronicity of constipation independent of whatever process originally triggered it. Continued retention of feces in the colon allows ongoing water absorption from the stool, making it progressively harder and more painful to pass, which in turn reinforces further withholding: a self-perpetuating positive feedback loop. Over time, the rectum's stretch receptors accommodate the chronically distended rectum, and contractile forces become less effective at achieving complete evacuation, worsening the underlying constipation."
  )},
  {"title": "Clinical features", "content": (
   "Children with functional constipation can present with decreased stooling frequency, decreased oral intake, and abdominal pain, distension, or cramping. Painful, hard bowel movements are typical, and parents commonly report withholding behaviors (such as posturing, leg-crossing, or hiding during the urge to defecate). Fecal incontinence (encopresis) can develop when constipation is severe, from overflow of liquid stool around a retained fecal mass. On examination, palpable stool may be felt in the abdomen, and rectal examination often reveals an enlarged rectum with stool palpable just beyond the anal verge, and typically an open, non-tight anal tone. Supporting findings for a functional (rather than organic) diagnosis include onset after infancy, clear stool-withholding behavior, absence of red flags, and episodic passage of large-caliber stools."
  )},
  {"title": "Diagnostics", "content": (
   "Functional constipation is frequently diagnosed by history and physical examination alone, supported by therapeutic response to a comprehensive treatment regimen; digital rectal examination is often, though not always, useful. Distinguishing functional constipation from Hirschsprung disease is the key diagnostic task in ambiguous cases: functional constipation is rare in infancy, delayed passage of meconium is rare, encopresis is common, stool caliber is very large, failure to thrive is rare, abdominal distension is variable, painful defecation is common, stool is palpable in the rectal vault, and anal tone is open/distended. Hirschsprung disease, by contrast, is common in infancy, delayed meconium passage (over 48 hours) is common, encopresis is unusual, stool is small and ribbon-like, failure to thrive and abdominal distension are common, painful defecation and rectal stool are rare, and anal tone is tight with an empty rectal vault; a barium enema in Hirschsprung disease shows a narrow distal segment with a dilated proximal segment (versus a generally dilated rectum in functional constipation), motility is abnormal, and rectal biopsy shows absent ganglion cells (versus normal ganglion cells in functional constipation). Other organic causes to distinguish include cystic fibrosis (respiratory problems, failure to thrive), cow's milk allergy (personal/family atopy history, eczema), and anatomic malformations such as anal stenosis (ribbon stools, tight anal canal)."
  )},
  {"title": "Differential diagnosis", "content": (
   "Beyond Hirschsprung disease, organic causes of constipation to consider include anal stenosis or imperforate anus, congenital megacolon, chronic intestinal pseudo-obstruction, cystic fibrosis, and cow's milk protein allergy. Functional non-retentive fecal incontinence (FNRFI) is a distinct entity accounting for only about 5-10% of children with fecal incontinence, in which children pass entire, normal-caliber stools in inappropriate places (at least once a month) without withholding behavior, pain, or difficulty defecating - unlike the constipation-associated (retentive) fecal incontinence that accounts for the vast majority of cases. New-onset painful defecation or stool withholding should also prompt consideration of streptococcal perianal disease or sexual abuse as a precipitant. Functional constipation can additionally be associated with dysfunctional urinary voiding and recurrent urinary tract infections, which should be screened for."
  )},
  {"title": "Treatment", "content": (
   "Management combines regular bowel/toilet training, dietary modification, sitz baths to relax the perineal muscles, and local lubricants to reduce pain on defecation - together relieving constipation in an estimated 90% of children with functional constipation. Stimulant laxatives such as senna or bisacodyl are generally avoided as first-line therapy and reserved for refractory cases. Children with associated behavioral problems benefit from counseling and behavioral modification therapy with a child psychologist. Successful long-term management depends heavily on adequate treatment duration and family education/counseling, since maintenance therapy may be required for a long time, even years; insufficient treatment duration is the most common cause of treatment failure and relapse, often stemming from reluctance by both parents and physicians to continue laxative therapy for a sufficient period. Relapses are common, and the problem can persist into adolescence if not managed appropriately - underscoring the need for sustained follow-up rather than stopping treatment as soon as symptoms initially improve."
  )}
 ],
 "clinical": [
  {"title": "Approach at the bedside", "content": (
   "In a child with infrequent, painful, or large-caliber stools, apply the diagnostic criteria directly: at least 1 month with 2 or more of infrequent defecation (≤2/week), stool retention history, painful/hard bowel movements, large-diameter stools, or a palpable rectal fecal mass (plus, in toilet-trained children, weekly fecal incontinence or toilet-obstructing stool size). Take a history targeting onset (after infancy favors functional; infancy-onset or delayed meconium passage favors Hirschsprung disease) and ask specifically about withholding behaviors and any recent painful precipitant, including screening for streptococcal perianal disease or, when the history raises concern, sexual abuse.\n\nOn exam, check for abdominal stool and perform a rectal exam: an enlarged, stool-filled rectum with open anal tone supports functional constipation, while a tight anal canal with an empty rectal vault (especially with a history of delayed meconium passage or failure to thrive) should raise concern for Hirschsprung disease and prompt referral for further workup (barium enema, anorectal manometry, rectal biopsy) rather than empiric constipation treatment. Once functional constipation is confirmed, start regular bowel/toilet training, dietary modification, sitz baths, and lubricants, reserving stimulant laxatives (senna, bisacodyl) for refractory cases, and counsel the family explicitly that treatment often needs to continue for months to years - stopping too soon is the most common reason for relapse. Screen for and address associated dysfunctional voiding/recurrent UTIs, and refer for behavioral counseling when withholding behavior or toileting anxiety is prominent."
  )}
 ]
}

with open("/tmp/functional-constipation.article.json", "w") as f:
    json.dump(data, f, indent=1)
print("written")
