Give me detailed hand written notes of heart from the pdf and also make the notes as such that i should not have a need to read the text book like the notes should be enough by itself also use the same language as in pdf text just make the language a bit humanoid

Reading File
Running Command

cd /tmp/workspace/attachments/84456406-a77b-46e7-8de9-32732c14485d && python3 -c " import pdfplumber with pdfplumber.open('Heart.pdf') as pdf: print(f'Total pages: {len(pdf.pages)}') # Extract first few pages to see structure for i, page in enumerate(pdf.pages[:3]): print(f'\n--- PAGE {i+1} ---') text = page.extract_text() if text: print(text[:2000]) else: print('[No text extracted]') "

Running Command

cd /tmp/workspace/attachments/84456406-a77b-46e7-8de9-32732c14485d && python3 -c " import pdfplumber with pdfplumber.open('Heart.pdf') as pdf: full_text = '' for i, page in enumerate(pdf.pages): text = page.extract_text() if text: full_text += f'\n\n=== PAGE {i+1} ===\n' + text print(full_text) " > /tmp/workspace/heart_raw.txt 2>&1 echo "Done. File size: $(wc -c < /tmp/workspace/heart_raw.txt) bytes" wc -l /tmp/workspace/heart_raw.txt

Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

ls /tmp/workspace/ && mkdir -p /tmp/workspace/heart-notes

Writing File

~/heart-notes/generate_notes.py


from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.lib import colors
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.pdfgen import canvas
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate

# ─── Colour palette ───────────────────────────────────────────────────────────
BG_CREAM    = colors.HexColor("#FDFAF3")   # paper background
INK_DARK    = colors.HexColor("#1A1A2E")   # main text
INK_BLUE    = colors.HexColor("#1B4F72")   # headings / section titles
INK_RED     = colors.HexColor("#A93226")   # H1 / important labels
INK_ORANGE  = colors.HexColor("#CA6F1E")   # sub-headings
INK_GREEN   = colors.HexColor("#1E8449")   # clinical anatomy boxes
RULE_COLOR  = colors.HexColor("#BDC3C7")   # horizontal rules
BOX_BG      = colors.HexColor("#EAF4FB")   # clinical note background
BOX_BG_G    = colors.HexColor("#EAFAF1")   # green box
BOX_BORDER  = colors.HexColor("#2980B9")
BOX_BORDER_G= colors.HexColor("#1E8449")
HIGHLIGHT   = colors.HexColor("#FDEBD0")   # orange highlight

# ─── Page layout ──────────────────────────────────────────────────────────────
PAGE_W, PAGE_H = A4
MARGIN_L = 2.2*cm;  MARGIN_R = 1.8*cm
MARGIN_T = 2.0*cm;  MARGIN_B = 2.0*cm
CONTENT_W = PAGE_W - MARGIN_L - MARGIN_R

def bg_canvas(c, doc):
    """Draw cream background on every page."""
    c.saveState()
    c.setFillColor(BG_CREAM)
    c.rect(0, 0, PAGE_W, PAGE_H, fill=1, stroke=0)
    # left ruled margin line
    c.setStrokeColor(colors.HexColor("#F1948A"))
    c.setLineWidth(0.8)
    c.line(MARGIN_L - 0.5*cm, 0, MARGIN_L - 0.5*cm, PAGE_H)
    # page number
    c.setFont("Helvetica", 8)
    c.setFillColor(colors.HexColor("#7F8C8D"))
    c.drawCentredString(PAGE_W/2, 1.2*cm, f"Heart & Pericardium — Study Notes  |  Page {doc.page}")
    c.restoreState()

# ─── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, **kw)

H1 = S("H1",
    fontName="Helvetica-Bold", fontSize=18, textColor=INK_RED,
    spaceAfter=4, spaceBefore=14, leading=22,
    borderPad=4, borderColor=INK_RED, borderWidth=0,
    leftIndent=0)

H2 = S("H2",
    fontName="Helvetica-Bold", fontSize=13, textColor=INK_BLUE,
    spaceAfter=3, spaceBefore=10, leading=17,
    leftIndent=0)

H3 = S("H3",
    fontName="Helvetica-Bold", fontSize=11, textColor=INK_ORANGE,
    spaceAfter=2, spaceBefore=7, leading=15,
    leftIndent=0)

H4 = S("H4",
    fontName="Helvetica-BoldOblique", fontSize=10, textColor=INK_GREEN,
    spaceAfter=2, spaceBefore=5, leading=14,
    leftIndent=8)

BODY = S("BODY",
    fontName="Helvetica", fontSize=9.5, textColor=INK_DARK,
    spaceAfter=3, spaceBefore=1, leading=14,
    leftIndent=0, alignment=TA_JUSTIFY)

BULLET = S("BULLET",
    fontName="Helvetica", fontSize=9.5, textColor=INK_DARK,
    spaceAfter=2, spaceBefore=1, leading=13,
    leftIndent=14, bulletIndent=4, alignment=TA_JUSTIFY)

SUBBULLET = S("SUBBULLET",
    fontName="Helvetica", fontSize=9, textColor=INK_DARK,
    spaceAfter=1, spaceBefore=0, leading=12,
    leftIndent=28, bulletIndent=16)

CLINICAL = S("CLINICAL",
    fontName="Helvetica", fontSize=9, textColor=colors.HexColor("#1B4F72"),
    spaceAfter=2, spaceBefore=2, leading=13,
    leftIndent=6, alignment=TA_JUSTIFY)

MNEMONIC = S("MNEMONIC",
    fontName="Helvetica-BoldOblique", fontSize=9.5,
    textColor=colors.HexColor("#6C3483"),
    spaceAfter=2, spaceBefore=2, leading=13,
    leftIndent=6)

NOTE_LABEL = S("NOTE_LABEL",
    fontName="Helvetica-Bold", fontSize=9, textColor=INK_RED,
    spaceAfter=1, spaceBefore=0, leading=12)

# ─── Helper builders ──────────────────────────────────────────────────────────
def hr(color=RULE_COLOR, thickness=0.5):
    return HRFlowable(width="100%", thickness=thickness, color=color, spaceAfter=4, spaceBefore=4)

def sp(h=4):
    return Spacer(1, h)

def h1(text):  return Paragraph(text, H1)
def h2(text):  return Paragraph(text, H2)
def h3(text):  return Paragraph(text, H3)
def h4(text):  return Paragraph(text, H4)
def body(text): return Paragraph(text, BODY)
def bull(text): return Paragraph(f"• {text}", BULLET)
def sbull(text):return Paragraph(f"   ◦ {text}", SUBBULLET)
def clin(text): return Paragraph(text, CLINICAL)
def mnemo(text):return Paragraph(text, MNEMONIC)
def note(label, text):
    return Paragraph(f"<b>{label}:</b> {text}", CLINICAL)

