I am a pulmonary fellow in training, create a powerpoint presentation about "EFFECTS OF ANESTHESIA ON PULMONARY FUNCTION" with references on the slides and include diagrams and images. Include script on the slides. Make sure to use new references

Reading File
Reading File
Reading File
Finding Sources
Searching PubMed

anesthesia pulmonary function respiratory effects

Searching Images

anesthesia respiratory effects lung function diagram

Reading File
Reading File
Searching PubMed

general anesthesia lung atelectasis mechanisms

Searching Images

functional residual capacity lung volumes anesthesia

Reading File
Reading File
Searching PubMed

inhalational anesthetic hypoxic pulmonary vasoconstriction gas exchange

Searching Images

ventilation perfusion mismatch shunt atelectasis

Loading Image
Finding Sources
Searching PubMed

postoperative pulmonary complications prevention strategies

Running Command

mkdir -p /tmp/workspace/anesthesia-pptx && ls /tmp/workspace/

Writing File

~/anesthesia-pptx/build_pptx.py


import json, subprocess, base64
from io import BytesIO
from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.oxml.ns import qn
from lxml import etree

# ── Colours ──────────────────────────────────────────────────────────────────
NAVY      = RGBColor(0x0A, 0x29, 0x4A)   # dark navy blue
TEAL      = RGBColor(0x00, 0x7A, 0x8A)   # accent teal
WHITE     = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_BG  = RGBColor(0xF0, 0xF5, 0xFA)   # very light blue-grey
GOLD      = RGBColor(0xE8, 0xA0, 0x00)   # accent gold
DARK_TEXT = RGBColor(0x1A, 0x1A, 0x2E)
MED_GREY  = RGBColor(0x55, 0x66, 0x77)
RED_WARN  = RGBColor(0xC0, 0x39, 0x2B)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
blank = prs.slide_layouts[6]

# ── Helper: filled rectangle ──────────────────────────────────────────────────
def add_rect(slide, l, t, w, h, fill_rgb, alpha=None):
    shape = slide.shapes.add_shape(1, Inches(l), Inches(t), Inches(w), Inches(h))
    shape.line.fill.background()
    shape.fill.solid()
    shape.fill.fore_color.rgb = fill_rgb
    return shape

