Teach ecg

Reading File
Asking for Preferences
Finding Sources
Searching the Web

ECG interpretation complete beginner guide systematic approach 2024

Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Loading Image
Loading Image
Reading File
I now have excellent content from Harrison's and Guyton & Hall. Let me compile the full ECG teaching lesson.

πŸ“‹ ECG (Electrocardiogram) - Complete Beginner's Guide


PART 1 - What Is an ECG?

An ECG (electrocardiogram) is a recording of the electrical activity of the heart, captured from electrodes placed on the skin. When a cardiac impulse passes through the heart, electrical current spreads into the surrounding tissues and reaches the skin surface. Electrodes pick up these tiny voltages and plot them against time on graph paper.
The result is a tracing that tells you:
  • Is the heart beating at the right rate and rhythm?
  • Is electricity traveling through the right pathway?
  • Is any part of the heart muscle damaged or under strain?
"When a cardiac impulse passes through the heart, electrical current spreads from the heart into adjacent tissues... a small portion spreads all the way to the surface of the body. If electrodes are placed on the skin on opposite sides of the heart, electrical potentials generated by the current can be recorded." - Guyton & Hall Textbook of Medical Physiology

PART 2 - The Electrical Conduction System (How the Heart Generates the Signal)

Before reading an ECG, you must understand what creates it:
Cardiac conduction system showing SA node, AV node, His bundle, bundle branches, and Purkinje fibers
The normal heartbeat originates in the SA node (sinoatrial node) in the right atrium - the heart's natural pacemaker. The signal then flows in this sequence:
StepStructureWhat Happens
1SA nodeGenerates the impulse spontaneously
2Right and left atriaDepolarize β†’ atrial contraction
3AV nodeDelays the signal (gives atria time to empty into ventricles)
4Bundle of HisPasses signal to ventricles
5Right & Left bundle branchesSplit to each ventricle
6Purkinje fibersRapidly spread activation across ventricular myocardium
7Ventricular myocardiumDepolarizes β†’ ventricular contraction
  • Harrison's Principles of Internal Medicine 22E, p. 1911

PART 3 - The ECG Waveforms Explained

Every heartbeat produces a characteristic pattern on the ECG:
ECG waveform diagram showing P wave, QRS complex, ST segment, T wave, U wave, and PR/QRS/QT intervals

The Waves

Wave / SegmentWhat it RepresentsNormal Appearance
P waveAtrial depolarization (atria contracting)Small, rounded, upright
QRS complexVentricular depolarization (ventricles contracting)Sharp, tall deflection
ST segmentEarly ventricular repolarization (ventricles at rest before recovery)Flat, at baseline
T waveVentricular repolarization (ventricles recovering)Broad, rounded, upright
U wavePossibly Purkinje fiber repolarizationSmall, may follow T wave

Q, R, and S - Breaking Down the QRS

The QRS complex can have up to 3 components:
  • Q wave - first downward deflection before the R
  • R wave - first upward deflection
  • S wave - downward deflection after the R
Not every QRS has all three - that is normal. If there is no R wave, the whole complex is called a QS.
"The P wave is caused by electrical potentials generated when the atria depolarize before atrial contraction begins. The QRS complex is caused by potentials generated when the ventricles depolarize before contraction... The T wave is caused by potentials generated as the ventricles recover from depolarization." - Guyton & Hall

PART 4 - The ECG Paper and Measurements

The ECG is printed on standard graph paper divided into 1 mm boxes:
Horizontal axis = TIME
  - 1 small box = 1 mm = 40 ms (0.04 s)
  - 5 small boxes = 1 large box = 200 ms (0.20 s)
  - Paper speed = 25 mm/s (standard)

Vertical axis = VOLTAGE (amplitude)
  - 1 mV = 10 mm (with standard calibration)

Key Intervals (with Normal Values)

IntervalWhat It MeasuresNormal Range
RR intervalTime between consecutive heartbeatsVaries by rate
PR intervalAtrial to ventricular conduction (includes AV delay)120-200 ms (3-5 small boxes)
QRS intervalVentricular depolarization duration≀110 ms (~2.5 small boxes)
QT intervalTotal ventricular depolarization + repolarizationVaries; corrected QTc ≀450 ms (men), ≀460 ms (women)
  • Harrison's Principles of Internal Medicine 22E, p. 1912

PART 5 - The 12 Leads (12 Camera Angles of the Heart)

A standard ECG uses 10 electrodes placed on the body to generate 12 leads (views). Think of each lead as a camera pointing at the heart from a different angle.

Limb Leads (Frontal Plane - front-to-back view)

LeadView
ILeft side of heart
IIInferior-left
IIIInferior
aVRRight shoulder (cavity view)
aVLLeft shoulder (high lateral)
aVFFeet (inferior)

Chest (Precordial) Leads (Horizontal Plane - side cross-section)

LeadPositionArea Viewed
V14th intercostal space, right sternal borderSeptal
V24th intercostal space, left sternal borderSeptal
V3Between V2 and V4Anterior
V45th intercostal space, midclavicular lineAnterior
V5Anterior axillary line, same level as V4Lateral
V6Midaxillary line, same level as V4/V5Lateral
The key principle: Each lead "looks" at a specific region of the heart. Changes in particular leads point to disease in that region.
ECG RegionLeadsCoronary Artery
InferiorII, III, aVFRight coronary artery (RCA)
LateralI, aVL, V5, V6Left circumflex artery
Anterior/SeptalV1-V4Left anterior descending (LAD)
Right ventricleV1, V3R-V6RRCA

PART 6 - Systematic Approach to Reading an ECG

Always read an ECG in the same order. Never skip steps. Here is a reliable 7-step system:

Step 1 - Rate

Count the ventricular rate (heart rate):
  • Quick method: Count the number of large boxes between two R waves, then divide 300 by that number
    • 1 large box = 300 bpm, 2 = 150, 3 = 100, 4 = 75, 5 = 60, 6 = 50
  • Normal: 60-100 bpm
  • Bradycardia: <60 bpm
  • Tachycardia: >100 bpm

Step 2 - Rhythm

  • Is the rhythm regular (RR intervals equal) or irregular?
  • Are there P waves?
  • Does every P wave have a QRS after it?
  • Does every QRS have a P wave before it?
  • A regular rhythm with P before every QRS = sinus rhythm (normal)

Step 3 - PR Interval

  • Measure from start of P to start of QRS
  • Short PR (<120 ms) β†’ pre-excitation (e.g., WPW syndrome)
  • Long PR (>200 ms) β†’ first-degree AV block

Step 4 - QRS Complex

  • Width: Narrow (<110 ms) = normal. Wide (β‰₯120 ms) = bundle branch block or ventricular rhythm
  • Height: Tall voltages β†’ hypertrophy; low voltages β†’ effusion, obesity, COPD
  • Q waves: Pathological Q waves (>1 mm wide, >ΒΌ of the QRS height) = old MI

Step 5 - ST Segment

This is critically important for detecting heart attacks:
  • ST elevation (>1 mm above baseline) = acute MI (STEMI) or pericarditis
  • ST depression (below baseline) = ischemia or NSTEMI
  • The J point is where QRS ends and ST begins

Step 6 - T Waves

  • Normal: upright in most leads, inverted in aVR
  • T-wave inversion = ischemia, strain, bundle branch block
  • Peaked/tall T waves = early MI (hyperacute T waves) or hyperkalemia

