~/nerve-assignment/create_assignment.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
HeadingLevel, AlignmentType, BorderStyle, WidthType, ShadingType,
VerticalAlign, PageNumber, Header, Footer, PageBreak, TableOfContents,
StyleLevel, UnderlineType
} = require('docx');
const fs = require('fs');
// ─── Color palette ───────────────────────────────────────────────────
const DARK_BLUE = "1F3864";
const MED_BLUE = "2E74B5";
const LIGHT_BLUE = "D6E4F0";
const LIGHT_GREY = "F2F2F2";
const WHITE = "FFFFFF";
const ACCENT = "C00000";
const TABLE_HEAD = "1F3864";
// ─── Helpers ─────────────────────────────────────────────────────────
function pageBreak() {
return new Paragraph({ children: [new PageBreak()] });
}
function heading1(text) {
return new Paragraph({
heading: HeadingLevel.HEADING_1,
children: [new TextRun({ text, bold: true, color: WHITE, size: 28 })],
shading: { type: ShadingType.SOLID, color: DARK_BLUE, fill: DARK_BLUE },
spacing: { before: 240, after: 120 },
indent: { left: 200, right: 200 },
});
}
function heading2(text) {
return new Paragraph({
heading: HeadingLevel.HEADING_2,
children: [new TextRun({ text, bold: true, color: WHITE, size: 24 })],
shading: { type: ShadingType.SOLID, color: MED_BLUE, fill: MED_BLUE },
spacing: { before: 200, after: 100 },
indent: { left: 160 },
});
}
function heading3(text) {
return new Paragraph({
heading: HeadingLevel.HEADING_3,
children: [new TextRun({ text, bold: true, color: DARK_BLUE, size: 22 })],
border: { bottom: { style: BorderStyle.SINGLE, size: 6, color: MED_BLUE } },
spacing: { before: 160, after: 80 },
});
}
function bodyPara(text, opts = {}) {
return new Paragraph({
children: [new TextRun({ text, size: 20, color: "000000", ...opts })],
spacing: { before: 60, after: 60 },
indent: { left: 200 },
});
}
function bulletPara(text) {
return new Paragraph({
children: [new TextRun({ text, size: 20 })],
bullet: { level: 0 },
spacing: { before: 40, after: 40 },
indent: { left: 360, hanging: 200 },
});
}
function noteBox(text) {
return new Paragraph({
children: [new TextRun({ text: "📌 " + text, size: 18, italics: true, color: "5A5A5A" })],
shading: { type: ShadingType.SOLID, color: "FFF9C4", fill: "FFF9C4" },
border: {
left: { style: BorderStyle.THICK, size: 8, color: ACCENT }
},
spacing: { before: 80, after: 80 },
indent: { left: 200, right: 200 },
});
}
function spacer(lines = 1) {
return new Paragraph({ children: [new TextRun({ text: "", size: 20 })], spacing: { before: lines * 60 } });
}
// ─── Table builder ────────────────────────────────────────────────────
function makeTable(headers, rows, columnWidths) {
const headerRow = new TableRow({
tableHeader: true,
children: headers.map((h, i) =>
new TableCell({
children: [new Paragraph({
children: [new TextRun({ text: h, bold: true, color: WHITE, size: 18 })],
alignment: AlignmentType.CENTER,
})],
shading: { type: ShadingType.SOLID, color: TABLE_HEAD, fill: TABLE_HEAD },
width: { size: columnWidths[i], type: WidthType.DXA },
verticalAlign: VerticalAlign.CENTER,
margins: { top: 60, bottom: 60, left: 80, right: 80 },
})
),
});
const dataRows = rows.map((row, rIdx) =>
new TableRow({
children: row.map((cell, cIdx) =>
new TableCell({
children: [new Paragraph({
children: [new TextRun({ text: cell, size: 18 })],
alignment: cIdx === 0 ? AlignmentType.LEFT : AlignmentType.LEFT,
})],
shading: {
type: ShadingType.SOLID,
color: rIdx % 2 === 0 ? WHITE : LIGHT_GREY,
fill: rIdx % 2 === 0 ? WHITE : LIGHT_GREY,
},
width: { size: columnWidths[cIdx], type: WidthType.DXA },
margins: { top: 50, bottom: 50, left: 80, right: 80 },
})
),
})
);
return new Table({
rows: [headerRow, ...dataRows],
width: { size: 9000, type: WidthType.DXA },
margins: { top: 80, bottom: 80 },
});
}
// ─── CONTENT ─────────────────────────────────────────────────────────
// ── TITLE PAGE ──
const titlePage = [
spacer(4),
new Paragraph({
children: [new TextRun({ text: "ASSIGNMENT", bold: true, size: 52, color: DARK_BLUE, allCaps: true })],
alignment: AlignmentType.CENTER,
spacing: { before: 200, after: 80 },
}),
new Paragraph({
children: [new TextRun({ text: "Nerve-wise Muscle Supply", bold: true, size: 44, color: MED_BLUE })],
alignment: AlignmentType.CENTER,
spacing: { before: 80, after: 80 },
}),
new Paragraph({
children: [new TextRun({ text: "Upper Limb & Lower Limb", bold: true, size: 36, color: DARK_BLUE })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 240 },
}),
new Paragraph({
children: [new TextRun({ text: "─────────────────────────────────────────", color: MED_BLUE, size: 24 })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 240 },
}),
new Paragraph({
children: [new TextRun({ text: "Subject: Anatomy / Kinesiology", size: 22, color: "333333" })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 60 },
}),
new Paragraph({
children: [new TextRun({ text: "Topic: Peripheral Nerve Innervation of Limb Muscles", size: 22, color: "333333" })],
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 60 },
}),
spacer(2),
new Paragraph({
children: [new TextRun({ text: "Submitted To:", bold: true, size: 22, color: DARK_BLUE })],
alignment: AlignmentType.CENTER,
spacing: { before: 80, after: 20 },
}),
new Paragraph({
children: [new TextRun({ text: "Course Faculty", size: 22, color: "444444" })],
alignment: AlignmentType.CENTER,
spacing: { before: 20, after: 60 },
}),
spacer(4),
pageBreak(),
];
// ── INTRODUCTION ──
const introduction = [
heading1("INTRODUCTION"),
spacer(),
bodyPara(
"The peripheral nervous system supplies the muscles of the upper and lower limbs through a well-organized network of nerves arising from the brachial plexus (C5–T1) and the lumbosacral plexus (L1–S3). Understanding nerve-wise muscle supply is fundamental in Anatomy, Physiology, Kinesiology, and Clinical Physiotherapy — especially for assessing motor deficits, diagnosing nerve injuries, and planning rehabilitation."
),
spacer(),
bodyPara(
"Each peripheral nerve carries motor fibers that innervate specific muscles. When a nerve is injured, the resulting weakness or paralysis follows a predictable pattern — called a 'denervation pattern' — which helps clinicians localize the site of injury. This assignment systematically lists each major nerve and the muscles it supplies in both the upper and lower limbs."
),
spacer(),
noteBox("Key Principle: Nerves from posterior divisions (Radial, Axillary) supply EXTENSORS; nerves from anterior divisions (Musculocutaneous, Median, Ulnar) supply FLEXORS in the upper limb."),
spacer(2),
pageBreak(),
];
// ══════════════════════════════════════════════════════════════════════
// UPPER LIMB
// ══════════════════════════════════════════════════════════════════════
const upperLimbIntro = [
heading1("PART I: UPPER LIMB"),
spacer(),
bodyPara("The upper limb is supplied by the BRACHIAL PLEXUS (C5, C6, C7, C8, T1). The major terminal branches are:"),
bulletPara("Musculocutaneous nerve (C5, C6, C7)"),
bulletPara("Median nerve (C6, C7, C8, T1)"),
bulletPara("Ulnar nerve (C7, C8, T1)"),
bulletPara("Radial nerve (C5, C6, C7, C8, T1)"),
bulletPara("Axillary nerve (C5, C6)"),
bulletPara("Plus: Suprascapular, Long thoracic, Thoracodorsal, Subscapular, Pectoral nerves"),
spacer(2),
];
// 1. Musculocutaneous
const musculocutaneous = [
heading2("1. Musculocutaneous Nerve (C5, C6, C7)"),
spacer(),
bodyPara("Origin: Lateral cord of brachial plexus. Pierces coracobrachialis, runs between biceps and brachialis."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action", "Clinical Importance"],
[
["1", "Coracobrachialis", "Flexion & adduction of arm at shoulder", "Pierced by the nerve itself"],
["2", "Biceps brachii (both heads)", "Elbow flexion + forearm supination", "Most powerful supinator; absent biceps reflex"],
["3", "Brachialis", "Elbow flexion (pure flexor)", "Principal flexor of elbow joint"],
],
[600, 2200, 3000, 3200]
),
spacer(),
noteBox("Mnemonic: 'BBC' — Brachialis, Biceps, Coracobrachialis"),
spacer(),
bodyPara("Injury result: Loss of elbow flexion and supination; sensory loss on lateral forearm."),
spacer(2),
];
// 2. Median Nerve
const medianNerve = [
heading2("2. Median Nerve (C6, C7, C8, T1)"),
spacer(),
bodyPara("Origin: Lateral + Medial cords (dual root). Called the 'nerve of precision grip' and 'eye of the hand'."),
spacer(),
heading3("2A. In the Forearm"),
spacer(),
makeTable(
["S.No.", "Muscle", "Nerve Branch", "Action"],
[
["1", "Pronator teres", "Main trunk", "Pronation of forearm"],
["2", "Flexor carpi radialis (FCR)", "Main trunk", "Wrist flexion + radial deviation"],
["3", "Palmaris longus", "Main trunk", "Wrist flexion (absent in 14%)"],
["4", "Flexor digitorum superficialis (FDS)", "Main trunk", "Flexion of middle phalanges (D2–D5)"],
["5", "Flexor digitorum profundus (FDP) — lateral half", "Anterior interosseous nerve (AIN)", "Flexion of distal phalanges D2 & D3"],
["6", "Flexor pollicis longus (FPL)", "Anterior interosseous nerve (AIN)", "Flexion of thumb IP joint"],
["7", "Pronator quadratus", "Anterior interosseous nerve (AIN)", "Pronation (powerful)"],
],
[500, 2400, 2000, 3100]
),
spacer(),
heading3("2B. In the Hand (LOAF Muscles)"),
spacer(),
makeTable(
["S.No.", "Muscle", "Action", "Test"],
[
["1", "Lateral 2 Lumbricals (1st & 2nd)", "MCP flexion + IP extension of D2 & D3", "Point to ceiling with index finger"],
["2", "Opponens pollicis", "Opposition of thumb (most important)", "Touch tip of thumb to little finger"],
["3", "Abductor pollicis brevis (APB)", "Abduction of thumb (palmar)", "Lift thumb perpendicular to palm"],
["4", "Flexor pollicis brevis — superficial head", "Flexion of thumb MCP joint", "Thumb flexion at MCP"],
],
[500, 2500, 3000, 2000]
),
spacer(),
noteBox("Mnemonic: 'LOAF' — Lumbricals (1&2), Opponens pollicis, Abductor pollicis brevis, Flexor pollicis brevis (superficial head)"),
spacer(),
bodyPara("Injury result: 'Ape hand' deformity, loss of thumb opposition (most disabling), 'pen test' abnormal, carpal tunnel syndrome affects this nerve."),
spacer(2),
];
// 3. Ulnar Nerve
const ulnarNerve = [
heading2("3. Ulnar Nerve (C7, C8, T1)"),
spacer(),
bodyPara("Origin: Medial cord of brachial plexus. Passes behind medial epicondyle (ulnar groove). Called 'musician's nerve' — controls fine movements of fingers."),
spacer(),
heading3("3A. In the Forearm"),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Flexor carpi ulnaris (FCU)", "Wrist flexion + ulnar deviation"],
["2", "Flexor digitorum profundus (FDP) — medial half", "Flexion of distal phalanges of D4 & D5"],
],
[500, 2500, 6000]
),
spacer(),
heading3("3B. In the Hand"),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Abductor digiti minimi", "Abduction of little finger"],
["2", "Flexor digiti minimi brevis", "Flexion of little finger MCP"],
["3", "Opponens digiti minimi", "Opposition of little finger"],
["4", "Medial 2 Lumbricals (3rd & 4th)", "MCP flexion + IP extension of D4 & D5"],
["5", "All 4 Dorsal interossei (DAB)", "Finger abduction"],
["6", "All 3 Palmar interossei (PAD)", "Finger adduction"],
["7", "Adductor pollicis", "Adduction of thumb"],
["8", "Flexor pollicis brevis — deep head", "Flexion of thumb MCP"],
["9", "Palmaris brevis", "Skin wrinkling over hypothenar"],
],
[500, 2800, 5700]
),
spacer(),
noteBox("Mnemonic: 'All hand muscles EXCEPT LOAF = Ulnar nerve'. Intrinsics: DAB = Dorsal Abduct; PAD = Palmar Adduct"),
spacer(),
bodyPara("Injury result: 'Claw hand' (ring & little fingers), Froment's sign (adductor pollicis weakness), loss of finger abduction/adduction."),
spacer(2),
];
// 4. Radial Nerve
const radialNerve = [
heading2("4. Radial Nerve (C5, C6, C7, C8, T1)"),
spacer(),
bodyPara("Origin: Posterior cord of brachial plexus. Largest branch. Passes through spiral groove of humerus. Called 'great extensor nerve'."),
spacer(),
heading3("4A. In the Arm"),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Triceps brachii (all 3 heads)", "Elbow extension"],
["2", "Anconeus", "Assists elbow extension"],
["3", "Brachioradialis", "Elbow flexion in midpronation"],
["4", "Extensor carpi radialis longus (ECRL)", "Wrist extension + radial deviation"],
],
[500, 2800, 5700]
),
spacer(),
heading3("4B. In the Forearm (via Posterior Interosseous Nerve — PIN)"),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Extensor carpi radialis brevis (ECRB)", "Wrist extension"],
["2", "Supinator", "Supination of forearm"],
["3", "Extensor digitorum communis (EDC)", "Extension of fingers D2–D5"],
["4", "Extensor digiti minimi (EDM)", "Extension of little finger"],
["5", "Extensor carpi ulnaris (ECU)", "Wrist extension + ulnar deviation"],
["6", "Abductor pollicis longus (APL)", "Abduction + extension of thumb"],
["7", "Extensor pollicis longus (EPL)", "Extension of thumb IP joint"],
["8", "Extensor pollicis brevis (EPB)", "Extension of thumb MCP joint"],
["9", "Extensor indicis proprius (EIP)", "Independent index finger extension"],
],
[500, 2800, 5700]
),
spacer(),
noteBox("Mnemonic: 'BEST' — Brachioradialis, Extensors (all), Supinator, Triceps"),
spacer(),
bodyPara("Injury result: 'Wrist drop' (radial nerve palsy at spiral groove); loss of wrist and finger extension; 'Saturday night palsy'. Test: Thumbs-up sign."),
spacer(2),
];
// 5. Axillary
const axillaryNerve = [
heading2("5. Axillary Nerve (C5, C6)"),
spacer(),
bodyPara("Origin: Posterior cord. Passes through quadrangular space. Most commonly injured in shoulder dislocation / surgical neck humerus fracture."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Deltoid — anterior fibers", "Shoulder flexion + medial rotation"],
["2", "Deltoid — middle fibers", "Shoulder abduction (15°–90°)"],
["3", "Deltoid — posterior fibers", "Shoulder extension + lateral rotation"],
["4", "Teres minor", "Lateral rotation of arm"],
],
[500, 2800, 5700]
),
spacer(),
bodyPara("Injury result: Loss of shoulder abduction, flattening of deltoid, sensory loss over regimental badge area (lateral upper arm)."),
spacer(2),
];
// 6. Suprascapular
const suprascapularNerve = [
heading2("6. Suprascapular Nerve (C5, C6)"),
spacer(),
bodyPara("Origin: Upper trunk of brachial plexus. Passes through suprascapular notch."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Supraspinatus", "Initiates shoulder abduction (0–15°); part of rotator cuff"],
["2", "Infraspinatus", "Lateral rotation of arm; rotator cuff"],
],
[500, 2800, 5700]
),
spacer(2),
];
// 7. Other nerves UL
const otherULNerves = [
heading2("7. Other Important Nerves of Upper Limb"),
spacer(),
makeTable(
["Nerve", "Root", "Muscle(s) Supplied", "Key Action / Injury"],
[
["Long thoracic nerve", "C5, C6, C7", "Serratus anterior", "'Winged scapula' on injury"],
["Dorsal scapular nerve", "C5", "Rhomboid major & minor; Levator scapulae", "Scapular retraction & elevation"],
["Thoracodorsal nerve", "C6, C7, C8", "Latissimus dorsi", "Arm extension, adduction, medial rotation"],
["Upper subscapular nerve", "C5, C6", "Subscapularis (upper part)", "Medial rotation of arm"],
["Lower subscapular nerve", "C5, C6", "Subscapularis (lower) + Teres major", "Medial rotation + extension"],
["Medial pectoral nerve", "C8, T1", "Pectoralis major (sternal) + Pectoralis minor", "Arm adduction + scapula depression"],
["Lateral pectoral nerve", "C5, C6, C7", "Pectoralis major (clavicular head)", "Arm flexion + adduction"],
],
[1600, 900, 2700, 3800]
),
spacer(2),
pageBreak(),
];
// ══════════════════════════════════════════════════════════════════════
// LOWER LIMB
// ══════════════════════════════════════════════════════════════════════
const lowerLimbIntro = [
heading1("PART II: LOWER LIMB"),
spacer(),
bodyPara("The lower limb is supplied by the LUMBOSACRAL PLEXUS:"),
bulletPara("Lumbar plexus (L1–L4): Femoral nerve, Obturator nerve, and smaller branches"),
bulletPara("Sacral plexus (L4–S3): Sciatic nerve (Tibial + Common Peroneal), Superior & Inferior Gluteal nerves, Pudendal nerve"),
spacer(2),
];
// 1. Femoral
const femoralNerve = [
heading2("1. Femoral Nerve (L2, L3, L4)"),
spacer(),
bodyPara("Origin: Lumbar plexus. Largest branch. Passes beneath inguinal ligament (lateral to femoral artery). Supplies anterior thigh."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action", "Note"],
[
["1", "Iliacus", "Hip flexion", "Joined by psoas — iliopsoas most powerful hip flexor"],
["2", "Psoas major (partial)", "Hip flexion + lumbar spine stabilization", "Also direct lumbar branches L1–L3"],
["3", "Sartorius", "Hip flexion + lateral rotation; knee flexion", "Longest muscle in body; 'tailor's muscle'"],
["4", "Pectineus", "Hip flexion + adduction", "Also partial obturator supply"],
["5", "Rectus femoris", "Hip flexion + knee extension", "Only quadriceps crossing both hip & knee"],
["6", "Vastus lateralis", "Knee extension", "Largest quadriceps; site of IM injections"],
["7", "Vastus medialis", "Knee extension + patellar stabilization", "VMO important in patellofemoral rehab"],
["8", "Vastus intermedius", "Knee extension", "Deep to rectus femoris"],
],
[500, 2000, 2800, 2700]
),
spacer(),
noteBox("Injury result: Loss of knee extension; absent knee jerk reflex (L3/L4); inability to walk upstairs. Quadriceps wasting prominent."),
spacer(2),
];
// 2. Obturator
const obturatorNerve = [
heading2("2. Obturator Nerve (L2, L3, L4)"),
spacer(),
bodyPara("Origin: Lumbar plexus. Passes through obturator canal. Supplies medial (adductor) compartment of thigh."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Adductor longus", "Hip adduction + slight flexion"],
["2", "Adductor brevis", "Hip adduction + slight flexion"],
["3", "Adductor magnus (adductor part)", "Hip adduction (hamstring part by tibial nerve)"],
["4", "Gracilis", "Hip adduction; knee flexion + medial rotation"],
["5", "Obturator externus", "Lateral rotation of hip"],
["6", "Pectineus (accessory)", "Hip adduction + flexion"],
],
[500, 2800, 5700]
),
spacer(),
noteBox("Mnemonic: 'Adductors = Obturator nerve'. Injury: Weakness of hip adduction; difficulty crossing legs."),
spacer(2),
];
// 3. Superior Gluteal
const supGluteal = [
heading2("3. Superior Gluteal Nerve (L4, L5, S1)"),
spacer(),
bodyPara("Origin: Sacral plexus. Exits greater sciatic foramen above piriformis. Most vulnerable in hip surgery."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Gluteus medius", "Hip abduction + medial rotation; pelvic stabilization during walking"],
["2", "Gluteus minimus", "Hip abduction + medial rotation"],
["3", "Tensor fasciae latae (TFL)", "Hip abduction + medial rotation; steadies knee via IT band"],
],
[500, 2800, 5700]
),
spacer(),
noteBox("Injury result: TRENDELENBURG GAIT — pelvis drops to opposite side when standing on affected leg. 'Waddling gait' if bilateral."),
spacer(2),
];
// 4. Inferior Gluteal
const infGluteal = [
heading2("4. Inferior Gluteal Nerve (L5, S1, S2)"),
spacer(),
bodyPara("Origin: Sacral plexus. Exits below piriformis."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Gluteus maximus", "Powerful hip extension + lateral rotation; rising from sitting, climbing stairs, running"],
],
[500, 2800, 5700]
),
spacer(),
bodyPara("Injury result: Difficulty climbing stairs, rising from sitting. Gluteal fold flattening."),
spacer(2),
];
// 5. Sciatic - hamstrings
const sciaticHamstrings = [
heading2("5. Sciatic Nerve (L4, L5, S1, S2, S3)"),
spacer(),
bodyPara("The largest nerve in the body. Arises from sacral plexus, exits through greater sciatic foramen below piriformis. Divides into Tibial and Common Peroneal (Fibular) nerves usually at apex of popliteal fossa."),
spacer(),
heading3("5A. Muscles in Gluteal Region / Posterior Thigh (before division)"),
spacer(),
makeTable(
["S.No.", "Muscle", "Specific Branch", "Action"],
[
["1", "Biceps femoris — long head", "Tibial division of sciatic", "Knee flexion + lateral rotation of leg"],
["2", "Semitendinosus", "Tibial division of sciatic", "Knee flexion + medial rotation"],
["3", "Semimembranosus", "Tibial division of sciatic", "Knee flexion + medial rotation"],
["4", "Adductor magnus — hamstring part", "Tibial division of sciatic", "Hip extension"],
["5", "Biceps femoris — short head", "Common peroneal division", "Knee flexion"],
],
[500, 2200, 2400, 2900]
),
spacer(2),
];
// 5B Tibial
const tibialNerve = [
heading3("5B. Tibial Nerve (L4, L5, S1, S2, S3)"),
spacer(),
bodyPara("Medial terminal branch of sciatic. Runs through posterior compartment of leg to foot."),
spacer(),
makeTable(
["S.No.", "Muscle", "Action"],
[
["1", "Gastrocnemius (medial & lateral heads)", "Plantarflexion + knee flexion"],
["2", "Soleus", "Plantarflexion (main postural muscle)"],
["3", "Plantaris", "Weak plantarflexion + knee flexion"],
["4", "Popliteus", "'Unlocks' knee (medial rotation of tibia on femur)"],
["5", "Tibialis posterior", "Plantarflexion + inversion (maintains medial arch)"],
["6", "Flexor digitorum longus (FDL)", "Flexion of lateral 4 toes; plantarflexion"],
["7", "Flexor hallucis longus (FHL)", "Flexion of big toe; plantarflexion ('push-off' muscle)"],
],
[500, 2800, 5700]
),
spacer(),
heading3("Tibial Nerve in Foot (via Medial & Lateral Plantar Nerves)"),
spacer(),
makeTable(
["S.No.", "Muscle", "Branch", "Action"],
[
["1", "Abductor hallucis", "Medial plantar", "Abduction + flexion of big toe"],
["2", "Flexor digitorum brevis", "Medial plantar", "Flexion of middle phalanges of toes 2–5"],
["3", "Flexor hallucis brevis", "Medial plantar", "Flexion of big toe MTP"],
["4", "1st Lumbrical", "Medial plantar", "MTP flexion + IP extension of 2nd toe"],
["5", "Quadratus plantae", "Lateral plantar", "Modifies pull of FDL; toe flexion"],
["6", "Lumbricals 2nd–4th", "Lateral plantar", "MTP flexion + IP extension"],
["7", "Abductor digiti minimi", "Lateral plantar", "Abduction of little toe"],
["8", "Flexor digiti minimi brevis", "Lateral plantar", "Flexion of little toe"],
["9", "Adductor hallucis", "Lateral plantar", "Adduction of big toe"],
["10", "All interossei (dorsal & plantar)", "Lateral plantar", "Toe abduction / adduction"],
],
[500, 2200, 1800, 3500]
),
spacer(),
noteBox("Injury result: Loss of plantarflexion, absent ankle jerk (S1/S2); 'claw toes'; loss of push-off in gait. Tarsal tunnel syndrome affects tibial nerve."),
spacer(2),
];
// Common Peroneal
const peronealNerve = [
heading3("5C. Common Peroneal (Fibular) Nerve (L4, L5, S1)"),
spacer(),
bodyPara("Lateral terminal branch of sciatic. Winds around neck of fibula — most vulnerable to compression here. Divides into Deep and Superficial peroneal nerves."),
spacer(),
makeTable(
["S.No.", "Muscle", "Branch", "Action", "Injury Effect"],
[
["1", "Tibialis anterior", "Deep peroneal", "Dorsiflexion + inversion", "FOOT DROP — most characteristic sign"],
["2", "Extensor hallucis longus", "Deep peroneal", "Extension of big toe; dorsiflexion", "Cannot extend big toe"],
["3", "Extensor digitorum longus", "Deep peroneal", "Extension of toes 2–5; dorsiflexion", "Toe drop"],
["4", "Peroneus tertius", "Deep peroneal", "Dorsiflexion + eversion", "Weak dorsiflexion"],
["5", "Extensor digitorum brevis", "Deep peroneal", "Toe extension (proximal)", "Weak toe extension"],
["6", "Extensor hallucis brevis", "Deep peroneal", "Big toe extension", "Weak extension"],
["7", "Peroneus (fibularis) longus", "Superficial peroneal", "Eversion + plantarflexion; maintains transverse arch", "Loss of foot eversion"],
["8", "Peroneus (fibularis) brevis", "Superficial peroneal", "Eversion of foot", "Loss of eversion; ankle instability"],
],
[400, 1800, 1400, 2200, 2200]
),
spacer(),
noteBox("Injury result: FOOT DROP — patient cannot dorsiflex foot; 'high-stepping gait' (steppage gait). Most common peroneal injury = fibula neck fracture / prolonged leg crossing."),
spacer(2),
];
// Other LL nerves
const otherLLNerves = [
heading2("6. Other Nerves of Lower Limb"),
spacer(),
makeTable(
["Nerve", "Root", "Muscle(s) Supplied", "Action / Injury"],
[
["Nerve to obturator internus", "L5, S1", "Obturator internus + Superior gemellus", "Lateral rotation of hip"],
["Nerve to quadratus femoris", "L4, L5, S1", "Quadratus femoris + Inferior gemellus", "Lateral rotation + adduction of hip"],
["Nerve to piriformis", "S1, S2", "Piriformis", "Lateral rotation of hip; 'piriformis syndrome'"],
["Pudendal nerve", "S2, S3, S4", "External urethral & anal sphincters; perineal muscles", "Bladder & bowel continence"],
],
[1800, 900, 2600, 3700]
),
spacer(2),
pageBreak(),
];
// ── CLINICAL SUMMARY ──
const clinicalSummary = [
heading1("PART III: CLINICAL SUMMARY"),
spacer(),
heading2("Nerve Injury Patterns — Quick Reference"),
spacer(),
makeTable(
["Nerve Injured", "Deformity / Sign", "Key Test"],
[
["Musculocutaneous", "Weak elbow flexion and supination", "Biceps reflex absent"],
["Median (wrist)", "'Ape hand' — thenar wasting; loss of opposition", "A-OK sign; pen test"],
["Median (elbow)", "Above + forearm pronators weak; 'pointing index'", "Anterior interosseous test"],
["Ulnar (wrist)", "'Claw hand' (ring & little fingers)", "Froment's sign; card test"],
["Ulnar (elbow)", "Claw hand + FCU + FDP(4,5) weak", "More severe clawing at wrist level"],
["Radial (spiral groove)", "'Wrist drop'; finger extension lost; triceps spared", "Thumbs-up sign fails"],
["Radial (axilla)", "Wrist drop + triceps weakness + loss of elbow extension", "Triceps reflex absent"],
["Axillary", "Deltoid paralysis — loss of abduction; flattened shoulder", "Shoulder ABD < 15°"],
["Long thoracic", "'Winged scapula' on wall push-up", "Push-up / wall push test"],
["Femoral", "Quadriceps paralysis; absent knee jerk", "Cannot extend knee"],
["Obturator", "Weak adduction; difficulty crossing legs", "Adduction against resistance"],
["Superior gluteal", "Trendelenburg gait; waddling (bilateral)", "Trendelenburg test positive"],
["Inferior gluteal", "Weak hip extension; difficulty climbing stairs", "Hip extension against resistance"],
["Common peroneal", "'Foot drop'; steppage gait", "Dorsiflexion absent"],
["Tibial", "Loss of plantarflexion; absent ankle jerk; claw toes", "Stand on tiptoes impossible"],
],
[2000, 2800, 3200]
),
spacer(2),
];
// ── MNEMONICS ──
const mnemonics = [
heading2("Important Mnemonics"),
spacer(),
makeTable(
["Nerve", "Mnemonic", "Stands For"],
[
["Musculocutaneous", "BBC", "Brachialis, Biceps, Coracobrachialis"],
["Median (hand)", "LOAF", "Lumbricals 1&2, Opponens pollicis, Abductor pollicis brevis, Flexor pollicis brevis (superficial)"],
["Ulnar (interossei)", "DAB / PAD", "Dorsal = Abduct; Palmar = Adduct"],
["Radial", "BEST", "Brachioradialis, Extensors (all wrist & finger), Supinator, Triceps"],
["Brachial plexus cords", "MLP", "Medial cord → Ulnar; Lateral cord → Musculocutaneous; Posterior cord → Radial + Axillary"],
["Rotator cuff", "SITS", "Supraspinatus, Infraspinatus, Teres minor, Subscapularis"],
],
[1800, 900, 6300]
),
spacer(2),
pageBreak(),
];
// ── CONCLUSION ──
const conclusion = [
heading1("CONCLUSION"),
spacer(),
bodyPara(
"A thorough knowledge of nerve-wise muscle supply is indispensable for any healthcare professional. By understanding which nerve supplies which muscle, clinicians can:"
),
bulletPara("Accurately diagnose the level and site of a peripheral nerve injury"),
bulletPara("Differentiate between upper motor neuron (UMN) and lower motor neuron (LMN) lesions"),
bulletPara("Plan targeted physiotherapy, NMES, and nerve re-education programs"),
bulletPara("Guide surgical planning for nerve repair, tendon transfers, and joint stabilization"),
bulletPara("Predict functional recovery and establish realistic rehabilitation goals"),
spacer(),
bodyPara(
"In the upper limb, the radial nerve is the 'great extensor nerve', the median nerve is the 'nerve of precision grip', and the ulnar nerve controls the intrinsic fine movements of the hand. In the lower limb, the femoral nerve is critical for knee extension and ambulation, while the sciatic nerve and its branches govern all ankle and foot movements. Injury to any of these nerves results in characteristic, predictable deficits that form the basis of clinical neurological examination."
),
spacer(2),
pageBreak(),
];
// ── REFERENCES ──
const references = [
heading1("REFERENCES"),
spacer(),
bodyPara("1. Standring S. (Ed.). Gray's Anatomy: The Anatomical Basis of Clinical Practice. 41st ed. Elsevier; 2015."),
bodyPara("2. Moore KL, Dalley AF, Agur AMR. Clinically Oriented Anatomy. 8th ed. Wolters Kluwer; 2017."),
bodyPara("3. Sinnatamby CS. Last's Anatomy: Regional and Applied. 12th ed. Churchill Livingstone; 2011."),
bodyPara("4. THIEME Atlas of Anatomy: General Anatomy and Musculoskeletal System. 3rd ed. Thieme; 2020."),
bodyPara("5. Rosen's Emergency Medicine: Concepts and Clinical Practice. 9th ed. Elsevier; 2018."),
bodyPara("6. Aids to the Examination of the Peripheral Nervous System. 5th ed. Saunders; 2010."),
spacer(2),
];
// ─── ASSEMBLE DOCUMENT ────────────────────────────────────────────────
const allContent = [
...titlePage,
...introduction,
...upperLimbIntro,
...musculocutaneous,
...medianNerve,
...ulnarNerve,
...radialNerve,
...axillaryNerve,
...suprascapularNerve,
...otherULNerves,
...lowerLimbIntro,
...femoralNerve,
...obturatorNerve,
...supGluteal,
...infGluteal,
...sciaticHamstrings,
...tibialNerve,
...peronealNerve,
...otherLLNerves,
...clinicalSummary,
...mnemonics,
...conclusion,
...references,
];
const doc = new Document({
styles: {
default: {
document: {
run: { font: "Calibri", size: 20, color: "000000" },
paragraph: { spacing: { line: 276 } },
},
},
},
sections: [
{
headers: {
default: new Header({
children: [
new Paragraph({
children: [
new TextRun({ text: "Nerve-wise Muscle Supply: Upper & Lower Limb", bold: true, size: 18, color: MED_BLUE }),
new TextRun({ text: "\t\t", size: 18 }),
new TextRun({ text: "Assignment", size: 18, color: "888888" }),
],
border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: MED_BLUE } },
tabStops: [{ type: "right", position: 9000 }],
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
children: [
new TextRun({ text: "Anatomy / Kinesiology | ", size: 16, color: "888888" }),
new TextRun({ text: "Peripheral Nerve Innervation", size: 16, color: "888888" }),
new TextRun({ text: "\t\tPage ", size: 16, color: "888888" }),
new PageNumber(),
],
border: { top: { style: BorderStyle.SINGLE, size: 4, color: MED_BLUE } },
tabStops: [{ type: "right", position: 9000 }],
}),
],
}),
},
children: allContent,
},
],
});
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync("/home/daytona/workspace/nerve-assignment/Nerve_Muscle_Supply_Assignment.docx", buffer);
console.log("SUCCESS: File written.");
}).catch(err => {
console.error("ERROR:", err);
process.exit(1);
});