6 years old boy presents with 5 days of fever ,cold.prepare case pro forms in pediatrics

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace && ls -la /home/daytona/workspace/

Running Command

mkdir -p /home/daytona/workspace/pediatric-proforma && ls /home/daytona/skills/docx/

Writing File

~/pediatric-proforma/generate.js

const {
  Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
  HeadingLevel, AlignmentType, BorderStyle, WidthType, VerticalAlign,
  ShadingType, PageBreak, Header, Footer, PageNumber, NumberFormat
} = require('docx');
const fs = require('fs');

// ── helpers ──────────────────────────────────────────────────────────────────

const BORDER = { style: BorderStyle.SINGLE, size: 6, color: '2B6CB0' };
const THIN   = { style: BorderStyle.SINGLE, size: 4, color: 'A0AEC0' };
const NO_BDR = { style: BorderStyle.NONE,   size: 0, color: 'FFFFFF' };

const cellBorders = (t='thin') => {
  const b = t === 'thick' ? BORDER : THIN;
  return { top: b, bottom: b, left: b, right: b };
};

const shade = (hex) => ({ type: ShadingType.CLEAR, fill: hex, color: 'auto' });

/** Heading paragraph */
function h(text, level, opts = {}) {
  return new Paragraph({
    text,
    heading: level,
    alignment: opts.center ? AlignmentType.CENTER : AlignmentType.LEFT,
    spacing: { before: opts.before ?? 200, after: opts.after ?? 100 },
    ...opts.extra,
  });
}

/** Plain paragraph */
function p(text = '', opts = {}) {
  return new Paragraph({
    children: [new TextRun({ text, size: 20, font: 'Calibri', ...opts.run })],
    spacing: { before: opts.before ?? 40, after: opts.after ?? 40 },
    alignment: opts.align ?? AlignmentType.LEFT,
  });
}

/** Bold label + normal value */
function labelLine(label, value = '', indent = false) {
  return new Paragraph({
    children: [
      new TextRun({ text: label, bold: true, size: 20, font: 'Calibri' }),
      new TextRun({ text: value, size: 20, font: 'Calibri' }),
    ],
    spacing: { before: 40, after: 40 },
    indent: indent ? { left: 360 } : undefined,
  });
}

/** Two-column label + blank field row */
function fieldRow(label, wide = false) {
  const w = wide ? 7800 : 3900;
  return new TableRow({
    children: [
      new TableCell({
        children: [new Paragraph({
          children: [new TextRun({ text: label, bold: true, size: 18, font: 'Calibri' })],
          spacing: { before: 30, after: 30 },
        })],
        width: { size: 2200, type: WidthType.DXA },
        borders: cellBorders(),
        shading: shade('EBF8FF'),
      }),
      new TableCell({
        children: [p('')],
        width: { size: w, type: WidthType.DXA },
        borders: cellBorders(),
      }),
    ],
  });
}

