Give me ecg class for pg student in ppt for PR interval and it’s disease and qrs and it’s disease

Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/ecg-class && ls /home/daytona/workspace/ecg-cla…

Writing File

~/ecg-class/ecg_class.js

const pptxgen = require("pptxgenjs");
const pres = new pptxgen();

pres.layout = "LAYOUT_16x9";
pres.title = "ECG for PG Students: PR Interval & QRS Complex";
pres.author = "Medical Teaching";

// ─── COLOUR PALETTE ──────────────────────────────────────────────────────────
const C = {
  bg:       "0D1B2A",   // deep navy – dominant
  bgLight:  "132338",   // slightly lighter navy for content slides
  accent1:  "E63946",   // bold red (ECG trace colour / headlines)
  accent2:  "F4A261",   // amber / warm highlight
  accent3:  "2EC4B6",   // teal / normal values
  white:    "FFFFFF",
  grey:     "B0C4D8",   // light blue-grey body text
  tableH:   "1B3A5C",   // table header
  tableR1:  "112233",
  tableR2:  "0D1B2A",
  green:    "4CAF50",
  yellow:   "FFC107",
  orange:   "FF7043",
  red:      "EF5350",
};

// ─── HELPERS ─────────────────────────────────────────────────────────────────
function addSlideBase(bg = C.bg) {
  const sl = pres.addSlide();
  sl.background = { color: bg };
  return sl;
}

function sectionDivider(title, subtitle) {
  const sl = addSlideBase(C.accent1);
  sl.addText(title, {
    x: 0.5, y: 1.8, w: 9, h: 1.4,
    fontSize: 40, bold: true, color: C.white,
    align: "center", fontFace: "Calibri"
  });
  if (subtitle) {
    sl.addText(subtitle, {
      x: 0.5, y: 3.4, w: 9, h: 0.8,
      fontSize: 22, color: C.white, align: "center",
      italic: true, fontFace: "Calibri"
    });
  }
  return sl;
}

function contentSlide(title, bullets, opts = {}) {
  const sl = addSlideBase(C.bgLight);
  // Title bar
  sl.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 }
  });
  sl.addText(title, {
    x: 0.2, y: 0, w: 9.6, h: 0.75,
    fontSize: 22, bold: true, color: C.white,
    valign: "middle", fontFace: "Calibri", margin: 0
  });

  const items = bullets.map((b, i) => {
    if (typeof b === "string") {
      return { text: b, options: { bullet: { indent: 10 }, breakLine: true, fontSize: 17, color: C.grey, fontFace: "Calibri" } };
    }
    // {text, sub, color}
    if (b.sub) {
      return [
        { text: b.text, options: { bullet: { indent: 10 }, breakLine: true, fontSize: 17, color: b.color || C.white, bold: b.bold || false, fontFace: "Calibri" } },
        { text: "    " + b.sub, options: { bullet: false, breakLine: true, fontSize: 14, color: C.grey, italic: true, fontFace: "Calibri" } }
      ];
    }
    return { text: b.text, options: { bullet: { indent: 10 }, breakLine: true, fontSize: b.size || 17, color: b.color || C.white, bold: b.bold || false, fontFace: "Calibri" } };
  }).flat();

  sl.addText(items, {
    x: opts.x || 0.3, y: opts.y || 0.9,
    w: opts.w || 9.4, h: opts.h || 4.6,
    valign: "top", fontFace: "Calibri"
  });
  return sl;
}