Step 7 - QT Interval

  • Measure from start of QRS to end of T wave
  • Correct for rate with the Bazett formula: QTc = QT Γ· √RR (both in seconds)
  • Prolonged QTc β†’ risk of torsades de pointes (dangerous arrhythmia)

PART 7 - Common Abnormal Patterns to Know

FindingWhat It Looks LikeLikely Cause
ST elevationST segment raised above baselineSTEMI, pericarditis
ST depressionST segment below baselineIschemia (NSTEMI), digoxin effect
Wide QRSQRS β‰₯120 msBundle branch block, ventricular rhythm
Prolonged PRPR >200 msFirst-degree AV block
No P waves, irregular RRChaotic baseline, irregularly irregularAtrial fibrillation
Sawtooth baselineFlutter waves at ~300/minAtrial flutter
Peaked T wavesVery tall, narrow T wavesHyperkalemia, early ischemia
Low voltagesQRS <5 mm in limb leadsPericardial effusion, COPD, obesity
Delta wave + short PRSlurred upstroke of QRSWolff-Parkinson-White (WPW)

PART 8 - Bundle Branch Blocks (Quick Summary)

When one of the bundle branches fails to conduct, the QRS widens because depolarization must spread slowly through the myocardium instead of the fast conduction system.
Right BBB (RBBB)Left BBB (LBBB)
QRS durationβ‰₯120 msβ‰₯120 ms
V1 patternrSR' ("rabbit ears")Broad, deep QS or rS
V6 patternqRS (wide S wave)Tall, broad R (no Q, no S)
ST/T directionOpposite to terminal QRSOpposite to QRS
SignificanceOften benignOften significant cardiac disease
A new LBBB in a patient with chest pain is treated as a STEMI equivalent.
  • Harrison's Principles of Internal Medicine 22E, p. 1913

PART 9 - Reading Your First ECG (Checklist)

Print this and use it every time:
β–‘ 1. Rate:          _____ bpm  (normal 60-100)
β–‘ 2. Rhythm:        Regular / Irregular   P waves present? Y/N
β–‘ 3. PR interval:   _____ ms   (normal 120-200)
β–‘ 4. QRS width:     _____ ms   (normal <110)
β–‘ 5. ST segment:    Normal / Elevated / Depressed
β–‘ 6. T waves:       Upright / Inverted / Peaked
β–‘ 7. QTc:          _____ ms   (normal <450/460 ms)
β–‘ 8. Axis:          Normal / LAD / RAD
β–‘ 9. Overall:       _______________________

Summary Table - Normal ECG Values

ParameterNormal Value
Heart rate60-100 bpm
PR interval120-200 ms (3-5 small boxes)
QRS duration<110 ms (<2.75 small boxes)
QTc<450 ms (men), <460 ms (women)
P wave<120 ms wide, <2.5 mm tall
ST segmentAt baseline (isoelectric)
T waveUpright in I, II, V3-V6; inverted in aVR

Sources:
  • Guyton and Hall Textbook of Medical Physiology - Fundamentals of Electrocardiography
  • Harrison's Principles of Internal Medicine, 22E (2025) - Basic ECG Waveforms and Intervals, ECG Leads

What to study next: Once you're comfortable with the basics, the best way to improve is by reading lots of ECGs systematically. Pick up common arrhythmias next (sinus bradycardia, tachycardia, AF, flutter), then move on to ST changes and ischemia interpretation. Would you like me to go deeper into any of these topics?

Yes

Asking for Preferences
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Finding Sources
Loading Image
Reading File
Finding Sources
Reading File
I now have all the content needed for a thorough deep-dive. Let me compile the full advanced lesson.

πŸ“‹ ECG Deep Dive - Advanced Interpretation


MODULE 1 - Arrhythmias

An arrhythmia is any rhythm that is NOT normal sinus rhythm. Always use your 7-step system, then classify:

1.1 Normal Sinus Rhythm (the reference)

  • Rate: 60-100 bpm
  • Regular rhythm
  • P wave before every QRS, every P wave followed by a QRS
  • PR interval 120-200 ms
  • Narrow QRS (<110 ms)

1.2 Rate Abnormalities

RhythmRateP WavesQRSCause
Sinus tachycardia>100 bpmNormal, before every QRSNarrowPain, fever, anxiety, bleeding, PE, thyrotoxicosis
Sinus bradycardia<60 bpmNormal, before every QRSNarrowAthletes, vagal, hypothyroid, beta-blockers, inferior MI
Key rule: Sinus tachycardia is always a response to something - find the cause, don't just treat the rate.

1.3 Atrial Arrhythmias

Atrial Fibrillation (AF)

The most common clinically significant arrhythmia.
Mechanism: Chaotic, disorganized electrical activity in the atria - no coordinated contraction.
ECG features:
  • Irregularly irregular RR intervals (no two RR intervals the same)
  • No discrete P waves - replaced by a fibrillatory baseline (chaotic wiggles)
  • Narrow QRS (unless bundle branch block or pre-excitation is present)
  • Rate: ventricular rate usually 100-160 bpm (uncontrolled)
"Performing an ECG during an episode of palpitations is extremely useful in making a definitive diagnosis." - Goldman-Cecil Medicine
Clinical pearls:
  • AF causes loss of the atrial "kick" (atrial contraction) - reduces cardiac output by ~20%
  • Blood pools in the atria (especially the left atrial appendage) - risk of clot and stroke
  • Treatment goals: rate control, rhythm control, anticoagulation

Atrial Flutter

Mechanism: A single reentrant circuit loops around the right atrium at ~300 bpm. The AV node blocks some of these, so the ventricles beat at a fraction of 300.
ECG features:
  • Sawtooth (flutter) waves at ~300/min, best seen in leads II, III, aVF
  • Regular ventricular rate, classically at 150 bpm (2:1 block), or 100 (3:1) or 75 (4:1)
  • Narrow QRS (unless BBB)
  • No distinct P waves - replaced by the flutter waves
Quick tip: If you see a regular narrow-complex tachycardia at exactly 150 bpm - always suspect atrial flutter with 2:1 block.

Supraventricular Tachycardia (SVT)

An umbrella term for fast narrow-complex rhythms arising above the ventricles.
ECG features:
  • Rate: typically 150-250 bpm
  • Narrow QRS (regular)
  • P waves may be hidden within or just after QRS (retrograde conduction)
  • Sudden onset and offset ("paroxysmal")
Management trick: Vagal maneuvers (Valsalva, carotid sinus massage) or IV adenosine will abruptly terminate SVT but will only slow atrial flutter (unmasking the flutter waves).

1.4 Ventricular Arrhythmias

Premature Ventricular Complex (PVC)

  • Wide, bizarre QRS not preceded by a P wave
  • Followed by a compensatory pause
  • T wave is opposite in direction to the QRS
  • Isolated PVCs are common and often benign; frequent (>10/hour), multiform, or on-T ("R-on-T") PVCs raise concern

Ventricular Tachycardia (VT)

  • Wide QRS tachycardia (QRS β‰₯120 ms) at rate >100 bpm
  • Rate typically 100-250 bpm
  • AV dissociation (P waves and QRS complexes firing independently) is diagnostic of VT
  • Life-threatening - causes hemodynamic collapse

Ventricular Fibrillation (VF)

  • Completely chaotic, irregular, no recognizable QRS
  • Cardiac arrest - requires immediate defibrillation
Rule of thumb: Any wide-complex tachycardia should be treated as VT until proven otherwise.

1.5 AV Blocks (Conduction Problems)

