Generate flashcards for diarrhoea
Flash cards
Pdf in this
mkdir -p /home/daytona/workspace/diarrhoea-flashcards && ls /home/daytona/workspace/diarrhoea-flashcards/
~/diarrhoea-flashcards/generate_flashcards.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import KeepTogether
OUTPUT = "/home/daytona/workspace/diarrhoea-flashcards/Diarrhoea_Flashcards.pdf"
# ── Colour palette ──────────────────────────────────────────────────────────
TEAL = colors.HexColor("#0D7377")
TEAL_LIGHT = colors.HexColor("#E6F4F4")
AMBER = colors.HexColor("#D97706")
AMBER_LIGHT= colors.HexColor("#FFF7ED")
RED = colors.HexColor("#B91C1C")
RED_LIGHT = colors.HexColor("#FEF2F2")
BLUE = colors.HexColor("#1D4ED8")
BLUE_LIGHT = colors.HexColor("#EFF6FF")
GREEN = colors.HexColor("#15803D")
GREEN_LIGHT= colors.HexColor("#F0FDF4")
PURPLE = colors.HexColor("#7E22CE")
PURPLE_LIGHT=colors.HexColor("#FAF5FF")
GREY_DARK = colors.HexColor("#1F2937")
GREY_MID = colors.HexColor("#6B7280")
WHITE = colors.white
# Category colours: (header_bg, header_fg, card_bg, accent)
CAT_COLORS = {
"Definition & Epidemiology": (TEAL, WHITE, TEAL_LIGHT, TEAL),
"Pathophysiology": (BLUE, WHITE, BLUE_LIGHT, BLUE),
"Classification": (PURPLE, WHITE, PURPLE_LIGHT, PURPLE),
"Clinical Features": (AMBER, WHITE, AMBER_LIGHT, AMBER),
"Causes & Aetiology": (RED, WHITE, RED_LIGHT, RED),
"Investigations": (GREEN, WHITE, GREEN_LIGHT, GREEN),
"Management": (TEAL, WHITE, TEAL_LIGHT, TEAL),
"Special Situations": (AMBER, WHITE, AMBER_LIGHT, AMBER),
"Complications": (RED, WHITE, RED_LIGHT, RED),
}
# ── Flashcard data ──────────────────────────────────────────────────────────
FLASHCARDS = [
# ── DEFINITION & EPIDEMIOLOGY ────────────────────────────────────────────
{
"category": "Definition & Epidemiology",
"q": "What is the clinical definition of diarrhoea?",
"a": (
"• Passage of <b>3 or more loose/liquid stools per day</b>, OR\n"
"• Stool output <b>>200 g/day</b> in adults\n"
"• Most patients describe increased <b>fluidity</b> as the essential feature\n"
"• <b>Acute:</b> <2 weeks | <b>Persistent:</b> 2–4 weeks | <b>Chronic:</b> ≥4 weeks"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Definition & Epidemiology",
"q": "What is the global burden of diarrhoeal disease?",
"a": (
"• 7.5% of Americans have acute gastroenteritis in any given month\n"
"• >3.5 million outpatient visits per year in the USA\n"
"• >180,000 hospital admissions and ~3,000 deaths/year from gastroenteritis in USA\n"
"• Chronic diarrhoea affects <b>6.6%</b> of the population\n"
"• In <b>developing countries</b>: leading cause of morbidity and mortality, especially in children"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
# ── PATHOPHYSIOLOGY ──────────────────────────────────────────────────────
{
"category": "Pathophysiology",
"q": "What are the four main pathophysiological mechanisms of diarrhoea?",
"a": (
"1. <b>Osmotic</b> – non-absorbable solutes draw water into the lumen\n"
"2. <b>Secretory</b> – net excess of ion/fluid secretion over absorption\n"
"3. <b>Inflammatory/Exudative</b> – mucosal damage with exudate, blood, pus\n"
"4. <b>Motility-related</b> – rapid transit reduces contact time for absorption\n\n"
"<i>Note: Most clinical diarrhoea is <b>complex</b> and involves multiple mechanisms simultaneously (ALPINEs framework)</i>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Pathophysiology",
"q": "How does osmotic diarrhoea differ from secretory diarrhoea?",
"a": (
"<b>Osmotic diarrhoea:</b>\n"
"• Non-absorbable solutes (e.g., Mg²⁺, lactose) draw water into lumen\n"
"• <b>Stops with fasting</b>\n"
"• Stool osmotic gap <b>>125 mOsm/kg</b>\n\n"
"<b>Secretory diarrhoea:</b>\n"
"• Excess active secretion or impaired absorption of ions\n"
"• <b>Persists with fasting</b>\n"
"• Stool osmotic gap <b><50 mOsm/kg</b>\n"
"• Often large volume (cholera: up to 10–12 L/day)"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Pathophysiology",
"q": "What is the stool osmotic gap and how is it calculated?",
"a": (
"<b>Formula:</b> 290 – 2 × (stool [Na⁺] + stool [K⁺])\n\n"
"• <b>>125 mOsm/kg</b> → Osmotic diarrhoea\n"
"• <b><50 mOsm/kg</b> → Secretory diarrhoea\n"
"• 50–125 mOsm/kg → Indeterminate / complex\n\n"
"<i>290 is the assumed normal plasma osmolality used as reference</i>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Pathophysiology",
"q": "How does cholera cause diarrhoea?",
"a": (
"• <i>Vibrio cholerae</i> toxin increases <b>cAMP</b> in enterocytes\n"
"• Opens apical <b>chloride channels (CFTR)</b> → Cl⁻ secretion\n"
"• Na⁺ and water follow passively → massive secretory diarrhoea\n"
"• Output: <b>10–12 L/day</b> (colon can reabsorb max 6–8 L/day)\n"
"• Also stimulates enteric nerves and endocrine cells\n"
"• Without treatment: mortality up to <b>50%</b>"
),
"source": "Guyton & Hall Medical Physiology; Sleisenger & Fordtran's"
},
{
"category": "Pathophysiology",
"q": "What is the ALPINEs framework in diarrhoea pathophysiology?",
"a": (
"ALPINEs describes the regulatory systems involved in diarrhoea:\n\n"
"<b>A</b> – Autocrine\n"
"<b>L</b> – Luminal\n"
"<b>P</b> – Paracrine\n"
"<b>I</b> – Immune\n"
"<b>N</b> – Neural\n"
"<b>E</b> – Endocrine\n"
"<b>S</b> – (Systems)\n\n"
"These systems interact simultaneously – e.g., enteric nerves stimulate mast cells, mast cell histamine alters neuron function, prostaglandins affect epithelium AND motility AND permeability"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
# ── CLASSIFICATION ───────────────────────────────────────────────────────
{
"category": "Classification",
"q": "How is diarrhoea classified by duration?",
"a": (
"• <b>Acute:</b> <2 weeks — usually infectious\n"
"• <b>Persistent:</b> 2–4 weeks — may be infectious or early chronic\n"
"• <b>Chronic:</b> ≥4 weeks — broad differential; structural, functional, inflammatory, endocrine\n\n"
"<i>Acute diarrhoea resolves spontaneously in most cases; chronic diarrhoea requires systematic evaluation</i>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Classification",
"q": "Classify diarrhoea by stool character (watery / fatty / inflammatory).",
"a": (
"<b>Watery diarrhoea:</b>\n"
"• Osmotic: carbohydrate malabsorption, osmotic laxatives (Mg²⁺, PO₄³⁻, SO₄²⁻)\n"
"• Secretory: bacterial toxins, VIPoma, carcinoid, microscopic colitis, IBD\n\n"
"<b>Fatty (steatorrhoea):</b>\n"
"• Malabsorption: coeliac, Whipple, short bowel, SIBO\n"
"• Maldigestion: pancreatic exocrine insufficiency, bile acid deficiency\n\n"
"<b>Inflammatory:</b>\n"
"• IBD, invasive infections (Salmonella, Shigella, Campylobacter, C. diff), ischaemic colitis, radiation colitis"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Classification",
"q": "What distinguishes large-volume from small-volume diarrhoea clinically?",
"a": (
"<b>Large-volume diarrhoea:</b>\n"
"• Suggests small bowel or right colon pathology\n"
"• Often watery, no tenesmus\n"
"• E.g., cholera, VIPoma, coeliac disease\n\n"
"<b>Small-volume diarrhoea:</b>\n"
"• Suggests left colon / rectal pathology\n"
"• Associated with urgency, tenesmus, passage of blood/mucus\n"
"• E.g., ulcerative colitis, rectal cancer, infectious proctitis"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
# ── CLINICAL FEATURES ────────────────────────────────────────────────────
{
"category": "Clinical Features",
"q": "What features in the history help characterise diarrhoea?",
"a": (
"• <b>Onset & duration</b> (acute vs chronic)\n"
"• <b>Stool frequency, volume, consistency</b>\n"
"• <b>Blood, mucus, pus</b> in stool → inflammatory / invasive\n"
"• <b>Nocturnal diarrhoea</b> → organic (not functional)\n"
"• <b>Fasting</b>: stops with fasting → osmotic; persists → secretory\n"
"• <b>Travel history</b> → traveller's diarrhoea\n"
"• <b>Food intake</b> (dairy, gluten, sorbitol, alcohol)\n"
"• <b>Medications</b> (antibiotics, NSAIDs, PPI, metformin, laxatives)\n"
"• <b>Immunosuppression</b> (HIV, chemotherapy, transplant)\n"
"• <b>Weight loss, fever, systemic symptoms</b> → alarm features"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Clinical Features",
"q": "What are the alarm features (red flags) in diarrhoea?",
"a": (
"• <b>Rectal bleeding</b>\n"
"• <b>Nocturnal diarrhoea</b> (waking from sleep)\n"
"• <b>Unintentional weight loss</b>\n"
"• <b>Progressive symptoms</b>\n"
"• <b>Age >50 years</b> with new-onset symptoms\n"
"• <b>Family history</b> of colorectal cancer or IBD\n"
"• <b>Anaemia</b> on blood tests\n"
"• <b>Fever with toxic appearance</b>\n\n"
"<i>Alarm features warrant urgent investigation and colonoscopy</i>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Clinical Features",
"q": "What are the physical examination findings to look for in diarrhoea?",
"a": (
"• <b>Signs of dehydration:</b> dry mucous membranes, reduced skin turgor, sunken eyes, tachycardia, hypotension\n"
"• <b>Fever</b> → infectious or inflammatory\n"
"• <b>Abdominal tenderness</b> → location suggests pathology\n"
"• <b>Perianal disease</b> (fistulae, skin tags) → Crohn disease\n"
"• <b>Extra-intestinal features:</b> arthritis, uveitis, erythema nodosum (IBD); flushing (carcinoid); goitre (hyperthyroidism)\n"
"• <b>Lymphadenopathy/wasting</b> → malignancy or HIV\n"
"• <b>Digital rectal exam:</b> exclude faecal impaction with overflow"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
# ── CAUSES & AETIOLOGY ───────────────────────────────────────────────────
{
"category": "Causes & Aetiology",
"q": "What are the common bacterial causes of acute infective diarrhoea?",
"a": (
"• <b>Campylobacter jejuni</b> — most common bacterial cause in UK\n"
"• <b>Salmonella spp.</b> — food-borne, may cause systemic illness\n"
"• <b>Shigella spp.</b> — dysentery (bloody diarrhoea), person-to-person\n"
"• <b>E. coli (ETEC)</b> — traveller's diarrhoea (secretory toxin)\n"
"• <b>E. coli O157:H7 (EHEC)</b> — haemorrhagic colitis → HUS\n"
"• <b>Clostridioides difficile</b> — antibiotic-associated, pseudomembranous colitis\n"
"• <b>Vibrio cholerae</b> — massive secretory diarrhoea ('rice-water stools')\n"
"• <b>Yersinia, Aeromonas, Plesiomonas</b>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Causes & Aetiology",
"q": "What are the common viral and parasitic causes of diarrhoea?",
"a": (
"<b>Viruses:</b>\n"
"• <b>Norovirus</b> — most common cause of acute viral gastroenteritis in adults\n"
"• <b>Rotavirus</b> — most common in children <5 years\n"
"• <b>Adenovirus, Astrovirus</b> — paediatric\n"
"• <b>CMV</b> — immunocompromised patients\n\n"
"<b>Parasites:</b>\n"
"• <b>Giardia lamblia</b> — steatorrhoea, bloating, no blood\n"
"• <b>Entamoeba histolytica</b> — amoebic dysentery (bloody)\n"
"• <b>Cryptosporidium parvum</b> — watery, self-limited in immunocompetent; chronic in HIV\n"
"• <b>Cyclospora, Cystoisospora</b> — returning travellers"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Causes & Aetiology",
"q": "What endocrine/hormonal causes of secretory diarrhoea should be remembered?",
"a": (
"Mnemonic: <b>VIPoma Gastrinoma Carcinoid Medullary Pheochromocytoma</b>\n\n"
"• <b>VIPoma</b> — vasoactive intestinal peptide → 'pancreatic cholera' (>3 L/day)\n"
"• <b>Gastrinoma</b> (Zollinger–Ellison) — excess acid inactivates pancreatic lipase\n"
"• <b>Carcinoid syndrome</b> — serotonin, watery diarrhoea + flushing\n"
"• <b>Medullary carcinoma of thyroid</b> — calcitonin\n"
"• <b>Phaeochromocytoma</b> — catecholamines\n"
"• <b>Somatostatinoma</b> — inhibits secretin/CCK → malabsorption\n"
"• <b>Addison disease</b> — aldosterone deficiency\n"
"• <b>Hyperthyroidism</b> — increased motility"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Causes & Aetiology",
"q": "Which drugs commonly cause diarrhoea?",
"a": (
"• <b>Antibiotics</b> — disruption of microbiome; C. difficile risk (especially 3rd-gen cephalosporins, clindamycin)\n"
"• <b>Metformin</b> — GI side effects, common\n"
"• <b>NSAIDs</b> — mucosal irritation\n"
"• <b>PPIs</b> — alter gut microbiome\n"
"• <b>Magnesium-containing antacids</b> — osmotic\n"
"• <b>Laxatives (stimulant)</b> — secretory/motility\n"
"• <b>Colchicine, SSRIs, ACE inhibitors</b>\n"
"• <b>Chemotherapy agents</b> (irinotecan, 5-FU)\n"
"• <b>HAART (HIV treatment)</b> — protease inhibitors especially"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Causes & Aetiology",
"q": "What are the causes of chronic diarrhoea to consider systematically?",
"a": (
"1. <b>Functional:</b> IBS-D, functional diarrhoea\n"
"2. <b>Malabsorption:</b> coeliac disease, SIBO, lactase deficiency, short bowel\n"
"3. <b>Inflammatory:</b> IBD (Crohn's, UC), microscopic colitis\n"
"4. <b>Infectious:</b> Giardia, C. difficile, tropical infections\n"
"5. <b>Drugs/iatrogenic:</b> medications, post-surgical (vagotomy, cholecystectomy), radiation\n"
"6. <b>Endocrine:</b> hyperthyroidism, VIPoma, carcinoid, Addison's\n"
"7. <b>Neoplastic:</b> colorectal cancer, lymphoma, villous adenoma\n"
"8. <b>Bile acid malabsorption</b> — after ileal resection or disease\n"
"9. <b>Microscopic colitis</b> — collagenous or lymphocytic colitis"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
# ── INVESTIGATIONS ───────────────────────────────────────────────────────
{
"category": "Investigations",
"q": "What stool tests are used in the evaluation of diarrhoea?",
"a": (
"<b>Basic stool tests:</b>\n"
"• <b>Faecal calprotectin</b> — sensitive marker of intestinal inflammation (IBD vs functional)\n"
"• <b>Stool culture</b> — for bacterial pathogens (Salmonella, Shigella, Campylobacter, E. coli)\n"
"• <b>Ova & parasites</b> — Giardia, Cryptosporidium, amoeba\n"
"• <b>C. difficile toxin PCR / EIA</b>\n"
"• <b>Multiplex PCR panel</b> — rapid, covers bacteria + viruses + parasites\n"
"• <b>Faecal fat (72h collection)</b> — steatorrhoea (>7g fat/day)\n"
"• <b>Faecal elastase</b> — pancreatic exocrine insufficiency\n"
"• <b>Faecal lactoferrin</b> — inflammatory marker"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease; Goldman-Cecil Medicine"
},
{
"category": "Investigations",
"q": "What blood tests are indicated in chronic diarrhoea?",
"a": (
"• <b>FBC</b> — anaemia (IBD, coeliac, malignancy), eosinophilia (parasites)\n"
"• <b>CRP / ESR</b> — inflammation\n"
"• <b>U&E, creatinine</b> — dehydration, electrolyte disturbance\n"
"• <b>TFTs</b> — hyperthyroidism\n"
"• <b>IgA tTG antibody + IgA level</b> — coeliac screen\n"
"• <b>Serum B12, folate, ferritin</b> — malabsorption\n"
"• <b>Albumin</b> — nutritional status / protein-losing enteropathy\n"
"• <b>Gut hormones</b> — gastrin (Zollinger–Ellison), VIP, chromogranin A, 5-HIAA\n"
"• <b>Cortisol / synacthen test</b> — Addison disease"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Investigations",
"q": "When is colonoscopy/endoscopy indicated in diarrhoea?",
"a": (
"<b>Colonoscopy indicated in:</b>\n"
"• Alarm features (rectal bleeding, weight loss, age >50)\n"
"• Chronic unexplained diarrhoea\n"
"• Suspected IBD\n"
"• Suspected microscopic colitis (biopsy even with normal appearance)\n"
"• Toxic-appearing patient with acute severe diarrhoea\n"
"• AIDS-related diarrhoea (colonoscopy preferred over sigmoidoscopy — right colon may be affected)\n\n"
"<b>Sigmoidoscopy</b> — adequate for initial assessment of acute severe infectious diarrhoea\n\n"
"<i>Always take mucosal biopsies even if mucosa looks normal</i>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
# ── MANAGEMENT ───────────────────────────────────────────────────────────
{
"category": "Management",
"q": "What is oral rehydration therapy (ORT) and how does it work?",
"a": (
"<b>Principle:</b> Na⁺–glucose co-transport (SGLT1) drives Na⁺ absorption even when secretory mechanisms are impaired\n\n"
"<b>WHO-ORS composition:</b>\n"
"• Glucose 13.5 g/L | NaCl 2.6 g/L | KCl 1.5 g/L | Na-citrate 2.9 g/L\n"
"• Osmolality: <b>245 mOsm/L</b> (reduced-osmolality formula)\n\n"
"<b>Use:</b>\n"
"• First-line for mild-moderate dehydration in all ages\n"
"• Revolutionary treatment — reduced cholera mortality from 50% to near 0%\n"
"• IV fluids reserved for severe dehydration or vomiting\n"
"• Avoid high-sugar drinks (sports drinks) — can worsen osmotic diarrhoea"
),
"source": "Harrison's Principles of Internal Medicine; Sleisenger & Fordtran's"
},
{
"category": "Management",
"q": "When are antibiotics indicated in acute infective diarrhoea?",
"a": (
"<b>Generally NOT needed</b> — most acute diarrhoea is self-limiting\n\n"
"<b>Antibiotics indicated in:</b>\n"
"• Severe/invasive infection (fever, bloody stool, toxic appearance)\n"
"• <b>Shigellosis</b> — azithromycin or ciprofloxacin\n"
"• <b>Cholera</b> — doxycycline (reduces duration/volume)\n"
"• <b>C. difficile</b> — vancomycin (oral) or fidaxomicin (first-line); metronidazole (mild)\n"
"• <b>Traveller's diarrhoea</b> — azithromycin or rifaximin\n"
"• <b>Giardiasis</b> — metronidazole or tinidazole\n"
"• <b>Amoebiasis</b> — metronidazole followed by luminal agent (paromomycin)\n\n"
"<i>Avoid antibiotics in EHEC O157:H7 — risk of HUS increases</i>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease; Harrison's"
},
{
"category": "Management",
"q": "What anti-motility and anti-secretory agents are used in diarrhoea?",
"a": (
"<b>Anti-motility agents:</b>\n"
"• <b>Loperamide</b> (opioid receptor agonist) — reduces peristalsis and fluid secretion; first-line for non-bloody, non-infective diarrhoea\n"
"• <b>Diphenoxylate/atropine (Lomotil)</b> — similar mechanism\n\n"
"<b>Cautions:</b> avoid in inflammatory/bloody diarrhoea and C. difficile (risk of toxic megacolon)\n\n"
"<b>Antisecretory:</b>\n"
"• <b>Bismuth subsalicylate</b> — antisecretory + antimicrobial + anti-inflammatory\n"
"• <b>Racecadotril</b> — enkephalinase inhibitor → reduces cAMP-mediated secretion\n"
"• <b>Octreotide</b> — somatostatin analogue for VIPoma, carcinoid, chemotherapy diarrhoea"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease; Harriet Lane Handbook"
},
{
"category": "Management",
"q": "How is C. difficile infection (CDI) managed?",
"a": (
"<b>Stop precipitating antibiotic</b> if possible\n\n"
"<b>Treatment by severity:</b>\n"
"• <b>Non-severe:</b> Oral <b>vancomycin</b> 125 mg QDS × 10 days, or <b>fidaxomicin</b> 200 mg BD × 10 days\n"
"• <b>Severe (WBC >15, creatinine >133):</b> oral vancomycin 500 mg QDS\n"
"• <b>Fulminant (ileus/toxic megacolon):</b> IV metronidazole + oral vancomycin ± colectomy\n\n"
"<b>Recurrent CDI:</b>\n"
"• <b>Faecal microbiota transplant (FMT)</b> — highly effective for ≥2 recurrences\n"
"• Bezlotoxumab (monoclonal Ab) to prevent recurrence\n\n"
"<i>Risk factors: advanced age, broad-spectrum antibiotics, hospitalization, PPI use</i>"
),
"source": "Goldman-Cecil Medicine; Sleisenger & Fordtran's"
},
{
"category": "Management",
"q": "How is acute diarrhoea managed based on patient appearance?",
"a": (
"<b>Non-toxic patient:</b>\n"
"• Symptomatic therapy + oral rehydration\n"
"• Usually no investigations required\n"
"• Reassurance and dietary advice\n\n"
"<b>Toxic patient (fever, dehydration, haemodynamic instability):</b>\n"
"• IV fluids + electrolyte repletion\n"
"• FBC, U&E, serum creatinine\n"
"• Stool: culture (if fecal WBC present), O&P, Giardia/Cryptosporidium antigen, C. diff PCR\n"
"• Consider multiplex PCR stool panel\n"
"• Sigmoidoscopy or colonoscopy if warranted\n"
"• Consider empirical antibiotics if severe"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease (Table 16.3)"
},
# ── SPECIAL SITUATIONS ───────────────────────────────────────────────────
{
"category": "Special Situations",
"q": "What causes diarrhoea in HIV/AIDS patients?",
"a": (
"<b>Pre-HAART era:</b> up to 90% of AIDS patients had diarrhoea\n"
"<b>Post-HAART era:</b> less common; mainly drug-induced (protease inhibitors) or non-HIV causes\n\n"
"<b>Infectious causes (by organism type):</b>\n"
"• <b>Protozoa (most common):</b> Cryptosporidium*, Microsporidia*, Giardia, Cyclospora, Entamoeba, Leishmania\n"
"• <b>Bacteria:</b> Salmonella*, Shigella*, Campylobacter*, C. diff, MAC, TB\n"
"• <b>Viruses:</b> CMV, HSV, Adenovirus, Norovirus\n"
"• <b>Fungi:</b> Histoplasma, Cryptococcus, Candida\n\n"
"<b>Risk factors for OI:</b> low CD4 count, not on HAART, unsafe water, exposure to animals\n"
"<i>* = common + often chronic/refractory in HIV</i>"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Special Situations",
"q": "What is traveller's diarrhoea and how is it managed?",
"a": (
"• Defined as ≥3 loose stools/day in a traveller, ± cramping, nausea, fever\n"
"• Most common in travel to South Asia, Sub-Saharan Africa, Latin America\n\n"
"<b>Causes:</b> ETEC (most common), Campylobacter, Shigella, Salmonella, Norovirus, Giardia\n\n"
"<b>Management:</b>\n"
"• <b>Mild:</b> Oral rehydration + bismuth subsalicylate or loperamide\n"
"• <b>Moderate-severe:</b> <b>Azithromycin</b> 1g single dose (drug of choice)\n"
" or Rifaximin 200mg TDS × 3 days (non-invasive E. coli only)\n"
" or Ciprofloxacin (increasing resistance)\n"
"• <b>Prevention:</b> boiled/bottled water, food hygiene; prophylactic antibiotics not routinely recommended"
),
"source": "Harrison's Principles of Internal Medicine; Sleisenger & Fordtran's"
},
{
"category": "Special Situations",
"q": "What is microscopic colitis and how does it present?",
"a": (
"• Chronic watery, non-bloody diarrhoea — often <b>nocturnal</b>, large volume\n"
"• Predominantly affects <b>older women</b>\n"
"• <b>Normal colonoscopy</b> — diagnosis requires <b>biopsy</b>\n\n"
"<b>Two subtypes:</b>\n"
"• <b>Collagenous colitis</b> — thickened subepithelial collagen band (>10 µm)\n"
"• <b>Lymphocytic colitis</b> — increased intraepithelial lymphocytes (>20 per 100 epithelial cells)\n\n"
"<b>Associations:</b> NSAIDs, PPIs, SSRIs, coeliac disease, autoimmune conditions\n\n"
"<b>Treatment:</b> Budesonide (first-line), stop offending drugs; cholestyramine for mild cases"
),
"source": "Sleisenger & Fordtran's GI and Liver Disease"
},
{
"category": "Special Situations",
"q": "What are the causes of post-surgical diarrhoea?",
"a": (
"• <b>Post-vagotomy diarrhoea</b> — after truncal vagotomy; rapid gastric emptying and abnormal intestinal motility\n"
"• <b>Bile acid malabsorption</b> — after ileal resection (>100cm) → bile acids reach colon → secretory diarrhoea\n"
"• <b>Short bowel syndrome</b> — after extensive small bowel resection → reduced absorptive surface\n"
"• <b>Post-cholecystectomy diarrhoea</b> — continuous bile acid secretion into gut\n"
"• <b>Dumping syndrome</b> — rapid transit after gastric surgery → osmotic diarrhoea\n"
"• <b>C. difficile</b> — hospital-acquired, antibiotic-associated\n\n"
"<i>Post-operative diarrhoea: always first exclude toxic megacolon (C. diff)</i>"
),
"source": "Goldman-Cecil Medicine; Bailey & Love's Surgery; Sleisenger & Fordtran's"
},
# ── COMPLICATIONS ────────────────────────────────────────────────────────
{
"category": "Complications",
"q": "What are the complications of acute severe diarrhoea?",
"a": (
"<b>Fluid and electrolyte complications:</b>\n"
"• <b>Dehydration</b> — mild, moderate, severe\n"
"• <b>Hyponatraemia / hypernatraemia</b>\n"
"• <b>Hypokalaemia</b> — from stool potassium losses\n"
"• <b>Metabolic acidosis</b> — HCO₃⁻ loss in stool\n\n"
"<b>Infective complications:</b>\n"
"• <b>Bacteraemia / septicaemia</b> — Salmonella, Shigella\n"
"• <b>Haemolytic Uraemic Syndrome (HUS)</b> — EHEC O157:H7 → thrombotic microangiopathy\n"
"• <b>Reactive arthritis</b> — post-Campylobacter, Salmonella, Shigella, Yersinia\n"
"• <b>Toxic megacolon</b> — C. difficile, IBD\n\n"
"<b>Nutritional:</b> malnutrition (especially in children in developing countries)"
),
"source": "Guyton & Hall; Sleisenger & Fordtran's"
},
{
"category": "Complications",
"q": "What is Haemolytic Uraemic Syndrome (HUS) and which pathogen causes it?",
"a": (
"<b>Cause:</b> Enterohaemorrhagic <i>E. coli</i> <b>O157:H7</b> (EHEC)\n"
"• Produces Shiga toxin (verotoxin) → systemic absorption\n\n"
"<b>Classic triad of HUS:</b>\n"
"1. <b>Microangiopathic haemolytic anaemia</b> (MAHA)\n"
"2. <b>Thrombocytopaenia</b>\n"
"3. <b>Acute kidney injury</b>\n\n"
"<b>Clinical features:</b> Haemorrhagic colitis → 5–10 days later: pallor, oedema, oliguria, purpura\n\n"
"<b>Management:</b> Supportive (dialysis if needed); <b>avoid antibiotics</b> (may lyse bacteria → ↑ toxin release) and anti-motility agents\n\n"
"<b>Prognosis:</b> Most children recover; 5% mortality"
),
"source": "Harrison's Principles; Sleisenger & Fordtran's"
},
{
"category": "Complications",
"q": "What is toxic megacolon and how is it recognised?",
"a": (
"<b>Definition:</b> Non-obstructive dilatation of the colon (>6 cm) with systemic toxicity\n\n"
"<b>Causes:</b>\n"
"• <b>C. difficile</b> (most common in hospital setting)\n"
"• Inflammatory bowel disease (UC > Crohn's)\n\n"
"<b>Clinical features:</b>\n"
"• <b>Paradoxical decrease in diarrhoea</b> (ileus)\n"
"• Fever, tachycardia, hypotension, delirium (signs of sepsis)\n"
"• Abdominal distension, tenderness\n\n"
"<b>Investigations:</b> AXR — colonic dilatation >6 cm\n\n"
"<b>Management:</b> NBM, IV fluids, antibiotics (IV metronidazole + oral vancomycin for CDI), surgical review (subtotal colectomy if no improvement in 24–72h)"
),
"source": "Goldman-Cecil Medicine; Sleisenger & Fordtran's"
},
]
# ── Build PDF ─────────────────────────────────────────────────────────────────
def build_pdf(output_path, cards):
doc = SimpleDocTemplate(
output_path,
pagesize=A4,
leftMargin=18*mm, rightMargin=18*mm,
topMargin=20*mm, bottomMargin=20*mm,
)
styles = getSampleStyleSheet()
# Custom styles
cover_title = ParagraphStyle("CoverTitle", parent=styles["Title"],
fontSize=32, textColor=TEAL, spaceAfter=6, alignment=TA_CENTER, fontName="Helvetica-Bold")
cover_sub = ParagraphStyle("CoverSub", parent=styles["Normal"],
fontSize=14, textColor=GREY_MID, alignment=TA_CENTER, spaceAfter=4)
cover_meta = ParagraphStyle("CoverMeta", parent=styles["Normal"],
fontSize=10, textColor=GREY_MID, alignment=TA_CENTER)
cat_header = ParagraphStyle("CatHeader", parent=styles["Normal"],
fontSize=13, fontName="Helvetica-Bold", textColor=WHITE,
alignment=TA_CENTER, spaceAfter=0, spaceBefore=0)
card_num = ParagraphStyle("CardNum", parent=styles["Normal"],
fontSize=8, textColor=GREY_MID, alignment=TA_LEFT, spaceAfter=2)
q_style = ParagraphStyle("Q", parent=styles["Normal"],
fontSize=11, fontName="Helvetica-Bold", textColor=GREY_DARK,
spaceAfter=6, leading=15)
a_style = ParagraphStyle("A", parent=styles["Normal"],
fontSize=10, textColor=GREY_DARK,
spaceAfter=3, leading=14)
src_style = ParagraphStyle("Src", parent=styles["Normal"],
fontSize=8, textColor=GREY_MID, alignment=TA_LEFT, spaceBefore=4)
def make_divider(color):
return HRFlowable(width="100%", thickness=1, color=color, spaceAfter=6, spaceBefore=2)
story = []
# ── Cover page ────────────────────────────────────────────────────────────
story.append(Spacer(1, 60*mm))
story.append(Paragraph("Diarrhoea", cover_title))
story.append(Spacer(1, 4*mm))
story.append(Paragraph("Medical Flashcard Set", cover_sub))
story.append(Spacer(1, 6*mm))
story.append(HRFlowable(width="60%", thickness=2, color=TEAL, spaceAfter=10, spaceBefore=4))
story.append(Spacer(1, 4*mm))
story.append(Paragraph(f"{len(cards)} Cards • 9 Categories", cover_meta))
story.append(Spacer(1, 3*mm))
story.append(Paragraph("Definition • Pathophysiology • Classification • Clinical Features", cover_meta))
story.append(Paragraph("Causes • Investigations • Management • Complications", cover_meta))
story.append(Spacer(1, 12*mm))
story.append(Paragraph("Based on: Sleisenger & Fordtran's GI and Liver Disease • Harrison's • Guyton & Hall • Goldman-Cecil Medicine", cover_meta))
story.append(PageBreak())
# ── Cards ─────────────────────────────────────────────────────────────────
cat_order = list(dict.fromkeys(c["category"] for c in cards))
cat_counts = {cat: sum(1 for c in cards if c["category"] == cat) for cat in cat_order}
card_counter = 0
current_cat = None
for i, card in enumerate(cards):
cat = card["category"]
hdr_bg, hdr_fg, card_bg, accent = CAT_COLORS.get(cat, (TEAL, WHITE, TEAL_LIGHT, TEAL))
# Category separator
if cat != current_cat:
if current_cat is not None:
story.append(Spacer(1, 4*mm))
# Category header bar
header_table = Table(
[[Paragraph(f"⬛ {cat} ({cat_counts[cat]} cards)", cat_header)]],
colWidths=["100%"]
)
header_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), hdr_bg),
("TOPPADDING", (0,0), (-1,-1), 8),
("BOTTOMPADDING", (0,0), (-1,-1), 8),
("LEFTPADDING", (0,0), (-1,-1), 12),
("RIGHTPADDING", (0,0), (-1,-1), 12),
("ROUNDEDCORNERS", (0,0), (-1,-1), [6, 6, 6, 6]),
]))
story.append(KeepTogether([header_table, Spacer(1, 3*mm)]))
current_cat = cat
card_counter += 1
# Build card content
q_text = card["q"]
a_text = card["a"].replace("\n", "<br/>")
src_text = f"Source: {card['source']}"
inner = [
Paragraph(f"Card {card_counter} of {len(cards)}", card_num),
make_divider(accent),
Paragraph(f"Q: {q_text}", q_style),
make_divider(accent),
Paragraph(f"<b>Answer:</b>", a_style),
Paragraph(a_text, a_style),
Spacer(1, 2*mm),
Paragraph(src_text, src_style),
]
card_table = Table(
[[inner]],
colWidths=["100%"]
)
card_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), card_bg),
("TOPPADDING", (0,0), (-1,-1), 10),
("BOTTOMPADDING", (0,0), (-1,-1), 10),
("LEFTPADDING", (0,0), (-1,-1), 14),
("RIGHTPADDING", (0,0), (-1,-1), 14),
("BOX", (0,0), (-1,-1), 1.5, accent),
("ROUNDEDCORNERS", (0,0), (-1,-1), [8, 8, 8, 8]),
]))
story.append(KeepTogether([card_table, Spacer(1, 5*mm)]))
doc.build(story)
print(f"PDF written: {output_path} ({len(cards)} cards)")
build_pdf(OUTPUT, FLASHCARDS)
cd /home/daytona/workspace/diarrhoea-flashcards && python generate_flashcards.py
Diarrhoea Flashcards
PDF Document · PDF
| Category | Cards |
|---|---|
| Definition & Epidemiology | 2 |
| Pathophysiology | 5 |
| Classification | 3 |
| Clinical Features | 3 |
| Causes & Aetiology | 5 |
| Investigations | 3 |
| Management | 5 |
| Special Situations | 4 |
| Complications | 3 |