/** Two equal column row for side-by-side fields */
function doubleFieldRow(lbl1, lbl2) {
  function half(lbl) {
    return new TableCell({
      children: [new Paragraph({
        children: [new TextRun({ text: lbl, bold: true, size: 18, font: 'Calibri' })],
        spacing: { before: 30, after: 30 },
      })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    });
  }
  function halfBlank() {
    return new TableCell({ children: [p('')], width: { size: 2500, type: WidthType.DXA }, borders: cellBorders() });
  }
  return new TableRow({ children: [half(lbl1), halfBlank(), half(lbl2), halfBlank()] });
}

/** Section header row spanning all columns */
function sectionHeaderRow(text, cols = 2) {
  return new TableRow({
    children: [new TableCell({
      children: [new Paragraph({
        children: [new TextRun({ text, bold: true, size: 20, color: 'FFFFFF', font: 'Calibri' })],
        spacing: { before: 60, after: 60 },
        alignment: AlignmentType.CENTER,
      })],
      columnSpan: cols,
      shading: shade('2B6CB0'),
      borders: cellBorders('thick'),
    })],
  });
}

/** Simple table from rows array */
function simpleTable(rows, width = 10000) {
  return new Table({
    rows,
    width: { size: width, type: WidthType.DXA },
  });
}

// ─────────────────────────────────────────────────────────────────────────────
// BUILD DOCUMENT
// ─────────────────────────────────────────────────────────────────────────────

const titleSection = [
  h('DEPARTMENT OF PEDIATRICS', HeadingLevel.HEADING_1, { center: true, before: 0, after: 60 }),
  new Paragraph({
    children: [new TextRun({ text: 'PEDIATRIC CASE PROFORMA', bold: true, size: 32, color: '2B6CB0', font: 'Calibri' })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 60, after: 60 },
  }),
  new Paragraph({
    children: [new TextRun({ text: 'Chief Complaint: Fever with Cold / Upper Respiratory Tract Infection', italics: true, size: 22, color: '4A5568', font: 'Calibri' })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 40, after: 200 },
  }),
];

// ── 1. IDENTIFICATION ─────────────────────────────────────────────────────────
const identTable = simpleTable([
  sectionHeaderRow('1. PATIENT IDENTIFICATION', 2),
  fieldRow('Name of Patient'),
  fieldRow('Age / Date of Birth'),
  doubleFieldRow('Sex (M / F)', 'Religion'),
  fieldRow('Address / Residential Area'),
  doubleFieldRow('IP / OP Number', 'Date of Admission'),
  doubleFieldRow('Date of Examination', 'Bed Number'),
  fieldRow('Name & Age of Informant'),
  fieldRow('Relation to Patient'),
  fieldRow('Reliability of Informant (Good / Fair / Poor)'),
]);

// ── 2. CHIEF COMPLAINTS ───────────────────────────────────────────────────────
const ccTable = simpleTable([
  sectionHeaderRow('2. CHIEF COMPLAINTS (in chronological order)', 2),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [
        new Paragraph({ children: [new TextRun({ text: 'Complaint', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } }),
        new Paragraph({ children: [new TextRun({ text: '1.  Fever                                           since _______ days', size: 18, font: 'Calibri' })], spacing: { before: 20, after: 20 } }),
        new Paragraph({ children: [new TextRun({ text: '2.  Nasal discharge / Cold                          since _______ days', size: 18, font: 'Calibri' })], spacing: { before: 20, after: 20 } }),
        new Paragraph({ children: [new TextRun({ text: '3.  ______________________________                  since _______ days', size: 18, font: 'Calibri' })], spacing: { before: 20, after: 20 } }),
        new Paragraph({ children: [new TextRun({ text: '4.  ______________________________                  since _______ days', size: 18, font: 'Calibri' })], spacing: { before: 20, after: 20 } }),
        new Paragraph({ children: [new TextRun({ text: '5.  ______________________________                  since _______ days', size: 18, font: 'Calibri' })], spacing: { before: 20, after: 20 } }),
      ],
      borders: cellBorders(),
    }),
  ]}),
]);

