Prepare a hospital formulary for a newly established multispecialty hospital, including criteria for addition and deletion of medicines

Reading File
Finding Sources
Finding Sources
Searching the Web

hospital formulary criteria addition deletion medicines Pharmacy Therapeutics Committee WHO essential medicines

Finding Sources
Finding Sources
Reading Web Page

https://welcome.nebraskamed.com/wp-content/uploads/2021/09/M…

Running Command

ls -la /tmp/workspace/ 2>/dev/null || mkdir -p /tmp/workspace && echo "workspace ready"

Reading File

You’re taking more time

Just give the content in text form

The hospital formulary above covers all essential components:
What's included:
  1. P&T Committee - composition, mandate, and meeting schedule
  2. Criteria for Addition - 8 domains: efficacy, safety, regulatory status, therapeutic need, cost-effectiveness, supply chain, EML status, and dosage form suitability
  3. Criteria for Deletion - 7 grounds: safety signals, obsolescence, low utilization, market withdrawal, cost-ineffectiveness, regulatory issues, and antimicrobial resistance
  4. Request Process - who can apply, what to submit, timelines, decision types, and appeals
  5. Restricted-Use Medicines - category for high-risk drugs requiring specialist prescribing
  6. Non-Formulary Use - exception pathway with accountability
  7. 24 Therapeutic Categories - covering all major specialties with representative drugs
  8. High-Alert Medicines - list and safety requirements
  9. Antimicrobial Stewardship - WHO AWaRe framework integration
  10. Review, Substitution, and Prescribing Principles - ongoing governance
You can adapt department names, drug lists, and approval signatures to your hospital's specific setup.

Create a professional style word file

Running Command

mkdir -p /tmp/workspace/hospital-formulary && echo "done"

Writing File

~/hospital-formulary/build_formulary.py

from docx import Document
from docx.shared import Pt, Inches, RGBColor, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT, WD_ALIGN_VERTICAL
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy

# ── colour palette ──────────────────────────────────────────────
DARK_BLUE   = RGBColor(0x00, 0x33, 0x66)   # header / section titles
MID_BLUE    = RGBColor(0x00, 0x5B, 0x9A)   # sub-headings
LIGHT_BLUE  = RGBColor(0xD6, 0xE4, 0xF0)   # table header fill
ACCENT      = RGBColor(0xC0, 0x39, 0x2B)   # high-alert red accent
WHITE       = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_GREY  = RGBColor(0xF2, 0xF2, 0xF2)
MID_GREY    = RGBColor(0xBF, 0xBF, 0xBF)
TEXT_BLACK  = RGBColor(0x1A, 0x1A, 0x1A)

doc = Document()

# ── page margins ────────────────────────────────────────────────
for section in doc.sections:
    section.top_margin    = Cm(2.0)
    section.bottom_margin = Cm(2.0)
    section.left_margin   = Cm(2.5)
    section.right_margin  = Cm(2.5)

# ── default Normal style ────────────────────────────────────────
normal = doc.styles["Normal"]
normal.font.name = "Calibri"
normal.font.size = Pt(10.5)
normal.font.color.rgb = TEXT_BLACK

# ── helper: set paragraph spacing ───────────────────────────────
def set_spacing(para, before=0, after=4, line=None):
    pPr = para._p.get_or_add_pPr()
    spacing = OxmlElement("w:spacing")
    spacing.set(qn("w:before"), str(before))
    spacing.set(qn("w:after"),  str(after))
    if line:
        spacing.set(qn("w:line"),     str(line))
        spacing.set(qn("w:lineRule"), "auto")
    pPr.append(spacing)

# ── helper: shade a table cell ───────────────────────────────────
def shade_cell(cell, rgb: RGBColor):
    tc   = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd  = OxmlElement("w:shd")
    hex_color = "{:02X}{:02X}{:02X}".format(rgb.red, rgb.green, rgb.blue)
    shd.set(qn("w:val"),   "clear")
    shd.set(qn("w:color"), "auto")
    shd.set(qn("w:fill"),  hex_color)
    tcPr.append(shd)

# ── helper: set cell border ──────────────────────────────────────
def set_cell_border(cell, **kwargs):
    tc   = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcBorders = OxmlElement("w:tcBorders")
    for edge in ("top","left","bottom","right","insideH","insideV"):
        tag = OxmlElement(f"w:{edge}")
        tag.set(qn("w:val"),   kwargs.get("val",   "single"))
        tag.set(qn("w:sz"),    kwargs.get("sz",    "4"))
        tag.set(qn("w:space"), "0")
        tag.set(qn("w:color"), kwargs.get("color", "BFBFBF"))
        tcBorders.append(tag)
    tcPr.append(tcBorders)