def add_textbox(slide, text, l, t, w, h, size=18, bold=False, color=DARK_TEXT,
                align=PP_ALIGN.LEFT, italic=False, wrap=True):
    tb = slide.shapes.add_textbox(Inches(l), Inches(t), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = wrap
    tf.margin_left = Inches(0.05)
    tf.margin_right = Inches(0.05)
    tf.margin_top = Inches(0.03)
    tf.margin_bottom = Inches(0.03)
    p = tf.paragraphs[0]
    p.alignment = align
    run = p.add_run()
    run.text = text
    run.font.size = Pt(size)
    run.font.bold = bold
    run.font.italic = italic
    run.font.color.rgb = color
    run.font.name = "Calibri"
    return tb

def add_multiline(slide, lines, l, t, w, h, size=16, bold_first=False,
                  color=DARK_TEXT, bullet=False, line_spacing=1.15):
    tb = slide.shapes.add_textbox(Inches(l), Inches(t), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = True
    tf.margin_left = Inches(0.1)
    tf.margin_right = Inches(0.05)
    tf.margin_top = Inches(0.05)
    tf.margin_bottom = Inches(0.05)
    for i, line in enumerate(lines):
        p = tf.add_paragraph() if i > 0 else tf.paragraphs[0]
        p.alignment = PP_ALIGN.LEFT
        if bullet:
            p.level = 0
        run = p.add_run()
        run.text = ("• " if bullet else "") + line
        run.font.size = Pt(size)
        run.font.bold = (bold_first and i == 0)
        run.font.color.rgb = color
        run.font.name = "Calibri"
    return tb

def add_note(slide, text):
    notes_slide = slide.notes_slide
    tf = notes_slide.notes_text_frame
    tf.text = text

def add_image_from_url(slide, url, l, t, w, h=None):
    try:
        result = json.loads(subprocess.check_output(
            ["python", "/tmp/skills/shared/scripts/fetch_images.py", url],
            timeout=30
        ))
        if result and result[0].get("base64"):
            raw = base64.b64decode(result[0]["base64"].split(",")[-1])
            img_stream = BytesIO(raw)
            if h:
                slide.shapes.add_picture(img_stream, Inches(l), Inches(t), Inches(w), Inches(h))
            else:
                slide.shapes.add_picture(img_stream, Inches(l), Inches(t), Inches(w))
            return True
    except Exception as e:
        print(f"Image fetch error: {e}")
    return False

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 1 – TITLE SLIDE
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
# Full background dark navy
add_rect(slide, 0, 0, 13.333, 7.5, NAVY)
# Accent teal bar at bottom
add_rect(slide, 0, 6.6, 13.333, 0.9, TEAL)
# Gold left accent strip
add_rect(slide, 0, 0, 0.18, 7.5, GOLD)

add_textbox(slide, "EFFECTS OF ANESTHESIA ON", 0.5, 1.3, 12.5, 1.1,
            size=38, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
add_textbox(slide, "PULMONARY FUNCTION", 0.5, 2.3, 12.5, 1.0,
            size=46, bold=True, color=GOLD, align=PP_ALIGN.CENTER)
add_textbox(slide, "A Comprehensive Review for Pulmonary Fellows", 0.5, 3.5, 12.5, 0.6,
            size=20, bold=False, color=RGBColor(0xB0,0xC8,0xE0), align=PP_ALIGN.CENTER, italic=True)
add_textbox(slide, "Based on: Morgan & Mikhail's Clinical Anesthesiology 7e  |  Fishman's Pulmonary Diseases & Disorders",
            0.5, 4.2, 12.5, 0.5, size=13, color=RGBColor(0xB0,0xC8,0xE0), align=PP_ALIGN.CENTER)
add_textbox(slide, "August 2026", 0.5, 6.65, 12.5, 0.5, size=14, color=WHITE, align=PP_ALIGN.CENTER)
add_note(slide, """SPEAKER SCRIPT – TITLE SLIDE:
Welcome everyone. Today we are going to explore one of the most clinically relevant topics at the intersection of anesthesiology and pulmonary medicine — the effects of anesthesia on pulmonary function.

As pulmonary fellows, you will frequently manage patients in the perioperative period, consult on high-risk surgical candidates, and help navigate respiratory complications after surgery. Understanding these mechanisms at a physiologic level will sharpen your clinical decision-making. We will cover changes in lung volumes, gas exchange, respiratory drive, airway resistance, and the differences between general and neuraxial anesthesia — finishing with practical mitigation strategies. Let's begin.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 2 – OUTLINE
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, LIGHT_BG)
add_rect(slide, 0, 0, 13.333, 1.1, NAVY)
add_rect(slide, 0, 6.8, 13.333, 0.7, TEAL)

add_textbox(slide, "OUTLINE", 0.4, 0.15, 12.5, 0.75, size=32, bold=True, color=WHITE, align=PP_ALIGN.LEFT)

topics = [
    "1.  Physiologic basis: why anesthesia disrupts lung mechanics",
    "2.  Effects on lung volumes & FRC",
    "3.  Atelectasis: mechanisms & CT evidence",
    "4.  Effects on ventilation/perfusion (V/Q) & gas exchange",
    "5.  Airway resistance & work of breathing",
    "6.  Respiratory drive: response to hypoxia & hypercapnia",
    "7.  Neuromuscular blockade: residual effects",
    "8.  Neuraxial anesthesia: comparative respiratory effects",
    "9.  Postoperative analgesia & respiratory depression",
    "10. Mitigation strategies & clinical implications",
    "11. References",
]
add_multiline(slide, topics, 0.8, 1.25, 11.8, 5.4, size=17, color=DARK_TEXT)
add_textbox(slide, "Morgan & Mikhail 7e, p.936 | Fishman's Pulmonary Diseases & Disorders, Ch.115",
            0.4, 6.82, 12.5, 0.42, size=11, color=WHITE, italic=True)
add_note(slide, """SPEAKER SCRIPT – OUTLINE:
Here is our roadmap for the session. We will work through the topic systematically — starting with the underlying physiology, moving through the specific pulmonary derangements caused by anesthesia, compare general versus neuraxial techniques, discuss the postoperative period, and end with evidence-based mitigation strategies you can apply at the bedside.
Feel free to ask questions at any point.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 3 – PHYSIOLOGIC BASIS
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, NAVY)
add_rect(slide, 0, 1.1, 0.08, 6.4, GOLD)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "PHYSIOLOGIC BASIS", 0.3, 0.15, 12.5, 0.75, size=30, bold=True, color=WHITE)
add_textbox(slide, "Why Does Anesthesia Disrupt Lung Mechanics?", 0.3, 1.2, 12.5, 0.5,
            size=19, color=TEAL, bold=True)

left_bullets = [
    "Loss of inspiratory & expiratory muscle tone",
    "Cephalad shift of the diaphragm (dorsal > ventral)",
    "Reduction in transverse thoracic diameter",
    "Changes in chest wall shape (rib cage moves inward)",
    "Increased intrathoracic blood volume",
    "Abolition of tonic respiratory muscle activity",
    "Suppression of central respiratory drive",
]
right_bullets = [
    "Effect begins within MINUTES of induction",
    "Independent of anesthetic depth",
    "Persists for hours–days after emergence",
    "Greater impact: obese, elderly, underlying lung disease",
    "Notable exception: KETAMINE preserves muscle tone",
    "Both inhaled & IV agents produce similar effects",
]

add_textbox(slide, "Mechanisms", 0.3, 1.8, 6.2, 0.4, size=15, bold=True, color=NAVY)
add_multiline(slide, left_bullets, 0.3, 2.2, 6.2, 4.3, size=14, bullet=True, color=DARK_TEXT)
add_textbox(slide, "Clinical Context", 6.8, 1.8, 6.0, 0.4, size=15, bold=True, color=NAVY)
add_multiline(slide, right_bullets, 6.8, 2.2, 6.0, 4.3, size=14, bullet=True, color=DARK_TEXT)

add_textbox(slide,
    "Fishman's Pulmonary Diseases & Disorders, p.1835 | Morgan & Mikhail 7e, p.936",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – PHYSIOLOGIC BASIS:
The moment you induce general anesthesia, a cascade of mechanical changes begins. The loss of inspiratory and expiratory muscle tone is immediate — the diaphragm is the main one. In the supine position, the abdominal contents push the diaphragm cephalad, and this is more pronounced dorsally than ventrally.

The rib cage geometry also changes: it moves inward, reducing the thoracic AP diameter. There is also redistribution of blood into the pulmonary circulation, adding to the reduction in air-containing lung volume.

Critically — and this is a pearls for your boards — these changes are NOT related to the depth of anesthesia. Lighter anesthesia does not protect the patient's lung mechanics. And importantly, ketamine is the one exception because it uniquely preserves respiratory muscle tone.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 4 – LUNG VOLUMES & FRC  (with diagram)
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, TEAL)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "LUNG VOLUMES & FUNCTIONAL RESIDUAL CAPACITY", 0.3, 0.15, 12.5, 0.8,
            size=26, bold=True, color=WHITE)

# Text content left
content = [
    "Supine position:   FRC ↓ by 0.8–1.0 L",
    "Induction of GA:   FRC ↓ further by 0.4–0.5 L",
    "Total reduction:   ~20% of baseline FRC",
    "Compressive atelectasis appears within 10 min",
    "Atelectatic area = 2–10% of total lung volume",
    "Not reversed by muscle paralysis alone",
    "Steep Trendelenburg (>30°): further ↓ FRC",
    "Sitting position at induction: minimal FRC change",
    "Closing capacity not proportionally reduced → ↑ shunt risk",
]
add_textbox(slide, "Key Changes", 0.3, 1.2, 5.8, 0.45, size=16, bold=True, color=TEAL)
add_multiline(slide, content, 0.3, 1.65, 5.8, 5.0, size=14, bullet=True, color=DARK_TEXT)

# FRC diagram (visual schematic using shapes)
# Draw a bar-chart-like diagram illustrating FRC changes
# Awake bar
add_textbox(slide, "Lung Volume Comparison", 6.4, 1.2, 6.6, 0.45, size=16, bold=True, color=TEAL)

# Bar chart background
add_rect(slide, 6.4, 1.7, 6.5, 5.0, LIGHT_BG)

# Labels
labels = ["Awake\n(upright)", "Awake\n(supine)", "GA\n(supine)"]
bar_heights = [3.6, 2.6, 1.9]  # proportional heights in inches
bar_colors  = [RGBColor(0x00,0x7A,0x8A), RGBColor(0x00,0x9B,0xAD), RGBColor(0xC0,0x39,0x2B)]
bar_labels  = ["FRC ~2.4 L", "FRC ~1.6 L", "FRC ~1.1 L"]
bar_x_starts = [6.6, 8.05, 9.5]
bar_width    = 1.1
chart_bottom = 6.45

for i in range(3):
    bh = bar_heights[i]
    by = chart_bottom - bh
    add_rect(slide, bar_x_starts[i], by, bar_width, bh, bar_colors[i])
    add_textbox(slide, bar_labels[i], bar_x_starts[i], by - 0.45, bar_width, 0.42,
                size=11, bold=True, color=bar_colors[i], align=PP_ALIGN.CENTER)
    add_textbox(slide, labels[i], bar_x_starts[i], chart_bottom + 0.04, bar_width, 0.5,
                size=11, color=DARK_TEXT, align=PP_ALIGN.CENTER)

# Y-axis label
add_textbox(slide, "FRC (L)", 6.4, 3.5, 0.7, 1.0, size=11, bold=True, color=NAVY)

add_textbox(slide,
    "Morgan & Mikhail 7e, p.936 | Fishman's p.1835 | Zeng C et al. Anesthesiology 2022;136(2):181. PMID:34499087",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – LUNG VOLUMES & FRC:
Let's look at the numbers. In the upright, awake patient, FRC is approximately 2.4 liters. Just moving to the supine position knocks off about 800 mL to 1 liter — even before you give a single drug. Then induction of general anesthesia further reduces FRC by another 400-500 mL.

The net result is roughly a 20% reduction in FRC from baseline. This matters because FRC is the buffer — it is the lung volume that keeps alveoli open at end-expiration and maintains oxygenation between breaths.

When FRC falls below closing capacity — the lung volume at which small airways begin to close — you get dependent atelectasis and intrapulmonary shunting. CT imaging has confirmed crescent-shaped areas of atelectasis in dependent lung zones within 10 minutes of induction (Zeng et al., Anesthesiology 2022).""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 5 – DIAPHRAGM DIAGRAM (textbook image)
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, NAVY)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "DIAPHRAGM SHIFT WITH ANESTHESIA", 0.3, 0.15, 12.5, 0.8,
            size=28, bold=True, color=WHITE)

# Embed the diaphragm image
img_url = "https://cdn.orris.care/cdss_images/7ab8f258289f19af2cabf2ecf281636a4c0ca2c7c4570d9039952e68c395afe6.png"
ok = add_image_from_url(slide, img_url, 0.5, 1.15, 5.5, 5.5)
if not ok:
    add_textbox(slide, "[Diaphragm diagram: Awake vs. Anesthetized]", 0.5, 1.15, 5.5, 5.5,
                size=14, color=MED_GREY)

# Annotation text
add_textbox(slide, "What This Diagram Shows", 6.3, 1.2, 6.5, 0.45, size=16, bold=True, color=TEAL)
annotations = [
    "AWAKE (top): Diaphragm in neutral position",
    "   • Inspiratory muscle tone maintains thoracic volume",
    "   • FRC preserved at ~2.4 L",
    "",
    "ANESTHETIZED (bottom): Loss of motor tone",
    "   • Dorsal diaphragm shifts CEPHALAD (arrows)",
    "   • Ventral diaphragm moves slightly caudad",
    "   • Thoracic spine becomes more lordotic",
    "   • Rib cage moves INWARD",
    "   • Abdominal contents push up → ↓ thoracic volume",
    "",
    "NET EFFECT:",
    "   • Lung volume reduction → atelectasis formation",
    "   • Dependent (dorsal) zones most affected",
    "   • More pronounced: obese, elderly patients",
]
add_multiline(slide, annotations, 6.3, 1.7, 6.6, 5.0, size=13, color=DARK_TEXT)

