attachment
attachment
attachment
attachment

Prepare notes for this topics

Reading File
analyse_media
analyse_media
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
I now have comprehensive material. Let me compile the complete, detailed study notes.

Pharmacology Study Notes

Source: Katzung's Basic and Clinical Pharmacology, 16th Edition (Vanderah & Katzung)

TOPIC 1: Introduction to Pharmacology & Definition and Scope

1.1 Definition of Pharmacology

Pharmacology is defined as the study of substances that interact with living systems through chemical processes. These interactions occur primarily by binding of the substance to regulatory molecules and activating or inhibiting normal body processes.
Medical Pharmacology specifically is the science of substances used to prevent, diagnose, and treat disease.
Toxicology is the branch of pharmacology dealing with undesirable effects of chemicals on living systems - from individual cells to complex ecosystems.

1.2 Primary Components of Pharmacology

ComponentDefinition
Drug ActionsHow a drug interacts with its molecular target (receptor, enzyme, transporter)
Mechanisms of ActionThe precise molecular/cellular events triggered by the drug
Therapeutic UsesClinical applications to prevent, diagnose, or treat disease

1.3 Subdivisions of Pharmacology

SubdivisionFocus
Pharmacokinetics (PK)What the body does to the drug - Absorption, Distribution, Metabolism, Excretion (ADME)
Pharmacodynamics (PD)What the drug does to the body - mechanisms of action, receptor interactions, dose-response
ToxicologyHarmful effects of chemicals on living systems
PharmacogenomicsRelationship between a patient's genetic makeup and their response to specific drugs
Clinical PharmacologyApplication of pharmacological principles to patient care
NeuropharmacologyDrug effects on the nervous system
ChemotherapyDrug effects on invading organisms or cancer cells
ImmunopharmacologyDrug effects on the immune system
Pharmacology sits at the intersection of anatomy, biochemistry, genetics, physiology, pathology, and clinical medicine.

1.4 How Pharmacokinetics and Pharmacodynamics Influence Drug Therapy

Pharmacokinetics (PK) - "What the body does to the drug"

ADME Framework:
A - Absorption
  • Drug moves from site of administration into blood
  • Influenced by: route of administration, drug solubility, formulation, first-pass metabolism
  • A drug given orally must cross intestinal wall epithelium and hepatic portal system before reaching systemic circulation
  • Prodrugs - inactive chemical precursors that are converted to active drug by biologic processes inside the body (e.g., enalapril → enalaprilat)
D - Distribution
  • Drug moves from bloodstream into tissues
  • Influenced by: plasma protein binding, lipid solubility, blood-brain barrier, volume of distribution (Vd)
  • Drugs bound to large plasma proteins (e.g., albumin) do NOT permeate most vascular pores
M - Metabolism
  • Primarily hepatic (cytochrome P450 enzymes)
  • Phase I: oxidation, reduction, hydrolysis → adds/exposes functional groups
  • Phase II: conjugation → makes drug more water-soluble for excretion
  • Important for drug interactions (CYP450 inhibitors/inducers)
E - Excretion
  • Primarily renal
  • Also: biliary, pulmonary, sweat, breast milk
  • Renal clearance depends on glomerular filtration, tubular secretion, reabsorption
Key PK Parameters:
ParameterMeaning
Half-life (t½)Time for plasma concentration to fall by 50%
Volume of distribution (Vd)Apparent volume in which drug is distributed
Clearance (CL)Rate of drug elimination per unit plasma concentration
Bioavailability (F)Fraction of administered dose reaching systemic circulation

Pharmacodynamics (PD) - "What the drug does to the body"

Drug-Receptor Interaction:
  • Drugs bind to specific receptor proteins, producing their effect
  • The relationship between drug concentration and effect is described by concentration-effect curves
Key Terms:
  • Affinity - strength of drug binding to its receptor
  • Efficacy - maximum pharmacological effect a drug can produce (intrinsic activity)
  • Potency - amount of drug needed to produce a given effect (relates to EC50)

1.5 Key Pharmacodynamic Terms

Agonists

  • Drugs that bind to a receptor AND activate it, mimicking the endogenous ligand
  • Full agonists - produce the maximum possible response (e.g., morphine at opioid receptors)
  • Partial agonists - produce a sub-maximal response even at full receptor occupancy, because they have lower intrinsic efficacy; they can also act as competitive inhibitors of full agonists (e.g., buprenorphine - safer analgesic than fentanyl because it suppresses breathing less)
  • Inverse agonists - bind to the receptor but reduce activity below baseline (opposite of agonist)

Antagonists

  • Drugs that bind to a receptor but do NOT activate it; they block the action of agonists
  • Competitive (reversible) antagonists - compete with agonist for the same binding site; effect can be overcome by increasing agonist concentration; shift the dose-response curve to the right
  • Non-competitive antagonists - bind irreversibly, or at an allosteric site; cannot be overcome by increasing agonist concentration; reduce the maximal response

Allosteric Modulators

  • Bind to a different (allosteric) site on the receptor, not the agonist (orthosteric) site
  • Positive allosteric modulators (PAM) - enhance receptor activity (e.g., benzodiazepines potentiate GABA at GABA-A receptors)
  • Negative allosteric modulators (NAM) - reduce receptor activity

1.6 Therapeutic Index (TI)

The Therapeutic Index is a measure of a drug's safety margin:
TI = TD50 / ED50
Where:
  • ED50 = dose effective in 50% of the population
  • TD50 = dose toxic in 50% of the population
  • LD50 = lethal dose in 50% of animals (used in preclinical testing)
  • A narrow TI = small margin between therapeutic and toxic dose → requires careful monitoring (e.g., digoxin, warfarin, lithium, aminoglycosides)
  • A wide TI = large safety margin (e.g., penicillins)

1.7 Drug Concentration-Time Curves

The plasma concentration-time curve is a graphical representation of how drug concentration in the plasma changes over time after administration.
Key features:
  • Cmax - peak plasma concentration
  • Tmax - time to reach peak concentration
  • AUC (Area Under the Curve) - reflects total drug exposure; used to calculate bioavailability
  • MEC (Minimum Effective Concentration) - lower threshold for therapeutic effect
  • MTC (Minimum Toxic Concentration) - upper threshold above which toxicity occurs
  • Therapeutic window - range between MEC and MTC
Plasma                MTC --------
Concentration         |  Therapeutic Window
                      MEC --------
         ___
        /   \
       /     \
      /       \___________
  ---/----Time (hours)----->
How to interpret a concentration-time curve:
  1. Rising phase = absorption phase
  2. Peak = Cmax at Tmax
  3. Falling phase = distribution + elimination
  4. The slope of the falling phase reflects the elimination rate constant (and half-life)

1.8 Adverse Effects and Drug Interactions in Patient Care

Types of Adverse Drug Reactions (ADRs):
TypeDescriptionExample
Type A (Augmented)Predictable, dose-dependent, extension of pharmacological effectHypoglycemia with insulin overdose
Type B (Bizarre)Unpredictable, not dose-dependent, idiosyncratic or immunologicalAnaphylaxis to penicillin
Type C (Chronic)Long-term use effectsAdrenal suppression with corticosteroids
Type D (Delayed)Appear after stopping drugTardive dyskinesia after antipsychotics
Drug Interactions:
  • Pharmacokinetic interactions - one drug alters absorption, distribution, metabolism, or excretion of another (e.g., CYP450 enzyme induction by rifampicin reduces efficacy of oral contraceptives)
  • Pharmacodynamic interactions - drugs act on same receptor/pathway
    • Synergism: enhanced effect (beneficial or harmful)
    • Antagonism: one drug reduces the effect of another
Clinical Relevance: Reviewing all patient medications is essential to identify polypharmacy issues, narrow-TI drugs, and interaction risks.

TOPIC 2: Drug Nomenclature and Classification Systems

2.1 Types of Drug Names