The AV node normally delays the signal 120-200 ms. When that system is damaged, AV blocks occur:
DegreePR IntervalAll P waves conduct?ECG PatternClinical Significance
1st degree>200 ms (prolonged)Yes (1:1)Long PR, every P has a QRSBenign, no treatment
2nd degree Mobitz I (Wenckebach)Progressively lengthensNo (some Ps "dropped")PR gets longer, then a QRS is droppedUsually benign, vagal in origin
2nd degree Mobitz IIFixed (constant)No (some Ps dropped without warning)Constant PR, then sudden dropped QRSSerious - may progress to complete block
3rd degree (Complete)N/A - no relationshipNoP waves and QRS complexes completely independent, slow ventricular escape rateEmergency - requires pacemaker
How to remember Mobitz I vs II:
  • Mobitz I (Wenckebach) = "The PR interval lengthens until a beat drops" - like a Wenckebach pattern (easier to remember: "longer, longer, longer, DROP")
  • Mobitz II = No warning, just sudden dropped beats - much more dangerous

MODULE 2 - ST Changes and Ischemia

The ST segment is isoelectric (flat at baseline) in a normal heart. ST deviation is one of the most important findings in clinical ECG interpretation.

2.1 Why the ST Changes in Ischemia

When heart muscle is ischemic (deprived of oxygen), the resting membrane potential drops and action potential duration shortens. This creates an electrical gradient between normal and ischemic tissue - called a "current of injury" - which shifts the ST segment on the ECG.
"Severe, acute ischemia lowers the resting membrane potential and shortens the duration of the action potential. Such changes cause a voltage gradient between normal and ischemic zones. These currents of injury are represented on the surface ECG by deviation of the ST segment." - Harrison's Principles of Internal Medicine, 22E

2.2 Transmural vs Subendocardial Ischemia

TypeDepthST on ECGExample
Transmural (full wall thickness)Outer (epicardial) layers involvedST elevation in leads facing the ischemic zoneSTEMI
Subendocardial (inner lining only)Inner (endocardial) layersST depression in overlying leadsNSTEMI, demand ischemia

2.3 STEMI - ST-Elevation MI

The most time-critical ECG diagnosis in medicine. Every minute of delay = lost heart muscle.
Formal criteria (ESC/ACC):
  • New ST elevation at the J point in β‰₯2 contiguous leads
  • β‰₯2 mm in V2-V3 (men) or β‰₯1.5 mm (women)
  • β‰₯1 mm in all other contiguous leads