add_textbox(slide,
    "Source: Morgan & Mikhail's Clinical Anesthesiology 7e, Figure 23-13, p.937",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – DIAPHRAGM DIAGRAM:
This diagram from Morgan & Mikhail beautifully illustrates the mechanical change at the diaphragm level.

In the awake state at top, you can see the diaphragm is in a relatively caudal position — pulled down by inspiratory muscle tone. The lung is expanded to its resting FRC.

After induction of anesthesia in the bottom panel, the arrows show the cephalad shift. Notice that the dorsal — meaning the back — portion moves more cephalad than the ventral portion. This asymmetric shift is important because the dorsal lung zones are the dependent zones in the supine patient. These are exactly the zones that develop compressive atelectasis.

Combined with the inward rib cage movement and the more lordotic thoracic spine, the net reduction in thoracic volume is substantial — translating directly into reduced FRC and atelectasis formation.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 6 – ATELECTASIS
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, RGBColor(0x7B,0x00,0x00))
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "PERIOPERATIVE ATELECTASIS: MECHANISMS & CT EVIDENCE", 0.3, 0.1, 12.5, 0.9,
            size=25, bold=True, color=WHITE)

# Three-column layout
col_titles = ["Types of Atelectasis", "CT Evidence", "Risk Factors"]
col_content = [
    [
        "Compressive atelectasis",
        "→ Weight of overlying lung/mediastinum",
        "→ Upward diaphragm displacement",
        "→ Most common type under GA",
        "",
        "Resorption atelectasis",
        "→ High FiO2 promotes N2 washout",
        "→ O2 rapidly absorbed from trapped alveoli",
        "→ Worsened by pure O2 pre-oxygenation",
        "",
        "Adhesive atelectasis",
        "→ Surfactant dysfunction with GA",
        "→ Increased alveolar surface tension",
    ],
    [
        "CT confirms: crescent-shaped dependent",
        "atelectasis in ALL patients under GA",
        "",
        "• Onset: within 10 minutes of induction",
        "• Extent: 2–10% of total lung volume",
        "• Location: dorsal (dependent) zones",
        "• Disappears with PEEP application",
        "• Both inhaled AND IV agents → same pattern",
        "• Degree unchanged by spontaneous vs",
        "  mechanical ventilation",
        "",
        "Zeng et al. Anesthesiology 2022",
        "Khan et al. J Thorac Dis 2023",
    ],
    [
        "HIGH RISK patients:",
        "• Obesity (BMI >30)",
        "• Age >65 years",
        "• Underlying COPD",
        "• Pre-existing hypoxemia",
        "",
        "SURGICAL FACTORS:",
        "• Supine/Trendelenburg position",
        "• Long operative duration",
        "• Upper abdominal surgery",
        "• Thoracic surgery",
        "",
        "→ Clinically apparent hypoxemia",
        "  persists into early postop period",
    ],
]

col_x = [0.2, 4.55, 8.9]
col_w = 4.2
for i in range(3):
    add_rect(slide, col_x[i], 1.2, col_w, 0.5, NAVY)
    add_textbox(slide, col_titles[i], col_x[i]+0.1, 1.25, col_w-0.2, 0.42,
                size=14, bold=True, color=WHITE)
    add_multiline(slide, col_content[i], col_x[i]+0.1, 1.8, col_w-0.15, 4.85,
                  size=12, color=DARK_TEXT)

add_textbox(slide,
    "Fishman's p.1835 | Zeng C et al. Anesthesiology 2022 PMID:34499087 | Khan A et al. J Thorac Dis 2023 PMID:37426163",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – ATELECTASIS:
Atelectasis is the central pulmonary complication of anesthesia. There are three types you need to distinguish.

Compressive atelectasis is the most common — caused by the weight of the overlying lung tissue and the mediastinum, combined with the cephalad diaphragm shift we just discussed. It predominantly affects dependent dorsal zones.

Resorption atelectasis is particularly relevant when we use 100% oxygen for preoxygenation. When nitrogen is washed out of alveoli and replaced with oxygen, any small airway obstruction leads to rapid resorption of that trapped pure oxygen — causing alveolar collapse. This is the argument for using lower FiO2 during induction in select patients.

Adhesive atelectasis involves surfactant dysfunction — anesthetic agents can impair surfactant secretion and function, raising surface tension and promoting alveolar collapse.

CT studies have confirmed all of this in vivo. Crescent-shaped atelectasis in the dorsal lung appears within 10 minutes in essentially every patient under general anesthesia.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 7 – V/Q & GAS EXCHANGE
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, TEAL)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "VENTILATION/PERFUSION MATCHING & GAS EXCHANGE", 0.3, 0.15, 12.5, 0.8,
            size=26, bold=True, color=WHITE)

# V/Q diagram schematic
add_textbox(slide, "V/Q Disturbance Under Anesthesia", 0.3, 1.2, 6.0, 0.45, size=16, bold=True, color=TEAL)

vq_content = [
    "Normal V/Q ratio = ~0.8 (matched ventilation & perfusion)",
    "",
    "Under GA:",
    "  • Atelectatic zones = ventilation = 0, perfusion maintained",
    "  • This represents TRUE intrapulmonary SHUNT (V/Q = 0)",
    "  • Shunt fraction rises to 5–15% (normal <5%)",
    "  • Correlates directly with volume of atelectatic lung",
    "",
    "HPV (hypoxic pulmonary vasoconstriction):",
    "  • Normal HPV diverts blood away from hypoxic zones",
    "  • Inhaled volatile agents IMPAIR HPV",
    "  • → perfusion of non-ventilated zones is NOT compensated",
    "  • IV agents (propofol) have minimal effect on HPV",
    "",
    "Dead space changes:",
    "  • PPV increases alveolar dead space (Zone 1 expansion)",
    "  • VD/VT ratio increases with PEEP and high tidal volumes",
    "  • Physiologic dead space = anatomic + alveolar dead space",
]
add_multiline(slide, vq_content, 0.3, 1.7, 6.2, 5.0, size=13, color=DARK_TEXT)

# Visual schematic of V/Q spectrum
add_textbox(slide, "V/Q Spectrum (Schematic)", 6.8, 1.2, 6.1, 0.45, size=16, bold=True, color=TEAL)

# Draw V/Q spectrum bar
sections = [
    ("Shunt\nV/Q=0", 6.8, 1.8, 1.3, 1.5, RED_WARN, "Under GA\n↑ to 5-15%"),
    ("Low V/Q\n0–0.8", 8.2, 1.8, 1.3, 1.5, RGBColor(0xE8,0x7A,0x00), "HPV\nImpaired by\nvolatiles"),
    ("Normal\nV/Q≈0.8", 9.6, 1.8, 1.3, 1.5, RGBColor(0x00,0x7A,0x8A), "Maintained"),
    ("High V/Q\n>0.8", 11.0, 1.8, 1.3, 1.5, RGBColor(0x55,0x99,0xBB), "↑ Dead\nspace\nwith PPV"),
    ("Dead Space\nV/Q=∞", 12.4, 1.8, 0.8, 1.5, NAVY, ""),
]
for label, x, y, w, h, color, note in sections:
    add_rect(slide, x, y, w, h, color)
    add_textbox(slide, label, x, y+0.1, w, 0.7, size=10, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
    if note:
        add_textbox(slide, note, x, y+h+0.1, w, 0.7, size=9, color=MED_GREY, align=PP_ALIGN.CENTER)

add_textbox(slide, "Clinical Consequence:", 6.8, 3.8, 6.1, 0.4, size=15, bold=True, color=RED_WARN)
clin = [
    "• Hypoxemia under GA: PaO2 often ↓ by 20–30 mmHg",
    "• Elderly + obese: most vulnerable (↓ FRC at baseline)",
    "• Shunt does NOT respond to supplemental O2 alone",
    "• PEEP is the primary treatment: recruits atelectatic zones",
    "• Maintains effect of HPV with IV-based anesthesia",
]
add_multiline(slide, clin, 6.8, 4.2, 6.1, 2.5, size=13, bullet=True, color=DARK_TEXT)

add_textbox(slide,
    "Fishman's p.1835 | Petersson & Glenny, Semin Respir Crit Care Med 2023 PMID:37816345 | Morgan & Mikhail 7e, p.938",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – V/Q & GAS EXCHANGE:
Atelectasis directly disrupts the V/Q matching that is fundamental to efficient gas exchange.

In normal physiology, V/Q is approximately 0.8. When atelectasis forms — particularly the compressive type in dependent zones — those areas receive zero ventilation while perfusion is maintained. This is a true shunt, a V/Q ratio of zero, and shunted blood returns to the left heart without being oxygenated. The shunt fraction typically rises to 5–15% under general anesthesia.

The normal defense against shunting is hypoxic pulmonary vasoconstriction — HPV — which redirects blood flow away from hypoxic areas. The problem is that volatile inhaled anesthetics — sevoflurane, desflurane, isoflurane — impair this HPV reflex. Propofol is safer from this standpoint. This is one reason some centers favor TIVA (total intravenous anesthesia) for patients with significant baseline lung disease.

At the other end, positive pressure ventilation increases alveolar dead space by over-distending non-dependent alveoli and reducing perfusion to West Zone 1 regions. So we simultaneously have more shunt AND more dead space — a real double hit.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 8 – AIRWAY RESISTANCE & WORK OF BREATHING
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, NAVY)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "AIRWAY RESISTANCE & WORK OF BREATHING", 0.3, 0.15, 12.5, 0.8,
            size=28, bold=True, color=WHITE)