Every drug has up to three names:
Name TypeDescriptionExample
Chemical nameIUPAC systematic chemical structureN-(4-hydroxyphenyl)acetamide
Generic (INN) nameInternational Nonproprietary Name - official, non-commercialparacetamol / acetaminophen
Brand (proprietary) nameManufacturer's trade name; capitalizedTylenol®

2.2 Drug Nomenclature Stems (INN Stems)

The International Nonproprietary Name (INN) system uses standardized prefixes and suffixes (stems) that indicate a drug's pharmacological class. Knowing these stems allows you to identify a drug's class at a glance.

Suffixes (-stems at the END of the name)

StemDrug ClassExamples
-ololBeta-adrenoceptor blockers (beta-blockers)propranolol, atenolol, bisoprolol, metoprolol
-prilACE inhibitors (angiotensin-converting enzyme inhibitors)lisinopril, enalapril, ramipril, captopril
-cillinPenicillin antibiotics (beta-lactams)ampicillin, amoxicillin, flucloxacillin
-statinHMG-CoA reductase inhibitors (lipid-lowering agents)atorvastatin, rosvustatin, simvastatin
-sartanAngiotensin II receptor blockers (ARBs)losartan, valsartan, irbesartan
-mabMonoclonal antibodiestrastuzumab, rituximab, adalimumab
-nibTyrosine kinase inhibitorsimatinib, gefitinib, erlotinib
-virAntiviral drugsaciclovir, oseltamivir
-azoleAntifungals / proton-pump inhibitorsomeprazole, fluconazole
-dipineDihydropyridine calcium channel blockersamlodipine, nifedipine
-mycin / -micinAntibiotics (aminoglycosides / macrolides)erythromycin, gentamicin
-cyclineTetracycline antibioticsdoxycycline, tetracycline

Prefixes (stems at the BEGINNING of the name)

PrefixMeaningExample
Es-S-enantiomer of a racemic drug (single optical isomer)Esomeprazole (S-enantiomer of omeprazole), escitalopram
Levo- (or L-)Levorotatory isomer (rotates polarized light to the left)Levothyroxine (L-T4), levofloxacin, levocetirizine
Dex- / Dextro-Dextrorotatory isomerDextromethorphan, dexamfetamine
Nor-Parent compound without an N-methyl groupNorepinephrine (parent of epinephrine)
Iso-Isomeric formIsoproterenol
Clinical Significance of Isomers:
  • Enantiomers often differ in potency, efficacy, and side-effect profiles
  • Esomeprazole (S-enantiomer) has superior acid suppression vs. racemic omeprazole
  • Levothyroxine (L-T4) is the biologically active form of thyroxine

2.3 Drug Classification Systems

Drugs can be classified by multiple overlapping systems:

A. By Mechanism of Action / Pharmacological Class

This is the most important system clinically. Key classes:
ClassMechanismExamples
Beta-blockersBlock β-adrenergic receptorsPropranolol (non-selective), atenolol (β1-selective)
ACE inhibitorsInhibit angiotensin-converting enzyme → ↓ angiotensin II, ↑ bradykininLisinopril, enalapril
StatinsInhibit HMG-CoA reductase → ↓ cholesterol synthesisAtorvastatin, rosuvastatin
PenicillinsInhibit bacterial cell wall synthesis (cross-link peptidoglycan)Ampicillin, amoxicillin
Proton pump inhibitorsIrreversibly inhibit H+/K+-ATPase in gastric parietal cellsOmeprazole, esomeprazole

B. By Therapeutic Use

Example: antihypertensives, antibiotics, analgesics, antidiabetics, etc.

C. By Chemical Structure

Example: penicillins and cephalosporins are both beta-lactam antibiotics

D. By Receptor Target

Example: adrenergic drugs (alpha/beta agonists and blockers), cholinergic drugs

E. ATC System (Anatomical Therapeutic Chemical)

WHO classification system - 5 levels from organ system down to individual chemical substance

2.4 Drug-Related Factors Affecting Drug Choice and Response

The following drug-related properties govern clinical selection:
FactorDetails
PotencyDose needed for a given effect (high potency = less drug needed)
EfficacyMaximum achievable effect regardless of dose
SelectivityDegree to which a drug acts on one receptor/tissue vs others
Duration of actionInfluenced by half-life, protein binding, formulation
Route of administrationOral, IV, IM, SC, topical, inhaled - affects bioavailability and onset
Adverse effect profileType A vs B reactions; organ toxicity profile
Drug interactionsPK and PD interactions with co-medications
Therapeutic indexSafety margin; narrow TI drugs require therapeutic drug monitoring
FormulationImmediate-release vs. modified-release affects PK

Quick-Reference Summary Table

ConceptKey Point
Pharmacology definitionStudy of substances interacting with living systems via chemical processes
PharmacokineticsADME - what the body does to the drug
PharmacodynamicsDrug-receptor interactions - what the drug does to the body
AgonistBinds + activates receptor
AntagonistBinds but does NOT activate; blocks agonist
Partial agonistSubmaximal response even at full receptor occupancy; mixed agonist-antagonist
Allosteric modulatorActs at site different from agonist binding site
Therapeutic IndexTD50/ED50; narrow TI = close monitoring needed
-ololBeta-blockers (propranolol, atenolol)
-prilACE inhibitors (lisinopril, enalapril)
-cillinPenicillins (ampicillin, amoxicillin)
-statinHMG-CoA reductase inhibitors (atorvastatin)
Es- prefixS-enantiomer (esomeprazole)
Levo- prefixLevorotatory isomer (levothyroxine)

Source: Katzung's Basic and Clinical Pharmacology, 16th Edition - Chapter 1 (Introduction: The Nature of Drugs) and Chapter 2 (Drug Receptors & Pharmacodynamics)

Generate a DOCX study guide with flowcharts for drug classification

Reading File
Running Command

ls /home/daytona/workspace/ && node --version && ls /home/daytona/skills/docx/

Running Command

mkdir -p /home/daytona/workspace/pharmacology-guide && ls /home/daytona/skills/d…

Running Command

cd /home/daytona/workspace/pharmacology-guide && npm install docx 2>&1 | tail -5

Running Command

node -e "require('docx'); console.log('docx available')" 2>/dev/null || ls /usr/…

Writing File

~/pharmacology-guide/generate.js

'use strict';

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

// ── Colour palette ──────────────────────────────────────────
const BLUE_DARK  = '1F3864';   // navy headings
const BLUE_MID   = '2E75B6';   // section heading fill
const BLUE_LIGHT = 'D6E4F0';   // table header rows
const TEAL       = '00B0A0';   // flowchart boxes
const TEAL_LIGHT = 'E0F5F3';   // flowchart light
const AMBER      = 'F5A623';   // highlight / callout
const AMBER_LIGHT= 'FEF3DB';   // callout background
const GRAY_LIGHT = 'F2F2F2';   // alternating table rows
const WHITE      = 'FFFFFF';

// ── Border helper ────────────────────────────────────────────
const solidBorder = (color = '999999', sz = 6) => ({
  style: BorderStyle.SINGLE, size: sz, color
});
const noBorder = { style: BorderStyle.NONE, size: 0, color: 'FFFFFF' };
const allNoBorders = { top: noBorder, bottom: noBorder, left: noBorder, right: noBorder };

// ── Text helpers ─────────────────────────────────────────────
const bold   = (t, sz = 22, color = '000000') => new TextRun({ text: t, bold: true,  size: sz, color });
const normal = (t, sz = 20, color = '000000') => new TextRun({ text: t, bold: false, size: sz, color });
const italic = (t, sz = 20, color = '555555') => new TextRun({ text: t, italics: true, size: sz, color });
const colorBold = (t, color, sz = 20)         => new TextRun({ text: t, bold: true,  size: sz, color });

const para = (runs, opts = {}) => new Paragraph({ children: Array.isArray(runs) ? runs : [runs], ...opts });
const spacer = (before = 100, after = 100) =>
  new Paragraph({ children: [new TextRun('')], spacing: { before, after } });

