Write a IAP and NELSON based essay for my MD PEDIATRIC THEORY Exam on topic Magnesium
IAP guidelines magnesium pediatric hypomagnesemia hypermagnesemia management India 2023 2024
| Age Group | Normal Serum Mg (mg/dL) | mmol/L |
|---|---|---|
| Neonates | 1.5 - 2.3 | 0.62 - 0.95 |
| Infants/Children | 1.7 - 2.5 | 0.70 - 1.03 |
| Adolescents/Adults | 1.8 - 2.6 | 0.74 - 1.07 |
| Indication | Dose | Rate |
|---|---|---|
| Symptomatic hypomagnesemia / Seizures | 25-50 mg/kg IV (max 2 g) | Over 10-20 min |
| Torsades de pointes | 25-50 mg/kg IV (max 2 g) | Over 1-5 min (emergency) |
| Asthma (severe, refractory) | 40 mg/kg/day IV (max 2 g) | Over 20 min |
| Eclampsia prophylaxis (adolescent) | 4-6 g loading dose | Over 20 min |
| Maintenance infusion | 25-50 mg/kg/day | Continuous |
| Serum Magnesium (mg/dL) | Clinical Effects |
|---|---|
| 4 - 5 | Decreased deep tendon reflexes (first sign), nausea, vomiting, flushing, headache |
| 5 - 7 | Hypotension, somnolence, weakness, confusion, ECG changes (prolonged PR, widened QRS, QT prolongation) |
| 7 - 10 | Loss of DTR, respiratory muscle weakness, constipation, urinary retention |
| > 10 | Respiratory insufficiency/arrest, complete heart block |
| 10 - 15 | Heart block, bradycardia |
| 10 - 24 | Cardiac arrest |
| Disorder | Gene | Inheritance | Features |
|---|---|---|---|
| Primary hypomagnesemia with secondary hypocalcemia | TRPM6 | AR | Neonatal seizures, severe hypomagnesemia, hypocalcemia |
| FHHNC (Familial Hypomagnesemia, Hypercalciuria, Nephrocalcinosis) | CLDN16, CLDN19 | AR | Renal Mg wasting, nephrocalcinosis, renal failure |
| Autosomal dominant hypomagnesemia | KCNA1 | AD | Muscle cramps, tremors |
| Hypomagnesemia with seizures and mental impairment | CNNM2 | AD | Seizures, cognitive impairment |
| Gitelman syndrome | SLC12A3 | AR | Hypomagnesemia, hypokalemia, hypocalciuria, metabolic alkalosis |
| Bartter syndrome Type III | CLCNKB | AR | Hypomagnesemia, hypokalemia, metabolic alkalosis |
Suspected hypomagnesemia
↓
Check serum Mg, Ca, K, PO4 + ECG
↓
Confirm Serum Mg < 1.7 mg/dL
↓
Symptomatic? (Seizures, tetany, arrhythmia)
YES NO
↓ ↓
IV MgSO4 Oral Mg replacement
25-50 mg/kg + treat cause
(max 2g) over
10-20 min
↓
FEMg (Fractional Excretion of Mg)
> 2% = Renal wasting < 2% = GI losses
(drugs, tubular disorders) (diarrhea, malabsorption)
↓
Treat underlying cause, continue replenishment
Monitor: DTR, RR, urine output, ECG, serum Mg q4-6h
Generate a Word document version formatted for print-friendly studying
ls /home/daytona/workspace/ 2>/dev/null && ls /home/daytona/skills/docx/
mkdir -p /home/daytona/workspace/magnesium-essay && node -e "require('docx'); co…
~/magnesium-essay/generate.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
Header, Footer, AlignmentType, HeadingLevel, BorderStyle, WidthType,
ShadingType, VerticalAlign, PageNumber, NumberFormat, UnderlineType,
convertInchesToTwip, TableLayoutType
} = require('docx');
const fs = require('fs');
// ─── COLOUR PALETTE ──────────────────────────────────────────────────────────
const DARK_BLUE = "1A3A5C";
const MID_BLUE = "2E6DA4";
const ACCENT_BLUE = "D6E4F0";
const LIGHT_GRAY = "F2F4F7";
const BORDER_GRAY = "AAAAAA";
const TABLE_HDR = "1A3A5C";
const WHITE = "FFFFFF";
const TEXT_BLACK = "1A1A1A";
const WARN_AMBER = "FFF3CD";
const WARN_BORDER = "D4A017";
// ─── HELPER: EMPTY LINE ───────────────────────────────────────────────────────
const emptyLine = (sz = 4) => new Paragraph({
children: [new TextRun({ text: "", size: sz })],
spacing: { before: 0, after: 0 }
});
// ─── HELPER: BOLD INLINE TEXT ─────────────────────────────────────────────────
const b = (text, opts = {}) => new TextRun({ text, bold: true, ...opts });
const t = (text, opts = {}) => new TextRun({ text, ...opts });
// ─── HEADING 1 ────────────────────────────────────────────────────────────────
function h1(text) {
return new Paragraph({
children: [
new TextRun({
text: text.toUpperCase(),
bold: true,
size: 28,
color: WHITE,
font: "Calibri"
})
],
heading: HeadingLevel.HEADING_1,
shading: { type: ShadingType.SOLID, color: DARK_BLUE },
spacing: { before: 280, after: 120 },
indent: { left: convertInchesToTwip(0.1), right: convertInchesToTwip(0.1) }
});
}
// ─── HEADING 2 ────────────────────────────────────────────────────────────────
function h2(text) {
return new Paragraph({
children: [
new TextRun({
text,
bold: true,
size: 24,
color: WHITE,
font: "Calibri"
})
],
heading: HeadingLevel.HEADING_2,
shading: { type: ShadingType.SOLID, color: MID_BLUE },
spacing: { before: 200, after: 80 },
indent: { left: convertInchesToTwip(0.05) }
});
}
// ─── HEADING 3 ────────────────────────────────────────────────────────────────
function h3(text) {
return new Paragraph({
children: [
new TextRun({
text,
bold: true,
size: 22,
color: DARK_BLUE,
font: "Calibri",
underline: { type: UnderlineType.SINGLE, color: MID_BLUE }
})
],
heading: HeadingLevel.HEADING_3,
spacing: { before: 160, after: 60 }
});
}
// ─── BODY PARAGRAPH ───────────────────────────────────────────────────────────
function bodyPara(runs, opts = {}) {
return new Paragraph({
children: Array.isArray(runs) ? runs : [new TextRun({ text: runs, size: 20, color: TEXT_BLACK, font: "Calibri" })],
spacing: { before: 60, after: 60 },
...opts
});
}
// ─── BULLET POINT ─────────────────────────────────────────────────────────────
function bullet(text, level = 0, bold = false) {
return new Paragraph({
children: [new TextRun({ text, size: 20, bold, color: TEXT_BLACK, font: "Calibri" })],
bullet: { level },
spacing: { before: 40, after: 40 },
indent: { left: convertInchesToTwip(0.25 + level * 0.25) }
});
}
// ─── CALLOUT BOX (shaded paragraph) ─────────────────────────────────────────
function callout(text, bgColor = ACCENT_BLUE, textColor = DARK_BLUE, bold = false) {
return new Paragraph({
children: [new TextRun({ text, size: 20, bold, color: textColor, font: "Calibri" })],
shading: { type: ShadingType.SOLID, color: bgColor },
border: {
left: { style: BorderStyle.THICK, size: 12, color: MID_BLUE },
top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY },
bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY },
right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY }
},
spacing: { before: 80, after: 80 },
indent: { left: convertInchesToTwip(0.15), right: convertInchesToTwip(0.15) }
});
}
// ─── AMBER WARNING BOX ────────────────────────────────────────────────────────
function warningBox(text) {
return new Paragraph({
children: [new TextRun({ text: "⚠ " + text, size: 20, bold: true, color: "7B5800", font: "Calibri" })],
shading: { type: ShadingType.SOLID, color: WARN_AMBER },
border: {
left: { style: BorderStyle.THICK, size: 12, color: WARN_BORDER },
top: { style: BorderStyle.SINGLE, size: 4, color: WARN_BORDER },
bottom: { style: BorderStyle.SINGLE, size: 4, color: WARN_BORDER },
right: { style: BorderStyle.SINGLE, size: 4, color: WARN_BORDER }
},
spacing: { before: 80, after: 80 },
indent: { left: convertInchesToTwip(0.15), right: convertInchesToTwip(0.15) }
});
}
// ─── TABLE HELPERS ────────────────────────────────────────────────────────────
function tCell(text, isHeader = false, width = null, colspan = 1, align = AlignmentType.LEFT) {
const opts = {
children: [new Paragraph({
children: [new TextRun({
text,
bold: isHeader,
size: isHeader ? 19 : 18,
color: isHeader ? WHITE : TEXT_BLACK,
font: "Calibri"
})],
alignment: align,
spacing: { before: 40, after: 40 }
})],
shading: isHeader ? { type: ShadingType.SOLID, color: TABLE_HDR } : undefined,
verticalAlign: VerticalAlign.CENTER,
margins: { top: 60, bottom: 60, left: 100, right: 100 }
};
if (width) opts.width = { size: width, type: WidthType.DXA };
if (colspan > 1) opts.columnSpan = colspan;
return new TableCell(opts);
}
function makeTable(headers, rows, colWidths = null) {
const numCols = headers.length;
const defaultWidth = Math.floor(9000 / numCols);
const tableRows = [
new TableRow({
children: headers.map((h, i) =>
tCell(h, true, colWidths ? colWidths[i] : defaultWidth)
),
tableHeader: true
}),
...rows.map((row, ri) =>
new TableRow({
children: row.map((cell, ci) => {
const cellEl = tCell(cell, false, colWidths ? colWidths[ci] : defaultWidth);
if (ri % 2 === 1) {
cellEl.options = cellEl.options || {};
// alternate row shading
}
return cellEl;
})
})
)
];
return new Table({
rows: tableRows,
width: { size: 100, type: WidthType.PERCENTAGE },
layout: TableLayoutType.FIXED,
margins: { top: 60, bottom: 60, left: 0, right: 0 },
borders: {
top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY },
bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY },
left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY },
right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY },
insideH:{ style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY },
insideV:{ style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY }
}
});
}
// ─── PAGE BREAK ───────────────────────────────────────────────────────────────
function pageBreak() {
return new Paragraph({ pageBreakBefore: true, children: [] });
}
// ─── DOCUMENT ─────────────────────────────────────────────────────────────────
const children = [
// ── TITLE PAGE ──────────────────────────────────────────────────────────────
new Paragraph({
children: [new TextRun({ text: "MAGNESIUM IN PEDIATRICS", bold: true, size: 52, color: DARK_BLUE, font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: convertInchesToTwip(1.5), after: 120 }
}),
new Paragraph({
children: [new TextRun({ text: "MD Pediatrics Theory Examination Essay", size: 28, color: MID_BLUE, font: "Calibri", italics: true })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 60 }
}),
new Paragraph({
children: [new TextRun({ text: "Based on IAP Guidelines & Nelson's Textbook of Pediatrics", size: 24, color: "555555", font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 200 }
}),
new Paragraph({
children: [new TextRun({ text: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━", color: MID_BLUE, size: 24, font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 60 }
}),
new Paragraph({
children: [new TextRun({ text: "Topics Covered:", bold: true, size: 22, color: DARK_BLUE, font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 120, after: 60 }
}),
...["Physiology & Distribution", "Renal Handling of Magnesium", "Hypomagnesemia (Etiology, Features, Diagnosis, Treatment)", "Hypermagnesemia (Etiology, Level-Dependent Features, Treatment)", "Neonatal Hypermagnesemia", "Magnesium as Therapeutic Agent (Asthma, Arrhythmia, DKA, Eclampsia)", "Genetic Disorders of Mg Metabolism", "High-Yield Exam Summary Points"].map(item =>
new Paragraph({
children: [new TextRun({ text: "• " + item, size: 20, color: "444444", font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 30, after: 30 }
})
),
pageBreak(),
// ── SECTION 1: INTRODUCTION ──────────────────────────────────────────────────
h1("1. Introduction"),
bodyPara([
new TextRun({ text: "Magnesium (Mg", size: 20, color: TEXT_BLACK, font: "Calibri" }),
new TextRun({ text: "2+", size: 14, color: TEXT_BLACK, font: "Calibri", superScript: true }),
new TextRun({ text: ") is the ", size: 20, color: TEXT_BLACK, font: "Calibri" }),
new TextRun({ text: "second most abundant intracellular cation", bold: true, size: 20, color: TEXT_BLACK, font: "Calibri" }),
new TextRun({ text: " after potassium and the fourth most abundant cation in the body overall. It is indispensable for over 300 enzymatic reactions including ATP synthesis, DNA/RNA synthesis, protein synthesis, and neuromuscular transmission.", size: 20, color: TEXT_BLACK, font: "Calibri" })
]),
bodyPara([
new TextRun({ text: "In pediatric practice, disorders of magnesium homeostasis — both deficiency (", size: 20, color: TEXT_BLACK, font: "Calibri" }),
new TextRun({ text: "hypomagnesemia", bold: true, size: 20, color: TEXT_BLACK, font: "Calibri" }),
new TextRun({ text: ") and excess (", size: 20, color: TEXT_BLACK, font: "Calibri" }),
new TextRun({ text: "hypermagnesemia", bold: true, size: 20, color: TEXT_BLACK, font: "Calibri" }),
new TextRun({ text: ") — carry significant clinical consequences including seizures, cardiac arrhythmias, and neuromuscular dysfunction. Magnesium is also a cornerstone therapeutic agent in pediatric emergencies such as status asthmaticus, torsades de pointes, and neonatal hypomagnesemic tetany.", size: 20, color: TEXT_BLACK, font: "Calibri" })
]),
emptyLine(8),
// ── SECTION 2: PHYSIOLOGY ─────────────────────────────────────────────────────
h1("2. Physiology & Distribution"),
h2("2.1 Body Distribution"),
makeTable(
["Compartment", "% of Total Body Mg", "Form"],
[
["Bone", "~67%", "Complexed with hydroxyapatite"],
["Intracellular (muscle, soft tissue)", "~31%", "Bound to proteins, ATP, nucleotides"],
["Extracellular fluid (serum)", "~1–2%", "Ionized 55%, protein-bound 30%, complexed 15%"]
],
[2500, 2500, 4000]
),
emptyLine(6),
callout("Key Point: Only 1–2% of total body Mg is in serum — serum levels are a POOR reflection of total body stores. Body stores may be significantly depleted before serum Mg falls."),
emptyLine(6),
h2("2.2 Normal Serum Magnesium Levels (Pediatric)"),
makeTable(
["Age Group", "Normal Serum Mg (mg/dL)", "Normal Serum Mg (mmol/L)"],
[
["Neonates", "1.5 – 2.3", "0.62 – 0.95"],
["Infants & Children", "1.7 – 2.5", "0.70 – 1.03"],
["Adolescents / Adults", "1.8 – 2.6", "0.74 – 1.07"]
],
[3000, 3000, 3000]
),
emptyLine(6),
h2("2.3 Daily Requirement"),
bullet("Minimum: 0.3 mEq/kg/day to prevent deficiency"),
bullet("Infants and children have higher daily requirements relative to body weight than adults"),
bullet("Dietary sources: green leafy vegetables, whole grains, nuts, seeds, legumes, meat, dairy"),
bullet("Less than 40% of dietary magnesium is absorbed — predominantly from the ileum and colon"),
emptyLine(6),
// ── SECTION 3: RENAL HANDLING ────────────────────────────────────────────────
h1("3. Renal Handling of Magnesium"),
bodyPara("The kidney is the primary organ regulating magnesium balance. Renal impairment is the most common predisposing factor to hypermagnesemia."),
emptyLine(6),
makeTable(
["Nephron Segment", "% Reabsorbed", "Mechanism / Clinical Relevance"],
[
["Glomerulus (filtration)", "70–80% is ultrafilterable", "Ionized + complexed forms pass freely"],
["Proximal tubule", "~25%", "Passive paracellular reabsorption"],
["Thick ascending limb of Loop of Henle (TAL)", "65–75% ★ PRIMARY SITE", "Paracellular via claudin-16 & claudin-19. BLOCKED by loop diuretics (furosemide)"],
["Distal convoluted tubule (DCT)", "~10% Fine-tuning", "Transcellular via TRPM6 channel. Regulated by aldosterone, insulin, EGF. Blocked by PPI use."]
],
[2200, 1600, 5200]
),
emptyLine(6),
callout("Threshold effect: When serum Mg exceeds ~2.5 mg/dL, urinary Mg excretion increases sharply — this is the kidney's primary defense against hypermagnesemia."),
emptyLine(6),
pageBreak(),
// ── SECTION 4: HYPOMAGNESEMIA ─────────────────────────────────────────────────
h1("4. Hypomagnesemia"),
callout("Definition: Serum magnesium < 1.7 mg/dL (< 0.70 mmol/L)", ACCENT_BLUE, DARK_BLUE, true),
emptyLine(6),
h2("4.1 Etiology (IAP / Nelson Classification)"),
h3("A. Decreased Intake / Impaired Absorption"),
bullet("Malnutrition, starvation, prolonged TPN without Mg supplementation"),
bullet("Malabsorption syndromes: Crohn's disease, celiac disease, short bowel syndrome"),
bullet("Proton pump inhibitor (PPI) use — impairs intestinal TRPM6 channel absorption (drug-induced)"),
bullet("Primary hypomagnesemia with secondary hypocalcemia (TRPM6 mutation) — neonatal onset, autosomal recessive"),
h3("B. Gastrointestinal Losses (Most Common in Indian Pediatric Practice)"),
bullet("Prolonged diarrhea — acute gastroenteritis, chronic diarrhea — #1 cause in India"),
bullet("Vomiting, prolonged nasogastric suction"),
bullet("Intestinal fistulae"),
h3("C. Renal Losses — Urinary Wasting"),
bullet("Drug-induced (most common renal cause):", false),
bullet("Loop diuretics (furosemide) — block TAL reabsorption", 1),
bullet("Aminoglycosides (gentamicin, amikacin)", 1),
bullet("Amphotericin B", 1),
bullet("Cisplatin (important in pediatric oncology)", 1),
bullet("Calcineurin inhibitors: tacrolimus, cyclosporine", 1),
bullet("Diabetic ketoacidosis (DKA) — osmotic diuresis causes profound Mg wasting"),
bullet("Bartter syndrome, Gitelman syndrome"),
bullet("Genetic tubulopathies: FHHNC (CLDN16/CLDN19 mutations), EAST syndrome"),
h3("D. Redistribution / Miscellaneous"),
bullet("Post-parathyroidectomy 'hungry bone syndrome'"),
bullet("Acute pancreatitis"),
bullet("Refeeding syndrome"),
bullet("Massive blood transfusion (citrate chelates Mg2+)"),
emptyLine(6),
h2("4.2 Clinical Features"),
warningBox("Mild hypomagnesemia is often ASYMPTOMATIC. Significant features occur at serum Mg < 1.2 mg/dL."),
emptyLine(6),
h3("Neuromuscular"),
bullet("Tremors, muscle cramps, fasciculations, weakness"),
bullet("Positive Chvostek and Trousseau signs (from associated hypocalcemia)"),
bullet("Tetany and seizures — especially in neonates with primary hypomagnesemia"),
h3("Cardiovascular"),
bullet("Torsades de Pointes — HALLMARK arrhythmia of hypomagnesemia", false, true),
bullet("QT prolongation, T-wave changes, widened QRS on ECG"),
bullet("Increased sensitivity to digoxin toxicity (hypomagnesemia aggravates digoxin toxicity — important in pediatric cardiology)"),
h3("The 'Magnesium Dependency Triad' (HIGH YIELD)"),
emptyLine(6),
makeTable(
["Electrolyte Abnormality", "Mechanism", "Clinical Clue"],
[
["Hypocalcemia", "Hypomagnesemia inhibits PTH secretion AND causes PTH resistance", "Hypocalcemia not responding to calcium supplementation → check Mg"],
["Hypokalemia", "Hypomagnesemia impairs Na-K-ATPase → urinary K+ wasting", "Refractory hypokalemia not responding to K+ replacement → check Mg"],
["Hypophosphatemia", "Less consistent; multifactorial", "Often co-exists in severe malnutrition/DKA"]
],
[2000, 3500, 3500]
),
emptyLine(6),
callout("EXAM KEY: Any child with REFRACTORY HYPOCALCEMIA or REFRACTORY HYPOKALEMIA must have serum magnesium checked. Correct Mg first — Ca2+ and K+ will not normalize until Mg is replenished.", WARN_AMBER, "7B5800", true),
emptyLine(6),
h2("4.3 Diagnosis"),
bullet("Serum magnesium < 1.7 mg/dL — first-line test"),
bullet("Serum calcium, potassium, phosphate — always check alongside"),
bullet("ECG — QT prolongation, arrhythmia assessment"),
bullet("Fractional Excretion of Magnesium (FEMg) — to localize cause:", false),
emptyLine(6),
callout("FEMg = (Urine Mg × Serum Cr) / (0.7 × Serum Mg × Urine Cr) × 100\n\n• FEMg > 2% → RENAL WASTING (tubular cause, drugs, tubulopathy)\n• FEMg < 2% → EXTRA-RENAL LOSSES (GI losses, redistribution)", LIGHT_GRAY, DARK_BLUE),
emptyLine(6),
bullet("24-hour urine Mg > 10–30 mg/day with hypomagnesemia also suggests renal wasting"),
bullet("Genetic testing if hereditary tubulopathy suspected (neonates, family history)"),
emptyLine(6),
pageBreak(),
h2("4.4 Treatment of Hypomagnesemia"),
h3("A. Mild / Asymptomatic (Serum Mg 1.2–1.7 mg/dL)"),
bullet("Oral magnesium supplementation (bioavailability ~33%)"),
bullet("Dose: 10–20 mg/kg/day elemental magnesium in divided doses"),
bullet("Preferred forms: magnesium gluconate, magnesium aspartate, magnesium chloride (sustained-release)"),
bullet("Limitation: diarrhea is dose-limiting — use with food; sustained-release preferred"),
bullet("Treat for several weeks — body stores replenish slowly"),
h3("B. Moderate–Severe / Symptomatic (Seizures, Tetany, Arrhythmia or Mg < 1.0 mg/dL)"),
bullet("IV Magnesium Sulfate (MgSO4) — drug of choice"),
emptyLine(6),
makeTable(
["Indication", "Pediatric Dose", "Rate / Notes"],
[
["Symptomatic hypomagnesemia / Seizures / Tetany", "25–50 mg/kg IV (max 2 g)", "Over 10–20 minutes"],
["Torsades de Pointes (Emergency)", "25–50 mg/kg IV (max 2 g)", "Over 1–5 minutes (rapid push)"],
["Severe / Refractory Asthma (Status Asthmaticus)", "40 mg/kg/day IV (max 2 g)", "Over 20 minutes — IAP / Nelson"],
["Maintenance Infusion", "25–50 mg/kg/day IV", "Continuous infusion; titrate to levels"],
["Neonatal Hypomagnesemic Tetany", "0.1–0.2 mEq/kg (25–50 mg/kg MgSO4)", "IV or IM; repeat in 12–24h if needed"]
],
[2500, 2500, 4000]
),
emptyLine(6),
h3("Monitoring During IV MgSO4 — MANDATORY"),
warningBox("STOP infusion if: Deep tendon reflexes (DTR) are lost, Respiratory Rate < 12/min, or Urine output < 1 mL/kg/hr in children"),
emptyLine(6),
makeTable(
["Parameter", "Frequency", "Danger Sign"],
[
["Serum magnesium", "Every 4–6 hours", "Mg > 4 mg/dL → risk of toxicity"],
["Deep tendon reflexes (patellar)", "Before EACH dose / hourly", "Loss of DTR = FIRST sign of toxicity"],
["Respiratory rate", "Every 15–30 min during infusion", "RR < 12/min → respiratory depression"],
["Urine output", "Hourly", "< 1 mL/kg/hr → stop or reduce rate"],
["ECG", "Continuous monitoring", "QRS widening, bradycardia, heart block"]
],
[2000, 2000, 5000]
),
emptyLine(6),
callout("ANTIDOTE for MgSO4 Toxicity: Calcium Gluconate 10% solution — 100–200 mg/kg IV (max 2 g) slowly over 10 minutes. Acts as direct calcium channel antagonist reversing Mg neuromuscular toxicity.", WARN_AMBER, "7B5800", true),
emptyLine(6),
pageBreak(),
// ── SECTION 5: HYPERMAGNESEMIA ──────────────────────────────────────────────
h1("5. Hypermagnesemia"),
callout("Definition: Serum magnesium > 2.5 mg/dL (> 1.03 mmol/L). Clinically significant: > 4 mg/dL.", ACCENT_BLUE, DARK_BLUE, true),
emptyLine(6),
h2("5.1 Etiology"),
makeTable(
["Cause", "Details / Pediatric Context"],
[
["Iatrogenic (most common in pediatrics)", "IV MgSO4 for asthma, arrhythmias; Mg-containing antacids/laxatives; bowel prep enemas"],
["Neonatal hypermagnesemia", "Transplacental transfer from mother receiving MgSO4 for pre-eclampsia/eclampsia — common in India"],
["Renal failure", "CrCl < 30 mL/min markedly impairs renal Mg excretion — most important predisposing factor"],
["Adrenal insufficiency / Hypothyroidism", "Rare; consider in recurrent/refractory cases"],
["Tumor lysis syndrome / Rhabdomyolysis", "Cellular Mg release"],
["Bowel obstruction / Severe ileus", "Decreased GI elimination + increased absorption of Mg-containing agents"]
],
[2500, 6500]
),
emptyLine(6),
h2("5.2 Clinical Features — Level Dependent (HIGH YIELD TABLE)"),
makeTable(
["Serum Mg (mg/dL)", "Clinical Effects"],
[
["4 – 5", "Decreased deep tendon reflexes (FIRST sign), nausea, vomiting, flushing, headache, weakness"],
["5 – 7", "Hypotension, somnolence, confusion, ECG changes (prolonged PR, widened QRS, QT prolongation)"],
["7 – 10", "Loss of all DTR, respiratory muscle weakness, constipation, urinary retention"],
["> 10", "Respiratory insufficiency / respiratory arrest"],
["10 – 15", "Complete heart block, severe bradycardia"],
["10 – 24", "CARDIAC ARREST"]
],
[2000, 7000]
),
emptyLine(6),
bodyPara([
new TextRun({ text: "Mechanisms of toxicity: ", bold: true, size: 20, font: "Calibri", color: DARK_BLUE }),
new TextRun({ text: "Mg2+ acts as a ", size: 20, font: "Calibri", color: TEXT_BLACK }),
new TextRun({ text: "calcium channel blocker", bold: true, size: 20, font: "Calibri", color: TEXT_BLACK }),
new TextRun({ text: " at neuromuscular junctions; blocks K+ channels needed for repolarization; suppresses PTH (causing hypocalcemia); interferes with platelet adhesiveness and coagulation.", size: 20, font: "Calibri", color: TEXT_BLACK })
]),
emptyLine(6),
h2("5.3 Neonatal Hypermagnesemia (IAP Special Consideration)"),
callout("Born to mothers receiving MgSO4 for pre-eclampsia/eclampsia — Mg crosses the placenta freely."),
emptyLine(6),
bodyPara("Clinical features in neonate:"),
bullet("Hypotonia ('floppy baby') — most prominent feature"),
bullet("Absent or depressed deep tendon reflexes"),
bullet("Poor feeding, diminished/absent suck reflex"),
bullet("Respiratory depression — may require ventilation"),
bullet("Ileus, urinary retention"),
bullet("These are TRANSIENT — resolve as Mg is cleared renally (usually 24–72 hours)"),
bullet("Treatment: supportive; calcium gluconate IV for severe cases; rarely exchange transfusion"),
emptyLine(6),
h2("5.4 Treatment of Hypermagnesemia"),
h3("Step 1 — Eliminate Source"),
bullet("Stop all exogenous magnesium (IV fluids, antacids, laxatives, enemas)"),
bullet("Mild/asymptomatic: cessation alone with monitoring may suffice"),
h3("Step 2 — Calcium (Direct Antagonist) — FIRST-LINE for Symptomatic"),
callout("Calcium Gluconate 10%: 100 mg/kg IV (max 2 g) over 5–10 minutes\n(or Calcium Chloride 10%: 5 mL IV over 30 seconds for cardiac emergency)\nDirectly antagonizes cardiac and neuromuscular effects of hypermagnesemia.", WARN_AMBER, "7B5800", true),
emptyLine(6),
h3("Step 3 — Enhance Renal Excretion (if renal function intact)"),
bullet("IV normal saline hydration + IV furosemide — promotes urinary Mg excretion"),
bullet("Effective ONLY with adequate renal function"),
h3("Step 4 — Dialysis (if renal failure or severe hypermagnesemia)"),
bullet("Hemodialysis rapidly and effectively corrects severe hypermagnesemia"),
bullet("Peritoneal dialysis is slower but can be used in neonates"),
h3("Step 5 — Supportive"),
bullet("Mechanical ventilation for respiratory failure"),
bullet("Continuous cardiac monitoring; ICU admission for Mg > 7–10 mg/dL or symptomatic patients"),
emptyLine(6),
pageBreak(),
// ── SECTION 6: THERAPEUTIC USES ──────────────────────────────────────────────
h1("6. Magnesium as a Therapeutic Agent in Pediatrics"),
h2("6.1 Severe Acute Asthma (Status Asthmaticus)"),
makeTable(
["Parameter", "Detail"],
[
["Mechanism", "Relaxes bronchial smooth muscle (Ca2+ channel blockade); inhibits cholinergic neuromuscular transmission; stabilizes mast cells & T-lymphocytes; stimulates NO and prostacyclin"],
["Indication (IAP/Nelson)", "Children with PEF < 60% after 1 hour of optimal therapy; severe refractory asthma with persistent hypoxia"],
["Pediatric Dose", "40 mg/kg IV MgSO4 (MAX 2 g) over 20 minutes"],
["Benefit", "Reduces need for hospitalization in severe asthma; nebulized Mg also studied but IV preferred for severe cases"],
["Side Effects", "Warmth, flushing, sweating, nausea, muscle weakness, loss of DTR, hypotension, respiratory depression"]
],
[2000, 7000]
),
emptyLine(6),
h2("6.2 Torsades de Pointes / Ventricular Arrhythmias"),
makeTable(
["Parameter", "Detail"],
[
["Drug of choice for", "Torsades de Pointes — regardless of serum magnesium level"],
["Pediatric Dose", "25–50 mg/kg IV (MAX 2 g) over 1–5 minutes (emergency)"],
["Mechanism", "Membrane-stabilizing properties; calcium channel antagonism"],
["Additional use", "Arrhythmia prophylaxis post-pediatric cardiac surgery: 25–50 mg/kg IV"]
],
[2500, 6500]
),
emptyLine(6),
h2("6.3 Diabetic Ketoacidosis (DKA)"),
bullet("Osmotic diuresis in DKA causes profound magnesium wasting"),
bullet("DKA therapy (insulin, IV fluids) further depletes Mg stores"),
bullet("Hypomagnesemia in DKA may worsen vomiting, mental changes, refractory hypokalemia/hypocalcemia, and precipitate fatal arrhythmia"),
callout("Recommendation: Add Mg to IV fluids when hypomagnesemia is suspected in DKA. Typical repletion: 25–50 mg/kg IV (max 2 g). Monitor serum Mg alongside K+."),
emptyLine(6),
h2("6.4 Eclampsia / Pre-eclampsia (Adolescent Girls)"),
makeTable(
["Parameter", "Detail"],
[
["Drug of choice", "MgSO4 for seizure prevention AND treatment in eclampsia — superior to phenytoin and diazepam"],
["Evidence", "Magpie Trial (10,000 women): MgSO4 reduced eclamptic seizure risk by >50% (RR 0.41, 95% CI 0.29–0.58)"],
["Mechanism", "NMDA receptor antagonism (anticonvulsant) + vasodilation"],
["Loading dose", "4–6 g IV over 20–30 minutes"],
["Maintenance", "1–2 g/hr continuous infusion"],
["Therapeutic blood level", "4–8 mEq/L"]
],
[2500, 6500]
),
emptyLine(6),
pageBreak(),
// ── SECTION 7: GENETIC DISORDERS ─────────────────────────────────────────────
h1("7. Genetic Disorders of Magnesium Metabolism (Nelson)"),
makeTable(
["Disorder", "Gene", "Inheritance", "Key Features"],
[
["Primary hypomagnesemia with secondary hypocalcemia", "TRPM6", "AR", "Neonatal seizures, severe hypomagnesemia, hypocalcemia unresponsive to Ca"],
["Familial Hypomagnesemia, Hypercalciuria & Nephrocalcinosis (FHHNC)", "CLDN16, CLDN19", "AR", "Renal Mg wasting, nephrocalcinosis, progressive renal failure"],
["Autosomal dominant hypomagnesemia", "KCNA1", "AD", "Muscle cramps, tremors, hypomagnesemia"],
["Hypomagnesemia with seizures & mental impairment", "CNNM2", "AD", "Seizures, cognitive impairment"],
["Gitelman syndrome", "SLC12A3", "AR", "Hypomagnesemia + hypokalemia + hypocalciuria + metabolic alkalosis"],
["Bartter syndrome Type III", "CLCNKB", "AR", "Hypomagnesemia + hypokalemia + metabolic alkalosis"]
],
[2500, 1200, 1300, 4000]
),
emptyLine(6),
pageBreak(),
// ── SECTION 8: DIAGNOSTIC APPROACH ──────────────────────────────────────────
h1("8. Diagnostic Approach to Hypomagnesemia in Children (IAP Algorithm)"),
emptyLine(6),
new Paragraph({
children: [new TextRun({ text: "STEP-BY-STEP APPROACH", bold: true, size: 22, color: DARK_BLUE, font: "Calibri" })],
spacing: { before: 60, after: 60 }
}),
callout("Step 1: Suspect hypomagnesemia in any child with:\n • Unexplained seizures / tetany\n • Refractory hypocalcemia (not responding to Ca supplementation)\n • Refractory hypokalemia (not responding to K+ replacement)\n • Prolonged diarrhea / malabsorption\n • Drug exposure: furosemide, aminoglycosides, amphotericin, cisplatin, PPI, tacrolimus\n • DKA management", LIGHT_GRAY, DARK_BLUE),
emptyLine(6),
callout("Step 2: Initial investigations:\n • Serum magnesium, calcium, potassium, phosphate\n • ECG (QT interval, arrhythmia)\n • Renal function (BUN, creatinine)", LIGHT_GRAY, DARK_BLUE),
emptyLine(6),
callout("Step 3: Calculate FEMg to localize cause:\n FEMg = (Urine Mg × Serum Cr) / (0.7 × Serum Mg × Urine Cr) × 100\n > 2% = Renal wasting | < 2% = Extra-renal (GI/redistribution)", LIGHT_GRAY, DARK_BLUE),
emptyLine(6),
callout("Step 4: Treat based on severity:\n • Asymptomatic, Mg 1.2–1.7 mg/dL → Oral Mg, 10–20 mg/kg/day\n • Symptomatic / Mg < 1.2 mg/dL → IV MgSO4, 25–50 mg/kg (max 2g) over 10–20 min\n • Seizures / Torsades → IV MgSO4, 25–50 mg/kg (max 2g) over 1–5 min (emergency)", ACCENT_BLUE, DARK_BLUE),
emptyLine(6),
callout("Step 5: Monitor during IV therapy:\n • DTR (patellar reflex) before EACH dose\n • RR (must be > 12/min)\n • Urine output (> 1 mL/kg/hr)\n • Serum Mg every 4–6 hours\n • Continuous ECG monitoring", LIGHT_GRAY, DARK_BLUE),
emptyLine(6),
callout("Step 6: Treat underlying cause. Genetic testing if hereditary tubulopathy suspected.", LIGHT_GRAY, DARK_BLUE),
emptyLine(6),
pageBreak(),
// ── SECTION 9: HIGH-YIELD SUMMARY ────────────────────────────────────────────
h1("9. High-Yield Exam Summary (IAP & Nelson Based)"),
emptyLine(6),
makeTable(
["#", "High-Yield Point"],
[
["1", "Hypomagnesemia triad: hypocalcemia + hypokalemia + hypomagnesemia — correct Mg FIRST, or Ca2+ and K+ will not normalize"],
["2", "Torsades de Pointes = classic arrhythmia of hypomagnesemia; IV MgSO4 is treatment regardless of serum levels"],
["3", "Neonatal hypermagnesemia from maternal MgSO4 = floppy baby, respiratory depression, absent reflexes — transient"],
["4", "Asthma (pediatric): dose = 40 mg/kg IV MgSO4 (max 2 g) over 20 min for severe/refractory exacerbation"],
["5", "ANTIDOTE for MgSO4 toxicity = Calcium Gluconate 10%, 100–200 mg/kg IV (max 2 g) slowly over 10 min"],
["6", "Monitor PATELLAR REFLEX before each MgSO4 dose — loss of DTR = first and most reliable sign of toxicity"],
["7", "FEMg > 2% = renal magnesium wasting (drugs, tubular disorders)"],
["8", "TRPM6 mutation = primary hypomagnesemia with secondary hypocalcemia — presents as neonatal seizures (AR)"],
["9", "Loop diuretics (furosemide) block TAL Mg reabsorption → renal Mg wasting"],
["10", "DKA → replace Mg in management (osmotic diuresis + insulin therapy cause Mg depletion)"],
["11", "PPI use → drug-induced hypomagnesemia via impaired intestinal TRPM6 absorption"],
["12", "Hypermagnesemia level-dependent features: DTR loss (4–5) → hypotension (5–7) → respiratory arrest (>10) → cardiac arrest (10–24)"],
["13", "Eclampsia drug of choice = MgSO4 (superior to phenytoin and diazepam — Magpie Trial)"],
["14", "Serum Mg reflects only 1–2% of body stores — check FEMg, serum Ca, K+ always alongside Mg"],
["15", "Gitelman syndrome = hypomagnesemia + hypokalemia + hypocalciuria + metabolic alkalosis (SLC12A3 mutation)"]
],
[500, 8500]
),
emptyLine(6),
pageBreak(),
// ── SECTION 10: REFERENCES ────────────────────────────────────────────────────
h1("10. References"),
bullet("Nelson's Textbook of Pediatrics, 21st Edition — Fluid and Electrolyte Disorders"),
bullet("IAP Textbook of Pediatrics / IAP Updates & Guidelines: Pediatric Critical Care 2024"),
bullet("Comprehensive Clinical Nephrology, 7th Edition — Magnesium Homeostasis and Disorders"),
bullet("Guyton & Hall Textbook of Medical Physiology — Renal Handling of Magnesium"),
bullet("Rosen's Emergency Medicine (10e) — Magnesium in Asthma; Hypermagnesemia and Hypomagnesemia"),
bullet("Tietz Textbook of Laboratory Medicine, 7th Edition — Magnesium Reference Intervals & Physiology"),
bullet("Brenner & Rector's The Kidney — Genetic Disorders of Magnesium Transport"),
bullet("Tintinalli's Emergency Medicine (9e) — Hypomagnesemia"),
bullet("Sabiston Textbook of Surgery — Magnesium Disorders"),
bullet("Creasy & Resnik's Maternal-Fetal Medicine — MgSO4 in Eclampsia (Magpie Trial)"),
bullet("Bradley & Daroff's Neurology in Clinical Practice — Disorders of Magnesium Metabolism"),
emptyLine(8),
new Paragraph({
children: [new TextRun({ text: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━", color: MID_BLUE, size: 24, font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 60 }
}),
new Paragraph({
children: [new TextRun({ text: "End of Essay — MD Pediatrics Theory | Magnesium", size: 20, color: "888888", italics: true, font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 60 }
})
]; // end children
// ─── ASSEMBLE DOCUMENT ────────────────────────────────────────────────────────
const doc = new Document({
styles: {
default: {
document: {
run: { font: "Calibri", size: 20, color: TEXT_BLACK }
}
}
},
sections: [{
properties: {
page: {
margin: {
top: convertInchesToTwip(1.0),
bottom: convertInchesToTwip(1.0),
left: convertInchesToTwip(1.0),
right: convertInchesToTwip(1.0)
}
}
},
headers: {
default: new Header({
children: [
new Paragraph({
children: [
new TextRun({ text: "MAGNESIUM IN PEDIATRICS | MD Pediatrics Theory Examination", size: 16, color: MID_BLUE, font: "Calibri" }),
new TextRun({ text: "\t", size: 16 }),
new TextRun({ text: "Page ", size: 16, color: "888888", font: "Calibri" }),
new PageNumber({ type: NumberFormat.DECIMAL })
],
alignment: AlignmentType.RIGHT,
border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: MID_BLUE } }
})
]
})
},
footers: {
default: new Footer({
children: [
new Paragraph({
children: [
new TextRun({ text: "Based on Nelson's Textbook of Pediatrics & IAP Guidelines", size: 16, color: "888888", italics: true, font: "Calibri" })
],
alignment: AlignmentType.CENTER,
border: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GRAY } }
})
]
})
},
children
}]
});
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync("/home/daytona/workspace/magnesium-essay/Magnesium_Pediatrics_Essay.docx", buffer);
console.log("SUCCESS: File written.");
}).catch(err => {
console.error("ERROR:", err.message);
process.exit(1);
});
cd /home/daytona/workspace/magnesium-essay && node generate.js 2>&1
~/magnesium-essay/generate.js
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/magnesium-essay/generate.js'
cd /home/daytona/workspace/magnesium-essay && node generate.js 2>&1
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/works…
cd /home/daytona/workspace/magnesium-essay && python3 -c " import zipfile, os wi…
Magnesium Pediatrics Essay
Word Document · DOCX