# ── helper: add horizontal rule ─────────────────────────────────
def add_hr(doc, color="005B9A", sz=12):
    p   = doc.add_paragraph()
    pPr = p._p.get_or_add_pPr()
    pb  = OxmlElement("w:pBdr")
    bot = OxmlElement("w:bottom")
    bot.set(qn("w:val"),   "single")
    bot.set(qn("w:sz"),    str(sz))
    bot.set(qn("w:space"), "1")
    bot.set(qn("w:color"), color)
    pb.append(bot)
    pPr.append(pb)
    set_spacing(p, before=0, after=0)
    return p

# ── helper: section heading ──────────────────────────────────────
def add_section_heading(doc, text, level=1):
    p = doc.add_paragraph()
    set_spacing(p, before=160, after=60)
    run = p.add_run(text)
    run.bold = True
    if level == 1:
        run.font.size  = Pt(13)
        run.font.color.rgb = DARK_BLUE
        add_hr(doc)
    elif level == 2:
        run.font.size  = Pt(11.5)
        run.font.color.rgb = MID_BLUE
    elif level == 3:
        run.font.size  = Pt(10.5)
        run.font.color.rgb = MID_BLUE
        run.italic = True
    return p

# ── helper: body paragraph ───────────────────────────────────────
def add_body(doc, text, bold=False, indent=False):
    p   = doc.add_paragraph()
    run = p.add_run(text)
    run.font.size = Pt(10.5)
    run.bold = bold
    if indent:
        p.paragraph_format.left_indent = Cm(0.6)
    set_spacing(p, before=0, after=40)
    return p

# ── helper: bullet ───────────────────────────────────────────────
def add_bullet(doc, text, level=0):
    p   = doc.add_paragraph(style="List Bullet")
    run = p.add_run(text)
    run.font.size = Pt(10.5)
    run.font.color.rgb = TEXT_BLACK
    p.paragraph_format.left_indent  = Cm(0.6 + level * 0.4)
    p.paragraph_format.space_after  = Pt(3)
    p.paragraph_format.space_before = Pt(0)
    return p

# ── helper: styled table ─────────────────────────────────────────
def add_styled_table(doc, headers, rows, col_widths=None):
    n_cols = len(headers)
    table  = doc.add_table(rows=1 + len(rows), cols=n_cols)
    table.style = "Table Grid"
    table.alignment = WD_TABLE_ALIGNMENT.CENTER

    # header row
    hdr_row = table.rows[0]
    for i, h in enumerate(headers):
        cell = hdr_row.cells[i]
        shade_cell(cell, DARK_BLUE)
        set_cell_border(cell, val="single", sz="4", color="FFFFFF")
        p   = cell.paragraphs[0]
        run = p.add_run(h)
        run.bold            = True
        run.font.size       = Pt(10)
        run.font.color.rgb  = WHITE
        p.alignment         = WD_ALIGN_PARAGRAPH.CENTER
        cell.vertical_alignment = WD_ALIGN_VERTICAL.CENTER
        set_spacing(p, before=40, after=40)

    # data rows
    for r_idx, row_data in enumerate(rows):
        row_obj = table.rows[r_idx + 1]
        fill    = LIGHT_GREY if r_idx % 2 == 0 else WHITE
        for c_idx, val in enumerate(row_data):
            cell = row_obj.cells[c_idx]
            shade_cell(cell, fill)
            set_cell_border(cell, val="single", sz="4", color="BFBFBF")
            p   = cell.paragraphs[0]
            run = p.add_run(str(val))
            run.font.size      = Pt(10)
            run.font.color.rgb = TEXT_BLACK
            p.alignment        = WD_ALIGN_PARAGRAPH.LEFT
            cell.vertical_alignment = WD_ALIGN_VERTICAL.CENTER
            set_spacing(p, before=30, after=30)

    # column widths
    if col_widths:
        for row_obj in table.rows:
            for i, w in enumerate(col_widths):
                row_obj.cells[i].width = Cm(w)

    doc.add_paragraph()  # spacer
    return table

# ════════════════════════════════════════════════════════════════
#  COVER PAGE
# ════════════════════════════════════════════════════════════════
# top colour band
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
pPr = p._p.get_or_add_pPr()
shd = OxmlElement("w:shd")
shd.set(qn("w:val"),  "clear")
shd.set(qn("w:fill"), "003366")
pPr.append(shd)
run = p.add_run("\n")
run.font.size = Pt(6)
set_spacing(p, before=0, after=0)