// ── Heading helpers ──────────────────────────────────────────
const h1 = text => new Paragraph({
  children: [new TextRun({ text, bold: true, size: 36, color: WHITE })],
  heading: HeadingLevel.HEADING_1,
  shading: { type: ShadingType.CLEAR, color: BLUE_DARK, fill: BLUE_DARK },
  spacing: { before: 300, after: 200 },
  indent: { left: convertInchesToTwip(0.1) }
});

const h2 = text => new Paragraph({
  children: [new TextRun({ text, bold: true, size: 28, color: WHITE })],
  heading: HeadingLevel.HEADING_2,
  shading: { type: ShadingType.CLEAR, color: BLUE_MID, fill: BLUE_MID },
  spacing: { before: 240, after: 120 },
  indent: { left: convertInchesToTwip(0.1) }
});

const h3 = text => new Paragraph({
  children: [new TextRun({ text, bold: true, size: 24, color: BLUE_DARK })],
  heading: HeadingLevel.HEADING_3,
  border: { bottom: solidBorder(BLUE_MID, 8) },
  spacing: { before: 200, after: 100 }
});

const h4 = text => new Paragraph({
  children: [new TextRun({ text, bold: true, size: 22, color: BLUE_MID })],
  spacing: { before: 160, after: 80 }
});

// ── Bullet helper ────────────────────────────────────────────
const bullet = (text, level = 0) => new Paragraph({
  children: [normal(text, 20)],
  bullet: { level },
  spacing: { before: 40, after: 40 }
});

const bulletBold = (label, text, level = 0) => new Paragraph({
  children: [bold(label + ' ', 20), normal(text, 20)],
  bullet: { level },
  spacing: { before: 40, after: 40 }
});

// ── Callout box (amber) ──────────────────────────────────────
const callout = lines => [
  new Paragraph({
    children: lines.map((l, i) => i === 0
      ? new TextRun({ text: l, bold: true, size: 20, color: '7B4000' })
      : new TextRun({ text: '\n' + l, size: 20, color: '7B4000' })
    ),
    shading: { type: ShadingType.CLEAR, color: AMBER_LIGHT, fill: AMBER_LIGHT },
    border: {
      left: { style: BorderStyle.SINGLE, size: 24, color: AMBER }
    },
    indent: { left: convertInchesToTwip(0.2), right: convertInchesToTwip(0.2) },
    spacing: { before: 100, after: 100 }
  })
];

// ── Simple data table ────────────────────────────────────────
function dataTable(headers, rows, colWidths) {
  const totalWidth = colWidths.reduce((a, b) => a + b, 0);
  const headerRow = new TableRow({
    children: headers.map((h, i) => new TableCell({
      children: [new Paragraph({
        children: [new TextRun({ text: h, bold: true, size: 20, color: WHITE })],
        alignment: AlignmentType.CENTER
      })],
      shading: { type: ShadingType.CLEAR, color: BLUE_DARK, fill: BLUE_DARK },
      width: { size: Math.round((colWidths[i] / totalWidth) * 9000), type: WidthType.DXA },
      verticalAlign: VerticalAlign.CENTER,
      margins: { top: 80, bottom: 80, left: 100, right: 100 }
    }))
  });

  const dataRows = rows.map((row, ri) => new TableRow({
    children: row.map((cell, ci) => new TableCell({
      children: [new Paragraph({
        children: typeof cell === 'string'
          ? [new TextRun({ text: cell, size: 18 })]
          : cell,
        alignment: AlignmentType.LEFT
      })],
      shading: {
        type: ShadingType.CLEAR,
        color: ri % 2 === 0 ? GRAY_LIGHT : WHITE,
        fill: ri % 2 === 0 ? GRAY_LIGHT : WHITE
      },
      width: { size: Math.round((colWidths[ci] / totalWidth) * 9000), type: WidthType.DXA },
      verticalAlign: VerticalAlign.CENTER,
      margins: { top: 60, bottom: 60, left: 100, right: 100 }
    }))
  }));

  return new Table({
    rows: [headerRow, ...dataRows],
    width: { size: 9000, type: WidthType.DXA },
    borders: {
      top: solidBorder('BBBBBB', 4), bottom: solidBorder('BBBBBB', 4),
      left: solidBorder('BBBBBB', 4), right: solidBorder('BBBBBB', 4),
      insideH: solidBorder('DDDDDD', 2), insideV: solidBorder('DDDDDD', 2)
    }
  });
}

// ── Flowchart box builder ─────────────────────────────────────
// We simulate a flowchart as a borderless table with styled cells + arrows
function flowBox(text, fill = TEAL, textColor = WHITE, sz = 20) {
  return new TableCell({
    children: [new Paragraph({
      children: [new TextRun({ text, bold: true, size: sz, color: textColor })],
      alignment: AlignmentType.CENTER,
      spacing: { before: 80, after: 80 }
    })],
    shading: { type: ShadingType.CLEAR, color: fill, fill },
    borders: {
      top: solidBorder(TEAL, 8), bottom: solidBorder(TEAL, 8),
      left: solidBorder(TEAL, 8), right: solidBorder(TEAL, 8)
    },
    verticalAlign: VerticalAlign.CENTER,
    margins: { top: 60, bottom: 60, left: 120, right: 120 },
    width: { size: 3200, type: WidthType.DXA }
  });
}

function arrowCell(symbol = '↓') {
  return new TableCell({
    children: [new Paragraph({
      children: [new TextRun({ text: symbol, bold: true, size: 28, color: BLUE_MID })],
      alignment: AlignmentType.CENTER
    })],
    borders: allNoBorders,
    shading: { type: ShadingType.CLEAR, color: WHITE, fill: WHITE },
    width: { size: 600, type: WidthType.DXA },
    verticalAlign: VerticalAlign.CENTER,
    margins: { top: 20, bottom: 20, left: 60, right: 60 }
  });
}

function spacerCell(w = 1000) {
  return new TableCell({
    children: [para('')],
    borders: allNoBorders,
    shading: { type: ShadingType.CLEAR, color: WHITE, fill: WHITE },
    width: { size: w, type: WidthType.DXA }
  });
}

function flowRow(cells) {
  return new TableRow({ children: cells });
}

// Vertical flowchart (single column, boxes stacked with arrows)
function verticalFlowchart(steps) {
  // steps: [{label, fill, textColor}]
  const rows = [];
  steps.forEach((step, i) => {
    rows.push(new TableRow({
      children: [
        spacerCell(2800),
        flowBox(step.label, step.fill || TEAL, step.textColor || WHITE, 20),
        spacerCell(2800)
      ]
    }));
    if (i < steps.length - 1) {
      rows.push(new TableRow({
        children: [
          spacerCell(2800),
          arrowCell('↓'),
          spacerCell(2800)
        ]
      }));
    }
  });
  return new Table({
    rows,
    width: { size: 9000, type: WidthType.DXA },
    borders: {
      top: noBorder, bottom: noBorder, left: noBorder, right: noBorder,
      insideH: noBorder, insideV: noBorder
    }
  });
}

// Horizontal flowchart
function horizontalFlowchart(steps, arrowSym = '→') {
  const cells = [];
  steps.forEach((step, i) => {
    cells.push(flowBox(step.label, step.fill || TEAL, step.textColor || WHITE, 18));
    if (i < steps.length - 1) cells.push(arrowCell(arrowSym));
  });
  return new Table({
    rows: [new TableRow({ children: cells })],
    width: { size: 9000, type: WidthType.DXA },
    borders: {
      top: noBorder, bottom: noBorder, left: noBorder, right: noBorder,
      insideH: noBorder, insideV: noBorder
    }
  });
}

