Describe intraperitoneal spaces. Describe the surgical anatomy of sub-diaphragmatic spaces and its surgical importance.- from standard literature like sabiston/bailey , if possible in an easy memorable format/Table in a downloadable one/two page pdf/image.

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Loading Image
Reading File
Reading File
Reading File
Finding Sources
Reading File
Reading File
Reading File
Running Command

mkdir -p /tmp/workspace/peritoneal-spaces && ls /tmp/workspace/peritoneal-spaces/

Writing File

~/peritoneal-spaces/generate_pdf.py


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

# Download the Harrison's intraperitoneal spaces diagram
img_url = "https://cdn.orris.care/cdss_images/623255f2dc87c75cc7af04c9e6c3d68a7c108715b2f0b4b856a56faaddef31f4.png"
img_path = "/tmp/workspace/peritoneal-spaces/peritoneal_diagram.png"
if not os.path.exists(img_path):
    urllib.request.urlretrieve(img_url, img_path)
    print("Image downloaded")
else:
    print("Image already exists")

OUTPUT = "/tmp/workspace/peritoneal-spaces/Intraperitoneal_Spaces_Surgery.pdf"
doc = SimpleDocTemplate(OUTPUT, pagesize=A4,
                        leftMargin=1.5*cm, rightMargin=1.5*cm,
                        topMargin=1.5*cm, bottomMargin=1.5*cm)

styles = getSampleStyleSheet()

# Custom styles
TITLE = ParagraphStyle('Title', parent=styles['Title'],
    fontSize=15, textColor=colors.HexColor('#1a3a5c'),
    spaceAfter=4, spaceBefore=0, alignment=TA_CENTER, leading=18)
SUBTITLE = ParagraphStyle('Subtitle', parent=styles['Normal'],
    fontSize=9, textColor=colors.HexColor('#2c6e9e'),
    spaceAfter=2, alignment=TA_CENTER)
H1 = ParagraphStyle('H1', parent=styles['Heading1'],
    fontSize=11, textColor=colors.white,
    backColor=colors.HexColor('#1a3a5c'),
    spaceBefore=6, spaceAfter=3, leading=14,
    leftIndent=4, rightIndent=4)
H2 = ParagraphStyle('H2', parent=styles['Heading2'],
    fontSize=9.5, textColor=colors.HexColor('#1a3a5c'),
    spaceBefore=4, spaceAfter=2, leading=12)
BODY = ParagraphStyle('Body', parent=styles['Normal'],
    fontSize=8, leading=10.5, spaceAfter=2, alignment=TA_JUSTIFY)
SMALL = ParagraphStyle('Small', parent=styles['Normal'],
    fontSize=7, leading=9, textColor=colors.HexColor('#555555'), alignment=TA_CENTER)
BULLET = ParagraphStyle('Bullet', parent=styles['Normal'],
    fontSize=7.5, leading=9.5, leftIndent=10, bulletIndent=0)
NOTE = ParagraphStyle('Note', parent=styles['Normal'],
    fontSize=7, leading=9, textColor=colors.HexColor('#8B0000'),
    backColor=colors.HexColor('#fff8f8'), leftIndent=4)

# Header
tbl_colors = {
    'header_bg': colors.HexColor('#1a3a5c'),
    'subhdr_bg': colors.HexColor('#2c6e9e'),
    'alt1': colors.HexColor('#e8f0f7'),
    'alt2': colors.white,
    'border': colors.HexColor('#1a3a5c'),
    'light_border': colors.HexColor('#b0c8e0'),
    'red': colors.HexColor('#8B0000'),
    'green': colors.HexColor('#1a5c2a'),
}

def section_header(text):
    return Paragraph(f"<b>{text}</b>", H1)

elements = []

# ─── TITLE ───────────────────────────────────────────────────
elements.append(Paragraph("Intraperitoneal Spaces &amp; Sub-diaphragmatic Spaces", TITLE))
elements.append(Paragraph("Surgical Anatomy &amp; Clinical Importance | Based on Bailey &amp; Love, Fischer's Mastery, Harrison's, Grainger &amp; Allison", SUBTITLE))
elements.append(HRFlowable(width="100%", thickness=2, color=colors.HexColor('#1a3a5c'), spaceAfter=4))