def clinical_box(items, title="CLINICAL ANATOMY", bg=BOX_BG, border=BOX_BORDER):
    """Coloured box for clinical notes."""
    content = [Paragraph(f"<b>{title}</b>", NOTE_LABEL)]
    for item in items:
        content.append(Paragraph(f"• {item}", CLINICAL))
    t = Table([[content]], colWidths=[CONTENT_W])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0), (-1,-1), bg),
        ("BOX",          (0,0), (-1,-1), 1.2, border),
        ("LEFTPADDING",  (0,0), (-1,-1), 8),
        ("RIGHTPADDING", (0,0), (-1,-1), 8),
        ("TOPPADDING",   (0,0), (-1,-1), 6),
        ("BOTTOMPADDING",(0,0), (-1,-1), 6),
        ("ROWBACKGROUNDS",(0,0),(-1,-1),[bg]),
    ]))
    return t

def highlight_box(text, bg=HIGHLIGHT, border=INK_ORANGE):
    t = Table([[Paragraph(text, MNEMONIC)]], colWidths=[CONTENT_W])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), bg),
        ("BOX",          (0,0),(-1,-1), 1, border),
        ("LEFTPADDING",  (0,0),(-1,-1), 8),
        ("RIGHTPADDING", (0,0),(-1,-1), 8),
        ("TOPPADDING",   (0,0),(-1,-1), 5),
        ("BOTTOMPADDING",(0,0),(-1,-1), 5),
    ]))
    return t

def two_col_table(rows, col_headers=None, w1=None, w2=None):
    if w1 is None: w1 = CONTENT_W * 0.45
    if w2 is None: w2 = CONTENT_W - w1
    data = []
    if col_headers:
        data.append([Paragraph(f"<b>{col_headers[0]}</b>", H4),
                     Paragraph(f"<b>{col_headers[1]}</b>", H4)])
    for r in rows:
        data.append([Paragraph(r[0], CLINICAL), Paragraph(r[1], CLINICAL)])
    t = Table(data, colWidths=[w1, w2])
    style = [
        ("BACKGROUND",   (0,0),(-1,0),  colors.HexColor("#D6EAF8")),
        ("BACKGROUND",   (0,1),(-1,-1), BG_CREAM),
        ("BOX",          (0,0),(-1,-1), 0.8, INK_BLUE),
        ("INNERGRID",    (0,0),(-1,-1), 0.4, RULE_COLOR),
        ("LEFTPADDING",  (0,0),(-1,-1), 6),
        ("RIGHTPADDING", (0,0),(-1,-1), 6),
        ("TOPPADDING",   (0,0),(-1,-1), 4),
        ("BOTTOMPADDING",(0,0),(-1,-1), 4),
        ("VALIGN",       (0,0),(-1,-1), "TOP"),
    ]
    if col_headers:
        style.append(("BACKGROUND",(0,0),(-1,0), colors.HexColor("#AED6F1")))
    t.setStyle(TableStyle(style))
    return t

# ─── Build Document ───────────────────────────────────────────────────────────
doc = BaseDocTemplate(
    "/tmp/workspace/heart-notes/Heart_Notes.pdf",
    pagesize=A4,
    leftMargin=MARGIN_L, rightMargin=MARGIN_R,
    topMargin=MARGIN_T,  bottomMargin=MARGIN_B,
)
frame = Frame(MARGIN_L, MARGIN_B, CONTENT_W, PAGE_H - MARGIN_T - MARGIN_B, id="main")
doc.addPageTemplates([PageTemplate(id="main", frames=frame, onPage=bg_canvas)])

story = []

# ═══════════════════════════════════════════════════════════════════════════════
#  TITLE PAGE BLOCK
# ═══════════════════════════════════════════════════════════════════════════════
story.append(sp(20))
title_data = [[Paragraph(
    "<b>HEART &amp; PERICARDIUM</b><br/>"
    "<font size=11 color='#1B4F72'>Complete Study Notes — Chapter 18</font>",
    ParagraphStyle("T", fontName="Helvetica-Bold", fontSize=22,
                   textColor=INK_RED, alignment=TA_CENTER, leading=28))]]
t = Table(title_data, colWidths=[CONTENT_W])
t.setStyle(TableStyle([
    ("BACKGROUND",   (0,0),(-1,-1), colors.HexColor("#EBF5FB")),
    ("BOX",          (0,0),(-1,-1), 2, INK_BLUE),
    ("TOPPADDING",   (0,0),(-1,-1), 14),
    ("BOTTOMPADDING",(0,0),(-1,-1), 14),
]))
story.append(t)
story.append(sp(6))
story.append(body(
    "<i>Source: BD Chaurasia's Human Anatomy — Regional &amp; Applied Dissection and Clinical Vol. 1 Thorax, Chapter 18. "
    "These notes preserve the original language of the textbook, made more readable for exam revision.</i>"
))
story.append(hr(INK_BLUE, 1))
story.append(sp(4))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 1: PERICARDIUM
# ═══════════════════════════════════════════════════════════════════════════════
story.append(h1("1. PERICARDIUM"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The pericardium is a fibroserous sac that encloses the heart and the roots of the great vessels. "
    "It occupies the middle mediastinum and is invested by the pleura on either side."
))
story.append(sp(4))

story.append(h2("Layers of Pericardium"))
story.append(two_col_table([
    ["<b>Fibrous pericardium</b>", "Tough outer coat — continuous above with the adventitia of great vessels, below fused to central tendon of diaphragm."],
    ["<b>Serous pericardium — Parietal layer</b>", "Lines the inner surface of fibrous pericardium."],
    ["<b>Serous pericardium — Visceral layer (Epicardium)</b>", "Closely applied to the heart surface; contains coronary vessels and fat."],
    ["<b>Pericardial cavity</b>", "Potential space between parietal and visceral layers; contains a thin film of fluid to reduce friction during cardiac contractions."],
], col_headers=["Layer", "Key Features"]))
story.append(sp(4))

story.append(h2("Sinuses of Pericardium"))
story.append(h3("a) Transverse Sinus"))
story.append(bull("Lies behind the ascending aorta and pulmonary trunk, and in front of the superior vena cava and left atrium."))
story.append(bull("It is a passage between the arterial (aorta + pulmonary trunk) and venous (SVC + pulmonary veins) reflections of the serous pericardium."))
story.append(bull("Surgically important: A ligature can be passed around the aorta and pulmonary trunk together through this sinus to stop the blood flow (used during cardiac surgery)."))

