Create a ppt for 'Total Parenteral Nutrition in Critical Illness- When to start?'. It is for a national conference of intensivists. It should take info from standard books like Miller's and Marino's and Washington'. And ESPEN, ASPEN guidelines. also, it should be properly mentioned what recommendations has been taken from where. A few other papers I will upload next

Reading File
Reading File
Reading File
Finding Sources

Total Parenteral Nutrition - StatPearls - NCBI Bookshelf https://share.google/XZyJzvb568WZ3BrH7

Critical care nutrition - EMCrit Project https://share.google/DoKWAIdmFSl26uU9a DRSC | Healthcare Professionals | Pharmaceutical Companies in Delhi https://share.google/m2iIQDsdGMF3xe4Jz. TPN in Post-Surgical Patients: Why It’s Needed and How It Helps https://share.google/qwGernCWp7GXlZLuT.

Parenteral nutrition in the ICU - ScienceDirect https://share.google/r5ywzMv3dPosdNrXW. Parenteral nutrition in intensive care – guidelines and treatment - The Anesthesia Guide https://share.google/POcxAnAwbVw2Z5y8o. ESPEN_practical_and_partially_revised_guideline_Clinical_nutrition_in_the_intensive_care_unit.pdf https://share.google/0S0W4VQEXnrvooAlq

Finding Sources
Searching the Web

ESPEN 2023 guidelines parenteral nutrition ICU timing critical illness recommendations

Reading Web Page

https://www.ncbi.nlm.nih.gov/books/NBK209343/

Finding Sources
Searching PubMed

"parenteral nutrition" AND "critical illness" AND timing

Reading File
Finding Sources
Searching PubMed

"parenteral nutrition" AND "intensive care" AND "early" AND "delayed"

Reading File
Finding Sources
Finding Sources
Reading File
Finding Sources
Searching PubMed

"supplemental parenteral nutrition" AND "critical illness" AND "enteral"

Reading File
Reading File
Finding Sources
Running Command

mkdir -p /home/daytona/workspace/tpn-ppt && ls /home/daytona/workspace/tpn-ppt/

Writing File

~/tpn-ppt/build.js

const pptxgen = require("pptxgenjs");

const pres = new pptxgen();
pres.layout = "LAYOUT_WIDE"; // 13.3" x 7.5"
pres.title = "Total Parenteral Nutrition in Critical Illness – When to Start?";
pres.author = "National Conference of Intensivists";

// ── COLOUR PALETTE ──────────────────────────────────────────────────────────
const C = {
  navy:    "0A1628",   // dominant dark background
  blue:    "1565C0",   // section header bar
  sky:     "42A5F5",   // accent / highlight
  teal:    "00838F",   // secondary accent
  gold:    "FFB300",   // warning / caution
  white:   "FFFFFF",
  offWhite:"EEF2F7",
  lightGray:"D0D8E8",
  bodyText:"E8EFF8",
  citeBg:  "132240",
  citeText:"A8C4E8",
  red:     "D32F2F",
  green:   "2E7D32",
};

// ── HELPERS ──────────────────────────────────────────────────────────────────
function addBackground(slide, color) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: "100%", h: "100%",
    fill: { color: color || C.navy }, line: { width: 0 },
  });
}

function sectionBar(slide, label, color) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: "100%", h: 0.75,
    fill: { color: color || C.blue }, line: { width: 0 },
  });
  slide.addText(label, {
    x: 0.3, y: 0, w: 12.7, h: 0.75,
    fontSize: 13, bold: true, color: C.white,
    fontFace: "Calibri", valign: "middle",
  });
}

function slideTitle(slide, title, sub) {
  slide.addText(title, {
    x: 0.4, y: 0.85, w: 12.5, h: 0.7,
    fontSize: 26, bold: true, color: C.white,
    fontFace: "Calibri", margin: 0,
  });
  if (sub) {
    slide.addText(sub, {
      x: 0.4, y: 1.5, w: 12.5, h: 0.4,
      fontSize: 14, color: C.sky, fontFace: "Calibri",
      italic: true, margin: 0,
    });
  }
}

function addCite(slide, text, y) {
  slide.addText(text, {
    x: 0.35, y: y || 6.9, w: 12.6, h: 0.35,
    fontSize: 9, color: C.citeText, fontFace: "Calibri",
    italic: true, margin: 0,
  });
}

function addBox(slide, opts) {
  // opts: x,y,w,h,fill,text,textColor,fontSize,bold,radius
  slide.addShape(pres.ShapeType.roundRect, {
    x: opts.x, y: opts.y, w: opts.w, h: opts.h,
    fill: { color: opts.fill || C.citeBg },
    line: { color: opts.border || C.sky, width: opts.borderW || 1 },
    rectRadius: opts.radius !== undefined ? opts.radius : 0.08,
  });
  slide.addText(opts.text, {
    x: opts.x + 0.12, y: opts.y + 0.06,
    w: opts.w - 0.24, h: opts.h - 0.12,
    fontSize: opts.fontSize || 13,
    color: opts.textColor || C.white,
    fontFace: "Calibri", bold: opts.bold || false,
    valign: "middle",
  });
}