# ─── SECTION 1: Overview ──────────────────────────────────────
elements.append(section_header("1. OVERVIEW: DIVISION OF THE PERITONEAL CAVITY"))
elements.append(Spacer(1, 2))

overview_data = [
    [Paragraph("<b>Division</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=8, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Landmark</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=8, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Compartments</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=8, textColor=colors.white, alignment=TA_CENTER))],
    [Paragraph("<b>Supramesocolic</b>\n(Upper)", BODY),
     Paragraph("Transverse mesocolon (above)", BODY),
     Paragraph("Right &amp; left subphrenic, subhepatic (Morison's), lesser sac", BODY)],
    [Paragraph("<b>Inframesocolic</b>\n(Lower)", BODY),
     Paragraph("Transverse mesocolon (below)", BODY),
     Paragraph("Right &amp; left infracolic spaces, paracolic gutters, pelvic pouch", BODY)],
    [Paragraph("<b>Retroperitoneal</b>", BODY),
     Paragraph("Behind parietal peritoneum", BODY),
     Paragraph("Pancreas, duodenum, aorta, IVC, kidneys, ureters, adrenals", BODY)],
]

overview_table = Table(overview_data, colWidths=[4*cm, 5*cm, 9*cm])
overview_table.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), tbl_colors['header_bg']),
    ('TEXTCOLOR', (0,0), (-1,0), colors.white),
    ('BACKGROUND', (0,1), (-1,1), tbl_colors['alt1']),
    ('BACKGROUND', (0,2), (-1,2), tbl_colors['alt2']),
    ('BACKGROUND', (0,3), (-1,3), tbl_colors['alt1']),
    ('GRID', (0,0), (-1,-1), 0.5, tbl_colors['light_border']),
    ('BOX', (0,0), (-1,-1), 1, tbl_colors['border']),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ('TOPPADDING', (0,0), (-1,-1), 3),
    ('BOTTOMPADDING', (0,0), (-1,-1), 3),
    ('LEFTPADDING', (0,0), (-1,-1), 4),
]))
elements.append(overview_table)
elements.append(Spacer(1, 4))

# ─── SECTION 2: Diagram + Space descriptions side by side ───
elements.append(section_header("2. INTRAPERITONEAL SPACES – ANATOMY AT A GLANCE"))
elements.append(Spacer(1, 3))

# Left: diagram
diagram = RLImage(img_path, width=7.5*cm, height=6.5*cm)
diagram_para = Paragraph("Fig. Intraperitoneal spaces & fluid circulation\n(Harrison's Principles of Internal Medicine, 22e)", SMALL)

