Write a full medical case record of this patient in the medical record template format

Reading File
Running Command

cd /home/daytona/workspace/attachments/3e0d920c-cbca-4939-a6d7-89738fe7a547 && p…

Running Command

cd /home/daytona/workspace/attachments/3e0d920c-cbca-4939-a6d7-89738fe7a547 && p…

Running Command

python3 -c " import pytesseract from PIL import Image import glob, os pages = s…

Running Command

cd /home/daytona/workspace/attachments/3e0d920c-cbca-4939-a6d7-89738fe7a547 && p…

Running Command

cd /home/daytona/workspace/attachments/3e0d920c-cbca-4939-a6d7-89738fe7a547 && p…

Running Command

cd /home/daytona/workspace/attachments/3e0d920c-cbca-4939-a6d7-89738fe7a547 && p…

Reading File
Running Command

ls /home/daytona/workspace/ && mkdir -p /home/daytona/workspace/medical-case-rec…

Writing File

~/medical-case-record/generate_case_record.js

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

// ─── Helpers ────────────────────────────────────────────────────────────────

const BORDER = {
  style: BorderStyle.SINGLE,
  size: 6,
  color: '2C3E50',
};

const THIN_BORDER = {
  style: BorderStyle.SINGLE,
  size: 4,
  color: '7F8C8D',
};

const NO_BORDER = { style: BorderStyle.NONE, size: 0, color: 'FFFFFF' };

function sectionHeading(text) {
  return new Paragraph({
    children: [
      new TextRun({
        text: text,
        bold: true,
        size: 24,
        color: 'FFFFFF',
        font: 'Calibri',
      }),
    ],
    shading: { type: ShadingType.SOLID, color: '1B4F72', fill: '1B4F72' },
    spacing: { before: 280, after: 120 },
    indent: { left: 120, right: 120 },
  });
}

function subHeading(text) {
  return new Paragraph({
    children: [
      new TextRun({
        text: text,
        bold: true,
        size: 22,
        color: '1B4F72',
        font: 'Calibri',
      }),
    ],
    shading: { type: ShadingType.SOLID, color: 'D6EAF8', fill: 'D6EAF8' },
    spacing: { before: 200, after: 80 },
    indent: { left: 80 },
  });
}

function bodyText(text, options = {}) {
  return new Paragraph({
    children: [
      new TextRun({
        text: text,
        size: 20,
        font: 'Calibri',
        bold: options.bold || false,
        italics: options.italic || false,
        color: options.color || '2C3E50',
      }),
    ],
    spacing: { before: 40, after: 60, line: 276, lineRule: LineRuleType.AUTO },
    indent: { left: options.indent || 0 },
    bullet: options.bullet ? { level: 0 } : undefined,
  });
}

function labelValue(label, value) {
  return new Paragraph({
    children: [
      new TextRun({ text: label + ': ', bold: true, size: 20, font: 'Calibri', color: '1B4F72' }),
      new TextRun({ text: value, size: 20, font: 'Calibri', color: '2C3E50' }),
    ],
    spacing: { before: 40, after: 60 },
    indent: { left: 120 },
  });
}

function spacer() {
  return new Paragraph({ children: [new TextRun({ text: '' })], spacing: { before: 40, after: 40 } });
}

function makeTable(headers, rows, colWidths) {
  const headerRow = new TableRow({
    tableHeader: true,
    children: headers.map((h, i) =>
      new TableCell({
        children: [new Paragraph({
          children: [new TextRun({ text: h, bold: true, size: 18, font: 'Calibri', color: 'FFFFFF' })],
          alignment: AlignmentType.CENTER,
          spacing: { before: 40, after: 40 },
        })],
        shading: { type: ShadingType.SOLID, color: '1B4F72', fill: '1B4F72' },
        width: { size: colWidths[i], type: WidthType.DXA },
        verticalAlign: VerticalAlign.CENTER,
        borders: { top: BORDER, bottom: BORDER, left: BORDER, right: BORDER },
      })
    ),
  });

  const dataRows = rows.map((row, ri) =>
    new TableRow({
      children: row.map((cell, ci) =>
        new TableCell({
          children: [new Paragraph({
            children: [new TextRun({ text: cell, size: 18, font: 'Calibri', color: '2C3E50' })],
            alignment: ci === 0 ? AlignmentType.LEFT : AlignmentType.CENTER,
            spacing: { before: 30, after: 30 },
          })],
          shading: { type: ShadingType.SOLID, color: ri % 2 === 0 ? 'FDFEFE' : 'EAF2FF', fill: ri % 2 === 0 ? 'FDFEFE' : 'EAF2FF' },
          width: { size: colWidths[ci], type: WidthType.DXA },
          verticalAlign: VerticalAlign.CENTER,
          borders: { top: THIN_BORDER, bottom: THIN_BORDER, left: THIN_BORDER, right: THIN_BORDER },
        })
      ),
    })
  );

  return new Table({
    rows: [headerRow, ...dataRows],
    width: { size: 100, type: WidthType.PERCENTAGE },
    margins: { top: 60, bottom: 60 },
  });
}

// ─── Document ───────────────────────────────────────────────────────────────