Localization by leads (from Tintinalli's Emergency Medicine):
TerritoryLeads with ST elevationCulprit Artery
AnteroseptalV1, V2 (+/- V3)LAD (proximal)
AnteriorV1, V2, V3, V4LAD
AnterolateralV1-V6, I, aVLLAD + circumflex
LateralI, aVLLeft circumflex
InferiorII, III, aVFRCA (80%) or circumflex (20%)
InferolateralII, III, aVF + V5, V6RCA or circumflex
Right ventricularII, III, aVF + ST elevation V3R-V6RProximal RCA
PosteriorTall R in V1-V2, ST depression V1-V3RCA or circumflex
Reciprocal changes: ST depression in leads opposite the infarct zone. These confirm STEMI and indicate larger territory at risk (e.g., inferior STEMI with ST elevation in II, III, aVF + ST depression in I, aVL).

2.4 Evolutionary Changes of MI

As an MI evolves over hours and days, the ECG changes in a predictable sequence:
Minutes β†’ Hours:
  Hyperacute T waves (tall, peaked, broad)
  ↓
Hours:
  ST elevation
  ↓
Hours to Days:
  T wave inversion (in leads with ST elevation)
  Q waves develop
  ↓
Days to Weeks:
  ST returns to baseline
  T-wave inversions persist
  Q waves persist (permanent marker of old MI)
Pathological Q waves (sign of old infarction):
  • Width β‰₯40 ms (1 small box)
  • Depth β‰₯25% of the overall QRS height
  • Must be present in β‰₯2 contiguous leads

2.5 Important ST Mimics (Not Always MI)

ConditionST PatternHow to Distinguish
PericarditisDiffuse ST elevation (all leads), saddle-shapedPR depression; no reciprocal changes; no Q waves
Early repolarizationST elevation V2-V5, notch at J pointBenign; young athletes; stable; no symptoms
Left bundle branch blockST discordance (opposite to QRS)Wide QRS, LBBB pattern
Brugada syndromeCoved ST elevation V1-V2 + RBBB-like patternNo chest pain; familial; risk of VF
Takotsubo (stress) cardiomyopathyAnterior ST elevation or T inversionEmotional trigger; apical ballooning on echo; coronaries normal
HypercalcemiaShort QT, shortened STCalcium levels elevated

MODULE 3 - Electrical Axis

The electrical axis represents the average direction of the depolarization wave as it travels through the ventricles. It is measured in degrees on the frontal plane.

3.1 Normal Axis

The normal QRS axis is between -30Β° and +90Β° (some sources say -30Β° to +100Β°).
Left axis deviation ECG showing vectorial analysis with lead I, II, III tracings and vector diagram

3.2 Axis Summary Table

CategoryDegreesLeads I and aVF
Normal axis-30Β° to +90Β°Both positive
Left axis deviation (LAD)-30Β° to -90Β°I positive, aVF negative
Right axis deviation (RAD)+90Β° to +180Β°I negative, aVF positive
Extreme axis ("no man's land")-90Β° to Β±180Β°Both negative

3.3 Quick Bedside Axis Method (using Leads I and aVF)

  1. Look at the QRS in Lead I - is it mostly upright (+) or mostly downward (-)?
  2. Look at the QRS in Lead aVF - is it mostly upright (+) or mostly downward (-)?
Lead I (+), aVF (+) β†’ Normal axis
Lead I (+), aVF (-) β†’ Left axis deviation
Lead I (-), aVF (+) β†’ Right axis deviation
Lead I (-), aVF (-) β†’ Extreme (northwest) axis

3.4 Causes of Axis Deviation

Left Axis Deviation (LAD)Right Axis Deviation (RAD)
Left ventricular hypertrophyRight ventricular hypertrophy
Left anterior fascicular blockLeft posterior fascicular block
Inferior MI (Q waves pull axis away)Right bundle branch block
Wolff-Parkinson-White syndromeLateral MI
LBBBPulmonary hypertension / PE (acute cor pulmonale)
HyperkalemiaDextrocardia
"Left axis deviation results from hypertension causing left ventricular hypertrophy... Right axis deviation may result from congenital pulmonary valve stenosis, tetralogy of Fallot, or other conditions causing right ventricular hypertrophy." - Guyton & Hall Textbook of Medical Physiology

MODULE 4 - Hypertrophy Patterns

4.1 Left Ventricular Hypertrophy (LVH)

A thicker, bigger left ventricle generates bigger electrical forces.
Voltage criteria (Sokolow-Lyon - most commonly used):
  • SV1 + RV5 or RV6 >35 mm (Cornell: RaVL >20 mm women, >28 mm men)
Other features:
  • Left axis deviation
  • Left atrial enlargement (bifid P wave in II, biphasic P in V1)
  • "Strain" pattern: ST depression + T-wave inversion in I, aVL, V5, V6 (leads with tall R waves)
Important caveat: High voltage alone is a common normal variant in young/athletic people. Voltage + strain pattern = more specific for true LVH.

4.2 Right Ventricular Hypertrophy (RVH)

Normally the left ventricle dominates. RVH shifts the balance.
ECG features:
  • Right axis deviation (>+90Β°)
  • Tall R wave in V1 (R>S in V1, or R>7 mm)
  • Deep S waves in V5, V6
  • T-wave inversion V1-V3
  • Right atrial enlargement: peaked P wave in II >2.5 mm ("P pulmonale")
Causes: Pulmonary hypertension, PE, mitral stenosis, congenital heart disease (tetralogy of Fallot, pulmonic stenosis)

MODULE 5 - Special Patterns to Know

5.1 Wolff-Parkinson-White (WPW)

An accessory pathway bypasses the AV node, causing early ventricular pre-excitation:
  • Short PR interval (<120 ms) - signal bypasses AV node delay
  • Delta wave - slurred upstroke at the start of QRS (slow conduction through myocardium before normal conduction catches up)
  • Wide QRS (total from delta to end)
  • Risk: rapid conduction down the accessory pathway in AF can trigger VF

5.2 Long QT Syndrome

  • QTc >450 ms (men) or >460 ms (women)
  • Causes: drugs (amiodarone, quinidine, haloperidol, erythromycin), hypokalemia, hypomagnesemia, congenital
  • Risk: Torsades de pointes - a polymorphic VT that looks like a twisting ribbon, which can degenerate to VF and cause sudden death

5.3 Brugada Syndrome

  • Coved-type ST elevation in V1-V2 with RBBB-like morphology
  • Can be unmasked by fever, sodium channel blockers
  • Risk of sudden cardiac death from VF - ICD implantation needed

5.4 Hyperkalemia (Potassium Effect on ECG)

Classic ECG progression with rising K+:
K+ 5.5-6.5: Peaked (tall, narrow, symmetric) T waves
K+ 6.5-7.5: Wide QRS, prolonged PR, flattened P waves
K+ >7.5:   Loss of P waves β†’ "sine wave" pattern
K+ >8-9:   VF or asystole

Summary - The Full Approach in One Place

Step 1  Rate:           _____ bpm (normal 60-100)
Step 2  Rhythm:         Regular/Irregular | P before every QRS?
Step 3  PR interval:    _____ ms (normal 120-200)
Step 4  QRS width:      _____ ms (<110 normal)
Step 5  Axis:           Lead I ___ aVF ___ β†’ Normal/LAD/RAD
Step 6  ST segment:     Normal/Elevated/Depressed
           If elevated β†’ Which leads? β†’ Localize territory
           Reciprocal changes? β†’ Confirms STEMI
Step 7  T waves:        Upright/Inverted/Hyperacute/Peaked
Step 8  QTc:            _____ ms (men <450, women <460)
Step 9  Hypertrophy:    Voltage criteria? Strain pattern?
Step 10 Pattern:        BBB? WPW? Brugada? Ischemia?

Sources:
  • Harrison's Principles of Internal Medicine, 22E (2025) - ECG Waveforms, Myocardial Ischemia and Infarction
  • Guyton and Hall Textbook of Medical Physiology - Axis Deviation, ECG Fundamentals
  • Tintinalli's Emergency Medicine - STEMI Criteria, ST-Segment Based Diagnosis
  • Goldman-Cecil Medicine - Electrocardiography, Arrhythmia Diagnosis

Would you like to go deeper into any specific module - for example, practice cases for arrhythmia recognition, detailed STEMI localization, or bundle branch block differentiation?

Create a practice case deck with 10 ECGs

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

mkdir -p /home/daytona/workspace/ecg-practice-deck && ls /home/daytona/workspace/ecg-practice-deck/

Writing File

~/ecg-practice-deck/build.js

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

// ─── Color Palette ──────────────────────────────────────────────────────────
const BG_DARK   = "0D1B2A";   // deep navy - title / answer slides
const BG_CASE   = "112233";   // slightly lighter navy - case slides
const BG_LIGHT  = "F0F4F8";   // off-white - ECG slides
const ACCENT    = "E63946";   // medical red
const GOLD      = "F4A261";   // warm gold for highlights
const WHITE     = "FFFFFF";
const LIGHT_TXT = "B8C8D8";
const GREEN     = "2EC4B6";   // teal-green for correct answers

// ─── ECG Cases Data ─────────────────────────────────────────────────────────
const cases = [
  {
    number: 1,
    clinicalContext: "65-year-old man with hypertension presents with palpitations and mild dyspnea for 2 days. HR 110, BP 130/85.",
    clues: ["Note the ventricular rhythm carefully", "Look for P waves", "Is every RR interval equal?"],
    imageUrl: "https://cdn.orris.care/cdss_images/c85541618159f7da9530493cfb243ab6826c7ea2c50edece5d0bd203ac7f6bb6.png",
    diagnosis: "Atrial Fibrillation (AF)",
    keyFindings: [
      "Irregularly irregular RR intervals",
      "No discrete P waves β€” chaotic baseline",
      "Narrow QRS complexes (AV node conducting normally)",
      "Ventricular rate ~110 bpm (uncontrolled)"
    ],
    teaching: "AF is the most common sustained arrhythmia. The chaotic atrial activity (>600 impulses/min) produces no organised P waves. The AV node acts as a 'gatekeeper', allowing only some impulses through β€” resulting in an irregularly irregular rhythm. Stroke risk must be assessed (CHAβ‚‚DSβ‚‚-VASc score).",
    management: "Rate control (beta-blocker/diltiazem) β†’ Anticoagulation (CHAβ‚‚DSβ‚‚-VASc β‰₯2) β†’ Consider rhythm control"
  },
  {
    number: 2,
    clinicalContext: "80-year-old man with sudden onset chest pain radiating to the jaw. Diaphoretic, BP 95/60, HR 88.",
    clues: ["Focus on leads II, III, and aVF", "Check leads I and aVL", "Look for reciprocal changes"],
    imageUrl: "https://cdn.orris.care/cdss_images/e30f337203edbe720805bc753caca4b6ae448f7e006d83ca604f83e144d2f782.png",
    diagnosis: "Inferior STEMI (RCA Occlusion)",
    keyFindings: [
      "ST elevation in leads II, III, aVF (inferior leads)",
      "ST elevation in lead III > lead II β†’ favours RCA over circumflex",
      "Reciprocal ST depression in lead I and aVL",
      "Must get right-sided leads to rule out RV infarction"
    ],
    teaching: "Inferior STEMI is caused by RCA occlusion in ~80% of cases. The hallmark is ST elevation in II, III, and aVF. Reciprocal ST depression in I and aVL confirms it. Always obtain lead V4R β€” ST elevation in V4R indicates co-existing RV infarction and means the patient will NOT tolerate nitrates.",
    management: "Aspirin + P2Y12 inhibitor β†’ Emergency PCI (door-to-balloon <90 min) β†’ Avoid nitrates if RV infarction suspected"
  },
  {
    number: 3,
    clinicalContext: "52-year-old man with 1 hour of crushing central chest pain, sweating. BP 140/90, HR 92. No prior cardiac history.",
    clues: ["Look at precordial leads V1-V4", "Check leads I and aVL", "Note the pattern of ST elevation"],
    imageUrl: "https://cdn.orris.care/cdss_images/dc6d5cd22f8672f0b27b85a097c90de9ee666d76b0d0e89b4b46115b0fe5f154.png",
    diagnosis: "Anterior STEMI (Distal LAD Occlusion)",
    keyFindings: [
      "ST elevation in V1, V2, V3 and lead I",
      "No ST depression in II, III, aVF (distal LAD β€” inferior wall spared)",
      "Anterior territory involvement: septum + anterior wall",
      "Distal LAD: less territory than proximal occlusion"
    ],
    teaching: "Anterior STEMI from LAD occlusion is the most haemodynamically dangerous MI. ST elevation in V1-V4 + I, aVL indicates anterior/lateral territory. Occlusion proximal to the first septal perforator affects a larger territory and carries higher mortality. Look for ST elevation in aVR (main stem equivalent).",
    management: "Dual antiplatelet + Emergency PCI β†’ Monitor for LBBB, VT, VF, acute MR, cardiogenic shock"
  },
  {
    number: 4,
    clinicalContext: "65-year-old woman with chest pain for 45 minutes, shortness of breath. Known COPD. BP 105/70, HR 115.",
    clues: ["Compare ST elevation across all leads", "Look for any lead with ST depression", "Check leads aVR and V1"],
    imageUrl: "https://cdn.orris.care/cdss_images/2892df61f6a4e33f8814ab62d11c2ad4ffb8a3cb8023eeeb775ea3cf982cde82.png",
    diagnosis: "Anterior STEMI (Proximal LAD Occlusion)",
    keyFindings: [
      "ST elevation V1, V2, V3, V4 with associated aVL involvement",
      "Extensive anterior territory = proximal LAD",
      "Reciprocal ST depression in inferior leads",
      "Risk of cardiogenic shock β€” large territory at risk"
    ],
    teaching: "Proximal LAD occlusion (before the first diagonal or septal branch) produces massive anterior STEMI affecting the anterior wall, septum, apex, and often the lateral wall. These patients have the highest in-hospital mortality among all STEMIs. Expect complications: VT, VF, AV block, LV failure.",
    management: "Fastest possible PCI β†’ ICU monitoring β†’ Inotropic support if cardiogenic shock"
  },
  {
    number: 5,
    clinicalContext: "33-year-old man post-long-haul flight, sudden onset pleuritic chest pain and breathlessness. HR 105, Oβ‚‚ sat 91% on air. Leg swollen.",
    clues: ["Look at lead I for S waves", "Look at lead III for Q waves and T-wave changes", "Check right precordial leads for RBBB pattern"],
    imageUrl: "https://cdn.orris.care/cdss_images/28043f05c25edcd2ef040a7618f8d8af42facf9c194292f826202ab262a09da3.png",
    diagnosis: "Pulmonary Embolism (S1Q3T3 Pattern)",
    keyFindings: [
      "S wave in lead I",
      "Q wave in lead III",
      "T-wave inversion in lead III (S1Q3T3)",
      "Incomplete RBBB with T-wave inversion V1–V4 (right heart strain)",
      "Sinus tachycardia"
    ],
    teaching: "The S1Q3T3 pattern reflects acute right ventricular strain from PE. The most common ECG finding is sinus tachycardia. S1Q3T3 is specific but not sensitive (~20%). T-wave inversion V1-V4 indicates RV pressure overload. The ECG is most useful for excluding MI and supporting PE diagnosis.",
    management: "CT pulmonary angiogram to confirm β†’ Anticoagulation (LMWH/DOAC) β†’ Thrombolysis if massive PE + haemodynamic collapse"
  },
  {
    number: 6,
    clinicalContext: "Patient with regular narrow-complex tachycardia at HR 150 bpm. Asymptomatic except mild palpitations. BP 118/75.",
    clues: ["A rate of exactly 150 bpm should trigger a specific suspicion", "Look at the baseline between QRS complexes in leads II, III, aVF", "Is there any sawtooth pattern?"],
    imageUrl: "https://cdn.orris.care/cdss_images/012b4fbfc7465f18d6c3598dd526531fd9e11dcda15d8da6c0faae3de3d1520f.png",
    diagnosis: "Atrial Flutter (2:1 AV Block)",
    keyFindings: [
      "Sawtooth flutter waves at ~300/min in inferior leads",
      "Positive flutter waves in V1",
      "Regular ventricular rate ~150 bpm (300 Γ· 2 = 150)",
      "2:1 AV conduction ratio",
      "Narrow QRS complexes"
    ],
    teaching: "Atrial flutter arises from a single reentry circuit in the right atrium cycling at ~300/min. The AV node blocks every other impulse, giving a ventricular rate of ~150 bpm. RULE: any regular narrow-complex tachycardia at exactly 150 bpm β†’ think flutter until proven otherwise. Vagal manoeuvres/adenosine will slow the rate transiently, unmasking the flutter waves.",
    management: "Rate control β†’ Anticoagulation (same as AF) β†’ Rhythm control: cardioversion or catheter ablation (>95% curative)"
  },
  {
    number: 7,
    clinicalContext: "73-year-old man with dizziness and near-syncope. HR 38, BP 90/60. Permanent pacemaker not fitted.",
    clues: ["Count the P waves and QRS complexes separately", "Are P waves and QRS complexes related to each other?", "What is the ventricular escape rate?"],
    imageUrl: "https://cdn.orris.care/cdss_images/261b1c6b1574e2e999daf13b011387a0122373806c4f1abfa30243401b33c870.png",
    diagnosis: "High-Grade AV Block",
    keyFindings: [
      "P waves and QRS complexes not always related (intermittent dissociation)",
      "Variable RR intervals β€” some P waves conduct, others are blocked",
      "Sinus rate 82 bpm; slower ventricular rate",
      "Beats 4 and 5 have shorter preceding RR β†’ these conduct",
      "This is high-grade (not complete) AV block"
    ],
    teaching: "High-grade AV block (also called advanced second-degree) means most P waves are blocked. In complete (third-degree) block, NO P waves conduct β€” the atria and ventricles beat completely independently. The ventricular escape rate is <40/min with wide QRS. Both are pacemaker indications. Causes: inferior MI, drugs (digoxin, beta-blockers), degenerative conduction disease.",
    management: "IV atropine (temporary) β†’ Transcutaneous pacing if unstable β†’ Permanent pacemaker"
  },
  {
    number: 8,
    clinicalContext: "55-year-old woman with progressive exertional dyspnoea and fatigue. History of hypertension for 15 years. BP 165/95.",
    clues: ["Look at QRS voltage in precordial leads", "Check for ST and T-wave changes in lateral leads (V5, V6, I, aVL)", "Calculate: S in V1 + R in V5 or V6"],
    imageUrl: "https://cdn.orris.care/cdss_images/17684e22a76b3488c70edf5d6e238d7feaf1c716f9e05f1e73b4e1deb5429cb4.png",
    diagnosis: "Normal Sinus Rhythm with PAC Initiating AF",
    keyFindings: [
      "Two normal sinus beats at the start",
      "A blocked premature atrial contraction (PAC) after the 2nd QRS",
      "A subsequent PAC then triggers atrial fibrillation",
      "Demonstrates how most AF is triggered by atrial ectopy from pulmonary veins"
    ],
    teaching: "Most episodes of AF are triggered by premature atrial contractions (PACs) originating from the pulmonary veins. A PAC fires at a critical moment when part of the atrium is still partially refractory, initiating re-entry and AF. This is the rationale for pulmonary vein isolation (PVI) catheter ablation. PACs appear on the ECG as early P waves with different morphology.",
    management: "Identify triggers β†’ Treat underlying cause β†’ Antiarrhythmic therapy or PVI ablation for paroxysmal AF"
  },
  {
    number: 9,
    clinicalContext: "58-year-old man presents with chest pain. ECG shows ST abnormalities in left bundle branch block. How do you interpret this?",
    clues: ["In LBBB, the ST segment is normally discordant to the QRS", "Concordant = ST goes SAME direction as QRS dominant deflection", "Excessive discordance >5mm is also abnormal"],
    imageUrl: "https://cdn.orris.care/cdss_images/ce8f5f11790c18bb6281489bc410aada31d4b45782ce90e05721fccf4be3822e.png",
    diagnosis: "LBBB with Modified Sgarbossa Criteria",
    keyFindings: [
      "A: Discordant ST depression (normal in LBBB)",
      "B: Discordant ST elevation (normal in LBBB)",
      "C: CONCORDANT ST elevation β†’ strongly suggests acute MI",
      "D: Concordant ST depression β†’ suggests acute MI",
      "E: Excessive discordant ST elevation >5mm β†’ weakly suggestive"
    ],
    teaching: "In LBBB, the ST segment is normally discordant (opposite direction to main QRS deflection) because repolarisation is abnormal. Finding concordant ST changes breaks this rule and suggests acute ischaemia on top of LBBB (Sgarbossa criteria). A new LBBB in chest pain was historically treated as STEMI equivalent, but now the modified Sgarbossa criteria are more specific.",
    management: "Concordant ST changes in LBBB + chest pain β†’ treat as STEMI β†’ Emergency PCI"
  },
  {
    number: 10,
    clinicalContext: "A 47-year-old man with right ventricular infarction complicating inferior STEMI. Note the classic findings.",
    clues: ["Look at the inferior leads II, III, aVF", "Check for ST elevation in right-sided leads V3R-V6R", "Observe lead V1 carefully"],
    imageUrl: "https://cdn.orris.care/cdss_images/591d741e2ea55e526228f79f8dd6a2cf080b0626906cbf806282e2992df06b17.png",
    diagnosis: "RV Infarction with Inferior STEMI",
    keyFindings: [
      "ST elevation in II, III, aVF (inferior STEMI)",
      "ST elevation in V1 on standard ECG",
      "Right-sided leads (V3R-V6R): ST elevation confirms RV infarction",
      "This pattern indicates proximal RCA occlusion",
      "RV infarction in ~30-50% of inferior STEMIs"
    ],
    teaching: "RV infarction complicates proximal RCA occlusion. On the standard 12-lead, ST elevation in V1 alongside inferior STEMI should trigger right-sided leads. Haemodynamically, these patients are volume-dependent β€” their RV needs preload. AVOID nitrates (cause massive BP drop), diuretics, and morphine. Give IV fluids. Management is different from standard STEMI.",
    management: "IV fluid boluses (cautious) β†’ No nitrates/diuretics β†’ Urgent PCI of proximal RCA β†’ Dobutamine if refractory"
  }
];

// ─── Fetch all ECG images via skill script ───────────────────────────────────
const imageUrls = cases.map(c => c.imageUrl);
console.log("Fetching ECG images...");
const fetchResult = execSync(
  `node /home/daytona/skills/shared/scripts/fetch_images.js ${imageUrls.map(u => `"${u}"`).join(" ")}`
).toString();
const images = JSON.parse(fetchResult);
console.log(`Fetched ${images.filter(i => !i.error).length}/${images.length} images successfully`);

// ─── Build Presentation ──────────────────────────────────────────────────────
let pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "ECG Practice Cases";
pres.author = "Orris Medical Education";

// ══════════════════════════════════════════════════════════════════════════════
// TITLE SLIDE
// ══════════════════════════════════════════════════════════════════════════════
{
  let slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: BG_DARK } });
  // Red accent bar
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 2.2, w: 10, h: 0.05, fill: { color: ACCENT } });
  // ECG-like decorative lines (horizontal)
  for (let i = 0; i < 5; i++) {
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0.3 + i * 0.28, w: 10, h: 0.01, fill: { color: "1A2E45" } });
  }
  slide.addText("ECG Practice Cases", {
    x: 0.6, y: 0.7, w: 8.8, h: 1.2,
    fontSize: 44, bold: true, color: WHITE, fontFace: "Calibri", align: "center"
  });
  slide.addText("10 Clinical Scenarios β€” Test Your Interpretation Skills", {
    x: 0.6, y: 1.85, w: 8.8, h: 0.55,
    fontSize: 18, color: LIGHT_TXT, fontFace: "Calibri", align: "center"
  });
  slide.addShape(pres.ShapeType.rect, { x: 3.5, y: 2.35, w: 3, h: 0.06, fill: { color: ACCENT } });

  const topics = ["Arrhythmias", "STEMI Localization", "AV Blocks", "Bundle Branch Blocks", "PE & RV Strain"];
  topics.forEach((t, i) => {
    const col = i < 3 ? 0 : 1;
    const row = i < 3 ? i : i - 3;
    slide.addShape(pres.ShapeType.rect, {
      x: 1.5 + col * 4.5, y: 2.6 + row * 0.52, w: 3.5, h: 0.42,
      fill: { color: "162840" }, line: { color: ACCENT, width: 1 }
    });
    slide.addText(t, {
      x: 1.5 + col * 4.5, y: 2.6 + row * 0.52, w: 3.5, h: 0.42,
      fontSize: 15, color: GOLD, bold: true, align: "center", valign: "middle"
    });
  });

  slide.addText("Each case: Clinical Context β†’ ECG β†’ Answer & Teaching", {
    x: 0.5, y: 5.1, w: 9, h: 0.35,
    fontSize: 13, color: "607890", align: "center", italic: true
  });
}