// ── 3. HISTORY OF PRESENT ILLNESS ─────────────────────────────────────────────
const hpiRows = [
  sectionHeaderRow('3. HISTORY OF PRESENT ILLNESS (HPI)', 2),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [
        new Paragraph({ children: [new TextRun({ text: 'A. FEVER', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } }),
      ],
      borders: cellBorders(),
    }),
  ]}),
  fieldRow('Onset (Sudden / Gradual)'),
  fieldRow('Duration (days)'),
  fieldRow('Grade of Fever'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Pattern of Fever', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Continuous   [ ] Remittent   [ ] Intermittent   [ ] Hectic   [ ] Undulant', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Diurnal Variation (Morning / Evening / No variation)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Associated Features of Fever', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Chills/Rigors   [ ] Sweating   [ ] Convulsions   [ ] Delirium   [ ] Rash', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Relieving Factors (Antipyretics: Yes / No, Name)'),
  fieldRow('Response to Antipyretics (Complete / Partial / None)'),

  // Cold
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [
        new Paragraph({ children: [new TextRun({ text: 'B. NASAL SYMPTOMS (COLD)', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } }),
      ],
      borders: cellBorders(),
    }),
  ]}),
  fieldRow('Onset (days)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Character of Discharge', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Clear/Watery   [ ] Mucoid   [ ] Mucopurulent   [ ] Blood-tinged', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Nasal Obstruction', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Unilateral   [ ] Bilateral   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Sneezing (Yes / No)'),
  fieldRow('Loss of Smell (Yes / No)'),

  // Throat
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'C. THROAT SYMPTOMS', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Sore Throat', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Yes   [ ] No       Dysphagia:  [ ] Yes   [ ] No', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Change in Voice (Hoarseness: Yes / No)'),

  // Cough
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'D. COUGH', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Nature of Cough', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Dry   [ ] Productive   [ ] Barking   [ ] Whooping   [ ] Absent', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Expectoration (Yes / No; if Yes describe)'),
  fieldRow('Breathlessness (Yes / No; NYHA grade if applicable)'),
  fieldRow('Stridor (Yes / No)'),

  // Ears
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'E. EAR SYMPTOMS', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Ear Symptoms', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Ear pain (Otalgia)   [ ] Discharge   [ ] Hearing Loss   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},

  // Other
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'F. OTHER ASSOCIATED SYMPTOMS', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'CNS Symptoms', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Headache   [ ] Photophobia   [ ] Neck stiffness   [ ] Altered sensorium   [ ] Seizures', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'GI Symptoms', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Vomiting   [ ] Diarrhea   [ ] Abdominal pain   [ ] Anorexia   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Rash / Skin Changes (Yes / No; if Yes describe)'),
  fieldRow('Conjunctival Redness / Eye Discharge (Yes / No)'),
  fieldRow('Decreased Urine Output (Yes / No)'),
  fieldRow('Any treatment taken before admission (specify)'),
];
const hpiTable = simpleTable(hpiRows);

// ── 4. PAST HISTORY ───────────────────────────────────────────────────────────
const pastRows = [
  sectionHeaderRow('4. PAST HISTORY', 2),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Similar Episodes in the Past', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Yes   [ ] No     If Yes: Number of times ______  Last episode ______', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('History of Recurrent URTI / Otitis Media'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Allergic Conditions', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Asthma   [ ] Allergic Rhinitis   [ ] Eczema   [ ] Food Allergy   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Previous Hospitalizations', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Yes   [ ] No     Reason: ________________________________', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Surgeries / Procedures (tonsillectomy, adenoidectomy, myringotomy)'),
  fieldRow('Known Drug Allergy (drug name + reaction)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Significant Illnesses', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Tuberculosis   [ ] Rheumatic fever   [ ] Measles   [ ] Chickenpox   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
];
const pastTable = simpleTable(pastRows);

// ── 5. BIRTH HISTORY ──────────────────────────────────────────────────────────
const birthRows = [
  sectionHeaderRow('5. BIRTH HISTORY', 2),
  fieldRow('Gestational Age at Birth (weeks)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Mode of Delivery', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Normal Vaginal   [ ] LSCS   [ ] Forceps   [ ] Vacuum     Place: [ ] Hospital   [ ] Home', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Birth Weight (kg)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Perinatal Complications', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Asphyxia   [ ] NICU stay   [ ] Jaundice   [ ] Sepsis   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Cry at birth (Immediate / Delayed / Absent)'),
];
const birthTable = simpleTable(birthRows);

// ── 6. IMMUNIZATION ───────────────────────────────────────────────────────────
const immunRows = [
  sectionHeaderRow('6. IMMUNIZATION HISTORY (As per National Immunization Schedule – India)', 2),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Vaccine', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 }, alignment: AlignmentType.CENTER })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('2B6CB0'),
      verticalAlign: VerticalAlign.CENTER,
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Given (Yes/No)', bold: true, size: 18, font: 'Calibri', color: 'FFFFFF' })], spacing: { before: 30, after: 30 }, alignment: AlignmentType.CENTER })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('2B6CB0'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Doses Given', bold: true, size: 18, font: 'Calibri', color: 'FFFFFF' })], spacing: { before: 30, after: 30 }, alignment: AlignmentType.CENTER })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('2B6CB0'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Remarks', bold: true, size: 18, font: 'Calibri', color: 'FFFFFF' })], spacing: { before: 30, after: 30 }, alignment: AlignmentType.CENTER })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('2B6CB0'),
    }),
  ]},
  ...['BCG', 'OPV (0, 1, 2, 3 + Booster)', 'Hepatitis B (3 doses)', 'DPT (3 doses + Boosters)', 'Hib', 'IPV', 'Measles / MR / MMR', 'Vitamin A (1st dose at 9 months)', 'Typhoid', 'Influenza', 'Varicella'].map(vax =>
    new TableRow({ children: [
      new TableCell({ children: [p(vax)], width: { size: 2500, type: WidthType.DXA }, borders: cellBorders(), shading: shade('EBF8FF') }),
      new TableCell({ children: [p('')], width: { size: 2500, type: WidthType.DXA }, borders: cellBorders() }),
      new TableCell({ children: [p('')], width: { size: 2500, type: WidthType.DXA }, borders: cellBorders() }),
      new TableCell({ children: [p('')], width: { size: 2500, type: WidthType.DXA }, borders: cellBorders() }),
    ]})
  ),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 4,
      children: [new Paragraph({ children: [new TextRun({ text: 'Immunization Status Overall:  [ ] Complete   [ ] Incomplete   [ ] Not immunized', size: 18, font: 'Calibri', bold: true })], spacing: { before: 30, after: 30 } })],
      borders: cellBorders(),
    }),
  ]}),
];
const immunTable = simpleTable(immunRows, 10000);