function keyValueSlide(title, rows) {
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText(title, {
    x: 0.2, y: 0, w: 9.6, h: 0.75,
    fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = rows.map((r, i) => [
    { text: r[0], options: { bold: true, color: C.accent2, fontSize: 15, fontFace: "Calibri" } },
    { text: r[1], options: { color: C.white, fontSize: 15, fontFace: "Calibri" } }
  ]);

  sl.addTable(tableData, {
    x: 0.4, y: 0.9, w: 9.2, h: 4.5,
    colW: [3.2, 6.0],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.52
  });
  return sl;
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 1 – TITLE
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bg);
  // Decorative ECG line
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.25, h: 5.625, fill: { color: C.accent1 } });
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 5.2, w: 10, h: 0.425, fill: { color: C.accent1 } });

  sl.addText("ECG for PG Students", {
    x: 0.6, y: 0.6, w: 9, h: 1.0,
    fontSize: 38, bold: true, color: C.white, fontFace: "Calibri"
  });
  sl.addText("PR Interval  |  QRS Complex", {
    x: 0.6, y: 1.7, w: 9, h: 0.8,
    fontSize: 28, color: C.accent2, fontFace: "Calibri", italic: true
  });
  sl.addText("Anatomy · Normal Values · Pathology · Clinical Pearls", {
    x: 0.6, y: 2.6, w: 9, h: 0.6,
    fontSize: 18, color: C.grey, fontFace: "Calibri"
  });
  sl.addShape(pres.ShapeType.line, {
    x: 0.6, y: 3.4, w: 8.8, h: 0,
    line: { color: C.accent1, width: 1.5 }
  });
  sl.addText([
    { text: "Sources: ", options: { bold: true, color: C.accent2 } },
    { text: "Goldman-Cecil Medicine • Braunwald's Heart Disease • Fuster & Hurst's The Heart", options: { color: C.grey } }
  ], { x: 0.6, y: 3.6, w: 9, h: 0.5, fontSize: 13, fontFace: "Calibri" });
  sl.addText("PG Teaching Series  •  July 2026", {
    x: 0.6, y: 4.8, w: 9, h: 0.4, fontSize: 13, color: C.grey, fontFace: "Calibri"
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 2 – Overview of ECG intervals
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("ECG Overview: Key Intervals at a Glance", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Interval", options: { bold: true, color: C.accent2, fontSize: 15, fill: { color: C.tableH }, fontFace: "Calibri" } },
      { text: "Represents", options: { bold: true, color: C.accent2, fontSize: 15, fill: { color: C.tableH }, fontFace: "Calibri" } },
      { text: "Normal Range", options: { bold: true, color: C.accent2, fontSize: 15, fill: { color: C.tableH }, fontFace: "Calibri" } },
      { text: "Abnormality", options: { bold: true, color: C.accent2, fontSize: 15, fill: { color: C.tableH }, fontFace: "Calibri" } }
    ],
    [
      { text: "PR interval", options: { color: C.white, fontSize: 14, fontFace: "Calibri" } },
      { text: "AV nodal conduction time (P wave onset → QRS onset)", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } },
      { text: "120–200 ms (3–5 small squares)", options: { color: C.accent3, fontSize: 13, fontFace: "Calibri" } },
      { text: ">200 ms = AV block  |  <120 ms = pre-excitation", options: { color: C.accent2, fontSize: 13, fontFace: "Calibri" } }
    ],
    [
      { text: "QRS complex", options: { color: C.white, fontSize: 14, fontFace: "Calibri" } },
      { text: "Ventricular depolarisation", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } },
      { text: "< 120 ms (< 3 small squares)", options: { color: C.accent3, fontSize: 13, fontFace: "Calibri" } },
      { text: "≥ 120 ms = BBB / ventricular rhythm / accessory pathway", options: { color: C.accent2, fontSize: 13, fontFace: "Calibri" } }
    ],
    [
      { text: "QT interval", options: { color: C.white, fontSize: 14, fontFace: "Calibri" } },
      { text: "Ventricular depolarisation + repolarisation", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } },
      { text: "QTc ≤ 440 ms (males) / ≤ 460 ms (females)", options: { color: C.accent3, fontSize: 13, fontFace: "Calibri" } },
      { text: "Prolonged → TdP risk", options: { color: C.accent2, fontSize: 13, fontFace: "Calibri" } }
    ],
    [
      { text: "ST segment", options: { color: C.white, fontSize: 14, fontFace: "Calibri" } },
      { text: "Early ventricular repolarisation", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } },
      { text: "Isoelectric", options: { color: C.accent3, fontSize: 13, fontFace: "Calibri" } },
      { text: "Elevation/depression → ischaemia / pericarditis", options: { color: C.accent2, fontSize: 13, fontFace: "Calibri" } }
    ]
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.85, w: 9.6, h: 4.5,
    colW: [2.0, 2.8, 2.4, 2.4],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.72
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SECTION DIVIDER – PR INTERVAL
// ═══════════════════════════════════════════════════════════════════════════════
sectionDivider("SECTION 1", "PR Interval – Anatomy, Normal Values & Diseases");

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 3 – PR interval: Anatomy & physiology
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("PR Interval: Anatomy & Physiology", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  // Left column: text
  sl.addText([
    { text: "What it measures\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "Time from onset of atrial depolarisation (P wave) to onset of ventricular depolarisation (Q or R wave).\n\n", options: { color: C.grey, fontSize: 15, breakLine: false } },
    { text: "Conduction pathway\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "SA node  →  atrial myocardium  →  AV node (longest delay, ~100 ms)  →  Bundle of His  →  Bundle branches  →  Purkinje fibres\n\n", options: { color: C.grey, fontSize: 14, breakLine: false } },
    { text: "Normal values\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "120–200 ms  (3–5 small squares at 25 mm/s)\n", options: { color: C.accent3, fontSize: 15, bold: true, breakLine: false } },
    { text: "Each small square = 40 ms  |  Each large square = 200 ms\n\n", options: { color: C.grey, fontSize: 13, italic: true, breakLine: false } },
    { text: "Autonomic influences\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "Sympathetic: shortens PR  (increases AV conduction)\nParasympathetic/vagal: prolongs PR  (slows AV conduction)", options: { color: C.grey, fontSize: 14, breakLine: false } },
  ], {
    x: 0.3, y: 0.85, w: 6.2, h: 4.6, valign: "top", fontFace: "Calibri"
  });

  // Right column: highlight box
  sl.addShape(pres.ShapeType.roundRect, {
    x: 6.7, y: 0.9, w: 3.0, h: 4.5, fill: { color: C.tableH }, line: { color: C.accent3, width: 1.5 }
  });
  sl.addText([
    { text: "MEMORY BOX\n\n", options: { bold: true, color: C.accent3, fontSize: 14, breakLine: false } },
    { text: "Short PR  (<120 ms)\n", options: { bold: true, color: C.accent2, fontSize: 13, breakLine: false } },
    { text: "→ WPW / LGL\n→ Junctional rhythm\n\n", options: { color: C.grey, fontSize: 12, breakLine: false } },
    { text: "Normal PR\n", options: { bold: true, color: C.accent3, fontSize: 13, breakLine: false } },
    { text: "120–200 ms\n\n", options: { color: C.white, fontSize: 13, bold: true, breakLine: false } },
    { text: "Long PR  (>200 ms)\n", options: { bold: true, color: C.orange, fontSize: 13, breakLine: false } },
    { text: "→ 1st degree AV block\n→ 2nd degree (Mobitz I/II)\n→ 3rd degree (complete)", options: { color: C.grey, fontSize: 12, breakLine: false } },
  ], {
    x: 6.75, y: 0.95, w: 2.9, h: 4.3, valign: "top", fontFace: "Calibri"
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 4 – AV Block Overview
// ═══════════════════════════════════════════════════════════════════════════════
contentSlide("PR Interval Diseases: AV Conduction Blocks – Overview", [
  { text: "Classification of AV Block (Goldman-Cecil / Braunwald)", bold: true, color: C.accent2 },
  { text: "First-degree AV block  –  prolonged PR (>200 ms), every P conducts", sub: "Usually benign; can progress to higher-degree block in ~50% within 1 year on monitoring" },
  { text: "Second-degree AV block  –  some P waves do not conduct", sub: "Divided into Mobitz Type I (Wenckebach) and Mobitz Type II", color: C.accent2 },
  { text: "High-degree AV block  –  ≥2 consecutive non-conducted P waves", sub: "Frequently persistent; may require pacemaker" },
  { text: "Third-degree (Complete) AV block  –  no P waves conduct; P and QRS completely dissociated", sub: "Atrial rate > ventricular escape rate; may cause syncope/asystole", color: C.orange },
  { text: "General principle: Site of block determines clinical course and pacemaker need", bold: true, color: C.accent3 },
  { text: "AV nodal block → usually narrower QRS, better prognosis", sub: "" },
  { text: "His-Purkinje block → wider QRS, higher risk of asystole, pacemaker often needed", sub: "" },
]);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 5 – 1st degree AV block
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("First-Degree AV Block", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Feature", options: { bold: true, color: C.accent2, fontSize: 14, fill: { color: C.tableH }, fontFace: "Calibri" } },
      { text: "Details", options: { bold: true, color: C.accent2, fontSize: 14, fill: { color: C.tableH }, fontFace: "Calibri" } }
    ],
    [{ text: "Definition", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "PR interval > 200 ms (>5 small squares); every P wave is followed by a QRS — nothing is truly blocked, just delayed", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Site of delay", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Usually the AV node (rarely His-Purkinje)", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Causes", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Increased vagal tone (athletes), inferior MI, rheumatic fever, myocarditis, digoxin / beta-blocker / Ca-channel blocker toxicity, Lyme disease, electrolyte imbalances", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "ECG findings", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Prolonged PR (>200 ms)  |  Constant PR interval  |  All P waves conduct  |  QRS usually narrow", options: { color: C.accent3, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Symptoms", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Usually asymptomatic; rarely palpitations or 'pacemaker syndrome'-like symptoms at very long PR", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Management", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Treat underlying cause; withdraw offending drugs; pacemaker NOT needed; monitor for progression", options: { color: C.accent2, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Pearl", options: { color: C.accent1, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "50% of patients with 1st-degree AVB either have detectable higher-degree block or progress to higher-grade block within ~1 year (Goldman-Cecil)", options: { color: C.accent2, fontSize: 12, italic: true, fontFace: "Calibri" } }],
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.85, w: 9.6, h: 4.55,
    colW: [2.2, 7.4],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.52
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 6 – 2nd degree AV block Mobitz I
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Second-Degree AV Block — Mobitz Type I (Wenckebach)", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 20, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  // Left column
  sl.addText([
    { text: "ECG Pattern\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "• Progressive PR prolongation\n• Greatest increment in PR is the FIRST one\n• RR intervals progressively shorten\n• Dropped QRS (P wave without QRS)\n• PR after the block is the SHORTEST\n• Cyclical pattern (grouped beating)\n\n", options: { color: C.grey, fontSize: 14, breakLine: false } },
    { text: "Site of block\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "Almost always within the AV node (above His bundle)\n\n", options: { color: C.grey, fontSize: 14, breakLine: false } },
    { text: "Causes\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "Inferior MI, increased vagal tone, digoxin/beta-blocker, myocarditis, post-cardiac surgery\n\n", options: { color: C.grey, fontSize: 14, breakLine: false } },
    { text: "Management\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "Usually benign; no pacemaker in asymptomatic patients\nAtropine if symptomatic bradycardia; treat underlying cause", options: { color: C.accent3, fontSize: 14, breakLine: false } },
  ], { x: 0.3, y: 0.85, w: 5.8, h: 4.6, valign: "top", fontFace: "Calibri" });

  // Right column – mnemonic box
  sl.addShape(pres.ShapeType.roundRect, {
    x: 6.4, y: 0.9, w: 3.3, h: 4.5, fill: { color: C.tableH }, line: { color: C.accent2, width: 1.5 }
  });
  sl.addText([
    { text: "WENCKEBACH RULE\n\n", options: { bold: true, color: C.accent2, fontSize: 14, breakLine: false } },
    { text: "Longer, Longer, Longer, DROP\nThen you have a Wenckebach block!\n\n", options: { color: C.white, fontSize: 13, italic: true, breakLine: false } },
    { text: "Key comparisons vs Mobitz II\n\n", options: { bold: true, color: C.accent3, fontSize: 13, breakLine: false } },
    { text: "Mobitz I\n", options: { bold: true, color: C.green, fontSize: 13, breakLine: false } },
    { text: "PR progressively ↑\nSite: AV node\nNarrow QRS\nBetter prognosis\n\n", options: { color: C.grey, fontSize: 12, breakLine: false } },
    { text: "Mobitz II\n", options: { bold: true, color: C.red, fontSize: 13, breakLine: false } },
    { text: "PR constant then drops\nSite: His-Purkinje\nWide QRS (usually)\nHigher risk → PPM", options: { color: C.grey, fontSize: 12, breakLine: false } },
  ], { x: 6.45, y: 0.95, w: 3.2, h: 4.3, valign: "top", fontFace: "Calibri" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 7 – 2nd degree Mobitz II + High-degree
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Second-Degree AV Block — Mobitz Type II  &  High-Degree AV Block", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 19, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Feature", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "Mobitz Type II", options: { bold: true, color: C.orange, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "High-Degree AV Block", options: { bold: true, color: C.red, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } }
    ],
    [
      { text: "PR interval", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
      { text: "Constant, then sudden non-conduction", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "Fixed or variable", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Pattern", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
      { text: "One non-conducted P wave abruptly (no PR prolongation)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "≥2 consecutive non-conducted P waves; e.g. 3:1, 4:1", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "QRS", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
      { text: "Usually wide (bundle branch block present)", options: { color: C.accent2, fontSize: 12, fontFace: "Calibri" } },
      { text: "Wide or narrow depending on escape pacemaker site", options: { color: C.accent2, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Site of block", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
      { text: "Below AV node (His-Purkinje system)", options: { color: C.accent1, fontSize: 12, fontFace: "Calibri" } },
      { text: "Below AV node, often infra-Hisian", options: { color: C.accent1, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Risk", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
      { text: "HIGH – tends to progress to complete block\nAsystole / syncope risk significant", options: { color: C.red, fontSize: 12, fontFace: "Calibri" } },
      { text: "HIGH – frequently recurs; risk of haemodynamic compromise", options: { color: C.red, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Management", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
      { text: "Permanent pacemaker indicated (Class I)\nTemporary pacing if acute", options: { color: C.accent3, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Permanent pacemaker usually required\nTemporary pacing as bridge", options: { color: C.accent3, fontSize: 12, bold: true, fontFace: "Calibri" } }
    ]
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.85, w: 9.6, h: 4.55,
    colW: [2.0, 3.8, 3.8],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.60
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 8 – 3rd degree (complete) AV block
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Third-Degree (Complete) AV Block", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Aspect", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 14, fontFace: "Calibri" } },
      { text: "Description", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 14, fontFace: "Calibri" } }
    ],
    [{ text: "Definition", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Complete AV dissociation — no atrial impulses reach the ventricles; atrial rate > ventricular escape rate", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "ECG features", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Regular P waves (atrial rate 60-100) with NO relationship to QRS | Regular slow escape rhythm | P waves 'march through' QRS | AV dissociation confirmed by varying PR intervals", options: { color: C.accent3, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Escape rhythm", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "AV junctional escape (block in AV node): narrow QRS, rate 40-60 bpm — relatively stable\nVentricular escape (infra-Hisian): wide QRS, rate 20-40 bpm — haemodynamically unstable", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Causes", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Acute MI (inferior MI → AV node; anterior MI → His-Purkinje), degenerative fibrosis (Lenegre/Lev disease), Lyme disease, digoxin toxicity, myocarditis, congenital, post-cardiac surgery", options: { color: C.grey, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Symptoms", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Syncope (Stokes-Adams attacks), presyncope, dizziness, heart failure, angina; asystole may occur", options: { color: C.orange, fontSize: 13, fontFace: "Calibri" } }],
    [{ text: "Management", options: { color: C.white, fontSize: 13, bold: true, fontFace: "Calibri" } },
     { text: "Acute: Atropine (if AV nodal) | Isoprenaline | Transcutaneous pacing | Transvenous temporary pacing\nDefinitive: Permanent pacemaker (Class I indication, especially if symptomatic, escape <40 bpm, infranodal block)", options: { color: C.accent3, fontSize: 13, bold: true, fontFace: "Calibri" } }],
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.85, w: 9.6, h: 4.55,
    colW: [2.2, 7.4],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.56
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 9 – SHORT PR: WPW and LGL
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Short PR Interval: Pre-Excitation Syndromes", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  // Left box – WPW
  sl.addShape(pres.ShapeType.roundRect, { x: 0.2, y: 0.88, w: 4.5, h: 4.55, fill: { color: C.tableH }, line: { color: C.accent2, width: 1.5 } });
  sl.addText([
    { text: "Wolff-Parkinson-White (WPW)\n\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "Pathway: Bundle of Kent (accessory AV pathway)\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "ECG Triad:\n", options: { bold: true, color: C.accent3, fontSize: 14, breakLine: false } },
    { text: "1. Short PR (<120 ms)\n2. Delta wave (slurred QRS upstroke)\n3. Wide QRS (>120 ms)\n\n", options: { color: C.white, fontSize: 13, breakLine: false } },
    { text: "Tachyarrhythmias:\n", options: { bold: true, color: C.orange, fontSize: 14, breakLine: false } },
    { text: "• AVRT (orthodromic – narrow; antidromic – wide)\n• AF with rapid ventricular response → risk of VF\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "Treatment:\n", options: { bold: true, color: C.accent3, fontSize: 14, breakLine: false } },
    { text: "Radiofrequency ablation (curative)\nAvoid digoxin & IV adenosine in AF + WPW!", options: { color: C.accent3, fontSize: 13, breakLine: false } },
  ], { x: 0.35, y: 0.95, w: 4.2, h: 4.3, valign: "top", fontFace: "Calibri" });

  // Right box – LGL
  sl.addShape(pres.ShapeType.roundRect, { x: 5.0, y: 0.88, w: 4.7, h: 4.55, fill: { color: C.tableH }, line: { color: C.accent3, width: 1.5 } });
  sl.addText([
    { text: "Lown-Ganong-Levine (LGL)\n\n", options: { bold: true, color: C.accent3, fontSize: 16, breakLine: false } },
    { text: "Pathway: James fibres (bypasses AV node, connects to His bundle)\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "ECG Features:\n", options: { bold: true, color: C.accent2, fontSize: 14, breakLine: false } },
    { text: "1. Short PR (<120 ms)\n2. NO delta wave\n3. Normal QRS width\n4. History of palpitations / SVT\n\n", options: { color: C.white, fontSize: 13, breakLine: false } },
    { text: "Significance:\n", options: { bold: true, color: C.orange, fontSize: 14, breakLine: false } },
    { text: "Associated with paroxysmal SVT (AVNRT/AVRT)\nSome question whether it is a true syndrome\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "PR in junctional rhythms:\n", options: { bold: true, color: C.accent2, fontSize: 13, breakLine: false } },
    { text: "Retrograde P after QRS, or P buried in QRS (not pre-excitation)", options: { color: C.grey, fontSize: 12, italic: true, breakLine: false } },
  ], { x: 5.15, y: 0.95, w: 4.4, h: 4.3, valign: "top", fontFace: "Calibri" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 10 – PR Pacemaker Indications Summary
// ═══════════════════════════════════════════════════════════════════════════════
contentSlide("Pacemaker Indications for PR/AV Block Diseases (ACC/AHA — Class I)", [
  { text: "3rd-degree AV block: symptomatic bradycardia OR asystole >3 sec OR escape rate <40 bpm", bold: true, color: C.accent2 },
  { text: "3rd-degree AV block in awake patient with infranodal escape rhythm regardless of symptoms", sub: "" },
  { text: "AF with pause ≥5 sec (ventricular standstill)", sub: "", color: C.white },
  { text: "2nd-degree Mobitz II: permanent PPM, especially with wide QRS (high risk of progression)", bold: true, color: C.orange },
  { text: "Advanced 2nd-degree or 3rd-degree AV block post-operative if not expected to resolve", sub: "" },
  { text: "AV block with neuromuscular disease (myotonic dystrophy, Kearns-Sayre, Erb dystrophy)", sub: "", color: C.white },
  { text: "Class IIA: Persistent 3rd-degree AVB with escape >40 bpm (asymptomatic adult, no cardiomegaly)", sub: "" },
  { text: "Class IIA: 1st or 2nd-degree AVB with pacemaker syndrome-like symptoms", sub: "" },
  { text: "1st-degree AVB alone: NOT an indication for pacemaker", bold: true, color: C.accent3 },
]);

// ═══════════════════════════════════════════════════════════════════════════════
// SECTION DIVIDER – QRS
// ═══════════════════════════════════════════════════════════════════════════════
sectionDivider("SECTION 2", "QRS Complex – Anatomy, Normal Values & Diseases");

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 11 – QRS: Anatomy & Physiology
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("QRS Complex: Anatomy & Physiology", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  sl.addText([
    { text: "What it represents\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "Ventricular depolarisation spreading through the ventricular myocardium via the His-Purkinje system.\nBoth ventricles depolarise almost simultaneously producing a narrow QRS.\n\n", options: { color: C.grey, fontSize: 14, breakLine: false } },
    { text: "Normal QRS duration\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "< 120 ms  (< 3 small squares at 25 mm/s)\nNormal axis: −30° to +90°\n\n", options: { color: C.accent3, fontSize: 15, bold: true, breakLine: false } },
    { text: "Components\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "Q wave: initial septal depolarisation (left→right)\nR wave: main ventricular depolarisation\nS wave: basal/posterior ventricular depolarisation\n\n", options: { color: C.grey, fontSize: 14, breakLine: false } },
    { text: "Significance of Width\n", options: { bold: true, color: C.accent2, fontSize: 16, breakLine: false } },
    { text: "Narrow QRS (<120 ms): conduction via His-Purkinje (supraventricular origin)\nWide QRS (≥120 ms): delayed/aberrant conduction → BBB, accessory pathway, ventricular origin", options: { color: C.grey, fontSize: 14, breakLine: false } },
  ], { x: 0.3, y: 0.85, w: 6.0, h: 4.6, valign: "top", fontFace: "Calibri" });

  sl.addShape(pres.ShapeType.roundRect, { x: 6.5, y: 0.9, w: 3.2, h: 4.5, fill: { color: C.tableH }, line: { color: C.accent3, width: 1.5 } });
  sl.addText([
    { text: "NORMAL VALUES\n\n", options: { bold: true, color: C.accent3, fontSize: 14, breakLine: false } },
    { text: "Duration: <120 ms\n", options: { bold: true, color: C.white, fontSize: 13, breakLine: false } },
    { text: "(borderline 110–119 ms)\n\n", options: { color: C.grey, fontSize: 12, italic: true, breakLine: false } },
    { text: "Amplitude:\n", options: { bold: true, color: C.accent2, fontSize: 13, breakLine: false } },
    { text: "LVH: S in V1 + R in V5/V6 > 35 mm\nRVH: R > S in V1\n\n", options: { color: C.grey, fontSize: 12, breakLine: false } },
    { text: "Pathological Q wave:\n", options: { bold: true, color: C.orange, fontSize: 13, breakLine: false } },
    { text: "> 40 ms wide OR\n> 1/4 height of R wave", options: { color: C.grey, fontSize: 12, breakLine: false } },
  ], { x: 6.55, y: 0.95, w: 3.1, h: 4.3, valign: "top", fontFace: "Calibri" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 12 – Bundle Branch Blocks Overview
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Wide QRS Diseases: Bundle Branch Blocks (BBB) — Overview", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 20, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Feature", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 14, fontFace: "Calibri" } },
      { text: "RBBB", options: { bold: true, color: C.accent3, fill: { color: C.tableH }, fontSize: 14, fontFace: "Calibri" } },
      { text: "LBBB", options: { bold: true, color: C.orange, fill: { color: C.tableH }, fontSize: 14, fontFace: "Calibri" } },
      { text: "LAFB / LPFB", options: { bold: true, color: C.grey, fill: { color: C.tableH }, fontSize: 14, fontFace: "Calibri" } }
    ],
    [
      { text: "QRS width", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "≥ 120 ms", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "≥ 120 ms", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "Normal (<120 ms)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "V1 morphology", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "rSR' (M-shaped / bunny ear)\nR' > initial r", options: { color: C.accent3, fontSize: 12, fontFace: "Calibri" } },
      { text: "Broad monophasic S wave or QS pattern", options: { color: C.orange, fontSize: 12, fontFace: "Calibri" } },
      { text: "Not specifically affected", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "V6 morphology", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Wide S wave (S > R)\nSlurred S", options: { color: C.accent3, fontSize: 12, fontFace: "Calibri" } },
      { text: "Broad monophasic R wave; no Q wave; no S wave", options: { color: C.orange, fontSize: 12, fontFace: "Calibri" } },
      { text: "Not specifically affected", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Axis change", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Usually normal or slight RAD", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "Usually LAD", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "LAFB: LAD (−45° to −90°)\nLPFB: RAD (+120° to +180°)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "ST/T changes", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Discordant ST-T (opposite to terminal QRS deflection)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "Discordant ST-T in all leads with R wave; makes ischaemia diagnosis difficult", options: { color: C.orange, fontSize: 12, fontFace: "Calibri" } },
      { text: "N/A", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Clinical significance", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Often benign; pulmonary causes, RHD, congenital; rarely progresses to CHB", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "LBBB + cardiomyopathy: VD dyssynchrony, ↑ mortality; CRT may help", options: { color: C.accent1, fontSize: 12, fontFace: "Calibri" } },
      { text: "Bifascicular block: 6% annual risk of CHB; monitor closely", options: { color: C.accent2, fontSize: 12, fontFace: "Calibri" } }
    ]
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.85, w: 9.6, h: 4.55,
    colW: [1.8, 2.6, 2.6, 2.6],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.54
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 13 – RBBB: Deep-dive
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Right Bundle Branch Block (RBBB) — Deep Dive", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  sl.addText([
    { text: "Pathophysiology\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "Block in the right bundle branch → RV activated late via cell-to-cell spread from LV\nProduces delayed RV depolarisation seen as R' in V1 and S in lateral leads\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "ECG Criteria\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "1. QRS ≥ 120 ms\n2. rSR' in V1 or V2 (M-pattern / 'rabbit ears')\n3. Broad, slurred S in I, aVL, V5, V6 (> 40 ms)\n4. Discordant T wave in V1 (inverted)\n\n", options: { color: C.white, fontSize: 13, breakLine: false } },
    { text: "Incomplete RBBB: QRS 100-119 ms with same morphology\n\n", options: { color: C.grey, fontSize: 12, italic: true, breakLine: false } },
    { text: "Common Causes\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "• Idiopathic (most common)  • Pulmonary embolism (acute cor pulmonale — S1Q3T3)\n• ASD (volume overload of RV)  • RHD  • Myocarditis\n• Myocardial infarction  • TAVI / cardiac surgery  • Normal variant in young\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "Clinical Pearl\n", options: { bold: true, color: C.accent3, fontSize: 15, breakLine: false } },
    { text: "New RBBB + anterior MI = Sgarbossa criteria apply; progression to CHB low for isolated RBBB", options: { color: C.accent3, fontSize: 13, breakLine: false } },
  ], { x: 0.3, y: 0.85, w: 9.4, h: 4.6, valign: "top", fontFace: "Calibri" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 14 – LBBB: Deep-dive
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Left Bundle Branch Block (LBBB) — Deep Dive", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  sl.addText([
    { text: "Pathophysiology\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "Block in main LBB or both fascicles → LV activated late via cell-to-cell spread from RV\nVentricular dyssynchrony — septum and LV free wall don't contract synchronously\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "ECG Criteria\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "1. QRS ≥ 120 ms\n2. Broad monophasic R in I, aVL, V5, V6 (no Q or S)\n3. QS or rS in V1, V2 (broad, deep)\n4. ST-T discordance: ST and T in opposite direction to main QRS deflection\n5. Usually left axis deviation\n\n", options: { color: C.white, fontSize: 13, breakLine: false } },
    { text: "Causes\n", options: { bold: true, color: C.accent2, fontSize: 15, breakLine: false } },
    { text: "• CAD / Acute MI (new LBBB in chest pain = STEMI-equivalent until proven otherwise!)\n• Cardiomyopathy (dilated)  • Hypertensive heart disease  • Aortic stenosis  • Post-TAVI\n• Lenegre-Lev disease (idiopathic fibrosis of conduction system)\n\n", options: { color: C.grey, fontSize: 13, breakLine: false } },
    { text: "LBBB + Cardiomyopathy (Fuster & Hurst)\n", options: { bold: true, color: C.orange, fontSize: 14, breakLine: false } },
    { text: "Significant VD dyssynchrony → worsening HF and ↑ mortality\nCRT (biventricular pacing) improves HF outcomes; some non-ischaemic CMP can normalise LV function (LBBB-induced CMP)\nHis-bundle pacing may correct underlying LBBB", options: { color: C.accent3, fontSize: 13, breakLine: false } },
  ], { x: 0.3, y: 0.85, w: 9.4, h: 4.6, valign: "top", fontFace: "Calibri" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 15 – Fascicular Blocks + Bifascicular / Trifascicular
// ═══════════════════════════════════════════════════════════════════════════════
contentSlide("Fascicular Blocks, Bifascicular & Trifascicular Block", [
  { text: "Left Anterior Fascicular Block (LAFB)", bold: true, color: C.accent2 },
  { text: "QRS <120 ms  |  LAD (−45° to −90°)  |  Small Q in I, aVL; small R in II, III, aVF  |  rS pattern in inferior leads", sub: "" },
  { text: "Left Posterior Fascicular Block (LPFB)", bold: true, color: C.accent2 },
  { text: "QRS <120 ms  |  RAD (+120° to +180°)  |  Small R in I, aVL; small Q in II, III, aVF  |  Must exclude RVH first", sub: "" },
  { text: "Bifascicular Block (RBBB + LAFB or RBBB + LPFB)", bold: true, color: C.orange },
  { text: "6% annual risk of progression to complete heart block (Fuster & Hurst)", sub: "" },
  { text: "RBBB + LPFB = most ominous bifascicular block (smaller fascicle in last path)", sub: "" },
  { text: "Trifascicular Block", bold: true, color: C.red },
  { text: "Bifascicular block + 1st-degree AV block (PR prolongation = delayed conduction in remaining fascicle)", sub: "" },
  { text: "Alternating BBB (RBBB and LBBB alternating) — Class I indication for pacemaker", sub: "" },
  { text: "Markedly prolonged H-V interval (>100 ms) on EPS = Class I pacemaker indication (Fuster & Hurst)", bold: true, color: C.accent3 },
]);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 16 – QRS Diseases: Ventricular Hypertrophy
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("QRS Diseases: Left & Right Ventricular Hypertrophy", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 20, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Criterion", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "LVH", options: { bold: true, color: C.accent3, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "RVH", options: { bold: true, color: C.orange, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } }
    ],
    [
      { text: "Voltage criteria", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Sokolov-Lyon: S(V1) + R(V5/V6) > 35 mm\nCornell: R(aVL) + S(V3) > 28 mm (men) / >20 mm (women)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "R > S in V1; R in V1 + S in V5/V6 > 10-11 mm\nRAD (+90° to +180°)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "QRS axis", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "LAD (often)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "RAD (usually >110°)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "ST-T changes", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "LV strain: ST depression + T inversion in I, aVL, V5, V6 (lateral leads)", options: { color: C.accent2, fontSize: 12, fontFace: "Calibri" } },
      { text: "RV strain: ST depression + T inversion in V1-V4 (right precordial leads)", options: { color: C.accent2, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "P wave", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "P mitrale (bifid P, LAE)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "P pulmonale (peaked P >2.5 mm in II, RAE)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Common causes", options: { color: C.white, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Hypertension (most common), AS, HCM, AI, MR", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "Pulmonary hypertension, PS, TOF, COPD, MS, ASD (Eisenmenger)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ]
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.85, w: 9.6, h: 4.55,
    colW: [2.3, 3.65, 3.65],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.62
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 17 – Pathological Q waves & Delta waves
// ═══════════════════════════════════════════════════════════════════════════════
contentSlide("QRS Diseases: Pathological Q Waves & Delta Wave", [
  { text: "Pathological Q Waves", bold: true, color: C.accent2 },
  { text: "Definition: > 40 ms (1 small square) wide  OR  amplitude > 25% of R wave in same lead", sub: "" },
  { text: "Significance: Indicates transmural (or significant) myocardial necrosis — old MI", sub: "", color: C.white },
  { text: "Location → territory:\n   Q in II, III, aVF = inferior MI (RCA)  |  V1-V4 = anterior MI (LAD)\n   I, aVL = lateral MI (Cx/LCx)  |  V1-V2 + tall R = posterior MI (circumflex)", sub: "", color: C.grey },
  { text: "Q waves may regress over time; persistent Q after MI = abnormal wall motion/scar", sub: "" },
  "",
  { text: "Delta Wave (QRS Pre-excitation)", bold: true, color: C.accent2 },
  { text: "Slurred upstroke at the beginning of QRS (initial slow depolarisation via accessory pathway)", sub: "" },
  { text: "Seen in WPW syndrome; location of delta wave can localise the accessory pathway", sub: "", color: C.white },
  { text: "Positive delta in V1 = left-sided pathway (type A WPW)\nNegative delta in V1 = right-sided/posteroseptal pathway (type B WPW)", sub: "" },
  { text: "CRITICAL: Negative delta waves in some leads can mimic pathological Q waves (pseudo-infarction pattern in WPW)", bold: true, color: C.orange },
]);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 18 – Wide QRS tachycardias
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bgLight);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Wide QRS Tachycardia — Differential Diagnosis (PG Must-Know)", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 20, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Cause", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "ECG Clue", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "Key differentiator", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } }
    ],
    [
      { text: "Ventricular Tachycardia (VT)", options: { color: C.red, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "AV dissociation, fusion beats, capture beats, concordance in precordial leads", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "Most common cause of regular wide QRS tachycardia; default diagnosis if in doubt", options: { color: C.accent1, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "SVT with aberrancy (BBB)", options: { color: C.accent3, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "RBBB or LBBB morphology; P wave visible before each QRS; rate-related aberrancy", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "Look for QRS morphology identical to baseline BBB; responds to adenosine", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Antidromic AVRT (WPW)", options: { color: C.accent2, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Maximally pre-excited QRS (extremely wide); accessory pathway antegrade conduction", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "DO NOT use AV-nodal blocking drugs (adenosine, digoxin, verapamil — risk VF)", options: { color: C.red, fontSize: 12, bold: true, fontFace: "Calibri" } }
    ],
    [
      { text: "Hyperkalaemia", options: { color: C.orange, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Sine-wave pattern; peaked T → wide QRS → no P → sine wave", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "ECG evolves with K+ level; emergent treatment (calcium gluconate, insulin, etc.)", options: { color: C.accent2, fontSize: 12, fontFace: "Calibri" } }
    ],
    [
      { text: "Pace-maker rhythm", options: { color: C.grey, fontSize: 12, bold: true, fontFace: "Calibri" } },
      { text: "Pacing spike before wide QRS; LBBB pattern (RV apex pacing)", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
      { text: "History of PPM; pacemaker-mediated tachycardia possible", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } }
    ]
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.85, w: 9.6, h: 4.55,
    colW: [2.4, 3.6, 3.6],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.62
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 19 – Brugada + ARVC (special QRS patterns)
// ═══════════════════════════════════════════════════════════════════════════════
contentSlide("Special QRS Patterns: Brugada Syndrome & ARVC", [
  { text: "Brugada Syndrome", bold: true, color: C.accent2 },
  { text: "Type 1 (diagnostic): Coved ST elevation (≥2 mm) + T inversion in V1-V2 (± V3)", sub: "" },
  { text: "Type 2: Saddleback ST elevation (≥0.5 mm); NOT diagnostic alone", sub: "", color: C.grey },
  { text: "Mechanism: Loss-of-function SCN5A mutation → phase 2 re-entry → VF\nPresents with syncope or SCD; often male, 3rd-4th decade", sub: "", color: C.white },
  { text: "Unmasked by fever, Na-channel blockers (flecainide, procainamide provocation test)", sub: "" },
  { text: "Treatment: ICD; quinidine for electrical storms; avoid triggering drugs", sub: "" },
  "",
  { text: "Arrhythmogenic Right Ventricular Cardiomyopathy (ARVC)", bold: true, color: C.accent2 },
  { text: "ECG: Epsilon wave (small deflection after QRS in V1-V3), inverted T waves V1-V3, RBBB pattern, terminal S in V1-V3", sub: "" },
  { text: "Fibrofatty replacement of RV myocardium → VT with LBBB morphology (from RV)", sub: "", color: C.white },
  { text: "Diagnosis: Task Force Criteria (2010) — major/minor structural, arrhythmic, genetic criteria", sub: "" },
  { text: "Treatment: ICD; sotalol/amiodarone; exercise restriction; catheter ablation", sub: "" },
]);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 20 – Quick Clinical Reference Summary
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bg);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("Clinical Quick Reference: ECG Summary Table", {
    x: 0.2, y: 0, w: 9.6, h: 0.75, fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const tableData = [
    [
      { text: "Finding", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "Key ECG Feature", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } },
      { text: "Action", options: { bold: true, color: C.accent2, fill: { color: C.tableH }, fontSize: 13, fontFace: "Calibri" } }
    ],
    [{ text: "1st-degree AVB", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
     { text: "PR >200 ms; all P conduct", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "Observe; treat cause", options: { color: C.green, fontSize: 12, fontFace: "Calibri" } }],
    [{ text: "2nd-degree Mobitz I", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
     { text: "Progressive PR ↑ → dropped QRS", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "Usually no pacemaker; treat cause", options: { color: C.yellow, fontSize: 12, fontFace: "Calibri" } }],
    [{ text: "2nd-degree Mobitz II", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
     { text: "Fixed PR → sudden dropped QRS; usually wide QRS", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "Pacemaker (Class I)", options: { color: C.accent1, fontSize: 12, bold: true, fontFace: "Calibri" } }],
    [{ text: "3rd-degree AVB", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
     { text: "P and QRS completely dissociated", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "Emergency PPM / transvenous pacing", options: { color: C.accent1, fontSize: 12, bold: true, fontFace: "Calibri" } }],
    [{ text: "WPW", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
     { text: "Short PR + delta wave + wide QRS", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "RF ablation; avoid AVN blockers in AF", options: { color: C.orange, fontSize: 12, fontFace: "Calibri" } }],
    [{ text: "RBBB", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
     { text: "rSR' V1; wide S in I, V6; QRS ≥120 ms", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "Usually benign; look for PE / ASD", options: { color: C.yellow, fontSize: 12, fontFace: "Calibri" } }],
    [{ text: "LBBB (NEW)", options: { color: C.accent1, fontSize: 12, bold: true, fontFace: "Calibri" } },
     { text: "Wide R in V6; QS in V1; QRS ≥120 ms", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "STEMI-equivalent — act immediately", options: { color: C.accent1, fontSize: 12, bold: true, fontFace: "Calibri" } }],
    [{ text: "Brugada Type 1", options: { color: C.white, fontSize: 12, fontFace: "Calibri" } },
     { text: "Coved ST ↑ + T inversion V1-V2", options: { color: C.grey, fontSize: 12, fontFace: "Calibri" } },
     { text: "Refer for ICD evaluation", options: { color: C.accent2, fontSize: 12, fontFace: "Calibri" } }],
  ];

  sl.addTable(tableData, {
    x: 0.2, y: 0.82, w: 9.6, h: 4.6,
    colW: [2.3, 3.7, 3.6],
    fill: { color: C.tableR1 },
    border: { pt: 0.5, color: C.tableH },
    fontFace: "Calibri",
    rowH: 0.46
  });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 21 – THANK YOU / End
// ═══════════════════════════════════════════════════════════════════════════════
{
  const sl = addSlideBase(C.bg);
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.25, h: 5.625, fill: { color: C.accent1 } });
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 5.2, w: 10, h: 0.425, fill: { color: C.accent1 } });

  sl.addText("Key Take-Home Messages", {
    x: 0.6, y: 0.4, w: 9, h: 0.7, fontSize: 28, bold: true, color: C.accent2, fontFace: "Calibri"
  });

  const msgs = [
    "PR >200 ms = delay, not block — but 50% progress to higher-degree block within 1 year",
    "Mobitz I = AV node, benign; Mobitz II = infranodal, dangerous → pacemaker",
    "Complete heart block: if escape <40 bpm or symptomatic → pacemaker (Class I)",
    "Short PR + delta wave + wide QRS = WPW → ablation; never give digoxin/verapamil in AF+WPW",
    "New LBBB in chest pain = STEMI-equivalent until proven otherwise",
    "Wide QRS tachycardia → treat as VT unless definitively proven otherwise",
    "LBBB + cardiomyopathy + LVEF ≤35% + QRS ≥150 ms → consider CRT",
    "Brugada Type 1: coved ST elevation V1-V2 + SCD risk → ICD"
  ];

  sl.addText(msgs.map((m, i) => ({
    text: `${i + 1}.  ${m}`,
    options: { bullet: false, breakLine: true, fontSize: 14, color: i % 2 === 0 ? C.white : C.grey, fontFace: "Calibri" }
  })), { x: 0.6, y: 1.2, w: 9, h: 3.8, valign: "top" });

  sl.addText("Sources: Goldman-Cecil Medicine • Braunwald's Heart Disease • Fuster & Hurst's The Heart 15e", {
    x: 0.6, y: 5.0, w: 9, h: 0.35, fontSize: 11, color: C.grey, italic: true, fontFace: "Calibri"
  });
}

// ─── SAVE ─────────────────────────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/ecg-class/ECG_Class_PG_PR_QRS.pptx";
pres.writeFile({ fileName: outPath }).then(() => {
  console.log("SAVED:", outPath);
}).catch(err => {
  console.error("ERROR:", err);
  process.exit(1);
});
Running Command

cd /home/daytona/workspace/ecg-class && node ecg_class.js

Running Command

ls -lh /home/daytona/workspace/ecg-class/ECG_Class_PG_PR_QRS.pptx

Your ECG class presentation is ready. Download it here:

ECG Class PG PR QRS

Presentation · PPTX


What's inside (21 slides, deep navy + ECG-red theme)

Section 1 — PR Interval

SlideContent
1Title slide
2ECG Intervals at a Glance (PR, QRS, QT, ST — normal values + abnormalities)
3PR Interval Anatomy & Physiology (conduction pathway, autonomic effects, memory box)
4AV Block Classification Overview (1st, 2nd, High-degree, 3rd degree)
51st-degree AV block — definition, site, causes, ECG, management, pearl (50% progress)
62nd-degree Mobitz I (Wenckebach) — ECG pattern, mnemonic, comparison vs Mobitz II
72nd-degree Mobitz II + High-degree block — comparison table, pacemaker indications
83rd-degree (Complete) AV block — AV dissociation, escape rhythms, Stokes-Adams attacks, treatment
9Short PR: WPW vs LGL — delta wave, accessory pathway, tachycardias, ablation; danger of digoxin/adenosine in AF+WPW
10Pacemaker indications for AV block (ACC/AHA Class I and IIA)

Section 2 — QRS Complex

SlideContent
11QRS Anatomy & Physiology (components, normal <120 ms, narrow vs wide significance)
12BBB Overview — RBBB vs LBBB vs LAFB/LPFB comparison table
13RBBB deep-dive — rSR' in V1, slurred S in V6, causes (PE, ASD, idiopathic)
14LBBB deep-dive — new LBBB = STEMI-equivalent; cardiomyopathy + dyssynchrony; CRT
15Fascicular, bifascicular, trifascicular block — 6% annual CHB risk, alternating BBB
16LVH vs RVH — Sokolov-Lyon, Cornell, strain pattern, P-mitrale vs P-pulmonale
17Pathological Q waves + Delta wave — pseudo-infarction in WPW
18Wide QRS tachycardia DDx — VT vs SVT with aberrancy vs antidromic AVRT vs hyperkalaemia
19Brugada Syndrome + ARVC — coved ST, epsilon wave, ICD indications
20Clinical Quick Reference Summary Table
218 key take-home messages
Sources used: Goldman-Cecil Medicine, Braunwald's Heart Disease, and Fuster & Hurst's The Heart (15th edition).

Add ecgs a lot of ecgs

Finding Sources
Finding Sources
Searching the Web

free open access ECG images first degree AV block Wenckebach LBBB RBBB WPW wikimedia commons

Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Finding Sources
Reading File
Reading File
Reading File
Reading File
Writing File

~/ecg-class/fetch_and_build_ecg.js

const pptxgen = require("pptxgenjs");
const { execSync } = require("child_process");
const fs = require("fs");

// ─── ECG IMAGE MANIFEST ──────────────────────────────────────────────────────
// All URLs from Braunwald, Goldman-Cecil, Tintinalli, Fuster & Hurst textbooks
const ECG_IMAGES = [
  // ── PR INTERVAL / AV BLOCK ──────────────────────────────────────────────
  {
    url: "https://cdn.orris.care/cdss_images/c2b34741f43433c951080d071fe2f6a8654c9a0911f1747ecd530f3564a90482.png",
    title: "First-Degree AV Block",
    caption: "PR interval = 370 ms (left) and 230 ms (right). AV nodal delay causes prolonged PR. RBBB and LBBB variants shown. (Braunwald Fig 68.6)",
    label: "1st DEGREE AV BLOCK",
    color: "4CAF50"
  },
  {
    url: "https://cdn.orris.care/cdss_images/b66e71fb0d729a2cc62ed255f330fe318dcb6010a0abdf694d620b7e8fdb7200.png",
    title: "Second-Degree AV Block — Mobitz Type I (Wenckebach)",
    caption: "Arrows point to non-conducted P waves. Progressive PR prolongation with grouped beating typical of Wenckebach. (Tintinalli Fig 18-15)",
    label: "MOBITZ I (WENCKEBACH)",
    color: "FFC107"
  },
  {
    url: "https://cdn.orris.care/cdss_images/5e296e6683d8287c1247898d4e8a48d412a5c32a1106dbbe7f5933b779f4aaa8.png",
    title: "Second-Degree AV Block Type I — Grouped Beating",
    caption: "Rhythm strip showing clustering (grouped beating) of QRS complexes. Classic Wenckebach cycle. (Tintinalli Fig 18-16A)",
    label: "WENCKEBACH — GROUPED BEATS",
    color: "FFC107"
  },
  {
    url: "https://cdn.orris.care/cdss_images/7dafd7481f734f07c02cf74e2dccfe65a10e5173569bec12048c6c2653b5f92e.png",
    title: "Wenckebach (Mobitz I) — His Bundle Recording",
    caption: "Progressive PR prolongation with AV nodal delay (AH interval increases) confirmed by intracardiac His recording. (Braunwald Fig 68.8)",
    label: "MOBITZ I — HIS BUNDLE EGM",
    color: "FFC107"
  },
  {
    url: "https://cdn.orris.care/cdss_images/84e74dd7616add16260f7ad984415c80f90150de7194451ea61cb9b43a5623e8.png",
    title: "Mobitz Type II AV Block — His-Purkinje Block",
    caption: "Constant PR then sudden dropped QRS (A). His-Purkinje Wenckebach with RBBB morphology (B). A-H constant, H-V prolongs to 280 ms before block. (Braunwald Fig 68.9)",
    label: "MOBITZ II — INFRANODAL BLOCK",
    color: "FF7043"
  },
  {
    url: "https://cdn.orris.care/cdss_images/058e3c82cd6ce2c61e60d860baebe7bde072c8f7ed64737c606b5efcd2eeeb43.png",
    title: "Second-Degree Mobitz II — 3 Examples",
    caption: "(A) Narrow QRS  (B) Wide QRS  (C) High-grade AV block with ≥2 consecutive non-conducted P waves (arrows). (Tintinalli Fig 18-17)",
    label: "MOBITZ II — NARROW / WIDE / HIGH-GRADE",
    color: "FF7043"
  },
  {
    url: "https://cdn.orris.care/cdss_images/0aabba9d32a52fe02bba3c8d503c0a2cba9c5a4e76c1cecd80aea22f62cd1adc.png",
    title: "High-Degree AV Block",
    caption: "Multiple non-conducted P waves (first buried in QRS). Periods of complete block followed by conducted beats with long PR. (Goldman-Cecil Fig 51-8)",
    label: "HIGH-DEGREE AV BLOCK",
    color: "EF5350"
  },
  {
    url: "https://cdn.orris.care/cdss_images/709d8329e83b59253486c07df2a5bc71ce9b824303cc5a39fd12bf509e27637b.png",
    title: "Congenital Third-Degree (Complete) AV Block",
    caption: "Complete AV nodal block — P waves not followed by His deflection; narrow QRS escape at ~40-60 bpm; P and QRS march independently. (Braunwald Fig 68.12)",
    label: "COMPLETE HEART BLOCK",
    color: "EF5350"
  },
  {
    url: "https://cdn.orris.care/cdss_images/67f3c12e10443e0f4069c0163ba42955754f6b84b482e57c035e63fd5623022b.png",
    title: "Complete Heart Block — AV Dissociation + Acute Inferior MI",
    caption: "Black arrows = atrial (P waves); red arrows = ventricular beats. Note ST elevation in III, aVF → acute inferior MI as cause. (Goldman-Cecil Fig 51-9)",
    label: "CHB + INFERIOR MI",
    color: "EF5350"
  },
  {
    url: "https://cdn.orris.care/cdss_images/d318069576993ef84e0b58435ed3df36f5d5897f7aed7c4611f8e1057e04268d.png",
    title: "Progressive AV Block — Endocarditis (MRSA Root Abscess)",
    caption: "Serial ECGs showing progression: (A) 1st-degree AV block → (B) 2nd-degree AV block → (C) Complete heart block. Caused by aortic root abscess. (Fuster Fig 33-6)",
    label: "1ST → 2ND → 3RD DEGREE — PROGRESSIVE",
    color: "E63946"
  },
  // ── WPW / PRE-EXCITATION ─────────────────────────────────────────────────
  {
    url: "https://cdn.orris.care/cdss_images/33194aadea047c86de59dcf6e4ff36f88e00e68e161b413a690f9d9dd3c3c649.png",
    title: "Wolff-Parkinson-White (WPW) — Pre-excited QRS",
    caption: "Short PR + delta wave (slurred QRS upstroke). Onset of QRS occurs BEFORE His deflection — classic EP confirmation of WPW. (Fuster Fig 35-10A)",
    label: "WPW — PRE-EXCITATION",
    color: "2EC4B6"
  },
  {
    url: "https://cdn.orris.care/cdss_images/eedac2961e19194f75180bde797f7219f6ccdc9029e274cfb657d39180b762e4.png",
    title: "WPW — Degree of Pre-excitation with Atrial Pacing",
    caption: "Left: sinus rhythm with obvious delta wave. Right: atrial pacing at 200 bpm — increased pre-excitation as AV node slows. 12-lead ECG. (Fuster Fig 35-11)",
    label: "WPW — 12-LEAD ECG",
    color: "2EC4B6"
  },
  // ── BUNDLE BRANCH BLOCK ─────────────────────────────────────────────────
  {
    url: "https://cdn.orris.care/cdss_images/c85484187579f2b983e2a5244ae0ecc48945d291a2b56f6afc04aafc27026d56.png",
    title: "Complete AV Nodal Block — Baseline + RV Pacing",
    caption: "(A) Complete AV nodal block at baseline — narrow escape rhythm. (B) After RV pacing — wide LBBB-morphology QRS from RV apex stimulation. (Fuster Fig 38-19)",
    label: "COMPLETE AV BLOCK + RV PACING",
    color: "B0C4D8"
  },
  // ── LADDER DIAGRAMS ──────────────────────────────────────────────────────
  {
    url: "https://cdn.orris.care/cdss_images/750c637a40c73f0367d9735e17517fda21817610141e756e1385deaae02ae69b.png",
    title: "Wenckebach Ladder Diagram — 4:3 AV Conduction Cycle",
    caption: "Classic ladder diagram: 4 P waves, 3 conducted QRS. AV tier shows increasing PR until block. PR increments decrease progressively. (Braunwald Fig 68.7)",
    label: "WENCKEBACH LADDER DIAGRAM",
    color: "FFC107"
  },
  {
    url: "https://cdn.orris.care/cdss_images/6a214f9d85b046708aebca999d66f6af998cc6e0fbd2b862dca31246a4ece588.png",
    title: "AV Dissociation — 4 Causes (Ladder Diagram)",
    caption: "Sinus bradycardia escape (I), VT without retrograde capture (II), complete AV block with escape (III), combination of II+III. (Braunwald Fig 68.6 dissociation diagram)",
    label: "AV DISSOCIATION — LADDER DIAGRAM",
    color: "B0C4D8"
  },
  // ── CONDUCTION SYSTEM ANATOMY ────────────────────────────────────────────
  {
    url: "https://cdn.orris.care/cdss_images/fbeb9fa227396bef2202dd2e2302f1ccb33690ce468d6bd2184310f11ed14996.png",
    title: "Cardiac Conduction System — Anatomy",
    caption: "SA node → atria → AV node → His bundle → bundle branches → Purkinje network. Diagram shows intracardiac electrogram (SA, His, V) relationship to surface ECG intervals. (Goldman-Cecil Fig 5-14)",
    label: "CONDUCTION SYSTEM ANATOMY",
    color: "2EC4B6"
  },
];

// ─── FETCH ALL IMAGES ────────────────────────────────────────────────────────
console.log(`Fetching ${ECG_IMAGES.length} ECG images...`);
const urlList = ECG_IMAGES.map(e => `"${e.url}"`).join(" ");
let fetchResults;
try {
  const raw = execSync(
    `node /home/daytona/skills/shared/scripts/fetch_images.js ${urlList}`,
    { maxBuffer: 100 * 1024 * 1024, timeout: 90000 }
  ).toString();
  fetchResults = JSON.parse(raw);
  console.log(`Fetched ${fetchResults.filter(r => !r.error).length} / ${fetchResults.length} images OK`);
} catch (e) {
  console.error("Fetch failed:", e.message.slice(0, 300));
  process.exit(1);
}

// Build a map: url → base64
const imgMap = {};
fetchResults.forEach(r => {
  if (!r.error && r.base64) imgMap[r.url] = r.base64;
  else console.warn("FAILED:", r.url, r.error);
});

// ─── BUILD PPTX ──────────────────────────────────────────────────────────────
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "ECG Class: PR Interval & QRS — ECG Image Gallery";

const C = {
  bg: "0D1B2A", bgLight: "132338", accent1: "E63946", accent2: "F4A261",
  accent3: "2EC4B6", white: "FFFFFF", grey: "B0C4D8", tableH: "1B3A5C",
};

function ecgSlide(ecg, idx, total) {
  const imgData = imgMap[ecg.url];
  const sl = pres.addSlide();
  sl.background = { color: C.bg };

  // Title bar
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.65, fill: { color: C.accent1 } });

  // Badge
  sl.addShape(pres.ShapeType.roundRect, {
    x: 0.15, y: 0.08, w: 3.2, h: 0.45,
    fill: { color: ecg.color || "2EC4B6" }, rectRadius: 0.1
  });
  sl.addText(ecg.label, {
    x: 0.15, y: 0.08, w: 3.2, h: 0.45,
    fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle",
    fontFace: "Calibri", margin: 0
  });

  sl.addText(ecg.title, {
    x: 3.5, y: 0, w: 6.3, h: 0.65,
    fontSize: 16, bold: true, color: C.white, valign: "middle",
    fontFace: "Calibri", margin: 0
  });

  // ECG image — big and prominent
  if (imgData) {
    sl.addImage({
      data: imgData,
      x: 0.15, y: 0.75, w: 9.7, h: 4.3,
    });
  } else {
    sl.addShape(pres.ShapeType.rect, {
      x: 0.15, y: 0.75, w: 9.7, h: 4.3,
      fill: { color: "1B3A5C" }, line: { color: C.accent1, width: 1 }
    });
    sl.addText("Image unavailable", {
      x: 0.15, y: 0.75, w: 9.7, h: 4.3,
      fontSize: 18, color: C.grey, align: "center", valign: "middle", fontFace: "Calibri"
    });
  }

  // Caption bar at bottom
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 5.1, w: 10, h: 0.525, fill: { color: "0A1628" } });
  sl.addText(ecg.caption, {
    x: 0.2, y: 5.1, w: 9.4, h: 0.525,
    fontSize: 11, color: C.grey, valign: "middle", fontFace: "Calibri", italic: true
  });
}

// ─── TITLE SLIDE ─────────────────────────────────────────────────────────────
{
  const sl = pres.addSlide();
  sl.background = { color: C.bg };
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.25, h: 5.625, fill: { color: C.accent1 } });
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 5.2, w: 10, h: 0.425, fill: { color: C.accent1 } });

  sl.addText("ECG Gallery", {
    x: 0.6, y: 0.8, w: 9, h: 1.0,
    fontSize: 44, bold: true, color: C.white, fontFace: "Calibri"
  });
  sl.addText("PR Interval & QRS Diseases — Real ECG Examples", {
    x: 0.6, y: 1.9, w: 9, h: 0.7,
    fontSize: 24, color: C.accent2, fontFace: "Calibri", italic: true
  });
  sl.addText([
    { text: `${ECG_IMAGES.length} ECG images`, options: { bold: true, color: C.accent3 } },
    { text: " from Braunwald's Heart Disease • Tintinalli's Emergency Medicine\nGoldman-Cecil Medicine • Fuster & Hurst's The Heart (15th ed.)", options: { color: C.grey } }
  ], { x: 0.6, y: 2.8, w: 9, h: 1.0, fontSize: 16, fontFace: "Calibri" });
  sl.addText("PG Teaching Series  •  July 2026", {
    x: 0.6, y: 4.8, w: 9, h: 0.4, fontSize: 14, color: C.grey, fontFace: "Calibri"
  });
}

// ─── INDEX SLIDE ─────────────────────────────────────────────────────────────
{
  const sl = pres.addSlide();
  sl.background = { color: C.bgLight };
  sl.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.75, fill: { color: C.accent1 } });
  sl.addText("ECG Gallery — Contents", {
    x: 0.2, y: 0, w: 9.6, h: 0.75,
    fontSize: 22, bold: true, color: C.white, valign: "middle", fontFace: "Calibri", margin: 0
  });

  const leftItems = ECG_IMAGES.slice(0, 8);
  const rightItems = ECG_IMAGES.slice(8);

  sl.addText(leftItems.map((e, i) => ({
    text: `${i + 1}. ${e.title}`,
    options: { bullet: false, breakLine: true, fontSize: 14, color: i % 2 === 0 ? C.white : C.grey, fontFace: "Calibri" }
  })), { x: 0.3, y: 0.9, w: 4.8, h: 4.6, valign: "top" });

  sl.addText(rightItems.map((e, i) => ({
    text: `${i + 9}. ${e.title}`,
    options: { bullet: false, breakLine: true, fontSize: 14, color: i % 2 === 0 ? C.white : C.grey, fontFace: "Calibri" }
  })), { x: 5.2, y: 0.9, w: 4.6, h: 4.6, valign: "top" });
}

// ─── SECTION DIVIDERS + ECG SLIDES ───────────────────────────────────────────
const sections = [
  { heading: "SECTION A: PR Interval & AV Block ECGs", sub: "1st Degree • Mobitz I • Mobitz II • High-Degree • Complete Heart Block", indices: [0,1,2,3,4,5,6,7,8,9] },
  { heading: "SECTION B: Pre-Excitation ECGs", sub: "WPW — Delta Wave • Accessory Pathway Confirmation", indices: [10,11] },
  { heading: "SECTION C: Conduction System & Pacing", sub: "BBB / Complete Block / RV Pacing • Ladder Diagrams • Anatomy", indices: [12,13,14,15] },
];

sections.forEach(sec => {
  // Section divider
  const sdiv = pres.addSlide();
  sdiv.background = { color: C.accent1 };
  sdiv.addText(sec.heading, {
    x: 0.5, y: 1.6, w: 9, h: 1.2,
    fontSize: 34, bold: true, color: C.white, align: "center", fontFace: "Calibri"
  });
  sdiv.addText(sec.sub, {
    x: 0.5, y: 3.0, w: 9, h: 0.8,
    fontSize: 20, color: C.white, align: "center", italic: true, fontFace: "Calibri"
  });

  // ECG slides
  sec.indices.forEach((idx, i) => {
    if (idx < ECG_IMAGES.length) ecgSlide(ECG_IMAGES[idx], i + 1, sec.indices.length);
  });
});

// ─── SAVE ─────────────────────────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/ecg-class/ECG_Gallery_PR_QRS.pptx";
pres.writeFile({ fileName: outPath }).then(() => {
  console.log("SAVED:", outPath);
  const stat = fs.statSync(outPath);
  console.log("Size:", (stat.size / 1024).toFixed(0), "KB");
}).catch(err => {
  console.error("ERROR:", err);
  process.exit(1);
});
Running Command

cd /home/daytona/workspace/ecg-class && node fetch_and_build_ecg.js 2>&1

Running Command

cd /home/daytona/workspace/ecg-class && node /home/daytona/skills/shared/scripts…

Running Command

cd /home/daytona/workspace/ecg-class && node /home/daytona/skills/shared/scripts…

??

Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.
This is a shared conversation. Sign in to Orris to start your own chat.