story.append(h3("b) Oblique Sinus"))
story.append(bull("A cul-de-sac (blind-ending pouch) posterior to the left atrium."))
story.append(bull("Boundaries: Right and below — inferior vena cava; Above and left — lower left pulmonary vein."))
story.append(bull("Surgical relevance: Fluid/blood may collect here; it is the most dependent part during surgery."))
story.append(sp(4))

story.append(h2("Nerve Supply of Pericardium"))
story.append(bull("Fibrous pericardium + parietal serous: Phrenic nerve (C3, C4, C5) — pain sensitive."))
story.append(bull("Visceral layer (epicardium): Autonomic nerves — pain insensitive."))
story.append(sp(4))

story.append(clinical_box([
    "Pericarditis: Inflammation of pericardium produces retrosternal pain (pericardial pain). Pain is referred to the tip of the shoulder since pericardium is supplied by the phrenic nerve (C3, C4, C5) — same as the skin over the shoulder tip.",
    "Pericardial effusion: Excess fluid in the pericardial cavity. Compresses cardiac chambers during diastole → reduces cardiac output.",
    "Cardiac tamponade: Large pericardial effusion compresses the heart, severely reducing cardiac output. Emergency: requires pericardiocentesis.",
    "Pericardiocentesis: Needle inserted between the xiphoid and the left costal margin at 45° angled towards left shoulder. This avoids the pleura and the coronary arteries.",
    "In mitral stenosis: Left atrium enlarges → compresses the oesophagus → causes dysphagia.",
], title="★ CLINICAL ANATOMY — PERICARDIUM"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 2: HEART — OVERVIEW
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("2. THE HEART — OVERVIEW"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The heart is a conical hollow muscular organ situated in the middle mediastinum. "
    "It is enclosed within the pericardium. "
    "<b>Greek name:</b> cardia → adjective <i>cardiac</i>. "
    "<b>Latin name:</b> cor → adjective <i>coronary</i>."
))
story.append(sp(4))

story.append(h2("Basic Facts"))
story.append(two_col_table([
    ["Shape",   "Conical / pyramidal"],
    ["Length",  "12 cm (base to apex)"],
    ["Width",   "8–9 cm (broadest transverse diameter)"],
    ["Weight",  "300 g (adult male); 250 g (adult female)"],
    ["Position","Obliquely behind the body of the sternum and costal cartilages. 1/3rd lies to the right, 2/3rd to the left of the median plane."],
    ["Chambers","Four: right and left atria (upper); right and left ventricles (lower)"],
], col_headers=["Feature", "Details"]))
story.append(sp(4))

story.append(h2("External Features — Apex"))
story.append(bull("Directed downwards, forwards, and to the left."))
story.append(bull("Lies in the left 5th intercostal space, 9 cm from the midsternal line (in adults)."))
story.append(bull("Corresponds to the inferior angle of the left ventricle."))
story.append(bull("In children below 2 years: apex is in left 4th intercostal space in midclavicular line."))
story.append(bull("Apex beat (cardiac impulse) is felt here normally."))
story.append(sp(4))

story.append(h2("Surfaces of the Heart"))
story.append(two_col_table([
    ["<b>Sternocostal (Anterior)</b>",
     "Mainly right ventricle. Also partly right atrium (right side), left ventricle (left side), and left auricle (left upper corner)."],
    ["<b>Inferior (Diaphragmatic)</b>",
     "Mainly left ventricle (2/3rd) and right ventricle (1/3rd). Rests on central tendon and left part of diaphragm."],
    ["<b>Base (Posterior)</b>",
     "Mainly left atrium + small part of right atrium. Faces T5–T8 vertebrae. Receives pulmonary veins (into left atrium) and venae cavae (into right atrium)."],
    ["<b>Left pulmonary</b>",
     "Left ventricle + left atrium. Related to left lung and pleura. Produces cardiac notch in left lung."],
    ["<b>Right pulmonary</b>",
     "Right atrium. Related to right lung and pleura."],
], col_headers=["Surface", "Composition & Relations"]))
story.append(sp(4))

story.append(h2("Borders of the Heart"))
story.append(bull("<b>Right border:</b> Right atrium, between right 3rd costal cartilage and right 6th costal cartilage (convex, vertical)."))
story.append(bull("<b>Left border:</b> Mainly left ventricle + left auricle (uppermost), between left 2nd costal cartilage and apex."))
story.append(bull("<b>Superior border:</b> Right and left atria + auricles. Behind the sternal angle."))
story.append(bull("<b>Inferior border:</b> Right ventricle (main) + small part of left ventricle near apex. Almost horizontal."))
story.append(sp(4))

story.append(h2("Grooves (Sulci) of the Heart"))
story.append(h3("1. Atrioventricular (Coronary) Sulcus"))
story.append(bull("Separates atria from ventricles all around the heart."))
story.append(bull("<b>Right part (oblique):</b> between right auricle and right ventricle — lodges right coronary artery."))
story.append(bull("<b>Left part (small):</b> between left auricle and left ventricle — lodges circumflex branch of left coronary artery."))
story.append(bull("<b>Posterior part:</b> between base and diaphragmatic surface — lodges coronary sinus."))

story.append(h3("2. Interatrial Groove"))
story.append(bull("Faintly visible posteriorly; anteriorly hidden by aorta and pulmonary trunk."))

story.append(h3("3. Anterior Interventricular Groove"))
story.append(bull("Nearer to the left margin of the heart. Runs downwards and to the left."))
story.append(bull("Lower end separates the apex from the inferior border."))
story.append(bull("Lodges anterior interventricular artery (LAD) + great cardiac vein."))

story.append(h3("4. Posterior Interventricular Groove"))
story.append(bull("On the diaphragmatic surface. Nearer to the right margin."))
story.append(bull("Lodges posterior interventricular artery + middle cardiac vein."))
story.append(bull("Both interventricular grooves meet at the inferior border near the apex."))

story.append(sp(4))
story.append(highlight_box(
    "★ CRUX OF THE HEART = meeting point of interatrial groove + atrioventricular groove + posterior interventricular groove."
))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 3: RIGHT ATRIUM
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("3. RIGHT ATRIUM"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The right atrium is the right upper chamber. It receives venous blood from the whole body and "
    "pumps it to the right ventricle through the tricuspid orifice. "
    "It forms the right border, part of the upper border, the sternocostal surface, and the base of the heart."
))
story.append(sp(4))

story.append(h2("External Features"))
story.append(bull("Elongated vertically: SVC opens at upper end, IVC at lower end."))
story.append(bull("<b>Right auricle:</b> upper end prolonged to the left; covers root of ascending aorta; margins are notched; interior is sponge-like (prevents free blood flow)."))
story.append(bull("<b>Sulcus terminalis:</b> shallow vertical groove on right border, from SVC to IVC. Internally corresponds to crista terminalis."))
story.append(bull("<b>SA node</b> sits in the upper part of the sulcus terminalis — acts as the pacemaker."))
story.append(bull("<b>Right atrioventricular groove:</b> separates right atrium from right ventricle; lodges right coronary artery + small cardiac vein."))
story.append(sp(4))

