Respiratory system notes pdf
mkdir -p /home/daytona/workspace/respiratory-notes && ls /home/daytona/workspace/respiratory-notes/
~/respiratory-notes/build_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table,
TableStyle, HRFlowable, PageBreak, KeepTogether)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import ListFlowable, ListItem
OUTPUT = "/home/daytona/workspace/respiratory-notes/Respiratory_System_Notes.pdf"
# ── Color Palette ──────────────────────────────────────────────────────────
NAVY = colors.HexColor("#1a3c5e")
BLUE = colors.HexColor("#2563EB")
LBLUE = colors.HexColor("#EFF6FF")
TEAL = colors.HexColor("#0D9488")
LTEAL = colors.HexColor("#F0FDFA")
AMBER = colors.HexColor("#D97706")
LAMBER = colors.HexColor("#FFFBEB")
RED = colors.HexColor("#DC2626")
LRED = colors.HexColor("#FEF2F2")
GREEN = colors.HexColor("#16A34A")
LGREEN = colors.HexColor("#F0FDF4")
GREY = colors.HexColor("#374151")
LGREY = colors.HexColor("#F9FAFB")
WHITE = colors.white
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=2*cm, rightMargin=2*cm,
topMargin=2.5*cm, bottomMargin=2.5*cm,
title="Respiratory System - Comprehensive Medical Notes",
author="Orris Medical Library"
)
styles = getSampleStyleSheet()
# Custom styles
def S(name, **kw):
return ParagraphStyle(name, **kw)
cover_title = S("CoverTitle", fontSize=30, textColor=WHITE, fontName="Helvetica-Bold",
alignment=TA_CENTER, spaceAfter=8)
cover_sub = S("CoverSub", fontSize=14, textColor=colors.HexColor("#BFDBFE"),
fontName="Helvetica", alignment=TA_CENTER, spaceAfter=4)
h1 = S("H1", fontSize=18, textColor=WHITE, fontName="Helvetica-Bold",
alignment=TA_LEFT, spaceAfter=4, spaceBefore=0, leading=22)
h2 = S("H2", fontSize=13, textColor=NAVY, fontName="Helvetica-Bold",
spaceBefore=12, spaceAfter=4, leading=16)
h3 = S("H3", fontSize=11, textColor=TEAL, fontName="Helvetica-Bold",
spaceBefore=8, spaceAfter=3, leading=14)
body = S("Body", fontSize=9.5, textColor=GREY, fontName="Helvetica",
leading=14, spaceAfter=5, alignment=TA_JUSTIFY)
bullet_style = S("Bullet", fontSize=9.5, textColor=GREY, fontName="Helvetica",
leading=13, spaceAfter=3, leftIndent=14, firstLineIndent=-10)
note_style = S("Note", fontSize=9, textColor=colors.HexColor("#1E40AF"),
fontName="Helvetica-Oblique", leading=13, leftIndent=8)
key_style = S("Key", fontSize=9, textColor=RED, fontName="Helvetica-Bold",
leading=13, spaceAfter=2)
table_header= S("TH", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
alignment=TA_CENTER, leading=12)
table_cell = S("TC", fontSize=9, textColor=GREY, fontName="Helvetica",
alignment=TA_LEFT, leading=12)
table_cell_c= S("TCC", fontSize=9, textColor=GREY, fontName="Helvetica",
alignment=TA_CENTER, leading=12)
# ── Helpers ────────────────────────────────────────────────────────────────
def section_banner(text, color=NAVY):
data = [[Paragraph(text, h1)]]
t = Table(data, colWidths=[17*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), color),
("ROUNDEDCORNERS", [6]),
("TOPPADDING", (0,0), (-1,-1), 8),
("BOTTOMPADDING", (0,0), (-1,-1), 8),
("LEFTPADDING", (0,0), (-1,-1), 12),
("RIGHTPADDING", (0,0), (-1,-1), 12),
]))
return t
def info_box(title, content_paras, bg=LBLUE, border=BLUE):
rows = [[Paragraph(f"<b>{title}</b>", S("BoxH", fontSize=9.5, textColor=border,
fontName="Helvetica-Bold", leading=13))]]
for p in content_paras:
rows.append([Paragraph(p, S("BoxB", fontSize=9, textColor=GREY,
fontName="Helvetica", leading=13, spaceAfter=2))])
t = Table(rows, colWidths=[16.6*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("BOX", (0,0), (-1,-1), 1, border),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING", (0,0), (-1,-1), 10),
]))
return t
def make_table(headers, rows, col_widths):
th_cells = [Paragraph(h, table_header) for h in headers]
data = [th_cells]
for row in rows:
data.append([Paragraph(str(c), table_cell) for c in row])
t = Table(data, colWidths=col_widths)
style = [
("BACKGROUND", (0,0), (-1,0), NAVY),
("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, LGREY]),
("GRID", (0,0), (-1,-1), 0.5, colors.HexColor("#D1D5DB")),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "TOP"),
]
t.setStyle(TableStyle(style))
return t
def bp(text):
return Paragraph(f"• {text}", bullet_style)
def p(text):
return Paragraph(text, body)
def sp(n=6):
return Spacer(1, n)
def hr():
return HRFlowable(width="100%", thickness=0.5, color=colors.HexColor("#E5E7EB"), spaceAfter=4, spaceBefore=4)
# ── Cover Page ─────────────────────────────────────────────────────────────
def make_cover():
elems = []
cover_data = [[Paragraph("RESPIRATORY SYSTEM", cover_title)],
[Paragraph("Comprehensive Medical Notes", cover_sub)],
[Paragraph("Physiology · Anatomy · Pathology · Clinical", cover_sub)],
[Spacer(1, 10)],
[Paragraph("Sources: Murray & Nadel's Respiratory Medicine · Guyton & Hall · Medical Physiology",
S("CoverSrc", fontSize=10, textColor=colors.HexColor("#93C5FD"),
fontName="Helvetica-Oblique", alignment=TA_CENTER))]]
cover_table = Table(cover_data, colWidths=[17*cm])
cover_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), NAVY),
("ROUNDEDCORNERS", [10]),
("TOPPADDING", (0,0), (-1,-1), 30),
("BOTTOMPADDING", (0,0), (-1,-1), 30),
("LEFTPADDING", (0,0), (-1,-1), 20),
("RIGHTPADDING", (0,0), (-1,-1), 20),
]))
elems.append(Spacer(1, 1*cm))
elems.append(cover_table)
elems.append(Spacer(1, 0.8*cm))
# TOC preview
toc_items = [
"1. Overview & Anatomy of the Respiratory System",
"2. Lung Volumes & Capacities",
"3. Mechanics of Breathing",
"4. Ventilation & Dead Space",
"5. Pulmonary Circulation & Blood Flow",
"6. Gas Exchange & Diffusion",
"7. Oxygen & CO2 Transport in Blood",
"8. Control of Breathing",
"9. Ventilation-Perfusion Relationships",
"10. Common Respiratory Diseases",
"11. Key Clinical Parameters & Reference Values",
]
toc_rows = [[Paragraph(i, S("TOC", fontSize=9.5, textColor=GREY,
fontName="Helvetica", leading=14))] for i in toc_items]
toc_t = Table([[Paragraph("<b>TABLE OF CONTENTS</b>", S("TOCH", fontSize=11,
textColor=NAVY, fontName="Helvetica-Bold", leading=15))]] + toc_rows,
colWidths=[17*cm])
toc_t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), LBLUE),
("BACKGROUND", (0,1), (-1,-1), WHITE),
("BOX", (0,0), (-1,-1), 1, BLUE),
("GRID", (0,1), (-1,-1), 0.3, colors.HexColor("#DBEAFE")),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 12),
("RIGHTPADDING", (0,0), (-1,-1), 12),
]))
elems.append(toc_t)
elems.append(PageBreak())
return elems
# ═══════════════════════════════════════════════════════════════════════════
story = []
story += make_cover()
# ── SECTION 1: OVERVIEW & ANATOMY ─────────────────────────────────────────
story.append(section_banner("1. OVERVIEW & ANATOMY OF THE RESPIRATORY SYSTEM", NAVY))
story.append(sp(8))
story.append(Paragraph("<b>Primary Function</b>", h2))
story.append(p("The primary function of the lung is <b>gas exchange</b>: delivering O2 to tissues and removing CO2. "
"Secondary functions include metabolizing compounds, filtering unwanted materials from the circulation, "
"and acting as a blood reservoir. (Murray & Nadel's)"))
story.append(sp(6))
story.append(Paragraph("<b>Structural Divisions</b>", h2))
story.append(make_table(
["Division", "Components", "Function"],
[
["Upper Respiratory Tract", "Nose, nasal cavity, paranasal sinuses, pharynx, larynx", "Filtering, warming, humidifying air; phonation"],
["Lower Respiratory Tract", "Trachea, bronchi, bronchioles, alveoli", "Conducting airways + gas exchange"],
["Conducting Zone", "Trachea → terminal bronchioles (generations 0–16)", "Air conduction only; forms anatomic dead space"],
["Transitional Zone", "Respiratory bronchioles (gen. 17–19)", "Partial gas exchange begins"],
["Respiratory Zone", "Alveolar ducts, alveolar sacs, alveoli (gen. 20–23)", "Primary site of gas exchange"],
],
[3.5*cm, 6.5*cm, 7*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>Weibel Model of Airway Branching (Model A)</b>", h2))
story.append(p("Weibel's model describes the human airways as a <b>dichotomously branching system</b> of 23 generations (Z). "
"Key features:"))
story.append(bp("Generations 0–16: conducting airways (trachea to terminal bronchioles) - NO alveoli"))
story.append(bp("Total cross-sectional area remains relatively constant until ~generation 16, then increases <b>dramatically</b>"))
story.append(bp("This area increase causes gas velocity to drop sharply near terminal bronchioles"))
story.append(bp("Gas transport shifts from <b>convective (bulk) flow</b> proximal to generation 16 → "
"<b>molecular diffusion</b> distal to generation 16"))
story.append(bp("Generations 17–19: respiratory bronchioles (transitional zone)"))
story.append(bp("Generations 20–22: alveolar ducts; generation 23: alveolar sacs"))
story.append(sp(4))
story.append(info_box("Clinical Pearl",
["Heavy sedimentation of aerosol particles occurs at the level of terminal bronchioles because "
"large-mass particles transported by bulk flow do not penetrate further by diffusion. This is why "
"the terminal bronchiole region is particularly vulnerable to particulate air pollutants."],
bg=LAMBER, border=AMBER))
story.append(sp(8))
story.append(Paragraph("<b>Alveolar Architecture</b>", h2))
story.append(bp("~300 million alveoli in adult lungs; total surface area ~70–100 m²"))
story.append(bp("Alveolar wall (septum) contains: Type I pneumocytes (gas exchange, 95% surface), "
"Type II pneumocytes (surfactant production), capillary endothelium, basement membranes"))
story.append(bp("Surfactant (dipalmitoylphosphatidylcholine) reduces surface tension, prevents alveolar collapse, "
"reduces work of breathing"))
story.append(bp("Pulmonary capillary blood-gas barrier thickness: ~0.5 µm (extremely thin for efficient diffusion)"))
story.append(sp(4))
story.append(Paragraph("<b>Lung Lobes</b>", h2))
story.append(make_table(
["Side", "Lobes", "Segments"],
[["Right lung", "3 lobes: Upper, Middle, Lower", "10 bronchopulmonary segments"],
["Left lung", "2 lobes: Upper (with lingula), Lower", "8–9 bronchopulmonary segments"]],
[3*cm, 7*cm, 7*cm]
))
story.append(PageBreak())
# ── SECTION 2: LUNG VOLUMES & CAPACITIES ─────────────────────────────────
story.append(section_banner("2. LUNG VOLUMES & CAPACITIES", TEAL))
story.append(sp(8))
story.append(p("Lung volumes are measured by <b>spirometry</b> (static) and <b>gas dilution / body plethysmography</b> "
"(for volumes containing residual volume). Normal values are for a 70-kg adult male."))
story.append(sp(6))
story.append(make_table(
["Volume/Capacity", "Abbreviation", "Normal Value", "Definition"],
[
["Tidal Volume", "TV (VT)", "~500 mL", "Volume of one normal breath"],
["Inspiratory Reserve Volume","IRV", "~3000 mL", "Extra volume that can be inhaled above VT"],
["Expiratory Reserve Volume", "ERV", "~1100 mL", "Extra volume that can be exhaled after normal expiration"],
["Residual Volume", "RV", "~1200 mL", "Volume remaining after maximal expiration (cannot be spirometered)"],
["Total Lung Capacity", "TLC", "~5800 mL", "Total volume at maximal inspiration (IRV+VT+ERV+RV)"],
["Vital Capacity", "VC", "~4600 mL", "Maximum volume exhaled after maximal inspiration (TLC – RV)"],
["Functional Residual Capacity","FRC", "~2300 mL", "Volume at end of normal expiration (ERV+RV)"],
["Inspiratory Capacity", "IC", "~3500 mL", "Maximum volume inhaled from FRC (VT+IRV)"],
["Forced Expiratory Volume 1s","FEV1", "~80% of FVC","Volume exhaled in 1st second of forced expiration"],
["Forced Vital Capacity", "FVC", "~4600 mL", "Total volume exhaled in forced expiration"],
],
[3.8*cm, 2.5*cm, 2.5*cm, 8.2*cm]
))
story.append(sp(8))
story.append(info_box("Obstructive vs. Restrictive Pattern",
["<b>Obstructive</b> (e.g., COPD, asthma): FEV1/FVC <0.70; FEV1 reduced; TLC normal or increased; RV increased",
"<b>Restrictive</b> (e.g., pulmonary fibrosis, chest wall disease): FVC reduced; FEV1/FVC normal or increased; TLC reduced"],
bg=LRED, border=RED))
story.append(sp(8))
story.append(Paragraph("<b>Key Relationships</b>", h2))
story.append(bp("TLC = IRV + VT + ERV + RV"))
story.append(bp("FRC = ERV + RV (lung volume at passive equilibrium between lung recoil and chest wall)"))
story.append(bp("VC = IRV + VT + ERV"))
story.append(bp("Anatomic dead space ≈ 150 mL (≈ 1 mL/pound body weight) in a 70-kg adult"))
story.append(bp("FRC is the point at which lung inward recoil = chest wall outward recoil"))
story.append(PageBreak())
# ── SECTION 3: MECHANICS OF BREATHING ─────────────────────────────────────
story.append(section_banner("3. MECHANICS OF BREATHING", colors.HexColor("#7C3AED")))
story.append(sp(8))
story.append(Paragraph("<b>Pressure Gradients Driving Airflow</b>", h2))
story.append(make_table(
["Pressure", "Definition", "Normal Value"],
[
["Atmospheric (Patm)", "Pressure at airway opening", "760 mmHg (sea level)"],
["Alveolar (Palv)", "Pressure inside alveoli", "0 cmH2O at rest (= Patm)"],
["Intrapleural (Ppl)", "Pressure in pleural space", "–5 cmH2O at FRC"],
["Transpulmonary (PL)", "Palv − Ppl (distending pressure)", "+5 cmH2O at FRC"],
["Transrespiratory", "Patm − Palv (driving airflow)", "~1–2 cmH2O during tidal breathing"],
],
[4*cm, 7*cm, 6*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>Compliance</b>", h2))
story.append(p("Compliance (C) = ΔVolume / ΔPressure. It measures how easily the lungs/chest wall distend."))
story.append(bp("Normal lung compliance: ~200 mL/cmH2O"))
story.append(bp("Normal chest wall compliance: ~200 mL/cmH2O"))
story.append(bp("Combined (respiratory system): ~100 mL/cmH2O"))
story.append(bp("<b>Increased compliance</b>: emphysema (destruction of elastic tissue)"))
story.append(bp("<b>Decreased compliance</b>: pulmonary fibrosis, pulmonary edema, ARDS, surfactant deficiency"))
story.append(sp(4))
story.append(Paragraph("<b>Airway Resistance</b>", h2))
story.append(p("Resistance (R) = ΔPressure / Flow. Governed by <b>Poiseuille's Law</b>: R ∝ 1/r⁴ (radius⁴)."))
story.append(bp("Normal airway resistance: 0.5–2.5 cmH2O/L/s"))
story.append(bp("Major site of resistance: medium-sized bronchi (generations 4–7), NOT the small airways"))
story.append(bp("<b>Increased resistance</b>: bronchospasm (asthma), mucus plugging, COPD, foreign body"))
story.append(bp("Bronchodilators (β2-agonists, anticholinergics) reduce resistance by increasing airway radius"))
story.append(sp(4))
story.append(Paragraph("<b>Work of Breathing</b>", h2))
story.append(bp("Normal work of breathing: ~0.5–1.0 J/breath; accounts for ~2–3% of total body O2 consumption"))
story.append(bp("Increased in: obstructive disease (↑ resistive work), restrictive disease (↑ elastic work)"))
story.append(bp("In respiratory failure, WOB may consume >25–30% of O2 delivery → mechanical ventilation required"))
story.append(sp(4))
story.append(Paragraph("<b>Elastic Recoil & Surfactant</b>", h2))
story.append(bp("Lung recoil force: ~2/3 from surface tension (alveolar air-liquid interface), ~1/3 from tissue elasticity"))
story.append(bp("Surfactant reduces surface tension from ~72 mN/m (water) to <5 mN/m"))
story.append(bp("Laplace's Law: P = 2T/r. Small alveoli would collapse without surfactant decreasing T at small radii"))
story.append(bp("Surfactant deficiency: neonatal respiratory distress syndrome (RDS) in premature infants"))
story.append(PageBreak())
# ── SECTION 4: VENTILATION & DEAD SPACE ──────────────────────────────────
story.append(section_banner("4. VENTILATION & DEAD SPACE", TEAL))
story.append(sp(8))
story.append(Paragraph("<b>Definitions</b>", h2))
story.append(make_table(
["Parameter", "Formula", "Normal Value", "Notes"],
[
["Minute (Total) Ventilation (VE)", "VE = VT × f", "~6 L/min", "VT=500 mL × 12 breaths/min"],
["Dead Space Volume (VD)", "Anatomic ~150 mL + alveolar dead space", "~150 mL", "≈ 1 mL/lb body weight"],
["Dead Space Ventilation (VD-dot)", "VD × f", "~1.8 L/min", "30% of total ventilation"],
["Alveolar Ventilation (VA-dot)", "VA = (VT − VD) × f", "~4.2 L/min", "Only this reaches alveoli for exchange"],
],
[4.5*cm, 3.5*cm, 2.5*cm, 6.5*cm]
))
story.append(sp(8))
story.append(info_box("Dead Space Concept (Bohr Equation)",
["Physiologic dead space = Anatomic dead space + Alveolar dead space",
"Bohr equation: VD/VT = (PaCO2 − PECO2) / PaCO2",
"Alveolar dead space: ventilated but not perfused alveoli (e.g., pulmonary embolism increases VD/VT)",
"Fowler single-breath N2-washout technique: used to measure anatomic dead space experimentally"],
bg=LTEAL, border=TEAL))
story.append(sp(8))
story.append(Paragraph("<b>Alveolar Gas Equation</b>", h2))
story.append(p("The alveolar O2 tension (PAO2) is calculated as:"))
story.append(info_box("Alveolar Gas Equation",
["PAO2 = (FiO2 × [Patm − PH2O]) − (PaCO2 / RQ)",
"At sea level breathing room air: PAO2 = (0.21 × 713) − (40/0.8) ≈ 149.7 − 50 ≈ 100 mmHg",
"PH2O = 47 mmHg at 37°C; RQ (respiratory quotient) = 0.8 (mixed diet)",
"Normal A-a gradient = 5–15 mmHg (increases with age, increases in V/Q mismatch, shunt, diffusion limitation)"],
bg=LGREEN, border=GREEN))
story.append(PageBreak())
# ── SECTION 5: PULMONARY CIRCULATION ─────────────────────────────────────
story.append(section_banner("5. PULMONARY CIRCULATION & BLOOD FLOW", NAVY))
story.append(sp(8))
story.append(Paragraph("<b>Pulmonary vs. Systemic Circulation</b>", h2))
story.append(make_table(
["Feature", "Pulmonary", "Systemic"],
[
["Pressure (systolic/diastolic)", "25/8 mmHg (mean ~15 mmHg)", "120/80 mmHg (mean ~95 mmHg)"],
["Resistance", "Low (1/10 of systemic)", "High"],
["Wall thickness", "Thin, compliant vessels", "Thick muscular arteries"],
["Response to hypoxia", "Vasoconstriction (HPV)", "Vasodilation"],
["Function", "Gas exchange, blood filtration", "O2 delivery to tissues"],
],
[4*cm, 6.5*cm, 6.5*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>Hypoxic Pulmonary Vasoconstriction (HPV)</b>", h2))
story.append(p("When alveolar O2 tension (PAO2) falls, local pulmonary arterioles <b>constrict</b>. "
"This is the opposite of the systemic response. HPV diverts blood away from "
"poorly-ventilated regions, optimising V/Q matching. Chronic hypoxia (e.g., high altitude, "
"COPD) leads to sustained HPV → pulmonary hypertension → cor pulmonale."))
story.append(sp(6))
story.append(Paragraph("<b>Zones of the Lung (West Zones)</b>", h2))
story.append(p("Due to gravity, both ventilation (V) and perfusion (Q) vary from apex to base, but "
"perfusion varies more steeply. This creates three zones described by John West:"))
story.append(make_table(
["Zone", "Location", "Pressures", "Perfusion"],
[
["Zone 1 (Apex)", "Apex of lung", "PA > Pa > Pv (alveolar > arterial > venous)", "Minimal/absent; physiologic dead space"],
["Zone 2 (Middle)", "Mid-lung", "Pa > PA > Pv (arterial > alveolar > venous)", "Intermittent; depends on arterial pressure"],
["Zone 3 (Base)", "Base of lung", "Pa > Pv > PA (both vascular > alveolar)", "Maximal, continuous"],
],
[2.5*cm, 2.5*cm, 7*cm, 5*cm]
))
story.append(sp(4))
story.append(info_box("Clinical Note",
["Zone 1 is normally absent in upright humans (pulmonary arterial pressure sufficient to perfuse apex). "
"Zone 1 expands in: haemorrhage (↓Pa), positive-pressure ventilation (↑PA), ARDS."],
bg=LAMBER, border=AMBER))
story.append(PageBreak())
# ── SECTION 6: GAS EXCHANGE & DIFFUSION ──────────────────────────────────
story.append(section_banner("6. GAS EXCHANGE & DIFFUSION", TEAL))
story.append(sp(8))
story.append(Paragraph("<b>Fick's Law of Diffusion</b>", h2))
story.append(info_box("Fick's Law",
["Vgas = (A / T) × D × (P1 − P2)",
"A = surface area of membrane; T = membrane thickness; D = diffusion coefficient (∝ solubility / √MW)",
"P1 − P2 = partial pressure gradient",
"CO2 diffuses ~20× faster than O2 (higher solubility); O2 transfer can be diffusion-limited under stress"],
bg=LGREEN, border=GREEN))
story.append(sp(6))
story.append(Paragraph("<b>Diffusion Capacity (DLCO)</b>", h2))
story.append(bp("DLCO measures the ability of the lung to transfer CO to the blood (used as proxy for O2)"))
story.append(bp("Normal DLCO: ~25 mL/min/mmHg"))
story.append(bp("Decreased DLCO: emphysema (↓surface area), pulmonary fibrosis (↑thickness), pulmonary hypertension (↓capillary volume)"))
story.append(bp("Increased DLCO: polycythaemia, pulmonary haemorrhage (extra Hb in alveoli), left-to-right shunt"))
story.append(sp(6))
story.append(Paragraph("<b>Causes of Hypoxaemia</b>", h2))
story.append(make_table(
["Mechanism", "A-a Gradient", "Examples", "Response to 100% O2"],
[
["Low inspired PO2", "Normal", "High altitude", "Yes"],
["Hypoventilation", "Normal", "Opioid overdose, neuromuscular disease", "Yes"],
["V/Q mismatch", "Elevated", "COPD, asthma, PE", "Yes (partial)"],
["Diffusion limitation", "Elevated", "Pulmonary fibrosis (exercise)", "Yes"],
["Shunt (right→left)", "Elevated", "ASD, VSD, ARDS, hepatopulmonary syndrome", "Minimal/no"],
],
[3.5*cm, 2.5*cm, 5*cm, 6*cm]
))
story.append(PageBreak())
# ── SECTION 7: O2 & CO2 TRANSPORT ─────────────────────────────────────────
story.append(section_banner("7. OXYGEN & CO2 TRANSPORT IN BLOOD", NAVY))
story.append(sp(8))
story.append(Paragraph("<b>Oxygen Transport</b>", h2))
story.append(make_table(
["Form", "Amount", "Details"],
[
["Dissolved in plasma", "~0.3 mL/dL", "0.003 × PaO2 (mmHg)"],
["Bound to haemoglobin", "~19.7 mL/dL", "1.34 mL O2/g Hb × [Hb] g/dL × SaO2"],
["Total O2 content (CaO2)", "~20 mL/dL", "CaO2 = (1.34 × Hb × SaO2) + (0.003 × PaO2)"],
["O2 delivery (DO2)", "~1000 mL/min", "DO2 = CaO2 × CO × 10; CO ≈ 5 L/min"],
],
[4*cm, 3.5*cm, 9.5*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>Oxyhaemoglobin Dissociation Curve (ODC)</b>", h2))
story.append(bp("Sigmoidal shape due to cooperative binding of O2 to Hb (4 subunits)"))
story.append(bp("P50 = PO2 at 50% Hb saturation; normal P50 ≈ 27 mmHg"))
story.append(bp("<b>Right shift</b> (↑P50, ↓O2 affinity, promotes O2 unloading to tissues): ↑temp, ↑H+ (↓pH), ↑PCO2, ↑2,3-DPG"))
story.append(bp("<b>Left shift</b> (↓P50, ↑O2 affinity, impairs tissue O2 delivery): ↓temp, ↓H+ (↑pH), ↓PCO2, ↓2,3-DPG, fetal Hb (HbF), CO poisoning, metHb"))
story.append(bp("Bohr effect: CO2/H+ directly shift the curve rightward, facilitating O2 release at metabolically active tissues"))
story.append(sp(8))
story.append(Paragraph("<b>CO2 Transport</b>", h2))
story.append(make_table(
["Form", "% of Total CO2", "Mechanism"],
[
["Dissolved in plasma", "~5%", "CO2 + H2O ⇌ H2CO3 ⇌ H+ + HCO3− (slow in plasma)"],
["As bicarbonate (HCO3−)", "~70%", "RBC carbonic anhydrase rapidly converts CO2 → HCO3−; HCO3− exits RBC (chloride shift)"],
["Carbaminohaemoglobin", "~23%", "CO2 binds directly to amino groups of Hb; deoxyHb binds more CO2 (Haldane effect)"],
],
[4*cm, 3*cm, 10*cm]
))
story.append(sp(4))
story.append(info_box("Haldane Effect",
["Deoxygenated haemoglobin (in tissues) binds more CO2 than oxygenated Hb. "
"This facilitates CO2 uptake at tissues and release at the lungs, where oxygenation of Hb "
"displaces CO2 for exhalation."],
bg=LBLUE, border=BLUE))
story.append(PageBreak())
# ── SECTION 8: CONTROL OF BREATHING ──────────────────────────────────────
story.append(section_banner("8. CONTROL OF BREATHING", colors.HexColor("#7C3AED")))
story.append(sp(8))
story.append(Paragraph("<b>Central Respiratory Centers</b>", h2))
story.append(make_table(
["Center", "Location", "Function"],
[
["Dorsal Respiratory Group (DRG)", "Medulla (NTS)", "Sets basic inspiratory rhythm; active during quiet breathing"],
["Ventral Respiratory Group (VRG)", "Medulla", "Active during forced/strenuous breathing; drives expiration"],
["Pneumotaxic Center", "Pons (parabrachial nucleus)", "Switches off inspiration; fine-tunes respiratory rate"],
["Apneustic Center", "Lower pons", "Prolongs inspiration; opposed by pneumotaxic center"],
],
[4.5*cm, 4.5*cm, 8*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>Chemoreceptors</b>", h2))
story.append(make_table(
["Type", "Location", "Stimulus", "Mechanism"],
[
["Central chemoreceptors", "Ventral medulla", "↑CO2 (↑H+ in CSF)", "CO2 crosses BBB → ↓CSF pH → ↑ventilation; primary driver of breathing"],
["Peripheral chemoreceptors", "Carotid bodies (main), aortic bodies", "↓PaO2 (<60 mmHg), ↑PaCO2, ↓pH", "Glomus type I cells → CN IX (carotid) / X (aortic) → medulla → ↑ventilation"],
],
[4*cm, 3.5*cm, 3.5*cm, 6*cm]
))
story.append(sp(6))
story.append(info_box("Hypoxic Drive & CO2 Retention",
["In COPD patients with chronic CO2 retention, central chemoreceptors become blunted to high CO2. "
"These patients rely on peripheral O2-mediated 'hypoxic drive'. Administering high-flow O2 can suppress "
"this drive and worsen CO2 retention → use controlled O2 therapy (target SpO2 88–92%)."],
bg=LRED, border=RED))
story.append(sp(6))
story.append(Paragraph("<b>Other Respiratory Reflexes</b>", h2))
story.append(bp("<b>Hering-Breuer reflex</b>: lung stretch receptors in airway smooth muscle; inhibit inspiration "
"when lungs over-inflated (important in newborns; minimal role in adults)"))
story.append(bp("<b>J-receptors (juxtacapillary)</b>: stimulated by pulmonary oedema, emboli, irritants → rapid shallow breathing, dyspnoea"))
story.append(bp("<b>Irritant receptors</b>: bronchial epithelium; triggered by dust, smoke, cold air → cough, bronchoconstriction"))
story.append(bp("<b>Carotid sinus reflex</b>: baroreceptors can modulate respiratory rate (e.g., hypertension → bradypnoea)"))
story.append(PageBreak())
# ── SECTION 9: V/Q RELATIONSHIPS ─────────────────────────────────────────
story.append(section_banner("9. VENTILATION-PERFUSION (V/Q) RELATIONSHIPS", TEAL))
story.append(sp(8))
story.append(p("The V/Q ratio describes the matching between alveolar ventilation and pulmonary blood flow. "
"Ideal V/Q = 1.0 (perfectly matched). Deviations cause hypoxaemia."))
story.append(sp(6))
story.append(make_table(
["V/Q Value", "Condition", "Cause", "Effect on Gas Exchange"],
[
["V/Q = 1.0 (normal)", "Ideal matching", "—", "Normal PaO2 and PaCO2"],
["V/Q = 0 (shunt)", "Perfusion without ventilation", "Atelectasis, pneumonia, ARDS", "↓PaO2; PaCO2 normal/↓; does NOT correct with 100% O2"],
["V/Q = ∞ (dead space)","Ventilation without perfusion","Pulmonary embolism, Zone 1", "↑VD/VT; ↑PaCO2 if unable to compensate"],
["V/Q mismatch (low)", "Low V/Q regions", "COPD, asthma, mucus plugging", "Main cause of hypoxaemia in COPD; corrects partially with supplemental O2"],
],
[3.5*cm, 3.5*cm, 4.5*cm, 6.5*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>Vertical Gradient of V/Q in Upright Lung</b>", h2))
story.append(bp("Apex: V/Q ≈ 3.3 (relatively over-ventilated) → higher PAO2, lower PACO2"))
story.append(bp("Base: V/Q ≈ 0.6 (relatively under-ventilated) → lower PAO2, higher PACO2"))
story.append(bp("Perfusion increases ~5× from apex to base; ventilation increases ~1.5× apex to base"))
story.append(bp("HPV partially compensates V/Q mismatch by reducing flow to poorly-ventilated areas"))
story.append(sp(4))
story.append(info_box("V/Q Scan",
["A ventilation-perfusion (V/Q) lung scan is the primary imaging tool for diagnosing pulmonary embolism "
"when CT pulmonary angiography is contraindicated. A high-probability scan (unmatched perfusion defect) "
"has ~85% specificity for PE."],
bg=LBLUE, border=BLUE))
story.append(PageBreak())
# ── SECTION 10: COMMON RESPIRATORY DISEASES ──────────────────────────────
story.append(section_banner("10. COMMON RESPIRATORY DISEASES", NAVY))
story.append(sp(8))
story.append(make_table(
["Disease", "Mechanism", "Key Features", "Spirometry"],
[
["Asthma", "Reversible airway obstruction, eosinophilic inflammation, bronchospasm",
"Wheeze, dyspnoea, cough; diurnal variation; triggers (allergens, cold, exercise)",
"Obstructive; FEV1/FVC <0.70; reversible >12% with bronchodilator"],
["COPD", "Emphysema + chronic bronchitis; irreversible; smoking most common cause",
"'Blue bloater' (bronchitis) vs 'pink puffer' (emphysema); productive cough; cor pulmonale",
"Obstructive; FEV1/FVC <0.70; not fully reversible"],
["Pulmonary Fibrosis (ILD)", "Alveolar damage → fibrosis; ↓compliance; ↓DLCO",
"Progressive dyspnoea, dry cough, bibasal crackles, clubbing",
"Restrictive; FVC ↓; FEV1/FVC ≥0.70; ↓DLCO"],
["Pneumonia", "Infection (bacterial, viral, fungal) → alveolar consolidation",
"Fever, productive cough, consolidation on CXR, ↑WCC",
"Usually normal or mild restriction"],
["Pulmonary Embolism", "Venous thrombus occludes pulmonary artery → ↑dead space, ↓perfusion",
"Sudden dyspnoea, pleuritic chest pain, tachycardia; hypoxaemia",
"Normal (acute)"],
["Pneumothorax", "Air in pleural space → lung collapse",
"Sudden chest pain, ↓breath sounds; tension type is life-threatening",
"Reduced volumes"],
["Pleural Effusion", "Fluid in pleural space (transudate/exudate)",
"Dull percussion, ↓breath sounds; Light's criteria to distinguish",
"Restrictive pattern"],
["ARDS", "Diffuse alveolar damage → non-cardiogenic pulmonary oedema; ↓compliance",
"Bilateral infiltrates, PaO2/FiO2 <300; Berlin criteria",
"Restrictive; ↓DLCO"],
],
[3*cm, 4*cm, 5*cm, 5*cm]
))
story.append(PageBreak())
# ── SECTION 11: KEY CLINICAL PARAMETERS ──────────────────────────────────
story.append(section_banner("11. KEY CLINICAL PARAMETERS & REFERENCE VALUES", TEAL))
story.append(sp(8))
story.append(Paragraph("<b>Arterial Blood Gas (ABG) Reference Ranges</b>", h2))
story.append(make_table(
["Parameter", "Normal Range", "Clinical Significance"],
[
["pH", "7.35 – 7.45", "< 7.35 = acidaemia; > 7.45 = alkalaemia"],
["PaO2", "80 – 100 mmHg", "< 60 mmHg = hypoxaemia requiring treatment"],
["PaCO2", "35 – 45 mmHg", "< 35 = hyperventilation; > 45 = hypoventilation/CO2 retention"],
["HCO3−", "22 – 26 mEq/L", "Metabolic component of acid-base balance"],
["SaO2", "95 – 100%", "< 90% = clinically significant desaturation"],
["A-a gradient","5 – 15 mmHg", "Elevated in V/Q mismatch, diffusion limitation, shunt"],
["P/F ratio", "> 400 (normal)", "PaO2/FiO2; < 300 = ARDS; < 200 = moderate; < 100 = severe ARDS"],
],
[3.5*cm, 3.5*cm, 10*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>ABG Interpretation Framework</b>", h2))
story.append(bp("Step 1: Check pH → acidaemia (<7.35) or alkalaemia (>7.45)?"))
story.append(bp("Step 2: Check PaCO2 → respiratory component: ↑CO2 = respiratory acidosis; ↓CO2 = respiratory alkalosis"))
story.append(bp("Step 3: Check HCO3− → metabolic component: ↓HCO3− = metabolic acidosis; ↑HCO3− = metabolic alkalosis"))
story.append(bp("Step 4: Check for compensation (partial or complete)"))
story.append(bp("Step 5: Calculate A-a gradient and P/F ratio to assess oxygenation"))
story.append(sp(8))
story.append(Paragraph("<b>Respiratory Compensation Rules</b>", h2))
story.append(make_table(
["Primary Disorder", "Expected Compensation"],
[
["Metabolic acidosis", "PaCO2 = 1.5 × HCO3− + 8 ± 2 (Winter's formula); or ↓PaCO2 by 1.2 per 1 mEq ↓HCO3−"],
["Metabolic alkalosis", "↑PaCO2 by 0.7 per 1 mEq ↑HCO3−; max PaCO2 ~55 mmHg"],
["Acute resp. acidosis", "↑HCO3− by 1 per 10 mmHg ↑PaCO2"],
["Chronic resp. acidosis","↑HCO3− by 3.5 per 10 mmHg ↑PaCO2"],
["Acute resp. alkalosis", "↓HCO3− by 2 per 10 mmHg ↓PaCO2"],
["Chronic resp. alkalosis","↓HCO3− by 5 per 10 mmHg ↓PaCO2"],
],
[5.5*cm, 11.5*cm]
))
story.append(sp(8))
story.append(Paragraph("<b>Summary of Key Equations</b>", h2))
story.append(info_box("Quick-Reference Equations",
["Alveolar gas equation: PAO2 = FiO2(Patm – PH2O) – PaCO2/RQ",
"Minute ventilation: VE = VT × f",
"Alveolar ventilation: VA = (VT – VD) × f",
"O2 content: CaO2 = (1.34 × Hb × SaO2) + (0.003 × PaO2)",
"O2 delivery: DO2 = CaO2 × CO × 10",
"Compliance: C = ΔV / ΔP",
"Bohr equation: VD/VT = (PaCO2 – PECO2) / PaCO2",
"Henderson-Hasselbalch: pH = 6.1 + log([HCO3−] / 0.03 × PaCO2)"],
bg=LGREEN, border=GREEN))
story.append(sp(8))
story.append(hr())
story.append(Paragraph(
"<i>Sources: Murray & Nadel's Textbook of Respiratory Medicine (6e), Guyton & Hall Textbook of Medical Physiology (14e), "
"Medical Physiology (Boron & Boulpaep). Notes compiled by Orris Medical Library — for educational use.</i>",
S("Footer", fontSize=8, textColor=colors.HexColor("#9CA3AF"), fontName="Helvetica-Oblique",
alignment=TA_CENTER, leading=11)))
# ── Build ──────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF created: {OUTPUT}")
cd /home/daytona/workspace/respiratory-notes && python build_pdf.py 2>&1
ls -lh /home/daytona/workspace/respiratory-notes/Respiratory_System_Notes.pdf
Respiratory System Notes
PDF Document · PDF
| # | Section | Highlights |
|---|---|---|
| 1 | Overview & Anatomy | Weibel model (23 airway generations), conducting vs respiratory zones, alveolar architecture, lung lobes |
| 2 | Lung Volumes & Capacities | Full table with TV, IRV, ERV, RV, TLC, VC, FRC, FEV1, FVC + obstructive vs restrictive patterns |
| 3 | Mechanics of Breathing | Compliance, airway resistance (Poiseuille's Law), work of breathing, surfactant and Laplace's Law |
| 4 | Ventilation & Dead Space | Minute ventilation, alveolar ventilation, Bohr equation, alveolar gas equation with worked values |
| 5 | Pulmonary Circulation | Pulmonary vs systemic pressures, hypoxic pulmonary vasoconstriction (HPV), West's Zones 1-3 |
| 6 | Gas Exchange & Diffusion | Fick's Law, DLCO, causes of hypoxaemia table (shunt vs V/Q mismatch vs diffusion) |
| 7 | O2 & CO2 Transport | O2 content formula, oxyhaemoglobin dissociation curve (right/left shifts, Bohr effect), CO2 transport forms, Haldane effect |
| 8 | Control of Breathing | Medullary/pontine centers, central vs peripheral chemoreceptors, hypoxic drive in COPD |
| 9 | V/Q Relationships | V/Q = 0 (shunt) vs V/Q = ∞ (dead space), vertical V/Q gradient in upright lung |
| 10 | Common Diseases | Asthma, COPD, ILD, pneumonia, PE, pneumothorax, pleural effusion, ARDS |
| 11 | Clinical Reference | ABG normal ranges, ABG interpretation framework, compensation rules, key equations quick-reference |