// ── 7. DEVELOPMENTAL HISTORY ──────────────────────────────────────────────────
const devRows = [
  sectionHeaderRow('7. DEVELOPMENTAL HISTORY', 2),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'Milestones achieved (age in months):', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  doubleFieldRow('Smiled socially (1.5 mo)', 'Head holding (3-4 mo)'),
  doubleFieldRow('Sitting without support (6-9 mo)', 'Standing alone (10-12 mo)'),
  doubleFieldRow('Walking alone (12-15 mo)', 'First words (12 mo)'),
  doubleFieldRow('Two-word phrases (18-24 mo)', 'Bladder/Bowel control'),
  fieldRow('School attendance (Class / Grade)'),
  fieldRow('Academic performance (Good / Average / Below average)'),
  fieldRow('Any regression of milestones (Yes / No; details)'),
];
const devTable = simpleTable(devRows);

// ── 8. NUTRITIONAL HISTORY ────────────────────────────────────────────────────
const nutRows = [
  sectionHeaderRow('8. NUTRITIONAL HISTORY', 2),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Feeding as Infant', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Exclusive Breastfeeding (till __ months)   [ ] Mixed   [ ] Formula only', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Complementary Feeding started at (months)'),
  fieldRow('Current Diet (Vegetarian / Mixed / Junk food predominant)'),
  fieldRow('Appetite (Good / Reduced / Increased)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Signs of Malnutrition', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Hair changes   [ ] Skin changes   [ ] Edema   [ ] Night blindness   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Vitamin/Iron/Zinc supplementation (Yes / No; name)'),
];
const nutTable = simpleTable(nutRows);

// ── 9. FAMILY HISTORY ─────────────────────────────────────────────────────────
const famRows = [
  sectionHeaderRow('9. FAMILY HISTORY', 2),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Family History of:', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Recurrent URTI   [ ] Asthma/Allergy   [ ] Tuberculosis   [ ] Immunodeficiency   [ ] None', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Consanguinity of Parents (Yes / No; if Yes, degree)'),
  fieldRow('Siblings (Number, ages, health status)'),
  fieldRow('Any sibling with similar illness currently (Yes / No)'),
  fieldRow('Father - Age, Occupation, Health Status'),
  fieldRow('Mother - Age, Occupation, Health Status'),
];
const famTable = simpleTable(famRows);

// ── 10. SOCIO-ENVIRONMENTAL HISTORY ──────────────────────────────────────────
const socRows = [
  sectionHeaderRow('10. SOCIO-ENVIRONMENTAL HISTORY', 2),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Socioeconomic Status', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Class (Kuppuswamy): [ ] I   [ ] II   [ ] III   [ ] IV   [ ] V', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Housing', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Pucca   [ ] Kutcha   [ ] Overcrowded   Ventilation: [ ] Good   [ ] Poor', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Source of Drinking Water (Tap / Well / Borewell / Packaged)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Passive Smoking Exposure', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Yes (indoor smoke / tobacco / biomass fuel)   [ ] No', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Contact History (sick person at home / school / day care)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Pet Animals at Home', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Yes (specify) ______________   [ ] No', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Travel History in last 2 weeks (Yes / No; destination)'),
];
const socTable = simpleTable(socRows);

// ── PAGE BREAK ────────────────────────────────────────────────────────────────
const pageBreak = new Paragraph({ children: [new PageBreak()] });

// ── 11. GENERAL PHYSICAL EXAMINATION ─────────────────────────────────────────
const gpeRows = [
  sectionHeaderRow('11. GENERAL PHYSICAL EXAMINATION (GPE)', 2),

  // Vitals
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'A. VITAL SIGNS', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  doubleFieldRow('Temperature (°F / °C)', 'Route (Axillary/Rectal/Oral)'),
  doubleFieldRow('Heart Rate (bpm)', 'Respiratory Rate (breaths/min)'),
  doubleFieldRow('Blood Pressure (mmHg)', 'SpO2 (%)'),
  doubleFieldRow('Weight (kg)', 'Height / Length (cm)'),
  doubleFieldRow('Head Circumference (cm)', 'Mid-arm circumference (cm)'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Weight-for-Age', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Percentile: ___   Z-score: ___   [ ] Normal   [ ] Underweight   [ ] Severe Underweight', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Height-for-Age', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Percentile: ___   Z-score: ___   [ ] Normal   [ ] Stunted', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2500, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('BMI (kg/m²) and Interpretation'),

  // General appearance
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'B. GENERAL APPEARANCE', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Built & Nourishment', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Well-built and well-nourished   [ ] Moderately nourished   [ ] Poorly nourished', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Pallor', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Present (Mild/Moderate/Severe)   [ ] Absent', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Icterus', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Present (Grade: 1/2/3/4)   [ ] Absent', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Cyanosis', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Central   [ ] Peripheral   [ ] Absent', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Clubbing', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Present (Grade 1/2/3/4)   [ ] Absent', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Edema', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Present (pitting/non-pitting, site)   [ ] Absent', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Lymphadenopathy', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Sites: [ ] Cervical   [ ] Submandibular   [ ] Axillary   [ ] Inguinal     Size: __ cm   Tender: Yes/No', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Dehydration', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] None   [ ] Some (sunken eyes, dry mucosa, reduced skin turgor)   [ ] Severe', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Toxic / Ill-looking Appearance', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Yes   [ ] No', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
];
const gpeTable = simpleTable(gpeRows);

// ── 12. SYSTEMIC EXAMINATION ──────────────────────────────────────────────────
const sysRows = [
  sectionHeaderRow('12. SYSTEMIC EXAMINATION', 2),

  // ENT
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'A. ENT EXAMINATION (Priority in this case)', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Nose', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Nasal mucosa: [ ] Normal   [ ] Erythematous   [ ] Pale/boggy     Polyp: [ ] Yes   [ ] No\nDischarge: [ ] None   [ ] Anterior   [ ] Post-nasal drip     Deviated septum: [ ] Yes   [ ] No', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Throat', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Pharyngeal wall: [ ] Normal   [ ] Injected/Erythematous   [ ] Granular\nTonsils: [ ] Normal   [ ] Enlarged (Grade I/II/III/IV)   [ ] Exudate   [ ] Crypts\nUvula: [ ] Central   [ ] Deviated', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Ears (Otoscopy)', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Right ear - TM: [ ] Intact/Normal   [ ] Dull/Retracted   [ ] Bulging   [ ] Perforated\nLeft ear - TM: [ ] Intact/Normal   [ ] Dull/Retracted   [ ] Bulging   [ ] Perforated\nEAC: [ ] Clear   [ ] Discharge   [ ] Wax', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Tenderness over sinuses (Frontal / Maxillary / None)'),
  fieldRow('Mastoid tenderness (Yes / No; side)'),

  // Respiratory
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'B. RESPIRATORY SYSTEM', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Inspection', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Chest shape: [ ] Normal   [ ] Barrel chest   [ ] Harrison\'s sulcus\nRetractions: [ ] None   [ ] Subcostal   [ ] Intercostal   [ ] Suprasternal\nBreathing pattern: [ ] Normal   [ ] Labored   [ ] Paradoxical', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Palpation', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Trachea: [ ] Central   [ ] Shifted\nVocal fremitus: [ ] Normal   [ ] Increased   [ ] Decreased\nTender ribs: [ ] Yes   [ ] No', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Percussion', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Resonant bilaterally   [ ] Dull (site: _______)   [ ] Hyper-resonant (site: _______)', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Auscultation', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Breath sounds: [ ] Normal vesicular   [ ] Diminished   [ ] Bronchial\nAdded sounds: [ ] None   [ ] Wheeze (expiratory/inspiratory)   [ ] Crackles (fine/coarse)   [ ] Rhonchi\nSite: _______', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Stridor (Inspiratory / Expiratory / Both / Absent)'),

  // CVS
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'C. CARDIOVASCULAR SYSTEM', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  fieldRow('Precordium (Normal / Heaving / Pulsatile)'),
  fieldRow('Apex Beat (location, character)'),
  fieldRow('Heart Sounds (S1 S2: Normal / Muffled; Murmur: Yes/No; site/grade)'),
  fieldRow('Peripheral pulses (Volume: Good / Poor / Absent; Character)'),
  fieldRow('Capillary Refill Time (seconds)'),

  // Abdomen
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'D. ABDOMEN', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  fieldRow('Shape / Distension (Flat / Scaphoid / Distended / Protuberant)'),
  fieldRow('Liver (size in cm below RCM; tender: Yes/No; surface/edge)'),
  fieldRow('Spleen (Palpable: Yes/No; size / schuffner\'s grade)'),
  fieldRow('Tenderness (site; guarding; rigidity)'),
  fieldRow('Bowel sounds (Normal / Increased / Decreased / Absent)'),

  // CNS
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'E. CENTRAL NERVOUS SYSTEM', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Level of Consciousness', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: '[ ] Alert and oriented   [ ] Irritable   [ ] Lethargic   [ ] Confused   [ ] GCS: E__V__M__', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Meningeal Signs', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Neck stiffness: [ ] Yes   [ ] No     Kernig\'s sign: [ ] +ve   [ ] -ve     Brudzinski\'s: [ ] +ve   [ ] -ve', size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Cranial nerves (Normal / Abnormal; specify)'),
  fieldRow('Motor system (Tone / Power / DTRs / Plantar response)'),
  fieldRow('Anterior fontanelle (if applicable) - Bulging / Depressed / Closed'),
];
const sysTable = simpleTable(sysRows);

// ── 13. INVESTIGATIONS ────────────────────────────────────────────────────────
const invRows = [
  sectionHeaderRow('13. INVESTIGATIONS', 2),

  // Routine
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'A. ROUTINE / FIRST-LINE', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Complete Blood Count (CBC)', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [
        new Paragraph({ children: [new TextRun({ text: 'Hb: ___ g/dL   WBC: ___ cells/cumm   Platelets: ___/cumm', size: 18, font: 'Calibri' })], spacing: { before: 20, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: 'Differential: N:__ L:__ E:__ M:__ B:__   Toxic granules: Yes/No', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 20 } }),
      ],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('ESR (mm/1st hr)'),
  fieldRow('C-Reactive Protein (CRP) (mg/L)'),
  fieldRow('Blood Culture & Sensitivity (if indicated)'),
  fieldRow('Urine Routine & Microscopy'),
  fieldRow('Throat Swab Culture (if Group A Strep suspected)'),
  fieldRow('Rapid Antigen Tests (COVID-19, Influenza, RSV) if available'),

  // Specific
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'B. SPECIFIC / DIRECTED BY CLINICAL FINDINGS', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  fieldRow('Chest X-Ray (if cough/wheeze/consolidation suspected)'),
  fieldRow('X-ray PNS (Water\'s view) if sinusitis suspected'),
  fieldRow('Nasal smear for eosinophils (if allergic rhinitis suspected)'),
  fieldRow('Serology: Dengue NS1/IgM; Typhoid Widal; Malaria RDT/smear'),
  fieldRow('ASO titre / Throat swab (if Strep pharyngitis suspected)'),
  fieldRow('LFT / RFT / Blood glucose (if systemically unwell)'),
  fieldRow('Procalcitonin (if bacterial sepsis suspected)'),
];
const invTable = simpleTable(invRows);

// ── 14. DIAGNOSIS ─────────────────────────────────────────────────────────────
const diagRows = [
  sectionHeaderRow('14. DIAGNOSIS', 2),
  fieldRow('Provisional Diagnosis'),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Differential Diagnoses', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 } })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('EBF8FF'),
    }),
    new TableCell({
      children: [
        new Paragraph({ children: [new TextRun({ text: '1. ______________________________________', size: 18, font: 'Calibri' })], spacing: { before: 20, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '2. ______________________________________', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '3. ______________________________________', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 20 } }),
      ],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
    }),
  ]},
  fieldRow('Final Diagnosis (after investigations)'),
  fieldRow('ICD-10 Code'),
];
const diagTable = simpleTable(diagRows);