# Left column: Airway Resistance
add_textbox(slide, "Airway Resistance", 0.3, 1.2, 6.0, 0.45, size=16, bold=True, color=TEAL)
ar_content = [
    "Expected: ↓ FRC → ↑ airway resistance (airways narrow as",
    "  lung volume decreases — interdependence)",
    "",
    "PARADOX: Clinically, resistance usually NOT increased",
    "",
    "WHY? Bronchodilating properties of volatile agents:",
    "  • Isoflurane, sevoflurane, desflurane → direct airway",
    "    smooth muscle relaxation",
    "  • Counteracts the FRC-related narrowing",
    "",
    "When airway resistance IS increased:",
    "  • Pathologic: laryngospasm, bronchoconstriction,",
    "    secretions, blood, tumor, tongue displacement",
    "  • Equipment: small ETT, malfunctioning valves,",
    "    circuit obstruction",
    "  • High-risk: asthma, COPD, obesity, recent URTI",
]
add_multiline(slide, ar_content, 0.3, 1.7, 6.2, 5.0, size=13, color=DARK_TEXT)

# Right column: Work of Breathing
add_textbox(slide, "Work of Breathing", 6.7, 1.2, 6.2, 0.45, size=16, bold=True, color=TEAL)
wob_content = [
    "Primary drivers of ↑ WOB under anesthesia:",
    "  • ↓ Lung compliance (atelectasis, secretions)",
    "  • ↓ Chest wall compliance",
    "  • Less commonly: ↑ airway resistance",
    "",
    "Lung Compliance:",
    "  CL = ΔV / ΔP",
    "  Normal: ~200 mL/cmH2O",
    "  Under GA: often reduced 30–50%",
    "",
    "Breathing Patterns Under GA:",
    "  • 'Light' anesthesia: irregular, breath-holding common",
    "  • Deeper GA: regular pattern restored",
    "  • Volatile agents: rapid, shallow breaths",
    "  • Opioid-based: slow, deep breaths",
    "",
    "Clinical management:",
    "  • Controlled mechanical ventilation circumvents",
    "    WOB problems",
    "  • Lung-protective ventilation: Vt 6-8 mL/kg IBW",
]
add_multiline(slide, wob_content, 6.7, 1.7, 6.2, 5.0, size=13, color=DARK_TEXT)

add_textbox(slide,
    "Morgan & Mikhail 7e, p.937 | Yue H & Yong T, Postgrad Med J 2024 PMID:38507221",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – AIRWAY RESISTANCE & WORK OF BREATHING:
You might expect that the decrease in FRC under anesthesia would increase airway resistance — because as lung volume decreases, the radial traction on small airways diminishes, allowing them to narrow. And physiologically, that is exactly what should happen.

However, in clinical practice, we usually do not see a significant increase in airway resistance because volatile anesthetic agents have direct bronchodilating properties. This is why sevoflurane has historically been the induction agent of choice for patients with asthma or reactive airways disease — it both induces anesthesia and relaxes bronchial smooth muscle simultaneously.

Regarding work of breathing — the primary driver is reduced compliance. Lung compliance falls substantially under GA — by 30 to 50% in some studies — mainly due to atelectasis, surfactant dysfunction, and changes in chest wall mechanics. In practice, we deal with this by transitioning to controlled mechanical ventilation, but this has its own costs in terms of dead space and barotrauma if not carefully managed.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 9 – RESPIRATORY DRIVE
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, RGBColor(0x1A,0x5C,0x3A))
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "RESPIRATORY DRIVE: HYPOXIC & HYPERCAPNIC RESPONSES", 0.3, 0.1, 12.5, 0.9,
            size=25, bold=True, color=WHITE)

# Left panel: CO2 response
add_rect(slide, 0.25, 1.2, 5.9, 0.5, RGBColor(0x1A,0x5C,0x3A))
add_textbox(slide, "Hypercapnic Ventilatory Response (HCVR)", 0.35, 1.25, 5.7, 0.4,
            size=14, bold=True, color=WHITE)
co2_content = [
    "Volatile agents: dose-dependent depression of HCVR",
    "• Right-shift of CO2 response curve",
    "• Increased PaCO2 threshold for breathing",
    "• At clinical doses: significant blunting",
    "",
    "During emergence: negligible effect at low concentrations",
    "",
    "IV agents (propofol, barbiturates, benzodiazepines):",
    "• Also depress CO2 response, dose-dependent",
    "",
    "Opioids: profound HCVR depression",
    "• Reduce slope AND shift threshold rightward",
    "• Main cause of postoperative hypercapnia",
    "• Effect persists due to lipid/muscle deposition",
]
add_multiline(slide, co2_content, 0.3, 1.75, 6.0, 4.9, size=12.5, color=DARK_TEXT)

# Right panel: O2 response (hypoxic drive)
add_rect(slide, 6.7, 1.2, 6.2, 0.5, RED_WARN)
add_textbox(slide, "⚠  Hypoxic Ventilatory Response (HVR) — HIGH RISK", 6.8, 1.25, 6.0, 0.4,
            size=13, bold=True, color=WHITE)
hxc_content = [
    "MOST CLINICALLY IMPORTANT EFFECT:",
    "",
    "Volatile agents MARKEDLY attenuate HVR",
    "• Even at subanesthetic (sub-MAC) concentrations",
    "• Effect persists for HOURS after termination",
    "• Due to redistribution from muscle & fat stores",
    "",
    "Who is at greatest risk:",
    "• Patients with chronic hypercapnia (COPD, obesity",
    "  hypoventilation, neuromuscular disease)",
    "• Dependent on hypoxic drive to maintain ventilation",
    "• These patients may develop severe postoperative",
    "  respiratory depression when HVR is blunted",
    "",
    "Clinical implications:",
    "• Close monitoring in PACU & HDU",
    "• Minimize volatile agent residuals",
    "• Use opioid-sparing techniques where possible",
    "• Consider NIV/supplemental O2 as bridge",
]
add_multiline(slide, hxc_content, 6.7, 1.75, 6.2, 4.9, size=12.5, color=DARK_TEXT)

add_textbox(slide,
    "Fishman's p.1835 | Hao X et al. Curr Neuropharmacol 2024 PMID:37563812 | Morgan & Mikhail 7e, p.937",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – RESPIRATORY DRIVE:
This slide covers what I consider one of the most clinically important aspects — the effects of anesthesia on respiratory drive.

There are two central chemoreceptor mechanisms: the response to rising CO2 (hypercapnic ventilatory response) and the response to falling oxygen (hypoxic ventilatory response).

For CO2 — all volatile anesthetics depress the CO2 response in a dose-dependent manner. At clinical anesthetic concentrations, patients will not breath adequately in response to hypercapnia. During emergence, this largely recovers because the concentrations drop below the meaningful threshold. IV agents and opioids also depress CO2 responsiveness.

Now — the critical point, and please highlight this — hypoxic ventilatory drive is MORE sensitive to volatile agents than CO2 response. The HVR is attenuated even at sub-anesthetic concentrations of volatiles. And because volatile agents are lipophilic and accumulate in muscle and fat, sufficient concentrations to suppress hypoxic drive persist for several hours after you turn off the gas.

This becomes life-threatening in COPD patients with chronic hypercapnia or obesity hypoventilation syndrome patients, who depend on their hypoxic drive to breathe. If you eliminate that drive and the patient is drowsy in the recovery room, they can deteriorate rapidly. This is a direct patient safety issue for pulmonologists managing these patients perioperatively.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 10 – NEUROMUSCULAR BLOCKADE
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, RGBColor(0x5C,0x1A,0x5C))
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "RESIDUAL NEUROMUSCULAR BLOCKADE", 0.3, 0.1, 12.5, 0.9,
            size=30, bold=True, color=WHITE)