story.append(h2("Tributaries (Inlets) of the Right Atrium"))
story.append(bull("Superior vena cava"))
story.append(bull("Inferior vena cava"))
story.append(bull("Coronary sinus"))
story.append(bull("Anterior cardiac veins"))
story.append(bull("Venae cordis minimae (Thebesian veins)"))
story.append(bull("Sometimes: right marginal vein"))
story.append(sp(4))

story.append(h2("Interior of the Right Atrium"))
story.append(body("Divided into three parts:"))
story.append(sp(2))

story.append(h3("1. Smooth Posterior Part — Sinus Venarum"))
story.append(bull("Developmentally derived from right horn of sinus venosus."))
story.append(bull("Most tributaries (except anterior cardiac veins) open here."))
story.append(bull("SVC opens at upper end; IVC opens at lower end."))
story.append(bull("<b>Valve of IVC (Eustachian valve):</b> rudimentary semilunar fold at the IVC opening. In fetal life, directs oxygenated blood from IVC → left atrium through foramen ovale."))
story.append(bull("<b>Valve of coronary sinus (Thebesian valve):</b> small semilunar fold at coronary sinus opening; prevents regurgitation."))
story.append(sp(3))

story.append(h3("2. Pectinate Part (Trabeculated)"))
story.append(bull("Muscular ridges (pectinate muscles / musculi pectinati) on walls."))
story.append(bull("Developmentally derived from right horn of primitive atrium."))
story.append(bull("Crista terminalis (internal ridge) separates smooth and pectinate parts."))
story.append(sp(3))

story.append(h3("3. Interatrial Septum"))
story.append(bull("<b>Fossa ovalis:</b> oval depression in the lower part of the interatrial septum — remnant of foramen ovale. Bounded above by limbus fossa ovalis (annulus ovalis)."))
story.append(bull("<b>Triangle of Koch:</b> Bounded by — (a) tendon of Todaro (above), (b) attachment of septal cusp of tricuspid valve (below), (c) opening of coronary sinus (apex)."))
story.append(bull("AV node lies at the apex of Triangle of Koch."))
story.append(sp(4))

story.append(h3("Right Atrioventricular (Tricuspid) Orifice"))
story.append(bull("Blood passes out of right atrium through the tricuspid orifice into right ventricle."))
story.append(bull("Guarded by tricuspid valve — maintains unidirectional blood flow."))
story.append(sp(4))