# hospital name placeholder
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
pPr = p._p.get_or_add_pPr()
shd = OxmlElement("w:shd")
shd.set(qn("w:val"),  "clear")
shd.set(qn("w:fill"), "003366")
pPr.append(shd)
run = p.add_run("[HOSPITAL NAME]")
run.font.name  = "Calibri"
run.font.size  = Pt(22)
run.bold       = True
run.font.color.rgb = WHITE
set_spacing(p, before=80, after=40)

p2 = doc.add_paragraph()
p2.alignment = WD_ALIGN_PARAGRAPH.CENTER
pPr2 = p2._p.get_or_add_pPr()
shd2 = OxmlElement("w:shd")
shd2.set(qn("w:val"),  "clear")
shd2.set(qn("w:fill"), "003366")
pPr2.append(shd2)
run2 = p2.add_run("Multispecialty Hospital")
run2.font.name = "Calibri"
run2.font.size = Pt(14)
run2.font.color.rgb = RGBColor(0xD6, 0xE4, 0xF0)
set_spacing(p2, before=0, after=80)

# bottom of band spacer
p3 = doc.add_paragraph()
pPr3 = p3._p.get_or_add_pPr()
shd3 = OxmlElement("w:shd")
shd3.set(qn("w:val"),  "clear")
shd3.set(qn("w:fill"), "003366")
pPr3.append(shd3)
run3 = p3.add_run(" ")
run3.font.size = Pt(4)
set_spacing(p3, before=0, after=0)

doc.add_paragraph()

# main title
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("HOSPITAL FORMULARY")
run.font.name  = "Calibri"
run.font.size  = Pt(28)
run.bold       = True
run.font.color.rgb = DARK_BLUE
set_spacing(p, before=200, after=80)

add_hr(doc, color="C0392B", sz=16)

p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("A Comprehensive Drug Reference & Policy Document")
run.font.size  = Pt(13)
run.italic     = True
run.font.color.rgb = MID_BLUE
set_spacing(p, before=60, after=200)

# meta table
meta_table = doc.add_table(rows=4, cols=2)
meta_table.alignment = WD_TABLE_ALIGNMENT.CENTER
meta_data = [
    ("Edition",         "1st Edition"),
    ("Effective Date",  "July 2026"),
    ("Prepared By",     "Pharmacy & Therapeutics (P&T) Committee"),
    ("Review Due",      "July 2027"),
]
for i, (label, value) in enumerate(meta_data):
    c0 = meta_table.rows[i].cells[0]
    c1 = meta_table.rows[i].cells[1]
    shade_cell(c0, LIGHT_BLUE)
    shade_cell(c1, WHITE)
    set_cell_border(c0, val="single", sz="4", color="005B9A")
    set_cell_border(c1, val="single", sz="4", color="005B9A")
    r0 = c0.paragraphs[0].add_run(label)
    r0.bold = True; r0.font.size = Pt(10.5); r0.font.color.rgb = DARK_BLUE
    r1 = c1.paragraphs[0].add_run(value)
    r1.font.size = Pt(10.5); r1.font.color.rgb = TEXT_BLACK
    set_spacing(c0.paragraphs[0], before=60, after=60)
    set_spacing(c1.paragraphs[0], before=60, after=60)
for row in meta_table.rows:
    row.cells[0].width = Cm(5)
    row.cells[1].width = Cm(9)

doc.add_page_break()

# ════════════════════════════════════════════════════════════════
#  SECTION 1 – PREAMBLE
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 1: PREAMBLE", 1)
add_body(doc, (
    "This formulary is an official document of the Pharmacy and Therapeutics (P&T) Committee. "
    "It represents a continuously updated, evidence-based list of medicines approved for use within "
    "this hospital. Its purpose is to promote rational drug use, ensure patient safety, optimise "
    "therapeutic outcomes, and support cost-effective prescribing across all departments."
))
add_body(doc, (
    "All prescribers, pharmacists, nurses, and clinical staff are expected to adhere to this formulary. "
    "Non-formulary medicines may be used only through the approved exception process described in Section 7."
))

# ════════════════════════════════════════════════════════════════
#  SECTION 2 – P&T COMMITTEE
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 2: PHARMACY & THERAPEUTICS COMMITTEE", 1)