// Branch flowchart: top node → N children
function branchFlowchart(rootLabel, branches) {
  // Row 1: root spanning full width
  const rootRow = new TableRow({
    children: [
      spacerCell(800),
      new TableCell({
        children: [new Paragraph({
          children: [new TextRun({ text: rootLabel, bold: true, size: 22, color: WHITE })],
          alignment: AlignmentType.CENTER,
          spacing: { before: 80, after: 80 }
        })],
        shading: { type: ShadingType.CLEAR, color: BLUE_DARK, fill: BLUE_DARK },
        columnSpan: branches.length * 2 - 1,
        borders: {
          top: solidBorder(BLUE_DARK, 8), bottom: solidBorder(BLUE_DARK, 8),
          left: solidBorder(BLUE_DARK, 8), right: solidBorder(BLUE_DARK, 8)
        },
        verticalAlign: VerticalAlign.CENTER,
        margins: { top: 80, bottom: 80, left: 120, right: 120 },
        width: { size: 7800, type: WidthType.DXA }
      }),
      spacerCell(800)
    ]
  });

  // Row 2: arrows
  const arrowCells = [spacerCell(800)];
  branches.forEach((b, i) => {
    arrowCells.push(arrowCell('↓'));
    if (i < branches.length - 1) arrowCells.push(spacerCell(200));
  });
  arrowCells.push(spacerCell(800));
  const arrowRow = new TableRow({ children: arrowCells });

  // Row 3: branch boxes
  const branchCells = [spacerCell(800)];
  branches.forEach((b, i) => {
    branchCells.push(new TableCell({
      children: [
        new Paragraph({
          children: [new TextRun({ text: b.label, bold: true, size: 18, color: WHITE })],
          alignment: AlignmentType.CENTER,
          spacing: { before: 60, after: 20 }
        }),
        new Paragraph({
          children: [new TextRun({ text: b.sub || '', size: 16, color: 'EEEEEE', italics: true })],
          alignment: AlignmentType.CENTER,
          spacing: { before: 0, after: 60 }
        })
      ],
      shading: { type: ShadingType.CLEAR, color: b.fill || TEAL, fill: b.fill || TEAL },
      borders: {
        top: solidBorder(b.fill || TEAL, 8), bottom: solidBorder(b.fill || TEAL, 8),
        left: solidBorder(b.fill || TEAL, 8), right: solidBorder(b.fill || TEAL, 8)
      },
      verticalAlign: VerticalAlign.CENTER,
      margins: { top: 60, bottom: 60, left: 80, right: 80 },
      width: { size: Math.floor(7800 / branches.length) - 200, type: WidthType.DXA }
    }));
    if (i < branches.length - 1) branchCells.push(spacerCell(200));
  });
  branchCells.push(spacerCell(800));
  const branchRow = new TableRow({ children: branchCells });

  return new Table({
    rows: [rootRow, arrowRow, branchRow],
    width: { size: 9500, type: WidthType.DXA },
    borders: {
      top: noBorder, bottom: noBorder, left: noBorder, right: noBorder,
      insideH: noBorder, insideV: noBorder
    }
  });
}

// ════════════════════════════════════════════════════════════════
//  DOCUMENT CONTENT
// ════════════════════════════════════════════════════════════════

const children = [];

// ── COVER ────────────────────────────────────────────────────
children.push(
  spacer(400, 200),
  new Paragraph({
    children: [new TextRun({ text: 'PHARMACOLOGY', bold: true, size: 72, color: BLUE_DARK })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 200, after: 60 }
  }),
  new Paragraph({
    children: [new TextRun({ text: 'Study Guide with Drug Classification Flowcharts', size: 36, color: BLUE_MID, italics: true })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 0, after: 80 }
  }),
  new Paragraph({
    children: [new TextRun({ text: '─────────────────────────────────────', size: 24, color: BLUE_MID })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 40, after: 80 }
  }),
  new Paragraph({
    children: [new TextRun({ text: 'Topics Covered:', bold: true, size: 24, color: BLUE_DARK })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 40, after: 40 }
  }),
  new Paragraph({
    children: [new TextRun({ text: '1. Introduction to Pharmacology', size: 22, color: '333333' })],
    alignment: AlignmentType.CENTER, spacing: { before: 20, after: 20 }
  }),
  new Paragraph({
    children: [new TextRun({ text: '2. Definition and Scope of Pharmacology', size: 22, color: '333333' })],
    alignment: AlignmentType.CENTER, spacing: { before: 20, after: 20 }
  }),
  new Paragraph({
    children: [new TextRun({ text: '3. Drug Nomenclature and Classification Systems', size: 22, color: '333333' })],
    alignment: AlignmentType.CENTER, spacing: { before: 20, after: 20 }
  }),
  spacer(200, 80),
  new Paragraph({
    children: [new TextRun({ text: 'Source: Katzung\'s Basic and Clinical Pharmacology, 16th Edition', size: 18, color: '777777', italics: true })],
    alignment: AlignmentType.CENTER
  }),
  new Paragraph({ children: [new PageBreak()], spacing: { before: 0, after: 0 } })
);

// ── SECTION 1: INTRODUCTION ──────────────────────────────────
children.push(
  h1('SECTION 1: Introduction to Pharmacology'),
  spacer(120, 60),
  h2('1.1  What is Pharmacology?'),
  spacer(60, 40),

  para([normal('Pharmacology is defined as the ', 20), bold('study of substances that interact with living systems', 20, BLUE_DARK), normal(' through chemical processes. These interactions occur by binding of the substance to regulatory molecules, activating or inhibiting normal body processes.', 20)]),
  spacer(80, 60),

  ...callout([
    'Key Definition',
    'Medical Pharmacology = the science of substances used to PREVENT, DIAGNOSE, and TREAT disease.',
    'Toxicology = the branch of pharmacology dealing with UNDESIRABLE effects of chemicals.'
  ]),
  spacer(80, 60),

  h3('Historical Milestones'),
  bullet('~1500 AD: Rational methods began replacing theoretical speculation in medicine'),
  bullet('18th-19th c: Magendie & Bernard developed experimental pharmacology'),
  bullet('1940s-50s: Rapid expansion - discovery of drug receptors and molecular mechanisms'),
  bullet('Today: Pharmacogenomics, biologics, and targeted therapies dominate research'),

  spacer(100, 60),
  h2('1.2  Flowchart: Scope of Pharmacology'),
  spacer(60, 40)
);

// Flowchart 1: Scope of Pharmacology
children.push(
  branchFlowchart('PHARMACOLOGY', [
    { label: 'Pharmacokinetics', sub: 'What body does to drug', fill: '1F3864' },
    { label: 'Pharmacodynamics', sub: 'What drug does to body', fill: '2E75B6' },
    { label: 'Toxicology', sub: 'Harmful effects', fill: 'C0392B' },
    { label: 'Pharmacogenomics', sub: 'Genetics & drug response', fill: '27AE60' }
  ]),
  spacer(120, 80),
  h2('1.3  Key Pharmacodynamic Terms'),
  spacer(60, 40)
);

// Table: Pharmacodynamic terms
children.push(
  dataTable(
    ['Term', 'Definition', 'Example'],
    [
      ['Agonist', 'Binds to receptor AND activates it; mimics endogenous ligand', 'Salbutamol at β2 receptors'],
      ['Full Agonist', 'Produces maximum possible response (100% efficacy)', 'Morphine at μ-opioid receptors'],
      ['Partial Agonist', 'Produces sub-maximal response even at full receptor occupancy; acts as mixed agonist-antagonist', 'Buprenorphine at μ-opioid receptors'],
      ['Inverse Agonist', 'Binds receptor but reduces activity below baseline', 'Some antihistamines at H1 receptors'],
      ['Competitive Antagonist', 'Blocks agonist by competing for same binding site; effect reversible by increasing agonist', 'Propranolol blocks adrenaline at β receptors'],
      ['Non-competitive Antagonist', 'Binds irreversibly or at allosteric site; reduces maximal response', 'Phenoxybenzamine at α receptors'],
      ['Positive Allosteric Modulator', 'Binds different site; enhances receptor activity', 'Benzodiazepines potentiate GABA-A'],
      ['Potency', 'Amount of drug needed for a given effect (EC50)', 'High potency = less drug needed'],
      ['Efficacy', 'Maximum pharmacological effect achievable regardless of dose', 'Ceiling effect of partial agonists']
    ],
    [25, 45, 30]
  ),
  spacer(120, 80)
);

