~/neonatal-admission/generate.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
HeadingLevel, AlignmentType, BorderStyle, WidthType, ShadingType,
VerticalAlign, PageNumber, Header, Footer, PageBreak,
UnderlineType
} = require('docx');
const fs = require('fs');
// ── colour palette ────────────────────────────────────────────────
const DARK_BLUE = "1F3864";
const MID_BLUE = "2E5FA3";
const LIGHT_BLUE = "D6E4F7";
const LIGHT_GRAY = "F2F2F2";
const WHITE = "FFFFFF";
const BLACK = "000000";
const BORDER_CLR = "A0B4CC";
// ── helper: thin border set ───────────────────────────────────────
const thinBorder = {
top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_CLR },
bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_CLR },
left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_CLR },
right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_CLR },
};
// ── helper: section heading paragraph ────────────────────────────
function sectionHeading(text) {
return new Paragraph({
children: [new TextRun({ text, bold: true, size: 26, color: WHITE, font: "Calibri" })],
heading: HeadingLevel.HEADING_2,
spacing: { before: 240, after: 80 },
shading: { type: ShadingType.CLEAR, fill: DARK_BLUE },
indent: { left: 120, right: 120 },
});
}
// ── helper: sub-heading ───────────────────────────────────────────
function subHeading(text) {
return new Paragraph({
children: [new TextRun({ text, bold: true, size: 22, color: WHITE, font: "Calibri" })],
spacing: { before: 160, after: 60 },
shading: { type: ShadingType.CLEAR, fill: MID_BLUE },
indent: { left: 120 },
});
}
// ── helper: label+blank line ──────────────────────────────────────
function labelLine(label, spacer) {
const sp = spacer || "____________________________________________";
return new Paragraph({
children: [
new TextRun({ text: label + " ", bold: true, size: 20, font: "Calibri", color: "333333" }),
new TextRun({ text: sp, size: 20, font: "Calibri", color: "999999" }),
],
spacing: { before: 40, after: 40 },
indent: { left: 180 },
});
}
// ── helper: checkbox item ─────────────────────────────────────────
function cb(label) {
return new Paragraph({
children: [new TextRun({ text: "☐ " + label, size: 20, font: "Calibri" })],
spacing: { before: 30, after: 30 },
indent: { left: 360 },
});
}
// ── helper: plain paragraph ───────────────────────────────────────
function para(text, opts) {
opts = opts || {};
return new Paragraph({
children: [new TextRun({
text,
size: opts.size || 20,
bold: opts.bold || false,
italics: opts.italic || false,
color: opts.color || BLACK,
font: "Calibri",
})],
spacing: { before: opts.spaceBefore || 40, after: opts.spaceAfter || 40 },
indent: { left: opts.indent || 180 },
alignment: opts.align || AlignmentType.LEFT,
});
}
// ── helper: italic note ───────────────────────────────────────────
function note(text) {
return new Paragraph({
children: [new TextRun({ text, italics: true, size: 18, color: "666666", font: "Calibri" })],
spacing: { before: 20, after: 60 },
indent: { left: 180 },
});
}
// ── helper: 2-column key-value table ─────────────────────────────
function kvTable(rows, colWidths) {
colWidths = colWidths || [2800, 6000];
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: rows.map(([k, v]) => new TableRow({
children: [
new TableCell({
width: { size: colWidths[0], type: WidthType.DXA },
shading: { type: ShadingType.CLEAR, fill: LIGHT_BLUE },
borders: thinBorder,
children: [new Paragraph({
children: [new TextRun({ text: k, bold: true, size: 20, font: "Calibri", color: "1F3864" })],
spacing: { before: 40, after: 40 }, indent: { left: 80 },
})],
}),
new TableCell({
width: { size: colWidths[1], type: WidthType.DXA },
borders: thinBorder,
children: [new Paragraph({
children: [new TextRun({ text: v || "________________________", size: 20, font: "Calibri", color: "777777" })],
spacing: { before: 40, after: 40 }, indent: { left: 80 },
})],
}),
],
})),
});
}
// ── helper: header row for a table ───────────────────────────────
function headerRow(cols) {
return new TableRow({
tableHeader: true,
children: cols.map(c => new TableCell({
shading: { type: ShadingType.CLEAR, fill: MID_BLUE },
borders: thinBorder,
children: [new Paragraph({
children: [new TextRun({ text: c, bold: true, size: 20, color: WHITE, font: "Calibri" })],
spacing: { before: 40, after: 40 }, indent: { left: 80 },
})],
})),
});
}
// ── helper: data row ──────────────────────────────────────────────
function dataRow(cells, shade) {
return new TableRow({
children: cells.map(c => new TableCell({
shading: { type: ShadingType.CLEAR, fill: shade || WHITE },
borders: thinBorder,
children: [new Paragraph({
children: [new TextRun({ text: c, size: 20, font: "Calibri" })],
spacing: { before: 40, after: 40 }, indent: { left: 80 },
})],
})),
});
}
// ═══════════════════════════════════════════════════════════════════
// BUILD DOCUMENT
// ═══════════════════════════════════════════════════════════════════
const children = [];
// ── TITLE BLOCK ───────────────────────────────────────────────────
children.push(new Paragraph({
children: [new TextRun({ text: "NEONATAL WARD ADMISSION PROFORMA", bold: true, size: 36, color: WHITE, font: "Calibri" })],
heading: HeadingLevel.HEADING_1,
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 100 },
shading: { type: ShadingType.CLEAR, fill: DARK_BLUE },
}));
children.push(new Paragraph({
children: [new TextRun({ text: "History & Examination Template | Based on Harriet Lane Handbook 23rd ed · Tintinalli's EM · Textbook of Family Medicine 9e", italics: true, size: 18, color: WHITE, font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 200 },
shading: { type: ShadingType.CLEAR, fill: MID_BLUE },
}));
// ── ADMIN FIELDS ──────────────────────────────────────────────────
children.push(new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: [
new TableRow({ children: [
new TableCell({ borders: thinBorder, shading: { type: ShadingType.CLEAR, fill: LIGHT_GRAY }, children: [labelLine("Institution:", "")] }),
new TableCell({ borders: thinBorder, shading: { type: ShadingType.CLEAR, fill: LIGHT_GRAY }, children: [labelLine("Ward:", "")] }),
]}),
new TableRow({ children: [
new TableCell({ borders: thinBorder, children: [labelLine("Date of Admission:", "")] }),
new TableCell({ borders: thinBorder, children: [labelLine("Time:", "")] }),
]}),
new TableRow({ children: [
new TableCell({ borders: thinBorder, shading: { type: ShadingType.CLEAR, fill: LIGHT_GRAY }, children: [labelLine("MRN / File No.:", "")] }),
new TableCell({ borders: thinBorder, shading: { type: ShadingType.CLEAR, fill: LIGHT_GRAY }, children: [labelLine("Admitted by:", "")] }),
]}),
],
}));
children.push(new Paragraph({ children: [], spacing: { before: 120 } }));
// ═══════ SECTION 1: PATIENT IDENTIFICATION ════════════════════════
children.push(sectionHeading("SECTION 1 — PATIENT IDENTIFICATION"));
children.push(kvTable([
["Neonate's Name", ""],
["Date / Time of Birth", ""],
["Gestational Age at Birth", "______ weeks ______ days"],
["Actual Age at Admission", "______ hours / days"],
["Birth Weight", "______ kg"],
["Sex", "☐ Male ☐ Female ☐ Ambiguous"],
["Place of Birth", "☐ This hospital ☐ Other hospital ☐ Home ☐ Other"],
["Referring Facility (if transferred)", ""],
["Mother's Name", ""],
["Mother's Age", ""],
["Mother's MRN", ""],
["Consultant / Attending", ""],
]));
// ═══════ SECTION 2: PRESENTING COMPLAINT ═════════════════════════
children.push(sectionHeading("SECTION 2 — PRESENTING COMPLAINT"));
children.push(labelLine("Chief reason for admission (caregiver's words):", ""));
children.push(para("________________________________________________________________________________", { color: "999999" }));
children.push(para("________________________________________________________________________________", { color: "999999" }));
children.push(labelLine("Duration:", ""));
// ═══════ SECTION 3: MATERNAL HISTORY ═════════════════════════════
children.push(sectionHeading("SECTION 3 — MATERNAL HISTORY"));
children.push(note('Source: Textbook of Family Medicine 9e, p.529 — "Gathering a complete maternal history, including medical problems, past obstetric history, medications, drug/alcohol/tobacco use, and prenatal serologies is important."'));
children.push(subHeading("3A. Antenatal History"));
children.push(kvTable([
["Gravida / Para / Abortus", "G ___ P ___ A ___"],
["Number of Fetuses", ""],
["Antenatal Care", "☐ Regular ☐ Irregular ☐ None No. of visits: ______"],
["Maternal Medical Conditions", "☐ GDM ☐ Pre-existing DM ☐ Hypertension ☐ Epilepsy\n☐ Thyroid disease ☐ Cardiac ☐ Renal ☐ Other: ______"],
["Infections During Pregnancy", "☐ TORCH ☐ Syphilis ☐ HIV ☐ HBsAg ☐ GBS\n☐ Malaria ☐ COVID-19 ☐ Zika ☐ UTI ☐ None"],
["Prenatal Serologies", "Blood group: ___ Rh: ___ VDRL: ___ HIV: ___\nHBsAg: ___ Rubella: ___"],
["Genetic / Anomaly Screening", "☐ Done — result: ______ ☐ Not done"],
["Ultrasound Findings", "☐ Normal ☐ Anomaly: ______ ☐ Not done"],
["Medications in Pregnancy", "(List all, including folic acid, iron, antihypertensives, ARVs):"],
["Substance Use", "☐ Alcohol ☐ Tobacco ☐ Recreational drugs ☐ None"],
["Radiation / Teratogen Exposure", ""],
["Antenatal Corticosteroids (preterm)", "☐ Yes — Complete course ☐ Incomplete course ☐ No"],
]));
children.push(subHeading("3B. Previous Obstetric History"));
children.push(kvTable([
["Previous stillbirths / neonatal deaths", ""],
["Previous infant with congenital anomaly", ""],
["Previous infant with severe jaundice / exchange transfusion", ""],
["Previous preterm deliveries", ""],
["Previous infant with metabolic / genetic disease", ""],
]));
// ═══════ SECTION 4: INTRAPARTUM HISTORY ══════════════════════════
children.push(sectionHeading("SECTION 4 — INTRAPARTUM HISTORY"));
children.push(note('Source: Tintinalli\'s Emergency Medicine, p.716 — "Obtain history including prolonged rupture of membranes, fever, and meconium-stained amniotic fluid."'));
children.push(kvTable([
["Mode of Delivery", "☐ SVD ☐ Assisted vaginal (vacuum/forceps) ☐ Elective LSCS ☐ Emergency LSCS"],
["Indication for Operative Delivery", ""],
["Duration of Labour", "______ hours"],
["Duration of Ruptured Membranes (ROM)", "______ hours"],
["Prolonged ROM (>18 hours)", "☐ Yes ☐ No"],
["Amniotic Fluid Appearance", "☐ Clear ☐ Meconium-stained (thin/thick) ☐ Blood-stained ☐ Foul-smelling"],
["Maternal Fever in Labour (>38°C)", "☐ Yes ☐ No"],
["Maternal Antibiotics in Labour", "☐ Yes — drug: ______ ☐ No"],
["Fetal Distress / Abnormal CTG", "☐ Yes ☐ No"],
["Cord Complications", "☐ Cord prolapse ☐ Nuchal cord ☐ Short cord ☐ None"],
["Placental Complications", "☐ Abruption ☐ Previa ☐ Normal"],
["Birth Attendant", "☐ Physician ☐ Midwife ☐ TBA ☐ Unattended"],
]));
// ═══════ SECTION 5: NEONATAL BIRTH HISTORY ════════════════════════
children.push(sectionHeading("SECTION 5 — NEONATAL BIRTH HISTORY"));
// Apgar table
children.push(subHeading("Apgar Score"));
children.push(note('If 5-min score <7, continue at 5-min intervals until ≥7. (Harriet Lane Handbook 23rd ed / Tintinalli\'s EM)'));
children.push(new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: [
headerRow(["Component", "0", "1", "2", "1-min", "5-min", "10-min"]),
dataRow(["Heart Rate", "Absent", "<100 bpm", ">100 bpm", "", "", ""], LIGHT_GRAY),
dataRow(["Respiratory Effort", "Absent", "Weak / Irregular", "Crying", "", "", ""], WHITE),
dataRow(["Muscle Tone", "Limp", "Some flexion", "Active / Flexed", "", "", ""], LIGHT_GRAY),
dataRow(["Reflex Irritability", "No response", "Grimace", "Cry / Cough", "", "", ""], WHITE),
dataRow(["Color", "Blue / Pale", "Acrocyanosis", "Completely pink", "", "", ""], LIGHT_GRAY),
dataRow(["TOTAL", "", "", "", " /10", " /10", " /10"], LIGHT_BLUE),
],
}));
children.push(kvTable([
["Resuscitation Required", "☐ None (routine care) ☐ Stimulation/Drying ☐ Supplemental O₂\n☐ PPV ☐ Chest compressions ☐ Intubation ☐ Epinephrine"],
["Time to First Cry", "______ min"],
["Birth Weight Category", "☐ LBW (<2500g) ☐ VLBW (<1500g) ☐ ELBW (<1000g)\n☐ Normal ☐ Macrosomic (>4000g)"],
["Length at Birth", "______ cm"],
["Head Circumference at Birth", "______ cm"],
["Birth Trauma Noted", "☐ Yes — describe: ______ ☐ No"],
["NICU Admission at Birth", "☐ Yes ☐ No"],
["Vitamin K Given", "☐ Yes ☐ No"],
["Eye Prophylaxis Given", "☐ Yes ☐ No"],
["BCG / HBV Given", "☐ Yes ☐ No"],
["Newborn Metabolic Screen Done", "☐ Yes ☐ No"],
]));
// ═══════ SECTION 6: POSTNATAL HISTORY ════════════════════════════
children.push(sectionHeading("SECTION 6 — POSTNATAL HISTORY (Admissions after Day 1)"));
children.push(kvTable([
["Feeding Type", "☐ Exclusive breastfeed ☐ Formula ☐ Mixed ☐ IV/NG only"],
["Feeding Problems", "☐ Poor latch ☐ Poor suck ☐ Vomiting ☐ Regurgitation ☐ None"],
["Stool Passed", "☐ Meconium ☐ Transitional ☐ Yellow ☐ Not yet\nTime of first meconium: ______ hours"],
["Urine Passed", "☐ Yes ☐ No Time of first void: ______ hours"],
["Weight Change Since Birth", "______ % loss / gain"],
["Jaundice Onset", "☐ <24 hr (PATHOLOGICAL — investigate) ☐ Day 2–3 ☐ Day 4+ ☐ None"],
["Phototherapy Previously", "☐ Yes ☐ No"],
["Umbilicus Status", "☐ Clean / Drying ☐ Discharge ☐ Erythema (omphalitis)"],
["Medications / Treatments Given", ""],
["Previous Discharge Since Birth", "☐ Yes — discharged on day: ______ ☐ Not yet discharged"],
]));
// ═══════ SECTION 7: FAMILY & SOCIAL HISTORY ══════════════════════
children.push(sectionHeading("SECTION 7 — FAMILY & SOCIAL HISTORY"));
children.push(kvTable([
["Consanguinity of Parents", "☐ Yes (relationship: ______) ☐ No"],
["Family History of:", "☐ Metabolic disease ☐ Haematologic (sickle cell / G6PD / thalassaemia)\n☐ Congenital anomalies ☐ Hearing loss ☐ SIDS ☐ Neurologic disease ☐ None"],
["Siblings' Health", ""],
["Socioeconomic Status", "☐ Good ☐ Fair ☐ Poor"],
["Primary Caregiver", "☐ Mother ☐ Father ☐ Other: ______"],
["Concerns About Home Environment", "☐ Yes — detail: ______ ☐ No"],
]));
// ═══════ SECTION 8: PHYSICAL EXAMINATION ══════════════════════════
children.push(sectionHeading("SECTION 8 — PHYSICAL EXAMINATION"));
children.push(note('Source: Textbook of Family Medicine 9e, p.529 — "The examination should begin with general appearance, then auscultation, then proceed head to toe in a systematic fashion."'));
// 8A Anthropometry
children.push(subHeading("8A. Anthropometry & Vital Signs"));
children.push(new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: [
headerRow(["Parameter", "Value", "Normal Range (Term)"]),
dataRow(["Weight (today)", "______ g", "Birth weight ± expected change"], LIGHT_GRAY),
dataRow(["Length", "______ cm", "48–52 cm"], WHITE),
dataRow(["Head Circumference (OFC)", "______ cm", "33–37 cm"], LIGHT_GRAY),
dataRow(["Heart Rate", "______ bpm", "100–180 bpm"], WHITE),
dataRow(["Respiratory Rate", "______ breaths/min", "24–60 breaths/min"], LIGHT_GRAY),
dataRow(["Temperature", "______ °C", "36.0–38.0 °C"], WHITE),
dataRow(["Systolic BP", "______ mmHg", "65–90 mmHg"], LIGHT_GRAY),
dataRow(["Diastolic BP", "______ mmHg", "50–70 mmHg"], WHITE),
dataRow(["SpO₂ (right hand / preductal)", "______ %", "≥95% (after 10 min of age)"], LIGHT_GRAY),
dataRow(["Blood Glucose (POC)", "______ mmol/L", "≥2.6 mmol/L"], WHITE),
dataRow(["Weight-for-GA Percentile", "______ th", "☐ AGA ☐ SGA (<10th) ☐ LGA (>90th)"], LIGHT_GRAY),
],
}));
children.push(note("Normal vital sign values: Harriet Lane Handbook 23rd ed. & Rudolph's Fundamentals of Pediatrics"));
// 8B General
children.push(subHeading("8B. General Appearance"));
for (const item of [
"☐ Active / vigorous ☐ Lethargic ☐ Irritable ☐ Inconsolable cry",
"Color: ☐ Pink (normal) ☐ Pallor ☐ Jaundice ☐ Central cyanosis ☐ Acrocyanosis (may be normal 1st hrs) ☐ Plethoric / ruddy ☐ Mottled",
"Tone: ☐ Normal (extremities flexed, symmetric) ☐ Hypotonic (frog-leg) ☐ Hypertonic / rigid ☐ Asymmetric",
"Nutritional status: ☐ Well-nourished ☐ Thin / malnourished ☐ Oedematous",
]) { children.push(para(item)); }
// 8C Head
children.push(subHeading("8C. Head & Skull"));
for (const item of [
"Shape: ☐ Normal ☐ Microcephaly ☐ Macrocephaly ☐ Molding (common, resolves) ☐ Asymmetric — suspect craniosynostosis",
"Anterior Fontanel: ☐ Soft/flat (normal) ☐ Bulging (↑ICP) ☐ Sunken (dehydration) Size: ___×___ cm (normal 4–6 cm)",
"Posterior Fontanel: ☐ Open (<1 cm, normal) ☐ Closed ☐ Enlarged",
"Scalp: ☐ Normal ☐ Caput succedaneum (crosses sutures) ☐ Cephalohematoma (does NOT cross sutures)\n ☐ Subgaleal hematoma (URGENT — fluctuant, crosses sutures) ☐ Scalp lacerations",
]) { children.push(para(item)); }
// 8D Eyes
children.push(subHeading("8D. Eyes"));
for (const item of [
"Spacing: ☐ Normal ☐ Hypertelorism ☐ Hypotelorism",
"Pupils: ☐ Equal & reactive ☐ Anisocoria",
"Red Reflex: ☐ Present bilaterally (NORMAL) ☐ WHITE reflex — URGENT referral (retinoblastoma / cataract / retinal detachment)",
"Sclera: ☐ White ☐ Icteric ☐ Subconjunctival haemorrhage (birth trauma — benign)",
"Discharge: ☐ None ☐ Purulent (ophthalmia neonatorum — URGENT) ☐ Watery (dacryostenosis)",
]) { children.push(para(item)); }
// 8E ENT
children.push(subHeading("8E. Ears, Nose & Throat"));
for (const item of [
"Ears: ☐ Normal position ☐ Low-set ☐ Pre-auricular tag/pit ☐ Canal patent bilaterally",
"Nose: ☐ Both nares patent ☐ Choanal atresia suspected (distress relieved by crying) ☐ Nasal flaring",
"Palate: ☐ Intact ☐ Cleft palate ☐ Cleft lip ☐ Submucosal cleft (palpate midline)",
"Tongue: ☐ Normal ☐ Macroglossia ☐ Tongue-tie (ankyloglossia)",
"Gums: ☐ Normal ☐ Epstein's pearls (benign) ☐ Natal teeth",
"Oral mucosa: ☐ Normal ☐ Thrush (white plaques)",
]) { children.push(para(item)); }
// 8F Neck
children.push(subHeading("8F. Neck"));
children.push(para("☐ No masses ☐ Webbing (Turner) ☐ Cystic hygroma ☐ Goitre ☐ SCM mass (torticollis)\n☐ Clavicle fracture (crepitus, asymmetric Moro)"));
// 8G Chest
children.push(subHeading("8G. Chest & Respiratory"));
for (const item of [
"Work of breathing: ☐ None ☐ Nasal flaring ☐ Subcostal recession ☐ Intercostal recession ☐ Sternal retraction ☐ Grunting ☐ Tracheal tug",
"Breath sounds: ☐ Equal bilaterally ☐ Reduced ______ side ☐ Crackles ☐ Wheeze ☐ Stridor",
"Breast tissue: ☐ Normal ☐ Physiological hypertrophy (benign) ☐ Mastitis (erythema, tenderness — treat)",
]) { children.push(para(item)); }
// 8H CVS
children.push(subHeading("8H. Cardiovascular"));
for (const item of [
"Precordium: ☐ Normal ☐ Hyperactive ☐ Displaced apex",
"Heart sounds: ☐ S1 S2 normal ☐ Murmur — Grade: ___/6 Location: ______ Radiation: ______ ☐ Gallop",
"Femoral pulses: ☐ Present & equal bilaterally ☐ Absent / weak (suspect coarctation of aorta)",
"Perfusion: ☐ CRT <3 sec (normal) ☐ CRT ≥3 sec (poor perfusion) ☐ Peripheral oedema",
"Four-limb BP (if coarctation suspected): R arm: ______ L arm: ______ Leg: ______",
]) { children.push(para(item)); }
// 8I Abdomen
children.push(subHeading("8I. Abdomen"));
for (const item of [
"Shape: ☐ Soft / rounded (normal) ☐ Distended ☐ Scaphoid (suspect diaphragmatic hernia)",
"Umbilicus: ☐ Normal (2 arteries + 1 vein) ☐ Single umbilical artery (screen renal) ☐ Omphalitis\n ☐ Granuloma ☐ Hernia ☐ Omphalocele / Gastroschisis",
"Bowel sounds: ☐ Present ☐ Absent ☐ Hyperactive",
"Liver: ______ cm below RCM ☐ Normal (<2 cm) ☐ Hepatomegaly",
"Spleen: ☐ Not palpable ☐ Palpable: ______ cm",
"Kidneys: ☐ Not palpable ☐ Palpable (PKD / hydronephrosis)",
"Anus: ☐ Patent and normally positioned ☐ Imperforate anus ☐ Anteriorly displaced",
]) { children.push(para(item)); }
// 8J Genitalia
children.push(subHeading("8J. Genitalia"));
children.push(para("Male: ☐ Testes descended bilaterally ☐ Undescended (R / L / bilateral) ☐ Hydrocele ☐ Hernia\n ☐ Hypospadias (position: ______) ☐ Epispadias"));
children.push(para("Female: ☐ Normal labia ☐ Vaginal tag (normal) ☐ Physiological discharge ☐ Hydrocolpos\n ☐ Clitoromegaly — URGENT: screen for CAH (electrolytes, 17-OHP, karyotype)"));
children.push(para("Ambiguous genitalia: ☐ Yes — URGENT workup ☐ No"));
// 8K Spine
children.push(subHeading("8K. Spine & Back"));
children.push(para("☐ Intact midline skin ☐ Shallow sacral dimple (benign) ☐ Deep/complex dimple (image)\n☐ Myelomeningocele ☐ Meningocele ☐ Hairy patch / lipoma (tethered cord) ☐ Sacrococcygeal teratoma"));
// 8L Extremities
children.push(subHeading("8L. Extremities & Musculoskeletal"));
for (const item of [
"Limbs: ☐ Symmetric movement ☐ Asymmetric (birth trauma / plexus injury)",
"Digits: ☐ Normal number ☐ Polydactyly ☐ Syndactyly ☐ Clinodactyly",
"Palmar crease: ☐ Normal ☐ Single palmar crease (Down syndrome)",
"Feet: ☐ Normal ☐ Clubfoot (talipes equinovarus) ☐ Rocker-bottom (Trisomy 18)",
]) { children.push(para(item)); }
children.push(para("Hips (MANDATORY IN EVERY NEONATE):", { bold: true }));
children.push(para(" Ortolani test: ☐ Negative ☐ Positive (clunk on abduction — femoral head relocates — DDH)"));
children.push(para(" Barlow test: ☐ Negative ☐ Positive (clunk on adduction — hip subluxes — DDH)"));
children.push(para(" Risk factors for DDH: ☐ Female ☐ Breech ☐ Family history"));
children.push(note("If positive or equivocal → refer orthopaedics. Female + breech / family hx + normal exam → hip USS at 6 weeks."));
children.push(note("Source: Textbook of Family Medicine 9e, p.530 — Ortolani & Barlow maneuvers for DDH"));
// 8M Neurological
children.push(subHeading("8M. Neurological Examination"));
for (const item of [
"Alertness: ☐ Alert ☐ Drowsy ☐ Lethargic ☐ Comatose / unresponsive",
"Cry: ☐ Normal ☐ High-pitched ☐ Weak/absent ☐ Cat-like (Cri-du-chat)",
"Tone: ☐ Normal (strong flexion, symmetric) ☐ Hypotonic (frog-leg, limbs extended)\n ☐ Hypertonic / opisthotonos ☐ Asymmetric",
]) { children.push(para(item)); }
children.push(para("Primitive Reflexes (present at term; asymmetry = ABNORMAL):"));
children.push(new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: [
headerRow(["Reflex", "Present", "Absent", "Asymmetric", "Notes"]),
dataRow(["Moro (startle)", "☐", "☐", "☐", "Absent Moro on one side — clavicle fracture / Erb's palsy"], LIGHT_GRAY),
dataRow(["Rooting", "☐", "☐", "☐", ""], WHITE),
dataRow(["Sucking", "☐", "☐", "☐", "Weak suck — neurologic / metabolic / preterm"], LIGHT_GRAY),
dataRow(["Palmar grasp", "☐", "☐", "☐", ""], WHITE),
dataRow(["Plantar grasp", "☐", "☐", "☐", ""], LIGHT_GRAY),
dataRow(["Stepping", "☐", "☐", "☐", ""], WHITE),
dataRow(["Asymmetric tonic neck", "☐", "☐", "☐", ""], LIGHT_GRAY),
],
}));
children.push(para("Brachial plexus: ☐ Normal ☐ Erb's palsy (C5–C6: adduction + internal rotation, absent Moro)\n ☐ Klumpke's palsy (C7–C8, T1: isolated hand paralysis)"));
children.push(para("Seizures: ☐ None ☐ Subtle (eye deviation, cycling) ☐ Tonic ☐ Clonic ☐ Myoclonic"));
// 8N Skin
children.push(subHeading("8N. Skin"));
children.push(para("Jaundice distribution: ☐ None ☐ Face only ☐ Trunk ☐ Below umbilicus ☐ Palms/soles (SEVERE)"));
children.push(para("Common benign lesions (reassure parents):"));
children.push(para(" ☐ Erythema toxicum neonatorum (erythematous macules/pustules on trunk — resolves spontaneously)\n ☐ Milia (tiny white facial papules) ☐ Mongolian spots (blue-gray sacral) ☐ Salmon patch / stork bite\n ☐ Lanugo (fine hair — preterm) ☐ Vernix caseosa"));
children.push(para("Concerning lesions:"));
children.push(para(" ☐ Vesiculopustular rash (HSV?) ☐ Petechiae / purpura (sepsis / TORCH)\n ☐ Bullous lesions ☐ Port wine stain on face (Sturge-Weber screen) ☐ Large congenital melanocytic naevus"));
// ═══════ SECTION 9: GESTATIONAL AGE ══════════════════════════════
children.push(sectionHeading("SECTION 9 — GESTATIONAL AGE ASSESSMENT (if uncertain)"));
children.push(kvTable([
["Ballard / New Ballard Score", "______ weeks"],
["Classification", "☐ Full-term (37–42 wks) ☐ Late preterm (34–36⁺⁶ wks)\n☐ Preterm (<34 wks) ☐ Post-term (>42 wks)"],
["Weight-GA Classification", "☐ AGA (10th–90th percentile) ☐ SGA (<10th percentile) ☐ LGA (>90th percentile)"],
]));
// ═══════ SECTION 10: WORKING DIAGNOSIS ═══════════════════════════
children.push(sectionHeading("SECTION 10 — WORKING DIAGNOSIS / PROBLEM LIST"));
for (let i = 1; i <= 4; i++) {
children.push(labelLine(`${i}.`, "____________________________________________________________"));
}
// ═══════ SECTION 11: INVESTIGATIONS ══════════════════════════════
children.push(sectionHeading("SECTION 11 — INVESTIGATIONS ORDERED"));
children.push(new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: [
headerRow(["Investigation", "Ordered", "Result / Notes"]),
...([
"Blood glucose (bedside)",
"FBC + differential",
"CRP / Procalcitonin",
"Blood culture",
"Serum bilirubin (total / direct)",
"Serum electrolytes (Na, K, Cl, HCO₃)",
"Serum calcium",
"Renal function (creatinine, urea)",
"Blood gas (venous / arterial)",
"Chest X-ray",
"Cranial ultrasound",
"Newborn metabolic screen",
"Hearing screen (OAE / AABR)",
"Pulse oximetry 4-limb (CHD screen)",
"Maternal blood group / Coombs (if jaundice)",
"Other: ______________________",
].map((inv, i) => dataRow([inv, "☐", ""], i % 2 === 0 ? LIGHT_GRAY : WHITE))),
],
}));
// ═══════ SECTION 12: MANAGEMENT PLAN ════════════════════════════
children.push(sectionHeading("SECTION 12 — INITIAL MANAGEMENT PLAN"));
children.push(subHeading("Feeding"));
for (const item of [
"☐ Breastfeeding — support and encourage",
"☐ Formula — type: ______ Volume: ______ mL/kg/day Frequency: ______",
"☐ IV fluids — type: ______ Rate: ______ mL/kg/day",
"☐ NGT / OGT — indication: ______",
]) { children.push(cb(item.replace("☐ ", ""))); }
children.push(subHeading("Thermoregulation"));
for (const item of [
"Skin-to-skin / kangaroo care",
"Incubator (target 36.5–37.5 °C)",
"Radiant warmer",
]) { children.push(cb(item)); }
children.push(subHeading("Monitoring"));
for (const item of [
"Continuous cardiorespiratory monitoring",
"SpO₂ monitoring",
"Hourly blood glucose monitoring",
"4-hourly vital signs",
]) { children.push(cb(item)); }
children.push(subHeading("Medications & Prophylaxis"));
for (const item of [
"Vitamin K — dose: ______",
"Eye prophylaxis given",
"HBV vaccine",
"Sepsis screen + empirical antibiotics: ______ (if indicated)",
"Antifungal prophylaxis (VLBW): ______",
"Phototherapy (jaundice threshold reached: ☐ Yes ☐ No)",
"Other: ______",
]) { children.push(cb(item)); }
children.push(para("Parental counselling: ☐ Done ☐ Pending", { spaceBefore: 120 }));
children.push(para("Consent: ☐ Obtained"));
// ═══════ SECTION 13: SIGNATURE ════════════════════════════════════
children.push(sectionHeading("SECTION 13 — CLINICIAN SIGNATURE"));
children.push(new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: [
new TableRow({ children: [
new TableCell({ borders: thinBorder, shading: { type: ShadingType.CLEAR, fill: LIGHT_BLUE }, children: [labelLine("Examining Clinician:", "")] }),
new TableCell({ borders: thinBorder, children: [labelLine("Designation:", "")] }),
]}),
new TableRow({ children: [
new TableCell({ borders: thinBorder, children: [labelLine("Date / Time:", "")] }),
new TableCell({ borders: thinBorder, children: [labelLine("Supervisor Review:", "")] }),
]}),
],
}));
// ═══════ QUICK REFERENCE BOX ══════════════════════════════════════
children.push(new Paragraph({ children: [], spacing: { before: 200 } }));
children.push(new Paragraph({
children: [new TextRun({ text: "QUICK REFERENCE — NORMAL NEONATAL VITAL SIGNS (TERM)", bold: true, size: 22, color: WHITE, font: "Calibri" })],
alignment: AlignmentType.CENTER,
spacing: { before: 100, after: 80 },
shading: { type: ShadingType.CLEAR, fill: DARK_BLUE },
}));
children.push(new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: thinBorder,
rows: [
headerRow(["Parameter", "Normal Value", "Source"]),
dataRow(["Heart Rate", "100–180 bpm", "Harriet Lane Handbook 23rd ed."], LIGHT_GRAY),
dataRow(["Respiratory Rate", "24–60 breaths/min", "Harriet Lane Handbook 23rd ed."], WHITE),
dataRow(["Systolic BP", "65–90 mmHg", "Harriet Lane Handbook 23rd ed."], LIGHT_GRAY),
dataRow(["Diastolic BP", "50–70 mmHg", "Harriet Lane Handbook 23rd ed."], WHITE),
dataRow(["Temperature", "36.0–38.0 °C", "Harriet Lane Handbook 23rd ed."], LIGHT_GRAY),
dataRow(["SpO₂ (preductal)", "≥95%", "Tintinalli's EM, Chapter 108"], WHITE),
dataRow(["Blood Glucose", "≥2.6 mmol/L (≥47 mg/dL)", "Harriet Lane Handbook 23rd ed."], LIGHT_GRAY),
],
}));
// ═══════ REFERENCES ═══════════════════════════════════════════════
children.push(new Paragraph({ children: [], spacing: { before: 200 } }));
children.push(sectionHeading("REFERENCES"));
for (const ref of [
"Textbook of Family Medicine, 9th ed. — Chapter 21: Care of the Newborn, pp. 529–531",
"Tintinalli's Emergency Medicine: A Comprehensive Study, 9th ed. — Chapter 108: Neonatal Resuscitation, p. 716",
"The Harriet Lane Handbook, 23rd ed. (Johns Hopkins Hospital) — Normal Vital Signs & Drug Dosing",
"Fitzpatrick's Dermatology, 9th ed. — Neonatal Skin Diseases, p. 1757",
"Creasy & Resnik's Maternal-Fetal Medicine: Principles and Practice — Neonatal Assessment",
]) {
children.push(new Paragraph({
children: [new TextRun({ text: "• " + ref, size: 18, font: "Calibri", italics: true })],
spacing: { before: 40, after: 40 }, indent: { left: 180 },
}));
}
// ═══════ ASSEMBLE & WRITE ═════════════════════════════════════════
const doc = new Document({
creator: "Orris Medical AI",
title: "Neonatal Ward Admission Proforma",
description: "Comprehensive neonatal history & examination template based on standard references",
styles: {
default: {
document: { run: { font: "Calibri", size: 20 } },
},
},
sections: [{
properties: {
page: {
margin: { top: 720, bottom: 720, left: 900, right: 900 },
},
},
headers: {
default: new Header({
children: [new Paragraph({
children: [
new TextRun({ text: "NEONATAL WARD ADMISSION PROFORMA", bold: true, size: 18, font: "Calibri", color: MID_BLUE }),
new TextRun({ text: " | Confidential Medical Record", size: 16, font: "Calibri", color: "888888" }),
],
alignment: AlignmentType.CENTER,
border: { bottom: { style: BorderStyle.SINGLE, size: 6, color: MID_BLUE } },
})],
}),
},
footers: {
default: new Footer({
children: [new Paragraph({
children: [
new TextRun({ text: "Page ", size: 16, font: "Calibri", color: "888888" }),
new TextRun({ children: [PageNumber.CURRENT], size: 16, font: "Calibri", color: "888888" }),
new TextRun({ text: " of ", size: 16, font: "Calibri", color: "888888" }),
new TextRun({ children: [PageNumber.TOTAL_PAGES], size: 16, font: "Calibri", color: "888888" }),
new TextRun({ text: " | Based on Harriet Lane Handbook 23rd ed · Tintinalli's EM · Textbook of Family Medicine 9e", size: 14, font: "Calibri", color: "AAAAAA", italics: true }),
],
alignment: AlignmentType.CENTER,
})],
}),
},
children,
}],
});
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync("/home/daytona/workspace/neonatal-admission/Neonatal_Admission_Proforma.docx", buffer);
console.log("SUCCESS: Document written.");
}).catch(err => {
console.error("ERROR:", err.message);
process.exit(1);
});