Create a PowerPoint presentation for diabetes mellitus

Asking for Preferences
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Reading File
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Searching Images

diabetes mellitus pathophysiology insulin pancreas islets

Searching Images

diabetic complications retinopathy nephropathy neuropathy microvascular

Running Command

mkdir -p /home/daytona/workspace/diabetes-pptx && ls /home/daytona/workspace/diabetes-pptx/

Writing File

~/diabetes-pptx/build.js

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

// ─── Fetch images from URLs ───────────────────────────────────────────────────
const imageUrls = [
  "https://cdn.orris.care/cdss_images/9ffefa078a10e7f1ce5cecab1604b3450dd4a00d45efbcc2da7bee934a0617e8.jpg",  // Islets of Langerhans immunofluorescence
  "https://cdn.orris.care/cdss_images/7320b27abf5b417434c17f911371d44df1836e0fb575bb0416a51a1537ff5917.jpg",  // Diabetic retinopathy fundus
  "https://cdn.orris.care/cdss_images/ad03c43ffb30047b3d41fff23b0db654aba1039f428198153dcbe59197c0842c.png",  // Pancreatic islet anatomy (Guyton)
];

let imgs = [];
try {
  const raw = execSync(
    `node /home/daytona/skills/shared/scripts/fetch_images.js ${imageUrls.map(u => `"${u}"`).join(" ")}`
  ).toString();
  imgs = JSON.parse(raw);
} catch (e) {
  console.error("Image fetch error:", e.message);
  imgs = imageUrls.map(() => ({ base64: null, error: "fetch failed" }));
}

// ─── Theme ───────────────────────────────────────────────────────────────────
const C = {
  darkBg:   "0D1B2A",  // deep navy
  midBg:    "1B2E45",  // medium navy
  accent:   "E8A838",  // golden amber
  accent2:  "2EC4B6",  // teal
  white:    "FFFFFF",
  lightGray:"D9E3EC",
  textGray: "A8BBCC",
  danger:   "E84545",
  success:  "27AE60",
};

const FONT_TITLE  = "Calibri";
const FONT_BODY   = "Calibri";

// ─── Init ────────────────────────────────────────────────────────────────────
let pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.author = "Medical Education";
pres.title  = "Diabetes Mellitus – Comprehensive Clinical Overview";

// ─── Helper: slide background ─────────────────────────────────────────────────
function addBg(slide, color = C.darkBg) {
  slide.background = { color };
}

// ─── Helper: section accent bar ──────────────────────────────────────────────
function accentBar(slide, label, color = C.accent) {
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.07, fill: { color }, line: { type: "none" } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 5.555, w: 10, h: 0.07, fill: { color }, line: { type: "none" } });
}

// ─── Helper: section divider label ───────────────────────────────────────────
function sectionPill(slide, label, x = 0.4, y = 0.2, bgColor = C.accent) {
  slide.addShape(pres.ShapeType.roundRect, {
    x, y, w: 2.8, h: 0.32, rectRadius: 0.16,
    fill: { color: bgColor }, line: { type: "none" },
  });
  slide.addText(label, {
    x, y, w: 2.8, h: 0.32,
    fontSize: 9, bold: true, color: C.darkBg, align: "center", valign: "middle",
    fontFace: FONT_BODY, margin: 0,
  });
}

// ─── Helper: card box ─────────────────────────────────────────────────────────
function card(slide, x, y, w, h, color = C.midBg, radius = 0.12) {
  slide.addShape(pres.ShapeType.roundRect, {
    x, y, w, h, rectRadius: radius,
    fill: { color },
    line: { color: "1E3A5A", pt: 1 },
    shadow: { type: "outer", color: "000000", opacity: 0.35, blur: 10, offset: 4, angle: 135 },
  });
}