// ── 15. MANAGEMENT ────────────────────────────────────────────────────────────
const mgmtRows = [
  sectionHeaderRow('15. MANAGEMENT PLAN', 2),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'A. NON-PHARMACOLOGICAL', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [
        new Paragraph({ children: [new TextRun({ text: '[ ] Adequate rest and fluids (oral hydration encouraged)', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Saline nasal drops / nasal irrigation', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Steam inhalation (supervised, avoid burns in children)', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Head-end elevation at night', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Warm gargles (if cooperative)', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Avoid contact with other sick individuals', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 20 } }),
      ],
      borders: cellBorders(),
    }),
  ]}),

  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'B. PHARMACOLOGICAL', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Drug', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 30, after: 30 }, alignment: AlignmentType.CENTER })],
      width: { size: 2200, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('2B6CB0'),
    }),
    new TableCell({
      children: [new Paragraph({ children: [new TextRun({ text: 'Dose, Route, Frequency, Duration, Remarks', bold: true, size: 18, font: 'Calibri', color: 'FFFFFF' })], spacing: { before: 30, after: 30 }, alignment: AlignmentType.CENTER })],
      width: { size: 7800, type: WidthType.DXA },
      borders: cellBorders(),
      shading: shade('2B6CB0'),
    }),
  ]},
  ...['Paracetamol (Antipyretic / Analgesic)', 'Ibuprofen (if >3 months, fever not controlled)', 'Antihistamine (Chlorpheniramine if prescribed)', 'Decongestant (Oxymetazoline drops - max 3 days)', 'Cough Suppressant / Expectorant', 'Antibiotic (only if bacterial cause confirmed)', 'Bronchodilator (if wheeze present)', 'ORS / IV Fluids (if dehydrated)', 'Other'].map(d =>
    new TableRow({ children: [
      new TableCell({ children: [p(d)], width: { size: 2200, type: WidthType.DXA }, borders: cellBorders(), shading: shade('EBF8FF') }),
      new TableCell({ children: [p('')], width: { size: 7800, type: WidthType.DXA }, borders: cellBorders() }),
    ]})
  ),

  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [new Paragraph({ children: [new TextRun({ text: 'C. REFERRAL / SPECIALIST CONSULTATION', bold: true, underline: {}, size: 20, font: 'Calibri', color: '2B6CB0' })], spacing: { before: 40, after: 20 } })],
      borders: cellBorders(),
    }),
  ]}),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [
        new Paragraph({ children: [new TextRun({ text: '[ ] ENT (Chronic/recurrent tonsillitis, AOM with complications, adenoid hypertrophy)', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Pulmonology (suspected asthma, recurrent wheeze)', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Immunology (recurrent/unusual infections)', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Other: _______________________________________________', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 20 } }),
      ],
      borders: cellBorders(),
    }),
  ]}),
];
const mgmtTable = simpleTable(mgmtRows);

