Give in detail about 9 quadrat ana patho pom surgery medicine

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Searching Images

nine abdominal regions quadrants diagram anatomy

Loading Image
Loading Image
Finding Sources
Finding Sources
I now have everything I need for a comprehensive, well-illustrated answer. Let me compile the full detailed response covering all 9 abdominal regions across anatomy, pathology, pharmacology (POM), surgery, and medicine.

The 9 Abdominal Regions (Quadrants) — Anatomy, Pathology, Pharmacology, Surgery & Medicine

Anatomical Basis of the Nine-Region Division

The abdomen is divided into 9 regions by 4 planes:
  • Two horizontal planes: Subcostal plane (below costal margins, at lower border of costal cartilage of rib X / vertebra LIII) and Intertubercular plane (connecting iliac crest tubercles / vertebra LV)
  • Two vertical (midclavicular) planes: Running from midpoint of clavicles to midpoint between ASIS and pubic symphysis
(Gray's Anatomy for Students)
Nine abdominal regions diagram — Gray's Anatomy

Nine sites of abdominal pain with clinical conditions — Bailey and Love

Region 1: Right Hypochondrium (Right Subcostal)

Anatomy

  • Liver (right lobe — primary location), gallbladder, hepatic flexure of colon, right kidney (upper pole), right adrenal gland, part of duodenum

Pathology

  • Hepatitis (viral, alcoholic, autoimmune) — tender hepatomegaly
  • Cholecystitis (acute/chronic) — Murphy's sign positive
  • Cholelithiasis — biliary colic
  • Liver abscess, hepatocellular carcinoma
  • Subphrenic abscess

Pharmacology (POM)

  • Ursodeoxycholic acid — dissolution of cholesterol gallstones; also used in primary biliary cholangitis
  • Antivirals (tenofovir, entecavir for HBV; sofosbuvir/ledipasvir for HCV)
  • Analgesics: Antispasmodics (hyoscine butylbromide) for biliary colic
  • Avoid hepatotoxic drugs (paracetamol overdose, statins, isoniazid) — monitor LFTs

Surgery

  • Laparoscopic cholecystectomy — gold standard for symptomatic gallstones (4-port technique; camera at umbilicus, working ports at epigastrium and right upper quadrant)
  • Open cholecystectomy (Kocher's incision — right subcostal) for complicated cases
  • ERCP + sphincterotomy for choledocholithiasis
  • Liver resection (hepatectomy) for HCC/metastases

Medicine

  • Murphy's sign (right subcostal tenderness on inspiration) — pathognomonic of cholecystitis
  • RUQ pain + jaundice + fever = Charcot's triad (cholangitis)
  • Courvoisier's law: palpable gallbladder + jaundice = likely malignancy (not gallstones)
  • US abdomen is first-line imaging; MRCP for bile duct evaluation

Region 2: Epigastric Region

Anatomy

  • Stomach, duodenum (D1, D2), liver (left lobe), pancreas (head and body), lesser omentum, abdominal aorta, inferior vena cava, coeliac axis

Pathology

  • Peptic ulcer disease (gastric/duodenal) — burning epigastric pain, worse/better with food
  • Acute pancreatitis — severe epigastric pain radiating to back
  • Gastritis, GORD
  • Aortic aneurysm (AAA) — pulsatile epigastric mass
  • Gastric cancer

Pharmacology (POM)

  • PPIs (omeprazole, lansoprazole) — first-line for GORD, peptic ulcer, H. pylori eradication
  • H2-blockers (ranitidine, famotidine) — second-line
  • H. pylori triple therapy: PPI + clarithromycin + amoxicillin (7–14 days)
  • Antacids (magnesium hydroxide, aluminium hydroxide) — symptomatic relief
  • Octreotide — reduces pancreatic secretions in acute pancreatitis
  • IV morphine or pethidine for severe pancreatitis pain
  • Prokinetics (metoclopramide, domperidone) for gastroparesis/GORD

Surgery

  • Truncal vagotomy + pyloroplasty (historical) for peptic ulcer
  • Billroth I/II gastrectomy or Roux-en-Y reconstruction for gastric cancer
  • Whipple's procedure (pancreaticoduodenectomy) for pancreatic head/periampullary cancer
  • Endoscopic hemostasis for bleeding peptic ulcer (adrenaline injection, clips)
  • AAA repair — open (midline laparotomy) or EVAR (endovascular)

Medicine

  • Ranson's criteria / APACHE II / Glasgow score for pancreatitis severity
  • Cullen's sign (periumbilical bruising) + Grey Turner's sign (flank bruising) = severe pancreatitis with retroperitoneal hemorrhage
  • H. pylori testing: urea breath test, stool antigen, biopsy (CLO test)
  • Epigastric pain + ECG changes → rule out inferior MI (referred pain via phrenic nerve)

Region 3: Left Hypochondrium (Left Subcostal)

Anatomy

  • Spleen, tail of pancreas, stomach (fundus), left kidney (upper pole), left adrenal gland, splenic flexure of colon

Pathology

  • Splenomegaly (malaria, CML, portal hypertension, EBV, lymphoma)
  • Splenic injury/rupture — trauma; Kehr's sign (left shoulder tip pain)
  • Splenic infarct — sickle cell disease, emboli
  • Gastric volvulus
  • Subphrenic abscess (left)

Pharmacology (POM)

  • Hydroxycarbamide (hydroxyurea) — reduces sickling crises; prevents splenic infarction in sickle cell disease
  • Anti-malarials (artemisinin-based, chloroquine, quinine)
  • Penicillin V prophylaxis — lifelong post-splenectomy to prevent overwhelming post-splenectomy infection (OPSI)
  • Vaccines post-splenectomy: pneumococcal (PCV13/PPSV23), meningococcal (ACWY + B), Hib, annual influenza

Surgery

  • Splenectomy (laparoscopic preferred) — for trauma, ITP refractory to treatment, hereditary spherocytosis, hypersplenism
  • Splenic artery embolization (non-operative management of splenic laceration grade I–III)
  • Distal pancreatectomy ± splenectomy for pancreatic tail tumours

Medicine

  • Massive splenomegaly causes: CML, myelofibrosis, visceral leishmaniasis (kala-azar), tropical splenomegaly
  • Traube's space dullness on percussion indicates splenomegaly
  • OPSI — potentially fatal; highest risk in first 2 years post-splenectomy; caused by encapsulated organisms (S. pneumoniae, N. meningitidis, H. influenzae)

Region 4: Right Flank (Right Lumbar / Right Lateral)

Anatomy

  • Ascending colon, right kidney (main body), right ureter, small intestinal loops, right psoas muscle, right quadratus lumborum

Pathology

  • Renal colic (ureteric stones) — severe colicky loin-to-groin pain, hematuria
  • Pyelonephritis — loin pain, fever, dysuria; positive renal angle tenderness (CVAT)
  • Renal cell carcinoma — classic triad: hematuria, loin pain, palpable mass
  • Crohn's disease (right-sided involvement)
  • Retroperitoneal fibrosis

Pharmacology (POM)

  • Alpha-blockers (tamsulosin) — facilitate ureteric stone passage (medical expulsive therapy)
  • NSAIDs (diclofenac IV/IM) — first-line analgesia for renal colic (reduces ureteral spasm + prostaglandin-mediated inflammation)
  • Opioids (morphine, pethidine) — adjunct for severe renal colic
  • Antibiotics for pyelonephritis: ciprofloxacin or co-amoxiclav (7–14 days); IV gentamicin + amoxicillin if severe
  • Sunitinib, pazopanib, nivolumab — targeted/immunotherapy for metastatic RCC

Surgery

  • Ureteroscopy + laser lithotripsy for ureteric calculi
  • ESWL (extracorporeal shock wave lithotripsy) for renal/proximal ureteric stones
  • Percutaneous nephrolithotomy (PCNL) for large staghorn calculi
  • Radical nephrectomy for RCC
  • Right hemicolectomy for Crohn's stricture / ascending colon cancer

Medicine

  • Renal angle tenderness (costovertebral angle) — pyelonephritis vs. musculoskeletal vs. renal colic
  • Urinalysis + urine culture mandatory; CT KUB (non-contrast) is gold standard for renal/ureteric calculi
  • ACE inhibitors/ARBs for renoprotection in diabetic nephropathy

Region 5: Umbilical Region (Periumbilical)

Anatomy

  • Small intestine (jejunum, ileum), transverse colon, abdominal aorta, inferior mesenteric artery origin, lymph nodes, umbilicus, mesentery

Pathology

  • Small bowel obstruction — colicky periumbilical pain, distension, vomiting, absolute constipation
  • Aortic aneurysm (AAA) — pulsatile mass at/above umbilicus; pain may radiate to back
  • Mesenteric ischemia — "pain out of proportion to signs"; postprandial angina
  • Umbilical hernia
  • Early appendicitis — visceral pain starts periumbilical before migrating to RIF (McBurney's point)

Pharmacology (POM)

  • IV fluids (crystalloids) + nasogastric decompression for bowel obstruction
  • Anticoagulants (heparin, warfarin) — prevent/treat mesenteric venous thrombosis
  • Thrombolytics / papaverine — intra-arterial for acute mesenteric ischemia (non-occlusive)
  • Antifibrinolytics are avoided
  • Beta-blockers — reduce AAA expansion rate (evidence for propranolol; currently used perioperatively)
  • Statins — slow aneurysm growth and reduce cardiovascular events

Surgery

  • Emergency laparotomy — for ruptured AAA (massive mortality); EVAR if available
  • Elective AAA repair — when >5.5 cm (men), >5 cm (women), or rapid expansion
  • Adhesiolysis — for adhesion-related SBO (laparoscopic or open)
  • Bowel resection — for mesenteric ischemia with necrosis (second-look laparotomy at 24–48 h)
  • Umbilical hernia repair — mesh or primary suture

Medicine

  • Cullen's sign (periumbilical bruising) = hemorrhagic pancreatitis or ruptured ectopic pregnancy
  • Sister Mary Joseph nodule = periumbilical lymph node metastasis from intra-abdominal malignancy
  • Aortic bruit on auscultation → investigate with US abdomen for AAA
  • Small bowel obstruction: "ladder pattern" (dilated loops with valvulae conniventes) on plain AXR

Region 6: Left Flank (Left Lumbar / Left Lateral)

Anatomy

  • Descending colon, left kidney, left ureter, small bowel loops, left psoas muscle, left quadratus lumborum

Pathology

  • Renal colic (left ureteric stones)
  • Pyelonephritis (left)
  • Polycystic kidney disease (bilateral flank masses)
  • Descending colon cancer — iron deficiency anemia, change in bowel habit
  • Retroperitoneal hematoma

Pharmacology (POM)

  • Same as right flank (NSAIDs, alpha-blockers for stones; antibiotics for UTI/pyelonephritis)
  • FOLFOX / FOLFIRI (fluorouracil + oxaliplatin or irinotecan) — chemotherapy for colon cancer
  • Bevacizumab (anti-VEGF) — add-on for metastatic colorectal cancer
  • Tolvaptan — vasopressin receptor antagonist for ADPKD (slows cyst growth)

Surgery

  • Same urological procedures as right flank
  • Left hemicolectomy for descending colon cancer
  • Bilateral laparoscopic nephrectomy in ADPKD (prior to transplantation if massive enlargement)

Medicine

  • PKD: bilateral flank masses + hypertension + hematuria; associated with berry aneurysms (screen MRA)
  • Descending colon cancer often presents with obstruction (narrower lumen than right colon); less likely to cause anemia than right-sided cancers

Region 7: Right Iliac Fossa (Right Groin / Right Inguinal Region)

Anatomy

  • Appendix (most common position: retrocaecal, 65%), caecum, terminal ileum, right ovary + right fallopian tube (females), right ureter (lower), psoas muscle, inguinal ligament, femoral/inguinal canal structures

Pathology

  • Acute appendicitis — most common surgical emergency worldwide
  • Ectopic pregnancy (right) — acute pain; positive bhCG; US shows no intrauterine pregnancy
  • Ovarian cyst / Mittelschmerz / Ovarian torsion
  • Mesenteric adenitis (children — mimics appendicitis)
  • Inguinal hernia (indirect most common, especially in males)
  • Crohn's disease (terminal ileitis)
  • Caecal carcinoma
  • Psoas abscess

Pharmacology (POM)

  • IV antibiotics pre-/post-appendicectomy: cefuroxime + metronidazole (covers aerobes + anaerobes)
  • Piperacillin-tazobactam or meropenem for complicated (perforated) appendicitis
  • Analgesia: IV opioids (morphine) — does NOT mask peritonism in studies; safe to give
  • Methotrexate — medical management of ectopic pregnancy (if unruptured, β-hCG <3000, no cardiac activity)
  • Mesalazine / azathioprine / biologics (infliximab, adalimumab) — Crohn's disease management

Surgery

  • Laparoscopic appendicectomy — standard of care; McBurney's point incision used in open (grid-iron incision)
  • Antibiotic-only management of uncomplicated appendicitis (Appendicitis Acuta trial) — controversial but gaining acceptance
  • Appendicectomy + right hemicolectomy for caecal carcinoma found incidentally
  • Inguinal hernia repair: open (Lichtenstein mesh) or laparoscopic (TEP/TAPP)
  • Salpingectomy / salpingostomy for ectopic pregnancy

Medicine

  • McBurney's point: 1/3 of the way from ASIS to umbilicus
  • Rovsing's sign (palpation LIF causes RIF pain), Psoas sign, Obturator sign
  • Alvarado score (MANTRELS) for appendicitis diagnosis
  • In women of childbearing age: always check β-hCG before attributing RIF pain to appendicitis

Region 8: Pubic/Hypogastric Region (Suprapubic)

Anatomy

  • Urinary bladder, uterus (body and cervix), fallopian tubes (bilateral), rectum/sigmoid colon junction, prostate (males), ureters (terminal portions), seminal vesicles

Pathology

  • Pelvic inflammatory disease (PID) — bilateral lower abdominal pain, vaginal discharge, cervical excitation
  • Ovarian cysts (bilateral)
  • Cystitis / UTI — suprapubic pain, dysuria, frequency
  • Bladder cancer — painless hematuria
  • Fibroids (uterine leiomyomas) — menorrhagia, pressure symptoms
  • Pelvic peritonitis / Pouch of Douglas abscess (pelvic abscess)
  • BPH / prostate cancer (males)

Pharmacology (POM)

  • Antibiotics for PID: doxycycline + metronidazole ± ceftriaxone (covers C. trachomatis, N. gonorrhoeae, anaerobes)
  • Antibiotics for UTI: trimethoprim, nitrofurantoin (uncomplicated); ciprofloxacin (complicated)
  • Antispasmodics / anticholinergics (oxybutynin, solifenacin) for overactive bladder
  • 5-alpha reductase inhibitors (finasteride) + alpha-blockers (tamsulosin) for BPH
  • GnRH agonists (leuprolide) for fibroids (induces medical menopause preoperatively)
  • NSAIDs / mefenamic acid for dysmenorrhea and fibroid-related pain
  • Combined oral contraceptive — suppresses endometriosis, reduces PID recurrence

Surgery

  • Laparoscopic drainage of pelvic abscess (Pouch of Douglas)
  • TURP / laser prostatectomy for BPH
  • Radical cystectomy + neobladder for muscle-invasive bladder cancer
  • Total abdominal hysterectomy ± bilateral salpingo-oophorectomy (TAH-BSO) for fibroids/cancer
  • Anterior/posterior repair (colporrhaphy) for pelvic organ prolapse
  • Pelvic lymph node dissection — staging for cervical/endometrial/bladder malignancy

Medicine

  • Fitz-Hugh-Curtis syndrome: right upper quadrant pain (perihepatic adhesions) secondary to ascending PID — mimics cholecystitis
  • Cervical motion tenderness (chandelier sign) = PID
  • PSA + TRUS-guided biopsy for prostate cancer; Gleason score for grading
  • Bimanual examination essential for pelvic pathology; transvaginal US for ovarian/uterine lesions

Region 9: Left Iliac Fossa (Left Groin / Left Inguinal Region)

Anatomy

  • Sigmoid colon, descending colon (lower), left ovary + left fallopian tube (females), left ureter (lower), inguinal structures (left), psoas muscle (left lower)

Pathology

  • Diverticulitis — "left-sided appendicitis"; older patients; LIF pain, fever, altered bowel habit
  • Diverticular abscess / perforation — peritonitis, pneumoperitoneum
  • Sigmoid colon cancer — change in bowel habit, bleeding PR, obstruction
  • Ectopic pregnancy (left)
  • Ovarian pathology (left) — same as right
  • Inguinal hernia (left)
  • Constipation (very common cause of LIF pain, especially elderly)

Pharmacology (POM)

  • Antibiotics for uncomplicated diverticulitis: metronidazole + ciprofloxacin (outpatient); IV co-amoxiclav or piperacillin-tazobactam (inpatient)
  • Recent evidence (DIABOLO trial, AVOD trial): antibiotics may not be needed for uncomplicated acute diverticulitis — conservative management (bowel rest, analgesia) gaining acceptance
  • Mesalazine — reduces recurrence of diverticulitis (limited evidence)
  • High-fibre diet — prevents diverticular disease progression
  • FOLFOX/FOLFIRI + bevacizumab — for metastatic sigmoid colon cancer
  • Osmotic laxatives (lactulose, macrogol) and stimulant laxatives (senna, bisacodyl) for constipation

Surgery

  • Hartmann's procedure — emergency sigmoid resection + end colostomy (for perforated diverticulitis with Hinchey III/IV peritonitis)
  • Laparoscopic sigmoid colectomy — elective, after resolution of recurrent/complicated diverticulitis (usually ≥2 attacks or single complicated episode)
  • Emergency Hartmann's reversal — reconnection of Hartmann's stoma (colostomy takedown)
  • Anterior resection — for sigmoid colon / upper rectal cancer (with or without defunctioning ileostomy)
  • Abdominoperineal resection (APR) — for low rectal cancer where sphincter cannot be preserved

Medicine

  • Hinchey classification for perforated diverticulitis (I: pericolic abscess → IV: fecal peritonitis)
  • CT abdomen/pelvis with IV contrast is the investigation of choice
  • Colonoscopy contraindicated in acute diverticulitis (risk of perforation) — perform 6–8 weeks after resolution
  • Diverticular disease vs. diverticulitis: former is asymptomatic; latter implies infection/inflammation

Summary Table

RegionKey OrgansKey PathologyKey SurgeryKey Drugs
R. HypochondriumLiver, GallbladderCholecystitis, HepatitisLaparoscopic cholecystectomyUrsodeoxycholic acid, PPIs, antivirals
EpigastricStomach, Duodenum, PancreasPUD, Pancreatitis, AAAWhipple's, gastrectomy, EVARPPIs, H. pylori triple therapy, octreotide
L. HypochondriumSpleen, Stomach fundusSplenomegaly, Splenic ruptureSplenectomyPenicillin V (post-splenectomy), hydroxyurea
R. FlankR. Kidney, Ascending colonRenal colic, Pyelonephritis, RCCNephrectomy, ureteroscopy, PCNLNSAIDs, tamsulosin, ciprofloxacin
UmbilicalSmall bowel, AortaSBO, AAA, Mesenteric ischemiaLaparotomy, EVAR, adhesiolysisIV fluids, heparin, statins
L. FlankL. Kidney, Descending colonRenal colic, Colon cancer, PKDHemicolectomy, nephrectomyFOLFOX, tolvaptan, NSAIDs
R. Iliac FossaAppendix, Caecum, R. OvaryAppendicitis, Ectopic pregnancy, Crohn'sAppendicectomy, hernia repairCefuroxime + metronidazole, methotrexate
Pubic/HypogastricBladder, Uterus, RectumPID, Cystitis, BPH, Bladder CaCystectomy, TURP, hysterectomyDoxycycline + metronidazole, tamsulosin
L. Iliac FossaSigmoid colon, L. OvaryDiverticulitis, Sigmoid Ca, EctopicHartmann's, anterior resectionMetronidazole + ciprofloxacin, FOLFOX

Sources:
  • Gray's Anatomy for Students, Nine-region pattern (block2, p. 336)
  • Bailey and Love's Short Practice of Surgery, 28th Edition, Figure 63.2
  • Tintinalli's Emergency Medicine, Rosen's Emergency Medicine, Sleisenger & Fordtran's Gastrointestinal and Liver Disease, Yamada's Textbook of Gastroenterology — clinical correlations throughout

Give pdf

Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace

Running Command

mkdir -p /home/daytona/workspace/9-abdominal-regions && python3 -c " from reportlab.lib.pagesizes import A4 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import cm from reportlab.lib import colors from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable, PageBreak from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY import urllib.request import os # Download images img_gray = '/home/daytona/workspace/9-abdominal-regions/gray_regions.png' img_bailey = '/home/daytona/workspace/9-abdominal-regions/bailey_pain.png' urllib.request.urlretrieve( 'https://cdn.orris.care/cdss_images/e74140efb1a0c95902c5bf7b8e6d28e12f99a04f7ddff75973b9edfeff4c6464.png', img_gray ) urllib.request.urlretrieve( 'https://cdn.orris.care/cdss_images/BAILY_1760530893882_a5e3a51d-802c-46b5-94c3-b2d3b0f8c01f.png', img_bailey ) print('Images downloaded:', os.path.exists(img_gray), os.path.exists(img_bailey)) "

Writing File

~/9-abdominal-regions/generate_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, Image, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
import os

OUTPUT = '/home/daytona/workspace/9-abdominal-regions/9_Abdominal_Regions.pdf'
IMG_GRAY = '/home/daytona/workspace/9-abdominal-regions/gray_regions.png'
IMG_BAILEY = '/home/daytona/workspace/9-abdominal-regions/bailey_pain.png'

doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    rightMargin=2*cm, leftMargin=2*cm,
    topMargin=2*cm, bottomMargin=2*cm
)

W, H = A4
styles = getSampleStyleSheet()

# Custom styles
title_style = ParagraphStyle('Title', parent=styles['Title'],
    fontSize=22, textColor=colors.HexColor('#1a237e'),
    spaceAfter=6, alignment=TA_CENTER, fontName='Helvetica-Bold')

subtitle_style = ParagraphStyle('Subtitle', parent=styles['Normal'],
    fontSize=11, textColor=colors.HexColor('#37474f'),
    spaceAfter=12, alignment=TA_CENTER)

h1_style = ParagraphStyle('H1', parent=styles['Heading1'],
    fontSize=16, textColor=colors.white,
    spaceBefore=14, spaceAfter=6,
    fontName='Helvetica-Bold', backColor=colors.HexColor('#1a237e'),
    leftIndent=-0.5*cm, rightIndent=-0.5*cm,
    borderPad=6)

h2_style = ParagraphStyle('H2', parent=styles['Heading2'],
    fontSize=12, textColor=colors.HexColor('#1a237e'),
    spaceBefore=10, spaceAfter=4,
    fontName='Helvetica-Bold',
    borderPad=3)

h3_style = ParagraphStyle('H3', parent=styles['Heading3'],
    fontSize=10, textColor=colors.HexColor('#b71c1c'),
    spaceBefore=6, spaceAfter=3,
    fontName='Helvetica-Bold')

body_style = ParagraphStyle('Body', parent=styles['Normal'],
    fontSize=9.5, leading=14,
    spaceAfter=4, alignment=TA_JUSTIFY,
    fontName='Helvetica')

bullet_style = ParagraphStyle('Bullet', parent=styles['Normal'],
    fontSize=9.5, leading=13, leftIndent=14,
    bulletIndent=4, spaceAfter=2,
    fontName='Helvetica')

caption_style = ParagraphStyle('Caption', parent=styles['Normal'],
    fontSize=8, textColor=colors.grey,
    alignment=TA_CENTER, spaceAfter=6)

def h1(text):
    return Paragraph(f'&nbsp;&nbsp;{text}', h1_style)

def h2(text):
    return Paragraph(text, h2_style)

def h3(text):
    return Paragraph(text, h3_style)

def body(text):
    return Paragraph(text, body_style)

def bullet(text):
    return Paragraph(f'• {text}', bullet_style)

def sp(n=1):
    return Spacer(1, n*0.3*cm)

def hr():
    return HRFlowable(width='100%', thickness=0.5, color=colors.HexColor('#b0bec5'), spaceAfter=4)

story = []

# ── COVER PAGE ─────────────────────────────────────────────────────────────────
story.append(Spacer(1, 3*cm))
story.append(Paragraph('The 9 Abdominal Regions', title_style))
story.append(sp(0.5))
story.append(Paragraph('Anatomy · Pathology · Pharmacology (POM) · Surgery · Medicine', subtitle_style))
story.append(sp(0.5))
story.append(HRFlowable(width='80%', thickness=2, color=colors.HexColor('#1a237e'), spaceAfter=10))
story.append(sp(1))

# Add both images side by side on cover
if os.path.exists(IMG_GRAY) and os.path.exists(IMG_BAILEY):
    img1 = Image(IMG_GRAY, width=7.5*cm, height=9*cm)
    img2 = Image(IMG_BAILEY, width=7.5*cm, height=9*cm)
    cover_table = Table([[img1, img2]], colWidths=[8*cm, 8*cm])
    cover_table.setStyle(TableStyle([
        ('ALIGN', (0,0), (-1,-1), 'CENTER'),
        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ]))
    story.append(cover_table)
    story.append(sp(0.3))
    story.append(Paragraph('Left: Gray\'s Anatomy for Students — Nine-region pattern  |  Right: Bailey & Love — Nine sites of abdominal pain', caption_style))

story.append(Spacer(1, 2*cm))
story.append(Paragraph('Sources: Gray\'s Anatomy for Students · Bailey & Love\'s Short Practice of Surgery ·\nTintinalli\'s Emergency Medicine · Rosen\'s Emergency Medicine ·\nSleisenger & Fordtran\'s GI & Liver Disease · Yamada\'s Textbook of Gastroenterology', subtitle_style))
story.append(PageBreak())

# ── INTRO ──────────────────────────────────────────────────────────────────────
story.append(h1('Anatomical Basis of the Nine-Region Division'))
story.append(sp())
story.append(body(
    'The abdomen is divided into <b>9 regions</b> by <b>4 planes</b>:'
))
story.append(bullet('<b>Subcostal plane (superior horizontal)</b>: immediately inferior to costal margins at lower border of costal cartilage of rib X, passing posteriorly through vertebra LIII.'))
story.append(bullet('<b>Intertubercular plane (inferior horizontal)</b>: connecting tubercles of iliac crests (~5 cm posterior to ASIS), passing through upper body of vertebra LV.'))
story.append(bullet('<b>Two midclavicular (vertical) planes</b>: from midpoint of clavicles inferiorly to midpoint between ASIS and pubic symphysis.'))
story.append(sp())
story.append(body(
    'These four planes create nine regions: <b>Right Hypochondrium</b>, <b>Epigastric</b>, <b>Left Hypochondrium</b> (superior row); '
    '<b>Right Flank</b>, <b>Umbilical</b>, <b>Left Flank</b> (middle row); '
    '<b>Right Iliac Fossa</b>, <b>Pubic/Hypogastric</b>, <b>Left Iliac Fossa</b> (inferior row).'
))
story.append(sp(2))

# ─── REGIONS DATA ─────────────────────────────────────────────────────────────
regions = [
    {
        'num': '1',
        'name': 'Right Hypochondrium (Right Subcostal)',
        'anatomy': [
            'Liver (right lobe — primary location)',
            'Gallbladder',
            'Hepatic flexure of colon',
            'Right kidney (upper pole) and right adrenal gland',
            'Part of duodenum (D1)',
        ],
        'pathology': [
            '<b>Hepatitis</b> (viral, alcoholic, autoimmune) — tender hepatomegaly',
            '<b>Acute/Chronic Cholecystitis</b> — Murphy\'s sign positive',
            '<b>Cholelithiasis</b> — biliary colic',
            '<b>Liver abscess</b>, Hepatocellular carcinoma (HCC)',
            '<b>Subphrenic abscess</b>',
        ],
        'pharmacology': [
            '<b>Ursodeoxycholic acid</b> — dissolution of cholesterol gallstones; primary biliary cholangitis',
            '<b>Antivirals</b>: tenofovir/entecavir (HBV); sofosbuvir/ledipasvir (HCV)',
            '<b>Antispasmodics</b> (hyoscine butylbromide) for biliary colic pain relief',
            'Avoid <b>hepatotoxic drugs</b> (paracetamol overdose, isoniazid, statins) — monitor LFTs',
        ],
        'surgery': [
            '<b>Laparoscopic cholecystectomy</b> — gold standard for symptomatic gallstones',
            '<b>Open cholecystectomy</b> via Kocher\'s (right subcostal) incision for complicated cases',
            '<b>ERCP + sphincterotomy</b> for choledocholithiasis',
            '<b>Liver resection (hepatectomy)</b> for HCC or colorectal liver metastases',
        ],
        'medicine': [
            '<b>Murphy\'s sign</b>: RUQ tenderness on deep inspiration — pathognomonic for cholecystitis',
            '<b>Charcot\'s triad</b>: RUQ pain + jaundice + fever = ascending cholangitis',
            '<b>Courvoisier\'s law</b>: palpable gallbladder + painless jaundice = malignancy (not stones)',
            'US abdomen = first-line imaging; MRCP for bile duct evaluation',
        ],
    },
    {
        'num': '2',
        'name': 'Epigastric Region',
        'anatomy': [
            'Stomach and duodenum (D1, D2)',
            'Liver (left lobe), lesser omentum',
            'Pancreas (head and body)',
            'Abdominal aorta (coeliac axis origin), inferior vena cava',
        ],
        'pathology': [
            '<b>Peptic ulcer disease</b> (gastric/duodenal) — burning pain; worse/better with food',
            '<b>Acute pancreatitis</b> — severe epigastric pain radiating to the back',
            '<b>Gastritis</b>, GORD',
            '<b>Abdominal aortic aneurysm (AAA)</b> — pulsatile epigastric mass',
            '<b>Gastric cancer</b>',
        ],
        'pharmacology': [
            '<b>PPIs</b> (omeprazole, lansoprazole) — first-line for GORD, peptic ulcer, H. pylori eradication',
            '<b>H. pylori triple therapy</b>: PPI + clarithromycin + amoxicillin (7–14 days)',
            '<b>H2-blockers</b> (famotidine) — second-line acid suppression',
            '<b>Octreotide</b> — reduces pancreatic secretions in acute pancreatitis',
            '<b>IV morphine</b> for severe pancreatitis pain; prokinetics (metoclopramide) for gastroparesis',
        ],
        'surgery': [
            '<b>Whipple\'s procedure</b> (pancreaticoduodenectomy) for pancreatic head/periampullary cancer',
            '<b>Billroth I/II gastrectomy</b> or <b>Roux-en-Y</b> for gastric cancer',
            '<b>Endoscopic hemostasis</b> for bleeding peptic ulcer (adrenaline injection, clips)',
            '<b>AAA repair</b> — open (midline laparotomy) or EVAR (endovascular)',
        ],
        'medicine': [
            '<b>Ranson\'s/Glasgow score</b> for pancreatitis severity assessment',
            '<b>Cullen\'s sign</b> (periumbilical bruising) + <b>Grey Turner\'s sign</b> (flank bruising) = haemorrhagic pancreatitis',
            '<b>H. pylori testing</b>: urea breath test, stool antigen, CLO test on biopsy',
            'Epigastric pain + ECG changes → rule out <b>inferior MI</b> (referred via phrenic nerve)',
        ],
    },
    {
        'num': '3',
        'name': 'Left Hypochondrium (Left Subcostal)',
        'anatomy': [
            'Spleen',
            'Tail of pancreas',
            'Stomach (fundus and body)',
            'Left kidney (upper pole) and left adrenal gland',
            'Splenic flexure of colon',
        ],
        'pathology': [
            '<b>Splenomegaly</b> (malaria, CML, portal hypertension, EBV, lymphoma)',
            '<b>Splenic injury/rupture</b> — trauma; Kehr\'s sign (left shoulder tip pain)',
            '<b>Splenic infarct</b> — sickle cell disease, cardioembolic',
            '<b>Gastric volvulus</b>',
            '<b>Subphrenic abscess</b> (left)',
        ],
        'pharmacology': [
            '<b>Hydroxycarbamide (hydroxyurea)</b> — reduces sickling crises; prevents splenic infarction',
            '<b>Antimalarials</b> (artemisinin-based, chloroquine)',
            '<b>Penicillin V prophylaxis</b> — lifelong post-splenectomy for OPSI prevention',
            '<b>Post-splenectomy vaccines</b>: pneumococcal (PCV13/PPSV23), meningococcal ACWY+B, Hib, annual influenza',
        ],
        'surgery': [
            '<b>Laparoscopic splenectomy</b> — for trauma (grade IV/V), ITP, hereditary spherocytosis',
            '<b>Splenic artery embolization</b> — non-operative for splenic laceration grade I–III',
            '<b>Distal pancreatectomy ± splenectomy</b> for pancreatic tail tumours',
        ],
        'medicine': [
            'Massive splenomegaly causes: CML, myelofibrosis, kala-azar, tropical splenomegaly',
            '<b>Traube\'s space dullness</b> on percussion indicates splenomegaly',
            '<b>OPSI (Overwhelming Post-Splenectomy Infection)</b>: highest risk first 2 years; caused by encapsulated organisms (S. pneumoniae, N. meningitidis, H. influenzae)',
        ],
    },
    {
        'num': '4',
        'name': 'Right Flank (Right Lumbar / Right Lateral)',
        'anatomy': [
            'Right kidney (main body)',
            'Right ureter (upper portion)',
            'Ascending colon',
            'Small intestinal loops',
            'Right psoas muscle, right quadratus lumborum',
        ],
        'pathology': [
            '<b>Renal colic</b> (ureteric stones) — severe colicky loin-to-groin pain, haematuria',
            '<b>Pyelonephritis</b> — loin pain, fever, dysuria; positive CVAT',
            '<b>Renal cell carcinoma (RCC)</b> — classic triad: haematuria + loin pain + mass',
            '<b>Crohn\'s disease</b> (right-sided involvement)',
            '<b>Retroperitoneal fibrosis</b>',
        ],
        'pharmacology': [
            '<b>NSAIDs (diclofenac)</b> — first-line analgesia for renal colic (reduces ureteral spasm)',
            '<b>Alpha-blockers (tamsulosin)</b> — medical expulsive therapy for ureteric stones',
            '<b>Antibiotics for pyelonephritis</b>: ciprofloxacin or co-amoxiclav PO; IV gentamicin + amoxicillin if severe',
            '<b>Sunitinib, pazopanib, nivolumab</b> — targeted/immunotherapy for metastatic RCC',
        ],
        'surgery': [
            '<b>Ureteroscopy + laser lithotripsy</b> for ureteric calculi',
            '<b>ESWL</b> (extracorporeal shock wave lithotripsy) for renal/proximal ureteric stones',
            '<b>PCNL</b> (percutaneous nephrolithotomy) for large staghorn calculi',
            '<b>Radical nephrectomy</b> for RCC',
            '<b>Right hemicolectomy</b> for Crohn\'s stricture / ascending colon cancer',
        ],
        'medicine': [
            '<b>Costovertebral angle tenderness</b> (renal angle) — pyelonephritis vs. renal colic',
            '<b>CT KUB</b> (non-contrast) is gold standard for renal/ureteric calculi',
            'ACE inhibitors/ARBs for renoprotection in diabetic nephropathy',
        ],
    },
    {
        'num': '5',
        'name': 'Umbilical Region (Periumbilical)',
        'anatomy': [
            'Small intestine (jejunum, ileum)',
            'Transverse colon',
            'Abdominal aorta and inferior mesenteric artery origin',
            'Mesentery and mesenteric lymph nodes',
            'Umbilicus',
        ],
        'pathology': [
            '<b>Small bowel obstruction (SBO)</b> — colicky periumbilical pain, distension, vomiting',
            '<b>Abdominal aortic aneurysm (AAA)</b> — pulsatile mass above/at umbilicus; pain → back',
            '<b>Mesenteric ischaemia</b> — "pain out of proportion to signs"; postprandial angina',
            '<b>Umbilical hernia</b>',
            '<b>Early appendicitis</b> — visceral pain starts periumbilical before migrating to RIF',
        ],
        'pharmacology': [
            '<b>IV crystalloids</b> + <b>nasogastric decompression</b> for bowel obstruction',
            '<b>Heparin / warfarin</b> — prevent/treat mesenteric venous thrombosis',
            '<b>Intra-arterial papaverine</b> for non-occlusive mesenteric ischaemia',
            '<b>Statins</b> — slow AAA growth, reduce cardiovascular events',
        ],
        'surgery': [
            '<b>Emergency laparotomy</b> for ruptured AAA; <b>EVAR</b> if anatomically suitable',
            '<b>Elective AAA repair</b>: ≥5.5 cm (men), ≥5 cm (women) or rapid expansion',
            '<b>Adhesiolysis</b> (laparoscopic or open) for adhesion-related SBO',
            '<b>Bowel resection</b> for mesenteric ischaemia with necrosis; second-look at 24–48 h',
            '<b>Umbilical hernia repair</b> — mesh or primary suture',
        ],
        'medicine': [
            '<b>Cullen\'s sign</b> (periumbilical bruising) = haemorrhagic pancreatitis or ruptured ectopic',
            '<b>Sister Mary Joseph nodule</b> = periumbilical lymph node metastasis from intra-abdominal malignancy',
            'SBO: "ladder pattern" (dilated loops with valvulae conniventes) on AXR',
            'Aortic bruit on auscultation → US abdomen for AAA',
        ],
    },
    {
        'num': '6',
        'name': 'Left Flank (Left Lumbar / Left Lateral)',
        'anatomy': [
            'Left kidney (main body)',
            'Left ureter (upper portion)',
            'Descending colon',
            'Small bowel loops',
            'Left psoas muscle, left quadratus lumborum',
        ],
        'pathology': [
            '<b>Renal colic</b> (left ureteric stones)',
            '<b>Pyelonephritis</b> (left)',
            '<b>Polycystic kidney disease (ADPKD)</b> — bilateral flank masses',
            '<b>Descending colon cancer</b> — change in bowel habit, PR bleeding, obstruction',
            '<b>Retroperitoneal haematoma</b>',
        ],
        'pharmacology': [
            'Same as right flank: <b>NSAIDs, tamsulosin</b> for stones; <b>antibiotics</b> for UTI/pyelonephritis',
            '<b>FOLFOX / FOLFIRI</b> (fluorouracil + oxaliplatin or irinotecan) for colon cancer chemotherapy',
            '<b>Bevacizumab</b> (anti-VEGF) — add-on for metastatic colorectal cancer',
            '<b>Tolvaptan</b> — vasopressin V2 receptor antagonist; slows cyst growth in ADPKD',
        ],
        'surgery': [
            'Same urological procedures as right flank (ureteroscopy, ESWL, PCNL)',
            '<b>Left hemicolectomy</b> for descending colon cancer',
            '<b>Bilateral laparoscopic nephrectomy</b> in massive ADPKD prior to transplantation',
        ],
        'medicine': [
            'ADPKD: bilateral flank masses + hypertension + haematuria; associated with berry aneurysms (screen with MRA brain)',
            'Descending colon cancer: presents with <b>obstruction</b> (narrower lumen); less likely to cause iron-deficiency anaemia than right-sided cancer',
        ],
    },
    {
        'num': '7',
        'name': 'Right Iliac Fossa (Right Groin / Right Inguinal Region)',
        'anatomy': [
            'Appendix (retrocaecal in 65% of cases)',
            'Caecum and terminal ileum',
            'Right ovary and right fallopian tube (females)',
            'Right ureter (lower portion)',
            'Inguinal structures: right femoral/inguinal canal',
        ],
        'pathology': [
            '<b>Acute appendicitis</b> — most common surgical emergency worldwide',
            '<b>Ectopic pregnancy</b> (right) — positive β-hCG; no intrauterine pregnancy on US',
            '<b>Ovarian cyst / torsion / Mittelschmerz</b>',
            '<b>Mesenteric adenitis</b> — children; mimics appendicitis',
            '<b>Indirect inguinal hernia</b> — most common, especially males',
            '<b>Crohn\'s disease</b> (terminal ileitis)',
            '<b>Caecal carcinoma / Psoas abscess</b>',
        ],
        'pharmacology': [
            '<b>IV antibiotics peri-appendicectomy</b>: cefuroxime + metronidazole (aerobes + anaerobes)',
            '<b>Piperacillin-tazobactam / meropenem</b> for complicated (perforated) appendicitis',
            '<b>IV morphine</b> — safe to give before diagnosis; does NOT mask peritonism',
            '<b>Methotrexate</b> — medical management of unruptured ectopic pregnancy (β-hCG <3000 IU/L, no cardiac activity)',
            '<b>Infliximab / adalimumab</b> — biologics for Crohn\'s disease',
        ],
        'surgery': [
            '<b>Laparoscopic appendicectomy</b> — standard of care',
            '<b>Open appendicectomy</b> via grid-iron incision at McBurney\'s point (for simple/limited access)',
            '<b>Antibiotic-only management</b> of uncomplicated appendicitis — gaining evidence (APPAC trial)',
            '<b>Inguinal hernia repair</b>: open Lichtenstein (mesh) or laparoscopic TEP/TAPP',
            '<b>Salpingectomy / salpingostomy</b> for ectopic pregnancy',
        ],
        'medicine': [
            '<b>McBurney\'s point</b>: 1/3 from ASIS to umbilicus — maximal tenderness in appendicitis',
            '<b>Rovsing\'s sign</b>: LIF palpation causes RIF pain; <b>Psoas sign</b>; <b>Obturator sign</b>',
            '<b>Alvarado score</b> (MANTRELS) for appendicitis diagnosis; score ≥7 = likely appendicitis',
            'In women of childbearing age: <b>always check β-hCG</b> before attributing RIF pain to appendicitis',
        ],
    },
    {
        'num': '8',
        'name': 'Pubic / Hypogastric Region (Suprapubic)',
        'anatomy': [
            'Urinary bladder',
            'Uterus (body and cervix) and fallopian tubes (females)',
            'Rectum and sigmoid colon junction',
            'Prostate gland (males)',
            'Terminal ureters; seminal vesicles (males)',
        ],
        'pathology': [
            '<b>Pelvic inflammatory disease (PID)</b> — bilateral lower abdominal pain, vaginal discharge, cervical excitation',
            '<b>Ovarian cysts / torsion</b>',
            '<b>Cystitis / UTI</b> — suprapubic pain, dysuria, frequency',
            '<b>Bladder cancer</b> — painless haematuria',
            '<b>Uterine fibroids</b> — menorrhagia, pressure symptoms',
            '<b>BPH / Prostate cancer</b> (males)',
            '<b>Pelvic abscess</b> (Pouch of Douglas)',
        ],
        'pharmacology': [
            '<b>PID antibiotics</b>: doxycycline + metronidazole ± ceftriaxone (covers Chlamydia, Gonorrhoea, anaerobes)',
            '<b>Antibiotics for UTI</b>: trimethoprim/nitrofurantoin (uncomplicated); ciprofloxacin (complicated)',
            '<b>Anticholinergics</b> (oxybutynin, solifenacin) for overactive bladder',
            '<b>5-alpha reductase inhibitors</b> (finasteride) + <b>alpha-blockers</b> (tamsulosin) for BPH',
            '<b>GnRH agonists</b> (leuprolide) for fibroid management (preoperative medical menopause)',
        ],
        'surgery': [
            '<b>Laparoscopic drainage</b> of Pouch of Douglas abscess',
            '<b>TURP / laser prostatectomy</b> for BPH',
            '<b>Radical cystectomy + neobladder</b> for muscle-invasive bladder cancer',
            '<b>Total abdominal hysterectomy ± BSO (TAH-BSO)</b> for fibroids/gynaecological cancer',
            '<b>Colporrhaphy</b> (anterior/posterior repair) for pelvic organ prolapse',
        ],
        'medicine': [
            '<b>Fitz-Hugh-Curtis syndrome</b>: RUQ pain (perihepatic adhesions) secondary to ascending PID — mimics cholecystitis',
            '<b>Chandelier sign</b> (cervical motion tenderness) = PID',
            'PSA + TRUS-guided biopsy for prostate cancer; <b>Gleason score</b> for grading',
            'Transvaginal US — first-line for ovarian/uterine pathology',
        ],
    },
    {
        'num': '9',
        'name': 'Left Iliac Fossa (Left Groin / Left Inguinal Region)',
        'anatomy': [
            'Sigmoid colon and lower descending colon',
            'Left ovary and left fallopian tube (females)',
            'Left ureter (lower portion)',
            'Left inguinal structures',
            'Left psoas muscle (lower)',
        ],
        'pathology': [
            '<b>Diverticulitis</b> — "left-sided appendicitis"; older patients; LIF pain, fever, altered bowel habit',
            '<b>Diverticular abscess / perforation</b> — peritonitis, pneumoperitoneum',
            '<b>Sigmoid colon cancer</b> — change in bowel habit, PR bleeding, obstruction',
            '<b>Ectopic pregnancy</b> (left)',
            '<b>Ovarian pathology</b> (left) — cyst, torsion',
            '<b>Left inguinal hernia</b>',
        ],
        'pharmacology': [
            '<b>Antibiotics for uncomplicated diverticulitis</b>: metronidazole + ciprofloxacin PO; IV co-amoxiclav or pip-taz if severe',
            'Recent evidence (AVOD/DIABOLO trials): antibiotics may not be needed for uncomplicated acute diverticulitis',
            '<b>FOLFOX / FOLFIRI + bevacizumab</b> for metastatic sigmoid colon cancer',
            '<b>Osmotic laxatives</b> (lactulose, macrogol) and <b>stimulant laxatives</b> (senna) for constipation',
            '<b>High-fibre diet</b> — prevents diverticular disease progression',
        ],
        'surgery': [
            '<b>Hartmann\'s procedure</b> — emergency sigmoid resection + end colostomy (Hinchey III/IV peritonitis)',
            '<b>Laparoscopic sigmoid colectomy</b> — elective for recurrent/complicated diverticulitis',
            '<b>Anterior resection</b> — for sigmoid/upper rectal cancer (± defunctioning ileostomy)',
            '<b>Abdominoperineal resection (APR)</b> — for low rectal cancer where sphincter cannot be preserved',
        ],
        'medicine': [
            '<b>Hinchey classification</b> for perforated diverticulitis: I (pericolic abscess) → IV (faecal peritonitis)',
            'CT abdomen/pelvis with IV contrast = investigation of choice for diverticulitis',
            'Colonoscopy contraindicated in <b>acute</b> diverticulitis; perform 6–8 weeks after resolution',
            '<b>Diverticular disease</b> (asymptomatic) vs. <b>diverticulitis</b> (infected/inflamed)',
        ],
    },
]

section_colors = [
    colors.HexColor('#1a237e'),  # deep blue
    colors.HexColor('#4a148c'),  # deep purple
    colors.HexColor('#006064'),  # teal
    colors.HexColor('#b71c1c'),  # deep red
    colors.HexColor('#1b5e20'),  # deep green
    colors.HexColor('#e65100'),  # deep orange
    colors.HexColor('#880e4f'),  # deep pink
    colors.HexColor('#37474f'),  # dark slate
    colors.HexColor('#4e342e'),  # brown
]

sub_headers = ['Anatomy', 'Pathology', 'Pharmacology (POM)', 'Surgery', 'Medicine']
sub_keys = ['anatomy', 'pathology', 'pharmacology', 'surgery', 'medicine']
sub_colors = [
    colors.HexColor('#1565c0'),
    colors.HexColor('#6a1b9a'),
    colors.HexColor('#00695c'),
    colors.HexColor('#b71c1c'),
    colors.HexColor('#2e7d32'),
]

for i, region in enumerate(regions):
    col = section_colors[i]
    
    # Region heading
    h1_p = ParagraphStyle(f'H1_{i}', parent=h1_style, backColor=col)
    story.append(Paragraph(f'&nbsp;&nbsp;Region {region["num"]}: {region["name"]}', h1_p))
    story.append(sp(0.5))
    
    for j, (key, label) in enumerate(zip(sub_keys, sub_headers)):
        sub_col = sub_colors[j]
        h2_p = ParagraphStyle(f'H2_{i}_{j}', parent=h2_style, 
                               textColor=sub_col,
                               borderPad=4)
        story.append(Paragraph(f'▶ {label}', h2_p))
        for item in region[key]:
            story.append(Paragraph(f'• {item}', bullet_style))
        story.append(sp(0.5))
    
    story.append(hr())
    if i < len(regions) - 1 and i in [2, 5]:
        story.append(PageBreak())
    else:
        story.append(sp())

# ── SUMMARY TABLE ──────────────────────────────────────────────────────────────
story.append(PageBreak())
story.append(Paragraph('&nbsp;&nbsp;Summary Table — All 9 Abdominal Regions', 
    ParagraphStyle('H1Sum', parent=h1_style, backColor=colors.HexColor('#37474f'))))
story.append(sp())

table_data = [
    ['Region', 'Key Organs', 'Key Pathology', 'Key Surgery', 'Key Drug(s)'],
    ['R. Hypochondrium', 'Liver, Gallbladder', 'Cholecystitis, Hepatitis, HCC', 'Lap cholecystectomy, Hepatectomy', 'Ursodeoxycholic acid, Antivirals'],
    ['Epigastric', 'Stomach, Pancreas, Aorta', 'PUD, Pancreatitis, AAA', 'Whipple\'s, Gastrectomy, EVAR', 'PPIs, H. pylori triple therapy'],
    ['L. Hypochondrium', 'Spleen, Stomach fundus', 'Splenomegaly, Splenic rupture', 'Splenectomy, Distal pancreatectomy', 'Penicillin V, Hydroxyurea'],
    ['R. Flank', 'R. Kidney, Ascending colon', 'Renal colic, Pyelonephritis, RCC', 'Nephrectomy, Ureteroscopy, PCNL', 'NSAIDs, Tamsulosin, Ciprofloxacin'],
    ['Umbilical', 'Small bowel, Aorta', 'SBO, AAA, Mesenteric ischaemia', 'Laparotomy, EVAR, Adhesiolysis', 'IV fluids, Heparin, Statins'],
    ['L. Flank', 'L. Kidney, Descending colon', 'Renal colic, Colon cancer, PKD', 'Hemicolectomy, Nephrectomy', 'FOLFOX, Tolvaptan, Tamsulosin'],
    ['R. Iliac Fossa', 'Appendix, Caecum, R. Ovary', 'Appendicitis, Ectopic, Crohn\'s', 'Appendicectomy, Hernia repair', 'Cefuroxime + Metronidazole'],
    ['Pubic/Hypogastric', 'Bladder, Uterus, Prostate', 'PID, Cystitis, BPH, Bladder Ca', 'Cystectomy, TURP, Hysterectomy', 'Doxycycline, Tamsulosin, Nitrofurantoin'],
    ['L. Iliac Fossa', 'Sigmoid colon, L. Ovary', 'Diverticulitis, Sigmoid Ca, Ectopic', 'Hartmann\'s, Anterior resection', 'Metronidazole + Ciprofloxacin'],
]

col_widths = [3.2*cm, 3.8*cm, 4.2*cm, 4.2*cm, 3.6*cm]
tbl = Table(table_data, colWidths=col_widths, repeatRows=1)
tbl.setStyle(TableStyle([
    # Header
    ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#37474f')),
    ('TEXTCOLOR', (0,0), (-1,0), colors.white),
    ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE', (0,0), (-1,0), 8),
    ('ALIGN', (0,0), (-1,0), 'CENTER'),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    # Body
    ('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
    ('FONTSIZE', (0,1), (-1,-1), 7.5),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor('#f5f5f5'), colors.white]),
    ('GRID', (0,0), (-1,-1), 0.4, colors.HexColor('#bdbdbd')),
    ('LEFTPADDING', (0,0), (-1,-1), 4),
    ('RIGHTPADDING', (0,0), (-1,-1), 4),
    ('TOPPADDING', (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
    # Color first column
    ('BACKGROUND', (0,1), (0,-1), colors.HexColor('#e3f2fd')),
    ('FONTNAME', (0,1), (0,-1), 'Helvetica-Bold'),
]))
story.append(tbl)
story.append(sp(2))

# ── FOOTER REFERENCES ──────────────────────────────────────────────────────────
story.append(HRFlowable(width='100%', thickness=1, color=colors.HexColor('#90a4ae'), spaceAfter=6))
story.append(Paragraph('<b>References / Sources</b>', h2_style))
refs = [
    "Gray's Anatomy for Students — Nine-region pattern, Block 2 (p. 336)",
    "Bailey and Love's Short Practice of Surgery, 28th Edition — Figure 63.2",
    "Tintinalli's Emergency Medicine — Abdominal pain, Appendicitis, Peptic Ulcer Disease",
    "Rosen's Emergency Medicine — Abdominal quadrant pain differential diagnosis",
    "Sleisenger & Fordtran's Gastrointestinal and Liver Disease — Pancreatitis, Diverticulitis",
    "Yamada's Textbook of Gastroenterology, 7th Edition — Clinical features of peptic ulcer disease",
    "Smith & Tanagho's General Urology, 19th Edition — Renal and ureteric pain",
    "Sabiston Textbook of Surgery — Surgical management of abdominal conditions",
]
for ref in refs:
    story.append(Paragraph(f'• {ref}', bullet_style))

doc.build(story)
print('PDF created:', OUTPUT)
Running Command

python3 /home/daytona/workspace/9-abdominal-regions/generate_pdf.py

Your PDF is ready! Download it here:

9 Abdominal Regions

PDF Document · PDF

What's included in the PDF:
  • Cover page with both anatomical diagrams (Gray's Anatomy nine-region diagram + Bailey & Love clinical pain sites illustration)
  • 9 region sections, each covering:
    • Anatomy (key organs)
    • Pathology (key diseases)
    • Pharmacology/POM (key drugs with mechanisms)
    • Surgery (key procedures)
    • Medicine (clinical signs, investigations, pearls)
  • Full summary table of all 9 regions at the end
  • References from Gray's Anatomy, Bailey & Love, Tintinalli's, Rosen's, Sabiston's, and more
This is a shared conversation. Sign in to Orris to start your own chat.