spaces_data = [
    [Paragraph("<b>Space</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Location / Boundaries</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Clinical Note</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER))],
    [Paragraph("<b>R. Subphrenic</b>", BULLET),
     Paragraph("Between diaphragm &amp; R. lobe of liver; limited L by falciform, posteromedially by R. coronary ligament", BULLET),
     Paragraph("Common abscess site post upper GI/biliary surgery", BULLET)],
    [Paragraph("<b>L. Subphrenic</b>", BULLET),
     Paragraph("Between diaphragm, L. lobe of liver &amp; spleen; bounded below by phrenicocolic lig.", BULLET),
     Paragraph("Enlarged after splenectomy; abscess post-splenectomy/gastric surgery", BULLET)],
    [Paragraph("<b>R. Subhepatic\n(Morison's Pouch)</b>", BULLET),
     Paragraph("Between R. lobe of liver &amp; R. kidney; posterosuperior extension of subhepatic space; LOWEST point when supine", BULLET),
     Paragraph("Most common site of intraperitoneal abscess; first site of fluid pooling when recumbent", BULLET)],
    [Paragraph("<b>L. Subhepatic\n(Lesser Sac)</b>", BULLET),
     Paragraph("Posterior to stomach, anterior to pancreas; communicates via foramen of Winslow (epiploic foramen)", BULLET),
     Paragraph("Abscess in pancreatitis, perforated posterior ulcer; limited spread due to foramen", BULLET)],
    [Paragraph("<b>R. Paracolic\nGutter</b>", BULLET),
     Paragraph("Lateral to ascending colon; communicates freely with subhepatic space superiorly &amp; pelvis inferiorly", BULLET),
     Paragraph("Main conduit for spread from appendix/colon to subphrenic/pelvis", BULLET)],
    [Paragraph("<b>L. Paracolic\nGutter</b>", BULLET),
     Paragraph("Lateral to descending colon; BLOCKED superiorly by phrenicocolic ligament", BULLET),
     Paragraph("Fluid cannot spread to L. subphrenic directly; limited superior spread", BULLET)],
    [Paragraph("<b>Pelvic Pouch\n(Pouch of Douglas / Rectovesical)</b>", BULLET),
     Paragraph("Lowest part of peritoneal cavity in erect position; rectouterine (F) or rectovesical (M)", BULLET),
     Paragraph("Most dependent site erect; appendix abscess, post-op collections, pelvic PID spread", BULLET)],
    [Paragraph("<b>R. Infracolic\nSpace</b>", BULLET),
     Paragraph("Right of root of mesentery, below transverse mesocolon", BULLET),
     Paragraph("Perforated duodenal ulcer fluid tracks here", BULLET)],
    [Paragraph("<b>L. Infracolic\nSpace</b>", BULLET),
     Paragraph("Left of root of mesentery, closed inferiorly by sigmoid mesocolon", BULLET),
     Paragraph("Relatively contained; diverticular abscess, sigmoid pathology", BULLET)],
]

spaces_table = Table(spaces_data, colWidths=[3.2*cm, 6.0*cm, 4.8*cm])
spaces_table.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), tbl_colors['header_bg']),
    ('TEXTCOLOR', (0,0), (-1,0), colors.white),
    *[('BACKGROUND', (0, i), (-1, i), tbl_colors['alt1'] if i % 2 == 0 else tbl_colors['alt2']) for i in range(1, len(spaces_data))],
    ('GRID', (0,0), (-1,-1), 0.5, tbl_colors['light_border']),
    ('BOX', (0,0), (-1,-1), 1, tbl_colors['border']),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('TOPPADDING', (0,0), (-1,-1), 3),
    ('BOTTOMPADDING', (0,0), (-1,-1), 3),
    ('LEFTPADDING', (0,0), (-1,-1), 3),
    ('RIGHTPADDING', (0,0), (-1,-1), 3),
]))

# Put diagram left, table right in a 2-col layout
from reportlab.platypus import Table as RTable
two_col = RTable([[diagram, spaces_table]], colWidths=[8.0*cm, 14.5*cm])
two_col.setStyle(TableStyle([
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('LEFTPADDING', (0,0), (-1,-1), 0),
    ('RIGHTPADDING', (0,0), (-1,-1), 4),
    ('TOPPADDING', (0,0), (-1,-1), 0),
    ('BOTTOMPADDING', (0,0), (-1,-1), 0),
]))
elements.append(two_col)
elements.append(diagram_para)
elements.append(Spacer(1, 4))

# ─── SECTION 3: Sub-diaphragmatic Spaces – Surgical Anatomy ─
elements.append(section_header("3. SUB-DIAPHRAGMATIC (SUBPHRENIC) SPACES – SURGICAL ANATOMY"))
elements.append(Spacer(1, 3))