// ══════════════════════════════════════════════════════════════════════════════
// HELPER: HOW TO USE SLIDE
// ══════════════════════════════════════════════════════════════════════════════
{
  let slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: BG_DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.12, h: 5.625, fill: { color: ACCENT } });
  slide.addText("How to Use This Deck", {
    x: 0.4, y: 0.2, w: 9.2, h: 0.7,
    fontSize: 28, bold: true, color: WHITE, fontFace: "Calibri"
  });
  const steps = [
    ["STEP 1 β€” Read the Clinical Context", "Age, symptoms, vitals β€” form your differential before seeing the ECG."],
    ["STEP 2 β€” Interpret the ECG", "Use your 7-step system: Rate β†’ Rhythm β†’ PR β†’ QRS β†’ Axis β†’ ST β†’ QT. Read the clues for hints."],
    ["STEP 3 β€” Commit to a Diagnosis", "Write it down or say it out loud before advancing to the answer slide."],
    ["STEP 4 β€” Check the Answer", "Review key findings, teaching points, and management pearls."],
  ];
  steps.forEach(([title, desc], i) => {
    slide.addShape(pres.ShapeType.rect, {
      x: 0.4, y: 1.0 + i * 1.1, w: 9.2, h: 0.95,
      fill: { color: "0F2035" }, line: { color: GOLD, width: 1.5 }
    });
    slide.addText(title, {
      x: 0.6, y: 1.05 + i * 1.1, w: 8.8, h: 0.35,
      fontSize: 14, bold: true, color: GOLD
    });
    slide.addText(desc, {
      x: 0.6, y: 1.38 + i * 1.1, w: 8.8, h: 0.5,
      fontSize: 12, color: LIGHT_TXT
    });
  });
}

