~/drug-interactions/generate.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
HeadingLevel, AlignmentType, BorderStyle, WidthType, ShadingType,
VerticalAlign, PageNumber, PageBreak, Header, Footer, LevelFormat
} = require('docx');
const fs = require('fs');
// ββ Colour palette ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const NAVY = "1F3864"; // dark navy β headers
const TEAL = "1F7A8C"; // teal β case title bars
const LIGHT = "D9E8F0"; // light blue β shading
const YELLOW = "FFF2CC"; // light yellow β highlight rows
const WHITE = "FFFFFF";
const BLACK = "000000";
const RED = "C00000"; // severity major/life-threatening
const GREEN = "375623"; // accepted
// ββ Helper: bold coloured text βββββββββββββββββββββββββββββββββββββββββββββββ
const run = (text, opts = {}) =>
new TextRun({ text, font: "Arial", size: opts.size || 22,
bold: opts.bold || false, italics: opts.italics || false,
color: opts.color || BLACK, allCaps: opts.allCaps || false });
// ββ Helper: paragraph ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const para = (children, opts = {}) =>
new Paragraph({
alignment: opts.align || AlignmentType.LEFT,
spacing: { before: opts.before ?? 60, after: opts.after ?? 60 },
children: Array.isArray(children) ? children : [children]
});
// ββ Helper: section heading paragraph βββββββββββββββββββββββββββββββββββββββ
const fieldLabel = (label, value) =>
para([
run(label + ": ", { bold: true, size: 20, color: NAVY }),
run(value, { size: 20 })
], { before: 40, after: 40 });
// ββ Helper: numbered suggestion βββββββββββββββββββββββββββββββββββββββββββββ
const suggLine = (n, text) =>
new Paragraph({
spacing: { before: 30, after: 30 },
indent: { left: 360, hanging: 280 },
children: [
run(n + ". ", { bold: true, size: 20, color: TEAL }),
run(text, { size: 20 })
]
});
// ββ Helper: coloured cell ββββββββββββββββββββββββββββββββββββββββββββββββββββ
const cell = (text, opts = {}) =>
new TableCell({
shading: opts.shade ? { fill: opts.shade, type: ShadingType.CLEAR, color: "auto" } : undefined,
width: opts.width ? { size: opts.width, type: WidthType.DXA } : undefined,
columnSpan: opts.span || 1,
verticalAlign: VerticalAlign.CENTER,
margins: { top: 80, bottom: 80, left: 120, right: 120 },
borders: opts.noBorder ? {
top: { style: BorderStyle.NONE }, bottom: { style: BorderStyle.NONE },
left: { style: BorderStyle.NONE }, right: { style: BorderStyle.NONE }
} : undefined,
children: [
new Paragraph({
alignment: opts.center ? AlignmentType.CENTER : AlignmentType.LEFT,
spacing: { before: 0, after: 0 },
children: [run(text, { bold: opts.bold || false, size: opts.size || 20,
color: opts.color || BLACK, italics: opts.italics || false })]
})
]
});
// ββ Helper: table row ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const trow = (cells) => new TableRow({ children: cells });
// ββ Helper: page break βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const pageBreak = () => new Paragraph({ children: [new PageBreak()] });
// ββ Helper: horizontal rule (thick border bottom) βββββββββββββββββββββββββββ
const hrule = () => new Paragraph({
spacing: { before: 0, after: 0 },
border: { bottom: { style: BorderStyle.THICK, size: 6, color: TEAL } },
children: [run("")]
});
// ββ Case title bar ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const caseTitle = (n, title) =>
new Paragraph({
spacing: { before: 160, after: 80 },
shading: { fill: TEAL, type: ShadingType.CLEAR, color: "auto" },
alignment: AlignmentType.CENTER,
children: [
run(`CASE ${n} | `, { bold: true, size: 26, color: WHITE }),
run(title, { bold: true, size: 26, color: WHITE })
]
});
// ββ Section label paragraph βββββββββββββββββββββββββββββββββββββββββββββββββββ
const sectionLabel = (text) =>
new Paragraph({
spacing: { before: 120, after: 40 },
shading: { fill: LIGHT, type: ShadingType.CLEAR, color: "auto" },
children: [run(text, { bold: true, size: 21, color: NAVY, allCaps: true })]
});
// ββ Patient info table ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const patientTable = (data) => new Table({
width: { size: 9026, type: WidthType.DXA },
rows: [
trow([
cell("Patient Name:", { shade: LIGHT, bold: true, size: 19, width: 1800 }),
cell(data.name, { size: 19, width: 2000 }),
cell("Age:", { shade: LIGHT, bold: true, size: 19, width: 800 }),
cell(data.age, { size: 19, width: 800 }),
cell("Date of Admission:", { shade: LIGHT, bold: true, size: 19, width: 1800 }),
cell(data.doa, { size: 19, width: 1826 })
]),
trow([
cell("IP/OP No:", { shade: LIGHT, bold: true, size: 19 }),
cell(data.ipop, { size: 19 }),
cell("Wt (kg):", { shade: LIGHT, bold: true, size: 19 }),
cell(data.weight, { size: 19 }),
cell("Gender:", { shade: LIGHT, bold: true, size: 19 }),
cell(data.gender, { size: 19 })
]),
trow([
cell("Intervention Date:", { shade: LIGHT, bold: true, size: 19 }),
cell(data.intDate, { size: 19 }),
cell("Unit:", { shade: LIGHT, bold: true, size: 19 }),
cell(data.unit, { size: 19, span: 3 })
])
]
});
// ββ Text block ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const textBlock = (text) =>
new Paragraph({ spacing: { before: 40, after: 40 }, children: [run(text, { size: 20 })] });
// ββ Signature table ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const sigTable = (hcp, pharmacist, preceptor, informed, accepted) =>
new Table({
width: { size: 9026, type: WidthType.DXA },
rows: [
trow([
cell("Informed to HCP?", { shade: LIGHT, bold: true, size: 19, width: 2000 }),
cell(informed, { size: 20, bold: true, color: informed === "YES" ? GREEN : RED, width: 2513 }),
cell("Name & Signature of HCP:", { shade: LIGHT, bold: true, size: 19, width: 2000 }),
cell(hcp, { size: 19, width: 2513 })
]),
trow([
cell("Accepted?", { shade: LIGHT, bold: true, size: 19 }),
cell(accepted, { size: 20, bold: true, color: accepted === "YES" ? GREEN : RED }),
cell("Name & Signature of Pharmacist:", { shade: LIGHT, bold: true, size: 19 }),
cell(pharmacist, { size: 19 })
]),
trow([
cell("Preceptor's Name & Signature:", { shade: LIGHT, bold: true, size: 19 }),
cell(preceptor, { size: 19, span: 3 })
])
]
});
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// SUMMARY TABLE
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const summaryTable = () => {
const headers = ["#", "Drug Pair", "Mechanism", "Severity", "Clinical Risk", "Key Action"];
const widths = [400, 2000, 2000, 1000, 1600, 2026];
const rows = [
["1","Warfarin + Aspirin","Additive anticoagulation + GI mucosal injury","MAJOR","GI Bleeding, supratherapeutic INR","Hold warfarin, add PPI"],
["2","Ciprofloxacin + Metformin","OCT2 inhibition -> reduced renal clearance","MAJOR","Lactic acidosis, hypoglycemia","Dose-reduce metformin; alternate antibiotic"],
["3","Phenytoin + Amlodipine","CYP3A4 induction -> subtherapeutic amlodipine","MAJOR","Uncontrolled hypertension","Switch to atenolol/losartan"],
["4","Fluoxetine + Sumatriptan","Combined serotonergic excess","LIFE-THREATENING","Serotonin Syndrome","Stop sumatriptan; use NSAIDs for migraine"],
["5","ACE Inhibitor + Indomethacin","Dual renal haemodynamic compromise","MAJOR","AKI on CKD","Stop NSAID; use colchicine/steroids"],
["6","Rifampicin + OCP","CYP3A4 induction -> reduced OCP levels","MAJOR","Contraceptive failure","Switch to copper-IUD or barrier method"],
["7","Digoxin + Furosemide","Hypokalemia potentiates Na/K-ATPase inhibition","LIFE-THREATENING","Digoxin toxicity, bradycardia","Hold digoxin; IV K+; add spironolactone"],
["8","Levothyroxine + Ferrous Sulfate","Chelation -> reduced T4 absorption","MODERATE","Uncontrolled hypothyroidism","Separate by 4+ hrs; empty stomach for T4"],
["9","Theophylline + Clarithromycin","CYP3A4 inhibition -> theophylline accumulation","LIFE-THREATENING","Toxicity: tachycardia, seizures","Hold theophylline; substitute antibiotic"],
["10","Alendronate + Calcium Carbonate","GI chelation -> reduced bisphosphonate absorption","MODERATE","Therapeutic failure, worsening osteoporosis","Correct timing; separate by 2+ hours"],
];
const headerRow = trow(headers.map((h, i) =>
new TableCell({
shading: { fill: NAVY, type: ShadingType.CLEAR, color: "auto" },
width: { size: widths[i], type: WidthType.DXA },
verticalAlign: VerticalAlign.CENTER,
margins: { top: 80, bottom: 80, left: 100, right: 100 },
children: [new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 0 },
children: [run(h, { bold: true, size: 18, color: WHITE })]
})]
})
));
const dataRows = rows.map((r, ri) =>
trow(r.map((val, ci) =>
new TableCell({
shading: { fill: ri % 2 === 0 ? WHITE : LIGHT, type: ShadingType.CLEAR, color: "auto" },
width: { size: widths[ci], type: WidthType.DXA },
verticalAlign: VerticalAlign.CENTER,
margins: { top: 60, bottom: 60, left: 100, right: 100 },
children: [new Paragraph({
alignment: ci === 0 ? AlignmentType.CENTER : AlignmentType.LEFT,
spacing: { before: 0, after: 0 },
children: [run(val, {
size: 18,
bold: ci === 0 || (ci === 3 && (val === "LIFE-THREATENING" || val === "MAJOR")),
color: ci === 3 ? (val === "LIFE-THREATENING" ? RED : val === "MAJOR" ? "B45309" : BLACK) : BLACK
})]
})]
})
))
);
return new Table({ width: { size: 9026, type: WidthType.DXA }, rows: [headerRow, ...dataRows] });
};
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// BUILD CASE BLOCKS
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function buildCase(n, caseData) {
const blocks = [];
blocks.push(caseTitle(n, caseData.title));
blocks.push(patientTable(caseData.patient));
blocks.push(new Paragraph({ spacing: { before: 80, after: 0 }, children: [run("")] }));
blocks.push(sectionLabel("Reason for Admission / Visit C/O"));
blocks.push(textBlock(caseData.reason));
blocks.push(sectionLabel("Drug Related Problem(s) Identified"));
blocks.push(new Paragraph({ spacing: { before: 40, after: 20 }, children: [
run("Drug Pair: ", { bold: true, size: 21, color: RED }),
run(caseData.drugPair, { bold: true, size: 21, color: RED })
]}));
blocks.push(textBlock(caseData.problem));
blocks.push(sectionLabel("Reason(s) for Intervention"));
caseData.reasons.forEach((r, i) => blocks.push(suggLine(i + 1, r)));
blocks.push(sectionLabel("Suggestions Made"));
caseData.suggestions.forEach((s, i) => blocks.push(suggLine(i + 1, s)));
blocks.push(new Paragraph({ spacing: { before: 100, after: 40 }, children: [run("")] }));
blocks.push(sigTable(caseData.hcp, "Pharm. Arjun Hegde", "Dr. Noorjahan, Dept. of Clinical Pharmacy", "YES", "YES"));
blocks.push(hrule());
return blocks;
}
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// CASE DATA
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const cases = [
{
title: "Warfarin + Aspirin",
patient: { name: "Ramesh Kumar", age: "62 yrs", doa: "13/07/2026", ipop: "IP/2026/001",
weight: "72 kg", gender: "Male", intDate: "13/07/2026", unit: "Cardiology Ward" },
reason: "Patient admitted with chest pain, palpitations, and shortness of breath. Diagnosed with Atrial Fibrillation (AF) and Ischemic Heart Disease. Currently on long-term anticoagulation therapy with warfarin. Aspirin 300 mg was co-prescribed by a different physician for its antiplatelet effect.",
drugPair: "Warfarin + Aspirin (300 mg)",
problem: "Both drugs were prescribed concurrently producing a major pharmacodynamic interaction. Warfarin is a Vitamin K antagonist and Aspirin irreversibly inhibits platelet COX-1, blocking thromboxane A2-mediated platelet aggregation. Together they produce additive/synergistic anticoagulation with significantly increased bleeding risk. Aspirin also irritates the gastric mucosa, compounding hemorrhagic risk. INR on admission: 4.2 (therapeutic range 2.0-3.0). Patient reported melena (black tarry stools) indicating upper GI bleeding.",
reasons: [
"INR supratherapeutic at 4.2 - above therapeutic range of 2.0-3.0",
"Concurrent antiplatelet + anticoagulant prescribed without gastroprotective cover",
"Melena indicating active upper GI bleed",
"No prior documentation of intentional dual therapy (e.g., mechanical heart valve indication)",
"Patient had not been counseled on bleeding risk signs"
],
suggestions: [
"Temporarily hold warfarin dose and recheck INR after 48 hours",
"Add Pantoprazole 40 mg OD as gastroprotective therapy",
"Evaluate necessity of dual therapy (warfarin + aspirin) for this patient's specific indication",
"If dual therapy is truly essential (e.g., AF + recent ACS), reduce aspirin to lowest effective dose (75 mg)",
"Counsel patient on signs of bleeding: unusual bruising, blood in urine, black stools",
"Dietary counseling on Vitamin K-containing foods affecting INR",
"Regular INR monitoring every 2 weeks once stable"
],
hcp: "Dr. Suresh Naik, Cardiologist"
},
{
title: "Ciprofloxacin + Metformin",
patient: { name: "Sunita Devi", age: "55 yrs", doa: "13/07/2026", ipop: "IP/2026/002",
weight: "65 kg", gender: "Female", intDate: "13/07/2026", unit: "General Medicine" },
reason: "Patient with known Type 2 Diabetes Mellitus on Metformin 1000 mg BD admitted with urinary tract infection (UTI). Ciprofloxacin 500 mg BD prescribed by the treating physician. Hypoglycemia episode (BG: 58 mg/dL) noted on Day 1.",
drugPair: "Ciprofloxacin (Fluoroquinolone) + Metformin (Biguanide)",
problem: "Ciprofloxacin inhibits organic cation transporter 2 (OCT2) in the renal tubules - the primary secretory elimination pathway for metformin. This inhibition reduces metformin renal clearance, increasing plasma levels and risk of lactic acidosis. Fluoroquinolones independently cause dysglycemia (both hypoglycemia and hyperglycemia). Patient eGFR borderline at 52 mL/min/1.73m2 further reducing metformin clearance. Blood glucose on admission: 58 mg/dL. Lactic acidosis is rare but potentially fatal.",
reasons: [
"Hypoglycemia episode (BG 58 mg/dL) on Day 1 of combined therapy",
"Metformin dose not adjusted despite new fluoroquinolone prescription",
"Borderline eGFR (52 mL/min/1.73m2) already compromising metformin renal clearance",
"No monitoring plan documented for renal function or blood glucose during antibiotic course"
],
suggestions: [
"Reduce Metformin dose to 500 mg BD during the antibiotic course",
"Monitor blood glucose every 4 hours during treatment",
"Monitor serum creatinine and eGFR every 48 hours",
"Consider switching antibiotic to Nitrofurantoin or Co-trimoxazole for uncomplicated UTI (less interaction risk)",
"Counsel patient to report muscle pain, weakness, or difficulty breathing (lactic acidosis symptoms)",
"Resume standard metformin dose only after completing antibiotics and confirming stable renal function"
],
hcp: "Dr. Meera Krishnamurthy, General Physician"
},
{
title: "Phenytoin + Amlodipine",
patient: { name: "Ajay Sharma", age: "48 yrs", doa: "13/07/2026", ipop: "OP/2026/003",
weight: "80 kg", gender: "Male", intDate: "13/07/2026", unit: "Neurology OPD" },
reason: "Patient with longstanding epilepsy on Phenytoin 300 mg OD presenting for review. Diagnosed with essential hypertension 3 months ago and started on Amlodipine 10 mg OD (maximum dose). BP remains poorly controlled at 156/98 mmHg despite 3 months of therapy.",
drugPair: "Phenytoin (Antiepileptic) + Amlodipine (CCB)",
problem: "Phenytoin is a potent inducer of hepatic CYP3A4. Amlodipine, a dihydropyridine calcium channel blocker, is primarily metabolized by CYP3A4. Phenytoin dramatically accelerates amlodipine metabolism, reducing plasma amlodipine concentrations by up to 80-90%. This results in subtherapeutic amlodipine levels and loss of antihypertensive effect, explaining persistent poor BP control despite maximum dosing. Further increasing amlodipine beyond 10 mg is not clinically feasible.",
reasons: [
"BP inadequately controlled (156/98 mmHg) on maximum dose amlodipine (10 mg OD) for 3 months",
"Pharmacokinetic drug interaction with phenytoin (CYP3A4 inducer) identified as likely cause",
"Further increasing amlodipine dose not recommended and would be ineffective",
"Risk of hypertensive stroke or cardiac event if unaddressed"
],
suggestions: [
"Discontinue Amlodipine - ineffective in the presence of a strong CYP3A4 inducer",
"Switch to Atenolol 50 mg OD (beta-blocker, not a CYP3A4 substrate - safe alternative)",
"Alternatively consider Losartan (ARB) - minimal CYP3A4 involvement",
"Add Chlorthalidone (thiazide-like diuretic) if BP control remains inadequate on monotherapy",
"Recheck BP in 4 weeks after switching antihypertensive",
"Therapeutic drug monitoring (TDM) of phenytoin levels to ensure anti-epileptic efficacy",
"Do NOT abruptly stop phenytoin - risk of breakthrough seizures"
],
hcp: "Dr. Praveen Kamath, Neurologist"
},
{
title: "Fluoxetine (SSRI) + Sumatriptan (Triptan)",
patient: { name: "Fatima Begum", age: "60 yrs", doa: "13/07/2026", ipop: "IP/2026/004",
weight: "58 kg", gender: "Female", intDate: "13/07/2026", unit: "Psychiatry" },
reason: "Patient with chronic Major Depressive Disorder on Fluoxetine 40 mg OD for 18 months. Referred to neurology for newly diagnosed migraine; Sumatriptan 50 mg PRN prescribed. Patient reported palpitations and mild restlessness after first sumatriptan dose.",
drugPair: "Fluoxetine (SSRI) + Sumatriptan (5-HT1B/1D Agonist)",
problem: "Fluoxetine blocks SERT (serotonin reuptake transporter), increasing synaptic serotonin. Sumatriptan is a direct 5-HT1B/1D receptor agonist. Combined serotonergic activity - presynaptic accumulation (SSRI) plus direct receptor agonism (triptan) - can precipitate Serotonin Syndrome. Classic triad: (1) Altered mental status/agitation, (2) Autonomic instability (tachycardia, hyperthermia, diaphoresis), (3) Neuromuscular abnormalities (tremor, hyperreflexia, clonus). Patient already experiencing early symptoms after first dose.",
reasons: [
"High-risk serotonin syndrome combination prescribed without interdepartmental communication",
"Patient already experiencing palpitations and restlessness after first sumatriptan dose - early serotonin syndrome signs",
"Both prescribers unaware of each other's prescriptions (polypharmacy from multiple departments)",
"60-year-old female - higher vulnerability to adverse drug reactions"
],
suggestions: [
"Discontinue Sumatriptan immediately",
"For acute migraine: switch to NSAIDs (Naproxen 500 mg), antiemetics (Metoclopramide), or Paracetamol 1 g",
"If triptan is clinically essential, consider low-dose Naratriptan or Frovatriptan under close monitoring",
"Educate patient on serotonin syndrome warning signs: fever, agitation, shivering, diarrhea, muscle twitching",
"Implement formal medication reconciliation between psychiatry and neurology departments",
"Consider non-pharmacological migraine management: trigger avoidance, relaxation techniques, biofeedback"
],
hcp: "Dr. Anand Reddy, Psychiatrist"
},
{
title: "ACE Inhibitor (Enalapril) + NSAID (Indomethacin)",
patient: { name: "Venkatesh Rao", age: "70 yrs", doa: "13/07/2026", ipop: "IP/2026/005",
weight: "75 kg", gender: "Male", intDate: "13/07/2026", unit: "Nephrology" },
reason: "Chronic Kidney Disease Stage 3 (eGFR: 38 mL/min/1.73m2) with hypertension managed on Enalapril 10 mg OD. Admitted with acute gout flare; Indomethacin 50 mg TDS prescribed for 5 days. Serum creatinine rose from 1.6 to 2.4 mg/dL within 48 hours.",
drugPair: "Enalapril (ACE Inhibitor) + Indomethacin (NSAID)",
problem: "This is the classic 'triple whammy' interaction. (1) NSAIDs inhibit prostaglandin (PGE2, PGI2) synthesis - these normally dilate the afferent arteriole maintaining GFR. Inhibition causes afferent constriction and reduced filtration. (2) ACE inhibitors block angiotensin II-mediated efferent arteriolar constriction that compensates for reduced afferent flow. Together both drugs unmask hemodynamic renal vulnerability, causing AKI superimposed on CKD. Serum creatinine rose from 1.6 to 2.4 mg/dL in 48 hours. Urine output dropped to 600 mL/day.",
reasons: [
"Rapidly rising creatinine (1.6 to 2.4 mg/dL in 48 hrs) - AKI on CKD",
"Reduced urine output (600 mL/day) indicating impaired renal perfusion",
"Patient has CKD-3 - vulnerable baseline already compromised",
"NSAIDs contraindicated or strongly cautioned in CKD + ACE inhibitor combination"
],
suggestions: [
"Immediately discontinue Indomethacin",
"Manage acute gout with Colchicine 0.5 mg BD (renal dose-adjusted) as first alternative",
"If colchicine not tolerated, use short-course oral Prednisolone 20-30 mg OD",
"Ensure adequate hydration (IV fluids if oral intake insufficient)",
"Monitor serum creatinine, urea, and electrolytes daily until renal function stabilizes",
"Monitor serum potassium closely - ACE inhibitor + renal impairment risks hyperkalemia",
"Reduce Enalapril dose if eGFR falls below 30 mL/min/1.73m2"
],
hcp: "Dr. Rajesh Shetty, Nephrologist"
},
{
title: "Rifampicin + Oral Contraceptive Pill (OCP)",
patient: { name: "Priya Nair", age: "35 yrs", doa: "13/07/2026", ipop: "OP/2026/006",
weight: "54 kg", gender: "Female", intDate: "13/07/2026", unit: "OB-GYN / Pulmonology" },
reason: "Young female on Combined OCP (Ethinylestradiol + Levonorgestrel) for contraception. Newly diagnosed with Pulmonary Tuberculosis (PTB) and initiated on RIPE regimen (Rifampicin 600 mg OD, Isoniazid, Pyrazinamide, Ethambutol). Patient not counseled about contraceptive failure risk.",
drugPair: "Rifampicin (Anti-TB) + Combined OCP (Ethinylestradiol + Levonorgestrel)",
problem: "Rifampicin is one of the most potent inducers of hepatic CYP3A4, CYP2C9, and P-glycoprotein (P-gp). Ethinylestradiol and levonorgestrel in OCPs are primarily CYP3A4 substrates. Rifampicin dramatically accelerates their hepatic metabolism, reducing estrogen and progestogen plasma levels by 40-80%. This renders hormonal contraception clinically INEFFECTIVE. P-gp induction further reduces OCP absorption from the GI tract. Enzyme induction persists for 4-8 weeks after stopping rifampicin. Unintended pregnancy during anti-TB treatment poses serious risk (drug teratogenicity concerns with Pyrazinamide and Ethambutol).",
reasons: [
"Patient not informed that OCP is no longer effective during rifampicin treatment",
"Unintended pregnancy risk during anti-TB therapy with potential fetal drug exposure",
"Patient's entire reproductive planning relies on a now-ineffective method",
"Both prescribers unaware of this critical interaction"
],
suggestions: [
"Counsel patient clearly: OCP is NO LONGER EFFECTIVE as contraception during rifampicin treatment",
"Immediately switch to a copper intrauterine device (Cu-IUD) - highly effective, non-hormonal, not affected by rifampicin",
"Alternatively use consistent barrier method (condoms) throughout TB treatment",
"If OCP is continued, must use dual contraception (OCP + barrier method) simultaneously",
"Maintain non-hormonal contraception for at least 4-8 weeks after completing rifampicin",
"Document counseling provided and obtain informed consent from patient",
"Coordinate with OB-GYN department for IUD insertion if chosen"
],
hcp: "Dr. Kavitha Bhat, Pulmonologist"
},
{
title: "Digoxin + Furosemide (Hypokalemia-Mediated Toxicity)",
patient: { name: "Suresh Patel", age: "65 yrs", doa: "13/07/2026", ipop: "IP/2026/007",
weight: "82 kg", gender: "Male", intDate: "13/07/2026", unit: "Cardiology" },
reason: "Chronic Heart Failure (NYHA Class III) on Digoxin 0.25 mg OD and Furosemide 80 mg OD. Presents with nausea, vomiting, yellow-green visual halos, and bradycardia (HR: 46 bpm). Serum K+: 2.8 mEq/L. Digoxin level: 3.2 ng/mL (therapeutic: 0.5-2.0 ng/mL).",
drugPair: "Digoxin + Furosemide (via Furosemide-induced Hypokalemia)",
problem: "Furosemide, a loop diuretic, inhibits the Na-K-2Cl cotransporter in the thick ascending limb of Henle's loop, causing renal potassium wasting and hypokalemia (K+ 2.8 mEq/L). Digoxin inhibits Na+/K+-ATPase on cardiac myocytes. Hypokalemia also inhibits Na+/K+-ATPase (K+ is the natural activating substrate), creating synergistic inhibition. This leads to dangerous intracellular calcium accumulation via the Na+/Ca2+ exchanger, producing bradycardia, AV block, and potentially lethal ventricular arrhythmias. Classic digoxin toxicity confirmed: level 3.2 ng/mL + visual disturbances + bradycardia (HR 46).",
reasons: [
"Digoxin toxicity confirmed: level 3.2 ng/mL (supratherapeutic) with clinical symptoms",
"Furosemide-induced hypokalemia (K+ 2.8 mEq/L) synergistically potentiating toxicity",
"Patient not on potassium supplementation despite long-term furosemide use",
"Bradycardia (HR 46 bpm) indicating risk of complete heart block or cardiac arrest"
],
suggestions: [
"URGENT: Hold Digoxin immediately pending level normalization",
"Administer IV Potassium Chloride (KCl) 40 mEq in 500 mL NS over 4 hours under continuous ECG monitoring",
"Maintain continuous cardiac monitoring; watch for AV block, VT, or VF",
"If life-threatening arrhythmia occurs, administer Digoxin-specific Fab antibody fragments (Digibind/DigiFab)",
"Add Spironolactone 25 mg OD (potassium-sparing diuretic) to prevent recurrent furosemide-induced hypokalemia",
"Reduce Furosemide to minimum effective dose for symptom control",
"Once stable, restart Digoxin at reduced dose (0.125 mg OD) with strict therapeutic drug monitoring"
],
hcp: "Dr. Suresh Naik, Cardiologist"
},
{
title: "Levothyroxine + Ferrous Sulfate",
patient: { name: "Rekha Iyer", age: "45 yrs", doa: "13/07/2026", ipop: "OP/2026/008",
weight: "61 kg", gender: "Female", intDate: "13/07/2026", unit: "Endocrinology OPD" },
reason: "Primary hypothyroidism on Levothyroxine 150 mcg OD for review. TSH persistently elevated at 8.4 mIU/L (normal: 0.4-4.0) despite 6 months of therapy and two dose increments. Concurrent iron-deficiency anemia on Ferrous Sulfate 200 mg TDS. Patient takes both medications simultaneously every morning.",
drugPair: "Levothyroxine (T4) + Ferrous Sulfate (Iron Supplement)",
problem: "Ferrous sulfate (Fe2+) forms an insoluble chelate complex with levothyroxine in the GI tract when administered simultaneously. This physicochemical interaction significantly impairs intestinal absorption of levothyroxine, reducing its bioavailability by 30-80% (studies show AUC reduction up to 80%). Reduced absorption leads to persistently subtherapeutic levothyroxine plasma levels and inadequate TSH suppression. Similar interactions occur with other divalent cations: calcium carbonate, aluminum/magnesium antacids, sucralfate. Patient has been on unnecessarily escalated doses because the root interaction was not identified for 6 months.",
reasons: [
"Persistently elevated TSH (8.4 mIU/L) despite adequate levothyroxine dose and two prior dose increments",
"Patient taking both tablets simultaneously every morning - root cause of treatment failure identified",
"Patient symptomatic with fatigue, cold intolerance, and weight gain - uncontrolled hypothyroidism",
"Drug interaction not documented by any prior prescriber despite 6 months of concurrent prescription"
],
suggestions: [
"Instruct patient to take Levothyroxine FIRST upon waking, 30-60 minutes before breakfast, with plain water ONLY",
"Take Ferrous Sulfate at a separate time - minimum 4 hours after levothyroxine (e.g., with lunch or dinner)",
"Do NOT co-administer levothyroxine with calcium, antacids, dairy products, or coffee",
"Reassess the previously increased levothyroxine dose - may now be excessive once absorption normalizes",
"Recheck TSH and Free T4 in 6 weeks after correcting administration timing",
"Titrate levothyroxine dose downward if TSH becomes suppressed after interaction is resolved",
"Provide a written instruction card on correct timing and pin to medication packaging"
],
hcp: "Dr. Girish Rao, Endocrinologist"
},
{
title: "Theophylline + Clarithromycin",
patient: { name: "Mohammed Irfan", age: "52 yrs", doa: "13/07/2026", ipop: "IP/2026/009",
weight: "78 kg", gender: "Male", intDate: "13/07/2026", unit: "Pulmonology" },
reason: "COPD (GOLD Stage III) on Theophylline SR 400 mg BD. Clarithromycin 500 mg BD prescribed by GP for community-acquired pneumonia. Now presenting with nausea, vomiting, tachycardia (HR: 122 bpm), and tremors. Serum theophylline level: 28 mcg/mL (toxic; therapeutic range: 10-20 mcg/mL).",
drugPair: "Theophylline (Xanthine Bronchodilator, NTI Drug) + Clarithromycin (Macrolide Antibiotic)",
problem: "Theophylline has a narrow therapeutic index (NTI); therapeutic range 10-20 mcg/mL, toxic >20 mcg/mL. It is primarily metabolized by hepatic CYP1A2 and CYP3A4. Clarithromycin is a potent inhibitor of CYP3A4 (and partial CYP1A2 inhibitor). When clarithromycin inhibits these enzymes, theophylline clearance is significantly reduced, causing accumulation to toxic levels (28 mcg/mL). Theophylline toxicity: GI (nausea, vomiting), cardiovascular (tachycardia, arrhythmias), neurological (tremors, seizures, agitation). Drug prescribed by GP without checking existing medication profile. Other drugs with similar interaction: erythromycin, ciprofloxacin, enoxacin, cimetidine.",
reasons: [
"Clinical theophylline toxicity confirmed: level 28 mcg/mL with tachycardia (HR 122), tremors, and vomiting",
"Clarithromycin prescribed by GP without reviewing existing medication profile",
"Theophylline dose not adjusted despite addition of a known CYP3A4 inhibitor",
"Narrow therapeutic index drug with serious and potentially life-threatening toxicity"
],
suggestions: [
"URGENT: Withhold Theophylline immediately; check serum theophylline STAT",
"Discontinue Clarithromycin; substitute with Doxycycline 100 mg BD or Amoxicillin-Clavulanate (no significant CYP3A4 effect on theophylline)",
"Symptomatic management: IV fluids for hydration; Propranolol (cautiously) for severe tachycardia if no contraindication",
"Continuous cardiac monitoring (ECG) until theophylline level falls within therapeutic range",
"Once symptoms resolve and levels normalize, restart theophylline at 75% of previous dose",
"If clarithromycin cannot be substituted, reduce theophylline dose by 50% and monitor levels every 48 hours",
"Patient education: Never take new medications (including OTC) without informing the pharmacist due to NTI drug status"
],
hcp: "Dr. Kavitha Bhat, Pulmonologist"
},
{
title: "Alendronate + Calcium Carbonate",
patient: { name: "Lakshmi Bai", age: "68 yrs", doa: "13/07/2026", ipop: "OP/2026/010",
weight: "63 kg", gender: "Female", intDate: "13/07/2026", unit: "Orthopedics OPD" },
reason: "Post-menopausal woman with established osteoporosis on Alendronate 70 mg once weekly and Calcium Carbonate 1250 mg + Vitamin D3 500 IU BD for 18 months. DEXA scan shows worsening osteoporosis (T-score: -3.2). Patient takes all medications together in the morning before breakfast.",
drugPair: "Alendronate (Bisphosphonate) + Calcium Carbonate (Divalent Cation Supplement)",
problem: "Bisphosphonates have inherently poor oral bioavailability (approx. 1-5% under optimal fasting conditions). This drops dramatically when taken with calcium supplements, dairy, or any polyvalent cation. Calcium ions (Ca2+) chelate directly with the bisphosphonate molecule in the GI lumen, forming an insoluble, unabsorbable calcium-alendronate complex. Studies show co-administration reduces alendronate bioavailability by over 60%. With insufficient systemic alendronate, osteoclast activity is not inhibited, bone resorption continues, and osteoporosis worsens - exactly what is seen with the deteriorating T-score (-3.2) after 18 months of apparently adequate therapy.",
reasons: [
"Worsening DEXA BMD (T-score -3.2) after 18 months of alendronate - apparent treatment failure",
"Interaction identified as root cause: patient taking alendronate simultaneously with calcium carbonate",
"Continued bone loss significantly increases vertebral and hip fracture risk in this patient",
"No pharmacist counseling previously documented on correct alendronate administration technique"
],
suggestions: [
"Instruct patient: Alendronate must be taken on an EMPTY STOMACH upon waking with a FULL glass (250 mL) of plain water ONLY",
"Patient must remain UPRIGHT (sitting or standing) for at least 30 minutes post-dose to prevent esophageal ulceration",
"Must NOT eat, drink (except plain water), or take any other medication for 30-60 minutes after alendronate",
"Take Calcium Carbonate + Vitamin D3 at a SEPARATE time (minimum 2 hours later, ideally with lunch or dinner)",
"Recheck DEXA bone mineral density in 12 months after correcting administration - expect measurable improvement",
"Assess modifiable osteoporosis risk factors: smoking, alcohol, physical activity level, fall prevention measures",
"Provide written instruction card for correct alendronate administration technique attached to packaging"
],
hcp: "Dr. Mahesh Shenoy, Orthopedic Surgeon"
}
];
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// ASSEMBLE DOCUMENT
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const headerPara = (text, opts = {}) =>
new Paragraph({
alignment: opts.center ? AlignmentType.CENTER : AlignmentType.LEFT,
spacing: { before: opts.before || 0, after: opts.after || 0 },
children: [run(text, opts)]
});
const children = [];
// ββ Cover / Title Block ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 200, after: 40 },
shading: { fill: NAVY, type: ShadingType.CLEAR, color: "auto" },
children: [run("RIFA-HUL MUSLIMEEN EDUCATIONAL TRUST (REGD.)", { bold: true, size: 18, color: WHITE })]
}));
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 0 },
shading: { fill: NAVY, type: ShadingType.CLEAR, color: "auto" },
children: [run("FAROOQIA COLLEGE OF PHARMACY", { bold: true, size: 36, color: WHITE })]
}));
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 0 },
shading: { fill: NAVY, type: ShadingType.CLEAR, color: "auto" },
children: [run("DEPARTMENT OF CLINICAL PHARMACY", { bold: true, size: 22, color: LIGHT })]
}));
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 20 },
shading: { fill: NAVY, type: ShadingType.CLEAR, color: "auto" },
children: [run("Farooqia Road, Eidgah, Mysore - 570 021, Karnataka, India", { size: 17, color: LIGHT })]
}));
children.push(new Paragraph({ spacing: { before: 60, after: 60 }, children: [run("")] }));
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 60, after: 20 },
shading: { fill: TEAL, type: ShadingType.CLEAR, color: "auto" },
children: [run("PHARMACIST INTERVENTION REPORTING & DOCUMENTATION FORM", { bold: true, size: 28, color: WHITE })]
}));
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 10, after: 20 },
shading: { fill: TEAL, type: ShadingType.CLEAR, color: "auto" },
children: [run("10 Clinically Significant Drug Interactions - Training Reference Document", { size: 22, color: WHITE, italics: true })]
}));
children.push(new Paragraph({ spacing: { before: 60, after: 40 }, children: [run("")] }));
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 0, after: 60 },
children: [run("Date: 13 July 2026 | Prepared by: Dept. of Clinical Pharmacy, Farooqia College of Pharmacy", { size: 19, italics: true, color: "555555" })]
}));
children.push(hrule());
children.push(new Paragraph({ spacing: { before: 60, after: 60 }, children: [run("")] }));
// ββ Quick Reference Summary Table ββββββββββββββββββββββββββββββββββββββββββββ
children.push(new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 80, after: 60 },
shading: { fill: NAVY, type: ShadingType.CLEAR, color: "auto" },
children: [run("QUICK REFERENCE SUMMARY - ALL 10 DRUG INTERACTIONS", { bold: true, size: 24, color: WHITE })]
}));
children.push(summaryTable());
children.push(new Paragraph({ spacing: { before: 60, after: 60 }, children: [run("")] }));
// ββ Page break before cases ββββββββββββββββββββββββββββββββββββββββββββββββββ
children.push(pageBreak());
// ββ All 10 case blocks βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
cases.forEach((c, i) => {
const blocks = buildCase(i + 1, c);
blocks.forEach(b => children.push(b));
if (i < cases.length - 1) {
children.push(new Paragraph({ spacing: { before: 60, after: 60 }, children: [run("")] }));
children.push(pageBreak());
}
});
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// BUILD & WRITE
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const doc = new Document({
numbering: {
config: [
{ reference: "bullets",
levels: [{ level: 0, format: LevelFormat.BULLET, text: "-", alignment: AlignmentType.LEFT,
style: { paragraph: { indent: { left: 360, hanging: 180 } } } }] }
]
},
styles: {
default: { document: { run: { font: "Arial", size: 22 } } },
},
sections: [{
properties: {
page: {
margin: { top: 720, bottom: 720, left: 900, right: 900 },
size: { width: 11906, height: 16838 }
}
},
headers: {
default: new Header({
children: [new Paragraph({
alignment: AlignmentType.CENTER,
border: { bottom: { style: BorderStyle.SINGLE, size: 4, color: TEAL } },
spacing: { before: 0, after: 60 },
children: [
run("Farooqia College of Pharmacy | Dept. of Clinical Pharmacy | Drug Interactions Training Reference", { size: 17, color: TEAL, italics: true })
]
})]
})
},
footers: {
default: new Footer({
children: [new Paragraph({
alignment: AlignmentType.CENTER,
border: { top: { style: BorderStyle.SINGLE, size: 4, color: TEAL } },
spacing: { before: 60, after: 0 },
children: [
run("Page ", { size: 17, color: "555555" }),
new PageNumber ? run("", { size: 17 }) : run("", {}),
]
})]
})
},
children
}]
});
Packer.toBuffer(doc).then(buf => {
fs.writeFileSync("/home/daytona/workspace/drug-interactions/Drug_Interactions_Training_Reference.docx", buf);
console.log("SUCCESS: Document created.");
});