Organize well answer for university exam high yeild 10 marks long answer As m pharm student write Easy language ma hooi but also maintain formal language.. easy to understand and write in exam. ….. Definition 1. Classification table 2. Mechanism of each type 3. Examples 4. Pharmacological management 5. Draw the Type I hypersensitivity flowchart 6. End with a one-line conclusion on the clinical importance of hypersensitivity reactions. Questions: Classify hypersensitivity reactions and explain the mechanism, mediators, and examples of each type. Discuss the types of hypersensitivity reactions with suitable examples and pharmacological management. Differentiate Type I, II, III, and IV hypersensitivity Explain Type I (Immediate) hypersensitivity. Explain mediators involved in hypersensitivity reactions.

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Finding Sources
Finding Sources
Loading Image
I have all the information I need. Now I'll write the complete, well-organized exam answer.

HYPERSENSITIVITY REACTIONS

Classification, Mechanism, Mediators, Examples & Pharmacological Management

[M. Pharm | Immunopharmacology / Pharmacology | 10 Marks Long Answer]

DEFINITION

Hypersensitivity is defined as an exaggerated or augmented immune response to an antigen (allergen) that is harmful to the host. It requires a presensitized state - meaning the individual must first be exposed to the antigen (sensitization), and the harmful response occurs upon second or subsequent exposure to the same antigen.
"Hypersensitivity responses lead to tissue damage: immunopathology. The mechanisms underlying them are the same as those normally employed by the body in combating infection - the problem is they occur with too high an intensity, directed against antigens that pose no threat." - Roitt's Essential Immunology

1. CLASSIFICATION TABLE

Classified by Gell and Coombs (1963)
FeatureType I (Immediate)Type II (Cytotoxic)Type III (Immune Complex)Type IV (Delayed/Cell-Mediated)
Other NameAnaphylactic / AtopicAntibody-Dependent CytotoxicImmune Complex-MediatedDelayed-Type Hypersensitivity (DTH)
ImmunoglobulinIgEIgG, IgMIgG, IgMNone (T-cell mediated)
Effector MechanismMast cell degranulationComplement + ADCCComplement activation + neutrophil recruitmentT-lymphocytes + Macrophages
Onset TimeSeconds to minutesMinutes to hours6-12 hours48-72 hours
Key CellsMast cells, Basophils, EosinophilsNK cells, Macrophages, NeutrophilsNeutrophils, MacrophagesCD4+ Th1 cells, CD8+ T cells, Macrophages
ComplementNot involvedInvolvedInvolvedNot involved
MediatorsHistamine, Leukotrienes, ProstaglandinsComplement fragments (C3b, MAC)C5a, C3a, Lysosomal enzymesIFN-γ, IL-2, TNF-β
ExampleAnaphylaxis, Asthma, Hay feverHemolytic anemia, ABO transfusion reactionSLE, Post-streptococcal GN, Serum sicknessContact dermatitis, Tuberculin test, Graft rejection

2. MECHANISM OF EACH TYPE

Type I - Immediate (IgE-Mediated) Hypersensitivity

Step-by-step mechanism:
Phase 1 - Sensitization:
  1. Allergen (e.g., pollen, penicillin) enters the body for the first time
  2. Antigen-presenting cells (APCs) present the antigen to Th2 cells
  3. Th2 cells release IL-4 and IL-13, which stimulate B cells to switch to IgE production
  4. IgE antibodies bind by their Fc portion to high-affinity FcεRI receptors on mast cells and basophils
  5. Patient is now sensitized (no symptoms yet)
Phase 2 - Elicitation (on re-exposure):
  1. Same allergen enters again and cross-links two or more IgE molecules on the surface of mast cells
  2. This cross-linking triggers mast cell degranulation
  3. Preformed mediators (histamine, tryptase) are released immediately
  4. Newly synthesized mediators (leukotrienes, prostaglandins) are formed from arachidonic acid within minutes

Type II - Cytotoxic (Antibody-Dependent) Hypersensitivity