subph_data = [
    [Paragraph("<b>Space</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Boundaries</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Common Causes of Abscess</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Drainage Approach</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER))],
    [Paragraph("<b>R. Anterior Subphrenic</b>\n(R. Superior)", BULLET),
     Paragraph("Superior: diaphragm\nInferior: R. lobe liver\nMedial: falciform lig.\nPost: coronary lig.", BULLET),
     Paragraph("Perforated peptic ulcer, cholecystectomy, hepatic surgery, appendicectomy (via R. paracolic gutter)", BULLET),
     Paragraph("Anterior subcostal extraperitoneal (below R. costal margin)", BULLET)],
    [Paragraph("<b>R. Posterior Subphrenic\n= Morison's Pouch\n(Hepatorenal Fossa)</b>", BULLET),
     Paragraph("Ant/Sup: R. lobe liver\nPost: R. kidney\nInf: transverse mesocolon\nMedial: IVC/portal pedicle", BULLET),
     Paragraph("Appendicitis (most common), perforated duodenal ulcer, cholecystitis, liver surgery", BULLET),
     Paragraph("Posterior approach (12th rib resection) or US/CT-guided percutaneous drainage", BULLET)],
    [Paragraph("<b>L. Anterior Subphrenic\n(L. Superior)</b>", BULLET),
     Paragraph("Superior: diaphragm\nInferior: L. lobe liver &amp; stomach\nMedial: falciform lig.\nLateral: spleen\nInferior: phrenicocolic lig.", BULLET),
     Paragraph("Splenectomy, gastric surgery (gastrectomy/perforation), splenic trauma", BULLET),
     Paragraph("Anterior subcostal approach L side; enlarged post-splenectomy", BULLET)],
    [Paragraph("<b>L. Posterior Subphrenic\n(Lesser Sac / Omental Bursa)</b>", BULLET),
     Paragraph("Ant: stomach &amp; lesser omentum\nPost: pancreas\nSup: caudate lobe\nComm via: Foramen of Winslow", BULLET),
     Paragraph("Acute pancreatitis (pancreatic pseudocyst), perforated posterior gastric ulcer", BULLET),
     Paragraph("Posterior trans-gastric (endoscopic cystgastrostomy) or surgical via lesser sac entry", BULLET)],
]

subph_table = Table(subph_data, colWidths=[3.8*cm, 5.2*cm, 6.0*cm, 4.5*cm])
subph_table.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), tbl_colors['header_bg']),
    ('TEXTCOLOR', (0,0), (-1,0), colors.white),
    ('BACKGROUND', (0,1), (-1,1), tbl_colors['alt1']),
    ('BACKGROUND', (0,2), (-1,2), tbl_colors['alt2']),
    ('BACKGROUND', (0,3), (-1,3), tbl_colors['alt1']),
    ('BACKGROUND', (0,4), (-1,4), tbl_colors['alt2']),
    ('GRID', (0,0), (-1,-1), 0.5, tbl_colors['light_border']),
    ('BOX', (0,0), (-1,-1), 1, tbl_colors['border']),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('TOPPADDING', (0,0), (-1,-1), 3),
    ('BOTTOMPADDING', (0,0), (-1,-1), 3),
    ('LEFTPADDING', (0,0), (-1,-1), 3),
    ('RIGHTPADDING', (0,0), (-1,-1), 3),
]))
elements.append(subph_table)
elements.append(Spacer(1, 4))

# ─── SECTION 4: Fluid & Infection Pathways ──────────────────
elements.append(section_header("4. FLUID / INFECTION SPREAD PATHWAYS (Surgically Important)"))
elements.append(Spacer(1, 3))