story.append(clinical_box([
    "Probe patency of foramen ovale: Present in about 25% of adults — a probe can be passed from right to left through the fossa ovalis. This is normally clinically silent but can cause paradoxical embolism.",
    "Atrial Septal Defect (ASD): Occurs when the foramen ovale fails to close at birth → left-to-right shunt → volume overload of right heart.",
    "AV node location in Triangle of Koch is vital in cardiac surgery — injury during mitral valve repair can cause complete heart block.",
    "Pacemaker leads: Right atrium acts as entry point; the SA node territory and right ventricle are sites for electrode placement.",
], title="★ CLINICAL ANATOMY — RIGHT ATRIUM"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 4: RIGHT VENTRICLE
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("4. RIGHT VENTRICLE"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The right ventricle receives deoxygenated blood from the right atrium and pumps it into the pulmonary trunk. "
    "It forms most of the sternocostal surface, a part of the inferior surface, and the left border of the heart."
))
story.append(sp(4))

story.append(h2("Interior of the Right Ventricle"))
story.append(h3("1. Inlet Part"))
story.append(bull("Receives blood from right atrium through the tricuspid orifice."))
story.append(bull("Has trabeculated walls (trabeculae carneae)."))
story.append(bull("<b>Trabeculae carneae types:</b> (a) Ridge-like, (b) Bridge-like, (c) Papillary muscles."))
story.append(bull("<b>Three papillary muscles:</b> anterior (largest), posterior, septal (smallest). Each has chordae tendineae attached to cusps of tricuspid valve."))
story.append(bull("<b>Septomarginal trabecula (Moderator band):</b> thick muscular band crosses from the interventricular septum to the anterior papillary muscle. Carries right bundle branch of the conducting system."))
story.append(sp(3))

story.append(h3("2. Outlet Part — Infundibulum (Conus Arteriosus)"))
story.append(bull("Smooth-walled funnel-shaped part leading to pulmonary orifice."))
story.append(bull("Separated from inlet part by the supraventricular crest (crista supraventricularis)."))
story.append(bull("Leads to the pulmonary valve and pulmonary trunk."))
story.append(sp(4))

story.append(h2("Interventricular Septum"))
story.append(bull("Separates right from left ventricle. Mostly muscular."))
story.append(bull("<b>Muscular part:</b> large lower portion."))
story.append(bull("<b>Membranous part:</b> small upper portion — most common site of Ventricular Septal Defect (VSD)."))
story.append(sp(4))

story.append(clinical_box([
    "VSD (Ventricular Septal Defect): Most common congenital heart defect. Left-to-right shunt, as left ventricular pressure > right.",
    "Tetralogy of Fallot: (1) Large VSD, (2) Pulmonary stenosis, (3) Overriding aorta, (4) Right ventricular hypertrophy. Results in right-to-left shunt → cyanosis (blue baby).",
    "Moderator band importance: Carries right bundle branch; surgical division causes right bundle branch block.",
], title="★ CLINICAL ANATOMY — RIGHT VENTRICLE"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 5: LEFT ATRIUM
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("5. LEFT ATRIUM"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The left atrium receives oxygenated blood from the lungs through four pulmonary veins and pumps it "
    "into the left ventricle through the mitral orifice."
))
story.append(sp(4))

story.append(h2("Position"))
story.append(bull("Forms the base (posterior surface) of the heart."))
story.append(bull("Most posterior chamber — lies in front of T5–T8 vertebrae."))
story.append(bull("Separated from oesophagus by pericardium — enlargement → dysphagia."))
story.append(bull("Anterior wall forms the posterior wall of the oblique sinus of the pericardium."))
story.append(sp(4))

story.append(h2("External Features"))
story.append(bull("<b>Left auricle:</b> projects to the left and overlaps the root of pulmonary trunk. Margins are notched."))
story.append(bull("Four pulmonary veins (two right, two left) open into its posterior wall."))
story.append(sp(4))

story.append(h2("Interior of Left Atrium"))
story.append(bull("Walls are smooth (unlike right atrium)."))
story.append(bull("Pectinate muscles confined only to the left auricle."))
story.append(bull("<b>Interatrial septum:</b> shows a crescentic ridge (the valve of foramen ovale) — corresponds to fossa ovalis of right atrium."))
story.append(bull("<b>Left atrioventricular (Mitral) orifice:</b> guarded by mitral (bicuspid) valve; opens into left ventricle."))
story.append(sp(4))

story.append(clinical_box([
    "Mitral stenosis: Narrowing of the mitral valve → back-pressure → left atrial enlargement. Enlarged left atrium compresses: (a) Oesophagus → dysphagia; (b) Recurrent laryngeal nerve → hoarseness of voice (Ortner's syndrome).",
    "Atrial fibrillation: Most common in left atrium. Stagnant blood in auricle → mural thrombus → systemic embolism → stroke.",
    "Pulmonary venous hypertension from mitral stenosis eventually causes pulmonary arterial hypertension.",
], title="★ CLINICAL ANATOMY — LEFT ATRIUM"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 6: LEFT VENTRICLE
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("6. LEFT VENTRICLE"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The left ventricle receives oxygenated blood from the left atrium and pumps it into the aorta "
    "for systemic circulation."
))
story.append(sp(4))

story.append(h2("Position & Surfaces"))
story.append(bull("Forms the apex, most of the left border, left surface, and left 2/3rd of the diaphragmatic surface."))
story.append(bull("Also forms 1/3rd of the sternocostal surface."))
story.append(sp(4))

story.append(h2("Interior of Left Ventricle"))
story.append(h3("1. Inlet Part"))
story.append(bull("Receives blood from left atrium via mitral valve."))
story.append(bull("<b>Two papillary muscles:</b> anterior and posterior — larger and stronger than in the right ventricle."))
story.append(bull("Walls heavily trabeculated (trabeculae carneae)."))

story.append(h3("2. Outlet Part (Aortic Vestibule)"))
story.append(bull("Smooth-walled. Leads to aortic valve and ascending aorta."))
story.append(bull("Bounded in front by interventricular septum, behind by anterior cusp of mitral valve."))
story.append(sp(4))

story.append(h2("Right vs Left Ventricle — Comparison"))
story.append(two_col_table([
    ["Wall thickness", "Thinner — 1/3rd of left ventricle", "Much thicker — 3× the right ventricle"],
    ["Function",       "Pushes blood only to lungs (low pressure circuit)", "Pushes blood to entire body (high pressure circuit)"],
    ["Papillary muscles", "Three — small", "Two — strong and large"],
    ["Cavity shape",   "Crescentic", "Circular"],
    ["Blood content",  "Deoxygenated", "Oxygenated"],
    ["Surfaces",       "2/3rd sternocostal + 1/3rd diaphragmatic", "1/3rd sternocostal + 2/3rd diaphragmatic"],
], col_headers=["Feature", "Right Ventricle", "Left Ventricle"], w1=CONTENT_W*0.28, w2=CONTENT_W*0.36))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 7: VALVES OF THE HEART
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("7. VALVES OF THE HEART"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "Valves maintain unidirectional blood flow and prevent regurgitation. There are two pairs:"
))
story.append(bull("<b>Pair 1 — Atrioventricular (AV) valves:</b> Right AV (tricuspid) and Left AV (bicuspid/mitral)."))
story.append(bull("<b>Pair 2 — Semilunar valves:</b> Aortic valve and Pulmonary valve."))
story.append(body("The cusps are folds of endocardium strengthened by an intervening layer of fibrous tissue."))
story.append(sp(4))

story.append(h2("A. Atrioventricular (AV) Valves"))
story.append(h3("Components of Both AV Valves"))
story.append(bull("<b>Fibrous ring:</b> cusps attached to a fibrous ring (annulus fibrosus)."))
story.append(bull("<b>Cusps:</b> flat flaps projecting into ventricles; composed of fibrous tissue covered by endocardium."))
story.append(bull("<b>Chordae tendineae:</b> strong tendinous cords that attach free margin of cusps to papillary muscles; prevent prolapse."))
story.append(bull("<b>Papillary muscles:</b> cone-shaped muscular projections from ventricular wall; their contraction tenses the chordae tendineae."))
story.append(sp(3))

story.append(h3("Tricuspid Valve (Right AV Valve)"))
story.append(bull("Has <b>3 cusps</b>: anterior (largest), posterior, septal."))
story.append(bull("Septal cusp is attached to the membranous part of IVS."))
story.append(bull("During ventricular systole — cusps are pushed up, margins meet → valve closes → prevents backflow into right atrium."))
story.append(sp(3))

story.append(h3("Mitral (Bicuspid) Valve — Left AV Valve"))
story.append(bull("Has <b>2 cusps</b>: anterior (larger, aortic) and posterior (mural/smaller)."))
story.append(bull("Anterior cusp partially separates inlet from outlet of left ventricle."))
story.append(bull("Two papillary muscles correspond to the two commissures of the valve."))
story.append(sp(4))

story.append(h2("B. Semilunar Valves (Aortic & Pulmonary)"))
story.append(bull("Each has <b>3 semilunar cusps</b>: right, left, and posterior (aortic) / anterior (pulmonary)."))
story.append(bull("<b>Aortic valve cusps:</b> right coronary cusp, left coronary cusp, non-coronary (posterior) cusp."))
story.append(bull("<b>Pulmonary valve cusps:</b> right, left, anterior."))
story.append(bull("<b>Nodule of Arantius:</b> fibrous nodule in the centre of free edge of each cusp; ensures perfect closure."))
story.append(bull("<b>Lunula:</b> thin crescentic area on either side of the nodule."))
story.append(bull("<b>Sinus of Valsalva (aortic sinus):</b> dilatation behind each cusp of aortic valve. Right and left coronary arteries arise from right and left aortic sinuses respectively."))
story.append(sp(4))

story.append(h2("Auscultatory Areas (Where Valves are Heard Best)"))
story.append(two_col_table([
    ["Mitral valve",    "Apex — left 5th ICS, midclavicular line"],
    ["Tricuspid valve", "Lower left sternal border / xiphisternal junction"],
    ["Aortic valve",    "Right 2nd ICS (right sternal border)"],
    ["Pulmonary valve", "Left 2nd ICS (left sternal border)"],
], col_headers=["Valve", "Auscultatory Area"]))
story.append(sp(4))

story.append(clinical_box([
    "Rheumatic heart disease: Most commonly affects the mitral valve → mitral stenosis or mitral regurgitation.",
    "Mitral valve prolapse: Posterior cusp bulges into the left atrium during systole → regurgitation.",
    "Aortic stenosis: Calcification/hardening of aortic valve cusps; common in elderly → left ventricular hypertrophy.",
    "Artificial (prosthetic) valves: Mechanical or bioprosthetic valves are used to replace damaged valves.",
    "Coronary artery origin: Right and left coronary arteries arise from sinuses of Valsalva. This keeps the orifices open even when aortic valve is closed (during diastole — when coronary flow is maximum).",
], title="★ CLINICAL ANATOMY — VALVES"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 8: STRUCTURE OF HEART WALL
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("8. STRUCTURE OF THE HEART WALL"))
story.append(hr(INK_RED, 1.2))

story.append(h2("Layers (from outside to inside)"))
story.append(two_col_table([
    ["<b>Epicardium</b>",   "Visceral layer of serous pericardium. Contains coronary vessels, nerve plexuses, and adipose tissue."],
    ["<b>Myocardium</b>",   "Middle layer — cardiac muscle. Thickest in left ventricle (bears greatest workload). Composed of cardiac muscle fibres arranged in spiral/figure-8 sheets (Figs. of Rushmer). The muscle is involuntary and striated."],
    ["<b>Endocardium</b>",  "Inner lining of heart chambers. Continuous with tunica intima of great vessels. Smooth to reduce friction of blood. Forms the cusps of valves (with fibrous tissue support)."],
], col_headers=["Layer", "Details"]))
story.append(sp(4))

story.append(h2("Fibrous Skeleton of the Heart"))
story.append(bull("Four fibrous rings (annuli fibrosi) around the four valvular orifices."))
story.append(bull("Two fibrous trigones (right and left) — areas of dense fibrous tissue between the rings."))
story.append(bull("Functions: Provides attachments for cardiac muscle fibres and valve cusps; electrically insulates atria from ventricles (except at the AV bundle)."))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 9: CONDUCTING SYSTEM
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("9. CONDUCTING SYSTEM OF THE HEART"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The conducting system consists of specialised cardiac muscle fibres that initiate and conduct the electrical "
    "impulse for rhythmic contraction of the heart."
))
story.append(sp(4))

story.append(h2("Components (in Order of Impulse Conduction)"))
story.append(two_col_table([
    ["<b>Sinuatrial (SA) Node</b>",
     "Pacemaker of the heart (generates impulse at 70/min). Located in upper part of sulcus terminalis at the junction of SVC and right atrium. Blood supply: SA nodal artery from right coronary artery (60%) or circumflex branch of left coronary artery (40%)."],
    ["<b>Atrioventricular (AV) Node</b>",
     "Located at apex of Triangle of Koch, in the interatrial septum. Rate of intrinsic firing: 40–60/min (secondary pacemaker). Delays impulse briefly to allow atrial contraction to complete before ventricular contraction begins."],
    ["<b>Bundle of His (AV Bundle)</b>",
     "Passes from AV node through the fibrous skeleton; runs along the upper border of the membranous IVS. Then divides into right and left bundle branches."],
    ["<b>Right Bundle Branch</b>",
     "Travels in the septomarginal trabecula (moderator band) to the anterior papillary muscle of right ventricle."],
    ["<b>Left Bundle Branch</b>",
     "Divides into anterior and posterior fascicles. Supplies left ventricle."],
    ["<b>Purkinje Fibres</b>",
     "Terminal fibres from both bundle branches; spread throughout ventricular myocardium in the subendocardial plexus. Rate: 20–40/min."],
], col_headers=["Component", "Key Details"]))
story.append(sp(4))

story.append(highlight_box(
    "★ Impulse pathway: SA node → Atrial muscle → AV node (slight delay) → Bundle of His → Right & Left bundle branches → Purkinje fibres → Ventricular myocardium"
))
story.append(sp(4))

story.append(clinical_box([
    "Cardiac arrhythmias: Defects/damage to conducting system → abnormal heart rhythms (arrhythmias). Vascular lesions are common cause.",
    "Heart block: Loss of blood supply to AV node or Bundle of His → ventricles dissociated from SA node. Atria contract at 70/min (SA node), ventricles at 25–30/min (ventricular escape). Treatment: artificial pacemaker.",
    "Artificial cardiac pacemaker: Small device (wristwatch size) placed in the chest to control heartbeat. Has a pulse generator with battery, wire, and electrode to stimulate ventricles. Useful in arrhythmias and heart block.",
    "CPR (Cardiopulmonary Resuscitation): In cardiac arrest — apply pressure on sternum at 100–120/min, depth 2 inches. Increased pressure pushes blood out of heart; decreasing pressure helps venous return.",
    "SA node artery from right coronary artery (60%) — right coronary occlusion can cause sinus node dysfunction.",
], title="★ CLINICAL ANATOMY — CONDUCTING SYSTEM"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 10: CORONARY ARTERIES
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("10. CORONARY ARTERIES"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The heart is supplied by two coronary arteries — right and left — arising from the ascending aorta "
    "from the right and left aortic sinuses of Valsalva respectively. "
    "Both run in the coronary sulcus (atrioventricular groove)."
))
story.append(sp(4))

story.append(h2("General Features of Coronary Arteries"))
story.append(bull("Blood flows during <b>diastole</b> (not systole) — myocardial contraction compresses intramyocardial vessels during systole."))
story.append(bull("They are functionally <b>end arteries</b> — no significant anastomoses → occlusion causes infarction."))
story.append(bull("They are the first branches of the aorta."))
story.append(sp(4))

story.append(h2("A. Right Coronary Artery (RCA)"))
story.append(h3("Origin & Course"))
story.append(bull("Arises from the right aortic sinus (anterior aortic sinus) of the ascending aorta."))
story.append(bull("Passes between the right auricle and the pulmonary trunk."))
story.append(bull("Descends in the right part of the atrioventricular groove."))
story.append(bull("Turns posteriorly in the right posterior coronary sulcus → reaches the crux of the heart."))
story.append(bull("Terminates by anastomosing with the circumflex branch of LCA at the crux (in 60% = right dominant)."))
story.append(sp(3))

story.append(h3("Branches of RCA"))
story.append(bull("<b>Atrial branches:</b> anterior, posterior, lateral. <b>SA nodal artery</b> = one of the anterior atrial branches (arises from RCA in 60% cases; from LCA circumflex in 40%)."))
story.append(bull("<b>Right conus artery:</b> forms annulus of Vieussens (arterial circle around pulmonary trunk) with a similar branch from LCA."))
story.append(bull("<b>Ventricular branches:</b> anterior group (sternocostal surface) and posterior group (diaphragmatic surface)."))
story.append(bull("<b>Right marginal artery:</b> arises as RCA crosses the right border; runs along inferior border to the apex."))
story.append(bull("<b>Posterior interventricular branch (PDA):</b> arises near the crux; runs in posterior interventricular groove. Gives: (a) septal branches (posteroinferior 1/3rd IVS); (b) AV nodal artery (branch to AV node in 80–90% cases)."))
story.append(sp(4))

story.append(h2("B. Left Coronary Artery (LCA)"))
story.append(h3("Origin & Course"))
story.append(bull("Arises from the left aortic sinus (left posterior sinus) of the ascending aorta."))
story.append(bull("Passes between the left auricle and pulmonary trunk."))
story.append(bull("Divides almost immediately into two main branches — <b>LAD</b> and <b>Circumflex</b>."))
story.append(sp(3))

story.append(h3("Branches of LCA"))
story.append(bull("<b>Left anterior descending (LAD) / Anterior interventricular artery:</b>"))
story.append(sbull("Runs in anterior interventricular groove."))
story.append(sbull("Gives diagonal branches (to left ventricle), septal perforators (anterosuperior 2/3rd of IVS), right conus artery."))
story.append(sbull("Reaches apex → may curl around to anastomose with posterior interventricular branch."))
story.append(bull("<b>Circumflex artery:</b>"))
story.append(sbull("Runs in the left atrioventricular groove (left part of coronary sulcus)."))
story.append(sbull("Gives SA nodal artery in 40% of cases."))
story.append(sbull("Gives left marginal artery — runs along left border."))
story.append(sbull("In left dominant (40%): circumflex gives posterior interventricular branch and AV nodal artery."))
story.append(sp(4))

story.append(h2("Coronary Dominance"))
story.append(two_col_table([
    ["Right dominant (60%)", "RCA gives posterior interventricular artery + AV nodal artery"],
    ["Left dominant (15%)",  "Circumflex gives posterior interventricular artery + AV nodal artery"],
    ["Co-dominant (25%)",    "Both arteries share the posterior supply"],
], col_headers=["Dominance Type", "Significance"]))
story.append(sp(4))

story.append(h2("Areas Supplied"))
story.append(two_col_table([
    ["Right coronary artery",
     "Right atrium, SA node (60%), AV node (80–90%), right ventricle, posteroinferior 1/3rd of IVS, posteroinferior left ventricle"],
    ["Left coronary artery (LAD)",
     "Left ventricle (anterior wall), anterosuperior 2/3rd of IVS (septal perforators), right ventricle (anterior part)"],
    ["Circumflex artery",
     "Left atrium, SA node (40%), left ventricle (lateral and posterior), left marginal region"],
], col_headers=["Artery", "Territory Supplied"]))
story.append(sp(4))

story.append(clinical_box([
    "Coronary atherosclerosis: Most common cause of IHD. Plaque formation → luminal narrowing → ischaemia.",
    "Angina pectoris: Transient myocardial ischaemia (15 sec–15 min), insufficient to cause necrosis. Heavy/tight/gripping retrosternal pain. Pain also referred to left shoulder and medial side of left arm and forearm. Stable angina = begins on exertion; Unstable angina = at rest, >20 min. Relieved by sublingual sorbitrate (nitrate).",
    "Myocardial infarction (Heart attack): Sudden occlusion of coronary branch → complete loss of blood supply → infarction → necrosis. Symptoms: prolonged angina (>30 min), nausea/vomiting, SOB, sweating.",
    "Commonly occluded vessels: LAD (40–50%) > RCA (30–40%) > Circumflex (15–20%).",
    "Coronary angiography: Determines site of narrowing/occlusion.",
    "Angioplasty: Removal of small blockage using stent/balloon via catheter (femoral artery → aorta → coronary artery).",
    "CABG (Coronary Artery Bypass Grafting): For large/multiple blockages. Graft = great saphenous vein or internal thoracic artery.",
    "Sudden occlusion of LAD = massive anterior MI. Occlusion of RCA = inferior MI + risk of AV block.",
], title="★ CLINICAL ANATOMY — CORONARY ARTERIES", bg=colors.HexColor("#FEF9E7"), border=colors.HexColor("#F39C12")))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 11: VEINS OF THE HEART
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("11. VEINS OF THE HEART"))
story.append(hr(INK_RED, 1.2))

story.append(h2("Main Venous Drainage"))
story.append(two_col_table([
    ["<b>Great cardiac vein</b>",
     "Begins at apex → runs in anterior interventricular groove → turns left in left AV groove → opens into left end of coronary sinus."],
    ["<b>Middle cardiac vein</b>",
     "Begins at apex → runs in posterior interventricular groove → opens into right end of coronary sinus."],
    ["<b>Small cardiac vein</b>",
     "Accompanies RCA in right posterior coronary sulcus → joins right end of coronary sinus."],
    ["<b>Posterior vein of left ventricle</b>",
     "Runs on diaphragmatic surface of left ventricle → ends in coronary sinus."],
    ["<b>Oblique vein of left atrium (Marshall)</b>",
     "Remnant of left superior vena cava (embryological). Opens into left end of coronary sinus."],
    ["<b>Anterior cardiac veins</b>",
     "Two or three small veins on the sternocostal surface of right ventricle → open directly into right atrium (NOT into coronary sinus)."],
    ["<b>Venae cordis minimae (Thebesian veins)</b>",
     "Tiny veins in walls of all chambers → open directly into all chambers (mainly right atrium and right ventricle)."],
], col_headers=["Vein", "Course & Drainage"]))
story.append(sp(4))

story.append(h2("Coronary Sinus"))
story.append(bull("Main venous channel of the heart. About 3 cm long."))
story.append(bull("Lies in the posterior part of the atrioventricular groove (between left atrium and left ventricle)."))
story.append(bull("Opens into the right atrium between the IVC opening and the tricuspid valve."))
story.append(bull("Opening is guarded by the Thebesian valve (valve of coronary sinus)."))
story.append(bull("Developmentally: remnant of the left horn of sinus venosus."))
story.append(sp(4))

story.append(clinical_box([
    "Coronary sinus catheterisation: Used for retrograde cardioplegia during cardiac surgery — cardioplegic solution delivered into coronary sinus to protect the heart during bypass.",
    "Cardiac resynchronisation therapy (CRT): A special pacemaker lead is placed in a lateral cardiac vein (tributary of coronary sinus) to pace the left ventricle.",
    "Oblique vein of Marshall (Marshall's vein): Site of origin of some arrhythmias (e.g. atrial fibrillation); targeted in ablation procedures.",
], title="★ CLINICAL ANATOMY — CORONARY SINUS & VEINS"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 12: NERVE SUPPLY OF THE HEART
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("12. NERVE SUPPLY OF THE HEART"))
story.append(hr(INK_RED, 1.2))

story.append(body(
    "The heart is supplied by autonomic nerves (both sympathetic and parasympathetic), which form the cardiac plexus."
))
story.append(sp(4))

story.append(h2("Cardiac Plexus"))
story.append(bull("Located at the bifurcation of the trachea, in front of the oesophagus."))
story.append(bull("Divided into: superficial cardiac plexus (below aortic arch) and deep cardiac plexus (behind aortic arch)."))
story.append(sp(3))

story.append(h2("Sympathetic Supply"))
story.append(bull("Preganglionic: Lateral horn of T1–T5 spinal cord segments."))
story.append(bull("Postganglionic: From superior, middle, and inferior cervical ganglia (superior, middle, inferior cervical cardiac nerves) and from upper 4–5 thoracic ganglia (thoracic cardiac branches)."))
story.append(bull("<b>Effects:</b> Increases heart rate (chronotropic), increases force of contraction (inotropic), dilates coronary arteries."))
story.append(sp(3))

story.append(h2("Parasympathetic Supply"))
story.append(bull("Preganglionic: From dorsal motor nucleus of vagus (CN X)."))
story.append(bull("Fibres travel via superior and inferior cervical cardiac branches of vagus and thoracic cardiac branches of vagus."))
story.append(bull("<b>Effects:</b> Decreases heart rate, decreases conduction velocity (especially at AV node), constricts coronary arteries."))
story.append(sp(4))

story.append(h2("Afferent (Sensory) Fibres"))
story.append(bull("Pain fibres from the heart travel with <b>sympathetic nerves</b> → enter spinal cord at T1–T5."))
story.append(bull("This explains referred pain of cardiac ischaemia to the chest, left shoulder, and medial aspect of left arm (dermatomes T1–T5)."))
story.append(bull("Vagal afferents: conduct reflex signals (e.g. Bezold-Jarisch reflex) — NOT pain."))
story.append(sp(4))

story.append(clinical_box([
    "Referred pain in angina/MI: Pain from ischaemic myocardium is referred to chest wall, left shoulder, and medial aspect of left arm and forearm — because the sensory fibres from the heart reach T1–T5 segments (same as those areas of skin).",
    "Coronary vasospasm (Prinzmetal angina): Excessive sympathetic stimulation → coronary artery spasm → angina at rest.",
    "Vasovagal syncope: Excessive vagal tone → sudden drop in heart rate and BP → transient loss of consciousness (fainting).",
], title="★ CLINICAL ANATOMY — NERVE SUPPLY"))
story.append(sp(6))

# ═══════════════════════════════════════════════════════════════════════════════
#  SECTION 13: APPLIED / SUMMARY TABLE
# ═══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
story.append(h1("13. QUICK-REVISION SUMMARY TABLE"))
story.append(hr(INK_RED, 1.2))

story.append(h2("Key Facts at a Glance"))
story.append(two_col_table([
    ["Heart weight",            "300 g (male), 250 g (female)"],
    ["Heart size",              "Own fist"],
    ["Location",                "Middle mediastinum, 1/3 right + 2/3 left of median plane"],
    ["Apex",                    "Left 5th ICS, 9 cm from midsternal line"],
    ["Base",                    "Posterior surface — mainly left atrium; T5–T8 level"],
    ["SA node location",        "Upper sulcus terminalis, junction of SVC + right atrium"],
    ["AV node location",        "Apex of Triangle of Koch (interatrial septum)"],
    ["Bundle of His",           "Along upper border of membranous IVS"],
    ["Moderator band",          "Carries right bundle branch; from IVS to anterior papillary muscle"],
    ["Coronary sinus",          "Posterior AV groove, drains into right atrium; Thebesian valve at opening"],
    ["SA nodal artery",         "RCA (60%); circumflex LCA (40%)"],
    ["AV nodal artery",         "RCA / posterior interventricular branch (80–90%)"],
    ["LAD most common MI",      "40–50% of coronary occlusions"],
    ["Fossa ovalis",            "Interatrial septum; remnant of foramen ovale"],
    ["Tricuspid valve cusps",   "3 — anterior, posterior, septal"],
    ["Mitral valve cusps",      "2 — anterior (aortic), posterior (mural)"],
    ["Semilunar cusps each",    "3 — aortic: R coronary, L coronary, non-coronary; pulmonary: R, L, anterior"],
    ["Blood flow in coronaries","During diastole"],
    ["Pericardiocentesis site", "Between xiphoid and left costal margin — 45° toward left shoulder"],
    ["CPR rate",                "100–120 compressions/min, depth 2 inches"],
], col_headers=["Topic", "Key Fact"]))
story.append(sp(8))

story.append(hr(INK_BLUE, 1.2))
story.append(Paragraph(
    "<i>End of Chapter 18 — Heart &amp; Pericardium Notes. "
    "All content sourced directly from BD Chaurasia's Human Anatomy, Chapter 18.</i>",
    ParagraphStyle("footer", fontName="Helvetica-Oblique", fontSize=8.5,
                   textColor=colors.HexColor("#7F8C8D"), alignment=TA_CENTER)
))

# ─── Build ────────────────────────────────────────────────────────────────────
doc.build(story)
print("PDF created successfully!")
Running Command

cd /tmp/workspace/heart-notes && python3 generate_notes.py 2>&1

Running Command

ls -lh /tmp/workspace/heart-notes/Heart_Notes.pdf

Your notes PDF is ready! Here's what's inside:

Heart Notes

PDF Document · PDF


What's covered in these notes (all 13 sections):

SectionTopic
1Pericardium — layers, transverse & oblique sinuses, nerve supply
2Heart overview — dimensions, position, surfaces, borders, grooves
3Right Atrium — external features, tributaries, interior (sinus venarum, pectinate part, fossa ovalis, Triangle of Koch)
4Right Ventricle — inlet, infundibulum, moderator band, IVS
5Left Atrium — position, interior, relations
6Left Ventricle — surfaces, inlet vs outlet, comparison table with RV
7Valves — AV valves (tricuspid + mitral), semilunar valves, auscultatory areas
8Heart Wall — epicardium, myocardium, endocardium, fibrous skeleton
9Conducting System — SA node, AV node, Bundle of His, bundle branches, Purkinje fibres
10Coronary Arteries — RCA & LCA in full detail, branches, dominance, supply areas
11Veins of the Heart — coronary sinus, great/middle/small cardiac veins
12Nerve Supply — sympathetic, parasympathetic, referred pain pathway
13Quick-revision summary table

Design features used to mimic handwritten notes:
  • Cream/ruled paper background with a red left-margin line
  • Color-coded headings (red H1, blue H2, orange H3, green H4)
  • Highlighted "★ CLINICAL ANATOMY" boxes in blue and yellow
  • Color-coded comparison tables for RV vs LV, coronary dominance, valves, etc.
  • Orange-highlighted mnemonic/pathway boxes
  • All language is taken directly from the BD Chaurasia textbook, just made more readable
This is a shared conversation. Sign in to Orris to start your own chat.