// ── 16. FOLLOW-UP & PATIENT EDUCATION ─────────────────────────────────────────
const followRows = [
  sectionHeaderRow('16. FOLLOW-UP & PATIENT / PARENT EDUCATION', 2),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [
        new Paragraph({ children: [new TextRun({ text: 'RED FLAG SIGNS - Return immediately if:', bold: true, size: 20, font: 'Calibri', color: 'C53030' })], spacing: { before: 30, after: 20 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Persistent fever >5 days or high-grade fever (>40°C) not responding to antipyretics', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Difficulty breathing / fast breathing / chest indrawing', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Unable to drink fluids / poor feeding', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Altered consciousness / excessive irritability / inconsolable crying', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Convulsions / Neck stiffness', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Ear pain / discharge from ear', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Skin rash with fever', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 20 } }),
      ],
      borders: cellBorders(),
    }),
  ]}),
  fieldRow('Next Follow-up Date'),
  new TableRow({ children: [
    new TableCell({
      columnSpan: 2,
      children: [
        new Paragraph({ children: [new TextRun({ text: 'Parent Counseling Done:', bold: true, size: 18, font: 'Calibri' })], spacing: { before: 20, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Importance of adequate fluid intake   [ ] Antipyretic use and fever management at home', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Avoiding antibiotics without prescription   [ ] Hand hygiene and droplet precautions', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 10 } }),
        new Paragraph({ children: [new TextRun({ text: '[ ] Catch-up vaccination discussed   [ ] Nutritional guidance', size: 18, font: 'Calibri' })], spacing: { before: 10, after: 20 } }),
      ],
      borders: cellBorders(),
    }),
  ]}),
];
const followTable = simpleTable(followRows);