pathway_data = [
    [Paragraph("<b>Source</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white)),
     Paragraph("<b>Pathway</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white)),
     Paragraph("<b>Likely Collection Site</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white)),
     Paragraph("<b>Mnemonic / Key Fact</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white))],
    [Paragraph("Perforated duodenal ulcer", BULLET),
     Paragraph("Right infracolic space → R. paracolic gutter → pelvis", BULLET),
     Paragraph("R. iliac fossa / pelvis", BULLET),
     Paragraph("Mimics acute appendicitis", BULLET)],
    [Paragraph("Appendicitis / perforated appendix", BULLET),
     Paragraph("Pelvis → R. paracolic gutter → R. subphrenic / Morison's", BULLET),
     Paragraph("R. subphrenic (most common subphrenic abscess source)", BULLET),
     Paragraph("<b>Morison's Pouch</b> = lowest supine", BULLET)],
    [Paragraph("Acute pancreatitis", BULLET),
     Paragraph("Lesser sac (direct) → L. subphrenic", BULLET),
     Paragraph("Pseudocyst in lesser sac", BULLET),
     Paragraph("Foramen of Winslow limits spread", BULLET)],
    [Paragraph("Cholecystitis / bile leak post-cholecystectomy", BULLET),
     Paragraph("Subhepatic → R. paracolic gutter", BULLET),
     Paragraph("Morison's pouch biloma", BULLET),
     Paragraph("CT-guided drainage via posterior approach", BULLET)],
    [Paragraph("Post-splenectomy", BULLET),
     Paragraph("L. subphrenic space (enlarged)", BULLET),
     Paragraph("L. subphrenic abscess", BULLET),
     Paragraph("Phrenicocolic lig. limits downward spread", BULLET)],
    [Paragraph("Ascites / peritoneal dialysis", BULLET),
     Paragraph("Paracolic gutters → pelvis (erect); → subphrenic (supine)", BULLET),
     Paragraph("Pelvis (erect), subphrenic (supine)", BULLET),
     Paragraph("Explains bilateral pleural effusions in ascites", BULLET)],
]

pathway_table = Table(pathway_data, colWidths=[3.8*cm, 5.5*cm, 4.5*cm, 4.5*cm])
pathway_table.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), tbl_colors['header_bg']),
    ('TEXTCOLOR', (0,0), (-1,0), colors.white),
    *[('BACKGROUND', (0, i), (-1, i), tbl_colors['alt1'] if i % 2 != 0 else tbl_colors['alt2']) for i in range(1, len(pathway_data))],
    ('GRID', (0,0), (-1,-1), 0.5, tbl_colors['light_border']),
    ('BOX', (0,0), (-1,-1), 1, tbl_colors['border']),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('TOPPADDING', (0,0), (-1,-1), 3),
    ('BOTTOMPADDING', (0,0), (-1,-1), 3),
    ('LEFTPADDING', (0,0), (-1,-1), 3),
    ('RIGHTPADDING', (0,0), (-1,-1), 3),
]))
elements.append(pathway_table)
elements.append(Spacer(1, 4))

# ─── SECTION 5: Surgical Importance Box ──────────────────────
elements.append(section_header("5. SURGICAL IMPORTANCE AT A GLANCE"))
elements.append(Spacer(1, 3))

surg_data = [
    [Paragraph("<b>Topic</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>Key Point</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER))],
    [Paragraph("<b>Morison's Pouch</b>", BODY),
     Paragraph("Most dependent site when supine → FAST scan target; commonest abscess site (appendicitis, cholecystitis)", BODY)],
    [Paragraph("<b>Phrenicocolic Ligament</b>", BODY),
     Paragraph("Blocks L. paracolic gutter → L. subphrenic spread; L. subphrenic abscess less common", BODY)],
    [Paragraph("<b>Falciform Ligament</b>", BODY),
     Paragraph("Barrier between R. and L. subphrenic spaces → bilateral subphrenic abscess rare", BODY)],
    [Paragraph("<b>Foramen of Winslow</b>", BODY),
     Paragraph("Only communication between greater sac and lesser sac (2 cm wide); limited spread in pancreatitis; surgical access for lesser sac drainage", BODY)],
    [Paragraph("<b>Subphrenic Abscess</b>", BODY),
     Paragraph("Classic triad: swinging pyrexia + shoulder tip pain + raised immobile hemidiaphragm on CXR. Adage: 'Pus somewhere, pus nowhere, pus under the diaphragm'", BODY)],
    [Paragraph("<b>Shoulder Tip Pain</b>", BODY),
     Paragraph("Referred via phrenic nerve (C3,4,5 → diaphragm shares C5 dermatome with shoulder tip); also explains post-laparoscopic pain", BODY)],
    [Paragraph("<b>Right Paracolic Gutter</b>", BODY),
     Paragraph("Open superiorly (to subhepatic &amp; subphrenic) AND inferiorly (to pelvis) → main infection highway; WIDER and DEEPER than left", BODY)],
    [Paragraph("<b>Pelvic Pouch</b>", BODY),
     Paragraph("Most dependent when erect → pelvic abscess drained transrectally (males) or transvaginally (females); boggy mass on PR/PV exam", BODY)],
    [Paragraph("<b>Post-appendicectomy wash-out</b>", BODY),
     Paragraph("Must aspirate pelvic, paracolic &amp; subhepatic spaces to reduce risk of post-op abscess (up to 30% after perforated appendix)", BODY)],
    [Paragraph("<b>Lesser Sac &amp; Pseudocyst</b>", BODY),
     Paragraph("Pancreatic pseudocyst (fluid in lesser sac) drained surgically by cystgastrostomy/cystjejunostomy or endoscopically", BODY)],
]

surg_table = Table(surg_data, colWidths=[5.0*cm, 13.5*cm])
surg_table.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), tbl_colors['header_bg']),
    ('TEXTCOLOR', (0,0), (-1,0), colors.white),
    *[('BACKGROUND', (0, i), (-1, i), tbl_colors['alt1'] if i % 2 != 0 else tbl_colors['alt2']) for i in range(1, len(surg_data))],
    ('GRID', (0,0), (-1,-1), 0.5, tbl_colors['light_border']),
    ('BOX', (0,0), (-1,-1), 1, tbl_colors['border']),
    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ('TOPPADDING', (0,0), (-1,-1), 3),
    ('BOTTOMPADDING', (0,0), (-1,-1), 3),
    ('LEFTPADDING', (0,0), (-1,-1), 4),
    ('RIGHTPADDING', (0,0), (-1,-1), 4),
]))
elements.append(surg_table)
elements.append(Spacer(1, 4))