// Flowchart 2: Agonist-Antagonist Spectrum
children.push(
  h2('1.4  Flowchart: Agonist-Antagonist Drug Spectrum'),
  spacer(60, 40),
  horizontalFlowchart([
    { label: 'Full Agonist\n(100% response)', fill: '27AE60' },
    { label: 'Partial Agonist\n(<100% response)', fill: '2E75B6' },
    { label: 'Antagonist\n(0% / blocks)', fill: BLUE_DARK },
    { label: 'Inverse Agonist\n(< Baseline)', fill: 'C0392B' }
  ], '→'),
  spacer(60, 40),
  ...callout([
    'Clinical Pearl: Partial Agonists',
    'Buprenorphine (partial agonist) is safer than fentanyl (full agonist) in opioid therapy because it suppresses breathing less strongly. However, it can antagonize other opioids in combined use.'
  ]),
  spacer(120, 80)
);

// Therapeutic Index
children.push(
  h2('1.5  Therapeutic Index'),
  spacer(60, 40),
  para([bold('Therapeutic Index (TI) = TD50 ÷ ED50', 22, BLUE_DARK)], { alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } }),
  spacer(40, 40),
  dataTable(
    ['Term', 'Meaning'],
    [
      ['ED50', 'Dose effective in 50% of the population'],
      ['TD50', 'Dose toxic in 50% of the population'],
      ['LD50', 'Lethal dose in 50% of animals (preclinical)'],
      ['Narrow TI', 'Small margin; requires therapeutic drug monitoring (e.g., digoxin, warfarin, lithium, aminoglycosides)'],
      ['Wide TI', 'Large safety margin; less monitoring needed (e.g., penicillins, most statins)']
    ],
    [30, 70]
  ),
  spacer(120, 80)
);

// Pharmacokinetics
children.push(
  h2('1.6  Pharmacokinetics (PK) - ADME'),
  spacer(60, 40),
  para([normal('Pharmacokinetics describes ', 20), bold('what the body does to the drug', 20, BLUE_MID), normal(' - encompassing Absorption, Distribution, Metabolism, and Excretion.', 20)]),
  spacer(80, 60)
);

// Flowchart 3: ADME
children.push(
  h3('Flowchart: The ADME Process'),
  spacer(60, 40),
  verticalFlowchart([
    { label: 'ADMINISTRATION\n(Oral / IV / IM / SC / Inhaled)', fill: BLUE_DARK },
    { label: 'A - ABSORPTION\nDrug enters bloodstream from site of administration\nInfluenced by: solubility, formulation, first-pass metabolism', fill: '2980B9' },
    { label: 'D - DISTRIBUTION\nDrug moves from blood into tissues\nInfluenced by: plasma protein binding, lipid solubility, Vd', fill: '2E75B6' },
    { label: 'M - METABOLISM\nPrimarily hepatic (CYP450 enzymes)\nPhase I: oxidation/reduction | Phase II: conjugation', fill: '1A5276' },
    { label: 'E - EXCRETION\nPrimarily renal; also biliary, pulmonary\nDepends on glomerular filtration, tubular secretion', fill: '154360' },
    { label: 'ELIMINATION\nDrug cleared from body\nHalf-life determines dosing frequency', fill: BLUE_DARK }
  ]),
  spacer(80, 60),
  dataTable(
    ['PK Parameter', 'Definition', 'Clinical Relevance'],
    [
      ['Half-life (t½)', 'Time for plasma concentration to fall by 50%', 'Determines dosing interval; ~5 × t½ to reach steady state'],
      ['Volume of Distribution (Vd)', 'Apparent volume in which drug distributes', 'High Vd = extensive tissue binding; low Vd = stays in plasma'],
      ['Clearance (CL)', 'Rate of elimination per unit plasma concentration', 'Determines maintenance dose'],
      ['Bioavailability (F)', 'Fraction of oral dose reaching systemic circulation', 'IV = 100%; oral varies due to first-pass effect'],
      ['AUC', 'Area under plasma concentration-time curve', 'Reflects total drug exposure; used to determine bioequivalence']
    ],
    [25, 38, 37]
  ),
  spacer(120, 80)
);

// Concentration-time curve (text-based)
children.push(
  h2('1.7  Drug Concentration-Time Curve'),
  spacer(60, 40),
  para([normal('The plasma concentration-time curve shows how drug concentration changes over time after a single dose.', 20)]),
  spacer(60, 40),
  dataTable(
    ['Feature', 'Definition'],
    [
      ['Cmax', 'Peak plasma concentration reached'],
      ['Tmax', 'Time at which Cmax is reached'],
      ['MEC (Min. Effective Concentration)', 'Minimum plasma level needed for therapeutic effect'],
      ['MTC (Min. Toxic Concentration)', 'Plasma level above which toxicity occurs'],
      ['Therapeutic Window', 'Range between MEC and MTC — target for dosing'],
      ['AUC', 'Total drug exposure (area under the curve)'],
      ['Rising phase', 'Absorption phase — drug entering blood faster than elimination'],
      ['Falling phase', 'Elimination phase — slope reflects half-life']
    ],
    [40, 60]
  ),
  spacer(80, 60),
  ...callout([
    'Key Concept: Therapeutic Window',
    'Target: maintain plasma concentration ABOVE MEC (effective) and BELOW MTC (toxic).',
    'Narrow therapeutic window drugs (digoxin, phenytoin, lithium) require regular plasma level monitoring.'
  ]),
  spacer(120, 80),
  new Paragraph({ children: [new PageBreak()], spacing: { before: 0, after: 0 } })
);

// ── SECTION 2: DEFINITION AND SCOPE ──────────────────────────
children.push(
  h1('SECTION 2: Definition and Scope of Pharmacology'),
  spacer(120, 60),
  h2('2.1  Primary Components'),
  spacer(60, 40),
  dataTable(
    ['Component', 'Description'],
    [
      ['Drug Actions', 'How a drug interacts with its molecular target (receptor, enzyme, ion channel, transporter)'],
      ['Mechanisms of Action', 'Precise molecular/cellular events triggered by drug-receptor binding'],
      ['Therapeutic Uses', 'Clinical application to prevent, diagnose, or treat disease — determined by PK + PD profile']
    ],
    [30, 70]
  ),
  spacer(100, 60),
  h2('2.2  Subdivisions of Pharmacology'),
  spacer(60, 40)
);

// Flowchart 4: Subdivisions
children.push(
  branchFlowchart('SUBDIVISIONS OF PHARMACOLOGY', [
    { label: 'Clinical\nPharmacology', sub: 'Drug use in patients', fill: '2E75B6' },
    { label: 'Neuropharmacology', sub: 'CNS/PNS drugs', fill: '8E44AD' },
    { label: 'Chemotherapy', sub: 'Anti-infective / anticancer', fill: 'C0392B' },
    { label: 'Immunopharmacology', sub: 'Immune system drugs', fill: '27AE60' },
    { label: 'Toxicology', sub: 'Adverse chemical effects', fill: 'E67E22' }
  ]),
  spacer(120, 80),
  h2('2.3  Adverse Drug Reactions (ADRs)'),
  spacer(60, 40),
  dataTable(
    ['Type', 'Characteristics', 'Example'],
    [
      ['Type A (Augmented)', 'Predictable, dose-dependent; extension of pharmacological action; most common (~80%)', 'Hypoglycemia from excess insulin'],
      ['Type B (Bizarre)', 'Unpredictable, dose-independent; idiosyncratic or immunological; less common but serious', 'Anaphylaxis to penicillin'],
      ['Type C (Chronic)', 'Effects of long-term use', 'HPA axis suppression with prolonged corticosteroids'],
      ['Type D (Delayed)', 'Appear after drug discontinuation', 'Tardive dyskinesia after stopping antipsychotics'],
      ['Type E (End of use)', 'Withdrawal reactions on stopping drug', 'Beta-blocker rebound hypertension']
    ],
    [20, 50, 30]
  ),
  spacer(100, 60),
  h2('2.4  Drug Interactions'),
  spacer(60, 40)
);