// ══════════════════════════════════════════════════════════════════════════════
// CASE SLIDES (Case + ECG + Answer) Γ— 10
// ══════════════════════════════════════════════════════════════════════════════
cases.forEach((c, idx) => {
  const img = images[idx];

  // ── CASE CONTEXT SLIDE ─────────────────────────────────────────────────────
  {
    let slide = pres.addSlide();
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: BG_CASE } });
    // Case number badge
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.72, fill: { color: ACCENT } });
    slide.addText(`CASE ${c.number}  /  10`, {
      x: 0.4, y: 0.08, w: 5, h: 0.56,
      fontSize: 22, bold: true, color: WHITE, fontFace: "Calibri"
    });
    slide.addText("CLINICAL CONTEXT", {
      x: 5, y: 0.08, w: 4.6, h: 0.56,
      fontSize: 13, color: "FFCCD0", align: "right", italic: true
    });

    // Clinical scenario box
    slide.addShape(pres.ShapeType.rect, { x: 0.4, y: 0.85, w: 9.2, h: 1.35, fill: { color: "0A1929" }, line: { color: GOLD, width: 1.5 } });
    slide.addText("Patient Presentation", {
      x: 0.6, y: 0.9, w: 8.8, h: 0.3,
      fontSize: 12, color: GOLD, bold: true, italic: true
    });
    slide.addText(c.clinicalContext, {
      x: 0.6, y: 1.18, w: 8.8, h: 0.9,
      fontSize: 14, color: WHITE, fontFace: "Calibri"
    });

    // Systematic approach reminder
    slide.addText("Apply Your 7-Step ECG System:", {
      x: 0.4, y: 2.3, w: 9.2, h: 0.35,
      fontSize: 13, color: LIGHT_TXT, bold: true
    });
    const steps7 = ["Rate", "Rhythm", "PR Interval", "QRS Width", "Axis", "ST Segment", "T Waves / QTc"];
    steps7.forEach((s, i) => {
      const col = i < 4 ? 0 : 1;
      const row = i < 4 ? i : i - 4;
      slide.addShape(pres.ShapeType.roundRect, {
        x: 0.4 + col * 4.8, y: 2.7 + row * 0.48, w: 4.3, h: 0.4,
        fill: { color: "162840" }, line: { color: "2A4A6A", width: 1 }, rectRadius: 0.05
      });
      slide.addText(`${i + 1}. ${s}`, {
        x: 0.4 + col * 4.8, y: 2.7 + row * 0.48, w: 4.3, h: 0.4,
        fontSize: 12, color: LIGHT_TXT, align: "center", valign: "middle"
      });
    });

    // Hint clues
    slide.addShape(pres.ShapeType.rect, { x: 0.4, y: 4.65, w: 9.2, h: 0.8, fill: { color: "1A3A1A" }, line: { color: GREEN, width: 1 } });
    slide.addText("πŸ’‘  Clues: " + c.clues.join("  |  "), {
      x: 0.5, y: 4.68, w: 9.0, h: 0.74,
      fontSize: 11.5, color: GREEN, italic: true, valign: "middle"
    });
  }

  // ── ECG SLIDE ─────────────────────────────────────────────────────────────
  {
    let slide = pres.addSlide();
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: BG_LIGHT } });
    // Top bar
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.5, fill: { color: BG_DARK } });
    slide.addText(`CASE ${c.number}  β€”  ECG`, {
      x: 0.4, y: 0.05, w: 6, h: 0.4,
      fontSize: 16, bold: true, color: WHITE
    });
    slide.addText("What is your diagnosis?", {
      x: 5, y: 0.05, w: 4.6, h: 0.4,
      fontSize: 14, color: GOLD, align: "right", italic: true
    });

    if (img && !img.error) {
      slide.addImage({
        data: img.base64,
        x: 0.3, y: 0.6, w: 9.4, h: 4.9
      });
    } else {
      slide.addText("ECG image could not be loaded", {
        x: 2, y: 2.5, w: 6, h: 1,
        fontSize: 18, color: ACCENT, align: "center"
      });
    }
  }

  // ── ANSWER SLIDE ──────────────────────────────────────────────────────────
  {
    let slide = pres.addSlide();
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: BG_DARK } });
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.15, h: 5.625, fill: { color: GREEN } });
    // Header
    slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.65, fill: { color: "051020" } });
    slide.addText(`CASE ${c.number}  β€”  ANSWER`, {
      x: 0.4, y: 0.1, w: 4, h: 0.45,
      fontSize: 15, bold: true, color: LIGHT_TXT
    });

    // Diagnosis banner
    slide.addShape(pres.ShapeType.rect, { x: 0.25, y: 0.75, w: 9.5, h: 0.75, fill: { color: ACCENT }, line: { color: ACCENT } });
    slide.addText(`βœ“  ${c.diagnosis}`, {
      x: 0.35, y: 0.75, w: 9.3, h: 0.75,
      fontSize: 22, bold: true, color: WHITE, valign: "middle", fontFace: "Calibri"
    });

    // Key Findings
    slide.addText("KEY ECG FINDINGS", {
      x: 0.3, y: 1.62, w: 4.4, h: 0.3,
      fontSize: 11, bold: true, color: GOLD, charSpacing: 2
    });
    slide.addShape(pres.ShapeType.rect, { x: 0.25, y: 1.93, w: 4.55, h: 2.3, fill: { color: "0A1929" }, line: { color: GOLD, width: 1 } });
    c.keyFindings.forEach((f, i) => {
      slide.addText(`β–Έ  ${f}`, {
        x: 0.35, y: 1.98 + i * 0.47, w: 4.35, h: 0.42,
        fontSize: 11.5, color: WHITE
      });
    });

    // Teaching point
    slide.addText("TEACHING POINT", {
      x: 5.05, y: 1.62, w: 4.6, h: 0.3,
      fontSize: 11, bold: true, color: GOLD, charSpacing: 2
    });
    slide.addShape(pres.ShapeType.rect, { x: 5.0, y: 1.93, w: 4.75, h: 1.55, fill: { color: "0A1929" }, line: { color: LIGHT_TXT, width: 1 } });
    slide.addText(c.teaching, {
      x: 5.1, y: 1.98, w: 4.55, h: 1.45,
      fontSize: 10.5, color: LIGHT_TXT
    });

    // Management pearl
    slide.addText("MANAGEMENT PEARL", {
      x: 5.05, y: 3.57, w: 4.6, h: 0.3,
      fontSize: 11, bold: true, color: GOLD, charSpacing: 2
    });
    slide.addShape(pres.ShapeType.rect, { x: 5.0, y: 3.87, w: 4.75, h: 1.45, fill: { color: "0F2530" }, line: { color: GREEN, width: 1 } });
    slide.addText(c.management, {
      x: 5.1, y: 3.92, w: 4.55, h: 1.3,
      fontSize: 11, color: GREEN
    });

    // Mini ECG thumbnail on answer slide
    if (img && !img.error) {
      slide.addImage({
        data: img.base64,
        x: 0.25, y: 4.28, w: 4.55, h: 1.2
      });
    }
  }
});

