Give me one page like the image I attached but the same for constipation one page
cd /home/daytona/workspace/attachments/784a9051-1acb-4564-8c9a-daa6b9021116 && python3 -c " import pdfplumber with pdfplumber.open('Constipation_OSCE_Booklet (1).pdf') as pdf: print(f'Pages: {len(pdf.pages)}') for i, page in enumerate(pdf.pages): print(f'--- PAGE {i+1} ---') print(page.extract_text()) print() "
mkdir -p /home/daytona/workspace/constipation-cheatsheet
~/constipation-cheatsheet/constipation_cheatsheet.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Constipation — Last Minute Revision + OSCE Cheat Sheet</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Arial:wght@400;700&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 7.2px;
background: #fff;
color: #111;
width: 210mm;
min-height: 297mm;
padding: 5mm 5mm;
}
/* ── HEADER ── */
.main-title {
text-align: center;
font-size: 13px;
font-weight: bold;
color: #1a1a2e;
letter-spacing: 0.5px;
margin-bottom: 1px;
}
.sub-title {
text-align: center;
font-size: 7.5px;
color: #c8860a;
font-weight: bold;
margin-bottom: 3px;
}
/* ── LAYOUT ── */
.two-col {
display: flex;
gap: 4px;
}
.col-left { flex: 0 0 48%; }
.col-right { flex: 0 0 52%; }
/* ── SECTION BOXES ── */
.section {
margin-bottom: 4px;
}
.section-header {
color: #fff;
font-weight: bold;
font-size: 7.8px;
padding: 2px 5px;
text-align: center;
letter-spacing: 0.3px;
}
.bg-navy { background: #1a3a5c; }
.bg-darkblue{ background: #1a2e5c; }
.bg-red { background: #c0392b; }
.bg-teal { background: #0d6b5e; }
.bg-purple { background: #5b2d8e; }
.bg-olive { background: #6b6b1a; }
.bg-orange { background: #b35a00; }
.bg-darkgreen { background: #1a5c2e; }
table {
width: 100%;
border-collapse: collapse;
font-size: 7px;
}
th {
background: #2c3e6b;
color: #fff;
padding: 1.5px 3px;
font-size: 7px;
font-weight: bold;
text-align: left;
border: 0.5px solid #aaa;
}
td {
padding: 1.5px 3px;
border: 0.5px solid #ccc;
vertical-align: top;
line-height: 1.35;
}
tr:nth-child(even) td { background: #f4f7fb; }
tr:nth-child(odd) td { background: #fff; }
/* coloured row highlights */
.row-yellow td { background: #fffacd !important; }
.row-pink td { background: #ffe4e8 !important; }
.row-green td { background: #e4f7e4 !important; }
.row-blue td { background: #ddeeff !important; }
.row-orange td { background: #fff0d9 !important; }
.row-purple td { background: #ede0f7 !important; }
/* sub-headers inside tables */
.tbl-subhead td {
background: #2c6b8a !important;
color: #fff !important;
font-weight: bold;
font-size: 7px;
text-align: center;
}
.tbl-subhead2 td {
background: #4a7c3f !important;
color: #fff !important;
font-weight: bold;
font-size: 7px;
text-align: center;
}
.tbl-subhead3 td {
background: #8a3a2c !important;
color: #fff !important;
font-weight: bold;
font-size: 7px;
text-align: center;
}
.tbl-subhead4 td {
background: #5c3a8a !important;
color: #fff !important;
font-weight: bold;
font-size: 7px;
text-align: center;
}
/* inline content blocks */
.content-box {
padding: 3px 5px;
border: 0.5px solid #ccc;
font-size: 7px;
line-height: 1.4;
}
.content-box ul { padding-left: 10px; }
.content-box li { margin-bottom: 1px; }
/* pearl box */
.pearl {
background: #fff8dc;
border: 1px solid #e6b800;
border-radius: 2px;
padding: 2px 5px;
font-size: 6.8px;
line-height: 1.4;
margin-top: 2px;
}
.pearl strong { color: #7a5c00; }
.red-flag {
background: #fff0f0;
border: 1px solid #c0392b;
border-radius: 2px;
padding: 2px 5px;
font-size: 6.8px;
line-height: 1.4;
margin-top: 2px;
}
.red-flag strong { color: #c0392b; }
/* highlight spans */
.hl-yellow { background: #ffe066; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-pink { background: #ffb3c6; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-green { background: #b3ffb3; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-blue { background: #b3d9ff; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-orange { background: #ffd9a0; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-purple { background: #d9b3ff; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-red { background: #ffb3b3; padding: 0 1px; border-radius: 1px; font-weight: bold; }
b { font-weight: bold; }
.arrow { color: #c0392b; font-weight: bold; }
.sources {
text-align: center;
font-size: 6px;
color: #666;
margin-top: 3px;
border-top: 0.5px solid #ccc;
padding-top: 2px;
}
.section-header-q {
background: #2c6b8a;
color: #fff;
font-weight: bold;
font-size: 7.2px;
padding: 1.5px 4px;
margin-bottom: 1px;
}
.spot-scenario { background: #ddeeff; }
.spot-dx { background: #e8ffe8; }
/* Bristol chart mini */
.bristol td:first-child { font-weight: bold; text-align: center; width: 20px; }
</style>
</head>
<body>
<!-- HEADER -->
<div class="main-title">CONSTIPATION — Last Minute Revision + OSCE Cheat Sheet</div>
<div class="sub-title">Final Year BBS | Bailey & Love · Sleisenger & Fordtran · Kumar & Clark · Oxford Handbook</div>
<!-- TWO COLUMN LAYOUT -->
<div class="two-col">
<!-- ══════════════ LEFT COLUMN ══════════════ -->
<div class="col-left">
<!-- DEFINITION & ROME IV -->
<div class="section">
<div class="section-header bg-navy">DEFINITION & ROME IV CRITERIA</div>
<div class="content-box">
<b>Constipation</b> = ≥2 of the following for <b>≥3 months</b> (onset ≥6 months prior):<br>
• Straining in >25% of defaecations • Hard/lumpy stools (Bristol 1–2) >25%<br>
• Sensation of incomplete evacuation >25% • Anorectal blockage sensation >25%<br>
• Manual manoeuvres to assist >25% • <b><3 spontaneous BM/week</b><br>
<span style="color:#555"><i>PLUS: loose stools rarely present without laxatives; insufficient criteria for IBS</i></span>
</div>
</div>
<!-- CAUSES — SPINE -->
<div class="section">
<div class="section-header bg-darkblue">CAUSES — ‘SPINE’ MNEMONIC</div>
<table>
<tr><th style="width:8px">Letter</th><th style="width:60px">Category</th><th>Key Examples</th></tr>
<tr class="row-blue">
<td><b>S</b></td><td>Structural</td>
<td>Colorectal Ca, anal fissure, stricture, diverticular disease, rectocoele, ext. compression</td>
</tr>
<tr class="row-green">
<td><b>P</b></td><td>Physiological / Dietary</td>
<td>Low fibre, poor fluid intake, immobility, IBS-C, slow transit, pregnancy</td>
</tr>
<tr class="row-orange">
<td><b>I</b></td><td>Iatrogenic (Drugs)</td>
<td><span class="hl-orange">Opioids (#1)</span>, Al/Ca antacids, iron, TCAs, anticholinergics, <span class="hl-yellow">verapamil</span>, ondansetron, antipsychotics</td>
</tr>
<tr class="row-pink">
<td><b>N</b></td><td>Neurological</td>
<td>Parkinson’s, MS, spinal cord injury, autonomic neuropathy, <span class="hl-pink">Hirschsprung’s</span>, cauda equina</td>
</tr>
<tr class="row-yellow">
<td><b>E</b></td><td>Endocrine / Metabolic</td>
<td><span class="hl-yellow">Hypothyroidism (#1 metabolic)</span>, hypercalcaemia, hypokalaemia, diabetes, uraemia</td>
</tr>
</table>
<div class="pearl"><strong>★ OSCE PEARL:</strong> Hypothyroidism + hypercalcaemia = 2 most tested metabolic causes. Always check <b>TFTs & Ca²+</b> in unexplained constipation.</div>
</div>
<!-- RED FLAGS -->
<div class="red-flag">
<strong>⚠ RED FLAGS — 2WW Referral (ABCDE):</strong>
<b>A</b>naemia (IDA) | <b>B</b>leeding PR | <b>C</b>hange in bowel habit >6 wks |
<b>D</b>uration sudden + age >50 | <b>E</b>xtra: weight loss, mass, family Hx CRC
</div>
<!-- HISTORY TAKING -->
<div class="section" style="margin-top:3px">
<div class="section-header bg-teal">OSCE HISTORY — KEY QUESTIONS</div>
<div class="section-header-q">Q1: Character of Constipation</div>
<table>
<tr><th>Ask This</th><th>Clinical Meaning</th></tr>
<tr><td>Frequency <3/week?</td><td>Meets Rome IV criterion</td></tr>
<tr><td>Hard/lumpy (Bristol 1–2)?</td><td>Slow transit</td></tr>
<tr><td>Straining / blockage?</td><td>Pelvic floor dyssynergia</td></tr>
<tr><td>Manual assist needed?</td><td>Severe outlet dysfunction / rectocoele</td></tr>
<tr><td>Acute vs chronic?</td><td>Acute <span class="arrow">→</span> obstruction/Ca; Chronic <span class="arrow">→</span> functional/IBS</td></tr>
<tr class="row-pink"><td><b>Alternating diarrhoea?</b></td><td><span class="hl-pink">IBS-C OR overflow diarrhoea</span> around faecal impaction</td></tr>
<tr class="row-red"><td><b>Blood / mucus?</b></td><td><span class="hl-red">ALARM — CRC, IBD, haemorrhoids, fissure</span></td></tr>
</table>
<div class="section-header-q" style="margin-top:2px">Q2: Associated Symptoms → Diagnosis</div>
<table>
<tr><th>Symptom Cluster</th><th>Think Of…</th></tr>
<tr><td>Pain relieved by defaecation</td><td>IBS-C</td></tr>
<tr class="row-red"><td>Wt loss + rectal bleeding + tenesmus</td><td><span class="hl-red">Colorectal Ca — urgent 2WW</span></td></tr>
<tr><td>Bloating + ribbony stools</td><td>Rectal/sigmoid Ca</td></tr>
<tr class="row-yellow"><td>Fatigue + cold intolerance + wt gain</td><td><span class="hl-yellow">Hypothyroidism → check TSH</span></td></tr>
<tr class="row-orange"><td>Polyuria + polydipsia + bone pain + nausea</td><td><span class="hl-orange">Hypercalcaemia — Bones, Stones, Groans, Moans</span></td></tr>
<tr class="row-pink"><td>Absolute constipation + vomiting + distension</td><td><span class="hl-pink">Bowel obstruction — EMERGENCY</span></td></tr>
<tr><td>Perianal pain + bright red blood on wiping</td><td>Anal fissure → fear reinforces constipation</td></tr>
</table>
<div class="section-header-q" style="margin-top:2px">Q3: Drug History — Key Constipating Drugs</div>
<table>
<tr><th>Drug Class</th><th>Example</th><th>Mechanism</th></tr>
<tr class="row-orange"><td><b>Opioids (#1)</b></td><td>Codeine, morphine</td><td>μ-receptor → ↓ peristalsis + ↑ sphincter tone</td></tr>
<tr><td>Antacids</td><td>Al(OH)³, CaCO³</td><td>Bind water → insoluble salts → hard stool</td></tr>
<tr><td>Iron supplements</td><td>Ferrous sulphate</td><td>Mucosal irritation + hard stool</td></tr>
<tr><td>Anticholinergics</td><td>TCAs, oxybutynin</td><td>↓ ACh → ↓ gut motility</td></tr>
<tr class="row-yellow"><td><b>CCBs</b></td><td>Verapamil > amlodipine</td><td>↓ smooth muscle contraction in gut</td></tr>
<tr><td>5-HT³ antagonists</td><td>Ondansetron</td><td>Block serotonin-mediated peristalsis</td></tr>
</table>
</div>
<!-- EXAMINATION -->
<div class="section">
<div class="section-header bg-olive">CLINICAL EXAMINATION</div>
<table>
<tr class="tbl-subhead"><td colspan="2">ABDOMINAL FINDINGS</td></tr>
<tr><th>Finding</th><th>Diagnosis</th></tr>
<tr><td>Distension</td><td>Obstruction, loaded colon, megacolon</td></tr>
<tr class="row-yellow"><td>Palpable mass LIF</td><td>Loaded sigmoid / faecal impaction</td></tr>
<tr><td>Firm mass, indents on pressure</td><td>Faecal mass (vs tumour)</td></tr>
<tr class="row-red"><td>Hard, fixed, irregular mass</td><td><span class="hl-red">CRC — urgent 2WW</span></td></tr>
<tr><td>Absent / tinkling bowel sounds</td><td>Obstruction / ileus</td></tr>
<tr class="tbl-subhead2"><td colspan="2">DIGITAL RECTAL EXAMINATION (DRE)</td></tr>
<tr class="row-yellow"><td><span class="hl-yellow">Empty rectum</span></td><td><b>Slow transit</b> — stool not reaching rectum</td></tr>
<tr class="row-orange"><td><span class="hl-orange">Loaded rectum</span></td><td><b>Outlet dysfunction / faecal impaction</b></td></tr>
<tr><td>Anterior wall bulge</td><td>Rectocoele (women)</td></tr>
<tr><td>↓ Anal tone</td><td>Rectal prolapse / neurological</td></tr>
<tr><td>↑ Anal tone (tight)</td><td>Anal fissure / dyssynergia</td></tr>
</table>
<div class="pearl"><strong>★ OSCE TIP:</strong> Always offer PR exam. <span class="hl-yellow">Empty rectum → slow transit study.</span> <span class="hl-orange">Loaded rectum → disimpact FIRST, then treat.</span></div>
</div>
</div><!-- end left col -->
<!-- ══════════════ RIGHT COLUMN ══════════════ -->
<div class="col-right">
<!-- INVESTIGATIONS -->
<div class="section">
<div class="section-header bg-darkblue">INVESTIGATIONS QUICK GUIDE</div>
<table>
<tr class="tbl-subhead"><td colspan="3">FIRST-LINE BLOODS</td></tr>
<tr><th>Test</th><th>Looking For</th><th>Clinical Value</th></tr>
<tr><td>FBC</td><td>Hb, MCV, platelets</td><td>IDA (↓Hb, ↓MCV) → occult bleed from CRC / IBD</td></tr>
<tr><td>U&E + Creatinine</td><td>K+, Na+, urea</td><td>Hypokalaemia → constipation; dehydration</td></tr>
<tr class="row-yellow"><td><b>Serum Ca²+</b></td><td>Corrected Ca</td><td>Hypercalcaemia → constipation; check PTH if ↑</td></tr>
<tr class="row-yellow"><td><b>TFTs (TSH/T4)</b></td><td>TSH</td><td>Hypothyroidism — very common, easily treated</td></tr>
<tr><td>Glucose / HbA1c</td><td>Fasting glucose</td><td>Diabetic autonomic neuropathy</td></tr>
<tr><td>CRP / ESR</td><td>Inflammation</td><td>↑ in IBD, CRC, infection</td></tr>
<tr><td>CEA</td><td>Carcinoembryonic Ag</td><td>Raised in CRC — NOT diagnostic alone; for monitoring</td></tr>
<tr class="tbl-subhead"><td colspan="3">IMAGING & SPECIALIST INVESTIGATIONS</td></tr>
<tr><th>Investigation</th><th>When to Order</th><th>What It Shows</th></tr>
<tr><td>AXR (plain film)</td><td>Suspected obstruction / impaction</td><td>Faecal loading, dilated loops (3-6-9 rule)</td></tr>
<tr class="row-blue"><td><b>Colonoscopy</b></td><td>Alarm features, age >50, new-onset, rectal bleeding</td><td>Polyps, Ca, IBD, diverticulosis — <b>GOLD STANDARD</b></td></tr>
<tr><td>CT colonography</td><td>Unable to tolerate colonoscopy / elderly</td><td>Virtual colonoscopy</td></tr>
<tr><td>Colonic transit study</td><td>Chronic constipation</td><td>Radiopaque markers — slow transit vs outlet; normal <5 days</td></tr>
<tr class="row-purple"><td>Anorectal manometry</td><td>Pelvic floor dysfunction</td><td>Sphincter pressures, RAIR, rectal sensation</td></tr>
<tr><td>Balloon expulsion test</td><td>Outlet dysfunction screen</td><td>Normal <1 min; prolonged → dyssynergia</td></tr>
<tr><td>Defaecating proctogram</td><td>Straining, incomplete evacuation</td><td>Rectocoele, intussusception, paradoxical puborectalis</td></tr>
<tr><td>Suction rectal biopsy</td><td>Suspected Hirschsprung’s</td><td>Absence of ganglion cells — <b>GOLD STANDARD</b></td></tr>
</table>
<div class="pearl"><strong>★ OSCE PEARL:</strong> Most important initial investigation in >50 with alarm features = <b>colonoscopy</b> to exclude CRC.</div>
</div>
<!-- MANAGEMENT -->
<div class="section">
<div class="section-header bg-teal">MANAGEMENT — LAXATIVE LADDER + SPECIFIC CAUSES</div>
<table>
<tr class="tbl-subhead2"><td colspan="4">STEP 1 — LIFESTYLE (ALWAYS FIRST)</td></tr>
<tr><td colspan="4" style="font-size:6.8px; padding:2px 4px; background:#f0fff0">
<b>Fibre</b> 25–30 g/day | <b>Fluids</b> 1.5–2 L/day | <b>Exercise</b> (stimulates colonic motility) |
<b>Toilet routine</b> after meals (gastrocolic reflex) | <b>Footstool</b> positioning | <b>Review & stop</b> constipating drugs
</td></tr>
<tr class="tbl-subhead2"><td colspan="4">STEP 2 — LAXATIVES</td></tr>
<tr><th>Class</th><th>Drug</th><th>Mechanism</th><th>Key Notes</th></tr>
<tr class="row-green"><td><b>Bulk-forming</b><br>(1st line mild)</td><td>Ispaghula husk (Fybogel)</td><td>↑ stool bulk → peristalsis</td><td>Take with ≥200 mL water; takes 2–3 days; <span class="hl-red">avoid in impaction</span></td></tr>
<tr class="row-blue"><td><b>Osmotic</b><br>(1st line opioid)</td><td>Macrogol (Movicol), Lactulose</td><td>Draw water into bowel by osmosis</td><td>Macrogol preferred (less bloating); lactulose causes flatulence</td></tr>
<tr class="row-orange"><td><b>Stimulant</b><br>(short-term)</td><td>Senna, Bisacodyl</td><td>Stimulate enteric nerves → ↑ peristalsis</td><td>Works 6–12 hrs; <span class="hl-orange">avoid long-term → atonic colon</span></td></tr>
<tr><td>Stool softener</td><td>Docusate sodium</td><td>Detergent → softens stool surface</td><td>Mild; useful post-op / anal fissure</td></tr>
<tr class="row-pink"><td>Rectal agents</td><td>Phosphate enema, Glycerol suppositories</td><td>Local osmotic + stimulant</td><td>Pre-procedure, impaction; glycerol for outlet dysfunction</td></tr>
<tr class="row-purple"><td><b>Secretagogue</b></td><td>Linaclotide, Lubiprostone</td><td>↑ intestinal Cl² secretion → stool fluidity</td><td>IBS-C & chronic idiopathic; specialist initiation</td></tr>
<tr class="row-yellow"><td><b>Prokinetic</b></td><td>Prucalopride</td><td>5-HT&sup4; agonist → ↑ colonic motility</td><td>Chronic idiopathic after 2 laxatives failed; specialist</td></tr>
</table>
<div class="pearl"><strong>★ LAXATIVE LADDER:</strong> Bulk-forming → Osmotic (macrogol) → Stimulant → Combination → Secretagogue / Prucalopride.<br>
In <span class="hl-orange">OPIOID-induced</span> constipation: START with <b>osmotic + stimulant together</b>. Bulk-forming alone NOT effective. <b>Methylnaltrexone SC</b> if refractory.</div>
<table style="margin-top:3px">
<tr class="tbl-subhead3"><td colspan="2">SPECIFIC CAUSE MANAGEMENT</td></tr>
<tr><th>Cause</th><th>Specific Treatment</th></tr>
<tr class="row-yellow"><td>Hypothyroidism</td><td>Levothyroxine replacement → constipation resolves as euthyroid state restored</td></tr>
<tr class="row-orange"><td>Hypercalcaemia</td><td>IV 0.9% NaCl + IV bisphosphonate (zoledronate); treat underlying cause</td></tr>
<tr><td>Hypokalaemia</td><td>IV / oral K+ replacement; address cause</td></tr>
<tr class="row-orange"><td>Opioid-induced</td><td>Osmotic + stimulant; methylnaltrexone SC if refractory</td></tr>
<tr><td>Anal fissure</td><td>Topical GTN 0.4% / diltiazem 2% → relax internal sphincter; botulinum if fails; lateral sphincterotomy if chronic</td></tr>
<tr class="row-pink"><td>Hirschsprung’s</td><td>Surgical pull-through (Swenson / Soave) — resection of aganglionic segment</td></tr>
<tr class="row-purple"><td>Slow transit (refractory)</td><td>Prucalopride (5-HT&sup4;); subtotal colectomy + ileorectal anastomosis if all else fails</td></tr>
<tr><td>Pelvic floor dyssynergia</td><td><b>Biofeedback therapy — FIRST-LINE</b>; retrains paradoxical puborectalis contraction</td></tr>
<tr><td>Faecal impaction</td><td>Manual evacuation under sedation if needed + phosphate enemas + macrogol 8 sachets/day</td></tr>
<tr class="row-blue"><td>IBS-C</td><td>Lifestyle + macrogol + linaclotide (NICE) + low-FODMAP diet + psychological support</td></tr>
</table>
</div>
<!-- OSCE VIVA Q&A + BRISTOL + SPECIAL SITUATIONS in 3-col mini layout -->
<div style="display:flex; gap:4px; margin-top:2px">
<!-- OSCE VIVA -->
<div style="flex:1">
<div class="section-header bg-purple" style="font-size:7.2px">OSCE VIVA Q&A</div>
<table>
<tr><th>Examiner Asks…</th><th>Your Answer</th></tr>
<tr><td>Define constipation (Rome IV)?</td><td><3 BM/week OR ≥2 symptoms in >25% defaecations</td></tr>
<tr class="row-orange"><td>Most common drug cause?</td><td><span class="hl-orange">Opioids</span> → ↓ peristalsis via μ-receptors</td></tr>
<tr class="row-yellow"><td>Top 2 metabolic causes?</td><td><span class="hl-yellow">Hypothyroidism</span> + <span class="hl-orange">Hypercalcaemia</span></td></tr>
<tr><td>First investigation, new >50?</td><td>FBC, TFTs, Ca²+ → colonoscopy if alarm features</td></tr>
<tr class="row-yellow"><td>Empty rectum on DRE?</td><td><span class="hl-yellow">Slow transit</span> — transit study next</td></tr>
<tr class="row-orange"><td>Loaded rectum on DRE?</td><td><span class="hl-orange">Outlet dysfunction / impaction</span> — disimpact first</td></tr>
<tr class="row-pink"><td>What is overflow diarrhoea?</td><td>Liquid leaks around impaction — <b>DO NOT give antidiarrhoeals; disimpact first</b></td></tr>
<tr><td>Best laxative for opioid Ca?</td><td>Osmotic (macrogol) + stimulant (senna)</td></tr>
<tr class="row-purple"><td>What is prucalopride?</td><td><span class="hl-purple">5-HT&sup4; agonist prokinetic</span> — chronic idiopathic, after 2 laxatives failed</td></tr>
<tr><td>Tx for pelvic floor dyssynergia?</td><td>Biofeedback therapy — first-line</td></tr>
<tr class="row-pink"><td>Hirschsprung’s gold standard Dx?</td><td><span class="hl-pink">Suction rectal biopsy</span> — absent ganglion cells + absent RAIR</td></tr>
<tr><td>Barium enema in Hirschsprung’s?</td><td>Transition zone: narrow aganglionic segment → dilated proximal colon</td></tr>
</table>
</div>
<!-- Bristol + Special Situations -->
<div style="flex:0 0 38%">
<div class="section-header bg-darkgreen" style="font-size:7.2px">BRISTOL STOOL CHART</div>
<table class="bristol">
<tr><th>#</th><th>Appearance</th><th>Meaning</th></tr>
<tr class="row-red"><td>1</td><td>Separate hard lumps</td><td>Severe constipation</td></tr>
<tr class="row-orange"><td>2</td><td>Lumpy sausage</td><td>Constipation</td></tr>
<tr><td>3</td><td>Cracked sausage</td><td>Normal–slow</td></tr>
<tr class="row-green"><td>4</td><td>Smooth snake</td><td><b>IDEAL</b></td></tr>
<tr><td>5</td><td>Soft blobs</td><td>Lacking fibre</td></tr>
<tr class="row-pink"><td>6</td><td>Fluffy / mushy</td><td>Mild diarrhoea</td></tr>
<tr class="row-red"><td>7</td><td>Watery</td><td>Diarrhoea</td></tr>
</table>
<div class="pearl" style="margin-top:2px"><b>Bristol 1–2</b> = constipation. <b>6–7</b> = diarrhoea. <b>4</b> = ideal. Ask patient to describe stool in OSCE.</div>
<div class="section-header bg-orange" style="font-size:7.2px; margin-top:3px">SPECIAL SITUATIONS</div>
<table>
<tr class="tbl-subhead"><td colspan="2">ELDERLY</td></tr>
<tr><td colspan="2" style="font-size:6.7px; padding:2px 3px; background:#fff8f0">Polypharmacy + immobility + dehydration + low fibre.<br>
Risk of faecal impaction → <span class="hl-pink">overflow (spurious) diarrhoea</span> — <b>DO NOT treat with antidiarrhoeals</b>.<br>
PR exam essential — hard stool confirms impaction.</td></tr>
<tr class="tbl-subhead2"><td colspan="2">PREGNANCY</td></tr>
<tr><td colspan="2" style="font-size:6.7px; padding:2px 3px; background:#f0fff0">Progesterone ↓ gut motility + iron supplements.<br>
<b>Safe:</b> Ispaghula husk, lactulose, macrogol (short-term).<br>
<b>Avoid:</b> Senna in 1st trimester; castor oil; mineral oils.</td></tr>
</table>
</div>
</div>
</div><!-- end right col -->
</div><!-- end two-col -->
<div class="sources">Sources: Bailey & Love · Sleisenger & Fordtran · Kumar & Clark · Oxford Handbook of Clinical Medicine · Rome IV Criteria</div>
</body>
</html>
cd /home/daytona/workspace/constipation-cheatsheet && python3 -c " import subprocess result = subprocess.run([ 'wkhtmltopdf', '--page-size', 'A4', '--orientation', 'Portrait', '--margin-top', '4mm', '--margin-bottom', '4mm', '--margin-left', '4mm', '--margin-right', '4mm', '--enable-local-file-access', '--zoom', '1.0', 'constipation_cheatsheet.html', 'constipation_cheatsheet.pdf' ], capture_output=True, text=True) print('STDOUT:', result.stdout) print('STDERR:', result.stderr) print('Return code:', result.returncode) "
which chromium-browser chromium google-chrome playwright 2>/dev/null; python3 -c "import playwright" 2>/dev/null && echo "playwright ok"; python3 -c "from weasyprint import HTML" 2>/dev/null && echo "weasyprint ok"; which libreoffice 2>/dev/null
cd /home/daytona/workspace/constipation-cheatsheet && chromium --headless --disable-gpu --no-sandbox --print-to-pdf=constipation_cheatsheet.pdf --print-to-pdf-no-header "file:///home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html" 2>&1; ls -lh constipation_cheatsheet.pdf 2>/dev/null || echo "PDF not created"
cd /home/daytona/workspace/constipation-cheatsheet && python3 -c " from pypdf import PdfReader r = PdfReader('constipation_cheatsheet.pdf') print(f'Pages: {len(r.pages)}') for i, p in enumerate(r.pages): print(f'Page {i+1}: {p.mediabox.width:.0f} x {p.mediabox.height:.0f} pts') "
~/constipation-cheatsheet/constipation_cheatsheet.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html'
~/constipation-cheatsheet/constipation_cheatsheet.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html'
~/constipation-cheatsheet/constipation_cheatsheet.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html'
~/constipation-cheatsheet/constipation_cheatsheet.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html'
~/constipation-cheatsheet/constipation_cheatsheet.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html'
~/constipation-cheatsheet/constipation_cheatsheet.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html'
~/constipation-cheatsheet/constipation_cheatsheet.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html'
cd /home/daytona/workspace/constipation-cheatsheet && chromium --headless --disable-gpu --no-sandbox --print-to-pdf=constipation_cheatsheet.pdf --print-to-pdf-no-header "file:///home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html" 2>/dev/null; python3 -c " from pypdf import PdfReader r = PdfReader('constipation_cheatsheet.pdf') print(f'Pages: {len(r.pages)}') "
cd /home/daytona/workspace/constipation-cheatsheet && chromium --headless --disable-gpu --no-sandbox \ --print-to-pdf=constipation_cheatsheet.pdf \ --print-to-pdf-no-header \ --no-pdf-header-footer \ "file:///home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html" \ 2>/dev/null # Try with explicit paper size via virtual printer settings python3 -c " import subprocess # Use --print-to-pdf with page size flag r = subprocess.run([ 'chromium', '--headless', '--disable-gpu', '--no-sandbox', '--print-to-pdf=constipation_final.pdf', '--print-to-pdf-no-header', '--virtual-time-budget=2000', 'file:///home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.html' ], capture_output=True, text=True) print(r.returncode, r.stderr[-200:] if r.stderr else '') " ls -lh constipation_cheatsheet.pdf 2>/dev/null
python3 -c " from pypdf import PdfReader r = PdfReader('/home/daytona/workspace/constipation-cheatsheet/constipation_cheatsheet.pdf') print(f'Pages: {len(r.pages)}') for i,p in enumerate(r.pages): print(f' Page {i+1}: {p.mediabox.width:.0f}x{p.mediabox.height:.0f} pts') "
Okay mkaw ot 2 pate no need t0 squeeze the contents make sure all of that mentioned
~/constipation-cheatsheet/constipation_2page.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Constipation — Last Minute Revision + OSCE Cheat Sheet</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 8.5px;
background: #fff;
color: #111;
width: 210mm;
padding: 6mm 6mm;
}
/* ── PAGE BREAK ── */
.page-break { page-break-after: always; padding-bottom: 6mm; }
/* ── HEADER ── */
.main-title {
text-align: center;
font-size: 15px;
font-weight: bold;
color: #1a1a2e;
letter-spacing: 0.6px;
margin-bottom: 2px;
}
.sub-title {
text-align: center;
font-size: 8px;
color: #c8860a;
font-weight: bold;
margin-bottom: 5px;
}
.page-label {
text-align: center;
font-size: 7.5px;
color: #555;
margin-bottom: 4px;
font-style: italic;
}
/* ── TWO-COLUMN LAYOUT ── */
.two-col { display: flex; gap: 6px; }
.col-left { flex: 0 0 48%; }
.col-right { flex: 1; }
/* ── SECTION BOXES ── */
.section { margin-bottom: 5px; }
.section-header {
color: #fff;
font-weight: bold;
font-size: 8.5px;
padding: 3px 6px;
text-align: center;
letter-spacing: 0.3px;
}
.bg-navy { background: #1a3a5c; }
.bg-darkblue { background: #1a2e5c; }
.bg-red { background: #c0392b; }
.bg-teal { background: #0d6b5e; }
.bg-purple { background: #5b2d8e; }
.bg-olive { background: #5a5a1a; }
.bg-orange { background: #b35a00; }
.bg-darkgreen{ background: #1a5c2e; }
.bg-maroon { background: #7a1a2e; }
/* ── TABLES ── */
table {
width: 100%;
border-collapse: collapse;
font-size: 8px;
}
th {
background: #2c3e6b;
color: #fff;
padding: 2px 4px;
font-size: 8px;
font-weight: bold;
text-align: left;
border: 0.5px solid #aaa;
}
td {
padding: 2px 4px;
border: 0.5px solid #ccc;
vertical-align: top;
line-height: 1.4;
}
tr:nth-child(even) td { background: #f4f7fb; }
tr:nth-child(odd) td { background: #fff; }
/* coloured row highlights */
.row-yellow td { background: #fffacd !important; }
.row-pink td { background: #ffe4e8 !important; }
.row-green td { background: #e4f7e4 !important; }
.row-blue td { background: #ddeeff !important; }
.row-orange td { background: #fff0d9 !important; }
.row-purple td { background: #ede0f7 !important; }
.row-red td { background: #ffe0e0 !important; }
/* sub-header rows inside tables */
.tbl-sub td { background: #2c6b8a !important; color:#fff !important; font-weight:bold; font-size:8px; text-align:center; }
.tbl-sub2 td { background: #4a7c3f !important; color:#fff !important; font-weight:bold; font-size:8px; text-align:center; }
.tbl-sub3 td { background: #8a3a2c !important; color:#fff !important; font-weight:bold; font-size:8px; text-align:center; }
.tbl-sub4 td { background: #5c3a8a !important; color:#fff !important; font-weight:bold; font-size:8px; text-align:center; }
/* ── CONTENT BOX ── */
.content-box {
padding: 3px 5px;
border: 0.5px solid #ccc;
font-size: 8px;
line-height: 1.45;
}
/* ── PEARL / RED-FLAG ── */
.pearl {
background: #fff8dc;
border: 1px solid #e6b800;
border-radius: 2px;
padding: 2.5px 5px;
font-size: 7.8px;
line-height: 1.4;
margin-top: 3px;
}
.pearl strong { color: #7a5c00; }
.red-flag {
background: #fff0f0;
border: 1.5px solid #c0392b;
border-radius: 2px;
padding: 2.5px 5px;
font-size: 7.8px;
line-height: 1.4;
margin-top: 3px;
}
.red-flag strong { color: #c0392b; }
/* ── Q-HEADER INSIDE HISTORY ── */
.q-head {
background: #2c6b8a;
color: #fff;
font-weight: bold;
font-size: 7.8px;
padding: 1.5px 4px;
margin: 3px 0 1px 0;
}
/* ── HIGHLIGHT SPANS ── */
.hl-yellow { background: #ffe066; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-pink { background: #ffb3c6; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-green { background: #b3ffb3; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-blue { background: #b3d9ff; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-orange { background: #ffd9a0; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-purple { background: #d9b3ff; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.hl-red { background: #ffb3b3; padding: 0 1px; border-radius: 1px; font-weight: bold; }
.sources {
text-align: center;
font-size: 7px;
color: #666;
margin-top: 4px;
border-top: 0.5px solid #ccc;
padding-top: 3px;
}
</style>
</head>
<body>
<!-- ═══════════════════════════════════════════════════════════
PAGE 1
═══════════════════════════════════════════════════════════ -->
<div class="page-break">
<div class="main-title">CONSTIPATION — Last Minute Revision + OSCE Cheat Sheet</div>
<div class="sub-title">Final Year BBS | Bailey & Love · Sleisenger & Fordtran · Kumar & Clark · Oxford Handbook of Clinical Medicine</div>
<div class="page-label">Page 1 of 2 — Definition · Causes · History · Examination · Investigations</div>
<div class="two-col">
<!-- ════════ LEFT ════════ -->
<div class="col-left">
<!-- DEFINITION -->
<div class="section">
<div class="section-header bg-navy">DEFINITION & ROME IV CRITERIA</div>
<div class="content-box">
<b>Constipation (Rome IV)</b> = ≥2 of the following present for <b>≥3 months</b>, symptom onset ≥6 months prior:<br>
• Straining during >25% of defaecations<br>
• Lumpy or hard stools (Bristol type 1–2) in >25%<br>
• Sensation of incomplete evacuation in >25%<br>
• Sensation of anorectal obstruction/blockage in >25%<br>
• Manual manoeuvres to facilitate defaecation in >25%<br>
• <b>Fewer than 3 spontaneous bowel movements per week</b><br>
<span style="color:#555"><i>PLUS: Loose stools rarely present without laxatives; insufficient criteria for IBS</i></span>
</div>
</div>
<!-- CAUSES -->
<div class="section">
<div class="section-header bg-darkblue">CAUSES — ‘SPINE’ MNEMONIC</div>
<table>
<tr><th style="width:14px">Letter</th><th style="width:90px">Category</th><th>Key Examples</th></tr>
<tr class="row-blue">
<td><b>S</b></td><td>Structural</td>
<td>Colorectal Ca, anal fissure, stricture, diverticular disease, pelvic organ prolapse, rectocoele, external compression</td>
</tr>
<tr class="row-green">
<td><b>P</b></td><td>Physiological / Dietary</td>
<td>Low fibre intake, poor fluid intake, immobility, IBS-C, slow transit constipation, pregnancy</td>
</tr>
<tr class="row-orange">
<td><b>I</b></td><td>Iatrogenic (Drugs)</td>
<td><span class="hl-orange">Opioids (#1)</span>, antacids (Al/Ca), iron tablets, TCAs, anticholinergics, <span class="hl-yellow">CCBs (verapamil)</span>, ondansetron, antipsychotics</td>
</tr>
<tr class="row-pink">
<td><b>N</b></td><td>Neurological</td>
<td>Parkinson’s disease, multiple sclerosis, spinal cord injury, autonomic neuropathy, <span class="hl-pink">Hirschsprung’s disease</span>, cauda equina</td>
</tr>
<tr class="row-yellow">
<td><b>E</b></td><td>Endocrine / Metabolic</td>
<td><span class="hl-yellow">Hypothyroidism (#1 metabolic)</span>, hypercalcaemia, hypokalaemia, diabetes, uraemia, pregnancy</td>
</tr>
</table>
<div class="pearl"><strong>★ OSCE PEARL:</strong> Hypothyroidism & hypercalcaemia = the 2 most exam-tested metabolic causes. Always check <b>TFTs & serum Ca²+</b> in unexplained constipation — both are easily reversible.</div>
<div class="red-flag"><strong>⚠ RED FLAG ALARM FEATURES — urgent colonoscopy / 2WW referral:</strong><br>
Age >50 with new-onset constipation • Rectal bleeding • Unintentional weight loss • Iron-deficiency anaemia • Palpable abdominal/rectal mass • Family Hx of CRC • Change in bowel habit >6 weeks</div>
</div>
<!-- HISTORY -->
<div class="section">
<div class="section-header bg-teal">HISTORY TAKING — CONSTIPATION</div>
<div class="content-box" style="font-size:8px">
<b>Opening:</b> “Can you tell me about your bowel habit? How often are you opening your bowels? How long has this been going on?”
</div>
<div class="q-head">1. CHARACTER OF CONSTIPATION</div>
<table>
<tr><th>Ask This</th><th>Clinical Meaning</th></tr>
<tr><td>How many times per week?</td><td><3/week = meets Rome IV frequency criterion</td></tr>
<tr><td>Stool consistency — hard/lumpy?</td><td>Bristol 1–2 = constipation; describes transit time</td></tr>
<tr><td>Straining / feeling of blockage?</td><td>Pelvic floor dyssynergia / outlet dysfunction</td></tr>
<tr><td>Need to manually assist?</td><td>Severe outlet dysfunction, large rectocoele</td></tr>
<tr><td>Acute onset vs chronic (years)?</td><td>Acute: think obstruction or malignancy; Chronic: functional/IBS</td></tr>
<tr class="row-pink"><td><b>Alternating with diarrhoea?</b></td><td><span class="hl-pink">IBS-C</span> OR <span class="hl-red">overflow diarrhoea around faecal impaction</span></td></tr>
<tr class="row-red"><td><b>Blood or mucus in stool?</b></td><td><span class="hl-red">ALARM — CRC, IBD, haemorrhoids, fissure</span></td></tr>
<tr><td>Sensation of incomplete emptying?</td><td>Rome IV criterion; also IBS-C, rectocoele</td></tr>
</table>
<div class="q-head">2. ASSOCIATED SYMPTOMS</div>
<table>
<tr><th>Symptom</th><th>Think of…</th></tr>
<tr><td>Abdominal pain relieved by defaecation</td><td>IBS-C</td></tr>
<tr class="row-red"><td>Weight loss + rectal bleeding + tenesmus</td><td><span class="hl-red">Colorectal carcinoma — urgent 2WW</span></td></tr>
<tr><td>Bloating + ribbony stools</td><td>Rectal / sigmoid Ca</td></tr>
<tr class="row-yellow"><td>Fatigue + cold intolerance + weight gain</td><td><span class="hl-yellow">Hypothyroidism → check TSH</span></td></tr>
<tr class="row-orange"><td>Polyuria + polydipsia + bone pain + nausea</td><td><span class="hl-orange">Hypercalcaemia — ‘Bones, Stones, Groans, Moans’</span></td></tr>
<tr class="row-pink"><td>Absolute constipation + vomiting + distension</td><td><span class="hl-pink">Bowel obstruction — EMERGENCY</span></td></tr>
<tr><td>Perianal pain + bright red blood on wiping</td><td>Anal fissure → fear of defaecation reinforces constipation</td></tr>
<tr><td>Neurological symptoms (weakness / sensory loss)</td><td>Spinal cord pathology — cauda equina, MS</td></tr>
</table>
<div class="q-head">3. DRUG HISTORY — KEY CONSTIPATING DRUGS</div>
<table>
<tr><th>Drug Class</th><th>Example</th><th>Mechanism</th></tr>
<tr class="row-orange"><td><b>Opioids (#1 cause)</b></td><td>Codeine, morphine, tramadol</td><td>μ-receptor agonist → ↓ peristalsis + ↑ sphincter tone</td></tr>
<tr><td>Antacids</td><td>Al(OH)³, CaCO³ (Rennies)</td><td>Bind water + form insoluble salts → hard stool</td></tr>
<tr><td>Iron supplements</td><td>Ferrous sulphate</td><td>Direct mucosal irritation + forms hard stool</td></tr>
<tr><td>Anticholinergics</td><td>TCAs, antihistamines, oxybutynin</td><td>↓ acetylcholine → ↓ gut motility</td></tr>
<tr class="row-yellow"><td><b>Calcium channel blockers</b></td><td>Verapamil > amlodipine</td><td>↓ smooth muscle contraction in gut</td></tr>
<tr><td>5-HT³ antagonists</td><td>Ondansetron, granisetron</td><td>Block serotonin-mediated peristalsis</td></tr>
<tr><td>Antipsychotics</td><td>Clozapine, olanzapine</td><td>Anticholinergic + autonomic effects</td></tr>
</table>
<div class="pearl"><strong>★ OSCE PEARL:</strong> In any patient on opioids — use <b>osmotic laxative (macrogol) PLUS stimulant (senna)</b>. Bulk-forming agents alone are insufficient. Consider <b>methylnaltrexone SC</b> if refractory.</div>
</div>
</div><!-- end left col P1 -->
<!-- ════════ RIGHT ════════ -->
<div class="col-right">
<!-- SOCIAL + PMH -->
<div class="section">
<div class="section-header bg-olive">4. SOCIAL & PAST MEDICAL HISTORY</div>
<table>
<tr class="tbl-sub"><td colspan="2">SOCIAL HISTORY</td></tr>
<tr><th>Factor</th><th>Significance</th></tr>
<tr><td>Diet — fibre intake?</td><td>Target 25–30 g/day; ask about fruit, veg, wholegrains</td></tr>
<tr><td>Fluid intake?</td><td>1.5–2 L/day essential — fibre does not work without water</td></tr>
<tr><td>Physical activity?</td><td>Sedentary lifestyle → ↓ colonic motility</td></tr>
<tr class="row-orange"><td>Pregnancy?</td><td>Progesterone ↓ gut motility; iron supplements compound this</td></tr>
<tr><td>Occupation / Stress?</td><td>IBS-C associated with anxiety, stress, psychological factors</td></tr>
<tr><td>Laxative use?</td><td>Long-term stimulant laxatives → atonic/cathartic colon</td></tr>
<tr><td>Mobility?</td><td>Institutionalised/bed-bound → ↓ peristalsis; constipation universal</td></tr>
<tr class="tbl-sub"><td colspan="2">PAST MEDICAL HISTORY</td></tr>
<tr><td colspan="2" style="font-size:7.8px; line-height:1.45; background:#fafafa">
Previous colorectal surgery / hysterectomy → adhesions, pelvic nerve damage<br>
Known IBD, diverticular disease, CRC | Hypothyroidism, DM, hypercalcaemia, renal disease<br>
Depression / eating disorders (anorexia → extreme constipation)<br>
<span class="hl-pink">Childhood onset → consider Hirschsprung’s</span> (no ganglion cells in distal bowel)<br>
Spinal cord injury, Parkinson’s, MS → neurogenic bowel
</td></tr>
</table>
<div class="content-box" style="margin-top:2px; font-size:7.8px">
<b>6. FAMILY HISTORY:</b> First-degree relative with CRC or polyps → ↑ CRC risk → earlier colonoscopy | HNPCC / Lynch syndrome → genetic testing
</div>
</div>
<!-- EXAMINATION -->
<div class="section">
<div class="section-header bg-maroon">CLINICAL EXAMINATION — CONSTIPATION</div>
<table>
<tr class="tbl-sub3"><td colspan="2">A. GENERAL INSPECTION</td></tr>
<tr><th>Finding</th><th>Significance</th></tr>
<tr><td>Weight / BMI: weight loss</td><td>Alarm (Ca); weight gain + fatigue → hypothyroidism</td></tr>
<tr><td>Pallor (conjunctival)</td><td>Iron-deficiency anaemia from occult blood loss (CRC)</td></tr>
<tr class="row-yellow"><td>Thyroid signs</td><td>Goitre, bradycardia, dry skin, coarse hair, periorbital oedema → hypothyroidism</td></tr>
<tr class="row-orange"><td>Hypercalcaemia signs</td><td>Confusion, weakness, polyuria — ‘Bones, Stones, Groans, Moans’</td></tr>
<tr><td>Parkinson’s features</td><td>Tremor, rigidity, bradykinesia → neurogenic constipation</td></tr>
</table>
<table style="margin-top:3px">
<tr class="tbl-sub3"><td colspan="2">B. ABDOMINAL EXAMINATION</td></tr>
<tr><th>Finding</th><th>Diagnosis to Consider</th></tr>
<tr><td>Distension</td><td>Obstruction, ileus, loaded colon, megacolon</td></tr>
<tr class="row-yellow"><td>Palpable mass LIF (left iliac fossa)</td><td>Loaded sigmoid colon / faecal impaction</td></tr>
<tr><td>Firm mass, indents on pressure</td><td>Faecal mass (distinguishes from tumour)</td></tr>
<tr class="row-red"><td>Hard, fixed, irregular mass</td><td><span class="hl-red">Colorectal carcinoma — urgent 2WW referral</span></td></tr>
<tr><td>Diffuse mild tenderness</td><td>Loaded colon / constipation</td></tr>
<tr><td>Tympany on percussion</td><td>Gas-filled loops → obstruction pattern</td></tr>
<tr><td>Absent / tinkling bowel sounds</td><td>Obstruction / ileus</td></tr>
</table>
<table style="margin-top:3px">
<tr class="tbl-sub3"><td colspan="2">C. PERIANAL & DIGITAL RECTAL EXAMINATION (DRE)</td></tr>
<tr><th>Finding</th><th>Significance</th></tr>
<tr><td>Inspection: haemorrhoids, fissure (posterior midline), skin tags, prolapse</td><td>Structural cause confirmed on inspection</td></tr>
<tr class="row-yellow"><td><span class="hl-yellow">Hard stool in rectum (DRE)</span></td><td><b>Faecal impaction / outlet dysfunction</b></td></tr>
<tr class="row-blue"><td><span class="hl-blue">Empty rectum (DRE)</span></td><td><b>Slow transit constipation</b> — stool not reaching rectum</td></tr>
<tr><td>↓ Anal tone</td><td>Rectal prolapse, sphincter damage, neurological cause</td></tr>
<tr><td>↑ Anal tone (tight)</td><td>Anal fissure, dyssynergia</td></tr>
<tr class="row-pink"><td>Anterior rectal wall bulge</td><td>Rectocoele (women — bowel herniates into vagina)</td></tr>
</table>
<div class="pearl"><strong>★ OSCE TIP:</strong> Always offer a PR examination. <span class="hl-yellow">Loaded rectum</span> = outlet dysfunction / impaction. <span class="hl-blue">Empty rectum</span> = slow transit → investigate with colonic transit study.</div>
</div>
<!-- INVESTIGATIONS -->
<div class="section">
<div class="section-header bg-darkblue">INVESTIGATIONS — CONSTIPATION</div>
<table>
<tr class="tbl-sub"><td colspan="3">FIRST-LINE BLOODS</td></tr>
<tr><th>Test</th><th>What You’re Looking For</th><th>Clinical Value</th></tr>
<tr><td>FBC</td><td>Hb, MCV, platelets</td><td>IDA (↓Hb, ↓MCV) → occult bleed from CRC or IBD</td></tr>
<tr><td>U&E; creatinine, urea</td><td>K+, Na+</td><td>Hypokalaemia → constipation; dehydration → ↑ urea</td></tr>
<tr class="row-yellow"><td><b>Serum Ca²+</b></td><td>Corrected calcium</td><td>Hypercalcaemia → constipation; check PTH if ↑</td></tr>
<tr class="row-yellow"><td><b>TFTs (TSH/T4)</b></td><td>Thyroid stimulating hormone</td><td>Hypothyroidism — very common, easily treated</td></tr>
<tr><td>Glucose / HbA1c</td><td>Fasting glucose, HbA1c</td><td>Diabetic autonomic neuropathy</td></tr>
<tr><td>CRP / ESR</td><td>Inflammatory markers</td><td>↑ in IBD, CRC, infection</td></tr>
<tr><td>CEA</td><td>Carcinoembryonic antigen</td><td>Raised in CRC — NOT diagnostic alone; use for monitoring</td></tr>
</table>
<table style="margin-top:3px">
<tr class="tbl-sub"><td colspan="3">IMAGING & SPECIALIST INVESTIGATIONS</td></tr>
<tr><th>Investigation</th><th>When to Order</th><th>What It Shows</th></tr>
<tr><td>AXR (plain film)</td><td>Suspected obstruction or faecal impaction</td><td>Faecal loading, dilated loops, obstruction pattern (3-6-9 rule)</td></tr>
<tr class="row-blue"><td><b>Colonoscopy / Sigmoidoscopy</b></td><td>Alarm features, age >50, new-onset, rectal bleeding</td><td>Polyps, carcinoma, IBD, diverticulosis — <b>GOLD STANDARD</b></td></tr>
<tr><td>CT colonography</td><td>Unable to tolerate colonoscopy / elderly</td><td>Virtual colonoscopy — same diagnostic yield</td></tr>
<tr><td>Colonic transit study (CTT)</td><td>Chronic constipation — slow transit vs outlet</td><td>Radiopaque markers tracked — normal transit <5 days</td></tr>
<tr class="row-purple"><td>Anorectal manometry</td><td>Suspected pelvic floor dysfunction / dyssynergia</td><td>Sphincter pressures, RAIR, rectal sensation</td></tr>
<tr><td>Balloon expulsion test</td><td>Outlet dysfunction screen</td><td>Normal <1 min; prolonged → dyssynergia</td></tr>
<tr><td>Defaecating proctogram</td><td>Straining, incomplete evacuation, outlet dysfunction</td><td>Rectocoele, intussusception, paradoxical puborectalis</td></tr>
<tr><td>MRI pelvis (dynamic)</td><td>Complex pelvic floor pathology</td><td>Structural + functional anatomy, rectocoele, prolapse</td></tr>
<tr class="row-pink"><td>Suction rectal biopsy</td><td>Suspected Hirschsprung’s disease</td><td>Absence of ganglion cells + ↑ acetylcholinesterase — <b>GOLD STANDARD</b></td></tr>
<tr><td>Contrast enema (barium)</td><td>Hirschsprung’s — transition zone</td><td>Narrow aganglionic → dilated proximal colon</td></tr>
</table>
<div class="pearl"><strong>★ OSCE PEARL:</strong> Most important initial investigation in a patient >50 with new-onset constipation and alarm features = <b>colonoscopy</b> to exclude colorectal carcinoma.</div>
</div>
</div><!-- end right col P1 -->
</div><!-- end two-col P1 -->
<div class="sources">Sources: Bailey & Love · Sleisenger & Fordtran · Kumar & Clark · Oxford Handbook of Clinical Medicine · Rome IV Criteria</div>
</div><!-- end PAGE 1 -->
<!-- ═══════════════════════════════════════════════════════════
PAGE 2
═══════════════════════════════════════════════════════════ -->
<div>
<div class="main-title">CONSTIPATION — Last Minute Revision + OSCE Cheat Sheet</div>
<div class="sub-title">Final Year BBS | Bailey & Love · Sleisenger & Fordtran · Kumar & Clark · Oxford Handbook of Clinical Medicine</div>
<div class="page-label">Page 2 of 2 — Management · Hirschsprung’s · Special Situations · OSCE Viva · Bristol Chart · Mnemonics</div>
<div class="two-col">
<!-- ════════ LEFT P2 ════════ -->
<div class="col-left">
<!-- MANAGEMENT -->
<div class="section">
<div class="section-header bg-teal">MANAGEMENT — CONSTIPATION</div>
<table>
<tr class="tbl-sub2"><td colspan="4">STEP 1 — LIFESTYLE (ALWAYS FIRST)</td></tr>
<tr><td colspan="4" style="font-size:8px; line-height:1.5; background:#f0fff4; padding:3px 5px">
<b>Dietary fibre:</b> Increase to 25–30 g/day (fruits, vegetables, wholegrain, bran)<br>
<b>Fluid intake:</b> 1.5–2 L/day — fibre requires water to bulk stools<br>
<b>Exercise:</b> Regular aerobic activity directly stimulates colonic motility<br>
<b>Toilet routine:</b> Regular time after meals (exploit gastrocolic reflex); never ignore urge to defaecate<br>
<b>Positioning:</b> Feet elevated on footstool (squatting position → straightens anorectal angle)<br>
<b>Review medications:</b> Stop or switch constipating drugs wherever clinically possible
</td></tr>
</table>
<table style="margin-top:3px">
<tr class="tbl-sub2"><td colspan="4">STEP 2 — LAXATIVES</td></tr>
<tr><th>Class</th><th>Drug</th><th>Mechanism</th><th>Key Notes</th></tr>
<tr class="row-green">
<td><b>Bulk-forming</b> (1st line mild)</td>
<td>Ispaghula husk (Fybogel)</td>
<td>↑ stool bulk → stimulates peristalsis</td>
<td>Take with ≥200 mL water; takes 2–3 days; <span class="hl-red">avoid in impaction</span></td>
</tr>
<tr class="row-blue">
<td><b>Osmotic</b> (1st line opioid-induced)</td>
<td>Macrogol (Movicol), Lactulose</td>
<td>Draw water into bowel by osmosis</td>
<td>Macrogol preferred (less bloating); lactulose causes flatulence</td>
</tr>
<tr class="row-orange">
<td><b>Stimulant</b> (short-term)</td>
<td>Senna, Bisacodyl</td>
<td>Stimulate enteric nerves → ↑ peristalsis</td>
<td>Works in 6–12 hrs; <span class="hl-orange">avoid long-term → atonic colon</span></td>
</tr>
<tr>
<td>Stool softener</td>
<td>Docusate sodium</td>
<td>Detergent action → softens stool surface</td>
<td>Mild; useful post-op / anal fissure; minimal evidence alone</td>
</tr>
<tr class="row-pink">
<td><b>Rectal agents</b> (acute/impaction)</td>
<td>Phosphate enema, Glycerol suppositories</td>
<td>Local osmotic + stimulant</td>
<td>Pre-procedure, impaction; glycerol suppositories for outlet dysfunction</td>
</tr>
<tr class="row-purple">
<td><b>Secretagogue</b> (chronic refractory)</td>
<td>Linaclotide, Lubiprostone</td>
<td>↑ intestinal Cl² secretion → stool fluidity</td>
<td>IBS-C & chronic idiopathic constipation; specialist initiation</td>
</tr>
<tr class="row-yellow">
<td><b>Prokinetic</b> (specialist)</td>
<td>Prucalopride</td>
<td>5-HT&sup4; agonist → ↑ colonic motility</td>
<td>Chronic idiopathic constipation — when 2 laxatives have failed</td>
</tr>
</table>
<div class="pearl"><strong>★ LAXATIVE LADDER:</strong> Bulk-forming → Osmotic (macrogol) → Stimulant → Combination → Secretagogue / Prucalopride.<br>
In <span class="hl-orange">OPIOID-induced constipation</span>: START with <b>osmotic + stimulant together</b>. Bulk-forming alone is NOT effective. <b>Methylnaltrexone SC</b> (peripherally acting μ-antagonist) if refractory.</div>
</div>
<!-- SPECIFIC CAUSE MANAGEMENT -->
<div class="section">
<div class="section-header bg-orange">MANAGEMENT — SPECIFIC CAUSES</div>
<table>
<tr><th>Cause</th><th>Specific Treatment</th></tr>
<tr class="row-yellow"><td>Hypothyroidism</td><td>Levothyroxine replacement → constipation resolves as euthyroid state is restored</td></tr>
<tr class="row-orange"><td>Hypercalcaemia</td><td>IV 0.9% NaCl rehydration + IV bisphosphonate (zoledronate); treat underlying cause (PTH, Ca)</td></tr>
<tr><td>Hypokalaemia</td><td>IV / oral K+ replacement; address cause</td></tr>
<tr class="row-orange"><td>Opioid-induced constipation</td><td>Osmotic + stimulant laxative; methylnaltrexone SC if refractory</td></tr>
<tr><td>Anal fissure</td><td>Topical GTN 0.4% cream / diltiazem 2% → relax internal sphincter; botulinum toxin if fails; lateral sphincterotomy if chronic</td></tr>
<tr class="row-pink"><td>Hirschsprung’s disease</td><td>Surgical pull-through procedure (Swenson / Soave) — resection of aganglionic segment</td></tr>
<tr class="row-purple"><td>Slow transit constipation (refractory)</td><td>Prucalopride (5-HT&sup4; agonist); subtotal colectomy + ileorectal anastomosis if all else fails</td></tr>
<tr><td>Pelvic floor dyssynergia</td><td><b>Biofeedback therapy — FIRST-LINE</b>; retrains paradoxical puborectalis contraction</td></tr>
<tr><td>Rectocoele</td><td>Pelvic floor physiotherapy; surgical repair (transanal/transvaginal) if symptomatic and large</td></tr>
<tr class="row-pink"><td>Faecal impaction</td><td>Manual evacuation under sedation if needed + phosphate enemas + macrogol disimpaction (8 sachets/day)</td></tr>
<tr class="row-blue"><td>IBS-C</td><td>Lifestyle + macrogol + linaclotide (NICE approved) + low-FODMAP diet + psychological support</td></tr>
<tr class="row-red"><td>CRC causing obstruction</td><td>Emergency: Hartmann’s procedure / colonic stenting as bridge to elective surgery</td></tr>
</table>
</div>
<!-- SPECIAL SITUATIONS -->
<div class="section">
<div class="section-header bg-navy">SPECIAL SITUATIONS</div>
<table>
<tr class="tbl-sub"><td colspan="2">CONSTIPATION IN THE ELDERLY</td></tr>
<tr><td colspan="2" style="font-size:8px; line-height:1.45; background:#fff8f0; padding:3px 5px">
Most common causes: <b>polypharmacy + immobility + dehydration + low fibre diet</b><br>
Risk of faecal impaction → <span class="hl-pink">overflow (spurious) diarrhoea</span> — <b>DO NOT treat with antidiarrhoeals; disimpact first</b><br>
PR examination essential — hard stool in rectum confirms impaction
</td></tr>
<tr class="tbl-sub2"><td colspan="2">CONSTIPATION IN PREGNANCY</td></tr>
<tr><td colspan="2" style="font-size:8px; line-height:1.45; background:#f0fff0; padding:3px 5px">
Progesterone ↓ gut motility; combined with iron supplements = very common<br>
<b>Safe:</b> Ispaghula husk, lactulose, macrogol (short-term)<br>
<b>Avoid:</b> Stimulant laxatives (senna) in 1st trimester; castor oil; mineral oils
</td></tr>
</table>
</div>
</div><!-- end left col P2 -->
<!-- ════════ RIGHT P2 ════════ -->
<div class="col-right">
<!-- HIRSCHSPRUNG'S -->
<div class="section">
<div class="section-header bg-maroon">HIRSCHSPRUNG’S DISEASE</div>
<table>
<tr class="tbl-sub3"><td colspan="2">PATHOPHYSIOLOGY</td></tr>
<tr><td colspan="2" style="font-size:8px; line-height:1.45; background:#fff5f5; padding:3px 5px">
Congenital absence of ganglion cells (Meissner’s submucosal + Auerbach’s myenteric plexus) in distal colon<br>
Failure of <b>neural crest cell migration</b> during embryogenesis (week 5–12)<br>
Aganglionic segment = tonically contracted → functional obstruction<br>
Proximal bowel becomes massively dilated → <b>megacolon</b>
</td></tr>
<tr class="tbl-sub3"><td colspan="2">PRESENTATION BY AGE</td></tr>
<tr><th>Age</th><th>Presentation</th></tr>
<tr class="row-pink"><td><b>Neonate</b></td><td>Failure to pass meconium within <b>48 hrs</b> of birth (normal = within 24 hrs)</td></tr>
<tr><td>Infant</td><td>Chronic constipation + abdominal distension + failure to thrive</td></tr>
<tr><td>Older child</td><td>Severe constipation since birth; does not self-resolve</td></tr>
<tr><td>Adult (rare)</td><td>Lifelong constipation; short-segment form</td></tr>
<tr class="tbl-sub3"><td colspan="2">INVESTIGATIONS</td></tr>
<tr><td colspan="2" style="font-size:8px; line-height:1.45; background:#fff5f5; padding:3px 5px">
<span class="hl-pink"><b>Suction rectal biopsy: GOLD STANDARD</b></span> — absence of ganglion cells + ↑ acetylcholinesterase staining<br>
<b>Contrast enema (barium):</b> Shows transition zone (narrow aganglionic → dilated proximal)<br>
<b>Anorectal manometry:</b> <span class="hl-yellow">Absent RAIR (recto-anal inhibitory reflex) — pathognomonic</span>
</td></tr>
<tr class="tbl-sub3"><td colspan="2">TREATMENT</td></tr>
<tr><td colspan="2" style="font-size:8px; line-height:1.45; background:#fff5f5; padding:3px 5px">
<b>Definitive:</b> Surgical pull-through (Swenson / Soave / Duhamel procedure)<br>
<b>Emergency:</b> Colostomy if toxic megacolon / perforation
</td></tr>
</table>
</div>
<!-- OSCE VIVA Q&A -->
<div class="section">
<div class="section-header bg-purple">OSCE VIVA Q&A</div>
<table>
<tr><th>Examiner Asks…</th><th>Your Answer</th></tr>
<tr><td>Define constipation (Rome IV)?</td><td><3 BM/week OR ≥2 of: straining, hard stools, incomplete evacuation, manual manoeuvres, in >25% defaecations</td></tr>
<tr class="row-orange"><td>Most common drug cause?</td><td><span class="hl-orange">Opioids</span> — reduce peristalsis via μ-receptors; also iron, Al antacids, TCAs, verapamil</td></tr>
<tr class="row-yellow"><td>Which metabolic causes must you exclude?</td><td><span class="hl-yellow">Hypothyroidism (TSH)</span>, <span class="hl-orange">hypercalcaemia (Ca²+)</span>, hypokalaemia (K+), diabetes</td></tr>
<tr><td>First investigation in new constipation >50 yrs?</td><td>FBC, TFTs, serum Ca²+ → colonoscopy if alarm features present</td></tr>
<tr class="row-blue"><td>Empty rectum on DRE tells you what?</td><td><span class="hl-blue">Slow transit constipation</span> — stool not reaching rectum; investigate with transit study</td></tr>
<tr class="row-yellow"><td>Loaded rectum on DRE tells you what?</td><td><span class="hl-yellow">Outlet dysfunction / faecal impaction</span> — treat impaction before laxatives</td></tr>
<tr class="row-pink"><td>What is overflow diarrhoea?</td><td>Liquid stool leaks around faecal impaction — <b>DO NOT give antidiarrhoeals; disimpact first</b></td></tr>
<tr><td>Best laxative for opioid-induced constipation?</td><td>Osmotic (macrogol) + stimulant (senna); methylnaltrexone if refractory</td></tr>
<tr class="row-purple"><td>What is prucalopride?</td><td><span class="hl-purple">5-HT&sup4; agonist prokinetic</span> — for chronic idiopathic constipation after 2 laxatives failed</td></tr>
<tr><td>Treatment for pelvic floor dyssynergia?</td><td>Biofeedback therapy — first-line; surgery rarely needed</td></tr>
<tr class="row-pink"><td>How do you diagnose Hirschsprung’s?</td><td><span class="hl-pink">Suction rectal biopsy</span> — absence of ganglion cells (+ absent RAIR on manometry)</td></tr>
<tr><td>Transition zone on barium enema?</td><td>Narrow aganglionic distal segment → dilated proximal colon (Hirschsprung’s)</td></tr>
<tr class="row-blue"><td>What does absent RAIR indicate?</td><td><span class="hl-blue">Hirschsprung’s disease</span> — pathognomonic finding on anorectal manometry</td></tr>
</table>
<div class="pearl"><strong>★ FINAL OSCE TIP:</strong> If asked about a constipated patient — your first 3 answers should always be: 1) Full drug history (opioids? iron? CCBs?), 2) Alarm features assessment, 3) Bloods: FBC, TFTs, Ca²+. Then colonoscopy if alarm features present.</div>
</div>
<!-- MNEMONICS + BRISTOL -->
<div style="display:flex; gap:5px; margin-top:2px">
<!-- MNEMONICS -->
<div style="flex:1">
<div class="section-header bg-darkblue" style="font-size:8px">MNEMONICS & HIGH-YIELD SUMMARY</div>
<table>
<tr class="tbl-sub"><td colspan="3">CAUSES — ‘SPINE’</td></tr>
<tr><th>Letter</th><th>Category</th><th>Key Example</th></tr>
<tr class="row-blue"><td><b>S</b></td><td>Structural</td><td>CRC, anal fissure, stricture, rectocoele</td></tr>
<tr class="row-green"><td><b>P</b></td><td>Physiological / Dietary</td><td>Low fibre, IBS-C, slow transit, immobility</td></tr>
<tr class="row-orange"><td><b>I</b></td><td>Iatrogenic (Drugs)</td><td>Opioids, iron, Al antacids, TCAs, verapamil</td></tr>
<tr class="row-pink"><td><b>N</b></td><td>Neurological</td><td>Parkinson’s, MS, spinal injury, Hirschsprung’s</td></tr>
<tr class="row-yellow"><td><b>E</b></td><td>Endocrine / Metabolic</td><td>Hypothyroid, hypercalcaemia, hypokalaemia</td></tr>
</table>
<table style="margin-top:3px">
<tr class="tbl-sub"><td colspan="2">ALARM FEATURES — ‘ABCDE’</td></tr>
<tr><th>Letter</th><th>Feature</th></tr>
<tr class="row-red"><td><b>A</b></td><td>Anaemia (iron-deficiency) — check FBC</td></tr>
<tr class="row-red"><td><b>B</b></td><td>Bleeding per rectum — fresh or dark</td></tr>
<tr class="row-red"><td><b>C</b></td><td>Change in bowel habit >6 weeks (new onset)</td></tr>
<tr class="row-red"><td><b>D</b></td><td>Duration sudden + age >50 years old</td></tr>
<tr class="row-red"><td><b>E</b></td><td>Extra: weight loss, palpable mass, family Hx CRC</td></tr>
</table>
</div>
<!-- BRISTOL STOOL CHART -->
<div style="flex:0 0 40%">
<div class="section-header bg-darkgreen" style="font-size:8px">BRISTOL STOOL CHART</div>
<table>
<tr><th>#</th><th>Appearance</th><th>Clinical Meaning</th></tr>
<tr class="row-red"><td style="text-align:center; font-weight:bold">1</td><td>Separate hard lumps</td><td>Severe constipation</td></tr>
<tr class="row-orange"><td style="text-align:center; font-weight:bold">2</td><td>Lumpy sausage</td><td>Constipation</td></tr>
<tr><td style="text-align:center; font-weight:bold">3</td><td>Cracked sausage</td><td>Normal to slow transit</td></tr>
<tr class="row-green"><td style="text-align:center; font-weight:bold">4</td><td>Smooth snake / sausage</td><td><b>IDEAL — normal transit</b></td></tr>
<tr><td style="text-align:center; font-weight:bold">5</td><td>Soft blobs, clear edges</td><td>Lacking fibre / fast transit</td></tr>
<tr class="row-pink"><td style="text-align:center; font-weight:bold">6</td><td>Fluffy / mushy, ragged</td><td>Mild diarrhoea</td></tr>
<tr class="row-red"><td style="text-align:center; font-weight:bold">7</td><td>Watery, no solid pieces</td><td>Diarrhoea — rapid transit</td></tr>
</table>
<div class="pearl" style="margin-top:3px">
<b>Bristol 1–2</b> = constipation.<br>
<b>Bristol 6–7</b> = diarrhoea.<br>
<b>Bristol 4</b> = ideal.<br>
Ask patient to describe stool using the chart in OSCE.
</div>
</div>
</div><!-- end flex row -->
</div><!-- end right col P2 -->
</div><!-- end two-col P2 -->
<div class="sources">Sources: Bailey & Love · Sleisenger & Fordtran · Kumar & Clark · Oxford Handbook of Clinical Medicine · Rome IV Criteria</div>
</div><!-- end PAGE 2 -->
</body>
</html>
cd /home/daytona/workspace/constipation-cheatsheet && chromium --headless --disable-gpu --no-sandbox \ --print-to-pdf=constipation_2page.pdf \ --print-to-pdf-no-header \ "file:///home/daytona/workspace/constipation-cheatsheet/constipation_2page.html" 2>/dev/null python3 -c " from pypdf import PdfReader r = PdfReader('constipation_2page.pdf') print(f'Pages: {len(r.pages)}') for i,p in enumerate(r.pages): print(f' Page {i+1}: {p.mediabox.width:.0f} x {p.mediabox.height:.0f} pts') import os print(f'File size: {os.path.getsize(\"constipation_2page.pdf\")/1024:.0f} KB') "
cd /home/daytona/workspace/constipation-cheatsheet && python3 -c " import subprocess, json # Use Chromium DevTools Protocol to set paper size explicitly to A4 result = subprocess.run([ 'chromium', '--headless=new', '--disable-gpu', '--no-sandbox', '--run-all-compositor-stages-before-draw', '--print-to-pdf=constipation_2page_a4.pdf', '--print-to-pdf-no-header', '--virtual-time-budget=5000', '--paper-width=8.27', '--paper-height=11.69', 'file:///home/daytona/workspace/constipation-cheatsheet/constipation_2page.html' ], capture_output=True, text=True) print('RC:', result.returncode) # just check last line of stderr lines = result.stderr.strip().split('\n') for l in lines[-3:]: print(l) " python3 -c " from pypdf import PdfReader; import os r = PdfReader('constipation_2page_a4.pdf') print(f'Pages: {len(r.pages)}') for i,p in enumerate(r.pages): print(f' Page {i+1}: {p.mediabox.width:.1f} x {p.mediabox.height:.1f} pts') print(f'Size: {os.path.getsize(\"constipation_2page_a4.pdf\")/1024:.0f} KB') " 2>/dev/null
python3 -c "from weasyprint import HTML; print('weasyprint available')" 2>/dev/null || echo "not available" python3 -c "import pdfkit; print('pdfkit available')" 2>/dev/null || echo "pdfkit not available" which xvfb-run 2>/dev/null || echo "no xvfb"
# Try using Chromium with xvfb and explicit print settings via CDP # First check if we can use puppeteer or playwright node -e "const p = require('puppeteer'); console.log('puppeteer ok')" 2>/dev/null || echo "no puppeteer" node -e "const p = require('playwright'); console.log('playwright ok')" 2>/dev/null || echo "no playwright" ls /usr/local/lib/node_modules/ 2>/dev/null | head -20 ls /usr/lib/node_modules/ 2>/dev/null | head -20
# Use reportlab to build the PDF natively - but that's complex # Better: use chromium with CDP (Chrome DevTools Protocol) directly # Let's try using python + CDP via subprocess to control chromium # Actually - the simplest fix is: the HTML content overflows 2 A4 pages because # Chromium defaults to Letter. Let me restructure the HTML so each "page" is # exactly Letter-sized (612pt = 8.5in), so 4 Letter pages = 2 visual "pages" # OR just make the PDF be exactly 2 US Letter pages which is what it naturally generates # when we cut content correctly. # Let me check: 4 US Letter pages with the content split as designed # means page1+page2 = visual page1, page3+page4 = visual page2 # The easiest fix: make font slightly smaller so it fits 2 Letter pages total # Check actual content - how much of each "page" is used? python3 -c " from pypdf import PdfReader r = PdfReader('/home/daytona/workspace/constipation-cheatsheet/constipation_2page_a4.pdf') for i,p in enumerate(r.pages): text = p.extract_text() print(f'--- Page {i+1}: {len(text)} chars ---') print(text[:100]) print() "
~/constipation-cheatsheet/constipation_2page.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html'
~/constipation-cheatsheet/constipation_2page.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html'
~/constipation-cheatsheet/constipation_2page.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html'
~/constipation-cheatsheet/constipation_2page.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html'
~/constipation-cheatsheet/constipation_2page.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html'
~/constipation-cheatsheet/constipation_2page.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html'
cd /home/daytona/workspace/constipation-cheatsheet && chromium --headless --disable-gpu --no-sandbox \ --print-to-pdf=constipation_2page.pdf \ --print-to-pdf-no-header \ "file:///home/daytona/workspace/constipation-cheatsheet/constipation_2page.html" 2>/dev/null python3 -c " from pypdf import PdfReader; import os r = PdfReader('constipation_2page.pdf') print(f'Pages: {len(r.pages)}') print(f'Size: {os.path.getsize(\"constipation_2page.pdf\")/1024:.0f} KB') "
cd /home/daytona/workspace/constipation-cheatsheet && chromium --headless --disable-gpu --no-sandbox \ --print-to-pdf=constipation_scaled.pdf \ --print-to-pdf-no-header \ --scale-factor=75 \ "file:///home/daytona/workspace/constipation-cheatsheet/constipation_2page.html" 2>/dev/null python3 -c " from pypdf import PdfReader; import os r = PdfReader('constipation_scaled.pdf') print(f'Pages: {len(r.pages)}') print(f'Size: {os.path.getsize(\"constipation_scaled.pdf\")/1024:.0f} KB') "
# Use pypdf to merge page pairs (1+2 -> page1, 3+4 -> page2) using page merging python3 << 'EOF' from pypdf import PdfReader, PdfWriter, Transformation from pypdf.generic import RectangleObject import math reader = PdfReader('/home/daytona/workspace/constipation-cheatsheet/constipation_2page.pdf') writer = PdfWriter() pages = list(reader.pages) total = len(pages) print(f"Input: {total} pages, each {float(pages[0].mediabox.width):.0f} x {float(pages[0].mediabox.height):.0f} pts") # Merge pairs: [0,1] -> page1, [2,3] -> page2 # Each output page: same width, double height, scaled to fit for pair_start in range(0, total, 2): p1 = pages[pair_start] p2 = pages[pair_start+1] if pair_start+1 < total else None w = float(p1.mediabox.width) h = float(p1.mediabox.height) # Create new page with same dimensions as input (portrait letter) # Scale each half-page to 50% height new_page = writer.add_blank_page(width=w, height=h) # Merge page1 scaled to top half # Scale = 0.5, place at y=h/2 t1 = Transformation().scale(0.5, 0.5).translate(0, h/2) new_page.merge_transformed_page(p1, t1) # Merge page2 scaled to bottom half if p2: t2 = Transformation().scale(0.5, 0.5).translate(0, 0) new_page.merge_transformed_page(p2, t2) with open('/home/daytona/workspace/constipation-cheatsheet/constipation_final.pdf', 'wb') as f: writer.write(f) import os r2 = PdfReader('/home/daytona/workspace/constipation-cheatsheet/constipation_final.pdf') print(f"Output: {len(r2.pages)} pages") print(f"Size: {os.path.getsize('/home/daytona/workspace/constipation-cheatsheet/constipation_final.pdf')//1024} KB") EOF
# The cleanest approach: use CSS @page with print styles and make each .page div # exactly 792pt (11in) tall. Chromium respects @page in headless print mode. # Let me rewrite the HTML with proper @page CSS python3 << 'EOF' # Read the current HTML and add proper @page CSS with open('/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html', 'r') as f: content = f.read() # Check if @page already exists print('@page' in content) # Check the page-break div approach import re pb = re.findall(r'page-break.*?;', content) print('Page breaks found:', pb[:5]) EOF
~/constipation-cheatsheet/constipation_2page.html
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/constipation-cheatsheet/constipation_2page.html'
cd /home/daytona/workspace/constipation-cheatsheet && chromium --headless --disable-gpu --no-sandbox \ --print-to-pdf=constipation_2page.pdf \ --print-to-pdf-no-header \ "file:///home/daytona/workspace/constipation-cheatsheet/constipation_2page.html" 2>/dev/null python3 -c " from pypdf import PdfReader; import os r = PdfReader('constipation_2page.pdf') print(f'Pages: {len(r.pages)}') for i,p in enumerate(r.pages): print(f' P{i+1}: {float(p.mediabox.width):.0f}x{float(p.mediabox.height):.0f}') print(f'Size: {os.path.getsize(\"constipation_2page.pdf\")/1024:.0f} KB') "
cd /home/daytona/workspace/constipation-cheatsheet && sed -i 's/font-size: 7.5px;/font-size: 7px;/' constipation_2page.html && sed -i 's/font-size: 7.2px;/font-size: 6.8px;/g' constipation_2page.html && sed -i 's/font-size: 7.2px/font-size: 6.8px/g' constipation_2page.html chromium --headless --disable-gpu --no-sandbox \ --print-to-pdf=constipation_2page.pdf \ --print-to-pdf-no-header \ "file:///home/daytona/workspace/constipation-cheatsheet/constipation_2page.html" 2>/dev/null python3 -c " from pypdf import PdfReader; import os r = PdfReader('constipation_2page.pdf') print(f'Pages: {len(r.pages)}') print(f'Size: {os.path.getsize(\"constipation_2page.pdf\")/1024:.0f} KB') "
constipation 2page
PDF Document · PDF
constipation 2page
HTML File · HTML
| Section | Content |
|---|---|
| Definition | Rome IV criteria in full |
| Causes | SPINE mnemonic with colour-coded table |
| Red Flags | ABCDE alarm features |
| History | Character, associated symptoms, drug history (7 drug classes), social Hx, PMHx, FHx |
| Examination | General inspection, abdominal, DRE findings |
| Investigations | Full bloods table + 10 imaging/specialist tests |
| Management | Lifestyle steps, 7-class laxative ladder, 12 specific cause treatments |
| Special Situations | Elderly + Pregnancy |
| Hirschsprung's | Pathophysiology, age presentation, investigations, treatment |
| OSCE Viva Q&A | 13 examiner Q&A pairs |
| Mnemonics | SPINE + ABCDE summary tables |
| Bristol Stool Chart | All 7 types with clinical meaning |
Why does it download as pdf.json
.json.constipation_2page.pdf.json to constipation_2page.pdf — it will open fine in any PDF viewer.constipation 2page
HTML File · HTML
Ctrl+P (or Cmd+P on Mac) → Save as PDF