// ─── Helper: bullet list ─────────────────────────────────────────────────────
function bulletList(slide, items, x, y, w, h, opts = {}) {
  const fontSize = opts.fontSize || 13;
  const color    = opts.color    || C.white;
  const indent   = opts.indent   || 0.3;
  const textArr = items.map((item, i) => ({
    text: item,
    options: {
      bullet: { type: "bullet", characterCode: "25B8", color: C.accent },
      indentLevel: 0,
      color,
      fontSize,
      fontFace: FONT_BODY,
      breakLine: i < items.length - 1,
      paraSpaceBefore: 3,
    },
  }));
  slide.addText(textArr, { x, y, w, h, valign: "top", margin: [4, 8, 0, 8] });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 1 – TITLE
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);

  // Background accent gradient strip
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 3.5, w: 10, h: 2.125, fill: { color: C.midBg }, line: { type: "none" } });
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: C.accent }, line: { type: "none" } });

  slide.addText("DIABETES MELLITUS", {
    x: 0.4, y: 0.55, w: 9.2, h: 1.2,
    fontSize: 44, bold: true, color: C.white, fontFace: FONT_TITLE, align: "left",
    charSpacing: 2,
  });
  slide.addText("A Comprehensive Clinical Overview", {
    x: 0.4, y: 1.7, w: 9.2, h: 0.5,
    fontSize: 20, color: C.accent, fontFace: FONT_BODY, align: "left", italic: true,
  });

  // Divider line
  slide.addShape(pres.ShapeType.line, {
    x: 0.4, y: 2.35, w: 9.2, h: 0,
    line: { color: C.accent, pt: 2 },
  });

  slide.addText("For Medical Students & Clinicians", {
    x: 0.4, y: 2.5, w: 5, h: 0.4,
    fontSize: 13, color: C.textGray, fontFace: FONT_BODY,
  });

  // Key stats row
  const stats = [
    { val: "537M",  label: "Adults with DM (2021)" },
    { val: "~10%",  label: "Global Prevalence" },
    { val: "3rd",   label: "Leading cause of blindness" },
    { val: "↑2x",   label: "CV mortality risk" },
  ];
  stats.forEach((s, i) => {
    const x = 0.4 + i * 2.4;
    card(slide, x, 3.7, 2.2, 1.5, "17304D");
    slide.addText(s.val, { x, y: 3.78, w: 2.2, h: 0.55, fontSize: 22, bold: true, color: C.accent, align: "center", fontFace: FONT_TITLE });
    slide.addText(s.label, { x, y: 4.3, w: 2.2, h: 0.55, fontSize: 9.5, color: C.lightGray, align: "center", fontFace: FONT_BODY });
  });

  slide.addText("Sources: IDF Diabetes Atlas 2021 | Harrison's Principles of Internal Medicine 22E | Guyton & Hall Medical Physiology", {
    x: 0, y: 5.38, w: 10, h: 0.22,
    fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 2 – DEFINITION & CLASSIFICATION
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "DEFINITION & CLASSIFICATION");

  slide.addText("What Is Diabetes Mellitus?", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  // Definition box
  card(slide, 0.3, 1.3, 9.4, 1.05, "112240");
  slide.addText(
    "A syndrome of impaired carbohydrate, fat, and protein metabolism caused by either lack of insulin secretion or decreased sensitivity of the tissues to insulin, resulting in chronic hyperglycaemia.",
    { x: 0.5, y: 1.37, w: 9.0, h: 0.92, fontSize: 12.5, color: C.lightGray, fontFace: FONT_BODY, italic: true, valign: "middle" }
  );

  // Type cards
  const types = [
    {
      title: "Type 1 DM",
      subtitle: "Insulin-Dependent",
      color: "1D3461",
      badge: C.danger,
      points: [
        "Autoimmune β-cell destruction",
        "Absolute insulin deficiency",
        "~5–10% of all DM cases",
        "Onset often < 30 yrs (juvenile)",
        "HLA-DR3/DR4 association",
        "Requires exogenous insulin lifelong",
      ],
    },
    {
      title: "Type 2 DM",
      subtitle: "Non-Insulin-Dependent",
      color: "1A3A28",
      badge: C.success,
      points: [
        "Insulin resistance + relative deficiency",
        "~90–95% of all DM cases",
        "Strong genetic & lifestyle component",
        "Associated with obesity (BMI > 30)",
        "Progressive β-cell dysfunction over time",
        "Oral agents ± insulin used",
      ],
    },
    {
      title: "Other Types",
      subtitle: "Secondary & Gestational",
      color: "2D2519",
      badge: C.accent,
      points: [
        "Gestational DM (GDM): pregnancy-related",
        "MODY: monogenic, young adults",
        "Pancreatic DM (pancreatitis, surgery)",
        "Drug-induced (steroids, thiazides)",
        "Endocrine (Cushing's, acromegaly)",
        "GDM ↑ risk of T2DM later in life",
      ],
    },
  ];

  types.forEach((t, i) => {
    const x = 0.3 + i * 3.15;
    card(slide, x, 2.45, 3.0, 2.9, t.color);
    // badge
    slide.addShape(pres.ShapeType.roundRect, { x: x + 0.1, y: 2.52, w: 1.3, h: 0.24, rectRadius: 0.12, fill: { color: t.badge }, line: { type: "none" } });
    slide.addText(t.subtitle, { x: x + 0.1, y: 2.52, w: 1.3, h: 0.24, fontSize: 7.5, bold: true, color: C.darkBg, align: "center", valign: "middle", fontFace: FONT_BODY, margin: 0 });
    slide.addText(t.title, { x: x + 0.1, y: 2.78, w: 2.8, h: 0.4, fontSize: 15, bold: true, color: C.white, fontFace: FONT_TITLE });
    bulletList(slide, t.points, x + 0.08, 3.2, 2.85, 2.0, { fontSize: 10.5 });
  });

  slide.addText("Guyton & Hall Medical Physiology, 14E  |  Harrison's Principles of Internal Medicine 22E", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 3 – EPIDEMIOLOGY
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "EPIDEMIOLOGY", 0.4, 0.2, "2EC4B6");

  slide.addText("Global Burden of Diabetes", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  // Big number cards
  const epi = [
    { num: "537 Million", sub: "Adults living with DM worldwide (2021)", icon: "🌍", color: "1D3461" },
    { num: "643 Million", sub: "Projected by 2030", icon: "📈", color: "1A3A28" },
    { num: "783 Million", sub: "Projected by 2045", icon: "⚠️", color: "2D2519" },
    { num: "240 Million", sub: "Undiagnosed (44% of total)", icon: "❓", color: "2D1A3A" },
  ];
  epi.forEach((e, i) => {
    const x = 0.3 + i * 2.35;
    card(slide, x, 1.35, 2.2, 1.6, e.color);
    slide.addText(e.icon, { x, y: 1.42, w: 2.2, h: 0.45, fontSize: 20, align: "center", fontFace: FONT_BODY });
    slide.addText(e.num, { x, y: 1.85, w: 2.2, h: 0.4, fontSize: 14, bold: true, color: C.accent, align: "center", fontFace: FONT_TITLE });
    slide.addText(e.sub, { x, y: 2.25, w: 2.2, h: 0.65, fontSize: 9, color: C.lightGray, align: "center", fontFace: FONT_BODY });
  });

  // Risk factors
  slide.addText("Key Risk Factors", {
    x: 0.4, y: 3.1, w: 9.2, h: 0.38,
    fontSize: 16, bold: true, color: C.accent2, fontFace: FONT_TITLE,
  });

  const risks = [
    ["Modifiable", C.success, [
      "Obesity (BMI ≥ 30 kg/m²)",
      "Physical inactivity",
      "Unhealthy diet (high glycaemic load)",
      "Hypertension & dyslipidaemia",
      "Smoking",
    ]],
    ["Non-Modifiable", C.danger, [
      "Family history / genetic predisposition",
      "Age > 45 years",
      "Ethnicity (South Asian, African, Hispanic)",
      "Prior gestational DM",
      "Low birth weight (IUGR)",
    ]],
    ["Metabolic / Clinical", C.accent, [
      "Impaired fasting glucose (IFG)",
      "Impaired glucose tolerance (IGT)",
      "Polycystic ovary syndrome (PCOS)",
      "Metabolic syndrome",
      "Drug-induced (steroids, atypical antipsychotics)",
    ]],
  ];

  risks.forEach(([title, color, pts], i) => {
    const x = 0.3 + i * 3.15;
    card(slide, x, 3.5, 3.0, 1.85, C.midBg);
    slide.addShape(pres.ShapeType.rect, { x, y: 3.5, w: 3.0, h: 0.05, fill: { color }, line: { type: "none" } });
    slide.addText(title, { x: x + 0.1, y: 3.55, w: 2.8, h: 0.3, fontSize: 11, bold: true, color, fontFace: FONT_TITLE });
    bulletList(slide, pts, x + 0.08, 3.85, 2.85, 1.45, { fontSize: 10 });
  });

  slide.addText("IDF Diabetes Atlas 10th Edition 2021", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 4 – PATHOPHYSIOLOGY (with islet image)
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "PATHOPHYSIOLOGY");

  slide.addText("Pathophysiology of Diabetes Mellitus", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  // Left column: text
  const pathPoints = [
    ["Islets of Langerhans", [
      "1–2 million islets in human pancreas",
      "β-cells (~60%): secrete insulin & amylin",
      "α-cells (~25%): secrete glucagon",
      "δ-cells (~10%): secrete somatostatin",
    ]],
    ["Type 1: Autoimmune Destruction", [
      "T-cell mediated destruction of β-cells",
      "Autoantibodies: anti-GAD, anti-IA2, anti-IAA",
      "HLA-DR3/DR4 confer susceptibility",
      "Absolute insulin deficiency → DKA risk",
    ]],
    ["Type 2: Insulin Resistance", [
      "Impaired insulin receptor signalling (PI3K/Akt)",
      "GLUT-4 downregulation in muscle & fat",
      "Hepatic glucose overproduction (gluconeogenesis ↑)",
      "Progressive β-cell exhaustion over time",
      "Incretin (GLP-1) defect amplifies dysfunction",
    ]],
  ];

  let yOff = 1.35;
  pathPoints.forEach(([heading, pts]) => {
    slide.addText(heading, {
      x: 0.35, y: yOff, w: 5.8, h: 0.32,
      fontSize: 12, bold: true, color: C.accent, fontFace: FONT_TITLE,
    });
    yOff += 0.3;
    bulletList(slide, pts, 0.35, yOff, 5.8, pts.length * 0.28 + 0.2, { fontSize: 11 });
    yOff += pts.length * 0.28 + 0.28;
  });

  // Right column: image
  if (imgs[0] && imgs[0].base64) {
    card(slide, 6.4, 1.25, 3.3, 3.1, "0A1525");
    slide.addImage({ data: imgs[0].base64, x: 6.5, y: 1.35, w: 3.1, h: 2.7,
      sizing: { type: "contain", w: 3.1, h: 2.7 } });
    slide.addText("Islets of Langerhans — Immunofluorescence\nRed: β-cells (insulin) | Blue: α-cells (glucagon) | Green: δ-cells (somatostatin)", {
      x: 6.35, y: 4.05, w: 3.4, h: 0.55, fontSize: 7.5, color: C.textGray,
      align: "center", fontFace: FONT_BODY, italic: true,
    });
  } else {
    card(slide, 6.4, 1.25, 3.3, 3.1, "0A1525");
    slide.addText("Islets of Langerhans\n\nβ-cells: insulin\nα-cells: glucagon\nδ-cells: somatostatin", {
      x: 6.5, y: 1.5, w: 3.1, h: 2.7, fontSize: 13, color: C.textGray, align: "center", fontFace: FONT_BODY,
    });
  }

  // Guyton ref
  card(slide, 0.3, 4.9, 9.4, 0.45, "0D1B2A");
  slide.addText("\"Diabetes mellitus is a syndrome of impaired carbohydrate, fat, and protein metabolism caused by either lack of insulin secretion or decreased sensitivity of tissues to insulin.\"  — Guyton & Hall, 14E", {
    x: 0.5, y: 4.93, w: 9.0, h: 0.38, fontSize: 8.5, color: C.textGray, italic: true, fontFace: FONT_BODY, valign: "middle",
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 5 – DIAGNOSIS
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "DIAGNOSIS", 0.4, 0.2, C.accent2);

  slide.addText("Diagnosis of Diabetes Mellitus", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  // ADA Diagnostic Criteria table header
  slide.addText("ADA Diagnostic Criteria (any ONE criterion, confirmed on repeat in asymptomatic patients):", {
    x: 0.35, y: 1.28, w: 9.3, h: 0.3, fontSize: 11.5, color: C.accent, fontFace: FONT_BODY, bold: true,
  });

  const criteria = [
    { test: "Fasting Plasma Glucose (FPG)", normal: "< 5.6 mmol/L\n(< 100 mg/dL)", prediab: "5.6–6.9 mmol/L\n(100–125 mg/dL)", dm: "≥ 7.0 mmol/L\n(≥ 126 mg/dL)", note: "No caloric intake for ≥8 h" },
    { test: "2-hr Plasma Glucose (OGTT 75 g)", normal: "< 7.8 mmol/L\n(< 140 mg/dL)", prediab: "7.8–11.0 mmol/L\n(140–199 mg/dL)", dm: "≥ 11.1 mmol/L\n(≥ 200 mg/dL)", note: "Oral Glucose Tolerance Test" },
    { test: "HbA1c", normal: "< 5.7%\n(< 39 mmol/mol)", prediab: "5.7–6.4%\n(39–47 mmol/mol)", dm: "≥ 6.5%\n(≥ 48 mmol/mol)", note: "Reflects ~3-month avg glucose" },
    { test: "Random Plasma Glucose", normal: "—", prediab: "—", dm: "≥ 11.1 mmol/L\n(≥ 200 mg/dL) + symptoms", note: "Polyuria, polydipsia, unexplained weight loss" },
  ];

  // Table columns: Test, Normal, Prediabetes, Diabetes, Note
  const colW = [2.5, 1.6, 1.8, 2.0, 1.8];
  const colX = [0.3, 2.85, 4.5, 6.35, 8.4];
  const headers = ["Test", "Normal", "Pre-Diabetes", "Diabetes", "Note"];
  const headerColors = [C.midBg, "1A3A28", "2D2519", C.danger, "1D2D3A"];

  // Header row
  headers.forEach((h, i) => {
    card(slide, colX[i], 1.63, colW[i], 0.38, headerColors[i]);
    slide.addText(h, { x: colX[i], y: 1.63, w: colW[i], h: 0.38, fontSize: 10, bold: true, color: C.accent, align: "center", valign: "middle", fontFace: FONT_TITLE, margin: 0 });
  });

  // Data rows
  criteria.forEach((row, ri) => {
    const y = 2.05 + ri * 0.72;
    const rowData = [row.test, row.normal, row.prediab, row.dm, row.note];
    const textColors = [C.white, C.success, C.accent, C.danger, C.textGray];
    rowData.forEach((cell, ci) => {
      card(slide, colX[ci], y, colW[ci], 0.68, ri % 2 === 0 ? C.midBg : "122030");
      slide.addText(cell, {
        x: colX[ci] + 0.05, y, w: colW[ci] - 0.1, h: 0.68,
        fontSize: 9, color: textColors[ci], align: "center", valign: "middle",
        fontFace: FONT_BODY, margin: 0,
      });
    });
  });

  // Classic symptoms
  slide.addText("Classic Symptoms of Hyperglycaemia:", {
    x: 0.35, y: 4.95, w: 3.5, h: 0.25, fontSize: 10, bold: true, color: C.accent2, fontFace: FONT_BODY,
  });
  const syms = ["Polyuria", "Polydipsia", "Polyphagia", "Weight loss", "Blurred vision", "Fatigue"];
  syms.forEach((s, i) => {
    slide.addShape(pres.ShapeType.roundRect, { x: 0.35 + i * 1.57, y: 5.2, w: 1.45, h: 0.26, rectRadius: 0.13, fill: { color: "17304D" }, line: { color: C.accent2, pt: 1 } });
    slide.addText(s, { x: 0.35 + i * 1.57, y: 5.2, w: 1.45, h: 0.26, fontSize: 9, color: C.white, align: "center", valign: "middle", fontFace: FONT_BODY, margin: 0 });
  });

  slide.addText("ADA Standards of Medical Care in Diabetes 2024", {
    x: 0, y: 5.45, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 6 – ACUTE COMPLICATIONS
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "ACUTE COMPLICATIONS", 0.4, 0.2, C.danger);

  slide.addText("Acute Complications", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  const acute = [
    {
      title: "Diabetic Ketoacidosis (DKA)",
      badge: "PREDOMINANTLY T1DM",
      badgeColor: C.danger,
      points: [
        "Absolute insulin deficiency → lipolysis & ketogenesis",
        "Triad: hyperglycaemia (> 11 mmol/L), ketonaemia, acidosis (pH < 7.3)",
        "Anion gap metabolic acidosis",
        "Symptoms: N/V, abdominal pain, Kussmaul breathing, fruity breath",
        "Triggers: infection, missed insulin, surgery, MI",
        "Rx: IV fluids, insulin infusion, K⁺ replacement, treat precipitant",
        "Mortality < 1% with appropriate management",
      ],
    },
    {
      title: "Hyperglycaemic Hyperosmolar State (HHS)",
      badge: "PREDOMINANTLY T2DM",
      badgeColor: C.accent,
      points: [
        "Profound hyperglycaemia (> 33 mmol/L), hyperosmolality (> 320 mOsm/kg)",
        "No significant ketosis (some insulin remains)",
        "Severe dehydration, altered consciousness, seizures",
        "Gradual onset over days–weeks",
        "Triggers: infection, non-compliance, new onset T2DM",
        "Rx: aggressive rehydration (0.9% saline), low-dose insulin, anticoagulation",
        "Mortality 10–20% (higher than DKA)",
      ],
    },
    {
      title: "Hypoglycaemia",
      badge: "ALL TYPES",
      badgeColor: C.accent2,
      points: [
        "Plasma glucose < 3.9 mmol/L (70 mg/dL) = Level 1",
        "< 3.0 mmol/L = Level 2 (clinically significant)",
        "< 2.8 mmol/L + symptoms = Level 3 (severe)",
        "Causes: excess insulin/sulphonylurea, missed meal, exercise",
        "Symptoms: tremor, sweating, palpitations, confusion, seizures",
        "Rx: 15–20 g fast-acting carbohydrate (rule of 15)",
        "Glucagon 1 mg IM/SC if unconscious",
      ],
    },
  ];

  acute.forEach((a, i) => {
    const x = 0.3 + i * 3.17;
    card(slide, x, 1.32, 3.05, 4.03, C.midBg);
    slide.addShape(pres.ShapeType.rect, { x, y: 1.32, w: 3.05, h: 0.06, fill: { color: a.badgeColor }, line: { type: "none" } });
    slide.addShape(pres.ShapeType.roundRect, { x: x + 0.08, y: 1.4, w: 2.0, h: 0.22, rectRadius: 0.11, fill: { color: a.badgeColor }, line: { type: "none" } });
    slide.addText(a.badge, { x: x + 0.08, y: 1.4, w: 2.0, h: 0.22, fontSize: 7, bold: true, color: C.darkBg, align: "center", valign: "middle", fontFace: FONT_BODY, margin: 0 });
    slide.addText(a.title, { x: x + 0.1, y: 1.65, w: 2.85, h: 0.5, fontSize: 12.5, bold: true, color: C.white, fontFace: FONT_TITLE });
    bulletList(slide, a.points, x + 0.08, 2.18, 2.9, 3.1, { fontSize: 10 });
  });

  slide.addText("Harrison's Principles of Internal Medicine 22E  |  Tintinalli's Emergency Medicine", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 7 – CHRONIC COMPLICATIONS (with retinopathy image)
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "CHRONIC COMPLICATIONS");

  slide.addText("Chronic Complications of Diabetes", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  // Microvascular column (left)
  card(slide, 0.3, 1.35, 4.5, 2.85, C.midBg);
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.35, w: 4.5, h: 0.06, fill: { color: C.accent2 }, line: { type: "none" } });
  slide.addText("MICROVASCULAR", { x: 0.4, y: 1.43, w: 4.3, h: 0.3, fontSize: 13, bold: true, color: C.accent2, fontFace: FONT_TITLE });

  const micro = [
    ["Diabetic Retinopathy", "Leading cause of blindness in working-age adults; background → proliferative; VEGF-driven neovascularisation; screen annually with dilated fundoscopy"],
    ["Diabetic Nephropathy", "Glomerular hyperfiltration → microalbuminuria → overt proteinuria → CKD; Kimmelstiel-Wilson nodules on biopsy; ACE-i/ARB protective"],
    ["Diabetic Neuropathy", "Distal symmetric polyneuropathy (stocking-glove); autonomic neuropathy (gastroparesis, postural hypotension); Charcot joint; foot ulceration risk"],
  ];

  let y = 1.78;
  micro.forEach(([title, desc]) => {
    slide.addText("▸ " + title, { x: 0.45, y, w: 4.2, h: 0.28, fontSize: 11, bold: true, color: C.accent, fontFace: FONT_TITLE });
    y += 0.27;
    slide.addText(desc, { x: 0.55, y, w: 4.1, h: 0.55, fontSize: 9.5, color: C.lightGray, fontFace: FONT_BODY });
    y += 0.6;
  });

  // Macrovascular column (right)
  card(slide, 5.1, 1.35, 4.6, 2.85, C.midBg);
  slide.addShape(pres.ShapeType.rect, { x: 5.1, y: 1.35, w: 4.6, h: 0.06, fill: { color: C.danger }, line: { type: "none" } });
  slide.addText("MACROVASCULAR", { x: 5.2, y: 1.43, w: 4.4, h: 0.3, fontSize: 13, bold: true, color: C.danger, fontFace: FONT_TITLE });

  const macro = [
    ["Coronary Artery Disease", "2–4× increased CV mortality; DM is CAD equivalent; aggressive statin therapy; aspirin in high-risk patients"],
    ["Cerebrovascular Disease", "Stroke risk doubled; lacunar infarcts common; tight BP control critical (target < 130/80 mmHg)"],
    ["Peripheral Artery Disease", "Critical limb ischaemia; diabetic foot syndrome; ABI < 0.9 diagnostic; leading cause of non-traumatic amputation"],
  ];

  y = 1.78;
  macro.forEach(([title, desc]) => {
    slide.addText("▸ " + title, { x: 5.25, y, w: 4.3, h: 0.28, fontSize: 11, bold: true, color: C.danger, fontFace: FONT_TITLE });
    y += 0.27;
    slide.addText(desc, { x: 5.35, y, w: 4.2, h: 0.55, fontSize: 9.5, color: C.lightGray, fontFace: FONT_BODY });
    y += 0.6;
  });

  // Retinopathy image
  if (imgs[1] && imgs[1].base64) {
    card(slide, 0.3, 4.28, 9.4, 1.02, "0A1525");
    slide.addImage({ data: imgs[1].base64, x: 0.4, y: 4.35, w: 2.1, h: 0.88,
      sizing: { type: "contain", w: 2.1, h: 0.88 } });
    slide.addText("Fundus photo: non-proliferative diabetic retinopathy showing microaneurysms (black arrow), haemorrhages (white arrow), and cotton-wool spots (green arrow). Right: IRMA — intraretinal microvascular abnormalities signalling progression toward proliferative DR.", {
      x: 2.6, y: 4.35, w: 7.0, h: 0.88, fontSize: 9, color: C.textGray, italic: true, fontFace: FONT_BODY, valign: "middle",
    });
  } else {
    card(slide, 0.3, 4.28, 9.4, 1.0, "0A1525");
    slide.addText("Chronic hyperglycaemia → advanced glycation end-products (AGEs) → vascular endothelial damage → micro & macrovascular disease", {
      x: 0.5, y: 4.35, w: 9.0, h: 0.88, fontSize: 11, color: C.textGray, italic: true, fontFace: FONT_BODY, valign: "middle",
    });
  }

  slide.addText("Harrison's Principles of Internal Medicine 22E  |  Braunwald's Heart Disease 12E", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 8 – MANAGEMENT: NON-PHARMACOLOGICAL
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "MANAGEMENT", 0.4, 0.2, C.success);

  slide.addText("Management — Lifestyle & Non-Pharmacological", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  const pillars = [
    {
      icon: "🥗", title: "Medical Nutrition Therapy",
      color: "1A3A28",
      pts: [
        "Reduce total caloric intake for weight loss (500–750 kcal/day deficit)",
        "Low glycaemic index foods; Mediterranean-style diet",
        "Limit saturated fats (< 10% total calories)",
        "Increase dietary fibre (≥ 25 g/day)",
        "Carbohydrate counting for insulin dosing (T1DM)",
        "Limit sugar-sweetened beverages & processed foods",
      ],
    },
    {
      icon: "🏃", title: "Physical Activity",
      color: "1D3461",
      pts: [
        "≥ 150 min/week moderate-intensity aerobic exercise",
        "Resistance training ≥ 2 days/week",
        "Break prolonged sitting every 30 minutes",
        "Exercise lowers HbA1c by ~0.5–1.0%",
        "Monitor glucose pre/post-exercise (T1DM)",
        "Graduated increase in activity to prevent hypoglycaemia",
      ],
    },
    {
      icon: "⚖️", title: "Weight Management",
      color: "2D2519",
      pts: [
        "5–10% weight loss → significant glycaemic improvement",
        "≥ 15% weight loss may achieve T2DM remission (DiRECT trial)",
        "Bariatric surgery: consider BMI ≥ 35 with DM (BMI ≥ 32.5 in Asian)",
        "Roux-en-Y gastric bypass most effective for glycaemic control",
        "Very low calorie diet (VLCD) protocols under supervision",
        "Weight loss reduces CV risk & medication burden",
      ],
    },
    {
      icon: "🧠", title: "Diabetes Self-Management Education",
      color: "2D1A3A",
      pts: [
        "Blood glucose monitoring — CGM preferred (T1DM; high-risk T2DM)",
        "Foot care: daily inspection, proper footwear, podiatry referral",
        "Sick day rules & hypoglycaemia management",
        "Smoking cessation (2× CV risk if diabetic smoker)",
        "Alcohol: moderate intake; risk of hypoglycaemia with insulin/SU",
        "Annual review: eyes, feet, kidneys, BP, lipids, HbA1c",
      ],
    },
  ];

  pillars.forEach((p, i) => {
    const col = i % 2;
    const row = Math.floor(i / 2);
    const x = 0.3 + col * 4.85;
    const y = 1.35 + row * 2.05;
    card(slide, x, y, 4.6, 1.95, p.color);
    slide.addText(`${p.icon}  ${p.title}`, { x: x + 0.15, y: y + 0.1, w: 4.3, h: 0.35, fontSize: 12.5, bold: true, color: C.accent, fontFace: FONT_TITLE });
    bulletList(slide, p.pts, x + 0.1, y + 0.45, 4.4, 1.4, { fontSize: 9.5 });
  });

  slide.addText("ADA Standards of Medical Care in Diabetes 2024  |  DiRECT Trial (NEJM 2018)", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 9 – PHARMACOLOGICAL MANAGEMENT
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "PHARMACOTHERAPY");

  slide.addText("Pharmacological Management of T2DM", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  const drugs = [
    { name: "Metformin", class: "Biguanide", moa: "↓ Hepatic gluconeogenesis; ↑ insulin sensitivity", hba1c: "1.0–2.0%", adv: "Weight neutral; CV benefit; cheap", adr: "GI upset; lactic acidosis (rare)", note: "1st line (if tolerated)", color: C.success },
    { name: "SGLT-2 Inhibitors", class: "Gliflozins", moa: "↑ Urinary glucose excretion via SGLT-2 blockade", hba1c: "0.5–1.0%", adv: "CV & renal benefit; weight loss; HF benefit", adr: "UTI/DKA (euglycaemic)", note: "Preferred: ASCVD/HF/CKD", color: C.accent2 },
    { name: "GLP-1 RAs", class: "Incretin Mimetics", moa: "↑ Glucose-dependent insulin; ↓ glucagon; ↓ gastric emptying", hba1c: "0.8–1.5%", adv: "Weight loss; CV benefit (liraglutide/semaglutide)", adr: "N/V; pancreatitis (rare)", note: "Preferred: obesity/ASCVD", color: C.accent },
    { name: "DPP-4 Inhibitors", class: "Gliptins", moa: "Inhibit DPP-4 → ↑ endogenous GLP-1 & GIP", hba1c: "0.5–0.8%", adv: "Weight neutral; well tolerated; oral", adr: "Nasopharyngitis; rare: pancreatitis", note: "2nd/3rd line", color: "5B85AA" },
    { name: "Sulphonylureas", class: "SUs", moa: "Close K⁺-ATP channels → insulin release from β-cells", hba1c: "1.0–2.0%", adv: "Highly effective; cheap; oral", adr: "Hypoglycaemia; weight gain", note: "2nd line (caution in elderly)", color: "9B5E3B" },
    { name: "Insulin Therapy", class: "Exogenous Insulin", moa: "Direct glucose uptake in muscle/fat; ↓ hepatic output", hba1c: "Unlimited effect", adv: "Most potent; required in T1DM & late T2DM", adr: "Hypoglycaemia; weight gain", note: "T1DM: mandatory; T2DM: step-up", color: "7B3F8B" },
  ];

  // Column headers
  const cols = ["Drug", "Class", "MoA", "HbA1c ↓", "Advantage", "ADR", "Note"];
  const colWs = [1.35, 1.15, 2.2, 0.85, 1.85, 1.6, 1.1];
  const colXs = [0.2, 1.6, 2.8, 5.05, 5.95, 7.85, 9.5];

  // Header row
  slide.addShape(pres.ShapeType.rect, { x: 0.2, y: 1.28, w: 9.55, h: 0.32, fill: { color: "0A1525" }, line: { type: "none" } });
  cols.forEach((h, i) => {
    slide.addText(h, { x: colXs[i], y: 1.28, w: colWs[i], h: 0.32, fontSize: 9, bold: true, color: C.accent, align: "center", valign: "middle", fontFace: FONT_TITLE, margin: 0 });
  });

  // Data rows
  drugs.forEach((d, ri) => {
    const y = 1.63 + ri * 0.6;
    const rowH = 0.57;
    const bg = ri % 2 === 0 ? C.midBg : "0F2035";
    slide.addShape(pres.ShapeType.rect, { x: 0.2, y, w: 9.55, h: rowH, fill: { color: bg }, line: { type: "none" } });
    // Left color bar
    slide.addShape(pres.ShapeType.rect, { x: 0.2, y, w: 0.08, h: rowH, fill: { color: d.color }, line: { type: "none" } });
    const rowData = [d.name, d.class, d.moa, d.hba1c, d.adv, d.adr, d.note];
    const fSizes = [10.5, 9, 8.5, 9, 8.5, 8.5, 8.5];
    const bolds = [true, false, false, true, false, false, false];
    rowData.forEach((cell, ci) => {
      slide.addText(cell, {
        x: colXs[ci] + 0.05, y: y + 0.04, w: colWs[ci] - 0.1, h: rowH - 0.08,
        fontSize: fSizes[ci], color: ci === 0 ? d.color : C.lightGray,
        bold: bolds[ci], align: "left", valign: "middle",
        fontFace: FONT_BODY, margin: 0,
      });
    });
  });

  slide.addText("ADA/EASD Consensus 2022  |  Harrison's Principles of Internal Medicine 22E", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 10 – MONITORING & TARGETS
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "MONITORING & TARGETS", 0.4, 0.2, C.accent2);

  slide.addText("Monitoring & Glycaemic Targets", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  // Targets table
  const targets = [
    { param: "HbA1c (General)", target: "< 7.0% (53 mmol/mol)", rationale: "Balances glycaemic benefit vs hypoglycaemia risk", color: C.success },
    { param: "HbA1c (Tight)", target: "< 6.5% (48 mmol/mol)", rationale: "Young, newly diagnosed, no CV disease, low hypo risk", color: C.accent2 },
    { param: "HbA1c (Relaxed)", target: "< 8.0% (64 mmol/mol)", rationale: "Frail elderly, short life expectancy, severe comorbidities", color: C.accent },
    { param: "Fasting/Pre-meal BG", target: "4.4–7.2 mmol/L (80–130 mg/dL)", rationale: "Target for self-monitored blood glucose", color: "5B85AA" },
    { param: "Post-meal BG (2 hr)", target: "< 10.0 mmol/L (180 mg/dL)", rationale: "Reduces risk of postprandial hyperglycaemia damage", color: "7B3F8B" },
    { param: "Blood Pressure", target: "< 130/80 mmHg", rationale: "Reduces CV and renal outcomes; ACE-i/ARB preferred", color: C.danger },
    { param: "LDL-Cholesterol", target: "< 1.8 mmol/L (< 70 mg/dL)", rationale: "High-intensity statin for all DM with ASCVD; moderate-intensity for others", color: "9B5E3B" },
  ];

  const colW2 = [2.4, 2.4, 4.9];
  const colX2 = [0.25, 2.7, 5.15];
  const hdr2 = ["Parameter", "Target", "Clinical Rationale"];
  hdr2.forEach((h, i) => {
    card(slide, colX2[i], 1.3, colW2[i], 0.3, "0A1525");
    slide.addText(h, { x: colX2[i], y: 1.3, w: colW2[i], h: 0.3, fontSize: 9.5, bold: true, color: C.accent, align: "center", valign: "middle", fontFace: FONT_TITLE, margin: 0 });
  });

  targets.forEach((t, i) => {
    const y = 1.63 + i * 0.49;
    const bg = i % 2 === 0 ? C.midBg : "0F2035";
    slide.addShape(pres.ShapeType.rect, { x: 0.25, y, w: 9.5, h: 0.46, fill: { color: bg }, line: { type: "none" } });
    slide.addShape(pres.ShapeType.rect, { x: 0.25, y, w: 0.07, h: 0.46, fill: { color: t.color }, line: { type: "none" } });
    slide.addText(t.param, { x: 0.37, y, w: 2.28, h: 0.46, fontSize: 10, bold: true, color: t.color, valign: "middle", fontFace: FONT_BODY, margin: 0 });
    slide.addText(t.target, { x: 2.7, y, w: 2.4, h: 0.46, fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", fontFace: FONT_BODY, margin: 0 });
    slide.addText(t.rationale, { x: 5.15, y, w: 4.6, h: 0.46, fontSize: 9.5, color: C.lightGray, valign: "middle", fontFace: FONT_BODY, margin: [0, 8, 0, 4] });
  });

  // CGM callout
  card(slide, 0.25, 5.05, 9.5, 0.38, "112240");
  slide.addText("⌚  Continuous Glucose Monitoring (CGM): Recommended in T1DM and insulin-treated T2DM. Target: Time-in-Range (TIR 70–180 mg/dL) ≥ 70% | Time Below Range < 4% | GMI replaces HbA1c in trending.", {
    x: 0.4, y: 5.07, w: 9.2, h: 0.34, fontSize: 9, color: C.accent2, fontFace: FONT_BODY, valign: "middle",
  });

  slide.addText("ADA Standards of Medical Care in Diabetes 2024  |  EASD Clinical Practice Guidelines 2023", {
    x: 0, y: 5.44, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 11 – T1DM INSULIN REGIMENS
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "INSULIN THERAPY");

  slide.addText("Insulin Therapy in Diabetes", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  // Insulin types table
  slide.addText("Insulin Preparations", {
    x: 0.35, y: 1.28, w: 4.5, h: 0.3, fontSize: 13, bold: true, color: C.accent, fontFace: FONT_TITLE,
  });

  const insulins = [
    { type: "Rapid-acting", eg: "Lispro, Aspart, Glulisine", onset: "5–15 min", peak: "30–90 min", dur: "3–5 h", use: "Mealtime bolus" },
    { type: "Short-acting", eg: "Regular (soluble)", onset: "30–60 min", peak: "2–4 h", dur: "5–8 h", use: "Mealtime (30 min before)" },
    { type: "Intermediate", eg: "NPH (Isophane)", onset: "1–3 h", peak: "5–8 h", dur: "12–18 h", use: "Twice daily basal" },
    { type: "Long-acting", eg: "Glargine, Detemir", onset: "1–2 h", peak: "Peakless", dur: "20–24 h", use: "Once daily basal" },
    { type: "Ultra-long", eg: "Degludec (Tresiba)", onset: "0.5–1.5 h", peak: "Flat", dur: "> 42 h", use: "Flexible once-daily basal" },
    { type: "Premixed", eg: "70/30 (NPH/Regular)", onset: "Dual", peak: "Dual", dur: "10–16 h", use: "BD regimen, less flexible" },
  ];

  const iCols = ["Type", "Examples", "Onset", "Peak", "Duration", "Clinical Use"];
  const iW = [1.4, 1.8, 0.8, 0.9, 0.9, 1.5];
  const iX = [0.25, 1.7, 3.55, 4.4, 5.35, 6.3];

  iCols.forEach((h, i) => {
    card(slide, iX[i], 1.63, iW[i], 0.28, "0A1525");
    slide.addText(h, { x: iX[i], y: 1.63, w: iW[i], h: 0.28, fontSize: 8.5, bold: true, color: C.accent, align: "center", valign: "middle", fontFace: FONT_TITLE, margin: 0 });
  });

  insulins.forEach((ins, ri) => {
    const y = 1.94 + ri * 0.42;
    const bg = ri % 2 === 0 ? C.midBg : "0F2035";
    slide.addShape(pres.ShapeType.rect, { x: 0.25, y, w: 7.6, h: 0.4, fill: { color: bg }, line: { type: "none" } });
    const cells = [ins.type, ins.eg, ins.onset, ins.peak, ins.dur, ins.use];
    cells.forEach((c, ci) => {
      slide.addText(c, { x: iX[ci], y: y + 0.04, w: iW[ci], h: 0.33, fontSize: 8.5, color: ci === 0 ? C.accent2 : C.lightGray, align: "center", valign: "middle", fontFace: FONT_BODY, margin: 0 });
    });
  });

  // Regimens (right side)
  card(slide, 8.05, 1.28, 1.75, 3.6, C.midBg);
  slide.addText("Basal-Bolus\n(Gold Standard)", { x: 8.1, y: 1.35, w: 1.65, h: 0.55, fontSize: 10, bold: true, color: C.accent, align: "center", fontFace: FONT_TITLE });
  bulletList(slide, ["Long-acting once daily", "Rapid-acting before each meal", "Covers physiological pattern", "Best HbA1c outcomes", "Requires carb counting"], 8.08, 1.93, 1.65, 2.0, { fontSize: 8.5, color: C.lightGray });

  // Sick day rules
  card(slide, 0.25, 4.47, 9.55, 0.88, "1C1020");
  slide.addText("⚠  Sick Day Rules for Insulin Users", { x: 0.45, y: 4.5, w: 5.0, h: 0.28, fontSize: 11, bold: true, color: C.danger, fontFace: FONT_TITLE });
  bulletList(slide, [
    "Never stop insulin during illness — sick day = increased insulin requirement",
    "Check blood glucose every 2–4 hours; check ketones if T1DM and BG > 14 mmol/L",
    "Maintain fluid intake; seek urgent review if: vomiting, BG > 20 mmol/L, or ketones > 1.5 mmol/L",
  ], 0.4, 4.78, 9.2, 0.55, { fontSize: 9.5, color: C.lightGray });

  slide.addText("Guyton & Hall Medical Physiology 14E  |  ADA Standards of Medical Care 2024", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 12 – SPECIAL SITUATIONS
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "SPECIAL SITUATIONS", 0.4, 0.2, C.accent);

  slide.addText("Diabetes in Special Situations", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  const situations = [
    {
      title: "🤰 Gestational Diabetes (GDM)",
      color: "1A2D4A",
      topColor: C.accent2,
      points: [
        "Occurs in ~7–10% of pregnancies",
        "Diagnosed by 75 g OGTT at 24–28 weeks gestation",
        "Criteria (WHO 2013): FPG ≥ 5.1, 1h ≥ 10.0, 2h ≥ 8.5 mmol/L",
        "Risks: macrosomia, shoulder dystocia, neonatal hypoglycaemia",
        "Rx: MNT first; metformin or insulin if targets not met",
        "50% progress to T2DM within 10 years post-delivery",
        "Screen offspring for metabolic syndrome",
      ],
    },
    {
      title: "🏥 Perioperative Diabetes",
      color: "1C2A1A",
      topColor: C.success,
      points: [
        "Hyperglycaemia worsens surgical outcomes (infection, wound healing)",
        "Target perioperative BG: 6–10 mmol/L (108–180 mg/dL)",
        "Omit oral agents morning of surgery; continue metformin if major surgery (risk lactic acidosis with hypoxia)",
        "SGLT-2i: stop ≥ 3 days pre-surgery (euglycaemic DKA risk)",
        "Insulin infusion preferred for complex/major surgery",
        "Close monitoring every 1–2 h intraoperatively",
      ],
    },
    {
      title: "👶 Paediatric / T1DM",
      color: "2D1A1A",
      topColor: C.danger,
      points: [
        "T1DM accounts for majority of childhood diabetes",
        "Present with rapid onset polyuria, polydipsia, DKA",
        "Intensive insulin therapy (basal-bolus or pump) from diagnosis",
        "Closed-loop systems (artificial pancreas) improving outcomes",
        "HbA1c target: < 7.0% (same as adults) to prevent complications",
        "Psychosocial support essential; diabetes distress common",
      ],
    },
    {
      title: "❤️ Diabetes & Cardiovascular Disease",
      color: "2D2000",
      topColor: C.accent,
      points: [
        "CV disease is the leading cause of mortality in DM",
        "DM is treated as CAD equivalent for lipid management",
        "SGLT-2i (empagliflozin, dapagliflozin) and GLP-1 RAs (liraglutide, semaglutide) with proven CV benefit",
        "Aspirin: 75–100 mg/day for secondary prevention",
        "Statin therapy for primary & secondary prevention",
        "Aggressive multifactorial risk factor management (ABC: A1c, BP, Cholesterol)",
      ],
    },
  ];

  situations.forEach((s, i) => {
    const col = i % 2;
    const row = Math.floor(i / 2);
    const x = 0.3 + col * 4.85;
    const y = 1.32 + row * 2.02;
    card(slide, x, y, 4.6, 1.92, s.color);
    slide.addShape(pres.ShapeType.rect, { x, y, w: 4.6, h: 0.05, fill: { color: s.topColor }, line: { type: "none" } });
    slide.addText(s.title, { x: x + 0.15, y: y + 0.09, w: 4.3, h: 0.35, fontSize: 12, bold: true, color: C.white, fontFace: FONT_TITLE });
    bulletList(slide, s.points, x + 0.1, y + 0.46, 4.4, 1.38, { fontSize: 9.5 });
  });

  slide.addText("Harrison's Principles of Internal Medicine 22E  |  NICE NG28 Diabetes in Pregnancy 2023", {
    x: 0, y: 5.42, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 13 – SUMMARY & KEY TAKE-AWAYS
// ─────────────────────────────────────────────────────────────────────────────
{
  const slide = pres.addSlide();
  addBg(slide);
  accentBar(slide);
  sectionPill(slide, "SUMMARY", 0.4, 0.2, C.accent);

  slide.addText("Key Clinical Pearls", {
    x: 0.4, y: 0.65, w: 9.2, h: 0.55,
    fontSize: 26, bold: true, color: C.white, fontFace: FONT_TITLE,
  });

  const pearls = [
    { num: "01", text: "DM is a heterogeneous metabolic syndrome — distinguish T1 (autoimmune, absolute insulin deficiency) from T2 (insulin resistance + relative deficiency) before commencing treatment.", color: C.danger },
    { num: "02", text: "Diagnosis requires objective confirmation: FPG ≥ 7.0 mmol/L, 2h OGTT ≥ 11.1 mmol/L, HbA1c ≥ 6.5%, or random glucose ≥ 11.1 mmol/L with symptoms.", color: C.accent },
    { num: "03", text: "Metformin remains first-line for T2DM. Add SGLT-2 inhibitor or GLP-1 RA in patients with established ASCVD, heart failure, or CKD irrespective of HbA1c.", color: C.success },
    { num: "04", text: "HbA1c target should be individualised: < 7% is general, < 6.5% for low-risk young patients, relaxed < 8% for frail elderly. CGM Time-in-Range is an emerging complementary metric.", color: C.accent2 },
    { num: "05", text: "Chronic complications drive mortality and morbidity: annual screening for retinopathy, nephropathy (uACR + eGFR), neuropathy, and cardiovascular risk is mandatory.", color: "5B85AA" },
    { num: "06", text: "Lifestyle intervention remains the cornerstone: structured nutrition, ≥150 min/week exercise, and ≥5–10% weight loss can achieve DM remission or significantly reduce medication burden.", color: "9B5E3B" },
  ];

  pearls.forEach((p, i) => {
    const y = 1.35 + i * 0.67;
    card(slide, 0.3, y, 9.4, 0.62, i % 2 === 0 ? C.midBg : "0F2035");
    // number circle
    slide.addShape(pres.ShapeType.ellipse, { x: 0.38, y: y + 0.13, w: 0.38, h: 0.38, fill: { color: p.color }, line: { type: "none" } });
    slide.addText(p.num, { x: 0.38, y: y + 0.13, w: 0.38, h: 0.38, fontSize: 10, bold: true, color: C.darkBg, align: "center", valign: "middle", fontFace: FONT_TITLE, margin: 0 });
    slide.addText(p.text, { x: 0.85, y: y + 0.06, w: 8.7, h: 0.52, fontSize: 10.5, color: C.lightGray, valign: "middle", fontFace: FONT_BODY });
  });

  slide.addText("Harrison's 22E | Guyton & Hall 14E | ADA Standards 2024 | IDF Atlas 2021 | ADA/EASD Consensus 2022", {
    x: 0, y: 5.43, w: 10, h: 0.18, fontSize: 7, color: "4A6080", align: "center", fontFace: FONT_BODY,
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// WRITE FILE
// ─────────────────────────────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/diabetes-pptx/Diabetes_Mellitus.pptx" })
  .then(() => console.log("✅ Saved: Diabetes_Mellitus.pptx"))
  .catch(err => console.error("❌ Error:", err));
Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.

Create a PowerPoint presentation for Section 1: Essential Physiology (Slides 2-5) Slide 2: Normal Glucose Homeostasis • Blood glucose maintained ~4-6 mmol/L (70-110 mg/dL) fasting • Sources: Dietary carbohydrates, hepatic gluconeogenesis/glycogenolysis • Key hormones: Insulin (lowers), Glucagon (raises) • Other: Cortisol, catecholamines, growth hormone (counter-regulatory) Slide 3: Role of Insulin • Produced by pancreatic beta cells • Actions: o Promotes glucose uptake (GLUT4 in muscle/adipose) o Glycogen synthesis (liver/muscle) o Inhibits lipolysis and gluconeogenesis • Anabolic hormone Slide 4: Role of Glucagon • Produced by pancreatic alpha cells • Actions: o Stimulates glycogenolysis and gluconeogenesis in liver o Promotes ketogenesis in prolonged fasting • Released in response to low blood glucose Slide 5: Pancreatic Islets and Regulation • Diagram of islets of Langerhans (beta, alpha cells) • Feedback loop: High glucose → insulin release; Low glucose → glucagon release • Postprandial vs. fasting states Section 2: Definitions and Classification (Slides 6-8) Slide 6: Definition of Diabetes Mellitus • Group of metabolic disorders characterized by chronic hyperglycemia due to defects in insulin secretion, insulin action, or both • Leads to disturbances in carbohydrate, fat, and protein metabolism Slide 7: Main Types of Diabetes • Type 1 DM (5-10%): Autoimmune beta-cell destruction → absolute insulin deficiency • Type 2 DM (90-95%): Insulin resistance + relative insulin deficiency • Gestational DM • Other: MODY, secondary (steroids, pancreatitis, etc.), prediabetes Slide 8: Diagnostic Criteria • Fasting plasma glucose ≥7.0 mmol/L (126 mg/dL) • 2h OGTT ≥11.1 mmol/L (200 mg/dL) • HbA1c ≥6.5% (48 mmol/mol) • Random glucose ≥11.1 mmol/L + symptoms • (Note: Confirm with repeat test unless symptomatic) Section 3: Pathophysiology (Slides 9-13) Slide 9: Pathophysiology of Type 1 DM • Autoimmune destruction of beta cells (T-cell mediated) • Genetic predisposition (HLA) + environmental triggers (viruses?) • Absolute insulin deficiency → hyperglycemia, lipolysis, ketogenesis Slide 10: Pathophysiology of Type 2 DM • Insulin resistance (muscle, liver, adipose) • Compensatory hyperinsulinemia initially • Progressive beta-cell dysfunction/failure • Contributing factors: Obesity, visceral fat, inflammation, genetics Slide 11: Hyperglycemia Consequences • Osmotic diuresis (polyuria, polydipsia, dehydration) • Glycosuria • Long-term: Advanced glycation end-products (AGEs), oxidative stress, vascular damage Slide 12-13: Flowcharts • One for T1DM, one for T2DM progression Section 4: Clinical Features and Natural History (Slides 14-18) Slide 14: Classic Symptoms of Hyperglycemia • Polyuria, polydipsia, polyphagia • Weight loss (especially T1) • Fatigue, blurred vision, recurrent infections • Slow-healing wounds Slide 15: Natural History of Type 1 DM • Rapid onset (weeks) • Often presents with DKA in children/young adults • Lifelong insulin dependence Slide 16: Natural History of Type 2 DM • Insidious onset (years) • Often diagnosed incidentally • Prediabetes phase → overt diabetes → complications • Strongly associated with obesity/metabolic syndrome Slide 17-18: Chronic Complications • Microvascular: Retinopathy, nephropathy, neuropathy • Macrovascular: CAD, stroke, peripheral artery disease • Others: Diabetic foot, infections, skin changes • Timeline graphic showing progression with poor control Section 5: Investigations (Slides 19-21) Slide 19: Diagnostic & Monitoring Tests • Blood glucose (fasting/random) • HbA1c (glycated hemoglobin) – reflects 2-3 months • OGTT • C-peptide/insulin levels (to differentiate T1 vs T2) • Autoantibodies (GAD, islet cell) for T1 Slide 20: Screening for Complications • Eye exam (fundoscopy/retinopathy screening) • Urine ACR (albumin-creatinine ratio) • eGFR/renal function • Lipid profile, ECG/foot exam • Neuropathy assessment Slide 21: Other Labs • Electrolytes, ketones (in illness), arterial blood gas Section 6: Management (Slides 22-28) Slide 22: General Principles • Patient education, lifestyle modification (diet, exercise, weight loss) • Glycemic targets (individualized, e.g., HbA1c <7%) • Multidisciplinary care: Dietitian, educator, podiatrist, etc. • Cardiovascular risk reduction (BP, lipids, smoking) Slide 23: Type 1 DM Management • Insulin therapy (basal-bolus, pump) • Carbohydrate counting, self-monitoring/CGM • Sick day rules Slide 24: Type 2 DM Management • Lifestyle first • Metformin (first-line) • Other orals: SGLT2i, GLP-1RA, sulfonylureas, DPP4i • Insulin if needed • Note benefits of SGLT2i/GLP-1 for CV/renal protection Slide 25: Monitoring and Follow-up • Regular HbA1c, self-monitoring • Annual complication screening Section 7: Diabetic Emergencies (Slides 26-34) Slide 26: Overview of Emergencies • Hyperglycemic: DKA, HHS • Hypoglycemia • Others: Hyperosmolar hyperglycemic state, lactic acidosis Slide 27: Diabetic Ketoacidosis (DKA) • Triad: Hyperglycemia (>11-13.9 mmol/L), ketonemia/acidosis (pH<7.3, bicarb<15), anion gap • Mostly T1DM (can occur in T2) • Precipitants: Infection, insulin omission, illness Slide 28: DKA Clinical Features • Polyuria/polydipsia, nausea/vomiting, abdominal pain • Kussmaul breathing, fruity breath (acetone) • Dehydration, altered mental status/coma Slide 29: HHS (Hyperosmolar Hyperglycemic State) • Severe hyperglycemia (>33 mmol/L), hyperosmolality (>320 mOsm), profound dehydration • Minimal/no ketoacidosis • Mostly elderly T2DM, insidious onset (days-weeks) • Higher mortality than DKA Slide 30: Hypoglycemia • Blood glucose <4 mmol/L (or <3.9 with symptoms) • Causes: Excess insulin/meds, missed meals, exercise • Symptoms: Adrenergic (sweating, tremor) + neuroglycopenic (confusion, seizure) Slide 31-32: Management of DKA/HHS • ABC, fluids (normal saline initially), insulin (after K+ check), electrolytes (esp. potassium), treat precipitant • Monitoring: Hourly glucose, electrolytes, gap closure • Key differences table (DKA vs HHS) Slide 33: Hypoglycemia Management • Conscious: Oral carbs (15g) • Unconscious: IV dextrose or IM glucagon • Prevent recurrence Slide 34: Prevention of Emergencies • Education, sick day rules, access to supplies, regular follow-up Conclusion & References (Slides 35-36) • Summary key points • Importance of early diagnosis, tight control, and education • References (ADA, NICE, or key sources) • Q&A slide Additional Tips for Creation: • Use simple diagrams (glucose regulation loop, DKA pathway). • Include tables for comparisons (DKA vs HHS, T1 vs T2). • Add high-yield images: Fundus photo of retinopathy, foot ulcer (with sensitivity). • Total timing: 30-45 minutes presentation. • Sources: Base on guidelines (e.g., ADA, WHO) for accuracy.

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.
This is a shared conversation. Sign in to Orris to start your own chat.