add_section_heading(doc, "2.1  Composition", 2)
members = [
    "Chief Medical Officer (Chairperson)",
    "Head of Pharmacy (Co-Chair / Secretary)",
    "Heads of clinical departments (Medicine, Surgery, Pediatrics, Obstetrics & Gynecology, "
    "Orthopedics, Cardiology, Neurology, Oncology, ICU, Anesthesiology)",
    "Chief Nursing Officer",
    "Hospital Administrator (Finance representative)",
    "Infection Control Officer",
    "Clinical Pharmacologist (where available)",
]
for m in members:
    add_bullet(doc, m)

add_section_heading(doc, "2.2  Mandate", 2)
mandates = [
    "Develop, maintain, and update the hospital formulary",
    "Establish drug use policies and medication safety protocols",
    "Review, approve, or reject requests for formulary additions and deletions",
    "Monitor adverse drug reactions and medication errors",
    "Guide antimicrobial stewardship",
    "Evaluate drug utilization data and therapeutic outcomes",
    "Approve therapeutic substitution policies",
]
for m in mandates:
    add_bullet(doc, m)

add_section_heading(doc, "2.3  Meeting Frequency", 2)
add_body(doc, (
    "The P&T Committee shall meet at minimum once every quarter. "
    "Emergency reviews may be convened as needed within 7 working days."
))

# ════════════════════════════════════════════════════════════════
#  SECTION 3 – CRITERIA FOR ADDITION
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 3: CRITERIA FOR ADDITION OF MEDICINES", 1)
add_body(doc, "A medicine must satisfy most of the following criteria before being considered for addition to the formulary:")

addition_criteria = [
    ("3.1  Clinical Efficacy", [
        "Proven efficacy supported by RCTs, systematic reviews, or meta-analyses",
        "Approved indication aligns with the hospital's clinical services and patient population",
        "Demonstrates clinically meaningful benefit over existing formulary alternatives",
        "Supported by standard national or international clinical guidelines (WHO, ICMR, specialty societies)",
    ]),
    ("3.2  Safety Profile", [
        "Acceptable adverse effect profile relative to therapeutic benefit",
        "Known contraindications, drug interactions, and precautions are manageable within the hospital",
        "Post-marketing surveillance data available and reviewed",
        "Risk-benefit ratio is favourable for the target patient population",
    ]),
    ("3.3  Regulatory Status", [
        "Licensed and approved by the national drug regulatory authority (e.g., CDSCO in India)",
        "Not a banned or restricted substance at the national level",
        "Complies with all applicable drug laws and hospital drug use policies",
    ]),
    ("3.4  Need & Therapeutic Advantage", [
        "Fills a therapeutic gap not addressed by current formulary medicines",
        "Represents a meaningful advance within its therapeutic class (better efficacy, fewer side effects, simpler dosing)",
        "Has relevance to the hospital's clinical specialties and patient case mix",
        "Addresses a condition with significant burden in the hospital's catchment area",
    ]),
    ("3.5  Cost-Effectiveness", [
        "Cost per treatment course is reasonable relative to clinical benefit",
        "Pharmacoeconomic analysis supports addition",
        "Procurement is reliable and sustainable through approved suppliers",
        "Does not create undue financial burden without commensurate clinical benefit",
    ]),
    ("3.6  Availability & Supply Chain", [
        "Available in the local market through established and verified suppliers",
        "Not subject to chronic supply shortages",
        "Storage and handling requirements are feasible within the hospital pharmacy",
    ]),
    ("3.7  WHO/NEML Status", [
        "Preference given to medicines listed on the WHO Model List of Essential Medicines or the National EML",
        "Non-EML medicines require stronger justification for addition",
    ]),
    ("3.8  Dosage Form & Administration", [
        "Available in appropriate dosage forms for the hospital's patient population",
        "Administration is practical within nursing and pharmacy workflow",
    ]),
]

for heading, bullets in addition_criteria:
    add_section_heading(doc, heading, 2)
    for b in bullets:
        add_bullet(doc, b)

# ════════════════════════════════════════════════════════════════
#  SECTION 4 – CRITERIA FOR DELETION
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 4: CRITERIA FOR DELETION OF MEDICINES", 1)
add_body(doc, "A medicine shall be considered for deletion if one or more of the following criteria apply:")