// ── 17. SIGNATURE ─────────────────────────────────────────────────────────────
const sigRows = [
  sectionHeaderRow('17. CLINICIAN DETAILS & SIGNATURE', 2),
  doubleFieldRow('Name of Resident / Intern', 'Registration Number'),
  doubleFieldRow('Designation', 'Unit / Ward'),
  doubleFieldRow('Name of Supervising Consultant', 'Signature & Date'),
];
const sigTable = simpleTable(sigRows);

// ─────────────────────────────────────────────────────────────────────────────
// ASSEMBLE
// ─────────────────────────────────────────────────────────────────────────────
const doc = new Document({
  styles: {
    default: {
      document: {
        run: { font: 'Calibri', size: 20 },
      },
    },
    paragraphStyles: [
      {
        id: 'Heading1',
        name: 'Heading 1',
        run: { bold: true, size: 28, color: '1A365D', font: 'Calibri' },
        paragraph: { spacing: { before: 240, after: 120 } },
      },
    ],
  },
  sections: [{
    properties: {
      page: {
        margin: { top: 720, bottom: 720, left: 720, right: 720 },
      },
    },
    headers: {
      default: new Header({
        children: [new Paragraph({
          children: [
            new TextRun({ text: 'PEDIATRIC CASE PROFORMA  |  DEPT. OF PEDIATRICS', size: 16, bold: true, font: 'Calibri', color: '4A5568' }),
          ],
          alignment: AlignmentType.CENTER,
          border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: 'A0AEC0' } },
        })],
      }),
    },
    footers: {
      default: new Footer({
        children: [new Paragraph({
          children: [
            new TextRun({ text: 'Confidential Medical Record  |  Page ', size: 16, font: 'Calibri', color: '718096' }),
            new PageNumber({ size: 16 }),
          ],
          alignment: AlignmentType.CENTER,
        })],
      }),
    },
    children: [
      ...titleSection,
      identTable,
      p(''),
      ccTable,
      p(''),
      hpiTable,
      p(''),
      pastTable,
      p(''),
      birthTable,
      p(''),
      immunTable,
      p(''),
      devTable,
      p(''),
      nutTable,
      p(''),
      famTable,
      p(''),
      socTable,
      pageBreak,
      gpeTable,
      p(''),
      sysTable,
      p(''),
      invTable,
      p(''),
      diagTable,
      p(''),
      mgmtTable,
      p(''),
      followTable,
      p(''),
      sigTable,
    ],
  }],
});

Packer.toBuffer(doc).then(buffer => {
  fs.writeFileSync('/home/daytona/workspace/pediatric-proforma/Pediatric_Case_Proforma_Fever_Cold.docx', buffer);
  console.log('Done: Pediatric_Case_Proforma_Fever_Cold.docx');
});
Running Command

cd /home/daytona/workspace/pediatric-proforma && node generate.js 2>&1

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.