# Left: Problem
add_rect(slide, 0.25, 1.15, 5.9, 0.5, RGBColor(0x5C,0x1A,0x5C))
add_textbox(slide, "The Problem", 0.35, 1.2, 5.7, 0.4, size=15, bold=True, color=WHITE)
prob = [
    "33–64% of patients arriving in PACU have inadequate",
    "neuromuscular recovery (train-of-four monitoring)",
    "",
    "Effects of residual blockade:",
    "  • Marked attenuation of HVR (hypoxic ventilatory response)",
    "  • Reduced upper airway dilator muscle activity",
    "  • Impaired respiratory muscle strength",
    "  • ↑ Risk: postop hypoxemia, upper airway obstruction",
    "",
    "TOF ratio <0.9 = clinically significant residual block",
    "TOF ratio <0.7 = severe impairment, reintubation risk",
    "",
    "Even partial blockade → pharyngeal muscle dysfunction",
    "→ impaired swallowing, aspiration risk",
]
add_multiline(slide, prob, 0.25, 1.7, 6.0, 4.9, size=13, color=DARK_TEXT)

# Right: Reversal agents
add_rect(slide, 6.7, 1.15, 6.2, 0.5, RGBColor(0x5C,0x1A,0x5C))
add_textbox(slide, "Reversal & Management", 6.8, 1.2, 6.0, 0.4, size=15, bold=True, color=WHITE)
rev = [
    "Traditional reversal: neostigmine (anticholinesterase)",
    "  • Incomplete at deep block (TOF <0.4)",
    "  • Muscarinic side effects",
    "  • Variable efficacy",
    "",
    "Sugammadex (selective relaxant binding agent):",
    "  • Encapsulates rocuronium/vecuronium",
    "  • Rapid, complete, reliable reversal",
    "  • Superior to neostigmine for PPCs",
    "",
    "Meta-analysis (Liu H et al. CMJ 2023):",
    "  • Sugammadex significantly reduces postoperative",
    "    pulmonary complications vs. neostigmine",
    "  • PMID: 37027443",
    "",
    "Monitoring recommendations:",
    "  • Quantitative TOF monitoring (not clinical assessment alone)",
    "  • Target TOF ratio ≥0.9 before extubation",
    "  • Increased vigilance in obese, elderly, renal failure",
]
add_multiline(slide, rev, 6.7, 1.7, 6.2, 4.9, size=13, color=DARK_TEXT)

add_textbox(slide,
    "Fishman's p.1836 | Liu H et al. Chin Med J 2023 PMID:37027443 | Pensier J et al. Anaesth Crit Care Pain Med 2025 PMID:40412515",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – RESIDUAL NEUROMUSCULAR BLOCKADE:
Residual neuromuscular blockade is a frequently underappreciated complication. The Fishman's textbook cites studies showing that between one-third and nearly two-thirds of patients arriving in the post-anesthesia care unit have inadequate neuromuscular recovery when assessed objectively with train-of-four monitoring.

This matters for pulmonary function because residual blockade specifically impairs the upper airway dilator muscles — which are more sensitive to neuromuscular blockers than the diaphragm. So a patient may appear to have adequate diaphragmatic function — they are breathing — but their pharyngeal muscles are still impaired. This leads to upper airway obstruction, loss of swallowing protection, and blunted hypoxic ventilatory responses.

Clinically, the shift to sugammadex for reversal of aminosteroidal relaxants has been a significant advance. A 2023 meta-analysis by Liu and colleagues confirmed that sugammadex is superior to neostigmine in preventing postoperative pulmonary complications — an important evidence point for your practice.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 11 – NEURAXIAL ANESTHESIA
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, RGBColor(0x0A,0x45,0x6B))
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "NEURAXIAL ANESTHESIA: PULMONARY EFFECTS", 0.3, 0.1, 12.5, 0.9,
            size=28, bold=True, color=WHITE)

# Comparison table
headers = ["Feature", "General Anesthesia", "Neuraxial Anesthesia"]
rows = [
    ["FRC", "↓ 20% (significant)", "Minimally affected"],
    ["Diaphragm function", "Impaired (motor tone lost)", "Preserved (phrenic nerve spared)"],
    ["Intercostal muscles", "Impaired", "Paralyzed at thoracic levels"],
    ["Hypoxic ventilatory response", "Markedly blunted", "Unaffected"],
    ["CO2 ventilatory response", "Dose-dependent depression", "Preserved or heightened"],
    ["Hypoxic pulmonary vasoconstriction", "Impaired by volatiles", "Unaffected"],
    ["Atelectasis formation", "Significant", "Minimal"],
    ["Postop pneumonia", "Higher risk", "Meta-analysis: lower risk"],
    ["30-day mortality", "Reference", "Meta-analysis: lower"],
    ["Respiratory depression", "Common", "Lower risk"],
]

table_top = 1.25
row_h = 0.43
col_widths = [3.2, 4.5, 4.5]
col_x_pos = [0.25, 3.5, 8.05]
header_colors = [NAVY, RGBColor(0xC0,0x39,0x2B), RGBColor(0x1A,0x5C,0x3A)]

for j, (header, col_w, col_x) in enumerate(zip(headers, col_widths, col_x_pos)):
    add_rect(slide, col_x, table_top, col_w, row_h, header_colors[j])
    add_textbox(slide, header, col_x+0.05, table_top+0.04, col_w-0.1, row_h-0.08,
                size=13, bold=True, color=WHITE, align=PP_ALIGN.CENTER)

for i, row in enumerate(rows):
    bg = LIGHT_BG if i % 2 == 0 else WHITE
    for j, (cell, col_w, col_x) in enumerate(zip(row, col_widths, col_x_pos)):
        add_rect(slide, col_x, table_top + (i+1)*row_h, col_w, row_h, bg)
        cell_color = DARK_TEXT
        if "↓" in cell or "Impaired" in cell or "blunted" in cell:
            cell_color = RED_WARN
        elif "Preserved" in cell or "lower" in cell.lower() or "Unaffected" in cell or "Minimal" in cell:
            cell_color = RGBColor(0x1A,0x5C,0x3A)
        add_textbox(slide, cell, col_x+0.05, table_top+(i+1)*row_h+0.04, col_w-0.1, row_h-0.08,
                    size=11.5, color=cell_color, align=PP_ALIGN.CENTER if j > 0 else PP_ALIGN.LEFT)

add_textbox(slide, "⚠ Neuraxial anesthesia at thoracic levels: motor block typically 2 dermatomes BELOW sensory level",
            0.25, 6.35, 12.5, 0.42, size=12, bold=True, color=RGBColor(0xA0,0x60,0x00))
add_textbox(slide,
    "Fishman's p.1836 | Morgan & Mikhail 7e, p.937 | Lusquinhos J et al. Cureus 2023 PMID:37303413",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – NEURAXIAL ANESTHESIA:
High-risk patients are often referred to receive neuraxial anesthesia — spinal or epidural — based on the premise that it spares the respiratory system. Let's examine what the evidence actually shows.

Neuraxial anesthesia does have real advantages. It preserves diaphragmatic innervation because the phrenic nerve exits at C3-C5, well above the typical spinal/epidural level. HPV is not impaired. CO2 responsiveness is preserved or even enhanced. FRC is much less affected because muscle tone is maintained above the block level.

The table shows the key comparisons. Red text indicates harm; green indicates advantage. Neuraxial anesthesia is predominantly green on the respiratory side.

Meta-analyses have detected lower 30-day mortality, lower rates of pneumonia, and reduced respiratory depression with neuraxial versus general anesthesia. However — and this is important — these analyses have been criticized for using heterogeneous surgical populations and older anesthetic techniques. Current guidelines do not yet recommend neuraxial as universally superior, especially with modern TIVA techniques and lung-protective ventilation strategies.

One caveat: at thoracic levels, external intercostal motor block occurs, but typically two dermatomes below the sensory level because motor neurons are less sensitive to local anesthetics.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 12 – POSTOPERATIVE ANALGESIA & RESPIRATORY DEPRESSION
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, RED_WARN)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "POSTOPERATIVE ANALGESIA & RESPIRATORY DEPRESSION", 0.3, 0.1, 12.5, 0.9,
            size=24, bold=True, color=WHITE)