deletion_criteria = [
    ("4.1  Safety Concerns", [
        "New evidence of serious adverse effects or toxicity that outweigh therapeutic benefit",
        "Regulatory action: withdrawal, recall, or suspension of marketing authorisation",
        "Significant post-marketing pharmacovigilance signals",
        "Medicine associated with recurring medication errors or patient harm events within the hospital",
    ]),
    ("4.2  Obsolescence / Therapeutic Redundancy", [
        "Newer, safer, or more effective alternatives have been added to the formulary",
        "No longer recommended in current national or international clinical guidelines",
        "Superseded by advances in medical practice or technology",
    ]),
    ("4.3  Low or No Utilisation", [
        "Consistently very low or zero utilisation over 12 months without justified clinical rationale",
        "Drug use data suggest the medicine is not contributing to patient care outcomes",
    ]),
    ("4.4  Market Withdrawal", [
        "Medicine is no longer manufactured, marketed, or commercially available",
        "Chronic, unresolvable supply failures from suppliers",
    ]),
    ("4.5  Cost-Ineffectiveness", [
        "More cost-effective alternatives available with equivalent or superior clinical outcomes",
        "Disproportionately high cost relative to clinical benefit",
    ]),
    ("4.6  Regulatory or Legal Issues", [
        "Drug is banned, restricted, or no longer permitted under applicable law",
        "Licensing issues with manufacturer or supplier",
    ]),
    ("4.7  Antimicrobial Resistance", [
        "Antimicrobial contributing to resistance patterns documented in the hospital antibiogram",
        "Antimicrobial Stewardship Programme recommends discontinuation or restriction",
    ]),
]

for heading, bullets in deletion_criteria:
    add_section_heading(doc, heading, 2)
    for b in bullets:
        add_bullet(doc, b)

# ════════════════════════════════════════════════════════════════
#  SECTION 5 – FORMULARY REQUEST PROCESS
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 5: PROCESS FOR FORMULARY REQUESTS", 1)

add_section_heading(doc, "5.1  Who Can Submit a Request", 2)
add_body(doc, ("Any registered medical practitioner, pharmacist, or department head may submit a request "
               "for formulary addition or deletion to the P&T Committee Secretary."))

add_section_heading(doc, "5.2  Submission Requirements", 2)
add_body(doc, "Requests must be submitted using the official Formulary Request Form (FRF) and must include:")
req_items = [
    "Name of medicine (generic name, brand name, dosage form, strength)",
    "Type of request: Addition / Deletion / Restriction change",
    "Clinical indication and proposed use within the hospital",
    "Evidence summary (key clinical trials, guidelines, meta-analyses)",
    "Current formulary alternatives (if addition request)",
    "Comparative efficacy, safety, and cost data",
    "Rationale: why existing formulary agents are insufficient (for additions)",
    "Impact on patient care and clinical outcomes",
]
for r in req_items:
    add_bullet(doc, r)

add_section_heading(doc, "5.3  Review Timeline", 2)
add_styled_table(doc,
    headers=["Request Type", "Review Timeline"],
    rows=[
        ("Routine requests",          "Next scheduled quarterly P&T meeting"),
        ("Urgent / emergency requests", "Within 7 working days by Committee Chair + 2 senior members"),
        ("Appeal of a decision",      "Next Committee meeting after written appeal"),
    ],
    col_widths=[7, 9]
)

add_section_heading(doc, "5.4  Decision Outcomes", 2)
outcomes = [
    "Approve - medicine added/deleted unconditionally",
    "Approve with Restrictions - added for specific indications, departments, or prescribers only",
    "Defer - additional evidence or information required before a decision",
    "Reject - criteria not met; requestor notified with reasons in writing",
]
for o in outcomes:
    add_bullet(doc, o)

add_section_heading(doc, "5.5  Appeals", 2)
add_body(doc, ("A requestor who disagrees with the Committee's decision may appeal in writing to the Chairperson "
               "within 30 days. The appeal will be reviewed at the next Committee meeting. "
               "The Committee's decision after appeal is final and binding."))

# ════════════════════════════════════════════════════════════════
#  SECTION 6 – RESTRICTED USE
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 6: RESTRICTED-USE MEDICINES", 1)
add_body(doc, "Certain medicines on the formulary are designated 'Restricted Use' due to:")
restr_reasons = [
    "High potential for toxicity or serious adverse events (e.g., cytotoxics, immunosuppressants, high-alert medicines)",
    "Risk of antimicrobial resistance (reserve antibiotics)",
    "Requirement for specialist knowledge or monitoring",
    "Potential for significant misuse",
]
for r in restr_reasons:
    add_bullet(doc, r)

add_body(doc, "Restricted medicines may only be prescribed by:", bold=True)
add_bullet(doc, "Designated specialty consultants (e.g., oncologists for cytotoxics, ID specialists for reserve antibiotics)")
add_bullet(doc, "With specific clinical criteria documented in the patient's record")
add_bullet(doc, "With pharmacist verification prior to dispensing")