// Flowchart 5: Drug Interactions
children.push(
  branchFlowchart('DRUG INTERACTIONS', [
    { label: 'Pharmacokinetic', sub: 'Affects ADME of other drug', fill: '2E75B6' },
    { label: 'Pharmacodynamic', sub: 'Affects receptor/pathway', fill: TEAL }
  ]),
  spacer(60, 40),
  dataTable(
    ['Interaction Type', 'Mechanism', 'Clinical Example'],
    [
      ['CYP450 Induction (PK)', 'Drug A induces liver enzymes → faster metabolism of Drug B → reduced Drug B levels', 'Rifampicin reduces efficacy of oral contraceptives'],
      ['CYP450 Inhibition (PK)', 'Drug A inhibits liver enzymes → slower metabolism of Drug B → Drug B toxicity', 'Clarithromycin + statins → statin toxicity'],
      ['Synergism (PD)', 'Two drugs act on same pathway, producing enhanced combined effect', 'Aspirin + warfarin → increased bleeding risk'],
      ['Antagonism (PD)', 'One drug reduces the effect of another', 'Naloxone reverses opioid effects'],
      ['Protein binding displacement (PK)', 'Drug A displaces Drug B from plasma proteins → increased free Drug B', 'Sulfonamides displace warfarin']
    ],
    [28, 42, 30]
  ),
  spacer(120, 80),
  new Paragraph({ children: [new PageBreak()], spacing: { before: 0, after: 0 } })
);

// ── SECTION 3: DRUG NOMENCLATURE ─────────────────────────────
children.push(
  h1('SECTION 3: Drug Nomenclature and Classification Systems'),
  spacer(120, 60),
  h2('3.1  Three Names of Every Drug'),
  spacer(60, 40),
  dataTable(
    ['Name Type', 'Description', 'Example (Painkiller)'],
    [
      ['Chemical Name', 'Full IUPAC systematic name based on molecular structure; used in chemistry', 'N-(4-hydroxyphenyl)acetamide'],
      ['Generic Name (INN)', 'International Nonproprietary Name — official, non-commercial, globally recognised', 'Paracetamol / Acetaminophen'],
      ['Brand (Proprietary) Name', 'Manufacturer\'s trade name; capitalized; may vary by country', 'Tylenol® / Panadol®']
    ],
    [25, 45, 30]
  ),
  spacer(100, 60),
  h2('3.2  INN Stem System — How to Read Drug Names'),
  spacer(60, 40),
  para([normal('The ', 20), bold('International Nonproprietary Name (INN)', 20, BLUE_DARK), normal(' system uses standardised stems embedded in drug names to indicate the pharmacological class. Learning stems lets you identify a drug\'s class at a glance.', 20)]),
  spacer(80, 60)
);

// Flowchart 6: INN Stems Map
children.push(
  h3('Flowchart: Major INN Suffix Stems'),
  spacer(60, 40),
  branchFlowchart('INN SUFFIX STEMS → Drug Class Identification', [
    { label: '-olol\nBeta-blockers', sub: 'propranolol, atenolol', fill: '1F3864' },
    { label: '-pril\nACE Inhibitors', sub: 'lisinopril, enalapril', fill: '2E75B6' },
    { label: '-sartan\nARBs', sub: 'losartan, valsartan', fill: '2980B9' },
    { label: '-dipine\nCa²⁺ Blockers', sub: 'amlodipine', fill: '1A5276' }
  ]),
  spacer(60, 40),
  branchFlowchart('MORE INN SUFFIX STEMS', [
    { label: '-statin\nHMG-CoA Inhibitors', sub: 'atorvastatin, rosuvastatin', fill: '27AE60' },
    { label: '-cillin\nPenicillins', sub: 'ampicillin, amoxicillin', fill: '1E8449' },
    { label: '-mycin/-micin\nAntibiotics', sub: 'erythromycin, gentamicin', fill: '145A32' },
    { label: '-cycline\nTetracyclines', sub: 'doxycycline', fill: '0E6655' }
  ]),
  spacer(60, 40),
  branchFlowchart('SPECIALTY & BIOLOGIC STEMS', [
    { label: '-mab\nMonoclonal Antibodies', sub: 'trastuzumab, rituximab', fill: '8E44AD' },
    { label: '-nib\nKinase Inhibitors', sub: 'imatinib, gefitinib', fill: '7D3C98' },
    { label: '-vir\nAntivirals', sub: 'aciclovir, oseltamivir', fill: 'E67E22' },
    { label: '-azole\nAntifungals/PPIs', sub: 'fluconazole, omeprazole', fill: 'D35400' }
  ]),
  spacer(100, 80)
);

// Full stems table
children.push(
  h3('Complete INN Stem Reference Table'),
  spacer(60, 40),
  dataTable(
    ['Stem', 'Class', 'Mechanism', 'Key Examples'],
    [
      ['-olol', 'Beta-blockers', 'Block β-adrenergic receptors → ↓ heart rate, BP, cardiac output', 'Propranolol (non-selective), Atenolol (β1-selective), Metoprolol (β1-selective), Bisoprolol'],
      ['-pril', 'ACE Inhibitors', 'Inhibit ACE → ↓ Angiotensin II, ↑ Bradykinin → vasodilation', 'Lisinopril, Enalapril, Ramipril, Captopril, Perindopril'],
      ['-sartan', 'ARBs (AT1 blockers)', 'Block angiotensin II AT1 receptor → vasodilation', 'Losartan, Valsartan, Irbesartan, Candesartan, Olmesartan'],
      ['-dipine', 'Dihydropyridine CCBs', 'Block L-type Ca²⁺ channels in vascular smooth muscle → vasodilation', 'Amlodipine, Nifedipine, Felodipine, Lercanidipine'],
      ['-statin', 'HMG-CoA reductase inhibitors', 'Inhibit rate-limiting step in cholesterol synthesis in liver', 'Atorvastatin, Rosuvastatin, Simvastatin, Pravastatin'],
      ['-cillin', 'Penicillin antibiotics', 'Inhibit bacterial cell wall synthesis by blocking PBPs (β-lactam ring)', 'Ampicillin, Amoxicillin, Flucloxacillin, Piperacillin'],
      ['-mycin/-micin', 'Macrolides / Aminoglycosides', 'Inhibit bacterial protein synthesis (30S or 50S ribosome)', 'Erythromycin, Azithromycin, Gentamicin, Tobramycin'],
      ['-cycline', 'Tetracycline antibiotics', 'Inhibit bacterial protein synthesis at 30S ribosomal subunit', 'Doxycycline, Tetracycline, Minocycline'],
      ['-mab', 'Monoclonal antibodies', 'Target-specific protein (receptor, cytokine, cell surface antigen)', 'Trastuzumab (HER2), Rituximab (CD20), Adalimumab (TNF-α)'],
      ['-nib', 'Tyrosine kinase inhibitors', 'Block intracellular kinase signalling → anti-proliferative', 'Imatinib (BCR-ABL), Gefitinib (EGFR), Erlotinib (EGFR)'],
      ['-vir', 'Antivirals', 'Various: nucleoside analogues, protease/neuraminidase inhibitors', 'Aciclovir, Oseltamivir, Ritonavir, Tenofovir'],
      ['-azole', 'Antifungals / PPIs', 'Azole antifungals: inhibit ergosterol synthesis; PPIs: inhibit H⁺/K⁺-ATPase', 'Fluconazole, Itraconazole, Omeprazole, Esomeprazole']
    ],
    [15, 20, 35, 30]
  ),
  spacer(100, 80)
);