# ─── SECTION 6: Memory Aids ───────────────────────────────────
elements.append(section_header("6. MNEMONICS &amp; MEMORY AIDS"))
elements.append(Spacer(1, 3))

mnemo_data = [
    [Paragraph("<b>Mnemonic</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER)),
     Paragraph("<b>What it Helps Remember</b>", ParagraphStyle('th', parent=styles['Normal'], fontSize=7.5, textColor=colors.white, alignment=TA_CENTER))],
    [Paragraph('"<b>Pus somewhere, pus nowhere, pus under the diaphragm</b>"', BODY),
     Paragraph("Classic surgical adage for subphrenic abscess – when pyrexia has no obvious source, think subphrenic (Bailey &amp; Love)", BODY)],
    [Paragraph('<b>R&gt;L subphrenic abscess</b>\n(Remember: R&gt;L gutter is open both ends)', BODY),
     Paragraph("Right side far more common (70-80%): R. paracolic gutter is the main conduit; falciform lig. prevents bilateral spread", BODY)],
    [Paragraph('<b>FAST scan target: Morison\'s Pouch</b>', BODY),
     Paragraph("Hepatorenal space = most dependent in supine patient → first to fill with blood/fluid in trauma → FAST exam", BODY)],
    [Paragraph('<b>C3,4,5 keeps the diaphragm alive</b>', BODY),
     Paragraph("Phrenic nerve (C3-5) → shoulder tip pain from diaphragmatic irritation (subphrenic abscess, post-laparoscopy CO2)", BODY)],
    [Paragraph('<b>Winslow = 2 cm window</b>', BODY),
     Paragraph("Foramen of Winslow (epiploic foramen) – only communication to lesser sac; bounded by: Ant=portal pedicle, Post=IVC, Sup=caudate lobe, Inf=1st part duodenum", BODY)],
    [Paragraph('<b>P-D-F-W (Peritoneal Divisions From Winslow)</b>', BODY),
     Paragraph("Spaces: Pelvic → paracolic → subhepatic (Morison's) → subphrenic via R. paracolic gutter; Winslow → lesser sac", BODY)],
]

mnemo_table = Table(mnemo_data, colWidths=[6.5*cm, 12.0*cm])
mnemo_table.setStyle(TableStyle([
    ('BACKGROUND', (0,0), (-1,0), tbl_colors['header_bg']),
    ('TEXTCOLOR', (0,0), (-1,0), colors.white),
    *[('BACKGROUND', (0, i), (-1, i), tbl_colors['alt1'] if i % 2 != 0 else tbl_colors['alt2']) for i in range(1, len(mnemo_data))],
    ('GRID', (0,0), (-1,-1), 0.5, tbl_colors['light_border']),
    ('BOX', (0,0), (-1,-1), 1, tbl_colors['border']),
    ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ('TOPPADDING', (0,0), (-1,-1), 3),
    ('BOTTOMPADDING', (0,0), (-1,-1), 3),
    ('LEFTPADDING', (0,0), (-1,-1), 4),
    ('RIGHTPADDING', (0,0), (-1,-1), 4),
]))
elements.append(mnemo_table)
elements.append(Spacer(1, 3))

# Footer
elements.append(HRFlowable(width="100%", thickness=1, color=colors.HexColor('#1a3a5c'), spaceBefore=2, spaceAfter=2))
elements.append(Paragraph(
    "Sources: Bailey &amp; Love's Short Practice of Surgery 28e | Fischer's Mastery of Surgery 8e | Harrison's Principles of Internal Medicine 22e | Grainger &amp; Allison's Diagnostic Radiology | Pye's Surgical Handicraft 22e",
    ParagraphStyle('footer', parent=styles['Normal'], fontSize=6.5, textColor=colors.HexColor('#555555'), alignment=TA_CENTER)
))

# Build PDF
doc.build(elements)
print(f"PDF generated: {OUTPUT}")
Running Command

cd /tmp/workspace/peritoneal-spaces && python generate_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/peritoneal-spaces/

Your PDF is ready for download:

Intraperitoneal Spaces Surgery

PDF Document · PDF


Here is a summary of everything covered in the document, drawn from Bailey & Love 28e, Fischer's Mastery of Surgery 8e, Harrison's 22e, Grainger & Allison, and Pye's Surgical Handicraft:

Intraperitoneal Spaces - Key Summary

Division of Peritoneal Cavity

The peritoneal cavity is divided into supramesocolic (above transverse mesocolon) and inframesocolic (below) compartments, with the retroperitoneal space behind.

Intraperitoneal Spaces (Quick Reference)

SpaceKey FeatureSurgical Importance
R. SubphrenicBetween diaphragm & R. lobe liver; medial limit = falciform lig.Post biliary/upper GI abscess
L. SubphrenicBetween diaphragm, L. liver & spleen; inf. limit = phrenicocolic lig.Enlarged after splenectomy; post-gastric surgery abscess
Morison's Pouch (R. subhepatic)Between R. liver & R. kidney; LOWEST point when supineMost common abscess site; FAST scan target in trauma
Lesser Sac (L. subhepatic)Behind stomach, in front of pancreas; entry via foramen of WinslowPseudocyst in pancreatitis; perforated posterior ulcer
R. Paracolic GutterOpen superiorly & inferiorly - main infection highwaySpreads appendix/colonic infection to subphrenic & pelvis
L. Paracolic GutterBlocked superiorly by phrenicocolic ligamentLimited superior spread; L. subphrenic abscess less common
Pelvic Pouch (Douglas/rectovesical)Most dependent when erectAppendix abscess, post-op collection; drained transrectally/transvaginally

Sub-diaphragmatic Spaces - Surgical Anatomy

  1. R. Anterior Subphrenic - bounded by falciform lig. medially, coronary lig. posteriorly. Drained via anterior subcostal approach.
  2. R. Posterior Subphrenic = Morison's Pouch - between liver & R. kidney; drained via posterior 12th rib approach or percutaneous.
  3. L. Anterior Subphrenic - between diaphragm, L. liver lobe, spleen; phrenicocolic ligament is inferior boundary. Enlarged after splenectomy.
  4. L. Posterior Subphrenic = Lesser Sac - behind stomach, in front of pancreas; access only via foramen of Winslow. Pseudocysts drained by cystgastrostomy/endoscopy.

Key Surgical Points

  • Falciform ligament separates R. and L. subphrenic spaces → bilateral subphrenic abscess is rare
  • Phrenicocolic ligament blocks L. paracolic gutter from the L. subphrenic space → R. side far more commonly affected
  • Shoulder tip pain in subphrenic abscess: referred via phrenic nerve (C3-5) - same dermatome as C5 shoulder; also explains post-laparoscopic CO2 pain
  • Classic adage: "Pus somewhere, pus nowhere, pus under the diaphragm" (Bailey & Love)
  • CXR clues: high immobile hemidiaphragm, gas under diaphragm, reactionary pleural effusion
  • Abscesses >5 cm: require percutaneous drainage or surgery; <5 cm may resolve with IV antibiotics
  • Post-appendicectomy: always aspirate pelvic, paracolic, and subhepatic spaces - reduces post-op abscess rate (up to 30% risk after perforated appendix)
This is a shared conversation. Sign in to Orris to start your own chat.