left_c = [
    "Pain → Splinting → Atelectasis cascade:",
    "  • Inadequate analgesia → patient refuses to breathe deeply",
    "  • Retained secretions → mucus plugging",
    "  • Microatelectasis → hypoxemia → pneumonia",
    "",
    "Opioid analgesia: benefits vs. risks",
    "  BENEFITS: enables deep breathing, coughing, mobility",
    "  RISKS:",
    "    - Respiratory depression (dose-dependent)",
    "    - Hypercapnia, hypoxemia",
    "    - Impaired airway protective reflexes",
    "",
    "Incidence of opioid respiratory depression (PACU):",
    "  • Defined by naloxone use: 0.3%",
    "  • Defined by hypercapnia: 3.3%",
    "  • Defined by O2 desaturation: 17%",
    "  (Fishman's meta-analysis data, p.1836)",
    "",
    "Risk ↑ in: elderly, renal failure, OSA, obesity,",
    "  concurrent CNS depressants",
]
add_textbox(slide, "Pain & Respiratory Function", 0.3, 1.2, 6.2, 0.45, size=16, bold=True, color=RED_WARN)
add_multiline(slide, left_c, 0.3, 1.7, 6.2, 5.0, size=12.5, color=DARK_TEXT)

right_c = [
    "Epidural analgesia advantages:",
    "  • Reduces systemic opioid requirements",
    "  • Preserves respiratory muscle function",
    "  • Evidence: lower PPCs after abdominal/thoracic surgery",
    "",
    "Hydrophilic vs. lipophilic epidural opioids:",
    "  • Morphine (hydrophilic): stays in CSF, rostral spread",
    "    → Risk of delayed respiratory depression (6-12h)",
    "  • Fentanyl (lipophilic): locally absorbed, less rostral spread",
    "    → Lower delayed respiratory depression risk",
    "",
    "Multimodal analgesia (opioid-sparing):",
    "  • NSAIDs, acetaminophen, gabapentinoids",
    "  • Regional nerve blocks",
    "  • Reduces opioid dose → reduces respiratory risk",
    "",
    "Treatment of respiratory depression:",
    "  • Naloxone 0.1–0.4 mg IV (titrate to effect)",
    "  • Bag-mask ventilation as bridge",
    "  • Intubation if naloxone fails",
    "  • Monitor in HDU/ICU for recurrence (opioid > naloxone)",
]
add_textbox(slide, "Analgesic Strategies", 6.7, 1.2, 6.2, 0.45, size=16, bold=True, color=RED_WARN)
add_multiline(slide, right_c, 6.7, 1.7, 6.2, 5.0, size=12.5, color=DARK_TEXT)

add_textbox(slide,
    "Fishman's p.1836 | Dhillon G et al. Open Respir Med J 2023 PMID:38655075 | Lusquinhos J et al. Cureus 2023 PMID:37303413",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – POSTOPERATIVE ANALGESIA & RESPIRATORY DEPRESSION:
Postoperative pain and its management is a double-edged sword for pulmonary function.

On one side — undertreated pain causes splinting. Patients take shallow breaths, refuse to cough, cannot mobilize. The result is retained secretions, microatelectasis, and a downstream risk of pneumonia. This is particularly relevant after upper abdominal or thoracic surgery, where diaphragmatic excursion is directly impaired by incisional pain.

On the other side — opioid analgesia carries a real risk of respiratory depression. The 17% incidence of oxygen desaturation in the PACU — defined by pulse oximetry — is striking. Even at 0.3% requiring naloxone rescue, in a busy perioperative environment this represents a substantial burden.

The safest approach is multimodal analgesia — combining epidural catheters, NSAIDs, acetaminophen, and regional blocks to minimize the systemic opioid dose. For the highest-risk patients, consider HDU-level monitoring for at least the first 24 hours postoperatively, which is when opioid respiratory depression is most likely to occur.

One pharmacology point worth remembering — when morphine is given epidurally, its hydrophilicity means it stays in the CSF and spreads rostrally to reach the respiratory center in the floor of the 4th ventricle. This can cause delayed respiratory depression 6 to 12 hours after administration — a particularly insidious risk.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 13 – MITIGATION STRATEGIES
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, RGBColor(0x1A,0x5C,0x3A))
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "MITIGATION STRATEGIES: EVIDENCE-BASED APPROACHES", 0.3, 0.1, 12.5, 0.9,
            size=24, bold=True, color=WHITE)

# 4 columns
strategy_groups = [
    {
        "title": "PRE-OPERATIVE",
        "color": RGBColor(0x0A,0x45,0x6B),
        "items": [
            "Optimize underlying lung disease",
            "Preop CPAP for OSA patients",
            "Pulmonary rehab (high-risk)",
            "Smoking cessation (≥8 wks benefit)",
            "Nutrition optimization",
            "Risk stratification (ARISCAT score)",
        ]
    },
    {
        "title": "INTRA-OPERATIVE",
        "color": TEAL,
        "items": [
            "Lung-protective ventilation:",
            "  Vt 6–8 mL/kg IBW",
            "  PEEP 5–8 cmH2O",
            "  Recruitment maneuvers prn",
            "Minimize FiO2 (use air/O2 mix)",
            "TIVA (propofol) in high-risk",
            "Neuromuscular blockade:",
            "  Minimize depth",
            "  Quantitative TOF monitoring",
            "  Sugammadex for reversal",
            "Avoid head-down position if possible",
        ]
    },
    {
        "title": "POST-OPERATIVE",
        "color": RGBColor(0xE8,0x7A,0x00),
        "items": [
            "Neuraxial/regional analgesia",
            "Multimodal opioid-sparing",
            "Early extubation protocols",
            "Incentive spirometry",
            "Early ambulation",
            "Continuous SpO2 monitoring",
            "HDU monitoring in high-risk",
            "Postop NIV/CPAP if needed",
            "Chest physiotherapy",
        ]
    },
    {
        "title": "SPECIAL POPULATIONS",
        "color": RGBColor(0x5C,0x1A,0x5C),
        "items": [
            "OBESITY: head-up preoxygenation,",
            "  early PEEP, CPAP postop",
            "COPD: bronchodilators, avoid",
            "  high FiO2, volatile caution",
            "PULM HTN: avoid volatile agents,",
            "  maintain HPV, avoid hypoxia",
            "ELDERLY: minimize sedation,",
            "  use sugammadex, early mobility",
        ]
    },
]

for i, g in enumerate(strategy_groups):
    cx = 0.25 + i * 3.28
    cw = 3.1
    add_rect(slide, cx, 1.2, cw, 0.52, g["color"])
    add_textbox(slide, g["title"], cx+0.08, 1.25, cw-0.15, 0.45, size=13, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
    add_multiline(slide, g["items"], cx+0.08, 1.78, cw-0.1, 4.85, size=12, color=DARK_TEXT)

add_textbox(slide,
    "Dhillon G et al. Open Respir Med J 2023 PMID:38655075 | Pensier J et al. ACCPM 2025 PMID:40412515 | Lusquinhos J et al. Cureus 2023 PMID:37303413",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – MITIGATION STRATEGIES:
Armed with an understanding of the mechanisms, we can now translate these into a practical mitigation framework organized by perioperative phase.

Preoperatively — the most impactful interventions are optimizing underlying lung disease and addressing modifiable risk factors. CPAP therapy for OSA patients is important, and smoking cessation offers the most benefit when done at least 8 weeks before surgery.

Intraoperatively — lung-protective ventilation is now standard of care. The key parameters are tidal volumes of 6–8 mL/kg ideal body weight, PEEP of 5–8 cmH2O, and periodic recruitment maneuvers. Using air-oxygen mixtures instead of pure O2 reduces resorption atelectasis risk. For high-risk patients, TIVA with propofol avoids the HPV-impairing effects of volatile agents.

For neuromuscular blockade — use the minimum necessary depth, monitor quantitatively with train-of-four, and use sugammadex for reversal rather than neostigmine.

Postoperatively — the triad of neuraxial analgesia, early mobilization, and respiratory physiotherapy is well-supported. In high-risk patients — obese, COPD, those with pulmonary hypertension — a higher surveillance level is warranted for the first 24 hours.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 14 – PERIOPERATIVE VENTILATION SLIDE
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, TEAL)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "PERIOPERATIVE VENTILATION: KEY PARAMETERS", 0.3, 0.15, 12.5, 0.8,
            size=27, bold=True, color=WHITE)

