Document a lama, at request discharge summary with investigations table
ls /home/daytona/workspace/ 2>/dev/null && ls /home/daytona/skills/docx/scripts/…
mkdir -p /home/daytona/workspace/lama-discharge && node -e "require('docx'); con…
~/lama-discharge/generate.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
AlignmentType, HeadingLevel, BorderStyle, WidthType, ShadingType,
VerticalAlign, LevelFormat, PageNumber, Header, Footer
} = require('docx');
const fs = require('fs');
// ─── helpers ───────────────────────────────────────────────────────────────
function bold(text, size) {
return new TextRun({ text, bold: true, size: size || 22 });
}
function normal(text, size) {
return new TextRun({ text, size: size || 22 });
}
function spacer() {
return new Paragraph({ children: [new TextRun({ text: '' })] });
}
// Thin solid border used in all table cells
const thinBorder = {
top: { style: BorderStyle.SINGLE, size: 6, color: '2E4057' },
bottom: { style: BorderStyle.SINGLE, size: 6, color: '2E4057' },
left: { style: BorderStyle.SINGLE, size: 6, color: '2E4057' },
right: { style: BorderStyle.SINGLE, size: 6, color: '2E4057' },
};
// Dark header shading
const headerShade = { type: ShadingType.CLEAR, fill: '2E4057', color: 'FFFFFF' };
// Light row shading (alternating)
const lightShade = { type: ShadingType.CLEAR, fill: 'EAF0FB', color: '000000' };
const whiteShade = { type: ShadingType.CLEAR, fill: 'FFFFFF', color: '000000' };
function headerCell(text, widthPct) {
return new TableCell({
width: { size: widthPct, type: WidthType.PERCENTAGE },
shading: headerShade,
borders: thinBorder,
verticalAlign: VerticalAlign.CENTER,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text, bold: true, size: 20, color: 'FFFFFF' })]
})
]
});
}
function dataCell(text, shade, bold_flag) {
return new TableCell({
shading: shade,
borders: thinBorder,
verticalAlign: VerticalAlign.CENTER,
children: [
new Paragraph({
children: [new TextRun({ text, bold: bold_flag || false, size: 20 })]
})
]
});
}
// ─── Document ─────────────────────────────────────────────────────────────
const doc = new Document({
styles: {
default: {
document: { run: { font: 'Arial', size: 22, color: '000000' } }
},
paragraphStyles: [
{
id: 'Heading1', name: 'Heading 1', basedOn: 'Normal', next: 'Normal', quickFormat: true,
run: { size: 36, bold: true, font: 'Arial', color: '2E4057' },
paragraph: { spacing: { before: 200, after: 100 }, outlineLevel: 0 }
},
{
id: 'Heading2', name: 'Heading 2', basedOn: 'Normal', next: 'Normal', quickFormat: true,
run: { size: 26, bold: true, font: 'Arial', color: '2E4057' },
paragraph: {
spacing: { before: 180, after: 80 },
border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: '2E4057', space: 4 } },
outlineLevel: 1
}
}
]
},
sections: [{
properties: {
page: {
margin: { top: 720, bottom: 720, left: 900, right: 900 }
}
},
headers: {
default: new Header({
children: [
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: {
top: { style: BorderStyle.NONE },
bottom: { style: BorderStyle.SINGLE, size: 8, color: '2E4057' },
left: { style: BorderStyle.NONE },
right: { style: BorderStyle.NONE },
insideH:{ style: BorderStyle.NONE },
insideV:{ style: BorderStyle.NONE },
},
rows: [
new TableRow({
children: [
new TableCell({
width: { size: 70, type: WidthType.PERCENTAGE },
borders: { top:{style:BorderStyle.NONE}, bottom:{style:BorderStyle.NONE}, left:{style:BorderStyle.NONE}, right:{style:BorderStyle.NONE} },
children: [
new Paragraph({ children: [new TextRun({ text: 'City General Hospital', bold: true, size: 32, color: '2E4057', font: 'Arial' })] }),
new Paragraph({ children: [new TextRun({ text: '123 Hospital Road, Citytown | Tel: (011) 555-0100', size: 18, color: '555555' })] }),
]
}),
new TableCell({
width: { size: 30, type: WidthType.PERCENTAGE },
borders: { top:{style:BorderStyle.NONE}, bottom:{style:BorderStyle.NONE}, left:{style:BorderStyle.NONE}, right:{style:BorderStyle.NONE} },
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [new TextRun({ text: 'LAMA DISCHARGE SUMMARY', bold: true, size: 22, color: 'CC0000', font: 'Arial' })]
}),
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [new TextRun({ text: 'Left Against Medical Advice', size: 18, color: '888888' })]
}),
]
})
]
})
]
})
]
})
},
footers: {
default: new Footer({
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
border: { top: { style: BorderStyle.SINGLE, size: 4, color: '2E4057', space: 4 } },
children: [
new TextRun({ text: 'Page ', size: 18, color: '888888' }),
new TextRun({ children: [PageNumber.CURRENT], size: 18, color: '888888' }),
new TextRun({ text: ' of ', size: 18, color: '888888' }),
new TextRun({ children: [PageNumber.TOTAL_PAGES], size: 18, color: '888888' }),
new TextRun({ text: ' | City General Hospital - Confidential Medical Record', size: 18, color: '888888' }),
]
})
]
})
},
children: [
// ── TITLE BLOCK ──────────────────────────────────────────────────────
spacer(),
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: 'DISCHARGE SUMMARY', bold: true, size: 40, color: '2E4057' })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: 'Left Against Medical Advice (LAMA)', bold: true, size: 28, color: 'CC0000' })]
}),
spacer(),
// ── PATIENT DETAILS TABLE ────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '1. Patient Identification', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: [
headerCell('Field', 25),
headerCell('Details', 75),
]
}),
new TableRow({ children: [ dataCell('Patient Name', lightShade, true), dataCell('Mr. Ramesh Kumar', lightShade) ] }),
new TableRow({ children: [ dataCell('Age / Sex', whiteShade, true), dataCell('48 Years / Male', whiteShade) ] }),
new TableRow({ children: [ dataCell('Date of Birth', lightShade, true), dataCell('15 March 1978', lightShade) ] }),
new TableRow({ children: [ dataCell('MRN / Hospital ID', whiteShade, true), dataCell('CGH-2026-00427', whiteShade) ] }),
new TableRow({ children: [ dataCell('Ward / Bed No.', lightShade, true), dataCell('Medical Ward B / Bed 12', lightShade) ] }),
new TableRow({ children: [ dataCell('Admitting Consultant', whiteShade, true), dataCell('Dr. Priya Sharma, MD (General Medicine)', whiteShade) ] }),
new TableRow({ children: [ dataCell('Date of Admission', lightShade, true), dataCell('04 July 2026 (07:30 hrs)', lightShade) ] }),
new TableRow({ children: [ dataCell('Date of LAMA', whiteShade, true), dataCell('10 July 2026 (15:45 hrs)', whiteShade) ] }),
new TableRow({ children: [ dataCell('Total Duration of Stay', lightShade, true), dataCell('6 Days', lightShade) ] }),
new TableRow({ children: [ dataCell('Next of Kin / Guardian', whiteShade, true), dataCell('Mrs. Sunita Kumar (Wife) | Tel: +91-98765-43210', whiteShade) ] }),
]
}),
spacer(),
// ── DIAGNOSIS ────────────────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '2. Diagnosis', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: [
headerCell('Type', 30),
headerCell('Diagnosis', 70),
]
}),
new TableRow({ children: [ dataCell('Primary Diagnosis', lightShade, true), dataCell('Community-Acquired Pneumonia (CAP) - Left Lower Lobe [ICD-10: J18.9]', lightShade) ] }),
new TableRow({ children: [ dataCell('Secondary Diagnosis', whiteShade, true), dataCell('Type 2 Diabetes Mellitus - Uncontrolled [ICD-10: E11.9]', whiteShade) ] }),
new TableRow({ children: [ dataCell('Co-morbidity', lightShade, true), dataCell('Systemic Hypertension [ICD-10: I10]', lightShade) ] }),
new TableRow({ children: [ dataCell('Condition at LAMA', whiteShade, true), dataCell('Improving but NOT medically stable; ongoing IV antibiotics and oxygen support', whiteShade) ] }),
]
}),
spacer(),
// ── PRESENTING COMPLAINTS ────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '3. Presenting Complaints', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Complaint', 60), headerCell('Duration', 40) ] }),
new TableRow({ children: [ dataCell('High-grade fever with chills', lightShade), dataCell('5 days prior to admission', lightShade) ] }),
new TableRow({ children: [ dataCell('Productive cough with yellowish sputum', whiteShade), dataCell('4 days', whiteShade) ] }),
new TableRow({ children: [ dataCell('Breathlessness on exertion (Grade III)', lightShade), dataCell('3 days', lightShade) ] }),
new TableRow({ children: [ dataCell('Right-sided pleuritic chest pain', whiteShade), dataCell('2 days', whiteShade) ] }),
new TableRow({ children: [ dataCell('Generalised weakness and anorexia', lightShade), dataCell('1 week', lightShade) ] }),
]
}),
spacer(),
// ── TREATMENT GIVEN ─────────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '4. Treatment Administered During Admission', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Drug / Intervention', 40), headerCell('Dose / Route', 30), headerCell('Duration', 30) ] }),
new TableRow({ children: [ dataCell('Inj. Piperacillin-Tazobactam', lightShade), dataCell('4.5 g IV q8h', lightShade), dataCell('6 days', lightShade) ] }),
new TableRow({ children: [ dataCell('Inj. Azithromycin', whiteShade), dataCell('500 mg IV OD', whiteShade), dataCell('6 days', whiteShade) ] }),
new TableRow({ children: [ dataCell('Inj. Insulin (Actrapid)', lightShade), dataCell('Sliding scale SC', lightShade), dataCell('6 days', lightShade) ] }),
new TableRow({ children: [ dataCell('Tab. Amlodipine', whiteShade), dataCell('5 mg PO OD', whiteShade), dataCell('6 days', whiteShade) ] }),
new TableRow({ children: [ dataCell('Supplemental Oxygen', lightShade), dataCell('4 L/min via nasal prongs', lightShade), dataCell('6 days', lightShade) ] }),
new TableRow({ children: [ dataCell('IV Fluids - Normal Saline', whiteShade), dataCell('1 L over 8 hrs', whiteShade), dataCell('First 48 hrs', whiteShade) ] }),
new TableRow({ children: [ dataCell('Nebulisation (Salbutamol)', lightShade), dataCell('2.5 mg q6h', lightShade), dataCell('6 days', lightShade) ] }),
new TableRow({ children: [ dataCell('Tab. Paracetamol', whiteShade), dataCell('500 mg PO q6h PRN', whiteShade), dataCell('As needed', whiteShade) ] }),
]
}),
spacer(),
// ── INVESTIGATIONS TABLE ──────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '5. Investigation Results', bold: true, size: 26, color: '2E4057' })] }),
// 5a - Haematology
new Paragraph({ spacing: { before: 120, after: 60 }, children: [bold('5a. Haematology', 22)] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Parameter', 35), headerCell('Admission (04/07)', 20), headerCell('Day 3 (07/07)', 20), headerCell('LAMA (10/07)', 15), headerCell('Reference Range', 10) ] }),
new TableRow({ children: [ dataCell('Haemoglobin (g/dL)', lightShade, true), dataCell('11.2', lightShade), dataCell('11.5', lightShade), dataCell('11.8', lightShade), dataCell('13-17', lightShade) ] }),
new TableRow({ children: [ dataCell('WBC Count (x10³/µL)', whiteShade, true), dataCell('18.4 *', whiteShade), dataCell('14.2 *', whiteShade), dataCell('10.1', whiteShade), dataCell('4-11', whiteShade) ] }),
new TableRow({ children: [ dataCell('Neutrophils (%)', lightShade, true), dataCell('84 *', lightShade), dataCell('76 *', lightShade), dataCell('68', lightShade), dataCell('50-70', lightShade) ] }),
new TableRow({ children: [ dataCell('Platelet Count (x10³/µL)', whiteShade, true), dataCell('198', whiteShade), dataCell('220', whiteShade), dataCell('240', whiteShade), dataCell('150-400', whiteShade) ] }),
new TableRow({ children: [ dataCell('ESR (mm/hr)', lightShade, true), dataCell('68 *', lightShade), dataCell('55 *', lightShade), dataCell('42 *', lightShade), dataCell('<20', lightShade) ] }),
new TableRow({ children: [ dataCell('CRP (mg/L)', whiteShade, true), dataCell('124 *', whiteShade), dataCell('88 *', whiteShade), dataCell('52 *', whiteShade), dataCell('<5', whiteShade) ] }),
new TableRow({ children: [ dataCell('Procalcitonin (ng/mL)', lightShade, true), dataCell('2.8 *', lightShade), dataCell('1.4 *', lightShade), dataCell('0.6', lightShade), dataCell('<0.5', lightShade) ] }),
]
}),
new Paragraph({ spacing: { before: 60, after: 80 }, children: [new TextRun({ text: '* = Abnormal value', italics: true, size: 18, color: 'CC0000' })] }),
// 5b - Biochemistry
new Paragraph({ spacing: { before: 120, after: 60 }, children: [bold('5b. Biochemistry', 22)] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Parameter', 35), headerCell('Admission (04/07)', 20), headerCell('Day 3 (07/07)', 20), headerCell('LAMA (10/07)', 15), headerCell('Reference Range', 10) ] }),
new TableRow({ children: [ dataCell('Random Blood Glucose (mg/dL)', lightShade, true), dataCell('312 *', lightShade), dataCell('218 *', lightShade), dataCell('168 *', lightShade), dataCell('70-140', lightShade) ] }),
new TableRow({ children: [ dataCell('HbA1c (%)', whiteShade, true), dataCell('9.8 *', whiteShade), dataCell('--', whiteShade), dataCell('--', whiteShade), dataCell('<7.0', whiteShade) ] }),
new TableRow({ children: [ dataCell('Serum Creatinine (mg/dL)', lightShade, true), dataCell('1.3', lightShade), dataCell('1.1', lightShade), dataCell('1.0', lightShade), dataCell('0.7-1.3', lightShade) ] }),
new TableRow({ children: [ dataCell('Blood Urea Nitrogen (mg/dL)', whiteShade, true), dataCell('28 *', whiteShade), dataCell('22', whiteShade), dataCell('18', whiteShade), dataCell('8-20', whiteShade) ] }),
new TableRow({ children: [ dataCell('Serum Sodium (mEq/L)', lightShade, true), dataCell('132 *', lightShade), dataCell('136', lightShade), dataCell('138', lightShade), dataCell('135-145', lightShade) ] }),
new TableRow({ children: [ dataCell('Serum Potassium (mEq/L)', whiteShade, true), dataCell('3.9', whiteShade), dataCell('4.1', whiteShade), dataCell('4.2', whiteShade), dataCell('3.5-5.0', whiteShade) ] }),
new TableRow({ children: [ dataCell('ALT / SGPT (U/L)', lightShade, true), dataCell('44', lightShade), dataCell('38', lightShade), dataCell('32', lightShade), dataCell('7-56', lightShade) ] }),
new TableRow({ children: [ dataCell('Total Bilirubin (mg/dL)', whiteShade, true), dataCell('0.9', whiteShade), dataCell('0.8', whiteShade), dataCell('0.8', whiteShade), dataCell('0.2-1.2', whiteShade) ] }),
]
}),
new Paragraph({ spacing: { before: 60, after: 80 }, children: [new TextRun({ text: '* = Abnormal value', italics: true, size: 18, color: 'CC0000' })] }),
// 5c - Microbiology
new Paragraph({ spacing: { before: 120, after: 60 }, children: [bold('5c. Microbiology', 22)] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Test', 30), headerCell('Sample', 20), headerCell('Result', 50) ] }),
new TableRow({ children: [ dataCell('Sputum C&S', lightShade, true), dataCell('Sputum', lightShade), dataCell('Streptococcus pneumoniae - Sensitive to Piperacillin-Tazobactam, Azithromycin', lightShade) ] }),
new TableRow({ children: [ dataCell('Blood Culture x2', whiteShade, true), dataCell('Peripheral blood', whiteShade), dataCell('No growth at 5 days (FINAL)', whiteShade) ] }),
new TableRow({ children: [ dataCell('Urinary Antigen (S. pneumoniae)', lightShade, true), dataCell('Urine', lightShade), dataCell('POSITIVE', lightShade) ] }),
new TableRow({ children: [ dataCell('COVID-19 RT-PCR', whiteShade, true), dataCell('Nasopharyngeal swab', whiteShade), dataCell('Negative', whiteShade) ] }),
new TableRow({ children: [ dataCell('Sputum AFB (x3)', lightShade, true), dataCell('Sputum', lightShade), dataCell('Negative', lightShade) ] }),
]
}),
spacer(),
// 5d - Imaging & ECG
new Paragraph({ spacing: { before: 120, after: 60 }, children: [bold('5d. Imaging & Investigations', 22)] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Investigation', 30), headerCell('Date', 15), headerCell('Findings', 55) ] }),
new TableRow({ children: [ dataCell('Chest X-Ray (PA)', lightShade, true), dataCell('04/07/2026', lightShade), dataCell('Homogeneous opacity in left lower lobe consistent with lobar consolidation. No pleural effusion.', lightShade) ] }),
new TableRow({ children: [ dataCell('Chest X-Ray (PA)', whiteShade, true), dataCell('08/07/2026', whiteShade), dataCell('Partial resolution of consolidation; opacity reduced by approx 40%.', whiteShade) ] }),
new TableRow({ children: [ dataCell('Chest X-Ray (PA)', lightShade, true), dataCell('10/07/2026 (at LAMA)', lightShade), dataCell('Consolidation still present - NOT fully resolved. Ongoing active pneumonia.', lightShade) ] }),
new TableRow({ children: [ dataCell('ECG (12-lead)', whiteShade, true), dataCell('04/07/2026', whiteShade), dataCell('Sinus tachycardia (HR 108 bpm). No ST-T changes. Normal axis.', whiteShade) ] }),
new TableRow({ children: [ dataCell('2D Echocardiogram', lightShade, true), dataCell('06/07/2026', lightShade), dataCell('Normal LV function (EF 58%). No regional wall motion abnormality. No pericardial effusion.', lightShade) ] }),
new TableRow({ children: [ dataCell('SpO2 at LAMA', whiteShade, true), dataCell('10/07/2026', whiteShade), dataCell('91% on room air (required 4 L/min O2 to maintain SpO2 >95%)', whiteShade) ] }),
]
}),
spacer(),
// ── CLINICAL PROGRESS ────────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '6. Clinical Progress', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Date', 15), headerCell('Clinical Notes', 85) ] }),
new TableRow({ children: [ dataCell('04/07', lightShade, true), dataCell('Admitted via Emergency. Febrile (T 39.2°C), tachycardic, SpO2 87% on room air. CXR confirmed LLL consolidation. IV antibiotics and O2 started.', lightShade) ] }),
new TableRow({ children: [ dataCell('05/07', whiteShade, true), dataCell('Fever persisting. Blood cultures drawn. Sputum sent for C&S. RBS 312 mg/dL - insulin sliding scale commenced.', whiteShade) ] }),
new TableRow({ children: [ dataCell('06/07', lightShade, true), dataCell('Marginal improvement - fever partially settling. Echo normal. Pneumococcal urinary antigen positive. Antibiotics continued.', lightShade) ] }),
new TableRow({ children: [ dataCell('07/07', whiteShade, true), dataCell('Temperature trending down. Reduced oxygen requirement. CRP improving. Patient ambulant within ward.', whiteShade) ] }),
new TableRow({ children: [ dataCell('08/07', lightShade, true), dataCell('Repeat CXR shows partial resolution. Patient feels better subjectively. Still requires supplemental oxygen.', lightShade) ] }),
new TableRow({ children: [ dataCell('09/07', whiteShade, true), dataCell('Patient requested discharge. Explained risks - treatment not complete. Patient counselled by consultant and nursing staff. Agreed to stay.', whiteShade) ] }),
new TableRow({ children: [ dataCell('10/07', lightShade, true), dataCell('Patient insisted on LAMA citing personal/family reasons. Risks of premature discharge explained in detail. Informed consent obtained. LAMA form signed.', lightShade) ] }),
]
}),
spacer(),
// ── CONDITION AT LAMA ────────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '7. Condition at Time of LAMA', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Parameter', 40), headerCell('Status', 60) ] }),
new TableRow({ children: [ dataCell('Consciousness / Orientation', lightShade, true), dataCell('Alert and oriented x3 - Patient fully conscious and capable of decision-making', lightShade) ] }),
new TableRow({ children: [ dataCell('Fever', whiteShade, true), dataCell('Afebrile (T 37.4°C) for last 24 hours', whiteShade) ] }),
new TableRow({ children: [ dataCell('Oxygen Requirement', lightShade, true), dataCell('STILL REQUIRED - 4 L/min to maintain SpO2 >95%; 91% on room air', lightShade) ] }),
new TableRow({ children: [ dataCell('Chest X-Ray', whiteShade, true), dataCell('Consolidation NOT fully resolved - active disease present', whiteShade) ] }),
new TableRow({ children: [ dataCell('Antibiotics', lightShade, true), dataCell('IV antibiotics INCOMPLETE - minimum 10-day course recommended; only 6 days given', lightShade) ] }),
new TableRow({ children: [ dataCell('Blood Glucose Control', whiteShade, true), dataCell('Partially controlled (RBS 168 mg/dL); insulin regimen not yet optimised', whiteShade) ] }),
new TableRow({ children: [ dataCell('Overall Clinical Assessment', lightShade, true), dataCell('Improving but NOT fit for discharge by medical criteria', lightShade) ] }),
]
}),
spacer(),
// ── LAMA DOCUMENTATION ───────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '8. LAMA Documentation & Risks Communicated', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('LAMA Documentation', 40), headerCell('Details', 60) ] }),
new TableRow({ children: [ dataCell('Reason for LAMA (stated by patient)', lightShade, true), dataCell('Family emergency; personal financial concerns; anxiety about prolonged hospitalisation', lightShade) ] }),
new TableRow({ children: [ dataCell('Capacity Assessment', whiteShade, true), dataCell('Patient assessed - fully competent to make autonomous decision (GCS 15/15)', whiteShade) ] }),
new TableRow({ children: [ dataCell('Risks Explained', lightShade, true), dataCell('(1) Recurrence/worsening of pneumonia (2) Risk of sepsis and respiratory failure (3) Incomplete antibiotic course - risk of drug resistance (4) Hypoxia - SpO2 may drop at home without supplemental O2 (5) Uncontrolled diabetes may worsen infection (6) Risk of re-admission to ICU / death in worst-case scenario', lightShade) ] }),
new TableRow({ children: [ dataCell('Patient Understanding', whiteShade, true), dataCell('Patient verbally confirmed understanding of all risks in presence of family', whiteShade) ] }),
new TableRow({ children: [ dataCell('LAMA Consent Form', lightShade, true), dataCell('Signed and witnessed by patient, next of kin (wife), and duty nurse (S/N Pooja Rao)', lightShade) ] }),
new TableRow({ children: [ dataCell('Witnessed By', whiteShade, true), dataCell('Dr. Amit Verma (Resident) | S/N Pooja Rao | Mrs. Sunita Kumar (Wife)', whiteShade) ] }),
new TableRow({ children: [ dataCell('Time of LAMA', lightShade, true), dataCell('10 July 2026 at 15:45 hrs', lightShade) ] }),
]
}),
spacer(),
// ── DISCHARGE MEDICATIONS ────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '9. Discharge Medications (Given at LAMA)', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Drug', 30), headerCell('Dose', 15), headerCell('Route', 10), headerCell('Frequency', 15), headerCell('Duration', 15), headerCell('Remarks', 15) ] }),
new TableRow({ children: [ dataCell('Tab. Amoxicillin-Clavulanate', lightShade), dataCell('625 mg', lightShade), dataCell('Oral', lightShade), dataCell('TDS', lightShade), dataCell('7 days', lightShade), dataCell('Step-down from IV', lightShade) ] }),
new TableRow({ children: [ dataCell('Tab. Azithromycin', whiteShade), dataCell('500 mg', whiteShade), dataCell('Oral', whiteShade), dataCell('OD', whiteShade), dataCell('4 more days', whiteShade), dataCell('Complete 10-day course', whiteShade) ] }),
new TableRow({ children: [ dataCell('Tab. Metformin', lightShade), dataCell('500 mg', lightShade), dataCell('Oral', lightShade), dataCell('BD', lightShade), dataCell('Ongoing', lightShade), dataCell('Resume; glucose to be monitored', lightShade) ] }),
new TableRow({ children: [ dataCell('Tab. Amlodipine', whiteShade), dataCell('5 mg', whiteShade), dataCell('Oral', whiteShade), dataCell('OD', whiteShade), dataCell('Ongoing', whiteShade), dataCell('Antihypertensive', whiteShade) ] }),
new TableRow({ children: [ dataCell('Tab. Paracetamol', lightShade), dataCell('500 mg', lightShade), dataCell('Oral', lightShade), dataCell('QID PRN', lightShade), dataCell('5 days', lightShade), dataCell('For fever/pain', lightShade) ] }),
new TableRow({ children: [ dataCell('Syr. Salbutamol', whiteShade), dataCell('2 mg/5 mL', whiteShade), dataCell('Oral', whiteShade), dataCell('TDS', whiteShade), dataCell('5 days', whiteShade), dataCell('Bronchodilator', whiteShade) ] }),
]
}),
spacer(),
// ── FOLLOW-UP INSTRUCTIONS ───────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '10. Follow-Up & Advice', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: [ headerCell('Instruction', 40), headerCell('Details', 60) ] }),
new TableRow({ children: [ dataCell('Follow-up Appointment', lightShade, true), dataCell('Within 48 hours - General Medicine OPD (Dr. Priya Sharma) - MANDATORY', lightShade) ] }),
new TableRow({ children: [ dataCell('Repeat Investigations', whiteShade, true), dataCell('CBC, CRP, CXR - to be done on Day 3 of discharge at OPD', whiteShade) ] }),
new TableRow({ children: [ dataCell('Blood Glucose Monitoring', lightShade, true), dataCell('Self-monitor FBS and PPBS daily; record in log book; target FBS <130 mg/dL', lightShade) ] }),
new TableRow({ children: [ dataCell('Blood Pressure Monitoring', whiteShade, true), dataCell('Daily BP monitoring; target <130/80 mmHg', whiteShade) ] }),
new TableRow({ children: [ dataCell('Return to Hospital IMMEDIATELY if:', lightShade, true), dataCell('Worsening breathlessness, SpO2 <92% at home, high fever >38.5°C, chest pain, confusion, or any deterioration', lightShade) ] }),
new TableRow({ children: [ dataCell('Activity Restriction', whiteShade, true), dataCell('Complete bed rest at home; no strenuous activity; nutritious diet; adequate hydration', whiteShade) ] }),
new TableRow({ children: [ dataCell('Emergency Contact', lightShade, true), dataCell('Hospital Emergency: (011) 555-0199 | Consulting Doctor: (011) 555-0101', lightShade) ] }),
]
}),
spacer(),
// ── SIGNATURES ────────────────────────────────────────────────────────
new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun({ text: '11. Signatures', bold: true, size: 26, color: '2E4057' })] }),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: [
headerCell('Role', 33),
headerCell('Name', 34),
headerCell('Signature & Date', 33),
]
}),
new TableRow({ children: [ dataCell('Treating Consultant', lightShade, true), dataCell('Dr. Priya Sharma, MD', lightShade), dataCell('____________________ 10/07/2026', lightShade) ] }),
new TableRow({ children: [ dataCell('Resident Doctor (Witness)', whiteShade, true), dataCell('Dr. Amit Verma, MBBS', whiteShade), dataCell('____________________ 10/07/2026', whiteShade) ] }),
new TableRow({ children: [ dataCell('Duty Nurse (Witness)', lightShade, true), dataCell('S/N Pooja Rao', lightShade), dataCell('____________________ 10/07/2026', lightShade) ] }),
new TableRow({ children: [ dataCell('Patient', whiteShade, true), dataCell('Mr. Ramesh Kumar', whiteShade), dataCell('____________________ 10/07/2026', whiteShade) ] }),
new TableRow({ children: [ dataCell('Next of Kin / Guardian', lightShade, true), dataCell('Mrs. Sunita Kumar (Wife)', lightShade), dataCell('____________________ 10/07/2026', lightShade) ] }),
]
}),
spacer(),
new Paragraph({
alignment: AlignmentType.CENTER,
children: [
new TextRun({ text: 'IMPORTANT NOTICE: ', bold: true, size: 20, color: 'CC0000' }),
new TextRun({ text: 'This patient was discharged AGAINST MEDICAL ADVICE. The hospital and treating team are NOT responsible for any complications arising after self-discharge. This document serves as a legal record.', size: 20, color: '333333' })
]
}),
spacer(),
]
}]
});
Packer.toBuffer(doc).then(buf => {
fs.writeFileSync('/home/daytona/workspace/lama-discharge/LAMA_Discharge_Summary.docx', buf);
console.log('DONE');
}).catch(e => { console.error(e); process.exit(1); });
cd /home/daytona/workspace/lama-discharge && node generate.js 2>&1
python /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksp…
python3 -c "import zipfile, os; z=zipfile.ZipFile('/home/daytona/workspace/lama-…
ls -lh /home/daytona/workspace/lama-discharge/LAMA_Discharge_Summary.docx
LAMA Discharge Summary
Word Document · DOCX
| Section | Content |
|---|---|
| 1 | Patient Identification (name, MRN, ward, consultant, admission/LAMA dates) |
| 2 | Diagnosis with ICD-10 codes (primary, secondary, co-morbidity) |
| 3 | Presenting Complaints with duration |
| 4 | Treatment Administered (drugs, dose, route, duration) |
| 5 | Investigations table - 4 sub-tables: Haematology (CBC, CRP, Procalcitonin with serial values Day 0/3/LAMA), Biochemistry (glucose, HbA1c, renal/liver panel), Microbiology (sputum C&S, blood cultures, urinary antigen), Imaging & ECG (serial CXRs, Echo, SpO2) |
| 6 | Day-by-day clinical progress notes |
| 7 | Condition at time of LAMA (oxygen requirement, unresolved consolidation, incomplete antibiotics) |
| 8 | LAMA documentation - risks communicated, capacity assessment, witnesses |
| 9 | Discharge medications (oral step-down antibiotics, DM/HTN drugs) |
| 10 | Follow-up instructions and emergency return criteria |
| 11 | Signature block (consultant, resident, nurse, patient, next of kin) |
Document for cancer patients no pdf need in written form
mkdir -p /home/daytona/workspace/cancer-discharge && node -e "require('docx'); c…
~/cancer-discharge/generate.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
AlignmentType, HeadingLevel, BorderStyle, WidthType, ShadingType,
VerticalAlign, PageNumber, Header, Footer
} = require('docx');
const fs = require('fs');
// ─── helpers ───────────────────────────────────────────────────────────────
function spacer(n) {
const arr = [];
for (let i = 0; i < (n || 1); i++)
arr.push(new Paragraph({ children: [new TextRun('')] }));
return arr;
}
const NAVY = '1A3A5C';
const TEAL = '0B6E72';
const RED = 'B71C1C';
const WHITE = 'FFFFFF';
const LGRAY = 'EAF2FB';
const MGRAY = 'D6E8F5';
const NONE = { style: BorderStyle.NONE, size: 0, color: WHITE };
const thinBorder = {
top: { style: BorderStyle.SINGLE, size: 6, color: NAVY },
bottom: { style: BorderStyle.SINGLE, size: 6, color: NAVY },
left: { style: BorderStyle.SINGLE, size: 6, color: NAVY },
right: { style: BorderStyle.SINGLE, size: 6, color: NAVY },
};
function hdr(text, pct) {
return new TableCell({
width: { size: pct, type: WidthType.PERCENTAGE },
shading: { type: ShadingType.CLEAR, fill: NAVY, color: WHITE },
borders: thinBorder,
verticalAlign: VerticalAlign.CENTER,
children: [new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text, bold: true, size: 19, color: WHITE, font: 'Arial' })]
})]
});
}
function cell(text, fill, isBold, color) {
return new TableCell({
shading: { type: ShadingType.CLEAR, fill: fill || WHITE, color: '000000' },
borders: thinBorder,
verticalAlign: VerticalAlign.CENTER,
children: [new Paragraph({
children: [new TextRun({ text, bold: isBold || false, size: 19, color: color || '111111', font: 'Arial' })]
})]
});
}
function label(text, fill) { return cell(text, fill || MGRAY, true); }
function value(text, fill) { return cell(text, fill || WHITE, false); }
function altLabel(text, i) { return label(text, i % 2 === 0 ? MGRAY : LGRAY); }
function altValue(text, i) { return value(text, i % 2 === 0 ? WHITE : LGRAY); }
function sectionHeading(num, title) {
return new Paragraph({
spacing: { before: 240, after: 60 },
children: [
new TextRun({ text: `${num}. ${title}`, bold: true, size: 26, color: NAVY, font: 'Arial' }),
],
border: { bottom: { style: BorderStyle.SINGLE, size: 6, color: TEAL, space: 4 } }
});
}
function twoColTable(rows) {
// rows = [[label, value], ...]
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: rows.map(([l, v], i) => new TableRow({
children: [altLabel(l, i), altValue(v, i)]
}))
});
}
// ─── Multi-col table with header row ────────────────────────────────────────
function multiTable(headers, dataRows, pcts) {
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({ children: headers.map((h, i) => hdr(h, pcts[i])) }),
...dataRows.map((row, ri) =>
new TableRow({
children: row.map((txt, ci) =>
ci === 0
? new TableCell({
width: { size: pcts[ci], type: WidthType.PERCENTAGE },
shading: { type: ShadingType.CLEAR, fill: ri % 2 === 0 ? MGRAY : LGRAY, color: '000000' },
borders: thinBorder,
verticalAlign: VerticalAlign.CENTER,
children: [new Paragraph({ children: [new TextRun({ text: txt, bold: true, size: 19, font: 'Arial' })] })]
})
: new TableCell({
width: { size: pcts[ci], type: WidthType.PERCENTAGE },
shading: { type: ShadingType.CLEAR, fill: ri % 2 === 0 ? WHITE : LGRAY, color: '000000' },
borders: thinBorder,
verticalAlign: VerticalAlign.CENTER,
children: [new Paragraph({ children: [new TextRun({ text: txt, size: 19, font: 'Arial' })] })]
})
)
})
)
]
});
}
// ─── Sub-section label ───────────────────────────────────────────────────────
function subHead(text) {
return new Paragraph({
spacing: { before: 160, after: 40 },
children: [new TextRun({ text, bold: true, size: 22, color: TEAL, font: 'Arial', underline: {} })]
});
}
// ─── Warning box ────────────────────────────────────────────────────────────
function warningBox(text) {
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: [
new TableCell({
shading: { type: ShadingType.CLEAR, fill: 'FFF3CD', color: '000000' },
borders: {
top: { style: BorderStyle.SINGLE, size: 10, color: RED },
bottom: { style: BorderStyle.SINGLE, size: 10, color: RED },
left: { style: BorderStyle.SINGLE, size: 10, color: RED },
right: { style: BorderStyle.SINGLE, size: 10, color: RED },
},
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text, bold: true, size: 20, color: RED, font: 'Arial' })]
})
]
})
]
})
]
});
}
// ─── Document ─────────────────────────────────────────────────────────────
const doc = new Document({
styles: {
default: {
document: { run: { font: 'Arial', size: 20, color: '111111' } }
}
},
sections: [{
properties: {
page: { margin: { top: 900, bottom: 720, left: 900, right: 900 } }
},
headers: {
default: new Header({
children: [
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: {
top: NONE, left: NONE, right: NONE, insideH: NONE, insideV: NONE,
bottom: { style: BorderStyle.DOUBLE, size: 8, color: NAVY },
},
rows: [new TableRow({
children: [
new TableCell({
width: { size: 65, type: WidthType.PERCENTAGE },
borders: { top: NONE, bottom: NONE, left: NONE, right: NONE },
children: [
new Paragraph({ children: [new TextRun({ text: 'CITY CANCER CENTRE', bold: true, size: 34, color: NAVY, font: 'Arial' })] }),
new Paragraph({ children: [new TextRun({ text: 'Department of Oncology | 123 Hope Avenue, Citytown', size: 18, color: '555555' })] }),
new Paragraph({ children: [new TextRun({ text: 'Tel: (011) 555-0200 | oncology@citycancercentre.org', size: 18, color: '555555' })] }),
]
}),
new TableCell({
width: { size: 35, type: WidthType.PERCENTAGE },
borders: { top: NONE, bottom: NONE, left: NONE, right: NONE },
children: [
new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun({ text: 'ONCOLOGY DISCHARGE SUMMARY', bold: true, size: 22, color: TEAL, font: 'Arial' })] }),
new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun({ text: 'Confidential Medical Record', size: 17, color: '888888' })] }),
]
})
]
})]
})
]
})
},
footers: {
default: new Footer({
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
border: { top: { style: BorderStyle.SINGLE, size: 4, color: NAVY, space: 4 } },
children: [
new TextRun({ text: 'Page ', size: 17, color: '888888' }),
new TextRun({ children: [PageNumber.CURRENT], size: 17, color: '888888' }),
new TextRun({ text: ' of ', size: 17, color: '888888' }),
new TextRun({ children: [PageNumber.TOTAL_PAGES], size: 17, color: '888888' }),
new TextRun({ text: ' | City Cancer Centre - Oncology Department - CONFIDENTIAL', size: 17, color: '888888' }),
]
})
]
})
},
children: [
// ── TITLE ────────────────────────────────────────────────────────────
...spacer(),
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: 'ONCOLOGY DISCHARGE SUMMARY', bold: true, size: 44, color: NAVY, font: 'Arial' })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { after: 60 },
children: [new TextRun({ text: 'Department of Oncology & Haematology', size: 24, color: TEAL, font: 'Arial' })]
}),
...spacer(),
// ── SECTION 1: PATIENT DETAILS ───────────────────────────────────────
sectionHeading('1', 'Patient Identification'),
twoColTable([
['Patient Name', 'Ms. Ananya Mehta'],
['Age / Sex', '52 Years / Female'],
['Date of Birth', '18 September 1973'],
['MRN / Hospital ID', 'CCC-2026-00312'],
['Ward / Bed', 'Oncology Ward C / Bed 7'],
['Treating Oncologist', 'Dr. Suresh Nair, MD, DM (Medical Oncology)'],
['Admitting Unit', 'Department of Medical Oncology'],
['Date of Admission', '01 July 2026 (09:00 hrs)'],
['Date of Discharge', '10 July 2026 (11:30 hrs)'],
['Length of Stay', '9 Days'],
['Next of Kin', 'Mr. Rakesh Mehta (Husband) | Tel: +91-98001-23456'],
['Emergency Contact', '(011) 555-0211 (Oncology ward direct line)'],
]),
...spacer(),
// ── SECTION 2: ONCOLOGICAL DIAGNOSIS ─────────────────────────────────
sectionHeading('2', 'Oncological Diagnosis & Staging'),
twoColTable([
['Primary Diagnosis', 'Carcinoma of the Left Breast [ICD-10: C50.912]'],
['Histological Type', 'Invasive Ductal Carcinoma (IDC), Grade III (Poorly Differentiated)'],
['Stage (AJCC 8th Ed.)', 'Stage IIIA (T3 N2 M0)'],
['Receptor Status', 'ER+++ / PR++ / HER2- (Hormone Receptor Positive; HER2-Negative)'],
['Ki-67 Proliferation Index', '42% (High)'],
['Molecular Subtype', 'Luminal B (HER2-negative)'],
['Date of Initial Diagnosis', '12 March 2026 (Core Needle Biopsy - Confirmed)'],
['Treatment Intent', 'Curative (Neoadjuvant Chemotherapy followed by Surgery)'],
['Current Admission Purpose', 'Cycle 3 of Neoadjuvant Chemotherapy (AC Regimen) + Management of Febrile Neutropenia'],
]),
...spacer(),
// ── SECTION 3: PRESENTING COMPLAINTS ─────────────────────────────────
sectionHeading('3', 'Presenting Complaints at Admission'),
multiTable(
['Complaint', 'Severity / Duration', 'CTCAE Grade'],
[
['Febrile Neutropenia (Fever >38.3°C)', 'Acute onset, 12 hrs prior to admission', 'Grade 3'],
['Fatigue and generalized weakness', 'Worsening over 3 days', 'Grade 2'],
['Nausea and vomiting (post-chemo)', '2 days post Cycle 3', 'Grade 2'],
['Mucositis - oral ulcers', 'Day 7 post-chemo', 'Grade 2'],
['Reduced oral intake / anorexia', '4 days', 'Grade 2'],
['Constipation', '3 days', 'Grade 1'],
],
[40, 35, 25]
),
new Paragraph({ spacing: { before: 60, after: 60 }, children: [new TextRun({ text: 'CTCAE = Common Terminology Criteria for Adverse Events (NCI v5.0)', italics: true, size: 17, color: '666666' })] }),
...spacer(),
// ── SECTION 4: CHEMOTHERAPY HISTORY ──────────────────────────────────
sectionHeading('4', 'Chemotherapy & Treatment History'),
subHead('4a. Current Chemotherapy Protocol'),
multiTable(
['Regimen', 'Drug', 'Dose', 'Route', 'Schedule'],
[
['AC Regimen (Neoadjuvant)', 'Doxorubicin (Adriamycin)', '60 mg/m² (BSA 1.63 m² = 97.8 mg)', 'IV infusion', 'Day 1, q21 days'],
['AC Regimen (Neoadjuvant)', 'Cyclophosphamide', '600 mg/m² (= 978 mg)', 'IV infusion', 'Day 1, q21 days'],
['Supportive', 'Ondansetron', '8 mg', 'IV', 'Before chemo + q8h x 3 days'],
['Supportive', 'Dexamethasone', '8 mg', 'IV', 'Before chemo'],
['Supportive', 'G-CSF (Filgrastim)', '300 mcg SC', 'SC', 'Day 3-10 post-chemo'],
],
[25, 25, 22, 13, 15]
),
...spacer(1),
subHead('4b. Cycle Summary'),
multiTable(
['Cycle', 'Date Given', 'Doxorubicin Dose', 'Cyclophosphamide Dose', 'Dose Modification', 'Toxicity Noted'],
[
['Cycle 1', '15 Apr 2026', '97.8 mg', '978 mg', 'None (100%)', 'Grade 1 nausea'],
['Cycle 2', '06 May 2026', '97.8 mg', '978 mg', 'None (100%)', 'Grade 2 fatigue, alopecia'],
['Cycle 3', '17 Jun 2026', '97.8 mg', '978 mg', 'None (100%)', 'Febrile neutropenia (current admission)'],
['Cycle 4', 'Planned: 08 Jul 2026', 'TBD', 'TBD', 'To be reviewed post-recovery', 'Pending'],
],
[10, 18, 18, 18, 18, 18]
),
...spacer(),
// ── SECTION 5: TREATMENT DURING ADMISSION ────────────────────────────
sectionHeading('5', 'Treatment Administered During This Admission'),
multiTable(
['Drug / Intervention', 'Dose / Route', 'Frequency', 'Duration / Notes'],
[
['Inj. Piperacillin-Tazobactam', '4.5 g IV', 'q8h', '7 days - empiric coverage for febrile neutropenia'],
['Inj. Vancomycin', '1 g IV', 'q12h', '5 days - added Day 2 for suspected line infection'],
['Inj. Filgrastim (G-CSF)', '300 mcg SC', 'OD', '7 days - to boost ANC recovery'],
['IV Fluids - Normal Saline', '1 L over 8 hrs', 'Continuous', 'Days 1-3 for hydration'],
['Inj. Ondansetron', '8 mg IV', 'q8h', '4 days - antiemetic'],
['Inj. Pantoprazole', '40 mg IV', 'OD', '9 days - gastroprotection'],
['Oral Mucositis Care - Gelcair rinse', 'Topical', 'TDS', '7 days - mucositis management'],
['Nutritional Supplement (Ensure)', '200 mL oral', 'BD', '7 days - supplemental nutrition'],
['Inj. Paracetamol', '1 g IV', 'q6h PRN', 'For fever'],
['Inj. Morphine (PRN)', '2-4 mg IV', 'q4h PRN', 'Mucositis pain - administered 3x in stay'],
['Compression stockings + LMWH prophylaxis', 'Enoxaparin 40 mg SC', 'OD', '9 days - DVT prophylaxis'],
],
[30, 20, 15, 35]
),
...spacer(),
// ── SECTION 6: INVESTIGATION RESULTS ─────────────────────────────────
sectionHeading('6', 'Investigation Results'),
// 6a Haematology
subHead('6a. Haematology - Complete Blood Count (Serial)'),
multiTable(
['Parameter', 'Admission\n01/07', 'Day 3\n03/07', 'Day 5\n05/07', 'Day 7\n07/07', 'Discharge\n10/07', 'Reference\nRange'],
[
['Haemoglobin (g/dL)', '9.2 *', '8.9 *', '9.0 *', '9.3 *', '9.6 *', '12-16'],
['WBC Count (x10³/µL)', '0.8 *', '0.4 *', '0.6 *', '1.8 *', '4.2', '4-11'],
['ANC (x10³/µL)', '0.2 *', '0.1 *', '0.3 *', '1.4 *', '2.8', '>1.5'],
['Platelet Count (x10³/µL)', '82 *', '68 *', '74 *', '96 *', '138 *', '150-400'],
['MCV (fL)', '88', '87', '88', '89', '90', '80-100'],
['Reticulocyte Count (%)', '1.8', '1.6', '1.9', '2.1', '2.4', '0.5-2.5'],
],
[28, 12, 12, 12, 12, 12, 12]
),
new Paragraph({ spacing: { before: 40, after: 80 }, children: [new TextRun({ text: '* = Abnormal (below/above reference range) ANC = Absolute Neutrophil Count', italics: true, size: 17, color: RED })] }),
// 6b Biochemistry
subHead('6b. Biochemistry & Metabolic Panel'),
multiTable(
['Parameter', 'Admission\n01/07', 'Day 5\n05/07', 'Discharge\n10/07', 'Reference Range'],
[
['Serum Creatinine (mg/dL)', '0.9', '0.8', '0.8', '0.5-1.1'],
['eGFR (mL/min/1.73m²)', '72', '76', '78', '>60'],
['ALT / SGPT (U/L)', '62 *', '55 *', '44', '7-56'],
['AST / SGOT (U/L)', '58 *', '48 *', '38', '10-40'],
['Total Bilirubin (mg/dL)', '1.0', '0.9', '0.8', '0.2-1.2'],
['Albumin (g/dL)', '3.0 *', '3.1 *', '3.3 *', '3.5-5.0'],
['Sodium (mEq/L)', '134 *', '136', '138', '135-145'],
['Potassium (mEq/L)', '3.4 *', '3.7', '4.0', '3.5-5.0'],
['LDH (U/L)', '320 *', '280 *', '248 *', '120-246'],
['CRP (mg/L)', '148 *', '88 *', '24 *', '<5'],
['Procalcitonin (ng/mL)', '3.2 *', '1.1 *', '0.3', '<0.5'],
['Ferritin (ng/mL)', '882 *', '724 *', '510 *', '13-150'],
],
[30, 18, 18, 18, 16]
),
new Paragraph({ spacing: { before: 40, after: 80 }, children: [new TextRun({ text: '* = Abnormal value', italics: true, size: 17, color: RED })] }),
// 6c Tumour Markers
subHead('6c. Tumour Markers'),
multiTable(
['Marker', 'Pre-Chemo\n(March 2026)', 'Post Cycle 2\n(May 2026)', 'Post Cycle 3\n(July 2026)', 'Reference Range', 'Trend'],
[
['CA 15-3 (U/mL)', '124 *', '88 *', '56 *', '<31', 'Decreasing - Treatment Response'],
['CEA (ng/mL)', '8.4 *', '6.2 *', '4.8 *', '<5.0', 'Decreasing - Treatment Response'],
['CA 125 (U/mL)', '18', '15', '12', '<35', 'Normal range'],
],
[20, 15, 15, 15, 15, 20]
),
new Paragraph({ spacing: { before: 40, after: 80 }, children: [new TextRun({ text: '* = Elevated above upper limit of normal Decreasing trend indicates positive treatment response', italics: true, size: 17, color: '0B6E72' })] }),
// 6d Microbiology
subHead('6d. Microbiology (Febrile Neutropenia Work-up)'),
multiTable(
['Test', 'Sample', 'Date', 'Result'],
[
['Blood Culture x2 (Peripheral)', 'Peripheral blood', '01/07', 'No growth at 5 days'],
['Blood Culture - PICC Line', 'PICC line', '01/07', 'Coagulase-Negative Staphylococci (CoNS) - Sensitive to Vancomycin'],
['Urine Culture', 'MSU', '01/07', 'No significant growth'],
['CXR - any pneumonia', '--', '01/07 + 05/07', 'No consolidation (see imaging)'],
['COVID-19 RT-PCR', 'Nasopharyngeal swab', '01/07', 'Negative'],
['Galactomannan (Aspergillus)', 'Serum', '02/07', 'Negative (index 0.18)'],
],
[25, 20, 12, 43]
),
...spacer(1),
// 6e Imaging
subHead('6e. Imaging & Cardiac Investigations'),
multiTable(
['Investigation', 'Date', 'Findings / Result'],
[
['Bilateral Mammogram', 'March 2026 (Diagnostic)', 'Left breast mass 4.2 x 3.8 cm; spiculated margins; microcalcifications. BIRADS 5.'],
['Breast MRI (staging)', 'April 2026', 'Left breast IDC 4.5 cm; 3 ipsilateral axillary LN involvement; no distant metastasis.'],
['CT Chest-Abdomen-Pelvis (staging)', 'April 2026', 'T3N2M0 confirmed. No hepatic/pulmonary/osseous metastasis. Multiple enlarged left axillary LNs.'],
['Bone Scan (isotope)', 'April 2026', 'No evidence of bone metastasis.'],
['MUGA Scan (baseline LVEF)', 'April 2026', 'LVEF 62% (baseline - Doxorubicin pre-requisite)'],
['MUGA Scan (post Cycle 2)', 'May 2026', 'LVEF 59% (acceptable; monitoring continues)'],
['Chest X-Ray (admission)', '01/07/2026', 'No consolidation, effusion, or cardiomegaly. Mild bilateral pleural thickening.'],
['Chest X-Ray (Day 5)', '05/07/2026', 'No new infiltrates. PICC line tip at SVC-RA junction - satisfactory position.'],
['ECG (12-lead)', '01/07/2026', 'Sinus tachycardia (HR 102 bpm), QTc 430 ms (within limits for continued therapy).'],
],
[28, 15, 57]
),
// 6f Pathology
...spacer(1),
subHead('6f. Histopathology / Pathology Reports'),
multiTable(
['Specimen', 'Date', 'Pathology Report Summary'],
[
['Core Needle Biopsy - Left Breast', 'March 2026', 'Invasive Ductal Carcinoma, Grade III. ER 90% +++ (Allred 7), PR 60% ++ (Allred 6), HER2 Score 1+ (FISH not amplified), Ki-67 42%.'],
['Lymph Node FNA - Left Axilla', 'March 2026', 'Metastatic carcinoma in 3/4 aspirated nodes. Consistent with breast primary.'],
],
[28, 14, 58]
),
...spacer(),
// ── SECTION 7: CLINICAL PROGRESS ─────────────────────────────────────
sectionHeading('7', 'Clinical Progress During Admission'),
multiTable(
['Date', 'Clinical Notes'],
[
['01/07', 'Admitted with febrile neutropenia (Temp 38.8°C, ANC 0.2). Blood cultures drawn. PICC line culture obtained. IV broad-spectrum antibiotics started (Pip-Taz). G-CSF commenced. Fluid resuscitation given.'],
['02/07', 'Persistent fever. Temp 38.5°C. Added Vancomycin empirically. Mucositis Grade 2 - morphine PRN commenced. Nutritional support initiated. CoNS in PICC line culture - Vancomycin appropriate.'],
['03/07', 'ANC nadir 0.1. Patient haemodynamically stable. Continuing IV antibiotics. Mouth care and gel rinse continuing. Fever persisting, Temp 38.1°C.'],
['04/07', 'First afebrile day (Temp 37.2°C). Patient marginally improved. Tolerating soft diet. Antiemetics tapered.'],
['05/07', 'ANC 0.3 - beginning recovery. Electrolyte correction done. Repeat CXR clear. Mucositis improving.'],
['06/07', 'Afebrile x48 hrs. Tolerating full oral diet. Mucositis resolving. IV antibiotics rationalised - Vancomycin stopped.'],
['07/07', 'ANC 1.4 - significant recovery. Pip-Taz continued 1 more day. G-CSF stopped as ANC >1.5 approaching.'],
['08/07', 'ANC 2.1. Patient ambulant. All IV antibiotics stopped. Transitioned to oral medications.'],
['09/07', 'ANC 2.8. Haemodynamically stable. Tolerating oral diet well. Discharge planning initiated. Oncology team discussion regarding Cycle 4 timing.'],
['10/07', 'Clinically fit for discharge. Full oncology team review done. Patient and family counselled for Cycle 4. Discharge medications prescribed. Follow-up arranged.'],
],
[10, 90]
),
...spacer(),
// ── SECTION 8: PERFORMANCE STATUS ────────────────────────────────────
sectionHeading('8', 'Performance Status & Functional Assessment'),
twoColTable([
['ECOG Performance Status (at admission)', 'ECOG 3 (Limited self-care; confined to bed >50% of waking hours)'],
['ECOG Performance Status (at discharge)', 'ECOG 1 (Restricted in strenuous activity; ambulant, able to self-care)'],
['Karnofsky Score (at admission)', '40%'],
['Karnofsky Score (at discharge)', '80%'],
['Pain Score (NRS at discharge)', '1/10 (minimal; no regular analgesia required)'],
['Nutritional Status (at discharge)', 'Improving; tolerating full oral diet; Ensure supplements continued'],
['Weight (at admission)', '58 kg'],
['Weight (at discharge)', '57.2 kg (loss of 0.8 kg during stay)'],
['BSA (Body Surface Area)', '1.63 m² (used for chemotherapy dosing)'],
]),
...spacer(),
// ── SECTION 9: DISCHARGE MEDICATIONS ─────────────────────────────────
sectionHeading('9', 'Discharge Medications'),
multiTable(
['Drug', 'Dose', 'Route', 'Frequency', 'Duration', 'Purpose'],
[
['Tab. Ciprofloxacin', '500 mg', 'Oral', 'BD', '5 days', 'Oral antibiotic step-down'],
['Tab. Fluconazole', '150 mg', 'Oral', 'Once weekly', '4 weeks', 'Antifungal prophylaxis'],
['Tab. Ondansetron', '8 mg', 'Oral', 'TDS PRN', '5 days', 'Antiemetic'],
['Tab. Pantoprazole', '40 mg', 'Oral', 'OD', 'Ongoing', 'Gastroprotection'],
['Syr. Nutritional Supplement (Ensure)', '200 mL', 'Oral', 'BD', '4 weeks', 'Nutritional support'],
['Tab. Ferrous Sulphate + Folic Acid', '200 mg', 'Oral', 'BD', 'Ongoing', 'Anaemia management'],
['Gelcair Oral Rinse', 'Topical', 'Oral', 'TDS', '7 days', 'Mucositis care'],
['Cap. Megestrol Acetate', '160 mg', 'Oral', 'OD', '4 weeks', 'Appetite stimulant'],
],
[25, 10, 8, 12, 12, 33]
),
...spacer(),
// ── SECTION 10: ONCOLOGY FOLLOW-UP PLAN ──────────────────────────────
sectionHeading('10', 'Oncology Follow-Up & Treatment Plan'),
multiTable(
['Plan Item', 'Details', 'Timeline'],
[
['Cycle 4 Assessment Visit', 'Full blood count, renal/liver profile, clinical review with Dr. Nair', '14 July 2026 (Day 4 post-discharge)'],
['Cycle 4 Chemotherapy (if ANC >1.5)', 'AC Regimen - Doxorubicin + Cyclophosphamide (pending CBC clearance)', 'Planned: 17 July 2026'],
['Post-Cycle G-CSF prophylaxis', 'Filgrastim 300 mcg SC daily x 7 days from Day 3', 'From Day 3 of each cycle'],
['Repeat Cardiac MUGA Scan', 'Cumulative doxorubicin dose monitoring - LVEF surveillance', 'Before Cycle 5 (August 2026)'],
['Breast MRI (treatment response)', 'Assess tumour response to neoadjuvant chemotherapy', 'After Cycle 6 completion'],
['Surgical Oncology Consultation', 'Modified Radical Mastectomy vs Breast Conservation Surgery - planning', 'Post-neoadjuvant chemo completion'],
['Nutritionist / Dietitian Review', 'Ongoing nutritional optimisation; weight management during chemo', 'Weekly during chemo cycles'],
['Palliative Care / Psycho-oncology', 'Psychological support, coping strategies, social worker referral', 'Referred; Appointment 16 July 2026'],
['Bone Health - DEXA Scan', 'Baseline bone density (pre-hormonal therapy)', 'After surgical treatment'],
],
[28, 47, 25]
),
...spacer(),
// ── SECTION 11: PATIENT EDUCATION ────────────────────────────────────
sectionHeading('11', 'Patient & Family Education / Counselling'),
multiTable(
['Topic', 'Information Provided'],
[
['Diagnosis & Prognosis', 'Stage IIIA breast cancer explained with expected outcomes; curative intent therapy discussed. Patient verbally confirms understanding.'],
['Chemotherapy Side Effects', 'Alopecia (complete), nausea/vomiting, fatigue, neutropenia, mucositis, neuropathy, cardiotoxicity risk - all explained.'],
['Neutropenic Precautions', 'Avoid crowded places, wash hands frequently, avoid raw food, report any fever >38°C IMMEDIATELY.'],
['Febrile Neutropenia Warning', 'EMERGENCY: Temperature >38.3°C or chills = go to Oncology Emergency directly. Do NOT wait. Call ahead.'],
['Fertility Counselling', 'Patient is post-menopausal. Fertility preservation not applicable. Ovarian function and hormone impact discussed.'],
['Hair Loss (Alopecia)', 'Expected with AC regimen; reversible after treatment. Wig/head covering information given. Support group details provided.'],
['Nutrition & Hydration', 'High-protein diet, adequate hydration (min 2L/day); avoid grapefruit; avoid herbal supplements without doctor approval.'],
['Psychological Support', 'Referral to psycho-oncology counsellor. Cancer support group details given. Palliative care team introduced.'],
['Financial / Social Support', 'Patient made aware of hospital social worker for insurance, financial aid, and transport assistance.'],
['PICC Line Care', 'Dressing change every 7 days at local clinic; keep dry; watch for redness or swelling; do not lift heavy weights with that arm.'],
],
[30, 70]
),
...spacer(),
// ── SECTION 12: RETURN CRITERIA ──────────────────────────────────────
sectionHeading('12', 'Return to Hospital - Emergency Criteria'),
warningBox('SEEK EMERGENCY CARE IMMEDIATELY IF ANY OF THE FOLLOWING OCCUR'),
...spacer(1),
multiTable(
['Emergency Sign / Symptom', 'Action'],
[
['Fever > 38.3°C or rigors/chills at any time', 'Go directly to Oncology Emergency - DO NOT WAIT'],
['Sudden shortness of breath or chest pain', 'Call emergency services (102) immediately'],
['Unusual bleeding - gums, nose, in urine or stool', 'Go to Oncology Emergency'],
['Severe vomiting (unable to keep any fluids down)', 'Present to Oncology OPD / Emergency'],
['Signs of infection at PICC line site (redness, swelling, pus)', 'Oncology Emergency - same day'],
['Confusion, severe headache, vision changes', 'Emergency services (102) immediately'],
['Severe pain not controlled by prescribed medications', 'Oncology ward direct line: (011) 555-0211'],
['New lumps, swelling, or rapidly changing symptoms', 'Call oncology team and arrange urgent review'],
],
[50, 50]
),
...spacer(),
// ── SECTION 13: SIGNATURES ────────────────────────────────────────────
sectionHeading('13', 'Authorisation & Signatures'),
multiTable(
['Role', 'Name', 'Designation', 'Signature & Date'],
[
['Treating Oncologist', 'Dr. Suresh Nair', 'MD, DM (Medical Oncology)', '____________________ 10/07/2026'],
['Senior Resident', 'Dr. Kavita Rao', 'MD (Medicine), Oncology Fellow', '____________________ 10/07/2026'],
['Oncology Nurse (Discharge)', 'Sr. Anita Thomas', 'RN, BSN, Oncology Certified', '____________________ 10/07/2026'],
['Patient', 'Ms. Ananya Mehta', 'Patient', '____________________ 10/07/2026'],
['Accompanying Person', 'Mr. Rakesh Mehta (Husband)', 'Next of Kin', '____________________ 10/07/2026'],
],
[20, 25, 30, 25]
),
...spacer(),
// ── CLOSING NOTE ──────────────────────────────────────────────────────
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 120 },
children: [
new TextRun({ text: 'This document is a confidential medical record. Unauthorised disclosure is prohibited. ', size: 18, color: '555555', italics: true }),
]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
children: [
new TextRun({ text: 'City Cancer Centre | Department of Oncology | (011) 555-0200 | oncology@citycancercentre.org', size: 18, color: NAVY, bold: true }),
]
}),
]
}]
});
Packer.toBuffer(doc).then(buf => {
fs.writeFileSync('/home/daytona/workspace/cancer-discharge/Oncology_Discharge_Summary.docx', buf);
console.log('DONE');
}).catch(e => { console.error(e); process.exit(1); });
cd /home/daytona/workspace/cancer-discharge && node generate.js 2>&1
python3 -c " import zipfile z = zipfile.ZipFile('/home/daytona/workspace/cancer-…
Oncology Discharge Summary
Word Document · DOCX
| # | Section | Highlights |
|---|---|---|
| 1 | Patient Identification | MRN, ward, treating oncologist, admission/discharge dates |
| 2 | Oncological Diagnosis & Staging | AJCC staging, histological grade, receptor status (ER/PR/HER2), Ki-67, molecular subtype |
| 3 | Presenting Complaints | Symptom table with CTCAE (NCI) grading |
| 4 | Chemotherapy History | Protocol table (drug, dose, BSA-adjusted dose, route, schedule) + full cycle-by-cycle summary with dose modifications |
| 5 | Treatment During Admission | All drugs with dose, route, frequency and purpose |
| 6 | Investigations | 6 sub-tables: Serial CBC (5 time-points), Biochemistry, Tumour Markers (CA 15-3, CEA with pre/post-chemo trends), Microbiology, Imaging (mammogram, MRI, CT, bone scan, MUGA), Histopathology |
| 7 | Clinical Progress | Day-by-day notes from admission to discharge |
| 8 | Performance Status | ECOG and Karnofsky scores at admission vs discharge |
| 9 | Discharge Medications | 8-drug table with dose, route, frequency, duration and purpose |
| 10 | Oncology Follow-Up Plan | Cycle 4 dates, MUGA surveillance, surgical referral, dietitian, psycho-oncology |
| 11 | Patient Education | 10 topics: side effects, neutropenic precautions, PICC line care, fertility, nutrition, psychological support |
| 12 | Emergency Return Criteria | Yellow warning box + 8-row table of red-flag symptoms with actions |
| 13 | Signatures | Oncologist, resident, nurse, patient, next of kin |