// ── BULLET HELPER ────────────────────────────────────────────────────────────
function makeBullets(items) {
  return items.map((item, i) => ({
    text: item.text || item,
    options: {
      bullet: item.sub ? { indent: 30 } : { code: "2022" },
      fontSize: item.sub ? 12 : 13.5,
      color: item.sub ? C.lightGray : C.bodyText,
      bold: item.bold || false,
      breakLine: true,
    },
  }));
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 1 — TITLE SLIDE
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);

  // decorative top strip
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: "100%", h: 0.18,
    fill: { color: C.sky }, line: { width: 0 },
  });
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 0.18, w: "100%", h: 0.08,
    fill: { color: C.teal }, line: { width: 0 },
  });

  // accent vertical bar
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 1.4, w: 0.18, h: 4.0,
    fill: { color: C.sky }, line: { width: 0 },
  });

  s.addText("Total Parenteral Nutrition\nin Critical Illness", {
    x: 0.5, y: 1.4, w: 12.3, h: 2.2,
    fontSize: 40, bold: true, color: C.white,
    fontFace: "Calibri", valign: "middle",
  });

  s.addShape(pres.ShapeType.rect, {
    x: 0.5, y: 3.55, w: 7.5, h: 0.06,
    fill: { color: C.sky }, line: { width: 0 },
  });

  s.addText("When to Start?", {
    x: 0.5, y: 3.65, w: 10, h: 0.7,
    fontSize: 28, bold: true, color: C.sky,
    fontFace: "Calibri",
  });

  s.addText("A Critical Care Nutrition Evidence Review", {
    x: 0.5, y: 4.4, w: 10, h: 0.45,
    fontSize: 16, color: C.lightGray, fontFace: "Calibri", italic: true,
  });

  s.addText("National Conference of Intensivists  •  May 2026", {
    x: 0.5, y: 5.0, w: 10, h: 0.4,
    fontSize: 13, color: C.citeText, fontFace: "Calibri",
  });

  // bottom strip
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 7.15, w: "100%", h: 0.35,
    fill: { color: C.blue }, line: { width: 0 },
  });
  s.addText("Sources: ESPEN 2023  |  ASPEN/SCCM 2016  |  Washington Manual  |  Harrison's  |  Miller's  |  Fishman's Pulmonary  |  Goldman-Cecil  |  StatPearls  |  PubMed", {
    x: 0.3, y: 7.16, w: 12.7, h: 0.32,
    fontSize: 9, color: C.lightGray, fontFace: "Calibri",
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 2 — WHY NUTRITION MATTERS IN THE ICU
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "The Problem: Malnutrition in Critical Illness");
  slideTitle(s, "Why Nutrition Matters in the ICU");

  const bullets = [
    { text: "Critically ill patients develop rapid, severe catabolism within 24–48 h of ICU admission" },
    { text: "ICU patients receive only ~35% of prescribed calories and ~42% of prescribed protein in the first few days", bold: true },
    { text: "Metabolic stress drives: muscle wasting, immune impairment, poor wound healing, prolonged ventilation" },
    { text: "Malnutrition independently increases ICU mortality, infection rates, and length of stay" },
    { text: "Yet overfeeding is equally harmful: hyperglycaemia, hepatic steatosis, hypercapnia, immune suppression" },
    { text: "The ICU intensivist must balance the risk of UNDERFEEDING vs. OVERFEEDING" },
  ];
  s.addText(makeBullets(bullets), {
    x: 0.5, y: 2.0, w: 12.0, h: 4.3,
    fontSize: 13.5, color: C.bodyText, fontFace: "Calibri",
    lineSpacingMultiple: 1.3,
  });

  addCite(s, "Fishman's Pulmonary Diseases (Timing and Route of Artificial Nutrition)  |  Harrison's Principles 22e (Chap. ICU Care)  |  StatPearls: TPN");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 3 — OVERVIEW OF NUTRITION SUPPORT ROUTES
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Routes of Nutrition Support");
  slideTitle(s, "Enteral vs Parenteral Nutrition — The Hierarchy");

  // EN Box
  s.addShape(pres.ShapeType.roundRect, {
    x: 0.4, y: 1.9, w: 5.7, h: 4.4,
    fill: { color: "0D2137" }, line: { color: C.teal, width: 2 },
    rectRadius: 0.1,
  });
  s.addText("ENTERAL NUTRITION (EN)", {
    x: 0.5, y: 2.0, w: 5.5, h: 0.45,
    fontSize: 15, bold: true, color: C.teal, fontFace: "Calibri",
  });
  const enItems = [
    "✔ Always FIRST choice if gut is functional",
    "✔ Preserves gut mucosal integrity & barrier",
    "✔ Stimulates bile flow, reduces bacterial translocation",
    "✔ Cheaper, safer, more physiological",
    "✔ Start within 24–48 h of ICU admission",
    "✗ May be insufficient alone in ~50% of patients",
    "✗ Contraindicated: bowel obstruction, ischaemia, high-output fistula",
  ];
  s.addText(enItems.map((t, i) => ({
    text: t, options: { breakLine: true, fontSize: 12, color: i < 5 ? C.bodyText : C.lightGray }
  })), {
    x: 0.5, y: 2.5, w: 5.5, h: 3.5,
    fontFace: "Calibri", lineSpacingMultiple: 1.25,
  });

  // PN Box
  s.addShape(pres.ShapeType.roundRect, {
    x: 6.8, y: 1.9, w: 5.9, h: 4.4,
    fill: { color: "0D2137" }, line: { color: C.sky, width: 2 },
    rectRadius: 0.1,
  });
  s.addText("PARENTERAL NUTRITION (PN)", {
    x: 6.9, y: 2.0, w: 5.7, h: 0.45,
    fontSize: 15, bold: true, color: C.sky, fontFace: "Calibri",
  });
  const pnItems = [
    "✔ Required when EN is contraindicated or inadequate",
    "✔ Provides complete macro/micronutrients IV",
    "✔ Effective for specific disease states (short bowel, etc.)",
    "✗ Risk: hyperglycaemia, hepatic steatosis, cholestasis",
    "✗ Risk: catheter-related blood-stream infections (CRBSI)",
    "✗ Risk: gut atrophy from disuse",
    "✗ More expensive; requires central venous access",
  ];
  s.addText(pnItems.map((t, i) => ({
    text: t, options: { breakLine: true, fontSize: 12, color: i < 3 ? C.bodyText : C.lightGray }
  })), {
    x: 6.9, y: 2.5, w: 5.6, h: 3.5,
    fontFace: "Calibri", lineSpacingMultiple: 1.25,
  });

  // Arrow
  s.addShape(pres.ShapeType.rightArrow, {
    x: 5.7, y: 3.7, w: 1.0, h: 0.5,
    fill: { color: C.gold }, line: { width: 0 },
  });
  s.addText("if EN fails", {
    x: 5.65, y: 4.25, w: 1.1, h: 0.3,
    fontSize: 9, color: C.gold, fontFace: "Calibri", align: "center",
  });

  addCite(s, "ESPEN ICU Guideline 2023  |  ASPEN/SCCM 2016  |  Washington Manual of Medical Therapeutics (PN General Principles)  |  Fishman's Pulmonary");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 4 — WHEN IS TPN INDICATED?
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Indications for TPN");
  slideTitle(s, "When Is TPN Indicated in the ICU?");

  // 3 boxes side by side
  const boxes = [
    {
      x: 0.35, color: C.teal, title: "ABSOLUTE INDICATIONS",
      items: [
        "Bowel obstruction / ileus",
        "Intestinal ischaemia / infarction",
        "High-output enteric fistula",
        "Short bowel syndrome",
        "Severe acute pancreatitis\n(with failed EN)",
        "Prolonged gastrointestinal failure",
      ],
    },
    {
      x: 4.85, color: C.sky, title: "RELATIVE INDICATIONS",
      items: [
        "EN providing <50% of\nrequirements for >3–7 days",
        "Haemodynamic instability\n(vasopressor-dependent)",
        "Persistent intolerance to EN\n(high gastric residuals, vomiting)",
        "Malabsorption syndromes",
        "Severe mucositis (BMT/chemo)",
      ],
    },
    {
      x: 9.35, color: C.gold, title: "NOT INDICATED / CAUTION",
      items: [
        "Functioning GI tract → use EN",
        "Expected ICU stay <5–7 days\n(well-nourished patients)",
        "Haemodynamic resuscitation\nnot yet complete",
        "Early PN in well-nourished patients\n→ increased morbidity",
        "First 7 days if EN is feasible",
      ],
    },
  ];

  boxes.forEach(b => {
    s.addShape(pres.ShapeType.roundRect, {
      x: b.x, y: 2.0, w: 4.1, h: 4.7,
      fill: { color: "0D2137" }, line: { color: b.color, width: 2 },
      rectRadius: 0.1,
    });
    s.addText(b.title, {
      x: b.x + 0.1, y: 2.08, w: 3.9, h: 0.42,
      fontSize: 12, bold: true, color: b.color, fontFace: "Calibri", align: "center",
    });
    s.addShape(pres.ShapeType.rect, {
      x: b.x, y: 2.5, w: 4.1, h: 0.04,
      fill: { color: b.color }, line: { width: 0 },
    });
    s.addText(b.items.map(t => ({
      text: t, options: { bullet: { code: "25B6" }, breakLine: true, fontSize: 12, color: C.bodyText }
    })), {
      x: b.x + 0.1, y: 2.58, w: 3.85, h: 4.0,
      fontFace: "Calibri", lineSpacingMultiple: 1.3,
    });
  });

  addCite(s, "Washington Manual (PN General Principles)  |  ESPEN ICU 2023 Guideline  |  ASPEN/SCCM 2016  |  Schwartz's Surgery 11e  |  Goldman-Cecil Medicine");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 5 — THE KEY QUESTION: EARLY vs DELAYED TPN
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "The Central Debate");
  slideTitle(s, "Early vs Delayed TPN — What Do the Guidelines Say?");

  // Timeline graphic
  s.addShape(pres.ShapeType.rect, {
    x: 0.5, y: 2.15, w: 12.3, h: 0.18,
    fill: { color: C.lightGray }, line: { width: 0 },
  });
  // Day markers
  const days = [
    { label: "Day 0\nICU Admission", x: 0.5 },
    { label: "Day 1–2", x: 2.5 },
    { label: "Day 3–4", x: 4.5 },
    { label: "Day 7\n(ASPEN threshold)", x: 7.0 },
    { label: "Day 8\n(ESPEN / EPaNIC)", x: 9.5 },
    { label: "Day 8+", x: 11.8 },
  ];
  days.forEach(d => {
    s.addShape(pres.ShapeType.ellipse, {
      x: d.x - 0.12, y: 2.09, w: 0.3, h: 0.3,
      fill: { color: C.sky }, line: { width: 0 },
    });
    s.addText(d.label, {
      x: d.x - 0.6, y: 2.44, w: 1.5, h: 0.6,
      fontSize: 9, color: C.lightGray, fontFace: "Calibri", align: "center",
    });
  });

  // EARLY PN zone
  s.addShape(pres.ShapeType.rect, {
    x: 0.5, y: 3.15, w: 6.6, h: 1.05,
    fill: { color: "3B1A0A" }, line: { color: C.gold, width: 1.5 },
  });
  s.addText("⚠  EARLY PN (Day 0–7): CAUTION", {
    x: 0.6, y: 3.2, w: 6.4, h: 0.4,
    fontSize: 13, bold: true, color: C.gold, fontFace: "Calibri",
  });
  s.addText("• Increased infections, complications & mortality vs. late PN (EPaNIC trial, n=4640)\n• ASPEN 2016: Withhold PN for first 7 days if EN is feasible in well-nourished patients", {
    x: 0.6, y: 3.55, w: 6.4, h: 0.6,
    fontSize: 11, color: C.bodyText, fontFace: "Calibri",
  });

  // DELAYED PN zone
  s.addShape(pres.ShapeType.rect, {
    x: 7.3, y: 3.15, w: 5.5, h: 1.05,
    fill: { color: "0A2B1A" }, line: { color: C.teal, width: 1.5 },
  });
  s.addText("✔  DELAYED PN (Day 8+): PREFERRED", {
    x: 7.4, y: 3.2, w: 5.3, h: 0.4,
    fontSize: 13, bold: true, color: C.teal, fontFace: "Calibri",
  });
  s.addText("• Better recovery, fewer ICU complications (Harrison's 22e, EPaNIC data)\n• ESPEN 2023: Initiate PN only after 7 days if EN target not reached", {
    x: 7.4, y: 3.55, w: 5.3, h: 0.6,
    fontSize: 11, color: C.bodyText, fontFace: "Calibri",
  });

  // Bottom key message
  s.addShape(pres.ShapeType.roundRect, {
    x: 0.4, y: 4.45, w: 12.5, h: 1.05,
    fill: { color: C.blue }, line: { width: 0 },
    rectRadius: 0.1,
  });
  s.addText("KEY MESSAGE: In well-nourished ICU patients where EN is feasible — do NOT initiate TPN in the first 7 days.\nThe risk of starvation does not exceed the risk of early PN until approximately Day 7–8.", {
    x: 0.6, y: 4.5, w: 12.2, h: 0.95,
    fontSize: 13.5, bold: true, color: C.white, fontFace: "Calibri",
    align: "center", valign: "middle",
  });

  addCite(s, "Washington Manual (PN p.63) |  Harrison's 22e (ICU Nutrition)  |  Fishman's Pulmonary (Timing & Route, p.2669)  |  EPaNIC Trial (NEJM 2011)  |  ASPEN/SCCM 2016  |  ESPEN 2023");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 6 — ESPEN 2023 RECOMMENDATIONS
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  // ESPEN blue header
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: "100%", h: 0.75,
    fill: { color: "0058A3" }, line: { width: 0 },
  });
  s.addText("ESPEN GUIDELINES 2023 — Clinical Nutrition in the ICU", {
    x: 0.3, y: 0, w: 12.7, h: 0.75,
    fontSize: 14, bold: true, color: C.white, fontFace: "Calibri", valign: "middle",
  });
  slideTitle(s, "ESPEN 2023: Key Recommendations on TPN Timing");

  const recs = [
    {
      grade: "Grade A", color: C.teal,
      text: "Enteral nutrition should be initiated within 24–48 h in all ICU patients who cannot maintain volitional intake.",
    },
    {
      grade: "Grade B", color: C.sky,
      text: "If EN is not feasible or is insufficient (<70% of target), PN should be considered — but NOT before Day 3–7 in well-nourished patients.",
    },
    {
      grade: "Grade A", color: C.teal,
      text: "In patients who were malnourished prior to ICU admission (NRS-2002 ≥5, or NUTRIC ≥6), TPN can be initiated earlier (Day 3–4) if EN is not feasible.",
    },
    {
      grade: "Grade B", color: C.sky,
      text: "Supplemental PN to top-up insufficient EN should not be started before Day 7 in non-malnourished patients (based on EPaNIC, SPN trials).",
    },
    {
      grade: "Expert Opinion", color: C.gold,
      text: "During acute resuscitation phase (Day 0–2): focus on haemodynamic stabilisation, not caloric targets. Avoid full feeding.",
    },
    {
      grade: "Grade B", color: C.sky,
      text: "Target 70–100% of measured energy expenditure (via indirect calorimetry) after the acute phase (Day 3 onwards).",
    },
  ];

  recs.forEach((r, i) => {
    const y = 1.85 + i * 0.82;
    // Grade badge
    s.addShape(pres.ShapeType.roundRect, {
      x: 0.35, y: y, w: 1.5, h: 0.45,
      fill: { color: r.color }, line: { width: 0 },
      rectRadius: 0.07,
    });
    s.addText(r.grade, {
      x: 0.35, y: y, w: 1.5, h: 0.45,
      fontSize: 10, bold: true, color: C.navy, fontFace: "Calibri",
      align: "center", valign: "middle",
    });
    s.addText(r.text, {
      x: 2.0, y: y, w: 11.0, h: 0.55,
      fontSize: 12.5, color: C.bodyText, fontFace: "Calibri", valign: "middle",
    });
  });

  addCite(s, "Source: ESPEN Practical and Partially Revised Guideline: Clinical Nutrition in the ICU (2023)  |  Thibault R et al. Clin Nutr ESPEN 2023 (PMID 37739675)");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 7 — ASPEN/SCCM 2016 RECOMMENDATIONS
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: "100%", h: 0.75,
    fill: { color: "A0001E" }, line: { width: 0 },
  });
  s.addText("ASPEN / SCCM GUIDELINES 2016 — Nutrition Support Therapy in the Adult Critically Ill Patient", {
    x: 0.3, y: 0, w: 12.7, h: 0.75,
    fontSize: 13, bold: true, color: C.white, fontFace: "Calibri", valign: "middle",
  });
  slideTitle(s, "ASPEN/SCCM 2016: Key Recommendations on TPN Timing");

  const recs = [
    {
      grade: "Grade A", color: C.teal,
      text: "If contraindication to EN: use PN only after 7 days in adequately nourished patients (BMI 18.5–30). Do NOT initiate in first 7 days.",
    },
    {
      grade: "Grade A", color: C.teal,
      text: "Well-nourished patients tolerating EN: No benefit from supplemental PN in the first week; may cause harm.",
    },
    {
      grade: "Grade B", color: C.sky,
      text: "Malnourished patients (NRS-2002 ≥5 or NUTRIC ≥6): Initiate PN as soon as feasible if EN is not possible — do not delay beyond 24–48 h.",
    },
    {
      grade: "Grade C", color: C.lightGray,
      text: "Obese patients (BMI ≥30): Use hypocaloric/high-protein PN. Target 11–14 kcal/kg actual BW or 22–25 kcal/kg ideal BW.",
    },
    {
      grade: "Expert Opinion", color: C.gold,
      text: "EN feeding <60% of target for >2–3 days may justify supplemental PN — but NOT in the first 7 days for well-nourished patients.",
    },
    {
      grade: "Grade A", color: C.teal,
      text: "When PN is initiated, use care to avoid overfeeding. Monitor glucose closely (target ≤180 mg/dL).",
    },
  ];

  recs.forEach((r, i) => {
    const y = 1.85 + i * 0.82;
    s.addShape(pres.ShapeType.roundRect, {
      x: 0.35, y: y, w: 1.5, h: 0.45,
      fill: { color: r.color }, line: { width: 0 },
      rectRadius: 0.07,
    });
    s.addText(r.grade, {
      x: 0.35, y: y, w: 1.5, h: 0.45,
      fontSize: 10, bold: true, color: C.navy, fontFace: "Calibri",
      align: "center", valign: "middle",
    });
    s.addText(r.text, {
      x: 2.0, y: y, w: 11.0, h: 0.55,
      fontSize: 12.5, color: C.bodyText, fontFace: "Calibri", valign: "middle",
    });
  });

  addCite(s, "Source: McClave SA et al. ASPEN/SCCM Guidelines for Provision and Assessment of Nutrition Support Therapy. JPEN 2016;40(2):159–211.");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 8 — RISK STRATIFICATION: WHO GETS TPN WHEN?
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Risk Stratification — Personalising TPN Timing");
  slideTitle(s, "Who Gets TPN When? A Risk-Based Approach");

  // 4 category boxes
  const cats = [
    {
      x: 0.35, y: 1.8, color: C.green, bg: "0A2B1A",
      label: "LOW RISK\n(Well-nourished, mild illness)",
      items: [
        "NRS-2002 <3 or NUTRIC <5",
        "EN feasible within 48 h",
        "Start EN within 24–48 h",
        "Withhold TPN for 7 days",
        "If EN still <60% target at Day 7→ add supplemental PN",
      ],
      timing: "TPN: Day 7+ only",
    },
    {
      x: 0.35, y: 4.5, color: C.gold, bg: "2B1A0A",
      label: "INTERMEDIATE RISK\n(Moderately malnourished)",
      items: [
        "NRS-2002 3–5 or NUTRIC 5–6",
        "EN attempted but suboptimal",
        "Optimise EN route & prokinetics",
        "Reassess at Day 3–4",
        "If <50% target → initiate PN Day 3–5",
      ],
      timing: "TPN: Day 3–5",
    },
    {
      x: 7.0, y: 1.8, color: C.red, bg: "2B0A0A",
      label: "HIGH RISK\n(Severely malnourished)",
      items: [
        "NRS-2002 ≥5 or NUTRIC ≥6",
        "Pre-existing malnutrition, BMI <18.5",
        "EN contraindicated or failed",
        "ESPEN & ASPEN: Start PN early",
        "Initiate TPN within 24–48 h of admission",
      ],
      timing: "TPN: Day 1–2",
    },
    {
      x: 7.0, y: 4.5, color: C.sky, bg: "0A1E2B",
      label: "EN CONTRAINDICATED\n(Any nutrition status)",
      items: [
        "Bowel obstruction, ischaemia, fistula",
        "Active GI bleeding, paralytic ileus",
        "Severe haemodynamic instability",
        "Start TPN once resuscitated",
        "Day 0–2 after stabilisation",
      ],
      timing: "TPN: After stabilisation",
    },
  ];

  cats.forEach(c => {
    const w = 6.25, h = 2.3;
    s.addShape(pres.ShapeType.roundRect, {
      x: c.x, y: c.y, w, h,
      fill: { color: c.bg }, line: { color: c.color, width: 2 },
      rectRadius: 0.1,
    });
    s.addText(c.label, {
      x: c.x + 0.1, y: c.y + 0.05, w: w - 0.2, h: 0.52,
      fontSize: 12, bold: true, color: c.color, fontFace: "Calibri",
    });
    s.addText(c.items.map(t => ({
      text: t, options: { bullet: { code: "2022" }, breakLine: true, fontSize: 11, color: C.bodyText }
    })), {
      x: c.x + 0.12, y: c.y + 0.58, w: w - 0.24, h: 1.3,
      fontFace: "Calibri", lineSpacingMultiple: 1.2,
    });
    // timing tag
    s.addShape(pres.ShapeType.roundRect, {
      x: c.x + w - 2.3, y: c.y + h - 0.38, w: 2.2, h: 0.32,
      fill: { color: c.color }, line: { width: 0 },
      rectRadius: 0.07,
    });
    s.addText(c.timing, {
      x: c.x + w - 2.3, y: c.y + h - 0.38, w: 2.2, h: 0.32,
      fontSize: 10, bold: true, color: C.navy, fontFace: "Calibri",
      align: "center", valign: "middle",
    });
  });

  addCite(s, "ESPEN 2023  |  ASPEN/SCCM 2016  |  Washington Manual  |  Hill A et al. JPEN 2022 (PMID 33899951)  |  Gao X et al. JAMA Surg 2022 (PMID 35293973)");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 9 — LANDMARK TRIALS
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Landmark Trials that Shaped Practice");
  slideTitle(s, "Key Clinical Trials — TPN Timing in the ICU");

  const trials = [
    {
      name: "EPaNIC Trial",
      year: "2011 (NEJM)", journal: "n=4,640 adults",
      color: C.red,
      finding: "Early PN (Day 1–2) vs Late PN (Day 8): Late PN → fewer infections, shorter ICU/hospital stay, less mechanical ventilation, more ICU-free days. Early PN increased complications.",
      impact: "Basis for ESPEN & ASPEN Day 7–8 recommendations",
    },
    {
      name: "SPN Trial",
      year: "2013 (Lancet)", journal: "n=305 adults",
      color: C.gold,
      finding: "Supplemental PN from Day 4 (when EN <60% target) vs continued inadequate EN: SPN reduced nosocomial infections and duration of ventilation.",
      impact: "Supports supplemental PN initiation at Day 4 when EN is insufficient",
    },
    {
      name: "CALORIES Trial",
      year: "2014 (NEJM)", journal: "n=2,400 adults",
      color: C.teal,
      finding: "Early PN vs Early EN in ICU patients where either was feasible: No mortality difference at 30 days. EN associated with more hypoglycaemia; PN with more vomiting/GI complications.",
      impact: "EN and PN have comparable outcomes when both are feasible; EN remains preferred",
    },
    {
      name: "PEPaNIC Trial",
      year: "2016 (NEJM)", journal: "n=1,440 children",
      color: C.sky,
      finding: "Paediatric ICU: Late PN (withholding PN for 7 days) → fewer infections, shorter ICU stay, earlier discharge vs early PN on admission.",
      impact: "Confirmed EPaNIC findings in paediatric population (Miller's Anaesthesia 10e)",
    },
  ];

  trials.forEach((t, i) => {
    const y = 1.85 + i * 1.32;
    s.addShape(pres.ShapeType.roundRect, {
      x: 0.35, y, w: 12.6, h: 1.18,
      fill: { color: "0D1E33" }, line: { color: t.color, width: 1.5 },
      rectRadius: 0.08,
    });
    // Trial name badge
    s.addShape(pres.ShapeType.rect, {
      x: 0.35, y, w: 2.5, h: 1.18,
      fill: { color: t.color }, line: { width: 0 },
    });
    s.addText([
      { text: t.name + "\n", options: { fontSize: 14, bold: true, color: C.navy, breakLine: false } },
      { text: t.year + "\n", options: { fontSize: 10, color: C.navy } },
      { text: t.journal, options: { fontSize: 10, color: C.navy, italic: true } },
    ], {
      x: 0.4, y: y + 0.05, w: 2.4, h: 1.05,
      fontFace: "Calibri", align: "center", valign: "middle",
    });
    s.addText([
      { text: "Finding: ", options: { bold: true, fontSize: 12, color: C.sky } },
      { text: t.finding + "\n", options: { fontSize: 12, color: C.bodyText } },
      { text: "Impact: ", options: { bold: true, fontSize: 11, color: t.color } },
      { text: t.impact, options: { fontSize: 11, color: C.lightGray, italic: true } },
    ], {
      x: 3.0, y: y + 0.06, w: 9.8, h: 1.05,
      fontFace: "Calibri", valign: "middle",
    });
  });

  addCite(s, "Van den Berghe et al. NEJM 2011 (EPaNIC)  |  Heidegger et al. Lancet 2013 (SPN)  |  Harvey et al. NEJM 2014 (CALORIES)  |  Fivez et al. NEJM 2016 (PEPaNIC) — cited in Miller's Anesthesia 10e");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 10 — PRACTICAL TIMING ALGORITHM
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Clinical Decision Algorithm");
  slideTitle(s, "Practical Algorithm: TPN Timing in the ICU Patient");

  // Flow chart using shapes and text
  // Box helper
  const fb = (x, y, w, h, label, sublabel, fc, bc) => {
    s.addShape(pres.ShapeType.roundRect, {
      x, y, w, h,
      fill: { color: bc || "0D2137" }, line: { color: fc || C.sky, width: 1.5 },
      rectRadius: 0.1,
    });
    s.addText(label, {
      x: x + 0.07, y: y + 0.03, w: w - 0.14, h: sublabel ? h * 0.55 : h - 0.06,
      fontSize: 11, bold: true, color: fc || C.sky, fontFace: "Calibri",
      align: "center", valign: "middle",
    });
    if (sublabel) {
      s.addText(sublabel, {
        x: x + 0.07, y: y + h * 0.52, w: w - 0.14, h: h * 0.48,
        fontSize: 9.5, color: C.lightGray, fontFace: "Calibri",
        align: "center", valign: "top",
      });
    }
  };

  // Top: ICU Admission
  fb(4.65, 1.7, 3.8, 0.55, "ICU Admission / Unable to Feed Orally", null, C.white, C.blue);

  // Arrow down
  s.addShape(pres.ShapeType.downArrow, { x: 6.25, y: 2.28, w: 0.5, h: 0.35, fill: { color: C.lightGray }, line: { width: 0 } });

  // Assess nutrition risk
  fb(4.65, 2.65, 3.8, 0.55, "Assess Nutritional Risk", "NRS-2002 or NUTRIC Score", C.sky, "091A2E");

  // Fork arrows
  s.addShape(pres.ShapeType.rect, { x: 2.2, y: 3.42, w: 9.6, h: 0.04, fill: { color: C.lightGray }, line: { width: 0 } });
  s.addShape(pres.ShapeType.downArrow, { x: 2.05, y: 3.46, w: 0.5, h: 0.32, fill: { color: C.lightGray }, line: { width: 0 } });
  s.addShape(pres.ShapeType.downArrow, { x: 6.05, y: 3.46, w: 0.5, h: 0.32, fill: { color: C.lightGray }, line: { width: 0 } });
  s.addShape(pres.ShapeType.downArrow, { x: 10.05, y: 3.46, w: 0.5, h: 0.32, fill: { color: C.lightGray }, line: { width: 0 } });

  s.addText("LOW RISK\nNRS <3 / NUTRIC <5", { x: 1.0, y: 3.2, w: 2.6, h: 0.42, fontSize: 10, bold: true, color: C.green, fontFace: "Calibri", align: "center" });
  s.addText("MODERATE RISK\nNRS 3–5 / NUTRIC 5–6", { x: 5.0, y: 3.2, w: 2.6, h: 0.42, fontSize: 10, bold: true, color: C.gold, fontFace: "Calibri", align: "center" });
  s.addText("HIGH RISK / EN\nContraindicated", { x: 9.0, y: 3.2, w: 2.6, h: 0.42, fontSize: 10, bold: true, color: C.red, fontFace: "Calibri", align: "center" });

  fb(0.6, 3.8, 3.1, 0.7, "Start EN within 24–48h", "Reassess daily. If EN <60% at Day 7→ add PN", C.green, "0A2B1A");
  fb(4.65, 3.8, 3.8, 0.7, "Start EN. Reassess Day 3–4.", "If EN <50%→ initiate PN Day 3–5", C.gold, "2B1A0A");
  fb(9.3, 3.8, 3.4, 0.7, "Start PN after stabilisation", "Day 1–2. EN if feasible in parallel", C.red, "2B0A0A");

  // Bottom convergence
  s.addShape(pres.ShapeType.rect, { x: 2.2, y: 4.54, w: 9.6, h: 0.04, fill: { color: C.lightGray }, line: { width: 0 } });
  s.addShape(pres.ShapeType.downArrow, { x: 6.25, y: 4.56, w: 0.5, h: 0.3, fill: { color: C.lightGray }, line: { width: 0 } });

  fb(3.8, 4.88, 5.7, 0.62, "Monitor Daily: Caloric delivery, glucose, electrolytes, TG", "Target 25–30 kcal/kg/day, 1.2–2.0 g protein/kg/day", C.sky, "091A2E");

  s.addShape(pres.ShapeType.downArrow, { x: 6.25, y: 5.52, w: 0.5, h: 0.3, fill: { color: C.lightGray }, line: { width: 0 } });

  fb(3.5, 5.84, 6.3, 0.6, "Wean PN as EN increases to meet targets", "Discontinue PN when EN ≥60% of requirements", C.teal, "0A2B1A");

  addCite(s, "ESPEN 2023 | ASPEN/SCCM 2016 | Washington Manual | Harrison's 22e | StatPearls: TPN (NCBI Bookshelf)");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 11 — PRACTICAL PRESCRIBING: WHAT TO ORDER
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "TPN Prescription in the ICU");
  slideTitle(s, "How to Prescribe TPN — Macronutrients & Targets");

  const cols = [
    {
      x: 0.35, title: "ENERGY", color: C.sky,
      items: [
        "Goal: 25–30 kcal/kg/day (non-obese)",
        "Acute phase (Day 1–3): 70% of target (hypocaloric)",
        "Obese (BMI ≥30): 11–14 kcal/kg actual BW",
        "Indirect calorimetry preferred to estimate REE",
        "Avoid overfeeding: respiratory failure, hyperglycaemia",
        "Glucose (dextrose): 3.4 kcal/g. Max 150–200 g/day",
        "Do not exceed 4–5 mg/kg/min glucose infusion rate",
      ],
    },
    {
      x: 4.6, title: "PROTEIN", color: C.teal,
      items: [
        "Goal: 1.2–2.0 g/kg/day (standard critically ill)",
        "Sepsis/burns/trauma: up to 2.0–2.5 g/kg/day",
        "Renal failure (no RRT): 1.0–1.5 g/kg/day",
        "On CRRT: increase to 2.5 g/kg/day (losses)",
        "40–50% essential amino acids in solution",
        "Branch-chain AA enriched for hepatic encephalopathy",
        "Essential AA only for severe renal insufficiency",
      ],
    },
    {
      x: 8.85, title: "LIPIDS & MICRONUTRIENTS", color: C.gold,
      items: [
        "Lipids: 20–30% of total calories",
        "Max infusion rate: 0.03–0.05 g/kg/h",
        "Do NOT use if TG >400 mg/dL",
        "ω-3 enriched emulsions: ↓ infections, ↓ ICU LOS\n  (meta-analysis 49 RCTs, Washington Manual)",
        "Check TG at least once during infusion",
        "Micronutrients: vitamins (A, C, D, E, K, B-complex)",
        "Trace elements: zinc, selenium, copper, chromium",
        "Electrolytes: Na, K, Mg, PO₄, Ca daily monitoring",
      ],
    },
  ];

  cols.forEach(c => {
    s.addShape(pres.ShapeType.roundRect, {
      x: c.x, y: 2.0, w: 4.1, h: 4.7,
      fill: { color: "0D2137" }, line: { color: c.color, width: 2 },
      rectRadius: 0.1,
    });
    s.addText(c.title, {
      x: c.x + 0.05, y: 2.06, w: 4.0, h: 0.42,
      fontSize: 14, bold: true, color: c.color, fontFace: "Calibri", align: "center",
    });
    s.addShape(pres.ShapeType.rect, {
      x: c.x, y: 2.48, w: 4.1, h: 0.05,
      fill: { color: c.color }, line: { width: 0 },
    });
    s.addText(c.items.map(t => ({
      text: t, options: { bullet: { code: "2022" }, breakLine: true, fontSize: 11.5, color: C.bodyText }
    })), {
      x: c.x + 0.1, y: 2.58, w: 3.88, h: 4.0,
      fontFace: "Calibri", lineSpacingMultiple: 1.25,
    });
  });

  addCite(s, "Washington Manual of Medical Therapeutics (PN Macronutrients, p.64)  |  ASPEN/SCCM 2016  |  ESPEN 2023  |  Harrison's 22e");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 12 — COMPLICATIONS OF TPN
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Complications of TPN — Vigilance is Key");
  slideTitle(s, "Complications: Why We Must Not Rush TPN");

  const sections = [
    {
      x: 0.35, y: 1.85, w: 4.0, color: C.sky,
      title: "Mechanical",
      items: ["Pneumothorax at line placement", "Haemothorax, air embolism", "Arterial puncture", "Line malposition / thrombosis", "Brachial plexus injury"],
    },
    {
      x: 4.6, y: 1.85, w: 4.0, color: C.gold,
      title: "Metabolic",
      items: ["Hyperglycaemia (most common) → target ≤180 mg/dL", "Hypoglycaemia (rebound on stop)", "Hypertriglyceridaemia (if TG>400 → stop lipids)", "Refeeding syndrome (↓ PO₄, K, Mg)", "Electrolyte imbalances (daily monitoring)"],
    },
    {
      x: 8.85, y: 1.85, w: 4.1, color: C.red,
      title: "Infectious",
      items: ["CRBSI (catheter-related bloodstream infection)", "Most serious complication", "Strict aseptic technique mandatory", "Early PN → significantly higher infection rates (EPaNIC)", "Use dedicated TPN lumen"],
    },
    {
      x: 0.35, y: 4.65, w: 4.0, color: C.teal,
      title: "Hepatobiliary",
      items: ["Hepatic steatosis (fatty liver)", "Cholestasis (acalculous cholecystitis)", "Elevated LFTs (transaminases, ALP)", "More common with prolonged PN >2 weeks", "Reduce dextrose/lipid; cycle PN if possible"],
    },
    {
      x: 4.6, y: 4.65, w: 4.0, color: C.lightGray,
      title: "GI / Immune",
      items: ["Gut mucosal atrophy (disuse)", "Increased bacterial translocation", "Immune suppression (ω-6 lipids)", "Reduced GI motility", "Use parallel EN whenever possible"],
    },
    {
      x: 8.85, y: 4.65, w: 4.1, color: C.gold,
      title: "Refeeding Syndrome",
      items: ["Risk: malnourished patients, alcoholism, anorexia", "Hypophosphataemia, hypomagnesaemia, hypokalaemia", "Can cause cardiac arrhythmia, respiratory failure", "Start at 50% target, increase over 3–5 days", "Monitor PO₄, Mg, K closely first 72 h"],
    },
  ];

  sections.forEach(sec => {
    const h = 2.35;
    s.addShape(pres.ShapeType.roundRect, {
      x: sec.x, y: sec.y, w: sec.w, h,
      fill: { color: "0D1E2D" }, line: { color: sec.color, width: 1.5 },
      rectRadius: 0.08,
    });
    s.addText(sec.title, {
      x: sec.x + 0.07, y: sec.y + 0.04, w: sec.w - 0.14, h: 0.38,
      fontSize: 13, bold: true, color: sec.color, fontFace: "Calibri", align: "center",
    });
    s.addShape(pres.ShapeType.rect, {
      x: sec.x, y: sec.y + 0.42, w: sec.w, h: 0.04,
      fill: { color: sec.color }, line: { width: 0 },
    });
    s.addText(sec.items.map(t => ({
      text: t, options: { bullet: { code: "2022" }, breakLine: true, fontSize: 11, color: C.bodyText }
    })), {
      x: sec.x + 0.1, y: sec.y + 0.5, w: sec.w - 0.2, h: 1.78,
      fontFace: "Calibri", lineSpacingMultiple: 1.2,
    });
  });

  addCite(s, "Washington Manual (PN Complications, p.64)  |  Harrison's 22e  |  EPaNIC Trial  |  ESPEN 2023  |  StatPearls: TPN");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 13 — SPECIAL POPULATIONS
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Special Populations in the ICU");
  slideTitle(s, "TPN Timing in Special Clinical Scenarios");

  const pops = [
    {
      icon: "🫁", label: "Post-Surgical / ARDS",
      color: C.sky,
      text: "Early EN within 24–48 h preferred post-surgery (Sabiston Surgery, ERAS guidelines). In ARDS: avoid overfeeding; ω-3 evidence conflicting. PN if EN not feasible after Day 7.",
    },
    {
      icon: "🩺", label: "Sepsis / Septic Shock",
      color: C.red,
      text: "Haemodynamic resuscitation FIRST (first 24–48 h). Avoid EN/PN until haemodynamically stable. Low-dose EN (trophic feeding) can begin in stable patients. TPN: Day 7 if EN fails.",
    },
    {
      icon: "🔥", label: "Burns",
      color: C.gold,
      text: "High protein requirement (2.0–2.5 g/kg/day). EN strongly preferred via NG tube. Very high caloric needs (30–35 kcal/kg/day). PN if GI failure. Can start EN within 6 h post-burn.",
    },
    {
      icon: "🫘", label: "Acute Kidney Injury / CRRT",
      color: C.teal,
      text: "AKI: Protein 1.0–1.5 g/kg/day (no RRT). On CRRT: increase to 2.5 g/kg/day to offset losses. Restrict fluid volume in TPN formulation. Avoid potassium overload.",
    },
    {
      icon: "⚖️", label: "Obesity (BMI ≥30)",
      color: C.lightGray,
      text: "Hypocaloric, high-protein strategy. Target 11–14 kcal/kg actual BW or 22–25 kcal/kg IBW. Protein ≥2.0 g/kg IBW/day. IV lipids twice weekly for essential fatty acids only (Washington Manual).",
    },
    {
      icon: "🧠", label: "Traumatic Brain Injury",
      color: C.sky,
      text: "Hypermetabolic state: caloric needs 140% of REE. Early EN preferred. PN if EN contraindicated. High protein (2.0 g/kg/day). Control glucose strictly (avoid hypoglycaemia).",
    },
  ];

  pops.forEach((p, i) => {
    const col = i % 3;
    const row = Math.floor(i / 3);
    const x = 0.35 + col * 4.3;
    const y = 1.85 + row * 2.55;
    s.addShape(pres.ShapeType.roundRect, {
      x, y, w: 4.1, h: 2.3,
      fill: { color: "0D1E2D" }, line: { color: p.color, width: 1.5 },
      rectRadius: 0.1,
    });
    s.addText(p.icon + "  " + p.label, {
      x: x + 0.1, y: y + 0.06, w: 3.9, h: 0.42,
      fontSize: 13, bold: true, color: p.color, fontFace: "Calibri",
    });
    s.addShape(pres.ShapeType.rect, {
      x, y: y + 0.48, w: 4.1, h: 0.04,
      fill: { color: p.color }, line: { width: 0 },
    });
    s.addText(p.text, {
      x: x + 0.1, y: y + 0.56, w: 3.9, h: 1.65,
      fontSize: 11, color: C.bodyText, fontFace: "Calibri", lineSpacingMultiple: 1.2,
    });
  });

  addCite(s, "ESPEN 2023  |  ASPEN/SCCM 2016  |  Washington Manual  |  Sabiston Surgery 21e  |  Harrison's 22e  |  Fishman's Pulmonary (ARDS nutrition)");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 14 — MONITORING TPN
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);
  sectionBar(s, "Monitoring TPN in the ICU");
  slideTitle(s, "TPN Monitoring Protocol — What to Check & When");

  // 3-column table
  const headers = ["Parameter", "Frequency", "Target / Action"];
  const rows = [
    ["Blood glucose", "Every 1–4 h initially; then 6-hourly when stable", "≤180 mg/dL. Use insulin infusion protocol if >180"],
    ["Serum electrolytes (Na, K, Cl)", "Daily", "Correct abnormalities; adjust PN formulation"],
    ["Phosphate, Magnesium, Calcium", "Daily (first week); twice weekly thereafter", "Critical — detect refeeding syndrome early"],
    ["Triglycerides", "At baseline; repeat within 24 h of starting lipids", "Hold lipids if TG >400 mg/dL"],
    ["Liver function tests (AST, ALT, ALP, bilirubin)", "Twice weekly", "Cholestasis / hepatic steatosis — reduce dextrose/fat"],
    ["Prealbumin / Albumin", "Weekly", "Albumin is poor marker of nutrition; use prealbumin or CRP/transferrin"],
    ["Nitrogen balance", "As needed (24 h urine urea nitrogen)", "Positive or zero balance = adequate protein"],
    ["Body weight / fluid balance", "Daily", "Avoid overloading; adjust volume"],
    ["Line inspection (catheter site)", "Daily", "Signs of infection → culture & consider removal"],
    ["Indirect calorimetry (REE)", "On Day 3–4 and reassess weekly", "Adjust caloric target; avoid over/underfeeding"],
  ];

  const tableY = 1.85;
  const colW = [2.8, 4.2, 5.7];
  const rowH = 0.48;

  // Header row
  let cx = 0.35;
  headers.forEach((h, i) => {
    s.addShape(pres.ShapeType.rect, { x: cx, y: tableY, w: colW[i], h: 0.45, fill: { color: C.blue }, line: { width: 0 } });
    s.addText(h, { x: cx + 0.07, y: tableY, w: colW[i] - 0.14, h: 0.45, fontSize: 13, bold: true, color: C.white, fontFace: "Calibri", valign: "middle" });
    cx += colW[i];
  });

  rows.forEach((row, ri) => {
    const y = tableY + 0.45 + ri * rowH;
    const bg = ri % 2 === 0 ? "0D1E33" : "091A2B";
    let cx2 = 0.35;
    row.forEach((cell, ci) => {
      s.addShape(pres.ShapeType.rect, { x: cx2, y, w: colW[ci], h: rowH, fill: { color: bg }, line: { color: "1E3A5F", width: 0.5 } });
      s.addText(cell, { x: cx2 + 0.07, y: y + 0.02, w: colW[ci] - 0.14, h: rowH - 0.04, fontSize: 10.5, color: ri === 0 && ci === 2 ? C.gold : C.bodyText, fontFace: "Calibri", valign: "middle" });
      cx2 += colW[ci];
    });
  });

  addCite(s, "Washington Manual of Medical Therapeutics (PN Monitoring)  |  ESPEN 2023  |  ASPEN/SCCM 2016  |  Harrison's 22e");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 15 — SUMMARY / TAKE-HOME MESSAGES