# ════════════════════════════════════════════════════════════════
#  SECTION 7 – NON-FORMULARY USE
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 7: NON-FORMULARY MEDICINE USE", 1)
add_body(doc, "A non-formulary medicine may be used in exceptional circumstances, provided:")
nf_items = [
    "No suitable formulary alternative exists for the patient's condition",
    "Request is initiated by a Consultant-grade physician",
    "Non-Formulary Use Form (NUF) is completed with clinical justification",
    "Approval is granted by the Head of Department and Chief Pharmacist",
    "Use is documented in the patient's medical record",
    "Frequent non-formulary use of a drug triggers automatic review for possible formulary addition",
]
for n in nf_items:
    add_bullet(doc, n)

# ════════════════════════════════════════════════════════════════
#  SECTION 8 – THERAPEUTIC CATEGORIES
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 8: FORMULARY – THERAPEUTIC CATEGORIES", 1)
add_body(doc, "The formulary is organised by therapeutic category aligned to the hospital's clinical services:")

cat_rows = [
    ("1",  "Analgesics & Antipyretics",          "Paracetamol, Ibuprofen, Morphine, Tramadol, Fentanyl"),
    ("2",  "Anesthetics (General & Local)",       "Propofol, Ketamine, Lignocaine, Bupivacaine, Sevoflurane"),
    ("3",  "Antibacterials",                      "Amoxicillin, Ceftriaxone, Pip-Taz, Meropenem, Vancomycin"),
    ("4",  "Antifungals",                         "Fluconazole, Amphotericin B, Voriconazole, Caspofungin"),
    ("5",  "Antivirals",                          "Acyclovir, Oseltamivir, Tenofovir, Remdesivir"),
    ("6",  "Antiparasitics",                      "Metronidazole, Albendazole, Chloroquine, Artemether-Lumefantrine"),
    ("7",  "Antituberculosis",                    "Isoniazid, Rifampicin, Ethambutol, Pyrazinamide, Streptomycin"),
    ("8",  "Cardiovascular",                      "Atenolol, Amlodipine, Enalapril, Furosemide, Digoxin, Heparin, Aspirin"),
    ("9",  "Respiratory",                         "Salbutamol, Ipratropium, Budesonide, Theophylline, N-Acetylcysteine"),
    ("10", "Gastrointestinal",                    "Pantoprazole, Ondansetron, Metoclopramide, Lactulose, Mesalazine"),
    ("11", "Endocrine / Diabetes",                "Regular Insulin, NPH Insulin, Glargine, Metformin, Glibenclamide"),
    ("12", "Neurological / CNS",                  "Phenytoin, Valproate, Levetiracetam, Haloperidol, Diazepam"),
    ("13", "Antineoplastics [Restricted]",        "Cisplatin, Doxorubicin, Paclitaxel, Methotrexate, Leucovorin"),
    ("14", "Immunosuppressants [Restricted]",     "Prednisolone, Methylprednisolone, Azathioprine, Cyclosporine"),
    ("15", "Haematological",                      "Ferrous Sulfate, Folic Acid, Vit B12, Tranexamic Acid, Alteplase"),
    ("16", "Obstetrics & Gynecology",             "Oxytocin, Misoprostol, Magnesium Sulfate, Progesterone"),
    ("17", "Paediatrics",                         "ORS, Vitamin A, Zinc, Paediatric Paracetamol, Amoxicillin Syrup"),
    ("18", "Ophthalmology",                       "Timolol eye drops, Moxifloxacin eye drops, Atropine eye drops"),
    ("19", "Dermatology",                         "Hydrocortisone cream, Clotrimazole, Mupirocin, Calamine"),
    ("20", "Vitamins, Minerals & Electrolytes",   "Normal Saline, Ringer's Lactate, KCl, Calcium Gluconate"),
    ("21", "Vaccines & Immunologicals",           "Tetanus Toxoid, Hepatitis B, Rabies Immunoglobulin"),
    ("22", "Contrast Media & Diagnostics",        "Iohexol, Gadolinium (Radiology use)"),
    ("23", "Antiseptics & Disinfectants",         "Povidone Iodine, Chlorhexidine, Isopropyl Alcohol"),
    ("24", "Antidotes",                           "Naloxone, Flumazenil, Protamine, N-Acetylcysteine, Atropine"),
]
add_styled_table(doc,
    headers=["#", "Therapeutic Category", "Representative Medicines"],
    rows=cat_rows,
    col_widths=[1.0, 5.5, 9.5]
)

