Electrolyte emergencies power point presentation for 20’minutes
ls /home/daytona/workspace/ 2>/dev/null && mkdir -p /home/daytona/workspace/elec…
~/electrolyte-pptx/build.js
const pptxgen = require("pptxgenjs");
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Electrolyte Emergencies";
pres.author = "Clinical Education";
// ── COLOR PALETTE ────────────────────────────────────────────────────────────
const C = {
navy: "0B1F3A", // dominant dark background
teal: "1A8C8A", // accent / section headers
gold: "E8A020", // highlight / warnings
white: "FFFFFF",
offWhite:"EBF0F5",
lightBg: "0D2B4E", // slightly lighter dark
red: "D94040", // danger / critical
green: "2EAD6A", // normal / treatment
gray: "8FA8BF", // secondary text
cardBg: "112F52", // card background
};
// ── HELPERS ──────────────────────────────────────────────────────────────────
function addBg(slide, color) {
slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:"100%", h:"100%", fill:{color} });
}
function sectionBanner(slide, title, subtitle) {
addBg(slide, C.navy);
// accent stripe left
slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:0.08, h:"100%", fill:{color: C.teal} });
slide.addShape(pres.ShapeType.rect, { x:0.08, y:0, w:0.04, h:"100%", fill:{color: C.gold} });
slide.addText(title, {
x:0.5, y:1.8, w:9, h:1.2,
fontSize:40, bold:true, color:C.white, fontFace:"Calibri",
align:"center"
});
if (subtitle) {
slide.addText(subtitle, {
x:0.5, y:3.1, w:9, h:0.7,
fontSize:20, color:C.teal, fontFace:"Calibri",
align:"center", italic:true
});
}
}
function slideTitle(slide, text, sub) {
// top bar
slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:"100%", h:1.0, fill:{color: C.navy} });
slide.addShape(pres.ShapeType.rect, { x:0, y:1.0, w:"100%", h:0.06, fill:{color: C.teal} });
slide.addShape(pres.ShapeType.rect, { x:0, y:1.06, w:"100%", h:0.03, fill:{color: C.gold} });
slide.addText(text, {
x:0.3, y:0.05, w:9.4, h:0.9,
fontSize:26, bold:true, color:C.white, fontFace:"Calibri",
valign:"middle"
});
if (sub) {
slide.addText(sub, {
x:0.3, y:0.85, w:9.4, h:0.22,
fontSize:11, color:C.teal, fontFace:"Calibri", italic:true
});
}
}
function card(slide, x, y, w, h, title, bullets, titleColor) {
slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill:{color: C.cardBg}, line:{color:C.teal, w:1} });
slide.addText(title, { x:x+0.1, y:y+0.05, w:w-0.2, h:0.35, fontSize:13, bold:true, color: titleColor||C.gold, fontFace:"Calibri" });
const items = bullets.map((b,i) => ({
text: b,
options: { bullet:{code:"25CF", color:C.teal, indent:10}, breakLine: i<bullets.length-1, fontSize:11, color:C.white, fontFace:"Calibri" }
}));
slide.addText(items, { x:x+0.1, y:y+0.42, w:w-0.2, h:h-0.52 });
}
function footerNote(slide, text) {
slide.addText(text, { x:0.3, y:5.28, w:9.4, h:0.28, fontSize:9, color:C.gray, italic:true, fontFace:"Calibri" });
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 1 — TITLE
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
// decorative gradient bands
sl.addShape(pres.ShapeType.rect, { x:0, y:0, w:"100%", h:"100%", fill:{color: C.navy} });
sl.addShape(pres.ShapeType.rect, { x:0, y:4.5, w:"100%", h:1.125, fill:{color: C.lightBg} });
sl.addShape(pres.ShapeType.rect, { x:0, y:4.47, w:"100%", h:0.06, fill:{color: C.teal} });
sl.addShape(pres.ShapeType.rect, { x:0, y:4.41, w:"100%", h:0.06, fill:{color: C.gold} });
sl.addText("⚡ ELECTROLYTE", { x:0.5, y:0.55, w:9, h:0.9, fontSize:52, bold:true, color:C.white, fontFace:"Calibri", align:"center", charSpacing:4 });
sl.addText("EMERGENCIES", { x:0.5, y:1.45, w:9, h:0.8, fontSize:52, bold:true, color:C.teal, fontFace:"Calibri", align:"center", charSpacing:4 });
sl.addText("Recognition · Assessment · Management", {
x:0.5, y:2.4, w:9, h:0.5, fontSize:18, color:C.gold, fontFace:"Calibri", align:"center", italic:true
});
sl.addShape(pres.ShapeType.rect, { x:3, y:3.0, w:4, h:0.04, fill:{color: C.teal} });
sl.addText("Na⁺ | K⁺ | Ca²⁺ | Mg²⁺ | Phosphate", {
x:0.5, y:3.15, w:9, h:0.4, fontSize:16, color:C.gray, fontFace:"Calibri", align:"center"
});
sl.addText("~20 minute clinical overview", { x:0.5, y:4.55, w:9, h:0.4, fontSize:13, color:C.gray, fontFace:"Calibri", align:"center", italic:true });
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 2 — OVERVIEW / AGENDA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "What We Will Cover Today");
const items = [
["1", "Hyponatremia", "Causes, symptoms, safe correction"],
["2", "Hypernatremia", "Assessment & rehydration strategy"],
["3", "Hypokalemia", "ECG changes, replacement protocols"],
["4", "Hyperkalemia", "Life-threatening — immediate steps"],
["5", "Hypocalcemia & Hypercalcemia", "Tetany to stones, bones & groans"],
["6", "Hypo/Hypermagnesemia", "The forgotten electrolyte"],
["7", "Hypophosphatemia", "Refeeding syndrome & beyond"],
];
items.forEach(([num, title, sub], i) => {
const x = (i < 4) ? 0.4 : 5.3;
const y = (i < 4) ? 1.3 + i * 0.9 : 1.3 + (i - 4) * 0.9;
sl.addShape(pres.ShapeType.rect, { x, y, w:0.38, h:0.38, fill:{color:C.teal}, line:{color:C.teal} });
sl.addText(num, { x, y, w:0.38, h:0.38, fontSize:14, bold:true, color:C.navy, align:"center", valign:"middle", fontFace:"Calibri" });
sl.addText(title, { x:x+0.45, y:y, w:4.0, h:0.22, fontSize:14, bold:true, color:C.white, fontFace:"Calibri" });
sl.addText(sub, { x:x+0.45, y:y+0.2, w:4.0, h:0.18, fontSize:10, color:C.gray, fontFace:"Calibri", italic:true });
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 3 — SECTION: SODIUM
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
sectionBanner(sl, "SODIUM DISORDERS", "Hyponatremia · Hypernatremia");
sl.addText("Normal range: 135 – 145 mEq/L", {
x:1, y:3.8, w:8, h:0.4, fontSize:14, color:C.gold, fontFace:"Calibri", align:"center"
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 4 — HYPONATREMIA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hyponatremia [Na⁺ < 135 mEq/L]", "Most common electrolyte disorder in hospitalized patients");
// Causes card
card(sl, 0.3, 1.25, 3.0, 3.9, "CAUSES", [
"Hypovolemic: vomiting, diarrhea, diuretics",
"Euvolemic: SIADH, hypothyroidism, adrenal insufficiency",
"Hypervolemic: HF, cirrhosis, nephrotic syndrome",
"Thiazides — 12× more likely than loop diuretics",
"Pseudohyponatremia: hyperglycemia, hyperlipidemia"
], C.gold);
// Symptoms card
card(sl, 3.45, 1.25, 2.9, 3.9, "SYMPTOMS", [
"Mild (>125): nausea, malaise, headache",
"Moderate: confusion, lethargy, falls",
"Severe (<120): seizures, coma, herniation",
"Chronic: subtle cognitive impairment, gait disturbance",
"Rapid onset → worse symptoms at higher Na⁺"
], C.gold);
// Treatment card
card(sl, 6.45, 1.25, 3.25, 3.9, "TREATMENT", [
"Symptomatic/severe: 3% NaCl 100 mL IV bolus",
"Goal: raise Na⁺ by 4–6 mEq/L in 1st hour",
"Max correction: ≤8–10 mEq/L per 24h",
"SIADH: fluid restrict ± tolvaptan",
"⚠️ Risk of osmotic demyelination syndrome (ODS) if overcorrected"
], C.red);
footerNote(sl, "Rosen's Emergency Medicine | Brenner & Rector's The Kidney");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 5 — HYPERNATREMIA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hypernatremia [Na⁺ > 145 mEq/L]", "Almost always indicates a water deficit");
card(sl, 0.3, 1.25, 3.0, 3.9, "CAUSES", [
"Free water loss: insensible losses, fever, burns",
"Diabetes insipidus (central or nephrogenic)",
"Osmotic diuresis: hyperglycemia, mannitol",
"Hypodipsia (elderly, impaired thirst mechanism)",
"Excessive Na⁺ administration (iatrogenic)"
], C.gold);
card(sl, 3.45, 1.25, 2.9, 3.9, "SYMPTOMS", [
"Thirst, restlessness, irritability",
"Lethargy → stupor → coma",
"Tachycardia, hypotension (if hypovolemic)",
"Muscle weakness, hyperreflexia",
"Seizures (especially in children, rapid rise)"
], C.gold);
card(sl, 6.45, 1.25, 3.25, 3.9, "TREATMENT", [
"Identify & treat underlying cause",
"Correct volume deficit with NS first if shocked",
"Then switch to D5W or 0.45% NaCl",
"Max correction: ≤10–12 mEq/L per 24h",
"Central DI: desmopressin (DDAVP)",
"⚠️ Rapid correction → cerebral edema"
], C.red);
footerNote(sl, "Roberts & Hedges' Clinical Procedures in Emergency Medicine | Current Surgical Therapy 14e");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 6 — SECTION: POTASSIUM
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
sectionBanner(sl, "POTASSIUM DISORDERS", "Hypokalemia · Hyperkalemia");
sl.addText("Normal range: 3.5 – 5.0 mEq/L | Primary intracellular cation", {
x:1, y:3.8, w:8, h:0.4, fontSize:14, color:C.gold, fontFace:"Calibri", align:"center"
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 7 — HYPOKALEMIA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hypokalemia [K⁺ < 3.5 mEq/L]", "Correct hypomagnesemia concurrently — refractory hypokalemia without Mg²⁺ replacement");
card(sl, 0.3, 1.25, 3.0, 3.9, "CAUSES", [
"GI losses: vomiting, diarrhea, ileostomy",
"Renal losses: diuretics (loop, thiazide)",
"Hyperaldosteronism (primary or secondary)",
"Transcellular shift: alkalosis, insulin, β-agonists",
"Poor intake (alcoholism, anorexia)"
], C.gold);
card(sl, 3.45, 1.25, 2.9, 3.9, "ECG + SYMPTOMS", [
"Flattened T-waves → U-waves",
"ST depression, prolonged QU interval",
"Ventricular ectopy, torsades de pointes",
"Muscle weakness, cramps, constipation",
"Rhabdomyolysis (severe, K⁺ <2.5 mEq/L)"
], C.gold);
card(sl, 6.45, 1.25, 3.25, 3.9, "TREATMENT", [
"Mild (3.0–3.5): oral KCl 40–60 mEq/day",
"Moderate (2.5–3.0): oral 60–80 mEq/day",
"Severe / unable to take oral: IV KCl",
"IV rate: max 10–20 mEq/hr peripheral",
"IV rate: up to 40 mEq/hr via central line",
"Replace Mg²⁺ concurrently if <0.8 mmol/L",
"Monitor ECG during IV replacement"
], C.green);
footerNote(sl, "Brenner & Rector's The Kidney, 11e | Henry's Clinical Diagnosis & Management");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 8 — HYPERKALEMIA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hyperkalemia [K⁺ > 5.0 mEq/L]", "⚠️ LIFE-THREATENING at >6.5 mEq/L — requires immediate action");
card(sl, 0.3, 1.25, 2.85, 3.9, "CAUSES", [
"AKI / CKD — most common",
"ACEi, ARBs, potassium-sparing diuretics",
"Adrenal insufficiency (Addison's disease)",
"Rhabdomyolysis, massive hemolysis",
"Transcellular shift: acidosis, DKA",
"Pseudohyperkalemia: hemolyzed sample"
], C.gold);
card(sl, 3.3, 1.25, 3.1, 3.9, "ECG PROGRESSION", [
"Peaked (tall, narrow) T-waves — earliest sign",
"Shortened QT interval",
"Prolonged PR, widened QRS",
"Sine wave pattern",
"Ventricular fibrillation / asystole",
"ECG changes can occur >6.0 mEq/L"
], C.red);
// Treatment steps — numbered
sl.addShape(pres.ShapeType.rect, { x:6.55, y:1.25, w:3.15, h:3.9, fill:{color:C.cardBg}, line:{color:C.red, w:1.5} });
sl.addText("TREATMENT (A-B-C-D-E)", { x:6.65, y:1.3, w:2.95, h:0.35, fontSize:12, bold:true, color:C.red, fontFace:"Calibri" });
const steps = [
["A", "Antagonize membrane", "Ca gluconate 1g IV — cardiac protection"],
["B", "Shift into cells", "Insulin 10u + D50W; Salbutamol neb"],
["C", "Correct acidosis", "NaHCO₃ if pH <7.2"],
["D", "Drive out (excrete)", "Furosemide, kayexalate/patiromer"],
["E", "Emergency dialysis", "If renal failure, refractory K⁺ >7.0"],
];
steps.forEach(([letter, phase, detail], i) => {
const y = 1.72 + i * 0.72;
sl.addShape(pres.ShapeType.rect, { x:6.65, y, w:0.3, h:0.3, fill:{color:C.red} });
sl.addText(letter, { x:6.65, y, w:0.3, h:0.3, fontSize:11, bold:true, color:C.white, align:"center", valign:"middle", fontFace:"Calibri" });
sl.addText(phase, { x:7.0, y, w:2.6, h:0.18, fontSize:11, bold:true, color:C.white, fontFace:"Calibri" });
sl.addText(detail, { x:7.0, y:y+0.17, w:2.6, h:0.18, fontSize:9, color:C.gray, fontFace:"Calibri" });
});
footerNote(sl, "Rosen's Emergency Medicine | Brenner & Rector | Goldman-Cecil Medicine");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 9 — SECTION: CALCIUM
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
sectionBanner(sl, "CALCIUM DISORDERS", "Hypocalcemia · Hypercalcemia");
sl.addText("Normal total Ca²⁺: 8.5 – 10.5 mg/dL | Ionized Ca²⁺: 1.15 – 1.35 mmol/L", {
x:0.5, y:3.8, w:9, h:0.4, fontSize:14, color:C.gold, fontFace:"Calibri", align:"center"
});
sl.addText("Correct total Ca²⁺ for albumin: Add 0.8 mg/dL per 1 g/dL albumin < 4 g/dL", {
x:0.5, y:4.2, w:9, h:0.35, fontSize:12, color:C.gray, fontFace:"Calibri", align:"center", italic:true
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 10 — HYPOCALCEMIA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hypocalcemia [Ca²⁺ < 8.5 mg/dL]", "Increased neuromuscular excitability — can be rapidly life-threatening");
card(sl, 0.3, 1.25, 3.0, 3.9, "CAUSES", [
"Hypoparathyroidism (post-thyroidectomy)",
"Vitamin D deficiency / malabsorption",
"Hypomagnesemia (impairs PTH secretion)",
"Massive transfusion (citrate binds Ca²⁺)",
"Acute pancreatitis, rhabdomyolysis",
"Sepsis, critical illness"
], C.gold);
card(sl, 3.45, 1.25, 2.9, 3.9, "SIGNS & SYMPTOMS", [
"Chvostek's sign: tap facial nerve → twitch",
"Trousseau's sign: BP cuff 3 min → carpopedal spasm",
"Tetany, perioral/fingertip paresthesias",
"Laryngospasm, bronchospasm (severe)",
"Seizures, prolonged QTc → TdP",
"Hypotension, heart failure"
], C.gold);
card(sl, 6.45, 1.25, 3.25, 3.9, "TREATMENT", [
"Symptomatic/severe: Ca gluconate 1–2g IV over 10–20 min",
"Repeat or infuse 0.5–1.5 mg/kg/hr",
"CaCl₂ (preferred if on vasopressors, 3× elemental Ca)",
"Oral: Ca carbonate + Vitamin D3 for chronic",
"Replace Mg²⁺ if deficient",
"Monitor ECG for QTc during IV treatment",
"⚠️ Avoid if digitalis toxicity suspected"
], C.green);
footerNote(sl, "Harrison's Principles of Internal Medicine 22E | Rosen's Emergency Medicine");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 11 — HYPERCALCEMIA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hypercalcemia [Ca²⁺ > 10.5 mg/dL]", "Stones · Bones · Groans · Psychic Moans");
// 4-quadrant mnemonic
const quads = [
{ label:"🪨 STONES", color:C.teal, x:0.3, y:1.2, items:["Nephrolithiasis","Nephrocalcinosis","Polyuria, polydipsia","Renal insufficiency"] },
{ label:"🦴 BONES", color:C.gold, x:5.2, y:1.2, items:["Bone pain","Osteoporosis","Osteitis fibrosa cystica","Subperiosteal resorption"] },
{ label:"😮💨 GROANS", color:C.red, x:0.3, y:3.3, items:["Nausea, vomiting","Constipation","Anorexia","Peptic ulcer, pancreatitis"] },
{ label:"🧠 PSYCHIC MOANS", color:"7E5BEF", x:5.2, y:3.3, items:["Depression","Anxiety","Confusion","Lethargy → coma (severe)"] },
];
quads.forEach(q => {
sl.addShape(pres.ShapeType.rect, { x:q.x, y:q.y, w:4.6, h:2.0, fill:{color:C.cardBg}, line:{color:q.color, w:1.5} });
sl.addText(q.label, { x:q.x+0.1, y:q.y+0.05, w:4.4, h:0.32, fontSize:13, bold:true, color:q.color, fontFace:"Calibri" });
const txt = q.items.map((t,i)=>({ text:t, options:{bullet:{code:"25CF",color:q.color}, breakLine:i<q.items.length-1, fontSize:11, color:C.white, fontFace:"Calibri"} }));
sl.addText(txt, { x:q.x+0.1, y:q.y+0.42, w:4.4, h:1.5 });
});
// Causes bar
sl.addShape(pres.ShapeType.rect, { x:0.3, y:5.1, w:9.4, h:0.35, fill:{color:C.lightBg} });
sl.addText("TOP CAUSES: Hyperparathyroidism (outpatient) · Malignancy (inpatient) · Thiazides · Sarcoidosis · Vitamin D toxicity", {
x:0.3, y:5.1, w:9.4, h:0.35, fontSize:10, color:C.gold, fontFace:"Calibri", align:"center", bold:true
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 12 — HYPERCALCEMIA TREATMENT
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hypercalcemia — Management", "Ca²⁺ >14 mg/dL or symptomatic = Emergency");
const steps = [
{ step:"1st", color:C.teal, title:"IV Fluids (immediate)", detail:"0.9% NaCl 200–300 mL/hr — restores GFR, promotes calciuresis\nTarget urine output 100–150 mL/hr" },
{ step:"2nd", color:C.gold, title:"IV Bisphosphonates (24–48h effect)", detail:"Zoledronic acid 4 mg IV over 15 min OR\nPamidronate 60–90 mg IV over 2–4h" },
{ step:"3rd", color:"7E5BEF", title:"Calcitonin (rapid, short-lived)", detail:"4 IU/kg IM/SC q12h — effect in hours, tachyphylaxis in 48h\nBridges until bisphosphonate takes effect" },
{ step:"4th", color:C.red, title:"Cinacalcet / Denosumab / Dialysis", detail:"Malignancy-related: denosumab 120 mg SC\nHemodialysis for severe, refractory hypercalcemia\nPrimary hyperPTH → definitive parathyroidectomy" },
];
steps.forEach((s, i) => {
const y = 1.3 + i * 1.0;
sl.addShape(pres.ShapeType.rect, { x:0.3, y, w:0.7, h:0.75, fill:{color:s.color} });
sl.addText(s.step, { x:0.3, y, w:0.7, h:0.75, fontSize:14, bold:true, color:C.navy, align:"center", valign:"middle", fontFace:"Calibri" });
sl.addText(s.title, { x:1.1, y:y+0.02, w:8.6, h:0.28, fontSize:14, bold:true, color:C.white, fontFace:"Calibri" });
sl.addText(s.detail, { x:1.1, y:y+0.3, w:8.6, h:0.45, fontSize:11, color:C.gray, fontFace:"Calibri" });
});
footerNote(sl, "Harrison's 22E | Goldman-Cecil Medicine | Rosen's Emergency Medicine");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 13 — SECTION: MAGNESIUM
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
sectionBanner(sl, "MAGNESIUM DISORDERS", "Hypomagnesemia · Hypermagnesemia");
sl.addText("Normal range: 1.7 – 2.2 mg/dL (0.7–0.9 mmol/L) | Second most abundant intracellular cation", {
x:0.3, y:3.8, w:9.4, h:0.4, fontSize:14, color:C.gold, fontFace:"Calibri", align:"center"
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 14 — HYPO/HYPERMAGNESEMIA
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Magnesium Disorders", "Often coexists with hypokalemia and hypocalcemia");
// Hypomagnesemia
sl.addShape(pres.ShapeType.rect, { x:0.3, y:1.2, w:4.6, h:4.25, fill:{color:C.cardBg}, line:{color:C.teal, w:1.5} });
sl.addText("HYPOMAGNESEMIA (Mg²⁺ < 1.7 mg/dL)", { x:0.4, y:1.25, w:4.4, h:0.35, fontSize:13, bold:true, color:C.teal, fontFace:"Calibri" });
const hypoMg = [
"Causes: Alcohol abuse, PPI use, diuretics, DM, diarrhea, malabsorption",
"Features: Tremor, tetany, seizures, arrhythmias, weakness",
"Enhances digoxin toxicity",
"Causes refractory hypokalemia and hypocalcemia",
"ECG: prolonged QT, Torsades de Pointes",
"Tx (severe): MgSO₄ 1–2g IV over 5–10 min",
"Tx (moderate): MgSO₄ 1–2g IV over 1h",
"Tx (mild): Oral Mg oxide 400–800 mg/day"
];
sl.addText(hypoMg.map((t,i)=>({text:t,options:{bullet:{code:"25CF",color:C.teal},breakLine:i<hypoMg.length-1,fontSize:11,color:C.white,fontFace:"Calibri"}})),
{ x:0.4, y:1.65, w:4.4, h:3.7 });
// Hypermagnesemia
sl.addShape(pres.ShapeType.rect, { x:5.1, y:1.2, w:4.6, h:4.25, fill:{color:C.cardBg}, line:{color:C.red, w:1.5} });
sl.addText("HYPERMAGNESEMIA (Mg²⁺ > 2.2 mg/dL)", { x:5.2, y:1.25, w:4.4, h:0.35, fontSize:13, bold:true, color:C.red, fontFace:"Calibri" });
const hyperMg = [
"Causes: Renal failure (most common), antacid/laxative overuse, Mg-containing IV fluids",
"Levels & effects:",
"4–5 mg/dL: Loss of deep tendon reflexes (earliest sign)",
"5–7 mg/dL: Somnolence, hypotension, bradycardia",
"7–10 mg/dL: Respiratory paralysis",
">12 mg/dL: Cardiac arrest",
"Tx: IV Ca gluconate 1–2g (antagonizes membrane effects)",
"IV fluids + furosemide (promotes Mg excretion)",
"Dialysis if renal failure"
];
sl.addText(hyperMg.map((t,i)=>({text:t,options:{bullet:{code:"25CF",color:C.red},breakLine:i<hyperMg.length-1,fontSize:10.5,color:C.white,fontFace:"Calibri"}})),
{ x:5.2, y:1.65, w:4.4, h:3.7 });
footerNote(sl, "Brenner & Rector's The Kidney | Henry's Clinical Diagnosis | Rosen's Emergency Medicine");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 15 — SECTION: PHOSPHATE
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Hypophosphatemia [PO₄³⁻ < 2.5 mg/dL]", "Refeeding syndrome · Critical illness · Essential for ATP synthesis");
card(sl, 0.3, 1.25, 3.0, 3.9, "CAUSES", [
"Refeeding syndrome (most dangerous)",
"Malnutrition / alcoholism",
"Hyperparathyroidism (↑ renal excretion)",
"Vitamin D deficiency",
"Antacid overuse (bind PO₄ in gut)",
"DKA treatment (insulin drives shift)",
"Post-renal transplant"
], C.gold);
card(sl, 3.45, 1.25, 2.9, 3.9, "FEATURES", [
"Mild (1.0–2.5): often asymptomatic",
"Moderate to severe (<1.0):",
"Muscle weakness, rhabdomyolysis",
"Respiratory failure (diaphragm weakness)",
"Hemolysis (RBC ATP depletion)",
"Encephalopathy, seizures",
"Heart failure (impaired myocardial contractility)"
], C.gold);
card(sl, 6.45, 1.25, 3.25, 3.9, "TREATMENT", [
"Mild-mod: oral sodium or K phosphate",
"Severe (<1.0) / symptomatic: IV phosphate",
"IV dose: 0.08–0.16 mmol/kg over 6h",
"Refeeding: slow caloric introduction",
"Max 2,500 kcal/day initially",
"Monitor K⁺, Mg²⁺, Ca²⁺ concurrently",
"⚠️ IV Ca + IV phosphate → precipitate"
], C.green);
footerNote(sl, "Harrison's Principles of Internal Medicine 22E | Goldman-Cecil Medicine");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 16 — QUICK REFERENCE TABLE
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Quick Reference: Electrolyte Emergencies at a Glance");
const headers = ["Electrolyte", "Critical Value", "ECG Change", "1st Immediate Action"];
const rows = [
["Hyponatremia", "< 120 mEq/L", "No specific change", "3% NaCl 100 mL IV bolus, raise Na 4-6 over 1h"],
["Hypernatremia", "> 160 mEq/L", "Tachycardia (sinus)", "0.9% NS if shocked → switch D5W / 0.45% NaCl"],
["Hypokalemia", "< 2.5 mEq/L", "U-waves, T flatten, TdP", "IV KCl ≤20 mEq/hr; replace Mg²⁺"],
["Hyperkalemia", "> 6.5 mEq/L", "Peaked T → wide QRS → sine", "Ca gluconate 1g IV immediately"],
["Hypocalcemia", "< 7.0 mg/dL", "Prolonged QTc, TdP", "Ca gluconate 1–2g IV over 10–20 min"],
["Hypercalcemia", "> 14 mg/dL", "Short QT, bradycardia", "IV 0.9% NaCl 200–300 mL/hr"],
["Hypomagnesemia", "< 1.0 mg/dL", "Prolonged QT, TdP", "MgSO₄ 2g IV over 5–10 min"],
["Hypophosphatemia", "< 1.0 mg/dL", "None specific", "IV phosphate 0.08–0.16 mmol/kg over 6h"],
];
const colW = [2.2, 1.7, 2.4, 3.4];
const colX = [0.25, 2.45, 4.15, 6.55];
const rowH = 0.44;
const startY = 1.2;
// Header row
colX.forEach((x, ci) => {
sl.addShape(pres.ShapeType.rect, { x, y:startY, w:colW[ci], h:0.42, fill:{color:C.teal} });
sl.addText(headers[ci], { x:x+0.05, y:startY, w:colW[ci]-0.1, h:0.42, fontSize:11, bold:true, color:C.navy, fontFace:"Calibri", valign:"middle" });
});
rows.forEach((row, ri) => {
const y = startY + 0.42 + ri * rowH;
const bg = ri % 2 === 0 ? C.cardBg : C.navy;
colX.forEach((x, ci) => {
sl.addShape(pres.ShapeType.rect, { x, y, w:colW[ci], h:rowH, fill:{color:bg} });
const textColor = ci === 0 ? C.gold : C.white;
sl.addText(row[ci], { x:x+0.05, y, w:colW[ci]-0.1, h:rowH, fontSize:9.5, color:textColor, fontFace:"Calibri", valign:"middle", bold:ci===0 });
});
});
footerNote(sl, "Values are clinical thresholds; always interpret in clinical context");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 17 — PEARLS & PITFALLS
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Clinical Pearls & Common Pitfalls");
const pearls = [
["💎", "Correct Na⁺ for glucose: for every 100 mg/dL ↑ glucose above 100, Na⁺ drops ~1.6 mEq/L (use 2.4 in severe hyperglycemia)"],
["💎", "Check Mg²⁺ in every patient with hypokalemia or hypocalcemia — you cannot fix K⁺ without fixing Mg²⁺"],
["💎", "Hyperkalemia ECG changes are unreliable — treat based on lab value + clinical context, not ECG alone"],
["💎", "Symptomatic hypocalcemia → Ca gluconate IV, never IM or subcutaneous; monitor ECG during infusion"],
["💎", "Refeeding syndrome: Start nutrition slowly, supplement K⁺, Mg²⁺, PO₄³⁻ before and during refeeding"],
];
const pitfalls = [
["⚠️", "Overcorrecting hyponatremia >10–12 mEq/L per day → osmotic demyelination syndrome (central pontine myelinolysis)"],
["⚠️", "Overcorrecting hypernatremia >10–12 mEq/L per day → cerebral edema, seizures"],
["⚠️", "Calcium + digoxin toxicity: Ca²⁺ is NOT absolutely contraindicated, but Digoxin-Fab is the priority treatment"],
["⚠️", "Pseudohyperkalemia: hemolyzed blood sample — always repeat if unexpected result or no ECG changes"],
["⚠️", "Giving IV Ca²⁺ and IV phosphate in the same line → calcium phosphate precipitation (potentially fatal)"],
];
sl.addText("PEARLS", { x:0.3, y:1.15, w:4.6, h:0.3, fontSize:13, bold:true, color:C.teal, fontFace:"Calibri" });
sl.addText("PITFALLS", { x:5.1, y:1.15, w:4.6, h:0.3, fontSize:13, bold:true, color:C.red, fontFace:"Calibri" });
pearls.forEach(([icon, text], i) => {
const y = 1.5 + i * 0.73;
sl.addText(`${icon} ${text}`, { x:0.3, y, w:4.6, h:0.7, fontSize:10, color:C.white, fontFace:"Calibri", valign:"top" });
});
pitfalls.forEach(([icon, text], i) => {
const y = 1.5 + i * 0.73;
sl.addText(`${icon} ${text}`, { x:5.1, y, w:4.6, h:0.7, fontSize:10, color:C.white, fontFace:"Calibri", valign:"top" });
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 18 — WHEN TO CALL FOR HELP / ADMIT
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Disposition & Escalation — When to Escalate");
const criteria = [
{ condition:"Hyponatremia", admit:"Na⁺ <125 or any neurological symptoms", icu:"Na⁺ <120 with seizures/coma or Na⁺ changing rapidly" },
{ condition:"Hypernatremia", admit:"Na⁺ >150 with symptoms or poor oral intake", icu:"Na⁺ >165 or hemodynamic compromise" },
{ condition:"Hypokalemia", admit:"K⁺ <3.0 with symptoms or ECG changes", icu:"K⁺ <2.5 or VT/VF" },
{ condition:"Hyperkalemia", admit:"K⁺ >5.5 with any symptoms or ECG changes", icu:"K⁺ >6.5 or ECG changes — EMERGENT" },
{ condition:"Hypocalcemia", admit:"iCa <0.9 mmol/L or symptomatic", icu:"Tetany, laryngospasm, seizures, arrhythmia" },
{ condition:"Hypercalcemia", admit:"Ca²⁺ >12 mg/dL or symptomatic", icu:"Ca²⁺ >14 mg/dL or altered mental status" },
];
const cols = ["Electrolyte", "Admit Threshold", "ICU / Emergent"];
const colW2 = [2.0, 3.8, 3.8];
const colX2 = [0.25, 2.25, 6.05];
colX2.forEach((x, ci) => {
sl.addShape(pres.ShapeType.rect, { x, y:1.2, w:colW2[ci], h:0.38, fill:{color:C.teal} });
sl.addText(cols[ci], { x:x+0.05, y:1.2, w:colW2[ci]-0.1, h:0.38, fontSize:12, bold:true, color:C.navy, fontFace:"Calibri", valign:"middle" });
});
criteria.forEach((row, ri) => {
const y = 1.58 + ri * 0.6;
const bg = ri % 2 === 0 ? C.cardBg : C.navy;
[row.condition, row.admit, row.icu].forEach((val, ci) => {
sl.addShape(pres.ShapeType.rect, { x:colX2[ci], y, w:colW2[ci], h:0.58, fill:{color:bg} });
sl.addText(val, { x:colX2[ci]+0.05, y, w:colW2[ci]-0.1, h:0.58, fontSize:9.5, color:ci===0?C.gold:C.white, fontFace:"Calibri", valign:"middle", bold:ci===0 });
});
});
footerNote(sl, "Clinical thresholds — always use clinical judgment; consult nephrology/ICU as needed");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 19 — SUMMARY
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
slideTitle(sl, "Key Takeaways");
const points = [
["Na⁺", "Correct slowly (max 8–10 mEq/L/day) — in BOTH directions. Use 3% NaCl for symptomatic hyponatremia."],
["K⁺", "Hyperkalemia with ECG changes = Calcium gluconate NOW. Always fix Mg²⁺ when replacing K⁺."],
["Ca²⁺", "Hypocalcemia: Ca gluconate IV + ECG monitoring. Hypercalcemia: fluids first, then bisphosphonates."],
["Mg²⁺", "The hidden key — drives hypokalemia and hypocalcemia resistance. MgSO₄ 2g IV for TdP/severe."],
["PO₄³⁻", "Refeeding syndrome is preventable. Start feeds slowly; replace PO₄, K⁺, Mg²⁺ prophylactically."],
["ECG", "Get a 12-lead ECG on every significant electrolyte disturbance — it guides urgency of treatment."],
];
points.forEach(([label, text], i) => {
const y = 1.3 + i * 0.67;
sl.addShape(pres.ShapeType.rect, { x:0.3, y, w:0.75, h:0.52, fill:{color:C.teal} });
sl.addText(label, { x:0.3, y, w:0.75, h:0.52, fontSize:13, bold:true, color:C.navy, align:"center", valign:"middle", fontFace:"Calibri" });
sl.addText(text, { x:1.15, y:y+0.02, w:8.6, h:0.52, fontSize:12, color:C.white, fontFace:"Calibri", valign:"middle" });
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 20 — FINAL / REFERENCES
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl, C.navy);
sl.addShape(pres.ShapeType.rect, { x:0, y:0, w:"100%", h:1.4, fill:{color:C.teal} });
sl.addText("Thank You", { x:0.5, y:0.1, w:9, h:0.8, fontSize:38, bold:true, color:C.navy, fontFace:"Calibri", align:"center" });
sl.addText("Questions & Discussion", { x:0.5, y:0.9, w:9, h:0.4, fontSize:18, color:C.navy, fontFace:"Calibri", align:"center", italic:true });
sl.addText("References", { x:0.5, y:1.6, w:9, h:0.35, fontSize:14, bold:true, color:C.gold, fontFace:"Calibri" });
const refs = [
"1. Walls RM et al. Rosen's Emergency Medicine: Concepts and Clinical Practice, 10th ed. Elsevier, 2023.",
"2. Brenner BM, Rector FC. Brenner and Rector's The Kidney, 11th ed. Elsevier, 2020.",
"3. Goldman L, Schafer AI. Goldman-Cecil Medicine, 26th ed. Elsevier, 2024.",
"4. Longo DL et al. Harrison's Principles of Internal Medicine, 22nd ed. McGraw-Hill, 2025.",
"5. Roberts JR, Custalow CB. Roberts and Hedges' Clinical Procedures in Emergency Medicine, 7th ed.",
"6. Henry JB. Henry's Clinical Diagnosis and Management by Laboratory Methods, 24th ed.",
"7. Miller RD et al. Miller's Anesthesia, 10th ed. Elsevier, 2023.",
];
refs.forEach((r, i) => {
sl.addText(r, { x:0.5, y:2.0 + i * 0.43, w:9, h:0.38, fontSize:10, color:C.gray, fontFace:"Calibri" });
});
}
// ─────────────────────────────────────────────────────────────────────────────
// WRITE FILE
// ─────────────────────────────────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/electrolyte-pptx/Electrolyte_Emergencies.pptx";
pres.writeFile({ fileName: outPath }).then(() => {
console.log("DONE: " + outPath);
}).catch(err => {
console.error("ERROR:", err);
process.exit(1);
});
cd /home/daytona/workspace/electrolyte-pptx && node build.js 2>&1
ls -lh /home/daytona/workspace/electrolyte-pptx/Electrolyte_Emergencies.pptx
Electrolyte Emergencies
Presentation · PPTX
| Slide | Content |
|---|---|
| 1 | Title slide — "Electrolyte Emergencies: Recognition · Assessment · Management" |
| 2 | Agenda overview with 7 topic tiles |
| 3 | Section divider — Sodium Disorders |
| 4 | Hyponatremia — Causes / Symptoms / Treatment (3% NaCl, ODS warning, correction limits) |
| 5 | Hypernatremia — Causes / Symptoms / Treatment (DDAVP for DI, rehydration strategy) |
| 6 | Section divider — Potassium Disorders |
| 7 | Hypokalemia — ECG changes (U-waves, TdP), IV/oral replacement protocols, Mg co-replacement |
| 8 | Hyperkalemia — ECG progression (peaked T → sine wave), A-B-C-D-E treatment steps |
| 9 | Section divider — Calcium Disorders (albumin correction formula) |
| 10 | Hypocalcemia — Chvostek's, Trousseau's, Ca gluconate vs CaCl₂, QTc monitoring |
| 11 | Hypercalcemia — "Stones, Bones, Groans, Psychic Moans" 4-quadrant visual |
| 12 | Hypercalcemia Management — stepwise: fluids → bisphosphonates → calcitonin → dialysis |
| 13 | Section divider — Magnesium Disorders |
| 14 | Hypo/Hypermagnesemia — side-by-side comparison, DTR loss, respiratory paralysis levels |
| 15 | Hypophosphatemia — Refeeding syndrome, ATP depletion consequences, IV phosphate dosing |
| 16 | Quick Reference Table — all 8 disorders: critical value / ECG change / immediate action |
| 17 | Clinical Pearls & Pitfalls — 5 pearls + 5 common errors to avoid |
| 18 | Disposition & Escalation — admit vs ICU thresholds for each disorder |
| 19 | Key Takeaways — one sentence per electrolyte |
| 20 | Thank You + 7 textbook references (Rosen's, Brenner, Harrison's, Goldman-Cecil, etc.) |