add_textbox(slide, "Lung-Protective Ventilation Targets", 0.3, 1.2, 7.0, 0.45, size=16, bold=True, color=TEAL)
vent_data = [
    ("Tidal Volume (Vt)", "6–8 mL/kg IBW", "↑ Vt → barotrauma, volutrauma, worsens atelectasis in non-dependent zones"),
    ("PEEP", "5–8 cmH2O (individualized)", "Keeps alveoli open, reverses compressive atelectasis, reduces shunt"),
    ("FiO2", "Lowest to maintain SpO2 ≥95%", "High FiO2 → resorption atelectasis (N2 washout)"),
    ("Plateau pressure", "< 30 cmH2O", "Marker of overdistension, reduce Vt if exceeded"),
    ("Driving pressure", "< 15 cmH2O", "ΔP = Pplat − PEEP; strong predictor of PPCs"),
    ("RR", "12–16 / min", "Adjust to target normo/mild hypercapnia"),
    ("I:E ratio", "1:2 (standard)", "Longer expiration for obstructive disease"),
    ("Recruitment maneuvers", "After hypoxic events, patient disconnection", "30 cmH2O × 30 sec; always follow with PEEP increase"),
]

# Table header
header_cols = ["Parameter", "Target Value", "Rationale"]
header_widths = [2.8, 3.5, 6.5]
header_x = [0.25, 3.1, 6.65]
for j, (h, w, x) in enumerate(zip(header_cols, header_widths, header_x)):
    add_rect(slide, x, 1.75, w, 0.42, NAVY)
    add_textbox(slide, h, x+0.05, 1.77, w-0.1, 0.38, size=13, bold=True, color=WHITE, align=PP_ALIGN.CENTER)

row_h2 = 0.48
for i, row in enumerate(vent_data):
    bg = LIGHT_BG if i % 2 == 0 else WHITE
    for j, (cell, w, x) in enumerate(zip(row, header_widths, header_x)):
        add_rect(slide, x, 2.17 + i*row_h2, w, row_h2, bg)
        tc = RGBColor(0x1A,0x5C,0x3A) if j == 1 else DARK_TEXT
        add_textbox(slide, cell, x+0.05, 2.17+i*row_h2+0.03, w-0.1, row_h2-0.06,
                    size=11.5, color=tc)

add_textbox(slide,
    "Pensier J et al. Anaesth Crit Care Pain Med 2025 PMID:40412515 | Yue H & Yong T, Postgrad Med J 2024 PMID:38507221",
    0.3, 6.88, 12.5, 0.42, size=11, color=MED_GREY, italic=True)