# ════════════════════════════════════════════════════════════════
#  SECTION 9 – HIGH-ALERT MEDICINES
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 9: HIGH-ALERT MEDICINES", 1)

# red-tinted notice box
p_notice = doc.add_paragraph()
pPr_n = p_notice._p.get_or_add_pPr()
shd_n = OxmlElement("w:shd")
shd_n.set(qn("w:val"),  "clear")
shd_n.set(qn("w:fill"), "F9EBEA")
pPr_n.append(shd_n)
run_n = p_notice.add_run(
    "  ⚠  The following categories require double-check verification, specific labeling, "
    "and restricted storage. Extra caution must be exercised at every step of prescribing, "
    "dispensing, and administration."
)
run_n.font.size = Pt(10.5)
run_n.font.color.rgb = ACCENT
run_n.bold = True
set_spacing(p_notice, before=60, after=80)
doc.add_paragraph()

high_alert = [
    ("Concentrated Electrolytes",        "KCl injection, Hypertonic Saline – never stored in clinical areas"),
    ("Insulin (all formulations)",       "Regular, NPH, Glargine – weight-based dosing mandatory"),
    ("Anticoagulants",                   "Heparin, Warfarin, LMWH – therapeutic monitoring required"),
    ("Opioids",                          "Morphine, Fentanyl, Tramadol – controlled substance protocols apply"),
    ("Cytotoxic / Antineoplastic Agents","Dedicated preparation area; PPE mandatory"),
    ("Neuromuscular Blocking Agents",    "Vecuronium, Atracurium – ICU/OT only; airway management essential"),
    ("Concentrated Dextrose (>10%)",     "Central line administration; osmolarity monitoring"),
    ("Thrombolytics",                    "Alteplase, Streptokinase – specialist-only initiation"),
]
add_styled_table(doc,
    headers=["High-Alert Category", "Notes / Safeguards"],
    rows=high_alert,
    col_widths=[6, 10]
)

add_body(doc, "All high-alert medicines must:", bold=True)
ha_rules = [
    "Be stored separately with clear visual HIGH-ALERT labels",
    "Be prescribed with dose, route, and rate explicitly stated",
    "Be dispensed only after pharmacist verification",
    "Be administered with independent double-check by two nurses",
]
for r in ha_rules:
    add_bullet(doc, r)

# ════════════════════════════════════════════════════════════════
#  SECTION 10 – ANTIMICROBIAL STEWARDSHIP
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 10: ANTIMICROBIAL STEWARDSHIP", 1)

add_section_heading(doc, "10.1  WHO AWaRe Antibiotic Classification", 2)
aware_rows = [
    ("Access",  "First-line for common infections",  "Amoxicillin, Cotrimoxazole, Doxycycline",  "Freely prescribable"),
    ("Watch",   "Higher resistance risk",            "Cephalosporins (3rd gen), Fluoroquinolones, Carbapenems", "Requires documented justification"),
    ("Reserve", "Last-resort antibiotics",           "Colistin, Tigecycline, Linezolid",          "Restricted: ID specialist approval required"),
]
add_styled_table(doc,
    headers=["Tier", "Classification", "Examples", "Prescribing Policy"],
    rows=aware_rows,
    col_widths=[2.5, 3.5, 6.0, 4.0]
)

add_section_heading(doc, "10.2  Antibiogram", 2)
add_body(doc, (
    "The hospital shall produce an updated antibiogram annually from microbiological surveillance data "
    "to guide empirical antibiotic prescribing. The P&T Committee shall review the antibiogram and "
    "update antibiotic selections in the formulary accordingly each year."
))

# ════════════════════════════════════════════════════════════════
#  SECTION 11 – FORMULARY REVIEW
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 11: FORMULARY REVIEW AND UPDATES", 1)
review_items = [
    "The formulary is a living document and shall be reviewed at minimum annually",
    "A full therapeutic class review cycle shall be completed every 2 years",
    "Emergency updates may be issued at any time following P&T Committee approval",
    "All formulary changes shall be communicated to clinical staff via departmental circulars, intranet updates, and pharmacy notices",
    "Previous editions shall be archived with version dates",
]
for r in review_items:
    add_bullet(doc, r)

# ════════════════════════════════════════════════════════════════
#  SECTION 12 – THERAPEUTIC SUBSTITUTION
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 12: THERAPEUTIC SUBSTITUTION POLICY", 1)
add_body(doc, ("When a prescribed formulary medicine is temporarily unavailable, the pharmacist may substitute "
               "with a therapeutically equivalent agent within the same drug class, provided:"))