Mechanism:
  1. IgG or IgM antibodies are directed against cell-surface antigens or antigens on extracellular matrix
  2. Antibody binding activates complement via classical pathway, producing MAC (membrane attack complex) → cell lysis
  3. Cells coated with IgG are also destroyed by:
    • ADCC (Antibody-Dependent Cellular Cytotoxicity): NK cells and macrophages with FcγR bind and kill the target cell
    • Opsonization: C3b-coated cells are phagocytosed by macrophages
  4. Drugs (e.g., penicillin) can haptenize red blood cells, triggering antibody formation against drug-RBC complex → hemolysis
  5. In some cases (e.g., Graves' disease), antibodies to cell-surface receptors stimulate or block function without causing lysis - sometimes called Type V

Type III - Immune Complex-Mediated Hypersensitivity

Mechanism:
  1. Antigen-antibody (IgG/IgM) complexes form in excess in circulation
  2. Normally, immune complexes are cleared by phagocytes, but when they persist, they deposit in tissues (glomeruli, joints, blood vessel walls)
  3. Deposited immune complexes activate complement → C3a and C5a (anaphylatoxins)
  4. C5a is a potent chemoattractant, recruiting neutrophils to the site
  5. Neutrophils release lysosomal enzymes and reactive oxygen speciestissue damage and inflammation
  6. Leads to vasculitis, nephritis, arthritis
Two subtypes:
  • Arthus reaction (local): IgG + injected antigen → local complement activation (12 hours)
  • Serum sickness (systemic): Large antigen excess → systemic immune complex deposition (6-12 hours)

Type IV - Delayed-Type (Cell-Mediated) Hypersensitivity

Mechanism:
  1. No antibody involved - purely T-cell mediated
  2. On first exposure, antigen is processed by APCs (Langerhans cells in skin) and presented to CD4+ Th1 cells via MHC Class II
  3. Th1 cells become sensitized and memory T cells form
  4. On re-exposure (48-72 hours later), antigen is re-presented to sensitized T cells
  5. Activated Th1 cells release cytokines: IFN-γ, IL-2, TNF-β
  6. IFN-γ activates macrophages, which release more TNF and lysosomal enzymes
  7. Results in granuloma formation, tissue induration, and necrosis
Subtypes of Type IV:
  • Contact hypersensitivity - chemicals (nickel, urushiol from poison ivy) act as haptens
  • Tuberculin-type - tuberculin test (positive = induration in 24-72 hrs)
  • Granulomatous - chronic macrophage activation (e.g., tuberculosis, leprosy)

3. MEDIATORS TABLE

TypePreformed MediatorsNewly Formed / Secondary Mediators
Type IHistamine, Tryptase, Heparin, Eosinophil Chemotactic FactorLeukotrienes (LTC4, LTD4, LTE4), Prostaglandins (PGD2), PAF, TNF-α, IL-4
Type II-Complement fragments (C3b, C5a, MAC), Perforin/Granzymes (ADCC)
Type III-C3a, C5a (anaphylatoxins), Lysosomal enzymes, Reactive oxygen species
Type IV-IFN-γ, IL-2, TNF-β, IL-17, Macrophage activating factor (MAF)

4. EXAMPLES (DISEASE-WISE)

DiseaseType
Anaphylaxis (bee sting, penicillin)Type I
Bronchial AsthmaType I
Hay Fever (Allergic Rhinitis)Type I
Atopic Dermatitis (Eczema)Type I
Hemolytic Transfusion Reaction (ABO mismatch)Type II
Rh hemolytic disease of newbornType II
Autoimmune Hemolytic AnemiaType II
Goodpasture SyndromeType II
Graves' Disease (TSH receptor antibody)Type II (V)
Myasthenia Gravis (AChR antibody)Type II (V)
Systemic Lupus Erythematosus (SLE)Type III
Post-streptococcal GlomerulonephritisType III
Serum SicknessType III
Arthus ReactionType III
Contact Dermatitis (poison ivy, nickel)Type IV
Tuberculin (Mantoux) TestType IV
Graft Rejection (allograft)Type IV
Leprosy (tuberculoid), TBType IV

5. PHARMACOLOGICAL MANAGEMENT

Type I Hypersensitivity - Management

Drug ClassDrug NameMechanism of ActionClinical Use
First-line (Anaphylaxis)Epinephrine (Adrenaline)Activates α1 (vasoconstriction) and β2 (bronchodilation) receptors; reverses bronchoconstriction and hypotensionSevere anaphylaxis - IM injection
H1 AntihistaminesDiphenhydramine, Cetirizine, LoratadineCompetitive block of H1 receptors; reduces vasodilation, pruritus, urticariaAllergic rhinitis, urticaria, mild allergy
CorticosteroidsPrednisolone, Dexamethasone, HydrocortisoneInhibit phospholipase A2 → block arachidonic acid cascade → reduces leukotrienes + prostaglandins; suppress cytokine productionSevere allergy, asthma, late-phase reaction
Leukotriene Receptor Antagonists (LTRA)Montelukast, ZafirlukastBlock cysteinyl leukotriene (CysLT1) receptors → reduce bronchoconstriction and mucus secretionBronchial asthma, allergic rhinitis
Mast Cell StabilizersSodium Cromoglycate, NedocromilPrevent mast cell degranulation by blocking chloride channels → inhibit release of histamine and other mediatorsProphylaxis in asthma, allergic rhinitis
β2-AgonistsSalbutamol, FormoterolBronchodilation by activating β2 receptors on bronchial smooth muscleAcute asthma attack
XanthinesTheophyllineInhibit phosphodiesterase → increase cAMP → bronchodilation + mast cell stabilizationChronic asthma
Monoclonal AntibodyOmalizumab (anti-IgE)Binds free IgE → prevents IgE binding to FcεRI on mast cells → no degranulationSevere allergic asthma, chronic urticaria
ImmunotherapyAllergen desensitizationRepeated low-dose allergen exposure shifts Th2 → Th1, increases IgG4 (blocking antibody), reduces IgELong-term allergy treatment

Type II Hypersensitivity - Management

Drug / ApproachMechanism
Corticosteroids (Prednisolone)Suppress antibody production and complement activation
Plasma exchange (Plasmapheresis)Removes circulating autoantibodies and immune complexes
IVIG (Intravenous Immunoglobulin)Saturates FcRn receptors → faster degradation of pathogenic IgG
Rituximab (anti-CD20)Depletes B cells → reduces antibody production
Supportive: Blood transfusion for hemolytic anemiaReplace destroyed RBCs

Type III Hypersensitivity - Management

Drug / ApproachMechanism
CorticosteroidsSuppress inflammation, inhibit complement activation and neutrophil function
NSAIDsRelieve joint pain and inflammation (COX inhibition)
PlasmapheresisRemove immune complexes from circulation
Hydroxychloroquine (in SLE)Inhibits Toll-like receptor signaling → reduces immune complex deposition
Immunosuppressants (Azathioprine, Cyclophosphamide, Mycophenolate)Reduce B and T cell activity; first-line in SLE nephritis
Anti-TNF agents (in vasculitis)Block TNF-mediated inflammation
Antigen removalTreat underlying infection (e.g., antibiotics for post-streptococcal GN)

Type IV Hypersensitivity - Management

Drug / ApproachMechanism
Corticosteroids (topical + systemic)Suppress T-cell activation; reduce cytokine release and macrophage activation - first-line for contact dermatitis
Calcineurin Inhibitors (Tacrolimus, Cyclosporine)Block calcineurin → inhibit IL-2 transcription → suppress T-cell proliferation; used in contact dermatitis and organ transplant rejection
Anti-TNF biologics (Infliximab, Adalimumab)Block TNF-α → reduce macrophage activation and granuloma formation
DapsoneAnti-inflammatory; used in leprosy (Type IV component)
Antituberculosis drugsTreat the cause of Type IV granuloma in TB
Avoidance of antigenFundamental approach in contact hypersensitivity

6. TYPE I HYPERSENSITIVITY - FLOWCHART

┌─────────────────────────────────────────────────────────┐
│              TYPE I HYPERSENSITIVITY FLOWCHART          │
│             (IgE-Mediated / Immediate Type)             │
└─────────────────────────────────────────────────────────┘

         ┌──────────────────────────────────────┐
         │   FIRST EXPOSURE TO ALLERGEN          │
         │ (Pollen, Dust mite, Penicillin, Food) │
         └────────────────┬─────────────────────┘
                          │
                          ▼
         ┌──────────────────────────────────┐
         │  Allergen → APCs present to      │
         │   Th2 cells                      │
         └─────────────────┬────────────────┘
                           │
                           ▼
         ┌─────────────────────────────────────────┐
         │  Th2 cells secrete IL-4 and IL-13        │
         │  → B cells undergo class switching       │
         │  → B cells produce IgE antibodies        │
         └──────────────────┬──────────────────────┘
                            │
                            ▼
         ┌────────────────────────────────────────────┐
         │  IgE binds to FcεRI receptors on           │
         │  MAST CELLS and BASOPHILS                  │
         │  (Patient is now SENSITIZED - no symptoms) │
         └─────────────────┬──────────────────────────┘
                           │
         ═══════════════════════════════════
              SECOND EXPOSURE TO ALLERGEN
         ═══════════════════════════════════
                           │
                           ▼
         ┌────────────────────────────────────────────┐
         │  Allergen CROSS-LINKS two IgE molecules    │
         │  on the surface of mast cells              │
         └──────────────────┬─────────────────────────┘
                            │
                            ▼
         ┌──────────────────────────────────────────────────┐
         │         MAST CELL DEGRANULATION                  │
         └─────────────┬──────────────────┬─────────────────┘
                       │                  │
             ┌─────────▼──────┐   ┌───────▼──────────────┐
             │ PREFORMED      │   │  NEWLY FORMED         │
             │ MEDIATORS      │   │  MEDIATORS            │
             │ (Released      │   │  (Synthesized from    │
             │  immediately)  │   │   Arachidonic acid)   │
             │                │   │                       │
             │ • Histamine    │   │ • Leukotrienes        │
             │ • Tryptase     │   │   (LTC4, LTD4, LTE4) │
             │ • Heparin      │   │ • Prostaglandin D2    │
             │ • ECF-A        │   │ • PAF                 │
             │   (Eosinophil  │   │ • TNF-α, IL-4         │
             │  Chemo Factor) │   │                       │
             └──────┬─────────┘   └───────┬───────────────┘
                    │                     │
                    └──────────┬──────────┘
                               ▼
         ┌─────────────────────────────────────────────────────┐
         │               CLINICAL EFFECTS                      │
         ├─────────────────────────────────────────────────────┤
         │  Histamine → Vasodilation, Edema, Bronchospasm,    │
         │               Pruritus, Urticaria                   │
         │  Leukotrienes → Bronchoconstriction, Mucus↑        │
         │  PGD2 → Vasodilation, Bronchospasm                 │
         │  PAF → Platelet aggregation, Bronchospasm          │
         └───────────────────┬─────────────────────────────────┘
                             │
               ┌─────────────┴──────────────┐
               ▼                            ▼
   ┌──────────────────────┐    ┌───────────────────────────┐
   │  LOCAL REACTION       │    │   SYSTEMIC REACTION       │
   │  (Atopy)              │    │   (Anaphylaxis)           │
   │                       │    │                           │
   │ • Hay fever           │    │ • Hypotension             │
   │ • Asthma              │    │ • Laryngeal edema         │
   │ • Urticaria           │    │ • Bronchospasm            │
   │ • Eczema              │    │ • Cardiovascular collapse │
   │ • Food allergy        │    │ • Can be FATAL            │
   └───────────────────────┘    └───────────────────────────┘
Visual reference from Roitt's Essential Immunology (6 types of hypersensitivity):
Six categories of hypersensitivity - Gell and Coombs classification showing Type I (IgE/mast cell), Type II (ADCC), Type III (immune complex), Type IV (T-cell/cytokines), Type V (stimulatory), and Innate
Figure: The Gell and Coombs Classification - Types I to IV (+ Type V and Innate). Source: Roitt's Essential Immunology, 13th Edition.

DIFFERENTIATION TABLE (Quick Comparison for Exam)

ParameterType IType IIType IIIType IV
AntibodyIgEIgG/IgMIgG/IgMNone
ComplementNoYesYesNo
Cells involvedMast cell, BasophilNK cell, MacrophageNeutrophilT-cell, Macrophage
OnsetSeconds - minutesMinutes6-12 hours48-72 hours
Passive transfer possible bySerum (IgE)Serum (IgG)Serum (IgG)Cells (T cells)
Skin test reactionWheal and flare (immediate)-Arthus (6 hrs)Induration (48-72 hrs)
Characteristic diseaseAnaphylaxisHemolytic anemiaSLEContact dermatitis
HistopathologyMast cell degranulationCell lysis, opsonizationNeutrophilic infiltrateMononuclear infiltrate, granuloma

CONCLUSION

Hypersensitivity reactions represent a spectrum of immune-mediated tissue damage with distinct mechanisms, mediators, and clinical presentations - their understanding is clinically indispensable for the rational selection of pharmacological agents, from epinephrine in anaphylaxis to calcineurin inhibitors in delayed-type hypersensitivity, and forms the immunological basis for treating allergic, autoimmune, and inflammatory diseases in clinical practice.

References:
  • Jawetz, Melnick & Adelberg's Medical Microbiology, 28th Edition - Hypersensitivity (pp. 150-153)
  • Roitt's Essential Immunology, 13th Edition - Chapter 14: Allergy and Other Hypersensitivities
  • Janeway's Immunobiology, 10th Edition - Chapter 14: Allergic Diseases and Hypersensitivity Reactions
  • Goodman & Gilman's The Pharmacological Basis of Therapeutics
  • Katzung's Basic and Clinical Pharmacology, 16th Edition

Generate a DOCX summary of this answer for printing and revision

Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/hypersensitivity && ls /home/daytona/workspace/hypersensitivity

Writing File

~/hypersensitivity/generate.js

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

// ─── Colour palette ────────────────────────────────────────────────
const BLUE_DARK   = "1F3864";   // deep navy – headings
const BLUE_MID    = "2E5EA6";   // medium blue – sub-headings
const BLUE_LIGHT  = "D6E4F0";   // pale blue – table header fill
const TEAL        = "1D7874";   // teal accent
const YELLOW_BG   = "FFF9C4";   // soft yellow – definition box
const WHITE       = "FFFFFF";
const GRAY_LIGHT  = "F2F2F2";   // alternating table row
const BLACK       = "000000";

// ─── Numbering config ──────────────────────────────────────────────
const numberingConfig = [
  {
    reference: "bullets",
    levels: [{
      level: 0, format: LevelFormat.BULLET, text: "\u2022",
      alignment: AlignmentType.LEFT,
      style: {
        paragraph: { indent: { left: 360, hanging: 180 }, spacing: { after: 60 } },
        run: { font: "Arial", size: 20 }
      }
    }]
  },
  {
    reference: "numbered",
    levels: [{
      level: 0, format: LevelFormat.DECIMAL, text: "%1.",
      alignment: AlignmentType.LEFT,
      style: {
        paragraph: { indent: { left: 360, hanging: 240 }, spacing: { after: 60 } },
        run: { font: "Arial", size: 20 }
      }
    }]
  }
];

// ─── Helper functions ──────────────────────────────────────────────

function h1(text) {
  return new Paragraph({
    heading: HeadingLevel.HEADING_1,
    children: [new TextRun({ text, font: "Arial", size: 32, bold: true, color: WHITE })],
    shading: { type: ShadingType.SOLID, color: BLUE_DARK, fill: BLUE_DARK },
    spacing: { before: 300, after: 160 },
    indent: { left: 120, right: 120 }
  });
}

function h2(text) {
  return new Paragraph({
    heading: HeadingLevel.HEADING_2,
    children: [new TextRun({ text, font: "Arial", size: 26, bold: true, color: WHITE })],
    shading: { type: ShadingType.SOLID, color: BLUE_MID, fill: BLUE_MID },
    spacing: { before: 240, after: 120 },
    indent: { left: 80 }
  });
}

function h3(text) {
  return new Paragraph({
    children: [new TextRun({ text, font: "Arial", size: 22, bold: true, color: BLUE_DARK, underline: {} })],
    spacing: { before: 200, after: 80 }
  });
}

function h4(text) {
  return new Paragraph({
    children: [new TextRun({ text, font: "Arial", size: 21, bold: true, color: TEAL })],
    spacing: { before: 140, after: 60 }
  });
}

function para(text, options = {}) {
  return new Paragraph({
    children: [new TextRun({ text, font: "Arial", size: 20, color: BLACK, ...options })],
    spacing: { after: 100 }
  });
}

function bullet(text) {
  return new Paragraph({
    numbering: { reference: "bullets", level: 0 },
    children: [new TextRun({ text, font: "Arial", size: 20, color: BLACK })],
    spacing: { after: 60 }
  });
}

function numberedItem(text) {
  return new Paragraph({
    numbering: { reference: "numbered", level: 0 },
    children: [new TextRun({ text, font: "Arial", size: 20, color: BLACK })],
    spacing: { after: 60 }
  });
}

function boldPara(text, rest = "") {
  return new Paragraph({
    children: [
      new TextRun({ text, font: "Arial", size: 20, bold: true, color: BLUE_DARK }),
      new TextRun({ text: rest, font: "Arial", size: 20, color: BLACK })
    ],
    spacing: { after: 80 }
  });
}

function spacer(pts = 120) {
  return new Paragraph({ children: [new TextRun("")], spacing: { after: pts } });
}

function pageBreak() {
  return new Paragraph({ children: [new PageBreak()] });
}

// Highlighted box (definition / conclusion)
function boxPara(text, fillColor = YELLOW_BG) {
  return new Paragraph({
    children: [new TextRun({ text, font: "Arial", size: 20, color: BLACK })],
    shading: { type: ShadingType.SOLID, color: fillColor, fill: fillColor },
    indent: { left: 180, right: 180 },
    spacing: { before: 80, after: 80 },
    border: {
      top: { style: BorderStyle.SINGLE, size: 4, color: TEAL },
      bottom: { style: BorderStyle.SINGLE, size: 4, color: TEAL },
      left: { style: BorderStyle.THICK, size: 8, color: TEAL },
      right: { style: BorderStyle.SINGLE, size: 4, color: TEAL }
    }
  });
}

// Table cell helpers
function hdrCell(text, width, options = {}) {
  return new TableCell({
    width: { size: width, type: WidthType.DXA },
    shading: { type: ShadingType.SOLID, color: BLUE_DARK, fill: BLUE_DARK },
    verticalAlign: VerticalAlign.CENTER,
    children: [new Paragraph({
      children: [new TextRun({ text, font: "Arial", size: 18, bold: true, color: WHITE })],
      alignment: AlignmentType.CENTER
    })],
    ...options
  });
}

function subHdrCell(text, width) {
  return new TableCell({
    width: { size: width, type: WidthType.DXA },
    shading: { type: ShadingType.SOLID, color: BLUE_MID, fill: BLUE_MID },
    verticalAlign: VerticalAlign.CENTER,
    children: [new Paragraph({
      children: [new TextRun({ text, font: "Arial", size: 17, bold: true, color: WHITE })],
      alignment: AlignmentType.CENTER
    })]
  });
}

function dataCell(text, width, fill = WHITE, bold = false) {
  return new TableCell({
    width: { size: width, type: WidthType.DXA },
    shading: { type: ShadingType.SOLID, color: fill, fill },
    verticalAlign: VerticalAlign.CENTER,
    children: [new Paragraph({
      children: [new TextRun({ text, font: "Arial", size: 18, color: BLACK, bold })],
      spacing: { after: 40 }
    })]
  });
}

function tableNoBorder(rows) {
  return new Table({
    width: { size: 9026, type: WidthType.DXA },
    borders: {
      top: { style: BorderStyle.SINGLE, size: 2, color: "AAAAAA" },
      bottom: { style: BorderStyle.SINGLE, size: 2, color: "AAAAAA" },
      left: { style: BorderStyle.SINGLE, size: 2, color: "AAAAAA" },
      right: { style: BorderStyle.SINGLE, size: 2, color: "AAAAAA" },
      insideH: { style: BorderStyle.SINGLE, size: 1, color: "CCCCCC" },
      insideV: { style: BorderStyle.SINGLE, size: 1, color: "CCCCCC" }
    },
    rows
  });
}

// ─── Document content ──────────────────────────────────────────────

const doc = new Document({
  numbering: { config: numberingConfig },
  styles: {
    default: {
      document: { run: { font: "Arial", size: 20, color: BLACK } }
    },
    paragraphStyles: [
      { id: "Heading1", name: "Heading 1", basedOn: "Normal", next: "Normal", quickFormat: true,
        run: { font: "Arial", size: 32, bold: true, color: WHITE },
        paragraph: { spacing: { before: 300, after: 160 }, outlineLevel: 0 } },
      { id: "Heading2", name: "Heading 2", basedOn: "Normal", next: "Normal", quickFormat: true,
        run: { font: "Arial", size: 26, bold: true, color: WHITE },
        paragraph: { spacing: { before: 240, after: 120 }, outlineLevel: 1 } }
    ]
  },
  sections: [{
    properties: {
      page: {
        size: { width: 11906, height: 16838 }, // A4
        margin: { top: 1080, right: 1080, bottom: 1080, left: 1080 }
      }
    },
    headers: {
      default: new Header({
        children: [
          new Paragraph({
            children: [
              new TextRun({ text: "HYPERSENSITIVITY REACTIONS  |  M. Pharm Exam Revision", font: "Arial", size: 16, color: BLUE_MID, bold: true }),
            ],
            alignment: AlignmentType.CENTER,
            border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: BLUE_LIGHT } }
          })
        ]
      })
    },
    footers: {
      default: new Footer({
        children: [
          new Paragraph({
            children: [
              new TextRun({ text: "Sources: Jawetz Medical Microbiology 28e | Roitt's Essential Immunology 13e | Janeway's Immunobiology 10e  |  Page ", font: "Arial", size: 14, color: "888888" }),
              new TextRun({ children: [PageNumber.CURRENT], font: "Arial", size: 14, color: "888888" }),
              new TextRun({ text: " of ", font: "Arial", size: 14, color: "888888" }),
              new TextRun({ children: [PageNumber.TOTAL_PAGES], font: "Arial", size: 14, color: "888888" })
            ],
            alignment: AlignmentType.CENTER,
            border: { top: { style: BorderStyle.SINGLE, size: 2, color: BLUE_LIGHT } }
          })
        ]
      })
    },
    children: [

      // ══════════════════════════════════════════
      // TITLE BLOCK
      // ══════════════════════════════════════════
      new Paragraph({
        children: [new TextRun({ text: "HYPERSENSITIVITY REACTIONS", font: "Arial", size: 44, bold: true, color: WHITE })],
        shading: { type: ShadingType.SOLID, color: BLUE_DARK, fill: BLUE_DARK },
        alignment: AlignmentType.CENTER,
        spacing: { before: 0, after: 0 },
        indent: { left: 0, right: 0 },
        border: {
          top: { style: BorderStyle.THICK, size: 12, color: TEAL },
          bottom: { style: BorderStyle.THICK, size: 12, color: TEAL }
        }
      }),
      new Paragraph({
        children: [new TextRun({ text: "Classification | Mechanism | Mediators | Examples | Pharmacological Management", font: "Arial", size: 22, color: BLUE_DARK, italics: true })],
        alignment: AlignmentType.CENTER,
        shading: { type: ShadingType.SOLID, color: BLUE_LIGHT, fill: BLUE_LIGHT },
        spacing: { before: 0, after: 0 }
      }),
      new Paragraph({
        children: [new TextRun({ text: "M. Pharm  |  Immunopharmacology & Pharmacology  |  10 Marks Long Answer", font: "Arial", size: 19, color: "555555" })],
        alignment: AlignmentType.CENTER,
        spacing: { before: 100, after: 200 }
      }),

      // ══════════════════════════════════════════
      // DEFINITION
      // ══════════════════════════════════════════
      h1("DEFINITION"),
      boxPara("Hypersensitivity is defined as an exaggerated or augmented immune response to an antigen (allergen) that is harmful to the host. It requires a presensitized state — the harmful response occurs upon second or subsequent exposure to the same antigen."),
      spacer(80),
      boldPara("Classified by: ", "Gell and Coombs (1963) into 4 types: Type I, II, III (antibody-mediated) and Type IV (T-cell mediated)."),
      spacer(100),

      // ══════════════════════════════════════════
      // CLASSIFICATION TABLE
      // ══════════════════════════════════════════
      h1("1. CLASSIFICATION TABLE — Gell and Coombs"),
      spacer(80),

      tableNoBorder([
        // Header row
        new TableRow({
          tableHeader: true,
          children: [
            hdrCell("Feature", 1200),
            hdrCell("Type I\n(Immediate)", 1700),
            hdrCell("Type II\n(Cytotoxic)", 1700),
            hdrCell("Type III\n(Immune Complex)", 1950),
            hdrCell("Type IV\n(Delayed / DTH)", 1976)
          ]
        }),
        // Data rows
        new TableRow({ children: [subHdrCell("Other Name", 1200), dataCell("Anaphylactic / Atopic", 1700, GRAY_LIGHT), dataCell("Antibody-Dependent Cytotoxic", 1700, GRAY_LIGHT), dataCell("Immune Complex-Mediated", 1950, GRAY_LIGHT), dataCell("Delayed-Type Hypersensitivity", 1976, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Immunoglobulin", 1200), dataCell("IgE", 1700), dataCell("IgG, IgM", 1700), dataCell("IgG, IgM", 1950), dataCell("None (T-cell mediated)", 1976)] }),
        new TableRow({ children: [subHdrCell("Effector", 1200), dataCell("Mast cell degranulation", 1700, GRAY_LIGHT), dataCell("Complement + ADCC", 1700, GRAY_LIGHT), dataCell("Complement + Neutrophils", 1950, GRAY_LIGHT), dataCell("CD4+ Th1 + Macrophages", 1976, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Onset", 1200), dataCell("Seconds–minutes", 1700), dataCell("Minutes–hours", 1700), dataCell("6–12 hours", 1950), dataCell("48–72 hours", 1976)] }),
        new TableRow({ children: [subHdrCell("Complement", 1200), dataCell("Not involved", 1700, GRAY_LIGHT), dataCell("Involved", 1700, GRAY_LIGHT), dataCell("Involved", 1950, GRAY_LIGHT), dataCell("Not involved", 1976, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Key Mediators", 1200), dataCell("Histamine, Leukotrienes, PGD2", 1700), dataCell("C3b, MAC, Perforin", 1700), dataCell("C3a, C5a, Lysosomal enzymes", 1950), dataCell("IFN-γ, IL-2, TNF-β", 1976)] }),
        new TableRow({ children: [subHdrCell("Classic Example", 1200), dataCell("Anaphylaxis, Asthma", 1700, GRAY_LIGHT), dataCell("Hemolytic anemia, ABO reaction", 1700, GRAY_LIGHT), dataCell("SLE, Serum sickness", 1950, GRAY_LIGHT), dataCell("Contact dermatitis, Tuberculin test", 1976, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Skin Test", 1200), dataCell("Wheal & flare (immediate)", 1700), dataCell("—", 1700), dataCell("Arthus (6 hrs)", 1950), dataCell("Induration (48–72 hrs)", 1976)] })
      ]),
      spacer(160),
      pageBreak(),

      // ══════════════════════════════════════════
      // MECHANISMS
      // ══════════════════════════════════════════
      h1("2. MECHANISM OF EACH TYPE"),
      spacer(80),

      // TYPE I
      h2("Type I — Immediate (IgE-Mediated) Hypersensitivity"),
      h3("Phase 1: Sensitization (First Exposure)"),
      numberedItem("Allergen (pollen, penicillin, dust mite) enters the body for the first time"),
      numberedItem("APCs present antigen to Th2 cells → Th2 cells release IL-4 and IL-13"),
      numberedItem("B cells undergo class-switching → produce IgE antibodies"),
      numberedItem("IgE binds by its Fc portion to high-affinity FcεRI receptors on mast cells and basophils"),
      numberedItem("Patient is now SENSITIZED — no clinical symptoms yet"),
      h3("Phase 2: Elicitation (Re-exposure)"),
      numberedItem("Same allergen cross-links two or more IgE molecules on mast cell surface"),
      numberedItem("Cross-linking triggers MAST CELL DEGRANULATION"),
      numberedItem("Preformed mediators (histamine, tryptase, heparin) are released immediately"),
      numberedItem("Newly formed mediators (leukotrienes, prostaglandins, PAF) are synthesized from arachidonic acid"),
      numberedItem("Results in: vasodilation, bronchospasm, increased vascular permeability, pruritus"),
      spacer(80),

      // Mediators table
      h4("Mediators of Type I Hypersensitivity"),
      tableNoBorder([
        new TableRow({ tableHeader: true, children: [hdrCell("Category", 2200), hdrCell("Mediator", 3000), hdrCell("Effect", 3826)] }),
        new TableRow({ children: [subHdrCell("Preformed (granule)", 2200), dataCell("Histamine", 3000, GRAY_LIGHT), dataCell("Vasodilation, increased permeability, bronchospasm, pruritus", 3826, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Preformed (granule)", 2200), dataCell("Tryptase, Heparin, ECF-A", 3000), dataCell("Proteolysis, anticoagulation, eosinophil recruitment", 3826)] }),
        new TableRow({ children: [subHdrCell("Newly Formed", 2200), dataCell("Leukotrienes C4, D4, E4 (SRS-A)", 3000, GRAY_LIGHT), dataCell("Bronchoconstriction, increased mucus (100x stronger than histamine)", 3826, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Newly Formed", 2200), dataCell("Prostaglandin D2 (PGD2)", 3000), dataCell("Bronchospasm, vasodilation", 3826)] }),
        new TableRow({ children: [subHdrCell("Newly Formed", 2200), dataCell("PAF (Platelet Activating Factor)", 3000, GRAY_LIGHT), dataCell("Platelet aggregation, bronchoconstriction", 3826, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Cytokines", 2200), dataCell("TNF-α, IL-4, IL-5", 3000), dataCell("Inflammation, IgE production, eosinophil activation (late phase)", 3826)] })
      ]),
      spacer(140),

      // TYPE II
      h2("Type II — Cytotoxic (Antibody-Dependent) Hypersensitivity"),
      numberedItem("IgG or IgM antibodies are directed against cell-surface antigens or extracellular matrix"),
      numberedItem("Antibody binding activates complement via classical pathway → MAC (membrane attack complex) → cell lysis"),
      numberedItem("Cells coated with IgG are also destroyed by ADCC (NK cells and macrophages via FcγR)"),
      numberedItem("Opsonization: C3b-coated cells are phagocytosed by macrophages"),
      numberedItem("Drugs (e.g., penicillin) can haptenize RBCs → antibody formation against drug-RBC complex → hemolysis"),
      numberedItem("Special case (Type V): Antibodies to cell surface receptors stimulate/block function without lysis — e.g., Graves' disease (TSH-R antibody)"),
      spacer(80),

      // TYPE III
      h2("Type III — Immune Complex-Mediated Hypersensitivity"),
      numberedItem("Antigen-antibody (IgG/IgM) complexes form in excess in circulation"),
      numberedItem("When complexes persist and are not cleared, they deposit in tissues (glomeruli, joints, vessel walls)"),
      numberedItem("Deposited immune complexes activate complement → C3a and C5a (anaphylatoxins)"),
      numberedItem("C5a is a potent chemoattractant → recruits neutrophils to the site"),
      numberedItem("Neutrophils release lysosomal enzymes and ROS → tissue damage and inflammation (vasculitis, nephritis, arthritis)"),
      spacer(60),
      h4("Two Subtypes:"),
      bullet("Arthus Reaction (Local): IgG + injected antigen → local complement activation within 12 hours"),
      bullet("Serum Sickness (Systemic): Large antigen excess → systemic immune complex deposition at 6–21 days"),
      spacer(80),

      // TYPE IV
      h2("Type IV — Delayed-Type (Cell-Mediated) Hypersensitivity"),
      numberedItem("No antibody involved — purely T-cell mediated"),
      numberedItem("First exposure: Antigen processed by APCs (Langerhans cells) → presented to CD4+ Th1 cells via MHC Class II → memory T cells form"),
      numberedItem("Re-exposure (48–72 hrs later): Antigen re-presented to sensitized T cells"),
      numberedItem("Activated Th1 cells release cytokines: IFN-γ, IL-2, TNF-β"),
      numberedItem("IFN-γ activates macrophages → release TNF and lysosomal enzymes → granuloma formation, induration, necrosis"),
      spacer(60),
      h4("Subtypes of Type IV:"),
      bullet("Contact Hypersensitivity: Chemicals (nickel, urushiol from poison ivy) act as haptens → sensitize skin T cells"),
      bullet("Tuberculin-Type: Tuberculin skin test — positive = induration in 24–72 hrs (CD4+ Th1 response)"),
      bullet("Granulomatous: Chronic macrophage activation — e.g., tuberculosis, leprosy, sarcoidosis"),
      spacer(160),
      pageBreak(),

      // ══════════════════════════════════════════
      // EXAMPLES
      // ══════════════════════════════════════════
      h1("3. EXAMPLES — Disease Classification"),
      spacer(80),
      tableNoBorder([
        new TableRow({ tableHeader: true, children: [hdrCell("Disease / Condition", 5000), hdrCell("Type of Hypersensitivity", 4026)] }),
        new TableRow({ children: [dataCell("Anaphylaxis (bee sting, penicillin injection)", 5000, GRAY_LIGHT), dataCell("Type I", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Bronchial Asthma", 5000), dataCell("Type I", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Hay Fever (Allergic Rhinitis)", 5000, GRAY_LIGHT), dataCell("Type I", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Atopic Dermatitis (Eczema)", 5000), dataCell("Type I", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Food Allergy (shellfish, peanuts)", 5000, GRAY_LIGHT), dataCell("Type I", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Hemolytic Transfusion Reaction (ABO mismatch)", 5000), dataCell("Type II", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Rh Hemolytic Disease of Newborn", 5000, GRAY_LIGHT), dataCell("Type II", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Autoimmune Hemolytic Anemia", 5000), dataCell("Type II", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Goodpasture Syndrome", 5000, GRAY_LIGHT), dataCell("Type II", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Graves' Disease (TSH-R antibody)", 5000), dataCell("Type II (V)", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Myasthenia Gravis (AChR antibody)", 5000, GRAY_LIGHT), dataCell("Type II (V)", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Systemic Lupus Erythematosus (SLE)", 5000), dataCell("Type III", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Post-Streptococcal Glomerulonephritis", 5000, GRAY_LIGHT), dataCell("Type III", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Serum Sickness", 5000), dataCell("Type III", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Arthus Reaction", 5000, GRAY_LIGHT), dataCell("Type III (local)", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Contact Dermatitis (poison ivy, nickel, formaldehyde)", 5000), dataCell("Type IV", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Tuberculin (Mantoux) Test", 5000, GRAY_LIGHT), dataCell("Type IV", 4026, GRAY_LIGHT, true)] }),
        new TableRow({ children: [dataCell("Organ Graft Rejection (allograft)", 5000), dataCell("Type IV", 4026, WHITE, true)] }),
        new TableRow({ children: [dataCell("Tuberculosis granuloma / Leprosy (tuberculoid)", 5000, GRAY_LIGHT), dataCell("Type IV", 4026, GRAY_LIGHT, true)] })
      ]),
      spacer(160),
      pageBreak(),

      // ══════════════════════════════════════════
      // PHARMACOLOGICAL MANAGEMENT
      // ══════════════════════════════════════════
      h1("4. PHARMACOLOGICAL MANAGEMENT"),
      spacer(80),

      // Type I management
      h2("Type I Hypersensitivity — Management"),
      spacer(60),
      tableNoBorder([
        new TableRow({ tableHeader: true, children: [hdrCell("Drug / Class", 2200), hdrCell("Example(s)", 1800), hdrCell("Mechanism of Action", 2600), hdrCell("Clinical Use", 2426)] }),
        new TableRow({ children: [subHdrCell("EPINEPHRINE (First-line)", 2200), dataCell("Adrenaline", 1800, GRAY_LIGHT), dataCell("α1 (vasoconstriction) + β2 (bronchodilation); reverses anaphylaxis", 2600, GRAY_LIGHT), dataCell("Severe anaphylaxis — IM injection", 2426, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("H1 Antihistamines", 2200), dataCell("Diphenhydramine, Cetirizine, Loratadine", 1800), dataCell("Competitive block of H1 receptors → reduce vasodilation, pruritus, urticaria", 2600), dataCell("Allergic rhinitis, urticaria, mild allergy", 2426)] }),
        new TableRow({ children: [subHdrCell("Corticosteroids", 2200), dataCell("Prednisolone, Dexamethasone, Hydrocortisone", 1800, GRAY_LIGHT), dataCell("Inhibit phospholipase A2 → block arachidonic acid → reduce LTs + PGs; suppress cytokines", 2600, GRAY_LIGHT), dataCell("Severe allergy, asthma, late-phase reaction", 2426, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Leukotriene Antagonists (LTRA)", 2200), dataCell("Montelukast, Zafirlukast", 1800), dataCell("Block CysLT1 receptors → reduce bronchoconstriction and mucus secretion", 2600), dataCell("Bronchial asthma, allergic rhinitis", 2426)] }),
        new TableRow({ children: [subHdrCell("Mast Cell Stabilizers", 2200), dataCell("Sodium Cromoglycate, Nedocromil", 1800, GRAY_LIGHT), dataCell("Block Cl- channels → prevent mast cell degranulation → inhibit histamine + mediator release", 2600, GRAY_LIGHT), dataCell("Prophylaxis in asthma, allergic rhinitis", 2426, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Beta-2 Agonists", 2200), dataCell("Salbutamol, Formoterol", 1800), dataCell("Activate β2 receptors on bronchial smooth muscle → bronchodilation", 2600), dataCell("Acute asthma attack", 2426)] }),
        new TableRow({ children: [subHdrCell("Xanthines", 2200), dataCell("Theophylline", 1800, GRAY_LIGHT), dataCell("Inhibit phosphodiesterase → increase cAMP → bronchodilation + mast cell stabilization", 2600, GRAY_LIGHT), dataCell("Chronic asthma", 2426, GRAY_LIGHT)] }),
        new TableRow({ children: [subHdrCell("Anti-IgE Monoclonal Ab", 2200), dataCell("Omalizumab", 1800), dataCell("Binds free IgE → prevents IgE binding to FcεRI on mast cells → no degranulation", 2600), dataCell("Severe allergic asthma, chronic urticaria", 2426)] }),
        new TableRow({ children: [subHdrCell("Allergen Immunotherapy", 2200), dataCell("Desensitization shots", 1800, GRAY_LIGHT), dataCell("Repeated low-dose allergen shifts Th2→Th1, increases IgG4 (blocking Ab), reduces IgE", 2600, GRAY_LIGHT), dataCell("Long-term allergy management", 2426, GRAY_LIGHT)] })
      ]),
      spacer(140),

      // Type II management
      h2("Type II Hypersensitivity — Management"),
      spacer(60),
      tableNoBorder([
        new TableRow({ tableHeader: true, children: [hdrCell("Drug / Approach", 3000), hdrCell("Mechanism", 3000), hdrCell("Use", 3026)] }),
        new TableRow({ children: [dataCell("Corticosteroids (Prednisolone)", 3000, GRAY_LIGHT), dataCell("Suppress antibody production and complement activation", 3000, GRAY_LIGHT), dataCell("Autoimmune hemolytic anemia, Goodpasture syndrome", 3026, GRAY_LIGHT)] }),
        new TableRow({ children: [dataCell("Plasmapheresis", 3000), dataCell("Removes circulating autoantibodies and immune complexes", 3000), dataCell("Goodpasture syndrome, myasthenia gravis", 3026)] }),
        new TableRow({ children: [dataCell("IVIG", 3000, GRAY_LIGHT), dataCell("Saturates FcRn receptors → faster degradation of pathogenic IgG", 3000, GRAY_LIGHT), dataCell("Autoimmune conditions, ITP", 3026, GRAY_LIGHT)] }),
        new TableRow({ children: [dataCell("Rituximab (anti-CD20 mAb)", 3000), dataCell("Depletes B cells → reduces autoantibody production", 3000), dataCell("Autoimmune hemolytic anemia, vasculitis", 3026)] })
      ]),
      spacer(140),

      // Type III management
      h2("Type III Hypersensitivity — Management"),
      spacer(60),
      tableNoBorder([
        new TableRow({ tableHeader: true, children: [hdrCell("Drug / Approach", 3000), hdrCell("Mechanism", 3000), hdrCell("Use", 3026)] }),
        new TableRow({ children: [dataCell("Corticosteroids", 3000, GRAY_LIGHT), dataCell("Suppress complement activation, neutrophil function, cytokine production", 3000, GRAY_LIGHT), dataCell("SLE, vasculitis, serum sickness", 3026, GRAY_LIGHT)] }),
        new TableRow({ children: [dataCell("NSAIDs", 3000), dataCell("COX inhibition → reduce prostaglandin-mediated inflammation", 3000), dataCell("Joint pain in SLE, serum sickness", 3026)] }),
        new TableRow({ children: [dataCell("Hydroxychloroquine", 3000, GRAY_LIGHT), dataCell("Inhibit TLR signaling → reduce immune complex deposition and flares", 3000, GRAY_LIGHT), dataCell("SLE (first-line adjunct)", 3026, GRAY_LIGHT)] }),
        new TableRow({ children: [dataCell("Immunosuppressants (Azathioprine, MMF, Cyclophosphamide)", 3000), dataCell("Reduce B and T cell activity → less immune complex formation", 3000), dataCell("Lupus nephritis (Type III), vasculitis", 3026)] }),
        new TableRow({ children: [dataCell("Plasmapheresis", 3000, GRAY_LIGHT), dataCell("Physically removes circulating immune complexes", 3000, GRAY_LIGHT), dataCell("Severe SLE, cryoglobulinemia", 3026, GRAY_LIGHT)] })
      ]),
      spacer(140),

      // Type IV management
      h2("Type IV Hypersensitivity — Management"),
      spacer(60),
      tableNoBorder([
        new TableRow({ tableHeader: true, children: [hdrCell("Drug / Approach", 3000), hdrCell("Mechanism", 3000), hdrCell("Use", 3026)] }),
        new TableRow({ children: [dataCell("Topical/Systemic Corticosteroids", 3000, GRAY_LIGHT), dataCell("Suppress T-cell activation; reduce cytokine release and macrophage activation", 3000, GRAY_LIGHT), dataCell("Contact dermatitis (first-line)", 3026, GRAY_LIGHT)] }),
        new TableRow({ children: [dataCell("Calcineurin Inhibitors (Tacrolimus, Cyclosporine)", 3000), dataCell("Block calcineurin → inhibit IL-2 transcription → suppress T-cell proliferation", 3000), dataCell("Contact dermatitis, organ transplant rejection", 3026)] }),
        new TableRow({ children: [dataCell("Anti-TNF Biologics (Infliximab, Adalimumab)", 3000, GRAY_LIGHT), dataCell("Block TNF-α → reduce macrophage activation and granuloma formation", 3000, GRAY_LIGHT), dataCell("TB granuloma complications, Crohn's disease", 3026, GRAY_LIGHT)] }),
        new TableRow({ children: [dataCell("Antituberculosis Drugs (HRZE)", 3000), dataCell("Treat the causative organism driving Type IV granuloma in TB", 3000), dataCell("Tuberculosis", 3026)] }),
        new TableRow({ children: [dataCell("Antigen Avoidance", 3000, GRAY_LIGHT), dataCell("Fundamental — remove sensitizing antigen entirely", 3000, GRAY_LIGHT), dataCell("Contact dermatitis (nickel, latex)", 3026, GRAY_LIGHT)] })
      ]),
      spacer(160),
      pageBreak(),

      // ══════════════════════════════════════════
      // FLOWCHART
      // ══════════════════════════════════════════
      h1("5. TYPE I HYPERSENSITIVITY — MECHANISM FLOWCHART"),
      spacer(80),

      // The flowchart is represented as a series of visually styled boxes using shaded paragraphs
      new Paragraph({
        children: [new TextRun({ text: "FIRST EXPOSURE TO ALLERGEN", font: "Arial", size: 22, bold: true, color: WHITE })],
        shading: { type: ShadingType.SOLID, color: BLUE_MID, fill: BLUE_MID },
        alignment: AlignmentType.CENTER,
        spacing: { before: 0, after: 0 },
        border: { top: { style: BorderStyle.THICK, size: 6, color: TEAL }, bottom: { style: BorderStyle.THICK, size: 6, color: TEAL }, left: { style: BorderStyle.THICK, size: 6, color: TEAL }, right: { style: BorderStyle.THICK, size: 6, color: TEAL } }
      }),
      new Paragraph({ children: [new TextRun({ text: "(Pollen, dust mite, penicillin, food antigen)", font: "Arial", size: 18, italics: true, color: "555555" })], alignment: AlignmentType.CENTER, spacing: { before: 40, after: 80 } }),
      new Paragraph({ children: [new TextRun({ text: "▼", font: "Arial", size: 28, bold: true, color: TEAL })], alignment: AlignmentType.CENTER, spacing: { after: 40 } }),

      new Paragraph({
        children: [new TextRun({ text: "Allergen → APCs present to Th2 cells → IL-4 and IL-13 released", font: "Arial", size: 20, color: BLUE_DARK })],
        shading: { type: ShadingType.SOLID, color: BLUE_LIGHT, fill: BLUE_LIGHT },
        alignment: AlignmentType.CENTER, spacing: { before: 0, after: 0 },
        border: { top: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, left: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, right: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID } }
      }),
      new Paragraph({ children: [new TextRun({ text: "▼", font: "Arial", size: 28, bold: true, color: TEAL })], alignment: AlignmentType.CENTER, spacing: { before: 40, after: 40 } }),

      new Paragraph({
        children: [new TextRun({ text: "B cells undergo class-switching → Produce IgE antibodies", font: "Arial", size: 20, color: BLUE_DARK })],
        shading: { type: ShadingType.SOLID, color: BLUE_LIGHT, fill: BLUE_LIGHT },
        alignment: AlignmentType.CENTER, spacing: { before: 0, after: 0 },
        border: { top: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, left: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, right: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID } }
      }),
      new Paragraph({ children: [new TextRun({ text: "▼", font: "Arial", size: 28, bold: true, color: TEAL })], alignment: AlignmentType.CENTER, spacing: { before: 40, after: 40 } }),

      new Paragraph({
        children: [new TextRun({ text: "IgE binds to FcεRI receptors on MAST CELLS and BASOPHILS  →  Patient is SENSITIZED", font: "Arial", size: 20, bold: true, color: BLUE_DARK })],
        shading: { type: ShadingType.SOLID, color: BLUE_LIGHT, fill: BLUE_LIGHT },
        alignment: AlignmentType.CENTER, spacing: { before: 0, after: 0 },
        border: { top: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, left: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, right: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID } }
      }),
      spacer(80),

      new Paragraph({
        children: [new TextRun({ text: "SECOND EXPOSURE TO SAME ALLERGEN", font: "Arial", size: 22, bold: true, color: WHITE })],
        shading: { type: ShadingType.SOLID, color: "C0392B", fill: "C0392B" },
        alignment: AlignmentType.CENTER,
        spacing: { before: 40, after: 0 },
        border: { top: { style: BorderStyle.THICK, size: 6, color: "922B21" }, bottom: { style: BorderStyle.THICK, size: 6, color: "922B21" }, left: { style: BorderStyle.THICK, size: 6, color: "922B21" }, right: { style: BorderStyle.THICK, size: 6, color: "922B21" } }
      }),
      new Paragraph({ children: [new TextRun({ text: "▼", font: "Arial", size: 28, bold: true, color: TEAL })], alignment: AlignmentType.CENTER, spacing: { before: 40, after: 40 } }),

      new Paragraph({
        children: [new TextRun({ text: "Allergen cross-links two IgE molecules on mast cell surface", font: "Arial", size: 20, color: BLACK })],
        shading: { type: ShadingType.SOLID, color: "FDECEA", fill: "FDECEA" },
        alignment: AlignmentType.CENTER, spacing: { before: 0, after: 0 },
        border: { top: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, bottom: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, left: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, right: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" } }
      }),
      new Paragraph({ children: [new TextRun({ text: "▼", font: "Arial", size: 28, bold: true, color: TEAL })], alignment: AlignmentType.CENTER, spacing: { before: 40, after: 40 } }),

      new Paragraph({
        children: [new TextRun({ text: "MAST CELL DEGRANULATION", font: "Arial", size: 24, bold: true, color: WHITE })],
        shading: { type: ShadingType.SOLID, color: "922B21", fill: "922B21" },
        alignment: AlignmentType.CENTER,
        spacing: { before: 0, after: 0 },
        border: { top: { style: BorderStyle.THICK, size: 8, color: "641E16" }, bottom: { style: BorderStyle.THICK, size: 8, color: "641E16" }, left: { style: BorderStyle.THICK, size: 8, color: "641E16" }, right: { style: BorderStyle.THICK, size: 8, color: "641E16" } }
      }),
      spacer(80),

      // Two-column mediators
      tableNoBorder([
        new TableRow({
          children: [
            new TableCell({
              width: { size: 4513, type: WidthType.DXA },
              shading: { type: ShadingType.SOLID, color: "D6EAF8", fill: "D6EAF8" },
              borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, left: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID }, right: { style: BorderStyle.SINGLE, size: 4, color: BLUE_MID } },
              children: [
                new Paragraph({ children: [new TextRun({ text: "PREFORMED MEDIATORS", font: "Arial", size: 20, bold: true, color: BLUE_DARK })], alignment: AlignmentType.CENTER }),
                new Paragraph({ children: [new TextRun({ text: "(Released immediately)", font: "Arial", size: 17, italics: true, color: "555555" })], alignment: AlignmentType.CENTER, spacing: { after: 60 } }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Histamine", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Tryptase", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Heparin", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "ECF-A (Eosinophil Chemotactic Factor)", font: "Arial", size: 19 })] })
              ]
            }),
            new TableCell({
              width: { size: 4513, type: WidthType.DXA },
              shading: { type: ShadingType.SOLID, color: "FDEDEC", fill: "FDEDEC" },
              borders: { top: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, bottom: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, left: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, right: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" } },
              children: [
                new Paragraph({ children: [new TextRun({ text: "NEWLY FORMED MEDIATORS", font: "Arial", size: 20, bold: true, color: "922B21" })], alignment: AlignmentType.CENTER }),
                new Paragraph({ children: [new TextRun({ text: "(From arachidonic acid)", font: "Arial", size: 17, italics: true, color: "555555" })], alignment: AlignmentType.CENTER, spacing: { after: 60 } }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Leukotrienes C4, D4, E4", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Prostaglandin D2 (PGD2)", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "PAF (Platelet Activating Factor)", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "TNF-α, IL-4, IL-5", font: "Arial", size: 19 })] })
              ]
            })
          ]
        })
      ]),
      spacer(80),
      new Paragraph({ children: [new TextRun({ text: "▼", font: "Arial", size: 28, bold: true, color: TEAL })], alignment: AlignmentType.CENTER, spacing: { before: 20, after: 20 } }),

      tableNoBorder([
        new TableRow({
          children: [
            new TableCell({
              width: { size: 4513, type: WidthType.DXA },
              shading: { type: ShadingType.SOLID, color: "E8F8F5", fill: "E8F8F5" },
              borders: { top: { style: BorderStyle.SINGLE, size: 4, color: TEAL }, bottom: { style: BorderStyle.SINGLE, size: 4, color: TEAL }, left: { style: BorderStyle.SINGLE, size: 4, color: TEAL }, right: { style: BorderStyle.SINGLE, size: 4, color: TEAL } },
              children: [
                new Paragraph({ children: [new TextRun({ text: "LOCAL REACTION (Atopy)", font: "Arial", size: 20, bold: true, color: TEAL })], alignment: AlignmentType.CENTER }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Hay Fever", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Asthma", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Urticaria / Eczema", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Food allergy", font: "Arial", size: 19 })] })
              ]
            }),
            new TableCell({
              width: { size: 4513, type: WidthType.DXA },
              shading: { type: ShadingType.SOLID, color: "FDEDEC", fill: "FDEDEC" },
              borders: { top: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, bottom: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, left: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" }, right: { style: BorderStyle.SINGLE, size: 4, color: "C0392B" } },
              children: [
                new Paragraph({ children: [new TextRun({ text: "SYSTEMIC REACTION (Anaphylaxis)", font: "Arial", size: 20, bold: true, color: "922B21" })], alignment: AlignmentType.CENTER }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Hypotension / Shock", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Laryngeal edema", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Bronchospasm", font: "Arial", size: 19 })] }),
                new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun({ text: "Cardiovascular collapse — FATAL", font: "Arial", size: 19, bold: true })] })
              ]
            })
          ]
        })
      ]),
      spacer(160),

      // ══════════════════════════════════════════
      // CONCLUSION
      // ══════════════════════════════════════════
      h1("CONCLUSION"),
      spacer(80),
      boxPara("Hypersensitivity reactions represent a spectrum of immune-mediated tissue damage with distinct mechanisms, mediators, and clinical presentations — their understanding is clinically indispensable for the rational selection of pharmacological agents, from epinephrine in anaphylaxis to calcineurin inhibitors in delayed-type hypersensitivity, and forms the immunological basis for treating allergic, autoimmune, and inflammatory diseases in clinical practice.", "E8F8F5"),
      spacer(120),

      // References
      h2("References"),
      bullet("Jawetz, Melnick & Adelberg's Medical Microbiology, 28th Edition — Chapter: Hypersensitivity (pp. 150-153)"),
      bullet("Roitt's Essential Immunology, 13th Edition — Chapter 14: Allergy and Other Hypersensitivities"),
      bullet("Janeway's Immunobiology, 10th Edition — Chapter 14: Allergic Diseases and Hypersensitivity Reactions"),
      bullet("Goodman & Gilman's The Pharmacological Basis of Therapeutics, 14th Edition"),
      bullet("Katzung's Basic and Clinical Pharmacology, 16th Edition"),
      spacer(80)
    ]
  }]
});

Packer.toBuffer(doc).then(buffer => {
  fs.writeFileSync("/home/daytona/workspace/hypersensitivity/Hypersensitivity_Reactions_MPharm.docx", buffer);
  console.log("DOCX generated successfully.");
}).catch(err => {
  console.error("Error:", err);
  process.exit(1);
});
Running Command

cd /home/daytona/workspace/hypersensitivity && node generate.js 2>&1

Running Command

python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/hypersensitivity/Hypersensitivity_Reactions_MPharm.docx 2>&1

Running Command

ls -lh /home/daytona/workspace/hypersensitivity/ && python3 -c "import zipfile; z=zipfile.ZipFile('/home/daytona/workspace/hypersensitivity/Hypersensitivity_Reactions_MPharm.docx'); print('Valid ZIP - files:', z.namelist()[:8])"

Your DOCX is ready for download and printing:

Hypersensitivity Reactions MPharm

Word Document · DOCX


Here's what's inside the document:
SectionContent
Title blockStyled header with subject, degree level, and marks
Header / FooterBook sources on every page + page numbers
DefinitionHighlighted teal-bordered box
Classification TableFull 8-row Gell & Coombs comparison (all 4 types)
Mechanism — Type IStep-by-step sensitization + elicitation phases, mediators table
Mechanism — Type II, III, IVDetailed numbered steps with subtypes
Examples Table20 diseases mapped to their type
Pharmacological Management4 separate tables - one per type, with drug name, mechanism, clinical use
Type I FlowchartVisual flow using colour-coded boxes (blue sensitization → red elicitation → dual outcome local/systemic)
ConclusionOne-line highlighted clinical importance statement
References5 standard textbooks cited
Design features for printing:
  • A4 page size with 0.75" margins (printer-friendly)
  • Navy/teal colour scheme (prints cleanly in both colour and B&W)
  • Alternating grey rows in all tables for easy reading
  • Page breaks between major sections so content does not split awkwardly
This is a shared conversation. Sign in to Orris to start your own chat.