// Prefixes
children.push(
  h2('3.3  INN Prefix Stems'),
  spacer(60, 40),
  dataTable(
    ['Prefix', 'Meaning', 'Clinical Significance', 'Examples'],
    [
      ['Es-', 'S-enantiomer of a racemic parent drug', 'Often has improved efficacy/selectivity vs. the racemate; launched as isomer switch', 'Esomeprazole (S-omeprazole), Escitalopram (S-citalopram)'],
      ['Levo- / L-', 'Levorotatory isomer (rotates polarized light to left)', 'Biologically active stereoisomer in many cases', 'Levothyroxine (L-T4 - active), Levofloxacin, Levothyroxine, Levodopa'],
      ['Dex- / Dextro-', 'Dextrorotatory isomer (right-rotating)', 'May be more potent or have different activity vs. L-form', 'Dextromethorphan, Dexamfetamine, Dexamethasone'],
      ['Nor-', 'Parent compound without N-methyl group (de-methylated)', 'Often less potent but longer-acting; some active metabolites', 'Norepinephrine (from epinephrine), Norfloxacin, Nortriptyline'],
      ['Iso-', 'Isomeric or isopropylamino form', 'Different receptor selectivity vs. parent', 'Isoproterenol (β1+β2 agonist), Isoflurane']
    ],
    [18, 22, 32, 28]
  ),
  spacer(80, 60),
  ...callout([
    'Isomer Switch Drugs - Exam Tip',
    'Es- and Levo- prefix drugs are "isomer switch" products — purified enantiomers of older racemic drugs.',
    'Esomeprazole = S-enantiomer of omeprazole → better acid suppression',
    'Levothyroxine = L-isomer of thyroxine → biologically active form for thyroid replacement'
  ]),
  spacer(120, 80)
);

// ── SECTION 4: CLASSIFICATION SYSTEMS ────────────────────────
children.push(
  h1('SECTION 4: Drug Classification Flowcharts'),
  spacer(120, 60),
  h2('4.1  Overview Flowchart: How Drugs are Classified'),
  spacer(60, 40)
);

children.push(
  branchFlowchart('DRUG CLASSIFICATION SYSTEMS', [
    { label: 'By Mechanism\n(Pharmacological)', sub: 'Most important clinically', fill: BLUE_DARK },
    { label: 'By Therapeutic\nUse', sub: 'e.g., antihypertensive', fill: '2E75B6' },
    { label: 'By Chemical\nStructure', sub: 'e.g., beta-lactams', fill: TEAL },
    { label: 'By Receptor\nTarget', sub: 'e.g., adrenergic', fill: '27AE60' },
    { label: 'ATC System\n(WHO)', sub: '5-level hierarchy', fill: '8E44AD' }
  ]),
  spacer(100, 80)
);

// Cardiovascular
children.push(
  h2('4.2  Cardiovascular Drug Classification Flowchart'),
  spacer(60, 40),
  branchFlowchart('CARDIOVASCULAR DRUGS', [
    { label: 'Antihypertensives', sub: 'Lower blood pressure', fill: '1F3864' },
    { label: 'Antiarrhythmics', sub: 'Restore rhythm', fill: '2E75B6' },
    { label: 'Antithrombotics', sub: 'Prevent clots', fill: 'C0392B' },
    { label: 'Heart Failure', sub: 'Inotropes / diuretics', fill: '27AE60' }
  ]),
  spacer(60, 40),
  h3('Antihypertensives by Mechanism'),
  spacer(40, 40),
  dataTable(
    ['Class (INN Stem)', 'Mechanism', 'Examples', 'Key Notes'],
    [
      ['Beta-blockers (-olol)', 'Block β1 receptors → ↓ HR and cardiac output', 'Atenolol, Metoprolol, Bisoprolol', 'Avoid in asthma; first-line in post-MI, heart failure'],
      ['ACE Inhibitors (-pril)', 'Block ACE → ↓ Ang II, ↑ bradykinin → vasodilation', 'Lisinopril, Ramipril, Enalapril', 'Cough (bradykinin); contraindicated in pregnancy; protect kidneys in diabetics'],
      ['ARBs (-sartan)', 'Block AT1 receptor → vasodilation', 'Losartan, Valsartan', 'No cough; preferred if ACEi cough; also renoprotective'],
      ['Dihydropyridine CCBs (-dipine)', 'Block L-type Ca²⁺ channels in vessels → vasodilation', 'Amlodipine, Nifedipine', 'Ankle oedema; reflex tachycardia with short-acting forms'],
      ['Thiazide diuretics (-ide)', 'Inhibit Na⁺/Cl⁻ cotransporter in DCT → natriuresis', 'Hydrochlorothiazide, Indapamide', 'First-line in elderly, Afro-Caribbean; watch K⁺'],
      ['Aldosterone antagonists', 'Block mineralocorticoid receptors → Na⁺ excretion', 'Spironolactone, Eplerenone', 'K⁺-sparing; useful in heart failure, Conn\'s syndrome']
    ],
    [22, 28, 25, 25]
  ),
  spacer(100, 80)
);

// Antibiotics
children.push(
  h2('4.3  Antibiotic Classification Flowchart'),
  spacer(60, 40),
  branchFlowchart('ANTIBIOTICS', [
    { label: 'Cell Wall\nSynthesis Inhibitors', sub: 'β-lactams, glycopeptides', fill: '1E8449' },
    { label: 'Protein Synthesis\nInhibitors', sub: '30S and 50S blockers', fill: '27AE60' },
    { label: 'DNA/RNA\nSynthesis Inhibitors', sub: 'Fluoroquinolones, rifampicin', fill: '145A32' },
    { label: 'Cell Membrane\nDisruptors', sub: 'Polymyxins, daptomycin', fill: '0B5345' }
  ]),
  spacer(60, 40),
  dataTable(
    ['Class (INN Stem)', 'Mechanism', 'Examples', 'Spectrum'],
    [
      ['Penicillins (-cillin)', 'Inhibit PBPs → block peptidoglycan crosslinking → cell lysis', 'Amoxicillin, Ampicillin, Piperacillin, Flucloxacillin', 'Variable; flucloxacillin for Staph; piperacillin for Pseudomonas'],
      ['Cephalosporins (-cef/-ceph)', 'Same as penicillins (β-lactam ring); broader spectrum across generations', 'Cefalexin (1st), Cefuroxime (2nd), Ceftriaxone (3rd), Cefepime (4th)', 'Progressively broader gram-negative; 3rd-gen cross BBB'],
      ['Carbapenems', 'Broadest β-lactam; resist most β-lactamases', 'Meropenem, Imipenem, Ertapenem', 'Gram+, Gram−, anaerobes; last resort for ESBL organisms'],
      ['Macrolides (-mycin)', 'Bind 50S ribosome → inhibit translocation', 'Azithromycin, Erythromycin, Clarithromycin', 'Atypicals (Legionella, Mycoplasma); good tissue penetration'],
      ['Aminoglycosides (-micin/-mycin)', 'Bind 30S ribosome → misreading of mRNA', 'Gentamicin, Tobramycin, Amikacin', 'Gram-negative bactericidal; nephrotoxic, ototoxic'],
      ['Tetracyclines (-cycline)', 'Bind 30S ribosome → block aminoacyl-tRNA binding', 'Doxycycline, Minocycline', 'Broad spectrum; atypicals, Chlamydia, Rickettsia'],
      ['Fluoroquinolones (-floxacin)', 'Inhibit DNA gyrase (topoisomerase II) and topoisomerase IV', 'Ciprofloxacin, Levofloxacin, Moxifloxacin', 'Gram− and Gram+; UTI, RTI, anthrax'],
      ['Glycopeptides', 'Bind D-Ala-D-Ala on peptidoglycan → block cell wall synthesis', 'Vancomycin, Teicoplanin', 'MRSA, C. difficile (oral vancomycin); IV for serious Gram+']
    ],
    [20, 30, 25, 25]
  ),
  spacer(100, 80)
);

