~/pnet-summary/generate_pnet.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
HeadingLevel, AlignmentType, BorderStyle, WidthType, ShadingType,
VerticalAlign, PageNumber, Header, Footer, TableOfContents,
PageBreak, UnderlineType
} = require('docx');
const fs = require('fs');
// ─── Color palette ───────────────────────────────────────────────────────────
const BLUE_DARK = "1A3A5C"; // Deep navy – main headings
const BLUE_MID = "2E6DA4"; // Mid blue – sub-headings, table headers
const BLUE_LIGHT = "D6E4F0"; // Pale blue – table header shading
const TEAL = "0E7C7B"; // Teal – h3 / callout labels
const GREY_BG = "F4F6F9"; // Very light grey – alternating table rows
const WHITE = "FFFFFF";
const TEXT_DARK = "1A1A1A";
// ─── Helpers ─────────────────────────────────────────────────────────────────
function h1(text) {
return new Paragraph({
heading: HeadingLevel.HEADING_1,
spacing: { before: 360, after: 120 },
children: [new TextRun({ text, color: BLUE_DARK, size: 36, bold: true, font: "Calibri" })]
});
}
function h2(text) {
return new Paragraph({
heading: HeadingLevel.HEADING_2,
spacing: { before: 280, after: 100 },
children: [new TextRun({ text, color: BLUE_MID, size: 28, bold: true, font: "Calibri" })]
});
}
function h3(text) {
return new Paragraph({
heading: HeadingLevel.HEADING_3,
spacing: { before: 200, after: 80 },
children: [new TextRun({ text, color: TEAL, size: 24, bold: true, font: "Calibri" })]
});
}
function body(text) {
return new Paragraph({
spacing: { before: 60, after: 60 },
children: [new TextRun({ text, size: 22, color: TEXT_DARK, font: "Calibri" })]
});
}
function bullet(text, bold_prefix = "") {
return new Paragraph({
bullet: { level: 0 },
spacing: { before: 40, after: 40 },
children: bold_prefix
? [
new TextRun({ text: bold_prefix, bold: true, size: 22, color: TEXT_DARK, font: "Calibri" }),
new TextRun({ text, size: 22, color: TEXT_DARK, font: "Calibri" })
]
: [new TextRun({ text, size: 22, color: TEXT_DARK, font: "Calibri" })]
});
}
function subbullet(text, bold_prefix = "") {
return new Paragraph({
bullet: { level: 1 },
spacing: { before: 30, after: 30 },
children: bold_prefix
? [
new TextRun({ text: bold_prefix, bold: true, size: 20, color: TEXT_DARK, font: "Calibri" }),
new TextRun({ text, size: 20, color: TEXT_DARK, font: "Calibri" })
]
: [new TextRun({ text, size: 20, color: TEXT_DARK, font: "Calibri" })]
});
}
function divider() {
return new Paragraph({
spacing: { before: 120, after: 120 },
border: { bottom: { style: BorderStyle.SINGLE, size: 1, color: BLUE_MID } },
children: []
});
}
function spacer() {
return new Paragraph({ children: [new TextRun({ text: "" })] });
}
// ─── Table helpers ────────────────────────────────────────────────────────────
function makeTableRow(cells, isHeader = false, shade = WHITE) {
return new TableRow({
tableHeader: isHeader,
children: cells.map(cell =>
new TableCell({
shading: isHeader
? { fill: BLUE_LIGHT, type: ShadingType.CLEAR, color: "auto" }
: { fill: shade, type: ShadingType.CLEAR, color: "auto" },
verticalAlign: VerticalAlign.CENTER,
margins: { top: 80, bottom: 80, left: 120, right: 120 },
children: [new Paragraph({
alignment: AlignmentType.LEFT,
children: [new TextRun({
text: cell,
bold: isHeader,
size: isHeader ? 20 : 19,
color: isHeader ? BLUE_DARK : TEXT_DARK,
font: "Calibri"
})]
})]
})
)
});
}
function makeTable(headers, rows, colWidths) {
const headerRow = makeTableRow(headers, true);
const dataRows = rows.map((row, i) =>
makeTableRow(row, false, i % 2 === 0 ? WHITE : GREY_BG)
);
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
columnWidths: colWidths,
rows: [headerRow, ...dataRows],
borders: {
top: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID },
bottom: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID },
left: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID },
right: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID },
insideH:{ style: BorderStyle.SINGLE, size: 2, color: "CCCCCC" },
insideV:{ style: BorderStyle.SINGLE, size: 2, color: "CCCCCC" },
}
});
}
// ─── Title page elements ──────────────────────────────────────────────────────
function titleBlock() {
return [
new Paragraph({ spacing: { before: 800, after: 200 }, children: [] }),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 160 },
children: [new TextRun({ text: "PANCREATIC NEUROENDOCRINE TUMORS", bold: true, size: 52, color: BLUE_DARK, font: "Calibri" })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 120 },
children: [new TextRun({ text: "A Comprehensive Clinical Summary", size: 36, color: BLUE_MID, italics: true, font: "Calibri" })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 60 },
children: [new TextRun({ text: "PNETs / panNENs", size: 28, color: TEAL, bold: true, font: "Calibri" })]
}),
divider(),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 60 },
children: [new TextRun({ text: "Sources: Harrison's Principles of Internal Medicine 22e (2025) | Schwartz's Principles of Surgery 11e", size: 18, color: "666666", italics: true, font: "Calibri" })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 60 },
children: [new TextRun({ text: "Fischer's Mastery of Surgery 8e | Maingot's Abdominal Operations | Current Surgical Therapy 14e", size: 18, color: "666666", italics: true, font: "Calibri" })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 60 },
children: [new TextRun({ text: `Date: ${new Date().toLocaleDateString('en-GB', {day:'2-digit',month:'long',year:'numeric'})}`, size: 18, color: "666666", font: "Calibri" })]
}),
new Paragraph({ children: [new PageBreak()] })
];
}
// ─── Document content ─────────────────────────────────────────────────────────
const content = [
...titleBlock(),
// ═══════════════════════════════════════════════════════════════════
h1("1. Overview & Epidemiology"),
body("Pancreatic neuroendocrine tumors (PNETs), also called panNETs or islet cell tumors, are a heterogeneous group of neoplasms arising from precursor cells of the endocrine pancreas. They were first described in 1869 and account for approximately 7% of all neuroendocrine tumors and only 1-3% of all pancreatic neoplasms."),
spacer(),
bullet("Incidence: ~0.5 per 100,000 persons per year (rising due to improved cross-sectional imaging)"),
bullet("The incidence of gastroenteropancreatic NETs increased 6.4-fold in the US between 1973-2012 (SEER data)"),
bullet("Mean age at diagnosis: 50 years; slight male predominance for some subtypes"),
bullet("80-90% are sporadic; 10-20% are associated with familial syndromes"),
bullet("60-90% are nonfunctional (NF-PNETs) - found incidentally on imaging"),
spacer(),
h3("Hereditary Syndromes Associated with PNETs"),
makeTable(
["Syndrome", "Gene / Locus", "Associated Features"],
[
["MEN-1 (most common)", "MEN1 / 11q13 (menin)", "Parathyroid hyperplasia, pituitary adenoma, pancreatic NETs"],
["Von Hippel-Lindau (VHL)", "VHL / 3p25", "Cerebellar hemangioblastoma, renal cell carcinoma, pheochromocytoma"],
["Neurofibromatosis type 1", "NF1 (neurofibromin)", "Café au lait spots, neurofibromas, pancreatic & extrapancreatic NETs"],
["Tuberous sclerosis", "TSC1 (hamartin) / TSC2 (tuberin)", "Hamartomas, renal angiomyolipomas, cortical tubers"]
],
[2500, 2000, 3500]
),
spacer(),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("2. Classification (WHO 2017)"),
body("The 2017 WHO classification relies on histopathologic criteria — Ki-67 proliferative index and mitotic count — to predict tumor grade and biologic behavior. Two broad categories exist: well-differentiated panNETs and poorly differentiated panNECs."),
spacer(),
makeTable(
["Classification / Grade", "Differentiation", "Ki-67 Index (%)", "Mitotic Count / 10 HPF"],
[
["panNET Grade 1 (Low)", "Well-differentiated", "< 3%", "< 2"],
["panNET Grade 2 (Intermediate)", "Well-differentiated", "3 – 20%", "2 – 20"],
["panNET Grade 3 (High)", "Well-differentiated", "> 20%", "> 20"],
["panNEC Grade 3 (Small cell / Large cell)", "Poorly differentiated", "> 20%", "> 20"]
],
[2500, 2000, 2000, 2000]
),
spacer(),
body("Key terminological distinction:"),
bullet("panNEN (pancreatic neuroendocrine neoplasm) = entire heterogeneous group"),
bullet("panNET = well-differentiated tumors; generally lower malignant potential"),
bullet("panNEC = poorly differentiated carcinoma; behaves aggressively like SCLC"),
body("Immunohistochemistry: Staining for chromogranin A and synaptophysin confirms neuroendocrine differentiation. Grade 3 tumors show marked pleomorphism and abundant mitoses."),
spacer(),
h3("Molecular Features"),
bullet("MEN1 gene mutations: 44% of sporadic PNETs (most common)"),
bullet("DAXX / ATRX mutations: 43% of sporadic PNETs (chromatin remodeling complex)"),
bullet("mTOR pathway mutations: 15% of PNETs"),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("3. Classification: Functional vs. Nonfunctional"),
h2("3A. Nonfunctional PNETs (NF-PNETs)"),
body("NF-PNETs comprise 60-90% of all PNETs. They do not produce clinically significant hormonal syndromes. Most are discovered incidentally on cross-sectional imaging done for other purposes (trauma, abdominal pain workup, etc.)."),
spacer(),
bullet("Presentation: Abdominal pain, weight loss, early satiety (mass effect), biliary obstruction with jaundice (head tumors), or incidental finding"),
bullet("Often larger at diagnosis due to absence of hormone-related symptoms"),
bullet("In rare cases: fulminant hepatic failure from liver replacement by poorly differentiated PNETs"),
bullet("Equally distributed across head, body, and tail of pancreas"),
spacer(),
h2("3B. Functional PNETs (F-PNETs) — Overview"),
body("F-PNETs produce excess hormones causing well-defined clinical syndromes. Because of the recognizable syndromes, they are typically detected earlier and at smaller sizes."),
spacer(),
makeTable(
["Tumor Type", "Hormone", "Incidence / 10⁶ / year", "% Malignant", "% MEN-1", "Classic Syndrome"],
[
["Insulinoma", "Insulin", "1 – 3", "10%", "10%", "Whipple's triad: fasting hypoglycemia, glucose <50 mg/dL, relief with glucose"],
["Gastrinoma", "Gastrin", "0.5 – 1.5", "> 60%", "20-25%", "Zollinger-Ellison syndrome: peptic ulcers, diarrhea, acid hypersecretion"],
["Glucagonoma", "Glucagon", "0.01 – 0.1", "50-80%", "Rare", "Necrolytic migratory erythema, diabetes, weight loss, DVT"],
["VIPoma", "VIP", "0.05 – 0.2", "40-70%", "6%", "WDHA: watery diarrhea (>3 L/day), hypokalemia, achlorhydria"],
["Somatostatinoma", "Somatostatin", "Rare", "> 70%", "45%", "Diabetes, steatorrhea, cholelithiasis, diarrhea (inhibitory triad)"],
["PPoma / Non-functional", "PP / none", "Common", "Variable", "18%", "Mass effect symptoms only"]
],
[1800, 1200, 1500, 1200, 1000, 3200]
),
spacer(),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("4. Individual Functional Tumors"),
h2("4A. Insulinoma"),
body("Insulinomas are the most common functional pancreatic endocrine neoplasm. They are uniformly distributed throughout the head, body, and tail of the pancreas."),
bullet("Clinical: Whipple's Triad — (1) symptoms of hypoglycemia, (2) blood glucose <50 mg/dL during symptoms, (3) relief of symptoms with glucose administration"),
bullet("Symptoms: Palpitations, trembling, diaphoresis, confusion, seizures, obtundation, personality change"),
bullet("90% are benign and solitary; 10% are malignant"),
bullet("10% are associated with MEN-1 (more likely to be multifocal, higher recurrence)"),
spacer(),
h3("Diagnosis"),
subbullet("72-hour supervised fast: sample glucose, insulin, C-peptide, proinsulin, and sulfonylurea every 4-6 hours and when symptomatic"),
subbullet("Elevated insulin + low glucose during fast = diagnostic"),
subbullet("Elevated C-peptide confirms endogenous origin (rules out exogenous insulin injection)"),
subbullet("Check sulfonylurea levels to rule out drug-induced hypoglycemia"),
spacer(),
h3("Localization & Surgery"),
subbullet("CT + EUS: identifies >90% of insulinomas preoperatively"),
subbullet("Intraoperative ultrasound (IOUS) confirms tumor location and relationship to main pancreatic duct"),
subbullet("Treatment: Simple enucleation for most; distal pancreatectomy or pancreaticoduodenectomy for tumors >2 cm or those close to the main duct"),
subbullet("Nearly 100% cure rate for benign solitary insulinomas"),
spacer(),
h2("4B. Gastrinoma (Zollinger-Ellison Syndrome)"),
body("Gastrinomas are the second most common functional pancreatic NET. They arise predominantly in the 'gastrinoma triangle' (Passaro's triangle)."),
bullet("Location: 80-90% within Passaro's triangle (cystic duct confluence → D2/D3 junction → neck/body of pancreas); 50-90% of sporadic cases arise in the duodenum"),
bullet("Clinical (ZES): Severe refractory peptic ulcers (90%), diarrhea (21-40% at diagnosis), GERD, steatorrhea, large gastric rugal folds"),
bullet("Malignancy: >60% are malignant; 50-80% have metastases at diagnosis (liver, lymph nodes)"),
bullet("Key physiology: Not suppressed by low luminal pH; paradoxically stimulated by secretin"),
spacer(),
h3("Diagnosis"),
subbullet("Fasting serum gastrin >1000 pg/mL + gastric pH <2 = diagnostic"),
subbullet("Secretin stimulation test: paradoxical rise in gastrin >200 pg/mL (>85% sensitivity, >95% specificity)"),
subbullet("Stop PPIs 3 weeks before testing to avoid false elevation"),
subbullet("Basal acid output (BAO) >15 mEq/h in ZES"),
spacer(),
h3("Management"),
subbullet("PPIs: Drug of choice; target BAO <10 mEq/h"),
subbullet("Localization: 68Ga-DOTATATE PET/CT + EUS (>90% detection combined)"),
subbullet("Surgery: Recommended for all sporadic resectable gastrinomas; duodenotomy + node clearance of Passaro's triangle"),
subbullet("MEN-1: Treat hyperparathyroidism first; surgery for tumors >2-2.5 cm"),
subbullet("Prognosis: 15-year survival ~80% without liver metastases; 20-50% 5-year survival with liver metastases"),
spacer(),
h2("4C. Glucagonoma"),
body("Glucagonomas are rare tumors producing excess glucagon. Most arise in the body and tail of the pancreas and are large (>5 cm) at diagnosis."),
bullet("Classic presentation: 4 D's — Dermatitis (necrolytic migratory erythema), Diabetes mellitus, DVT (deep vein thrombosis), Depression"),
bullet("Necrolytic migratory erythema (NME): Pathognomonic rash — migratory, crusting, blistering eruption predominantly on lower extremities, perineum, and perioral areas"),
bullet("Other features: Weight loss, anemia, hypoaminoacidemia, glossitis, stomatitis"),
bullet("50-80% are malignant at diagnosis; majority have liver or lymph node metastases"),
spacer(),
h3("Diagnosis & Management"),
subbullet("Elevated fasting plasma glucagon (>500 pg/mL; normal <150 pg/mL)"),
subbullet("CT/MRI for localization and staging; usually large and easily identified"),
subbullet("Somatostatin analogues: Control symptoms (especially NME and diarrhea) preoperatively"),
subbullet("Surgical resection: Distal pancreatectomy for body/tail tumors; curative in ~30%"),
subbullet("Correct hypoaminoacidemia with IV amino acids (improves NME before surgery)"),
spacer(),
h2("4D. VIPoma (WDHA Syndrome / Verner-Morrison Syndrome)"),
body("VIPomas secrete vasoactive intestinal peptide (VIP). First described by Verner and Morrison in 1958. Also called pancreatic cholera or WDHA syndrome."),
bullet("WDHA: Watery Diarrhea (>3 L/day, episodic, secretory — persists with fasting), Hypokalemia, Achlorhydria"),
bullet("Life-threatening hypovolemia and electrolyte disturbance; can present with tetany"),
bullet("60-75% arise in the pancreatic body/tail; 40-70% malignant"),
spacer(),
h3("Diagnosis & Management"),
subbullet("Serum VIP level >200 pg/mL (measure multiple times — episodic secretion)"),
subbullet("Aggressive IV fluid and electrolyte replacement preoperatively"),
subbullet("Somatostatin analogues (octreotide/lanreotide): Dramatically reduce diarrhea and allow fluid replacement"),
subbullet("CT: Usually localizes tumor (most have already spread outside pancreas at diagnosis)"),
subbullet("Surgery: Distal pancreatectomy; debulking for palliation in advanced disease"),
spacer(),
h2("4E. Somatostatinoma"),
body("Somatostatinomas are the rarest functional PNETs. They produce excess somatostatin which inhibits multiple GI functions."),
bullet("Inhibitory triad: Diabetes mellitus (inhibition of insulin), Steatorrhea/malabsorption (inhibition of pancreatic enzymes), Cholelithiasis (inhibition of CCK → bile stasis)"),
bullet("Diarrhea, hypochlorhydria, weight loss"),
bullet(">70% are malignant at diagnosis"),
bullet("45% associated with MEN-1 or NF-1"),
bullet("Most arise in the pancreatic head or periampullary duodenum"),
spacer(),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("5. Investigations & Staging"),
h2("5A. Biochemical Workup"),
body("All suspected PNETs should undergo a thorough hormonal and general biochemical evaluation:"),
makeTable(
["Test", "Significance"],
[
["Fasting serum gastrin", "Gastrinoma (>1000 pg/mL with pH <2 diagnostic)"],
["Fasting serum insulin + glucose + C-peptide", "Insulinoma (insulin:glucose ratio elevated)"],
["Plasma glucagon", "Glucagonoma (>500 pg/mL)"],
["Serum VIP", "VIPoma (>200 pg/mL)"],
["Serum somatostatin", "Somatostatinoma"],
["Chromogranin A (CgA)", "Universal NET marker; elevated in 60-80% of all PNETs; mirrors tumor burden"],
["Pancreastatin", "Marker of NET activity; less affected by PPI use than CgA"],
["5-HIAA (urine)", "Carcinoid syndrome (serotonin-producing NETs)"],
["Serum calcium, PTH", "Screen for MEN-1 (hyperparathyroidism)"],
["Secretin stimulation test", "Confirms gastrinoma (paradoxical gastrin rise >200 pg/mL)"],
["72-hour supervised fast", "Gold standard for insulinoma"]
],
[3500, 5500]
),
spacer(),
h2("5B. Imaging & Localization"),
makeTable(
["Modality", "Sensitivity / Use", "Key Points"],
[
["Triple-phase CT (with/without contrast)", "~70-80% overall", "First-line; PNETs are hypervascular — enhance in arterial phase; staging of liver metastases"],
["MRI / MRCP", "~80-90%", "Superior for small lesions and liver metastases; no radiation"],
["Endoscopic Ultrasound (EUS)", ">90% for small pancreatic/duodenal tumors", "Best for lesions <1 cm in pancreatic head/duodenal wall; guides tissue biopsy"],
["68Ga-DOTATATE PET/CT", "Highest sensitivity (~90-95%)", "First-line functional imaging; somatostatin receptor scintigraphy; detects primary + all metastases"],
["Octreotide scintigraphy (OctreoScan)", "~80-85%", "Older modality; now largely replaced by 68Ga-DOTATATE PET/CT"],
["Intraoperative Ultrasound (IOUS)", "Very high", "Detects occult tumors missed on preoperative imaging; guides enucleation vs. resection decision"],
["Selective angiography / portal venous sampling", "Adjunct", "Reserved for cases unlocalized by other methods"],
["FDG-PET/CT", "For high-grade tumors", "Useful for poorly differentiated panNEC (grade 3); inverse relationship to somatostatin receptor expression"]
],
[2500, 2000, 4500]
),
spacer(),
h2("5C. Tissue Diagnosis & Histopathology"),
bullet("Core biopsy or FNA (EUS-guided) for tissue diagnosis when surgery is not immediately planned"),
bullet("Immunohistochemistry: Chromogranin A, Synaptophysin (neuroendocrine markers), Ki-67 staining (grade)"),
bullet("Electron microscopy: Dense-core neurosecretory granules"),
bullet("Specific hormone staining (insulin, glucagon, gastrin, VIP, somatostatin) for functional tumors"),
spacer(),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("6. Management"),
h2("6A. Surgical Management"),
body("Surgery is the only potentially curative treatment and should be considered in all patients with resectable disease. Approach varies by tumor type, size, location, and presence of MEN-1."),
spacer(),
makeTable(
["Tumor / Situation", "Surgical Approach"],
[
["Small NF-PNET (<2 cm, no malignant features)", "Active surveillance; surgery if growing or symptomatic"],
["NF-PNET >2 cm", "Resection: enucleation (if away from main duct) or formal pancreatectomy"],
["Insulinoma (benign, solitary)", "Enucleation; >90% cure rate"],
["Insulinoma (close to main duct, >2 cm)", "Distal pancreatectomy or pancreaticoduodenectomy"],
["Duodenal gastrinoma (sporadic)", "Duodenotomy + full-thickness excision + lymph node clearance of Passaro's triangle"],
["Pancreatic gastrinoma (sporadic)", "Enucleation or formal pancreatectomy; regional lymphadenectomy always"],
["Gastrinoma in MEN-1", "Surgery for tumors >2-2.5 cm only; parathyroidectomy first"],
["Glucagonoma", "Distal pancreatectomy (body/tail); correct hypoaminoacidemia first"],
["VIPoma", "Distal pancreatectomy; debulking for palliation"],
["Pancreatic head tumor with ductal involvement", "Pancreaticoduodenectomy (Whipple procedure)"],
["Resectable liver metastases", "Synchronous or staged hepatic resection if primary controlled and complete removal feasible"],
["Intraoperative occult tumor", "IOUS + duodenotomy for thorough exploration"]
],
[3500, 5500]
),
spacer(),
h3("Highly Selective Vagotomy"),
body("May be performed when gastrinoma cannot be localized or unresectable disease is found — reduces acid secretion and decreases PPI requirement without compromising gastric motility."),
spacer(),
h2("6B. Medical Management of Hormone Excess"),
makeTable(
["Condition", "Medical Treatment"],
[
["Gastrinoma (ZES)", "PPI (omeprazole/lansoprazole) — drug of choice; target BAO <10 mEq/h; add H2 blockers if needed"],
["Insulinoma (preop/inoperable)", "Diazoxide (inhibits insulin release); frequent small meals; IV dextrose for hypoglycemic crises"],
["Glucagonoma", "Somatostatin analogue (octreotide) — controls NME, diarrhea; IV amino acid infusion for NME"],
["VIPoma", "Octreotide/lanreotide — dramatically reduces diarrhea; IV fluid + electrolyte replacement"],
["Somatostatinoma", "Surgical resection; supportive management of diabetes, enzyme replacement for steatorrhea"],
["General hormonal control", "Somatostatin analogues (octreotide, lanreotide) — effective across multiple tumor types"]
],
[2500, 6500]
),
spacer(),
h2("6C. Management of Metastatic / Advanced PNETs"),
body("Treatment of metastatic PNETs requires a multidisciplinary approach. The selection of therapy depends on tumor grade, somatostatin receptor expression, extent of disease, and rate of progression."),
spacer(),
h3("Systemic Therapies"),
makeTable(
["Treatment", "Indication / Key Points"],
[
["Somatostatin analogues (octreotide, lanreotide)", "Symptom control AND antiproliferative; first-line for low/intermediate grade, receptor-positive tumors"],
["PRRT (177Lu-DOTATATE — Lutathera)", "Peptide receptor radionuclide therapy; high receptor expression; grade 1-2; significant OS improvement (NETTER-1 trial)"],
["Everolimus (mTOR inhibitor)", "Grade 1-2 pancreatic NETs; approved for progressive disease (RADIANT-3 trial)"],
["Sunitinib (tyrosine kinase inhibitor)", "Pancreatic NETs; targets VEGFR, PDGFR; approved for progressive well-differentiated pNETs"],
["Chemotherapy (streptozotocin + 5-FU ± doxorubicin)", "Poorly differentiated panNEC or rapidly progressive well-differentiated tumors; response rate ~40%"],
["Temozolomide ± capecitabine (TEMCAP)", "Pancreatic NETs with MGMT promoter methylation; response rate ~40-70%"],
["Interferon-alpha", "Adjunct antiproliferative; limited use due to side effects"]
],
[3000, 6000]
),
spacer(),
h3("Liver-Directed Therapies"),
bullet("Surgical hepatic resection: If primary controlled + complete removal feasible"),
bullet("Hepatic artery embolization (HAE) / chemoembolization (TACE): Liver-dominant disease"),
bullet("Radiofrequency ablation (RFA) / microwave ablation: Focal liver metastases"),
bullet("Selective internal radiation therapy (SIRT / Y-90 radioembolization): Unresectable liver metastases"),
bullet("Liver transplantation: Highly selected patients with unresectable liver-only metastases (5-year survival ~60% in selected cases)"),
spacer(),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("7. Surveillance & Follow-Up"),
body("Post-resection surveillance is essential given the potential for late recurrence. Strategy depends on grade and whether biochemical cure was achieved."),
spacer(),
bullet("Serum markers: Fasting serum gastrin, CgA, specific hormone levels (depending on tumor type)"),
bullet("Secretin stimulation test: For gastrinoma recurrence"),
bullet("Cross-sectional imaging (CT/MRI): Every 3-6 months initially, then annually"),
bullet("68Ga-DOTATATE PET/CT: For suspected recurrence or restaging"),
bullet("OGD surveillance: For gastrinoma patients"),
spacer(),
body("For NF-PNETs managed conservatively (<2 cm), annual imaging surveillance to detect growth is standard practice."),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("8. Prognosis"),
makeTable(
["Tumor Type / Situation", "Prognosis"],
[
["Benign insulinoma (sporadic, resected)", "Near 100% cure; excellent long-term survival"],
["Gastrinoma — no liver metastases", "~80% 15-year survival"],
["Gastrinoma — liver metastases", "20-50% 5-year survival"],
["MEN-1 gastrinoma <2.5 cm (no metastases)", "100% at 15 years"],
["MEN-1 gastrinoma with metastases", "52% at 15 years"],
["Glucagonoma (resected)", "~60% 5-year survival; high recurrence"],
["NF-PNET Grade 1 (resected)", "Excellent; >80% 5-year survival"],
["NF-PNET Grade 2", "Good; 60-80% 5-year survival"],
["panNEC Grade 3 (poorly differentiated)", "Poor; median survival <2 years"],
["Biochemical cure after gastrinoma surgery (sporadic)", "~30-40%"],
["Biochemical cure (MEN-1)", "~5% at 5 years"]
],
[4000, 5000]
),
spacer(),
body("Key prognostic factors: Tumor grade (Ki-67 / mitotic index), presence of liver metastases, complete surgical resection, sporadic vs. MEN-1 context, and tumor size at diagnosis."),
body("Note: Lymph node metastases alone (without liver involvement) do NOT significantly reduce long-term survival in gastrinomas and many other PNETs."),
divider(),
// ═══════════════════════════════════════════════════════════════════
h1("9. Quick Reference Summary Tables"),
h2("Functional PNET Comparison"),
makeTable(
["Feature", "Insulinoma", "Gastrinoma", "Glucagonoma", "VIPoma", "Somatostatinoma"],
[
["Hormone", "Insulin", "Gastrin", "Glucagon", "VIP", "Somatostatin"],
["Syndrome", "Whipple's triad", "Zollinger-Ellison", "4 D's + NME", "WDHA", "Inhibitory triad"],
["Most common site", "Uniform pancreas", "Duodenum (sporadic)", "Body/tail", "Body/tail", "Head / duodenum"],
["Malignancy", "10%", ">60%", "50-80%", "40-70%", ">70%"],
["MEN-1", "10%", "20-25%", "Rare", "6%", "45%"],
["Key test", "72-h fast", "Fasting gastrin + secretin stimulation", "Plasma glucagon", "Serum VIP", "Plasma somatostatin"],
["Drug of choice", "Diazoxide / glucose", "PPI (omeprazole)", "Octreotide", "Octreotide + IVF", "Symptomatic"],
["Surgery", "Enucleation", "Duodenotomy / enucleation / resection", "Distal pancreatectomy", "Distal pancreatectomy", "Resection"]
],
[2200, 1800, 2000, 1700, 1600, 2200]
),
spacer(),
h2("WHO 2017 Grade Summary"),
makeTable(
["Grade", "Differentiation", "Ki-67 (%)", "Mitotic Rate", "Behavior"],
[
["Grade 1", "Well-differentiated", "<3%", "<2/10 HPF", "Slow-growing; excellent prognosis"],
["Grade 2", "Well-differentiated", "3-20%", "2-20/10 HPF", "Intermediate behavior"],
["Grade 3 (panNET)", "Well-differentiated", ">20%", ">20/10 HPF", "Aggressive but better than panNEC"],
["Grade 3 (panNEC)", "Poorly differentiated", ">20%", ">20/10 HPF", "Very aggressive; treat like SCLC"]
],
[1500, 2000, 1800, 2200, 3500]
),
spacer(),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 400, after: 100 },
children: [new TextRun({ text: "— End of Document —", size: 18, italics: true, color: "888888", font: "Calibri" })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 60 },
children: [new TextRun({
text: "Sources: Harrison's 22e (2025) | Schwartz's Surgery 11e | Fischer's Mastery of Surgery 8e | Maingot's Abdominal Operations | Current Surgical Therapy 14e | Robbins & Cotran Pathology 10e",
size: 16, italics: true, color: "999999", font: "Calibri"
})]
})
];
// ─── Build document ───────────────────────────────────────────────────────────
const doc = new Document({
creator: "Orris Medical AI",
title: "Pancreatic Neuroendocrine Tumors – Summary Document",
description: "Comprehensive clinical summary of PNETs",
styles: {
paragraphStyles: [
{
id: "Normal",
name: "Normal",
run: { font: "Calibri", size: 22 }
}
]
},
sections: [{
properties: {
page: {
margin: { top: 1080, bottom: 1080, left: 1080, right: 1080 }
}
},
headers: {
default: new Header({
children: [new Paragraph({
alignment: AlignmentType.RIGHT,
border: { bottom: { style: BorderStyle.SINGLE, size: 1, color: BLUE_MID } },
children: [
new TextRun({ text: "Pancreatic Neuroendocrine Tumors (PNETs)", size: 18, color: BLUE_MID, font: "Calibri" })
]
})]
})
},
footers: {
default: new Footer({
children: [new Paragraph({
alignment: AlignmentType.CENTER,
border: { top: { style: BorderStyle.SINGLE, size: 1, color: "CCCCCC" } },
children: [
new TextRun({ text: "Page ", size: 16, color: "888888", font: "Calibri" }),
new TextRun({ children: [PageNumber.CURRENT], size: 16, color: "888888", font: "Calibri" }),
new TextRun({ text: " | Orris Medical AI | Compiled from authoritative surgical & medical textbooks", size: 16, color: "888888", font: "Calibri" })
]
})]
})
},
children: content
}]
});
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync('/home/daytona/workspace/pnet-summary/PNET_Summary.docx', buffer);
console.log('SUCCESS: Document written to /home/daytona/workspace/pnet-summary/PNET_Summary.docx');
}).catch(err => {
console.error('ERROR:', err);
process.exit(1);
});