sub_items = [
    "The substitution is approved in the hospital's therapeutic equivalence table",
    "The prescribing physician is informed and concurs",
    "The substitution is documented in the patient's medication record",
    "No substitution is made for narrow therapeutic index drugs (anticonvulsants, anticoagulants, immunosuppressants) without explicit physician approval",
]
for s in sub_items:
    add_bullet(doc, s)

# ════════════════════════════════════════════════════════════════
#  SECTION 13 – GENERAL PRESCRIBING PRINCIPLES
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 13: GENERAL PRESCRIBING PRINCIPLES", 1)
prescribing = [
    "Always prescribe by generic (INN) name",
    "State dose, route, frequency, and duration clearly on every prescription",
    "Adhere to the formulary for routine prescribing",
    "Consult the pharmacist for complex drug interaction queries",
    "Report all adverse drug reactions to the hospital pharmacovigilance system and national ADR monitoring programme",
    "Refer to departmental clinical protocols and treatment guidelines for disease-specific management",
    "Avoid polypharmacy; review and reconcile medications at every patient transition point (admission, transfer, discharge)",
]
for i, p_text in enumerate(prescribing, 1):
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Cm(0.6)
    p.paragraph_format.space_after = Pt(4)
    run_num = p.add_run(f"{i}.  ")
    run_num.bold = True
    run_num.font.color.rgb = DARK_BLUE
    run_num.font.size = Pt(10.5)
    run_txt = p.add_run(p_text)
    run_txt.font.size = Pt(10.5)

# ════════════════════════════════════════════════════════════════
#  SECTION 14 – ABBREVIATIONS
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 14: ABBREVIATIONS", 1)
abbr_rows = [
    ("P&T",   "Pharmacy and Therapeutics"),
    ("EML",   "Essential Medicines List"),
    ("NEML",  "National Essential Medicines List"),
    ("WHO",   "World Health Organization"),
    ("CDSCO", "Central Drugs Standard Control Organisation"),
    ("FRF",   "Formulary Request Form"),
    ("NUF",   "Non-Formulary Use Form"),
    ("ADR",   "Adverse Drug Reaction"),
    ("RCT",   "Randomized Controlled Trial"),
    ("ICU",   "Intensive Care Unit"),
    ("AWaRe", "Access, Watch, Reserve (WHO antibiotic framework)"),
    ("INN",   "International Nonproprietary Name"),
    ("ID",    "Infectious Disease"),
    ("LMWH",  "Low Molecular Weight Heparin"),
]
add_styled_table(doc,
    headers=["Abbreviation", "Full Form"],
    rows=abbr_rows,
    col_widths=[4, 12]
)

# ════════════════════════════════════════════════════════════════
#  SECTION 15 – APPROVAL & AUTHORIZATION
# ════════════════════════════════════════════════════════════════
add_section_heading(doc, "SECTION 15: APPROVAL AND AUTHORIZATION", 1)
approval_rows = [
    ("P&T Committee Chairperson",  "", ""),
    ("Head of Pharmacy",           "", ""),
    ("Chief Medical Officer",      "", ""),
    ("Hospital Director",          "", ""),
]
add_styled_table(doc,
    headers=["Role", "Name & Signature", "Date"],
    rows=approval_rows,
    col_widths=[6, 7, 3]
)

add_hr(doc)
p_foot = doc.add_paragraph()
p_foot.alignment = WD_ALIGN_PARAGRAPH.CENTER
run_f = p_foot.add_run(
    "This formulary supersedes all previous editions.  "
    "For queries, contact the Pharmacy & Therapeutics Committee Secretary.\n"
    "Next scheduled review: July 2027"
)
run_f.font.size = Pt(9)
run_f.italic = True
run_f.font.color.rgb = MID_BLUE
set_spacing(p_foot, before=60, after=0)

# ── save ─────────────────────────────────────────────────────────
out = "/tmp/workspace/hospital-formulary/Hospital_Formulary_2026.docx"
doc.save(out)
print(f"Saved: {out}")
Running Command

python3 /tmp/workspace/hospital-formulary/build_formulary.py

Running Command

python3 -c "from docx.shared import RGBColor; c = RGBColor(0xD6,0xE4,0xF0); print(dir(c)); print(int(c))"

Running Command

python3 -c "from docx.shared import RGBColor; c = RGBColor(0xD6,0xE4,0xF0); print(c[0], c[1], c[2])"

Editing File

~/hospital-formulary/build_formulary.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/hospital-formulary/build_formulary.py'
Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.

Just give me text form

Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.
This is a shared conversation. Sign in to Orris to start your own chat.