// Lipid-lowering
children.push(
  h2('4.4  Lipid-Lowering Drug Classification Flowchart'),
  spacer(60, 40),
  branchFlowchart('LIPID-LOWERING DRUGS', [
    { label: 'Statins (-statin)', sub: 'HMG-CoA reductase inhibitors', fill: '2C3E50' },
    { label: 'Fibrates (-fibrate)', sub: 'PPAR-α agonists', fill: '2E4057' },
    { label: 'Ezetimibe', sub: 'Cholesterol absorption inhibitor', fill: '27AE60' },
    { label: 'PCSK9 Inhibitors (-mab)', sub: 'Monoclonal antibodies', fill: '8E44AD' }
  ]),
  spacer(60, 40),
  dataTable(
    ['Class', 'Mechanism', 'Primary Effect', 'Examples'],
    [
      ['Statins (-statin)', 'Inhibit HMG-CoA reductase → ↓ hepatic cholesterol synthesis → upregulate LDL receptors → ↓ LDL', '↓ LDL-C (30-50%)', 'Atorvastatin, Rosuvastatin, Simvastatin, Pravastatin'],
      ['Fibrates (-fibrate)', 'Activate PPAR-α → ↑ lipoprotein lipase → ↑ TG clearance', '↓ Triglycerides (↑ HDL)', 'Fenofibrate, Gemfibrozil'],
      ['Ezetimibe', 'Blocks NPC1L1 transporter in intestinal brush border → ↓ cholesterol absorption', '↓ LDL-C (15-20%)', 'Ezetimibe (Ezetrol)'],
      ['PCSK9 Inhibitors (-mab)', 'Bind PCSK9 → prevent LDL receptor degradation → ↑↑ LDL receptor recycling', '↓ LDL-C (50-60%); for familial hypercholesterolemia', 'Evolocumab (Repatha), Alirocumab (Praluent)']
    ],
    [20, 35, 25, 20]
  ),
  spacer(120, 80)
);

// Quick Reference
children.push(
  h1('QUICK REFERENCE: INN Stems Cheat Sheet'),
  spacer(100, 60),
  dataTable(
    ['Stem', 'Class', 'Prototype Drug'],
    [
      ['-olol', 'Beta-blockers', 'Propranolol'],
      ['-pril', 'ACE Inhibitors', 'Lisinopril'],
      ['-sartan', 'ARBs', 'Losartan'],
      ['-dipine', 'Dihydropyridine CCBs', 'Amlodipine'],
      ['-statin', 'HMG-CoA reductase inhibitors', 'Atorvastatin'],
      ['-cillin', 'Penicillin antibiotics', 'Ampicillin'],
      ['-cycline', 'Tetracycline antibiotics', 'Doxycycline'],
      ['-mycin / -micin', 'Macrolides / Aminoglycosides', 'Azithromycin / Gentamicin'],
      ['-floxacin', 'Fluoroquinolones', 'Ciprofloxacin'],
      ['-mab', 'Monoclonal antibodies', 'Trastuzumab'],
      ['-nib', 'Tyrosine kinase inhibitors', 'Imatinib'],
      ['-vir', 'Antivirals', 'Aciclovir'],
      ['-azole', 'Antifungals / PPIs', 'Omeprazole'],
      ['Es-', 'S-enantiomer (isomer switch)', 'Esomeprazole'],
      ['Levo-', 'Levorotatory isomer', 'Levothyroxine'],
      ['Nor-', 'De-methylated derivative', 'Norepinephrine'],
      ['Dex-', 'Dextrorotatory isomer', 'Dexamethasone']
    ],
    [25, 45, 30]
  ),
  spacer(100, 80),
  ...callout([
    'Study Tip: Using Stems in Clinical Practice',
    '1. See a new drug name → identify the stem → know the class instantly',
    '2. Know the class → predict mechanism, side effects, contraindications, and monitoring',
    '3. Example: "empagliflozin" → contains "-flozin" stem → SGLT2 inhibitor → glucose excretion in urine'
  ]),
  spacer(120, 80),
  new Paragraph({
    children: [new TextRun({ text: 'Source: Katzung\'s Basic and Clinical Pharmacology, 16th Edition', size: 18, color: '777777', italics: true })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 100, after: 100 }
  })
);

// ── BUILD DOCUMENT ────────────────────────────────────────────
const doc = new Document({
  numbering: {
    config: []
  },
  styles: {
    default: {
      document: {
        run: { font: 'Calibri', size: 20 }
      }
    }
  },
  sections: [{
    properties: {
      page: {
        margin: {
          top: convertInchesToTwip(0.9),
          bottom: convertInchesToTwip(0.9),
          left: convertInchesToTwip(1),
          right: convertInchesToTwip(1)
        }
      }
    },
    headers: {
      default: new Header({
        children: [new Paragraph({
          children: [
            new TextRun({ text: 'Pharmacology Study Guide  |  Drug Classification', size: 18, color: '888888' }),
          ],
          alignment: AlignmentType.RIGHT,
          border: { bottom: solidBorder('CCCCCC', 4) }
        })]
      })
    },
    footers: {
      default: new Footer({
        children: [new Paragraph({
          children: [
            new TextRun({ text: 'Katzung\'s Basic & Clinical Pharmacology, 16th Ed.    |    Page ', size: 16, color: '888888' }),
            new TextRun({ children: [PageNumber.CURRENT], size: 16, color: '888888' })
          ],
          alignment: AlignmentType.CENTER,
          border: { top: solidBorder('CCCCCC', 4) }
        })]
      })
    },
    children
  }]
});

Packer.toBuffer(doc).then(buf => {
  fs.writeFileSync('/home/daytona/workspace/pharmacology-guide/Pharmacology_Study_Guide.docx', buf);
  console.log('SUCCESS: File written.');
}).catch(err => {
  console.error('ERROR:', err.message);
  process.exit(1);
});
Running Command

node /home/daytona/workspace/pharmacology-guide/generate.js 2>&1

Running Command

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

Running Command

ls -lh /home/daytona/workspace/pharmacology-guide/ && python3 -c " import zipfil…

Your Pharmacology Study Guide DOCX is ready:

Pharmacology Study Guide

Word Document · DOCX


Here's what's inside the document (27 KB, fully formatted):
Cover Page
  • Title, topic list, source credit (Katzung's 16th Ed.)
Section 1 - Introduction to Pharmacology
  • Definition, history timeline
  • Flowchart: Scope of pharmacology (PK / PD / Toxicology / Pharmacogenomics)
  • Full table of pharmacodynamic terms (agonist, antagonist, partial agonist, allosteric modulator, etc.)
  • Flowchart: Agonist-Antagonist Drug Spectrum (Full → Partial → Antagonist → Inverse)
  • Therapeutic Index table (ED50, TD50, narrow vs. wide TI drugs)
  • Flowchart: ADME process (vertical step-by-step)
  • PK parameters table (t½, Vd, CL, F, AUC)
  • Drug concentration-time curve reference table (Cmax, Tmax, MEC, MTC, therapeutic window)
Section 2 - Definition and Scope
  • Primary components table, subdivisions flowchart
  • ADR types table (Type A-E)
  • Drug interactions flowchart (PK vs. PD) + examples table
Section 3 - Drug Nomenclature
  • Three drug names table (chemical / generic / brand)
  • Three INN stem flowcharts (suffix stems, specialty stems, biologic stems)
  • Complete suffix stem reference table (12 stems with mechanism + examples)
  • INN prefix table (Es-, Levo-, Dex-, Nor-, Iso-)
Section 4 - Drug Classification Flowcharts
  • Master classification flowchart (5 systems)
  • Cardiovascular drugs flowchart + antihypertensives table
  • Antibiotics classification flowchart + mechanism table (8 classes)
  • Lipid-lowering drugs flowchart + table (statins, fibrates, ezetimibe, PCSK9 inhibitors)
Quick Reference Cheat Sheet - all 17 INN stems in one table
This is a shared conversation. Sign in to Orris to start your own chat.