add_note(slide, """SPEAKER SCRIPT – PERIOPERATIVE VENTILATION:
This slide provides a quick reference for lung-protective ventilation targets in the operating room.

The most important parameters from a pulmonary standpoint are tidal volume and driving pressure. Low tidal volumes — 6 to 8 mL/kg of ideal body weight, not actual body weight — reduce volutrauma and improve outcomes. This is the same low-Vt strategy we use in ARDS, now applied preventively in the OR.

Driving pressure is increasingly recognized as a more important predictor of postoperative pulmonary complications than Vt alone. Driving pressure equals plateau pressure minus PEEP. A value above 15 cmH2O predicts harm. The key manipulation is to increase PEEP — which raises the denominator — rather than just reducing Vt.

PEEP of 5–8 cmH2O is now routine. Higher PEEP may be needed in obese patients, but requires monitoring for hemodynamic effects. Recruitment maneuvers — 30 cmH2O for 30 seconds — are effective for reversing atelectasis, especially after patient disconnections, but must always be followed by an appropriate PEEP level to maintain the recruited lung.

The 2025 review by Pensier et al. in Anaesthesia Critical Care & Pain Medicine provides a current overview of these ventilation parameters and their evidence base.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 15 – KEY TAKE-AWAYS
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, NAVY)
add_rect(slide, 0, 0, 13.333, 1.1, GOLD)
add_rect(slide, 0, 6.85, 13.333, 0.65, TEAL)

add_textbox(slide, "KEY TAKE-AWAY MESSAGES", 0.3, 0.1, 12.5, 0.88, size=32, bold=True, color=NAVY)

takeaways = [
    "1.  General anesthesia causes an immediate, significant reduction in FRC (~20%) via diaphragm cephalad shift, rib cage inward movement, and increased intrathoracic blood volume.",
    "2.  Dependent atelectasis is universal within 10 minutes of induction, affecting 2–10% of lung volume, and is the primary cause of intraoperative hypoxemia.",
    "3.  Shunt fraction rises to 5–15% under GA. Volatile agents worsen this by impairing hypoxic pulmonary vasoconstriction — propofol/TIVA is preferred in high-risk patients.",
    "4.  Hypoxic ventilatory response is markedly blunted even at sub-anesthetic volatile concentrations; the effect persists hours after emergence — critical in COPD/OHS patients.",
    "5.  Residual neuromuscular blockade affects 33–64% of PACU patients; use quantitative TOF monitoring and sugammadex for complete reversal.",
    "6.  Neuraxial anesthesia preserves diaphragm function, HPV, and CO2 response — meta-analyses support lower PPCs and 30-day mortality vs. GA in appropriate candidates.",
    "7.  Lung-protective ventilation (Vt 6–8 mL/kg IBW, PEEP 5–8, driving pressure <15 cmH2O) is the intraoperative standard of care.",
    "8.  Multimodal analgesia with epidural/regional components minimizes systemic opioid use and reduces respiratory depression risk in the postoperative period.",
]
add_multiline(slide, takeaways, 0.4, 1.2, 12.5, 5.5, size=14.5, color=WHITE)

add_textbox(slide, "References available on following slide | Prepared August 2026", 0.3, 6.88, 12.5, 0.42,
            size=11, color=WHITE, italic=True, align=PP_ALIGN.CENTER)
add_note(slide, """SPEAKER SCRIPT – TAKE-AWAYS:
Let me summarize the eight key messages from today's presentation.

The effects of anesthesia on pulmonary function are immediate, multifaceted, and persist well into the recovery period. As a pulmonary fellow, you will be called to consult on patients before high-risk surgery, to help manage postoperative respiratory complications, and to advise on ventilator management in the perioperative period.

Understanding these mechanisms — not just memorizing the facts — allows you to reason through novel clinical scenarios. When a COPD patient deteriorates in the PACU after a two-hour abdominal procedure, you now have the framework to understand why: residual volatile effects on hypoxic drive, atelectasis reducing FRC below closing capacity, residual neuromuscular blockade impairing airway protection, and inadequate analgesia causing splinting.

The good news is that all of these are modifiable with evidence-based interventions — which is where your expertise as a pulmonologist adds direct value to the surgical team.""")

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 16 – REFERENCES
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
add_rect(slide, 0, 0, 13.333, 1.1, NAVY)
add_rect(slide, 0, 6.85, 13.333, 0.65, LIGHT_BG)

add_textbox(slide, "REFERENCES", 0.3, 0.15, 12.5, 0.75, size=32, bold=True, color=WHITE)

refs = [
    "TEXTBOOKS",
    "1.  Morgan GE, Mikhail MS, Murray MJ. Morgan & Mikhail's Clinical Anesthesiology, 7th ed. McGraw-Hill; 2022. Chapter 23: pp.935-942.",
    "2.  Fishman AP, et al. Fishman's Pulmonary Diseases and Disorders, 2-Volume Set, 5th ed. McGraw-Hill; 2022. Chapter 115: Impact of Anesthesia and Postoperative Analgesia on Pulmonary Function, pp.1834-1840.",
    "",
    "RECENT PEER-REVIEWED PUBLICATIONS",
    "3.  Zeng C, Lagier D, Lee JW, et al. Perioperative Pulmonary Atelectasis: Part I. Biology and Mechanisms. Anesthesiology. 2022;136(2):181-205. PMID: 34499087. doi:10.1097/ALN.0000000000003943",
    "4.  Khan A, Bashour SI, Casal RF. Preventing Atelectasis During Bronchoscopy Under General Anesthesia. J Thorac Dis. 2023;15(7):3720-3730. PMID: 37426163. doi:10.21037/jtd-23-97",
    "5.  Hao X, Yang Y, Liu J. The Modulation by Anesthetics and Analgesics of Respiratory Rhythm in the Nervous System. Curr Neuropharmacol. 2024;22(4):698-714. PMID: 37563812. doi:10.2174/1570159X21666230810110901",
    "6.  Liu H, Luo R, Cao S, et al. Superiority of Sugammadex in Preventing Postoperative Pulmonary Complications. Chin Med J. 2023;136(9):1066-1073. PMID: 37027443. doi:10.1097/CM9.0000000000002381",
    "7.  Pensier J, Guerrero MA, Berger-Estilita J, et al. Perioperative Ventilation Support: What Clinicians and Researchers Must Know. Anaesth Crit Care Pain Med. 2025. PMID: 40412515. doi:10.1016/j.accpm.2025.101554",
    "8.  Yue H, Yong T. Progress in the Relationship Between Mechanical Ventilation Parameters and Ventilator-Related Complications During Perioperative Anesthesia. Postgrad Med J. 2024;100(1184):500-508. PMID: 38507221. doi:10.1093/postmj/qgae035",
    "9.  Lusquinhos J, Tavares M, Abelha F. Postoperative Pulmonary Complications and Perioperative Strategies: A Systematic Review. Cureus. 2023;15(6):e38786. PMID: 37303413. doi:10.7759/cureus.38786",
    "10. Dhillon G, Buddhavarapu VS, Grewal H, et al. Evidence-Based Practice Interventions for Reducing Postoperative Pulmonary Complications: A Narrative Review. Open Respir Med J. 2023;17:e210299X247199. PMID: 38655075. doi:10.2174/012210299X247199231128100613",
    "11. Petersson J, Glenny RW. Gas Exchange in the Lung. Semin Respir Crit Care Med. 2023;44(6):757-774. PMID: 37816345. doi:10.1055/s-0043-1770060",
    "12. Peralta AR, Debiane LG. Anesthesia Strategies to Minimize Lung Atelectasis in Peripheral Bronchoscopy. Curr Opin Pulm Med. 2026. PMID: 41065573.",
]

add_multiline(slide, refs, 0.3, 1.15, 12.7, 5.55, size=11.5, color=DARK_TEXT)
add_note(slide, """SPEAKER SCRIPT – REFERENCES:
Here are the full references for the presentation. They include two authoritative textbooks — Morgan and Mikhail's Clinical Anesthesiology and Fishman's Pulmonary Diseases and Disorders — alongside 10 recent peer-reviewed publications from 2022 to 2026.

The most recent publication is from 2026 — Peralta and Debiane on anesthesia strategies for minimizing atelectasis during bronchoscopy — which is directly relevant to our bronchoscopy practice.

All PubMed IDs are provided for easy retrieval. I am happy to share the presentation file and the reference list. Thank you for your attention.""")

# ─────────────────────────────────────────────────────────────────────────────
# SAVE
# ─────────────────────────────────────────────────────────────────────────────
out_path = "/tmp/workspace/anesthesia-pptx/Effects_of_Anesthesia_on_Pulmonary_Function.pptx"
from io import BytesIO
buf = BytesIO()
prs.save(buf)
with open(out_path, "wb") as f:
    f.write(buf.getvalue())

print(f"Saved: {out_path}")
print(f"Slides: {len(prs.slides)}")
Running Command

cd /tmp/workspace/anesthesia-pptx && python build_pptx.py 2>&1

Editing File

~/anesthesia-pptx/build_pptx.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/anesthesia-pptx/build_pptx.py'
Editing File

~/anesthesia-pptx/build_pptx.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/anesthesia-pptx/build_pptx.py'
Running Command

cd /tmp/workspace/anesthesia-pptx && python build_pptx.py 2>&1

Running Command

ls -lh /tmp/workspace/anesthesia-pptx/ && python3 -c " from pptx import Presentation prs = Presentation('/tmp/workspace/anesthesia-pptx/Effects_of_Anesthesia_on_Pulmonary_Function.pptx') print(f'Total slides: {len(prs.slides)}') for i, slide in enumerate(prs.slides, 1): texts = [] pics = [] for s in slide.shapes: if s.has_text_frame: t = s.text_frame.text.strip() if t: texts.append(t[:60]) if s.shape_type == 13: pics.append('IMAGE') notes = '' try: n = slide.notes_slide.notes_text_frame.text.strip() notes = f'[Notes: {len(n)} chars]' except: pass print(f' Slide {i:2d}: {texts[0][:55] if texts else \"(no text)\"} | Pics:{len(pics)} {notes}') "

Your presentation is ready:

Effects of Anesthesia on Pulmonary Function

Presentation · PPTX


What's Inside (16 Slides, 16:9 Widescreen)

#Slide TitleVisual Elements
1Title SlideNavy/gold professional design
2OutlineFull session roadmap
3Physiologic BasisTwo-column mechanism overview
4Lung Volumes & FRCCustom bar chart (Awake upright → Supine → GA)
5Diaphragm Shift DiagramEmbedded textbook image (Awake vs. Anesthetized)
6Perioperative Atelectasis3-column table: Types / CT Evidence / Risk Factors
7V/Q Matching & Gas ExchangeV/Q spectrum visual schematic
8Airway Resistance & WOBTwo-column layout with key equations
9Respiratory Drive (HVR/HCVR)Red-highlighted warning panel on hypoxic drive
10Residual NMBProblem / Reversal two-column layout
11Neuraxial vs. GA ComparisonColor-coded comparison table (red=harm, green=benefit)
12Postop Analgesia & Resp. DepressionIncidence data + morphine/fentanyl epidural comparison
13Mitigation Strategies4-column: Pre-op / Intra-op / Post-op / Special Populations
14Perioperative Ventilation ParametersParameter reference table with targets & rationale
15Key Take-Away Messages8 clinical pearls on dark navy
16References12 full citations with PMIDs & DOIs

References Used

Textbooks:
  • Morgan & Mikhail's Clinical Anesthesiology, 7e, Chapter 23 (pp. 935-942)
  • Fishman's Pulmonary Diseases & Disorders, 5e, Chapter 115 (pp. 1834-1840)
Recent Publications (2022-2026):
  • Zeng et al. Anesthesiology 2022 - Perioperative Atelectasis Biology (PMID: 34499087)
  • Khan et al. J Thorac Dis 2023 - Atelectasis prevention in bronchoscopy (PMID: 37426163)
  • Hao et al. Curr Neuropharmacol 2024 - Anesthetic modulation of respiratory rhythm (PMID: 37563812)
  • Liu et al. Chin Med J 2023 - Sugammadex meta-analysis (PMID: 37027443)
  • Pensier et al. Anaesth Crit Care Pain Med 2025 - Perioperative ventilation (PMID: 40412515)
  • Yue & Yong. Postgrad Med J 2024 - Ventilator parameters & PPCs (PMID: 38507221)
  • Lusquinhos et al. Cureus 2023 - PPCs systematic review (PMID: 37303413)
  • Dhillon et al. Open Respir Med J 2023 - Evidence-based PPC reduction (PMID: 38655075)
  • Petersson & Glenny. Semin Respir Crit Care Med 2023 - Gas exchange physiology (PMID: 37816345)
  • Peralta & Debiane. Curr Opin Pulm Med 2026 - Atelectasis in bronchoscopy (PMID: 41065573)
Each slide has a full speaker script in the Notes panel — just click the Notes view in PowerPoint.
This is a shared conversation. Sign in to Orris to start your own chat.