// ════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addBackground(s, C.navy);

  // Top gradient strip
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: "100%", h: 0.18, fill: { color: C.sky }, line: { width: 0 } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0.18, w: "100%", h: 0.08, fill: { color: C.teal }, line: { width: 0 } });

  s.addText("SUMMARY — Take-Home Messages", {
    x: 0.4, y: 0.35, w: 12.5, h: 0.55,
    fontSize: 22, bold: true, color: C.white, fontFace: "Calibri",
  });

  const msgs = [
    { num: "1", color: C.teal, text: "Enteral nutrition is ALWAYS first choice when the gut works. Start within 24–48 h of ICU admission." },
    { num: "2", color: C.sky, text: "In well-nourished patients: DO NOT start TPN in the first 7 days even if EN is insufficient — the harm of early PN exceeds the harm of short-term underfeeding." },
    { num: "3", color: C.gold, text: "In severely malnourished patients (NRS-2002 ≥5 or NUTRIC ≥6) or when EN is absolutely contraindicated: Start TPN early (Day 1–2) after haemodynamic stabilisation." },
    { num: "4", color: C.red, text: "Supplemental PN to augment insufficient EN should wait until Day 7 in non-malnourished, and Day 3–5 in moderately malnourished patients." },
    { num: "5", color: C.sky, text: "Monitor rigorously: glucose every 4–6 h (target ≤180 mg/dL), daily electrolytes, triglycerides, and watch for refeeding syndrome." },
    { num: "6", color: C.teal, text: "Wean PN as EN increases. Discontinue PN once EN meets ≥60% of energy requirements." },
  ];

  msgs.forEach((m, i) => {
    const y = 1.0 + i * 1.0;
    s.addShape(pres.ShapeType.ellipse, {
      x: 0.35, y: y + 0.05, w: 0.52, h: 0.52,
      fill: { color: m.color }, line: { width: 0 },
    });
    s.addText(m.num, {
      x: 0.35, y: y + 0.05, w: 0.52, h: 0.52,
      fontSize: 16, bold: true, color: C.navy, fontFace: "Calibri",
      align: "center", valign: "middle",
    });
    s.addText(m.text, {
      x: 1.0, y: y + 0.03, w: 11.8, h: 0.56,
      fontSize: 12.5, color: i === 1 ? C.white : C.bodyText,
      bold: i === 1,
      fontFace: "Calibri", valign: "middle",
    });
  });

  // Bottom banner
  s.addShape(pres.ShapeType.rect, {
    x: 0, y: 7.05, w: "100%", h: 0.45,
    fill: { color: C.blue }, line: { width: 0 },
  });
  s.addText("Sources: ESPEN 2023  •  ASPEN/SCCM 2016  •  Washington Manual of Medical Therapeutics  •  Harrison's Principles 22e  •  Miller's Anaesthesia 10e  •  Fishman's Pulmonary Diseases  •  Goldman-Cecil Medicine  •  StatPearls (NCBI Bookshelf)  •  EPaNIC, SPN, CALORIES, PEPaNIC Trials", {
    x: 0.3, y: 7.06, w: 12.7, h: 0.42,
    fontSize: 9, color: C.lightGray, fontFace: "Calibri",
  });
}

// ════════════════════════════════════════════════════════════════════════════
// WRITE FILE
// ════════════════════════════════════════════════════════════════════════════
pres.writeFile({ fileName: "/home/daytona/workspace/tpn-ppt/TPN_Critical_Illness_When_To_Start.pptx" })
  .then(() => console.log("✅ Presentation saved successfully."))
  .catch(err => { console.error("ERROR:", err); process.exit(1); });
You've run out of free credits. Sign up for a free account to continue using Orris.
This is a shared conversation. Sign in to Orris to start your own chat.