// ══════════════════════════════════════════════════════════════════════════════
// SUMMARY / QUICK REFERENCE SLIDE
// ══════════════════════════════════════════════════════════════════════════════
{
  let slide = pres.addSlide();
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: BG_DARK } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.65, fill: { color: ACCENT } });
  slide.addText("ECG Quick Reference Card", {
    x: 0.4, y: 0.08, w: 9.2, h: 0.5,
    fontSize: 22, bold: true, color: WHITE, align: "center"
  });

  const diagnoses = [
    ["AF", "Irregularly irregular, no P waves, narrow QRS"],
    ["A. Flutter", "Sawtooth ~300/min, regular rate ~150 (2:1)"],
    ["Inf. STEMI", "ST↑ II, III, aVF + reciprocal depression I, aVL"],
    ["Ant. STEMI", "ST↑ V1-V4 Β± I, aVL (LAD)"],
    ["PE", "S1Q3T3, sinus tachy, T inv V1-V4, RBBB pattern"],
    ["3Β° AV Block", "P waves + QRS independent, escape rate <40"],
    ["LBBB", "QRS β‰₯120ms, broad R V5/V6, QS in V1"],
    ["RBBB", "QRS β‰₯120ms, rSR' V1 (rabbit ears), wide S V6"],
    ["LVH", "SV1 + RV5/V6 >35mm, strain pattern I/aVL"],
    ["WPW", "Short PR, delta wave, wide QRS"],
  ];
  diagnoses.forEach(([dx, features], i) => {
    const col = i < 5 ? 0 : 1;
    const row = i < 5 ? i : i - 5;
    slide.addShape(pres.ShapeType.rect, {
      x: 0.2 + col * 4.9, y: 0.78 + row * 0.93, w: 4.65, h: 0.86,
      fill: { color: "0A1929" }, line: { color: "2A4A6A", width: 1 }
    });
    slide.addText(dx, {
      x: 0.3 + col * 4.9, y: 0.82 + row * 0.93, w: 1.1, h: 0.35,
      fontSize: 12, bold: true, color: GOLD
    });
    slide.addText(features, {
      x: 0.3 + col * 4.9, y: 1.14 + row * 0.93, w: 4.45, h: 0.4,
      fontSize: 10.5, color: LIGHT_TXT
    });
  });
}