const doc = new Document({
  creator: 'Medical Case Record System',
  title: 'Full Medical Case Record - NGUYEN DUC LONG',
  description: 'Inpatient Case Record, Can Tho University of Medicine and Pharmacy Hospital',
  styles: {
    default: {
      document: {
        run: { font: 'Calibri', size: 20 },
        paragraph: { spacing: { line: 276, lineRule: LineRuleType.AUTO } },
      },
    },
  },
  sections: [
    {
      properties: {
        page: {
          margin: { top: 720, bottom: 720, left: 1008, right: 1008 },
          size: { width: 12240, height: 15840 },
        },
      },
      headers: {
        default: new Header({
          children: [
            new Paragraph({
              children: [
                new TextRun({ text: 'CAN THO UNIVERSITY OF MEDICINE AND PHARMACY HOSPITAL', bold: true, size: 18, font: 'Calibri', color: '1B4F72' }),
                new TextRun({ text: '   |   ', size: 18, font: 'Calibri', color: '7F8C8D' }),
                new TextRun({ text: 'Department of Emergency & Critical Care', size: 18, font: 'Calibri', color: '7F8C8D' }),
                new TextRun({ text: '   |   PID: 26072400   |   Adm. No.: 116056', size: 18, font: 'Calibri', color: '7F8C8D' }),
              ],
              alignment: AlignmentType.CENTER,
              border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: '1B4F72' } },
              spacing: { after: 60 },
            }),
          ],
        }),
      },
      footers: {
        default: new Footer({
          children: [
            new Paragraph({
              children: [
                new TextRun({ text: 'NGUYEN DUC LONG  |  DOB: 16/09/1989  |  Admitted: 08/07/2026  |  ', size: 16, font: 'Calibri', color: '7F8C8D' }),
                new TextRun({ text: 'Page ', size: 16, font: 'Calibri', color: '7F8C8D' }),
                new TextRun({ children: [PageNumber.CURRENT], size: 16, font: 'Calibri', color: '7F8C8D' }),
                new TextRun({ text: ' of ', size: 16, font: 'Calibri', color: '7F8C8D' }),
                new TextRun({ children: [PageNumber.TOTAL_PAGES], size: 16, font: 'Calibri', color: '7F8C8D' }),
              ],
              alignment: AlignmentType.CENTER,
              border: { top: { style: BorderStyle.SINGLE, size: 4, color: '1B4F72' } },
              spacing: { before: 60 },
            }),
          ],
        }),
      },
      children: [

        // ═══════════════════════════════════════════════════════════════════
        // TITLE BLOCK
        // ═══════════════════════════════════════════════════════════════════
        new Paragraph({
          children: [new TextRun({ text: 'FULL MEDICAL CASE RECORD', bold: true, size: 36, font: 'Calibri', color: 'FFFFFF' })],
          alignment: AlignmentType.CENTER,
          shading: { type: ShadingType.SOLID, color: '154360', fill: '154360' },
          spacing: { before: 0, after: 0 },
          indent: { left: 0, right: 0 },
          border: {
            top: { style: BorderStyle.THICK, size: 12, color: '1ABC9C' },
            bottom: { style: BorderStyle.THICK, size: 12, color: '1ABC9C' },
          },
        }),
        new Paragraph({
          children: [new TextRun({ text: 'Can Tho University of Medicine and Pharmacy Hospital', size: 22, font: 'Calibri', color: 'D6EAF8', bold: false })],
          alignment: AlignmentType.CENTER,
          shading: { type: ShadingType.SOLID, color: '1B4F72', fill: '1B4F72' },
          spacing: { before: 0, after: 0 },
        }),
        new Paragraph({
          children: [new TextRun({ text: 'Department of Emergency and Critical Care (ICU/Resuscitation)', size: 20, font: 'Calibri', color: 'AED6F1' })],
          alignment: AlignmentType.CENTER,
          shading: { type: ShadingType.SOLID, color: '1B4F72', fill: '1B4F72' },
          spacing: { before: 0, after: 200 },
        }),

        // ═══════════════════════════════════════════════════════════════════
        // I. PATIENT IDENTIFICATION
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('I.   PATIENT IDENTIFICATION'),

        makeTable(
          ['FIELD', 'DETAIL'],
          [
            ['Full Name', 'NGUYEN DUC LONG'],
            ['Date of Birth', '16 September 1989'],
            ['Age', '37 years'],
            ['Sex', 'Male'],
            ['Ethnicity', 'Kinh'],
            ['Occupation', 'Construction worker'],
            ['Address', 'Xa Quang Dong, Tinh Nghe An'],
            ['Health Insurance No.', 'DN4790112057344 (valid to 31/12/2026)'],
            ['Hospital ID (PID)', '26072400'],
            ['Admission Number', '116056'],
            ['Date & Time of Admission', '08 July 2026 at 15:49 hrs'],
            ['Attending Physician', 'Ths. BS Truong Ngoc Thach'],
            ['Consulting Surgeon', 'BS Tran Quang Son (Orthopaedics)'],
            ['Next of Kin', 'Hoang Minh Tien (Tel: 0339930898), Xa Quang Dong, Nghe An'],
          ],
          [3000, 6000]
        ),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // II. CHIEF COMPLAINT
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('II.   CHIEF COMPLAINT'),
        bodyText('Left leg and foot injury with deformity and an open wound, following a workplace crush mechanism.', { indent: 120 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // III. HISTORY OF PRESENTING ILLNESS
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('III.   HISTORY OF PRESENTING ILLNESS'),
        bodyText('On 08 July 2026 (the day of admission), the patient was engaged in construction work when a heavy roll of sheet metal fell and crushed his left lower leg and foot. He was conscious throughout the incident. Immediately after the injury he noticed:', { indent: 120 }),
        bodyText('Deformity of the left ankle and foot region', { bullet: true }),
        bodyText('Markedly reduced mobility of the left ankle and foot', { bullet: true }),
        bodyText('A laceration on the dorsum of the left foot with mild active bleeding', { bullet: true }),
        bodyText('Severe pain around the left ankle', { bullet: true }),
        bodyText('There was no loss of consciousness, no head or torso injury, and no complaint of difficulty breathing. He was brought directly to the Emergency Department of Can Tho University Hospital on the same day.', { indent: 120 }),
        bodyText('Duration of symptoms prior to presentation: Acute, same day (within hours).', { indent: 120, italic: true }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // IV. PAST MEDICAL HISTORY
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('IV.   PAST MEDICAL HISTORY'),

        makeTable(
          ['CATEGORY', 'DETAILS'],
          [
            ['Personal Medical History', 'Gastroesophageal reflux disease (GERD) - managed conservatively'],
            ['Surgical History', 'None'],
            ['Drug Allergy', 'None reported'],
            ['Family History', 'Non-contributory'],
            ['Social History', 'Construction worker; no relevant toxic exposures beyond occupational hazard'],
          ],
          [2800, 6200]
        ),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // V. REVIEW OF SYSTEMS
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('V.   REVIEW OF SYSTEMS'),
        labelValue('Musculoskeletal', 'Left ankle pain, deformity, restricted range of motion (as above)'),
        labelValue('Cardiovascular', 'No chest pain, no palpitations'),
        labelValue('Respiratory', 'No shortness of breath, no cough'),
        labelValue('Gastrointestinal', 'Known GERD; no acute abdominal complaint'),
        labelValue('Neurological', 'No loss of consciousness; no paraesthesia reported (toe sensation grossly intact on inspection)'),
        labelValue('Other Systems', 'Unremarkable'),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // VI. PHYSICAL EXAMINATION
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('VI.   PHYSICAL EXAMINATION'),

        subHeading('A. Vital Signs (on admission)'),

        makeTable(
          ['PARAMETER', 'VALUE', 'UNIT'],
          [
            ['Pulse', '78', 'beats/min'],
            ['Temperature', '37.0', '°C'],
            ['Blood Pressure', '120/70', 'mmHg'],
            ['Respiratory Rate', '20', 'breaths/min'],
            ['SpO2 (room air)', '98%', '-'],
            ['Weight', '60', 'kg'],
            ['Height', '165', 'cm'],
            ['BMI', '22.04', 'kg/m²'],
          ],
          [3000, 2500, 3500]
        ),

        bodyText('Haemodynamic assessment: Stable. No evidence of haemorrhagic shock (HR 78 bpm, BP 120/70 mmHg).', { indent: 120, italic: true }),

        spacer(),
        subHeading('B. General Appearance'),
        bodyText('Conscious and alert. Good verbal contact. Skin and mucous membranes are pink. In evident pain, particularly localised to the left ankle region. No pallor, jaundice, or cyanosis.', { indent: 120 }),

        spacer(),
        subHeading('C. Local (Orthopaedic) Examination - Left Lower Limb'),

        bodyText('Inspection:', { bold: true, indent: 120 }),
        bodyText('Visible deformity and malalignment of the left ankle-foot axis', { bullet: true }),
        bodyText('Wound on the dorsal surface of the left ankle, approximately 1 cm in size, with mild active bleeding', { bullet: true }),
        bodyText('No gross distal limb ischaemia (toes remain pink)', { bullet: true }),

        bodyText('Palpation:', { bold: true, indent: 120 }),
        bodyText('Severe tenderness over the left ankle', { bullet: true }),
        bodyText('Dorsalis pedis pulse (left): NOT palpable - indicating possible vascular compromise or significant haematoma/oedema causing pulse obliteration', { bullet: true }),
        bodyText('Dorsalis pedis pulse (right): Palpable and normal', { bullet: true }),
        bodyText('Temperature and capillary refill of toes: Grossly maintained (pink toes noted)', { bullet: true }),

        bodyText('Movement:', { bold: true, indent: 120 }),
        bodyText('Ankle and foot mobility on the left is markedly reduced due to pain and deformity', { bullet: true }),
        bodyText('Toe sensation grossly intact; no paraesthesia recorded', { bullet: true }),

        spacer(),
        subHeading('D. Systemic Examination'),

        makeTable(
          ['SYSTEM', 'FINDINGS'],
          [
            ['Cardiovascular', 'Regular rhythm, normal heart sounds, no murmurs. Heart size clinically normal.'],
            ['Respiratory', 'Symmetrical chest expansion, vesicular breath sounds bilaterally, no wheeze or crepitations.'],
            ['Abdomen', 'Soft, non-distended, non-tender. No organomegaly. No guarding or rigidity.'],
            ['CNS', 'Alert and oriented. GCS 15/15.'],
          ],
          [2500, 6500]
        ),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // VII. INVESTIGATIONS
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('VII.   INVESTIGATIONS'),

        subHeading('A. Complete Blood Count (CBC) - 08/07/2026'),

        makeTable(
          ['TEST', 'RESULT', 'REFERENCE RANGE', 'UNIT', 'INTERPRETATION'],
          [
            ['WBC', '10.43 (H)', '4.0 - 9.0', '10⁹/L', 'Mildly elevated - reactive leucocytosis (trauma/stress)'],
            ['Neutrophils %', '55.7', '42.0 - 85.0', '%', 'Normal'],
            ['Lymphocytes %', '36.8', '11 - 49', '%', 'Normal'],
            ['Monocytes %', '6.0', '0.0 - 9.0', '%', 'Normal'],
            ['Eosinophils %', '1.1', '0.0 - 6.0', '%', 'Normal'],
            ['Basophils %', '0.4', '0.0 - 2.0', '%', 'Normal'],
            ['Neutrophils (abs)', '5.80', '1.7 - 7.7', '10⁹/L', 'Normal'],
            ['Lymphocytes (abs)', '3.83', '0.4 - 4.4', '10⁹/L', 'Normal'],
            ['Monocytes (abs)', '0.63', '0.0 - 0.8', '10⁹/L', 'Normal'],
            ['Eosinophils (abs)', '0.12', '0.0 - 0.6', '10⁹/L', 'Normal'],
            ['Basophils (abs)', '0.05', '0.0 - 0.2', '10⁹/L', 'Normal'],
            ['RBC', '5.27', '3.8 - 5.3', '10¹²/L', 'Normal'],
            ['Haemoglobin', '15.7', '12 - 17.2', 'g/dL', 'Normal - no acute haemorrhagic anaemia'],
            ['Haematocrit', '47.5 (H)', '37 - 47', '%', 'Marginally elevated - mild haemoconcentration'],
            ['MCV', '90.2', '80 - 100', 'fL', 'Normocytic'],
            ['MCH', '29.7', '27 - 32', 'pg', 'Normal'],
            ['MCHC', '33.0', '32 - 36', 'g/dL', 'Normal'],
            ['RDW', '12.9', '10 - 14.5', '%', 'Normal'],
            ['Platelets', '258', '150 - 400', '10⁹/L', 'Normal'],
            ['MPV', '9.4 (H)', '5.0 - 9.0', 'fL', 'Marginally elevated'],
            ['PCT', '0.243', '0.1 - 1.0', '%', 'Normal'],
            ['PDW', '16.2', '12 - 18', '%', 'Normal'],
          ],
          [1600, 900, 1200, 900, 4400]
        ),

        bodyText('CBC Summary: Mild reactive leucocytosis (WBC 10.43 x10⁹/L) consistent with an acute traumatic/stress response. Haemoglobin is normal (15.7 g/dL), confirming no significant acute blood loss. No thrombocytopenia. Normocytic normochromic picture.', { indent: 120, italic: true }),

        spacer(),
        subHeading('B. Coagulation Profile - 08/07/2026'),

        makeTable(
          ['TEST', 'RESULT', 'REFERENCE RANGE', 'UNIT', 'INTERPRETATION'],
          [
            ['PT (seconds)', '13.1', 'Control: 13.5', 's', 'Normal'],
            ['PT%', '106', '70 - 120', '%', 'Normal'],
            ['INR', '0.96', '0.8 - 1.2', '-', 'Normal - safe for surgical/procedural intervention'],
            ['APTT', '27.2', '24.8 - 34.4', 's', 'Normal'],
          ],
          [1600, 900, 1400, 700, 4400]
        ),

        bodyText('Coagulation Summary: All parameters within normal limits. No coagulopathy. Safe for closed reduction or operative intervention.', { indent: 120, italic: true }),

        spacer(),
        subHeading('C. Biochemistry Panel - 08/07/2026'),

        makeTable(
          ['TEST', 'RESULT', 'REFERENCE RANGE', 'UNIT', 'INTERPRETATION'],
          [
            ['Sodium (Na+)', '143.8', '134 - 145', 'mmol/L', 'Normal'],
            ['Potassium (K+)', '3.97', '3.4 - 4.8', 'mmol/L', 'Normal'],
            ['Chloride (Cl-)', '108.0 (H)', '98 - 107', 'mmol/L', 'Mildly elevated - not clinically significant in isolation'],
            ['AST (GOT)', '27', '5 - 34', 'U/L', 'Normal'],
            ['ALT (GPT)', '23', '< 55', 'U/L', 'Normal'],
            ['Urea', '5.6', '2.5 - 6.7', 'mmol/L', 'Normal'],
            ['Creatinine', '97.0', '62 - 106', 'µmol/L', 'Normal'],
            ['eGFR', '80.73', '> 60', 'mL/min/1.73m²', 'Adequate renal function'],
            ['Blood Glucose', '4.76', '3.8 - 6.1', 'mmol/L', 'Normal'],
          ],
          [1600, 900, 1200, 900, 4400]
        ),

        bodyText('Biochemistry Summary: Renal function well-preserved. Liver enzymes normal. Electrolytes near-normal (borderline chloride elevation clinically insignificant). No metabolic derangement contraindicating intervention.', { indent: 120, italic: true }),

        spacer(),
        subHeading('D. Imaging Reports'),

        bodyText('1. Chest X-ray (AP, Digital) - 08/07/2026', { bold: true, indent: 120 }),
        bodyText('Requested by: BS Tran Quang Son  |  Reported by: ThS. BS Nguyen Hoang An', { indent: 200, italic: true }),
        bodyText('Findings: Soft tissues - no abnormality. Bony thoracic cage - no fracture. Diaphragm - normal contour bilaterally. Pleural spaces - no effusion, no pneumothorax. Lung parenchyma - clear; no consolidation, collapse, or nodules. Hilar structures - normal. Great vessels - normal calibre and contour. Cardiac silhouette - not enlarged (cardiothoracic ratio within normal limits). Mediastinum - no widening.', { indent: 200 }),
        bodyText('Conclusion: NO ABNORMALITIES DETECTED.', { indent: 200, bold: true }),

        spacer(),
        bodyText('2. Left Leg (Tibia-Fibula) X-ray, AP and Lateral - 08/07/2026', { bold: true, indent: 120 }),
        bodyText('Reported by: ThS. BS Nguyen Hoang An', { indent: 200, italic: true }),
        bodyText('Findings: Bone structure - no fracture detected. Joints - no abnormality identified. Soft tissue - difficult to assess (obscured by plaster/cast artefact). Note: plaster/bandage cast artefact present.', { indent: 200 }),
        bodyText('Conclusion: CAST ARTEFACT OVER THE LEFT LEG. NO BONY INJURY IDENTIFIED ON AVAILABLE VIEWS.', { indent: 200, bold: true }),

        spacer(),
        bodyText('3. Left Ankle X-ray, AP and Lateral - 08/07/2026', { bold: true, indent: 120 }),
        bodyText('Requested by: BS Truong Ngoc Thach  |  Reported by: ThS. BS Nguyen Hoang An', { indent: 200, italic: true }),
        bodyText('Findings: Bone structure - no fracture detected. Joint spaces - widened tibiotalar and talofibular joint spaces (left ankle mortise). Soft tissue - difficult to assess (cast artefact). Note: plaster/bandage cast artefact noted.', { indent: 200 }),
        bodyText('Conclusion: WIDENED LEFT TIBIOTALAR-TALOFIBULAR JOINT SPACE, consistent with ligamentous injury or dislocation component. No fracture identified on plain films. MRI or CT may be required to fully characterise soft tissue and chondral injury if clinically indicated.', { indent: 200, bold: true }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // VIII. DIAGNOSES
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('VIII.   ADMISSION DIAGNOSES'),

        subHeading('Primary Diagnoses'),
        bodyText('1. Left ankle dislocation (traumatic, open) - ICD-10: S93.0', { bold: true, indent: 120 }),
        bodyText('Resulting from high-energy crush injury at workplace. Clinical features include deformity, absent left dorsalis pedis pulse, restricted mobility, and radiological widening of the left ankle joint space.', { indent: 200 }),

        bodyText('2. Open wound, dorsum of left ankle/foot - ICD-10: S91.0', { bold: true, indent: 120 }),
        bodyText('Laceration approximately 1 cm, minor active bleeding. Converts injury to an open category with infection risk.', { indent: 200 }),

        bodyText('3. Soft tissue injury, left ankle and foot - ICD-10: S90.9', { bold: true, indent: 120 }),
        bodyText('Contusion and haematoma expected from crush mechanism.', { indent: 200 }),

        subHeading('Secondary (Comorbid) Diagnosis'),
        bodyText('1. Gastroesophageal Reflux Disease (GERD) - ICD-10: K21', { bold: true, indent: 120 }),
        bodyText('Pre-existing, stable. Relevant to perioperative analgesic choice and gastroprotective medication.', { indent: 200 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // IX. DIFFERENTIAL DIAGNOSES
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('IX.   DIFFERENTIAL DIAGNOSES'),

        makeTable(
          ['RANK', 'DIAGNOSIS', 'SUPPORTING FEATURES', 'FEATURES AGAINST'],
          [
            ['1', 'Traumatic ankle dislocation (without fracture)', 'Deformity, absent DP pulse, axis deviation, X-ray joint space widening, high-energy mechanism', 'No fracture line on X-ray'],
            ['2', 'Bimalleolar/trimalleolar fracture-dislocation', 'High-energy mechanism, deformity, significant swelling', 'No fracture line on plain films'],
            ['3', 'Grade III ligamentous rupture (severe ankle sprain)', 'Mechanism, swelling, restricted motion, joint space widening', 'Severity of deformity and absent pulse exceeds typical sprain'],
            ['4', 'Peroneal/tibial tendon disruption', 'Crush mechanism, soft tissue injury', 'No specific tendon imaging yet obtained'],
          ],
          [600, 2200, 3100, 3100]
        ),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // X. PROBLEM LIST & CLINICAL REASONING
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('X.   PROBLEM LIST AND CLINICAL REASONING'),

        bodyText('Problem 1: Left ankle deformity with absent dorsalis pedis pulse', { bold: true, indent: 120 }),
        bodyText('This is the most time-critical finding. The mechanism (crush by heavy metal roll) combined with the clinical triad of deformity, axis malalignment, and absent left dorsalis pedis pulse raises immediate concern for vascular compromise (anterior tibial artery injury or compression by haematoma/displaced joint). The presence of pink toes with intact capillary refill suggests collateral perfusion via the posterior tibial artery is maintained. However, absent DP pulse mandates urgent orthopaedic and potentially vascular surgical assessment, and prompt reduction if dislocation is confirmed.', { indent: 200 }),

        spacer(),
        bodyText('Problem 2: Open wound on the dorsum of the left ankle/foot (~1 cm)', { bold: true, indent: 120 }),
        bodyText('The open wound converts this to an open injury. This increases the risk of infection (including septic arthritis and osteomyelitis), necessitates wound assessment, irrigation, and antibiotic prophylaxis. Tetanus prophylaxis must be verified.', { indent: 200 }),

        spacer(),
        bodyText('Problem 3: Leucocytosis (WBC 10.43 x10⁹/L)', { bold: true, indent: 120 }),
        bodyText('This is a mild, stress-reactive leucocytosis appropriate to the acute traumatic context. Absolute neutrophil count (5.80 x10⁹/L) is within range. No left shift or toxic granulation noted. Serial monitoring post-reduction is appropriate to ensure it resolves and does not evolve into an infective picture.', { indent: 200 }),

        spacer(),
        bodyText('Problem 4: Borderline hyperchloraemia (Cl- 108 mmol/L)', { bold: true, indent: 120 }),
        bodyText('Likely represents mild hyperchloraemic state secondary to physiological stress or fluid resuscitation artefact. Not clinically significant in isolation. Monitor with repeat electrolytes.', { indent: 200 }),

        spacer(),
        bodyText('Problem 5: Background GERD', { bold: true, indent: 120 }),
        bodyText('Pre-existing condition. Of relevance perioperatively - patient should receive gastroprotective cover (PPI) if undergoing general or regional anaesthesia. NSAIDs avoided as analgesics.', { indent: 200 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XI. INITIAL EMERGENCY MANAGEMENT
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XI.   INITIAL EMERGENCY MANAGEMENT'),

        bodyText('1. Analgesia', { bold: true, indent: 120 }),
        bodyText('Tramadol 100 mg intramuscular injection, single dose, administered at 15:30 hrs on 08/07/2026. Appropriate first-line opioid analgesic for moderate-to-severe musculoskeletal pain; NSAIDs avoided given GERD history.', { indent: 200 }),

        bodyText('2. Immobilisation', { bold: true, indent: 120 }),
        bodyText('Left lower limb immobilised with a posterior plaster back-slab/cast (evidenced by cast artefact on X-ray and nursing records).', { indent: 200 }),

        bodyText('3. Urgent Orthopaedic Surgical Consultation', { bold: true, indent: 120 }),
        bodyText('Orthopaedic surgery team (BS Tran Quang Son) called and reviewed at ~16:04 hrs. Plan for further management including potential closed reduction under anaesthesia.', { indent: 200 }),

        bodyText('4. Investigations Ordered', { bold: true, indent: 120 }),
        bodyText('CBC, coagulation profile, biochemistry panel (electrolytes, renal function, LFTs, glucose) - all completed. Chest X-ray (pre-operative clearance) - completed, normal. Left ankle and leg X-rays (AP + lateral) - completed. ECG and blood grouping/cross-match ordered by orthopaedic team.', { indent: 200 }),

        bodyText('5. Wound Care', { bold: true, indent: 120 }),
        bodyText('Wound on dorsal left ankle assessed. Minor haemostasis applied. Sterile dressing applied.', { indent: 200 }),

        bodyText('6. Monitoring', { bold: true, indent: 120 }),
        bodyText('Continuous SpO2 monitoring, pulse oximetry, and neurovascular observations of the left foot (colour, capillary refill, sensation, temperature, and pulse checks) ordered.', { indent: 200 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XII. PROCEDURE RECORD - CLOSED REDUCTION
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XII.   PROCEDURE RECORD - CLOSED REDUCTION (16:10 hrs, 08/07/2026)'),

        makeTable(
          ['FIELD', 'DETAIL'],
          [
            ['Procedure', 'Closed reduction of left ankle dislocation with plaster back-slab application (Nan, bo bot trat khop co chan)'],
            ['Time of Procedure', '16:10 hrs, 08/07/2026'],
            ['Performing Surgeon', 'BS Tran Quang Son (Orthopaedics)'],
            ['Anaesthetic Method', 'Local anaesthesia (Gay te tai cho)'],
            ['Pre-procedure Diagnosis', 'Left ankle dislocation'],
            ['Post-procedure Diagnosis', 'Left ankle dislocation - reduced'],
          ],
          [3000, 6000]
        ),

        bodyText('Procedure Summary:', { bold: true, indent: 120 }),
        bodyText('Longitudinal traction applied to the left lower leg axis. The joint was observed to reduce. Following reduction: left dorsalis pedis pulse became palpable and strong; toe colour remained pink; SpO2 100%; toes with good sensation. The wound on the dorsum of the left ankle was noted to be actively bleeding with yellowish fluid, raising concern for a penetrating wound into the joint (suspected open/intra-articular wound). The wound was irrigated and dressed. A plaster cast was applied to the left foot in neutral position.', { indent: 200 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XIII. OPERATIVE RECORD - OPEN JOINT EXPLORATION (18:50 hrs, 08/07/2026)
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XIII.   OPERATIVE RECORD - OPEN JOINT EXPLORATION AND REPAIR (18:50 hrs, 08/07/2026)'),

        makeTable(
          ['FIELD', 'DETAIL'],
          [
            ['Operation', 'Open wound debridement of left ankle joint; deltoid ligament repair; drainage tube insertion (Cat loc khap bao khop + Day chang delta + Dan luu khop)'],
            ['Indication (17:31 hrs)', 'Suspected open ankle joint wound (penetrating wound with joint fluid noted post-reduction) - Vet thuong thau khop co chan trai - Trat ho khop'],
            ['Surgical Plan (17:31)', 'Reduction + Open debridement of joint capsule + Deltoid ligament repair + Drainage; Anaesthetic: Spinal or endotracheal general anaesthesia'],
            ['Time of Operation', '18:50 hrs, 08/07/2026'],
            ['Surgeon', 'TS. BS. Tran Quang Son'],
            ['Anaesthesiologist', 'BS Vo Nguyen Hong Phuc'],
            ['Anaesthetic Method', 'Spinal / Local with sedation (Gay te tuy song / Gay te tai cho)'],
            ['Tourniquet', 'Left thigh tourniquet at 250 mmHg'],
          ],
          [2800, 6200]
        ),

        bodyText('Intraoperative Findings:', { bold: true, indent: 120 }),
        bodyText('Upon surgical exploration of the left ankle wound, the following were identified:', { indent: 200 }),
        bodyText('Laceration of the joint capsule (bao khop)', { bullet: true }),
        bodyText('Cartilage/chondral surface injury (ton thuong sun xuong)', { bullet: true }),
        bodyText('Venous structures intact (tinh mach hien con nguyen ven)', { bullet: true }),
        bodyText('Deltoid ligament rupture (dut day chang delta)', { bullet: true }),
        bodyText('Left ankle joint laxity (khop co chan trai long le)', { bullet: true }),

        bodyText('Operative Steps Performed:', { bold: true, indent: 120 }),
        bodyText('Wide extension of wound with surgical debridement of joint capsule', { bullet: true }),
        bodyText('Deltoid ligament repair/reconstruction', { bullet: true }),
        bodyText('Joint irrigation and closure with drainage tube placement', { bullet: true }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XIV. POST-OPERATIVE COURSE
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XIV.   POST-OPERATIVE COURSE AND WARD PROGRESS'),

        makeTable(
          ['DATE/TIME', 'LOCATION', 'CLINICAL STATUS', 'KEY OBSERVATIONS', 'ORDERS/INTERVENTIONS'],
          [
            ['08/07/2026 19:50', 'Dept of Anaesthesia & Recovery', 'Stable post-operatively', 'Returned from theatre stable; conscious; vital signs stable', 'Paracetamol 10mg/mL (IV) x 1 bag; Meloxicam (Brosiral) 10mg/mL 1.5mL IM once; Transfer to Orthopaedics CTCH'],
            ['08/07/2026 21:35', 'Orthopaedics Dept (CTCH) - Transfer received', 'Stable', 'Conscious and cooperative; HR 80/min; BP 100/70 mmHg; SpO2 98%; both legs sensation returning post-spinal', 'Nursing care Level 2; supine position; transfer to orthopaedic ward'],
            ['09/07/2026 05:00', 'Orthopaedics Ward (CTCH)', 'Stable', 'Conscious; vital signs stable; wound with drainage bag in situ; both legs mobile', 'Ceftazidime 1000mg IM x6/day (8h/16h/23h); Sterile diluent (water for injection) x48 ampoules; Levofloxacin 500mg/100mL IV drip x1/day; Paracetamol 10mg/mL IV; Dressing change ordered'],
            ['09/07/2026 07:30 / 10:30', 'Orthopaedics Ward', 'Stable; recovering', 'Wound with minimal drainage; both legs mobile; bilateral pedal pulses palpable', 'Dressing change, suture check (wound < 15cm); continue antibiotics'],
            ['10/07/2026', 'Orthopaedics Ward', 'Improving', 'Minimal wound drainage; wound healing satisfactorily; both legs mobile; bilateral pedal pulses intact', 'Continue Ceftazidime, Levofloxacin, Paracetamol; Dressing change'],
            ['11/07/2026', 'Orthopaedics Ward (Room K24.11.02.110)', 'Improving', 'Stable vital signs; wound with minimal drainage; pain decreasing', 'Ceftazidime x6/day; Levofloxacin 500mg IV x1/day; Paracetamol IV x3/day; Esomeprazole 40mg oral daily; Celecoxib 200mg oral daily; Dressing change'],
            ['12/07/2026', 'Orthopaedics Ward', 'Continuing improvement', 'Stable; wound improving', 'Levofloxacin continued; Ceftazidime (course day 4); Esomeprazole; Celecoxib; Amoxicillin/Clavulanate 875/125mg oral twice daily; Paracetamol (Hapacol) 500mg oral TDS; Dressing change'],
            ['13/07/2026', 'Orthopaedics Ward', 'Stable, improving', 'Wound clean with minimal drainage; both pedal pulses palpable; mobile bilaterally', 'Levofloxacin IV; Esomeprazole 40mg daily; Celecoxib 200mg daily; Amoxicillin/Clavulanate 875/125mg BD; Paracetamol 500mg TDS; Dressing change, suture review'],
            ['14/07/2026', 'Orthopaedics Ward', 'Stable, continuing recovery', 'Pain at wound site; wound with minimal serous drainage; bilateral pedal pulses palpable; bilateral leg movement intact', 'Levofloxacin IV; Esomeprazole; Celecoxib; Ongoing dressing; Further management plan pending review'],
          ],
          [1100, 1300, 900, 2400, 3300]
        ),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XV. MEDICATIONS ADMINISTERED (COMPLETE LIST)
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XV.   MEDICATIONS ADMINISTERED'),

        makeTable(
          ['DRUG', 'DOSE', 'ROUTE', 'FREQUENCY', 'DATES', 'INDICATION'],
          [
            ['Tramadol (Tramadol HCl)', '100 mg', 'IM', 'Single dose', '08/07/2026 15:30', 'Acute pain - post crush injury'],
            ['Paracetamol 10mg/mL', '1 bag (IV)', 'IV infusion', 'TDS (8h, 16h, 23h)', '08/07 - ongoing', 'Post-operative analgesia'],
            ['Meloxicam (Brosiral) 10mg/mL', '1.5 mL', 'IM', 'Once', '08/07/2026 post-op', 'Anti-inflammatory (single dose)'],
            ['Ceftazidime (Tenamyd) 1000 mg', '1000 mg', 'IM', 'TDS (8h, 16h, 23h)', '09/07 - 12/07/2026', 'Antibiotic prophylaxis - open joint wound'],
            ['Levofloxacin 500mg/100mL', '500 mg', 'IV drip', 'Daily (8h)', '09/07/2026 - ongoing', 'Broad spectrum antibiotic cover'],
            ['Esomeprazole 40mg', '40 mg', 'Oral', 'Daily (8h)', '11/07/2026 - ongoing', 'Gastroprotection (GERD + perioperative)'],
            ['Celecoxib (Beroxib) 200mg', '200 mg', 'Oral', 'Daily (8h)', '11/07/2026 - ongoing', 'COX-2 selective anti-inflammatory/analgesic'],
            ['Amoxicillin/Clavulanate (Curam) 875/125mg', '875/125 mg', 'Oral', 'BD (morning and evening)', '12/07/2026 - ongoing', 'Step-down oral antibiotic therapy'],
            ['Paracetamol (Hapacol Caplet 500)', '500 mg', 'Oral', 'TDS (8h, 16h, 23h)', '12/07/2026 - ongoing', 'Step-down oral analgesia'],
          ],
          [1500, 700, 700, 1000, 1000, 4100]
        ),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XVI. NURSING ASSESSMENT SUMMARY
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XVI.   NURSING ASSESSMENT SUMMARY'),

        bodyText('15:49 hrs - 08/07/2026 (Initial assessment - Nurse Loan):', { bold: true, indent: 120 }),
        bodyText('Patient conscious, oriented, good contact; mucous membranes pink; vital signs stable. Left ankle: abrasion, minor bleeding, deformity present; axis deviation noted; left dorsalis pedis pulse not palpable; range of movement of left ankle and foot limited; toe colour pink (capillary refill maintained). Abdomen soft; breathing regular and unlaboured. No drug allergy history.', { indent: 200 }),
        bodyText('Actions: Vital signs taken; physician reviewed; Tramadol IM administered; investigations requested; orthopaedic surgery team called.', { indent: 200, italic: true }),

        spacer(),
        bodyText('16:04 hrs - 08/07/2026 (Second entry - Nurse Loan):', { bold: true, indent: 120 }),
        bodyText('Patient remains stable. Orthopaedic surgery review completed. Pre-operative investigations ordered (ECG, blood group). Results awaited and to be communicated to orthopaedic team.', { indent: 200 }),

        spacer(),
        bodyText('19:04 hrs - 08/07/2026 (Third entry):', { bold: true, indent: 120 }),
        bodyText('Patient stable. Orthopaedic surgeon examined. Planned immobilisation/reduction completed. Further investigations ordered (ECG, blood group, repeat labs).', { indent: 200 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XVII. PLAN OF MANAGEMENT
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XVII.   PLAN OF MANAGEMENT'),

        subHeading('Immediate (Emergency - Completed)'),
        bodyText('Neurovascular monitoring of left foot (pulse, capillary refill, sensation, warmth) every 30-60 minutes', { bullet: true }),
        bodyText('Immobilisation with back-slab; limb elevation above heart level to reduce oedema', { bullet: true }),
        bodyText('Analgesia: Tramadol 100mg IM (administered); escalation pathway to IV morphine/regional nerve block if needed', { bullet: true }),
        bodyText('Wound care: sterile dressing; contamination assessment; tetanus prophylaxis as indicated', { bullet: true }),
        bodyText('IV access; fluid administration as required; NBM in anticipation of operative intervention', { bullet: true }),

        subHeading('Definitive (Orthopaedic - Completed)'),
        bodyText('Closed reduction under local anaesthesia (16:10 hrs, 08/07/2026) - successful; dorsalis pedis pulse returned post-reduction', { bullet: true }),
        bodyText('Emergency operative intervention (18:50 hrs, 08/07/2026): Open wound debridement, joint capsule repair, deltoid ligament reconstruction, drain placement - due to suspected open joint wound with joint fluid noted at wound site', { bullet: true }),
        bodyText('Post-operative plaster immobilisation of left ankle in neutral position', { bullet: true }),
        bodyText('Prophylactic antibiotic therapy (Ceftazidime + Levofloxacin) commenced post-operatively', { bullet: true }),

        subHeading('Ongoing'),
        bodyText('Serial neurovascular checks; Doppler if available', { bullet: true }),
        bodyText('Daily dressing changes with suture line inspection', { bullet: true }),
        bodyText('Step-down antibiotic therapy: IV to oral (Amoxicillin/Clavulanate) as wound improves', { bullet: true }),
        bodyText('Gastroprotection (Esomeprazole 40mg daily) - maintained perioperatively and while on anti-inflammatory drugs', { bullet: true }),
        bodyText('Monitor for compartment syndrome: pain on passive dorsiflexion of toes, tense compartments, disproportionate pain', { bullet: true }),
        bodyText('Repeat CBC and CMP at 24-48 hours post-intervention', { bullet: true }),
        bodyText('Post-discharge physiotherapy and rehabilitation planning', { bullet: true }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XVIII. PATHOPHYSIOLOGY / CLINICAL REASONING
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XVIII.   PATHOPHYSIOLOGY AND CLINICAL REASONING'),

        bodyText('Traumatic Ankle Dislocation without Fracture (Rare Pattern):', { bold: true, indent: 120 }),
        bodyText('Pure ankle dislocations without associated fracture represent approximately 1-2% of ankle injuries. They typically occur with high-energy mechanisms where ligamentous failure precedes bony injury. In this case, the roll of sheet metal acting as a direct crush force transferred axial load and shearing forces across the ankle mortise, producing: (1) Stretching or complete rupture of the anterior talofibular, calcaneofibular, and/or deltoid ligaments; (2) Talar displacement from the mortise causing axis malalignment; (3) Haematoma and swelling compressing neurovascular structures - explaining the absent dorsalis pedis pulse despite intact toe perfusion via posterior tibial artery collateral circulation; (4) Joint space widening on radiograph reflecting loss of mortise congruity.', { indent: 200 }),

        spacer(),
        bodyText('Open Joint Wound (Intra-articular Penetration):', { bold: true, indent: 120 }),
        bodyText('The appearance of yellowish joint fluid at the wound site following reduction indicated a penetrating wound communicating with the ankle joint cavity. This is a surgical emergency requiring formal operative exploration, irrigation, and debridement to prevent septic arthritis and osteomyelitis - hence the decision for operative intervention at 18:50 hrs on the same day.', { indent: 200 }),

        spacer(),
        bodyText('Mild Reactive Leucocytosis:', { bold: true, indent: 120 }),
        bodyText('Acute tissue injury triggers catecholamine-mediated demargination of neutrophils from vessel walls into the circulating pool, causing a transient neutrophilia and mild leucocytosis. This is not indicative of infection and is expected to normalise following definitive management.', { indent: 200 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XIX. PROGNOSIS
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XIX.   PROGNOSIS'),

        bodyText('With prompt and appropriate management (urgent reduction, wound care, operative debridement, limb elevation, neurovascular monitoring), the prognosis for limb salvage and functional recovery is favourable, given:', { indent: 120 }),
        bodyText('No fracture identified on plain films', { bullet: true }),
        bodyText('Toe perfusion maintained (pink toes, intact capillary refill) and dorsalis pedis pulse returned post-reduction', { bullet: true }),
        bodyText('Haemodynamically stable patient throughout', { bullet: true }),
        bodyText('Normal coagulation and renal function', { bullet: true }),
        bodyText('Prompt operative joint debridement reducing risk of septic arthritis', { bullet: true }),
        bodyText('Long-term outcomes will depend on the degree of chondral and ligamentous injury confirmed intraoperatively (cartilage injury and deltoid ligament rupture noted). Risk of post-traumatic ankle arthritis and chronic instability should be addressed in rehabilitation planning.', { indent: 120, italic: true }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XX. MULTI-DISCIPLINARY TEAM CONFERENCE RECORD
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XX.   MULTI-DISCIPLINARY TEAM CONFERENCE (HỘI CHẨN) - 18:00 hrs, 08/07/2026'),

        makeTable(
          ['FIELD', 'DETAIL'],
          [
            ['Chairperson', 'Vo Minh Phuong'],
            ['Secretary', 'Ho Thi Bao Xuyen'],
            ['Members', 'Tran Quang Son; Vo Nguyen Hong Phuc'],
            ['Time', '18:00 hrs, 08/07/2026'],
            ['Case Summary Presented', 'Left ankle dislocation following workplace crush injury; post closed reduction with noted open joint wound; plan for operative exploration'],
            ['Decision', 'Operative intervention: Open wound debridement, joint capsule repair (Cat loc khau bao khop), deltoid ligament repair (Day chang chay son), drainage; Anaesthetic: Spinal/endotracheal'],
            ['Risks Discussed', 'Re-dislocation; joint infection; anaesthetic risk'],
          ],
          [2000, 7000]
        ),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XXI. CASE SUMMARY
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XXI.   CASE SUMMARY'),

        bodyText('Mr. Nguyen Duc Long, a 37-year-old male construction worker from Nghe An province, presented to the Emergency Department of Can Tho University of Medicine and Pharmacy Hospital on 08 July 2026 at 15:49 hrs following a workplace crush injury to the left lower limb caused by a heavy roll of sheet metal.', { indent: 120 }),
        spacer(),
        bodyText('On examination he was haemodynamically stable (BP 120/70 mmHg, HR 78 bpm, SpO2 98%) but had a visibly deformed left ankle with axis malalignment, a 1 cm wound on the dorsum of the foot, and critically, an absent left dorsalis pedis pulse. Investigations revealed mild reactive leucocytosis (WBC 10.43 x10⁹/L), normal haemoglobin (15.7 g/dL), normal coagulation (INR 0.96, APTT 27.2s), and normal renal and hepatic function. Plain X-rays of the chest were normal. Left ankle X-ray showed widening of the left tibiotalar-talofibular joint space consistent with dislocation, without fracture.', { indent: 120 }),
        spacer(),
        bodyText('He underwent urgent closed reduction under local anaesthesia at 16:10 hrs on the same day (performed by BS Tran Quang Son), with immediate return of the left dorsalis pedis pulse. However, inspection of the wound revealed yellowish fluid consistent with joint fluid, confirming an open intra-articular wound. Following MDT discussion, he underwent emergency operative exploration at 18:50 hrs: open debridement of the ankle joint capsule, deltoid ligament repair, and insertion of a drainage tube. Intraoperative findings included a lacerated joint capsule, chondral surface injury, and complete deltoid ligament rupture.', { indent: 120 }),
        spacer(),
        bodyText('Post-operatively he was managed in the Recovery Unit then transferred to Orthopaedics. He received dual antibiotic therapy (Ceftazidime + Levofloxacin IV), analgesia (Paracetamol IV/oral, Celecoxib), and gastroprotection (Esomeprazole). Daily wound dressing and suture review have been performed from 09/07/2026. As of 14/07/2026 he remains stable with minimal wound drainage, bilateral pedal pulses palpable, and bilateral leg movement intact.', { indent: 120 }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // XXII. CLINICAL PEARLS
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XXII.   CLINICAL PEARLS'),

        bodyText('Absent dorsalis pedis pulse in ankle dislocation = time-sensitive emergency; reduction within 6 hours prevents talar avascular necrosis and ischaemic complications', { bullet: true }),
        bodyText('Normal plain films do NOT exclude chondral injury, ligamentous rupture, or syndesmotic disruption - CT/MRI is the gold standard for these', { bullet: true }),
        bodyText('Yellowish fluid at an ankle wound following dislocation = joint communication must be excluded; formal operative exploration is mandatory', { bullet: true }),
        bodyText('Mild leucocytosis in acute trauma is catecholamine-driven (demargination) not infective - do not reflexively prescribe antibiotics for this alone', { bullet: true }),
        bodyText('GERD history = avoid NSAIDs (except selective COX-2 inhibitors with caution and PPI cover); use PPI cover perioperatively; Tramadol is appropriate first-line analgesic', { bullet: true }),
        bodyText('The CBC differential (NEU% 55.7, normal absolute neutrophil count) rules out a significant left shift, supporting a reactive rather than infective aetiology for the leucocytosis', { bullet: true }),
        bodyText('Pure ankle dislocation without fracture is rare (1-2% of ankle injuries); requires CT or MRI to fully characterise osteochondral injury before definitive rehabilitation planning', { bullet: true }),

        spacer(),

        // ═══════════════════════════════════════════════════════════════════
        // SIGNATURES
        // ═══════════════════════════════════════════════════════════════════
        sectionHeading('XXIII.   SIGNATURES AND ATTESTATION'),

        makeTable(
          ['ROLE', 'NAME', 'SIGNATURE / DATE'],
          [
            ['Attending Physician (Emergency)', 'Ths. BS Truong Ngoc Thach', '08/07/2026'],
            ['Orthopaedic Surgeon (Primary)', 'TS. BS Tran Quang Son', '08/07/2026'],
            ['Anaesthesiologist', 'BS Vo Nguyen Hong Phuc', '08/07/2026'],
            ['Ward Physician (Post-operative)', 'TS. BS Tran Nguyen Anh Duy', '09 - 14/07/2026'],
            ['Reviewing Physician (MDT Chair)', 'Vo Minh Phuong', '08/07/2026'],
            ['Nursing (Initial Assessment)', 'Nurse Loan', '08/07/2026'],
          ],
          [2200, 2800, 4000]
        ),

        spacer(),
        bodyText('Case record compiled at: Can Tho University of Medicine and Pharmacy Hospital, Department of Emergency and Critical Care.', { indent: 120, italic: true }),
        bodyText('Date compiled: 14 July 2026', { indent: 120, italic: true }),

      ],
    },
  ],
});

Packer.toBuffer(doc).then((buffer) => {
  fs.writeFileSync('/home/daytona/workspace/medical-case-record/NGUYEN_DUC_LONG_Medical_Case_Record.docx', buffer);
  console.log('SUCCESS: Document written.');
}).catch(err => {
  console.error('ERROR:', err);
});
Running Command

cd /home/daytona/workspace/medical-case-record && node generate_case_record.js 2…

Running Command

python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/works…

Running Command

# Verify file was created and check size ls -lh /home/daytona/workspace/medical-…

The document is valid. Here is the completed full medical case record:

Full Medical Case Record - NGUYEN DUC LONG

The document has been generated successfully from both uploaded PDFs (the 23-page scanned Vietnamese hospital records + the structured case record PDF). Here is a summary of what was extracted and compiled:
Download the Word document:

NGUYEN DUC LONG Medical Case Record

Word Document · DOCX


What the record contains (23 sections):

SectionContent
IPatient identification (name, DOB, PID, admission details, attending physicians)
IIChief complaint
IIIHistory of presenting illness
IVPast medical history (GERD, no surgical history, no drug allergy)
VReview of systems
VIPhysical examination - vital signs, general exam, orthopaedic exam (absent DP pulse noted), systemic exam
VIIFull investigations - CBC (22 parameters), coagulation profile, biochemistry panel, and 3 imaging reports (CXR, tibia-fibula XR, ankle XR) with official radiology conclusions
VIIIAdmission diagnoses (ICD-10 coded: S93.0, S91.0, S90.9, K21)
IXDifferential diagnoses (ranked)
XProblem list and clinical reasoning (5 problems)
XIInitial emergency management
XIIProcedure record: Closed reduction (16:10 hrs, 08/07/2026) - successful with pulse return
XIIIOperative record: Emergency open joint exploration, deltoid ligament repair, drain insertion (18:50 hrs, 08/07/2026) with intraoperative findings
XIVDay-by-day post-operative ward progress (08/07 - 14/07/2026)
XVComplete medications list (9 drugs with doses, routes, frequencies, dates)
XVINursing assessment summary (3 time-stamped entries)
XVIIPlan of management (emergency, definitive, ongoing)
XVIIIPathophysiology and clinical reasoning
XIXPrognosis
XXMDT conference record (Hội chẩn, 18:00 hrs, 08/07/2026)
XXIComprehensive case summary
XXIIClinical pearls
XXIIISignatures and attestation
Key findings captured from the raw scans: The closed reduction at 16:10 was successful (dorsalis pedis pulse returned), but joint fluid at the wound site prompted an emergency MDT decision for operative exploration at 18:50 hrs, where a lacerated joint capsule, chondral injury, and complete deltoid ligament rupture were found. Post-operative antibiotic escalation and step-down therapy are fully documented through 14/07/2026.
This is a shared conversation. Sign in to Orris to start your own chat.