// ── WRITE FILE ─────────────────────────────────────────────────────────────
const outputPath = "/home/daytona/workspace/ecg-practice-deck/ECG_Practice_Cases.pptx";
pres.writeFile({ fileName: outputPath }).then(() => {
  console.log(`βœ… Presentation saved to: ${outputPath}`);
}).catch(err => {
  console.error("Error writing file:", err);
  process.exit(1);
});
Running Command

cd /home/daytona/workspace/ecg-practice-deck && node build.js 2>&1

Running Command

cd /home/daytona/workspace/ecg-practice-deck # Fetch images one at a time and save each to a JSON file URLS=( "https://cdn.orris.care/cdss_images/c85541618159f7da9530493cfb243ab6826c7ea2c50edece5d0bd203ac7f6bb6.png" "https://cdn.orris.care/cdss_images/e30f337203edbe720805bc753caca4b6ae448f7e006d83ca604f83e144d2f782.png" "https://cdn.orris.care/cdss_images/dc6d5cd22f8672f0b27b85a097c90de9ee666d76b0d0e89b4b46115b0fe5f154.png" "https://cdn.orris.care/cdss_images/2892df61f6a4e33f8814ab62d11c2ad4ffb8a3cb8023eeeb775ea3cf982cde82.png" "https://cdn.orris.care/cdss_images/28043f05c25edcd2ef040a7618f8d8af42facf9c194292f826202ab262a09da3.png" "https://cdn.orris.care/cdss_images/012b4fbfc7465f18d6c3598dd526531fd9e11dcda15d8da6c0faae3de3d1520f.png" "https://cdn.orris.care/cdss_images/261b1c6b1574e2e999daf13b011387a0122373806c4f1abfa30243401b33c870.png" "https://cdn.orris.care/cdss_images/17684e22a76b3488c70edf5d6e238d7feaf1c716f9e05f1e73b4e1deb5429cb4.png" "https://cdn.orris.care/cdss_images/ce8f5f11790c18bb6281489bc410aada31d4b45782ce90e05721fccf4be3822e.png" "https://cdn.orris.care/cdss_images/591d741e2ea55e526228f79f8dd6a2cf080b0626906cbf806282e2992df06b17.png" ) mkdir -p imgs for i in "${!URLS[@]}"; do node /home/daytona/skills/shared/scripts/fetch_images.js "${URLS[$i]}" > "imgs/img${i}.json" echo "Fetched image $i" done echo "All done"

Running Command

cd /home/daytona/workspace/ecg-practice-deck && mkdir -p imgs && node -e " const { execSync } = require('child_process'); const urls = [ 'https://cdn.orris.care/cdss_images/c85541618159f7da9530493cfb243ab6826c7ea2c50edece5d0bd203ac7f6bb6.png', 'https://cdn.orris.care/cdss_images/e30f337203edbe720805bc753caca4b6ae448f7e006d83ca604f83e144d2f782.png', 'https://cdn.orris.care/cdss_images/dc6d5cd22f8672f0b27b85a097c90de9ee666d76b0d0e89b4b46115b0fe5f154.png', 'https://cdn.orris.care/cdss_images/2892df61f6a4e33f8814ab62d11c2ad4ffb8a3cb8023eeeb775ea3cf982cde82.png', 'https://cdn.orris.care/cdss_images/28043f05c25edcd2ef040a7618f8d8af42facf9c194292f826202ab262a09da3.png', 'https://cdn.orris.care/cdss_images/012b4fbfc7465f18d6c3598dd526531fd9e11dcda15d8da6c0faae3de3d1520f.png', 'https://cdn.orris.care/cdss_images/261b1c6b1574e2e999daf13b011387a0122373806c4f1abfa30243401b33c870.png', 'https://cdn.orris.care/cdss_images/17684e22a76b3488c70edf5d6e238d7feaf1c716f9e05f1e73b4e1deb5429cb4.png', 'https://cdn.orris.care/cdss_images/ce8f5f11790c18bb6281489bc410aada31d4b45782ce90e05721fccf4be3822e.png', 'https://cdn.orris.care/cdss_images/591d741e2ea55e526228f79f8dd6a2cf080b0626906cbf806282e2992df06b17.png' ]; const fs = require('fs'); for (let i = 0; i < urls.length; i++) { const result = execSync(\`node /home/daytona/skills/shared/scripts/fetch_images.js \\\"\${urls[i]}\\\"\`); fs.writeFileSync(\`imgs/img\${i}.json\`, result); console.log('Saved img' + i + '.json, size=' + result.length); } console.log('All images fetched'); " 2>&1

Editing File

~/ecg-practice-deck/build.js

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/ecg-practice-deck/build.js'
Running Command

cd /home/daytona/workspace/ecg-practice-deck && node build.js 2>&1

Running Command

ls -lh /home/daytona/workspace/ecg-practice-deck/ECG_Practice_Cases.pptx

Your practice deck is ready (7.4 MB, 32 slides):

ECG Practice Cases

Presentation Β· PPTX


What's inside the deck:
The deck has 32 slides structured as: Title β†’ How to Use β†’ then 3 slides per case (Clinical Context β†’ ECG β†’ Answer), plus a final Quick Reference Card.
#ECG DiagnosisKey Teaching
1Atrial FibrillationIrregularly irregular, no P waves
2Inferior STEMI (RCA)ST↑ II/III/aVF, reciprocal I/aVL
3Anterior STEMI - distal LADST↑ V1-V3, no inferior reciprocal
4Anterior STEMI - proximal LADExtensive ST↑, high mortality
5Pulmonary Embolism - S1Q3T3Right heart strain pattern
6Atrial Flutter 2:1Sawtooth waves, rate = 150
7High-Grade AV BlockP waves + QRS intermittently dissociated
8PAC triggering AFHow AF starts - pulmonary vein ectopy
9LBBB + Sgarbossa criteriaConcordant ST = MI in LBBB
10RV Infarction with inferior STEMIV4R ST↑, NO nitrates
Each answer slide includes: diagnosis banner, key ECG findings, teaching point, management pearl, and a mini ECG thumbnail for review.
This is a shared conversation. Sign in to Orris to start your own chat.