Make a pdf on hydrocortisone in snes

Reading File
Asking for Preferences

No anaesthesia also mention the details

Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Running Command

mkdir -p /tmp/workspace/hydrocortisone-pdf && ls /tmp/workspace/

Writing File

~/hydrocortisone-pdf/build_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib.colors import HexColor, white, black
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.lib import colors

OUTPUT = "/tmp/workspace/hydrocortisone-pdf/Hydrocortisone_in_Anaesthesia.pdf"

# ── Colours ──────────────────────────────────────────────────────────────────
NAVY   = HexColor("#1B3A6B")
TEAL   = HexColor("#1A7A8A")
LIGHT  = HexColor("#E8F4F8")
ACCENT = HexColor("#F0A500")
GREY   = HexColor("#F5F5F5")
DKGREY = HexColor("#444444")

doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=2*cm, rightMargin=2*cm,
    topMargin=2*cm, bottomMargin=2*cm,
    title="Hydrocortisone in Anaesthesia",
    author="Orris Medical",
)

styles = getSampleStyleSheet()

# ── Custom Styles ─────────────────────────────────────────────────────────────
def S(name, **kw):
    return ParagraphStyle(name, **kw)

cover_title  = S("CoverTitle",  fontSize=30, textColor=white,   alignment=TA_CENTER, leading=36, fontName="Helvetica-Bold")
cover_sub    = S("CoverSub",    fontSize=14, textColor=ACCENT,  alignment=TA_CENTER, leading=20, fontName="Helvetica-Bold")
cover_body   = S("CoverBody",   fontSize=10, textColor=white,   alignment=TA_CENTER, leading=15, fontName="Helvetica")

h1           = S("H1",  fontSize=15, textColor=white,  fontName="Helvetica-Bold", alignment=TA_LEFT, leading=20)
h2           = S("H2",  fontSize=12, textColor=NAVY,   fontName="Helvetica-Bold", alignment=TA_LEFT, leading=16, spaceBefore=10)
body         = S("Body",fontSize=10, textColor=DKGREY, fontName="Helvetica",      alignment=TA_JUSTIFY, leading=15, spaceBefore=4)
bullet_style = S("Bullet",fontSize=10, textColor=DKGREY, fontName="Helvetica", leftIndent=16, leading=15, spaceBefore=3,
                 bulletIndent=4, bulletFontName="Helvetica", bulletFontSize=10)
note         = S("Note", fontSize=9, textColor=TEAL, fontName="Helvetica-Oblique", leading=13, spaceBefore=4)
tbl_hdr      = S("TblHdr",fontSize=9, textColor=white,  fontName="Helvetica-Bold", alignment=TA_CENTER)
tbl_cell     = S("TblCell",fontSize=9,textColor=DKGREY, fontName="Helvetica",     alignment=TA_CENTER, leading=12)
tbl_left     = S("TblLeft",fontSize=9,textColor=DKGREY, fontName="Helvetica",     alignment=TA_LEFT,   leading=12)
footer_s     = S("Footer",fontSize=8, textColor=HexColor("#888888"), alignment=TA_CENTER)

# ── Helper: section header banner ────────────────────────────────────────────
def section_header(text):
    tbl = Table([[Paragraph(text, h1)]], colWidths=[17*cm])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), NAVY),
        ("TOPPADDING",  (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0),(-1,-1), 8),
        ("LEFTPADDING", (0,0), (-1,-1), 12),
        ("ROUNDEDCORNERS", [4]),
    ]))
    return tbl

def sub_header(text):
    return [Spacer(1, 0.3*cm), Paragraph(text, h2), HRFlowable(width="100%", thickness=1, color=TEAL, spaceAfter=4)]

def bp(text):
    return Paragraph(f"<bullet>\u2022</bullet> {text}", bullet_style)

def para(text):
    return Paragraph(text, body)

def spacer(n=0.25):
    return Spacer(1, n*cm)

# ═══════════════════════════════════════════════════════════════════════════════
# COVER PAGE
# ═══════════════════════════════════════════════════════════════════════════════
story = []

cover_bg = Table(
    [[Paragraph("HYDROCORTISONE", cover_title)],
     [Paragraph("in Anaesthesia", cover_sub)],
     [spacer(0.5)],
     [Paragraph("Perioperative steroid supplementation, adrenal physiology,<br/>"
                "pharmacology, dosing protocols, and clinical considerations", cover_body)],
     [spacer(0.5)],
     [Paragraph("Sources: Morgan &amp; Mikhail's Clinical Anesthesiology 7e · Fischer's Mastery of Surgery 8e<br/>"
                "Sabiston Textbook of Surgery · Campbell's Operative Orthopaedics 15e<br/>"
                "The Harriet Lane Handbook 23e · Katzung's Pharmacology 16e", cover_body)],
     [spacer(1)],
     [Paragraph("Prepared by <b>Orris Medical Intelligence</b> · August 2026", cover_body)],
    ],
    colWidths=[17*cm]
)
cover_bg.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), NAVY),
    ("TOPPADDING",    (0,0), (-1,-1), 14),
    ("BOTTOMPADDING", (0,0), (-1,-1), 14),
    ("LEFTPADDING",   (0,0), (-1,-1), 20),
    ("RIGHTPADDING",  (0,0), (-1,-1), 20),
    ("ROUNDEDCORNERS", [6]),
]))
story.append(spacer(1))
story.append(cover_bg)
story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 1 — OVERVIEW & PHARMACOLOGY
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_header("1.  Overview & Pharmacology"))
story.append(spacer())
story.append(para(
    "Hydrocortisone (cortisol) is the principal endogenous glucocorticoid secreted by the "
    "zona fasciculata of the adrenal cortex. It is synthesised from cholesterol and is the "
    "reference compound against which all synthetic corticosteroids are compared (relative "
    "anti-inflammatory potency = 1). In clinical practice, hydrocortisone is used both as "
    "physiological replacement and as a pharmacological agent to attenuate the inflammatory "
    "and stress responses."
))
story.append(spacer())

*sub_header("Drug Nomenclature & Formulations"), *[spacer(0.1)]
story.extend(sub_header("Drug Nomenclature & Formulations"))
story.append(para("<b>Generic name:</b> Hydrocortisone &nbsp;|&nbsp; <b>Class:</b> Corticosteroid (glucocorticoid)"))
story.append(spacer(0.2))

form_data = [
    [Paragraph("Route", tbl_hdr), Paragraph("Formulation", tbl_hdr), Paragraph("Common Brands", tbl_hdr)],
    [Paragraph("Oral", tbl_cell),     Paragraph("Tablets: 5, 10, 20 mg\nGranule capsules: 0.5, 1, 2, 5 mg\nSuspension: 2 mg/mL", tbl_left), Paragraph("Cortef, Alkindi Sprinkle", tbl_cell)],
    [Paragraph("IV / IM", tbl_cell),  Paragraph("Sodium succinate injection: 100, 250, 500, 1000 mg/vial", tbl_left), Paragraph("Solu-Cortef", tbl_cell)],
    [Paragraph("Rectal", tbl_cell),   Paragraph("Enema 100 mg/60 mL; Foam 10% (90 mg/dose); Suppositories 25–30 mg", tbl_left), Paragraph("Cortenema, Cortifoam, Proctocort", tbl_cell)],
    [Paragraph("Topical", tbl_cell),  Paragraph("Cream/ointment/lotion: 0.5%, 1%, 2%, 2.5%", tbl_left), Paragraph("NuCort, MiCort-HC", tbl_cell)],
]
form_tbl = Table(form_data, colWidths=[3*cm, 7.5*cm, 6*cm])
form_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), TEAL),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [GREY, white]),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.lightgrey),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(form_tbl)
story.append(spacer())

story.extend(sub_header("Mechanism of Action"))
story.append(para(
    "Hydrocortisone binds to intracellular glucocorticoid receptors (GR-alpha), forming a "
    "ligand-receptor complex that translocates to the nucleus. There it modulates transcription "
    "of target genes - upregulating anti-inflammatory mediators (lipocortin-1, IL-10) and "
    "suppressing pro-inflammatory cytokines (TNF-alpha, IL-1, IL-6), phospholipase A2, and "
    "COX-2. It also stabilises lysosomal membranes, reduces capillary permeability, and "
    "inhibits prostaglandin and leukotriene synthesis."
))
story.append(spacer())

story.extend(sub_header("Pharmacokinetics"))
pk_data = [
    [Paragraph("Parameter", tbl_hdr), Paragraph("Detail", tbl_hdr)],
    [Paragraph("Absorption (oral)", tbl_left), Paragraph("Rapid; peak plasma ~1 h", tbl_left)],
    [Paragraph("Protein binding", tbl_left), Paragraph("~90% (CBG and albumin); only free fraction is active", tbl_left)],
    [Paragraph("Metabolism", tbl_left), Paragraph("Hepatic (and renal); converted to inactive tetrahydro-metabolites", tbl_left)],
    [Paragraph("Plasma half-life", tbl_left), Paragraph("~90 minutes (biological effect lasts 8–12 hours)", tbl_left)],
    [Paragraph("Elimination", tbl_left), Paragraph("Renal excretion as glucuronide/sulfate conjugates", tbl_left)],
    [Paragraph("Bioavailability (IV vs oral)", tbl_left), Paragraph("IV = 100%; oral ~96%", tbl_left)],
]
pk_tbl = Table(pk_data, colWidths=[6*cm, 11*cm])
pk_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), TEAL),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [GREY, white]),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.lightgrey),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(pk_tbl)

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 2 — HPA AXIS & SURGICAL STRESS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_header("2.  HPA Axis & Surgical Stress Response"))
story.append(spacer())
story.append(para(
    "The hypothalamic-pituitary-adrenal (HPA) axis responds to surgical stress by releasing "
    "corticotropin-releasing hormone (CRH) from the hypothalamus, which stimulates ACTH "
    "secretion from the pituitary, which in turn drives adrenal cortisol output. Under basal "
    "conditions, adults secrete approximately <b>20 mg of cortisol daily</b>. Under conditions "
    "of maximal surgical stress, this may increase to more than <b>300 mg/day</b>."
))
story.append(spacer())
story.append(para(
    "Patients on long-term exogenous glucocorticoids develop HPA axis suppression. When these "
    "patients undergo surgery, their adrenal glands may not respond adequately to stress, "
    "potentially resulting in an <b>acute adrenal (Addisonian) crisis</b> - characterised by "
    "fever, abdominal pain, orthostatic hypotension, hypovolaemia, and circulatory shock "
    "unresponsive to resuscitation."
))
story.append(spacer())

story.extend(sub_header("Who is at Risk?"))
story.append(bp("Patients taking &ge;5 mg prednisone/day (or equivalent) for &ge;2 weeks in the past 12 months"))
story.append(bp("Any route of administration: oral, topical, inhalational, intra-articular"))
story.append(bp("Patients with primary adrenal insufficiency (Addison's disease) - highest risk"))
story.append(bp("Patients receiving etomidate infusions (direct adrenocortical suppression)"))
story.append(bp("Cushing's syndrome patients undergoing adrenalectomy"))
story.append(spacer())

story.extend(sub_header("Who is NOT at Risk (No Supplementation Needed)?"))
story.append(bp("Taking glucocorticoids for <3 weeks"))
story.append(bp("Taking <5 mg prednisone/day (or equivalent) for any duration"))
story.append(bp("Taking <10 mg prednisone every other day"))
story.append(para("<i>(These patients have a non-suppressed HPA axis; maintain their usual daily dose peri-operatively.)</i>"))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 3 — PERIOPERATIVE DOSING PROTOCOLS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_header("3.  Perioperative Hydrocortisone Dosing Protocols"))
story.append(spacer())

# ── 3a Morgan & Mikhail ──
story.extend(sub_header("3a. Morgan & Mikhail Regimen (Traditional + Low-Dose)"))
story.append(para(
    "<b>Traditional regimen:</b> Administer <b>100 mg hydrocortisone IV every 8 hours</b> "
    "beginning on the morning of surgery. Continue for 24–48 h then taper to usual dose."
))
story.append(spacer(0.2))
story.append(para(
    "<b>Low-dose (preferred) regimen:</b> <b>25 mg hydrocortisone IV at induction</b>, "
    "followed by an infusion of <b>100 mg hydrocortisone over 24 hours</b>. This maintains "
    "plasma cortisol equal to or higher than levels seen in healthy patients undergoing "
    "similar elective surgery, and is particularly useful in diabetic patients as it "
    "minimises glucocorticoid-induced hyperglycaemia."
))
story.append(spacer(0.4))
story.append(Paragraph(
    "<i>Source: Morgan &amp; Mikhail's Clinical Anesthesiology, 7e, p.1430-1431</i>", note))
story.append(spacer())

# ── 3b Fischer Mastery of Surgery ──
story.extend(sub_header("3b. Fischer's Mastery of Surgery - Stress-Based Protocol"))
story.append(para(
    "Based on the extent of surgical stress and HPA suppression status:"
))
story.append(spacer(0.2))

fischer_data = [
    [Paragraph("Surgical Stress Level", tbl_hdr), Paragraph("Pre-induction Dose", tbl_hdr), Paragraph("Post-operative Continuation", tbl_hdr)],
    [Paragraph("Moderate stress\n(e.g., arthroplasty, abdominal procedures)", tbl_left),
     Paragraph("50 mg hydrocortisone IV", tbl_cell),
     Paragraph("25 mg IV every 8 h for 24 h,\nthen resume outpatient dose", tbl_left)],
    [Paragraph("Major stress\n(e.g., major vascular, trauma, bilateral procedures)", tbl_left),
     Paragraph("100 mg hydrocortisone IV", tbl_cell),
     Paragraph("50 mg IV every 8 h for 24 h,\nthen resume outpatient dose", tbl_left)],
]
fischer_tbl = Table(fischer_data, colWidths=[6*cm, 5*cm, 6*cm])
fischer_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), NAVY),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHT, white]),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.lightgrey),
    ("TOPPADDING",    (0,0), (-1,-1), 6),
    ("BOTTOMPADDING", (0,0), (-1,-1), 6),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(fischer_tbl)
story.append(spacer(0.2))
story.append(Paragraph("<i>Source: Fischer's Mastery of Surgery, 8e, p.189-190</i>", note))
story.append(spacer())

# ── 3c Campbell - Orthopaedic procedures ──
story.extend(sub_header("3c. Campbell's Operative Orthopaedics - Procedure Classification"))
story.append(spacer(0.2))

camp_data = [
    [Paragraph("Procedure Class", tbl_hdr), Paragraph("Example Procedures", tbl_hdr), Paragraph("Recommended Supplemental Dose", tbl_hdr)],
    [Paragraph("Minor / Minimal stress", tbl_left),
     Paragraph("Carpal tunnel release, knee arthroscopy, tenosynovectomy, hammer toe correction", tbl_left),
     Paragraph("25 mg hydrocortisone on day of procedure only\n(equiv. prednisone 5 mg)", tbl_left)],
    [Paragraph("Moderate stress", tbl_left),
     Paragraph("Hip/knee/shoulder/ankle arthroplasty, ACL reconstruction, complex foot reconstruction", tbl_left),
     Paragraph("50-75 mg hydrocortisone on day of procedure;\ntaper over 1-2 days to pre-op dose\n(equiv. prednisone 10-15 mg)", tbl_left)],
    [Paragraph("Intensive / Significant stress", tbl_left),
     Paragraph("Multiple trauma, bilateral knee arthroplasty, revision arthroplasty, multilevel spinal fusion", tbl_left),
     Paragraph("100-150 mg hydrocortisone on day of procedure;\ntaper over 1-2 days to pre-op dose\n(equiv. prednisone 20-30 mg)", tbl_left)],
]
camp_tbl = Table(camp_data, colWidths=[4.5*cm, 6.5*cm, 6*cm])
camp_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), NAVY),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHT, GREY, white]),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.lightgrey),
    ("TOPPADDING",    (0,0), (-1,-1), 6),
    ("BOTTOMPADDING", (0,0), (-1,-1), 6),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(camp_tbl)
story.append(spacer(0.2))
story.append(Paragraph(
    "<i>Source: Campbell's Operative Orthopaedics, 15e (from Howe CR, Gardner GC, Kadel NJ: "
    "J Am Acad Orthop Surg 14:544, 2006)</i>", note))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 4 — DOSING IN OTHER INDICATIONS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_header("4.  Dosing in Other Anaesthesia-Relevant Conditions"))
story.append(spacer())

story.extend(sub_header("Acute Adrenal Insufficiency (Addisonian Crisis)"))
story.append(bp("<b>Adult:</b> 100 mg IV hydrocortisone immediately; continue 50-100 mg IV every 6-8 h"))
story.append(bp("Concurrent aggressive IV fluid resuscitation (0.9% NaCl) is essential"))
story.append(bp("Monitor glucose, electrolytes, blood pressure continuously"))
story.append(bp("Primary AI patients should receive 100 mg IV before induction of anaesthesia (Sabiston)"))
story.append(spacer())

story.extend(sub_header("Status Asthmaticus"))
story.append(bp("<b>Child:</b> Load (optional) 4-8 mg/kg/dose IV (max 250 mg); Maintenance 8 mg/kg/24 h divided Q6 h IV"))
story.append(bp("<b>Adult:</b> 100-500 mg/dose IV every 6 h"))
story.append(spacer())

story.extend(sub_header("Physiological Replacement (Chronic Adrenal Insufficiency)"))
story.append(para(
    "Daily adult cortisol production ~30 mg/day. Standard replacement: <b>20 mg oral hydrocortisone "
    "in the morning + 10 mg in the evening.</b> Supplemental fludrocortisone 0.1 mg/day for "
    "mineralocorticoid replacement in primary adrenal insufficiency."
))
story.append(spacer())

story.extend(sub_header("Anti-inflammatory / Immunosuppressive (Paediatric)"))
story.append(bp("PO: 2.5-10 mg/kg/24 h divided Q6-8 h"))
story.append(bp("IM/IV: 1-5 mg/kg/24 h divided Q12-24 h"))
story.append(spacer())

story.extend(sub_header("Adolescent & Adult Anti-inflammatory"))
story.append(bp("PO/IM/IV: 15-240 mg/dose every 12 h (titrated to response)"))
story.append(spacer())

story.extend(sub_header("Glucocorticoid Potency Comparison"))
pot_data = [
    [Paragraph("Drug", tbl_hdr), Paragraph("Anti-inflammatory\nPotency", tbl_hdr), Paragraph("Mineralocorticoid\nActivity", tbl_hdr), Paragraph("Equivalent\nDose (mg)", tbl_hdr)],
    [Paragraph("Cortisone", tbl_cell),          Paragraph("0.8", tbl_cell),  Paragraph("++", tbl_cell),    Paragraph("25", tbl_cell)],
    [Paragraph("Hydrocortisone", tbl_cell),      Paragraph("1 (reference)",tbl_cell),Paragraph("++",tbl_cell),Paragraph("20", tbl_cell)],
    [Paragraph("Prednisone", tbl_cell),          Paragraph("4", tbl_cell),   Paragraph("+", tbl_cell),     Paragraph("5", tbl_cell)],
    [Paragraph("Prednisolone", tbl_cell),        Paragraph("4", tbl_cell),   Paragraph("+", tbl_cell),     Paragraph("5", tbl_cell)],
    [Paragraph("Methylprednisolone", tbl_cell),  Paragraph("5", tbl_cell),   Paragraph("nil", tbl_cell),   Paragraph("4", tbl_cell)],
    [Paragraph("Triamcinolone", tbl_cell),       Paragraph("5", tbl_cell),   Paragraph("nil", tbl_cell),   Paragraph("4", tbl_cell)],
    [Paragraph("Dexamethasone", tbl_cell),       Paragraph("25-30", tbl_cell),Paragraph("nil", tbl_cell),  Paragraph("0.75", tbl_cell)],
]
pot_tbl = Table(pot_data, colWidths=[5*cm, 4.5*cm, 4*cm, 3.5*cm])
pot_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), TEAL),
    ("BACKGROUND",    (0,2), (-1,2), HexColor("#D4EBF0")),  # highlight HC row
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [GREY, white, LIGHT, white, GREY, white, LIGHT]),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.lightgrey),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("FONTNAME",      (0,2), (-1,2), "Helvetica-Bold"),
]))
story.append(pot_tbl)
story.append(Paragraph("<i>Source: The Washington Manual of Medical Therapeutics; Katzung's Pharmacology 16e</i>", note))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 5 — ADVERSE EFFECTS & PRECAUTIONS
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_header("5.  Adverse Effects, Precautions & Monitoring"))
story.append(spacer())

story.extend(sub_header("Short-term Perioperative Use"))
story.append(bp("Hyperglycaemia - monitor blood glucose closely, especially in diabetic patients"))
story.append(bp("Hypertension and sodium/water retention (mineralocorticoid effect)"))
story.append(bp("Hypokalaemia - check K+ levels, especially with high doses"))
story.append(bp("Impaired wound healing with prolonged use"))
story.append(bp("Risk of infections - avoid exposure to chickenpox and measles in immunocompromised patients"))
story.append(spacer())

story.extend(sub_header("Long-term / Chronic Use"))
story.append(bp("HPA axis suppression and secondary adrenal insufficiency"))
story.append(bp("Cushing's syndrome features: moon facies, truncal obesity, striae, easy bruising"))
story.append(bp("Osteoporosis and vertebral compression fractures"))
story.append(bp("Psychiatric effects: mood changes, euphoria, psychosis"))
story.append(bp("Growth retardation in children"))
story.append(bp("Hypertrophic cardiomyopathy in premature infants"))
story.append(bp("Peptic ulceration (particularly with concurrent NSAIDs)"))
story.append(spacer())

story.extend(sub_header("Special Considerations in Anaesthesia"))
story.append(bp("<b>Etomidate:</b> Inhibits 11-beta-hydroxylase causing adrenocortical suppression; "
    "consider perioperative hydrocortisone cover"))
story.append(bp("<b>Diabetes:</b> Prefer low-dose regimen (25 mg induction + 100 mg infusion/24 h) to limit hyperglycaemia"))
story.append(bp("<b>Septic shock:</b> Hydrocortisone 200-300 mg/day IV in divided doses or continuous infusion "
    "considered in vasopressor-dependent shock"))
story.append(bp("<b>Rheumatoid arthritis:</b> Check cervical spine flexion-extension films before intubation; "
    "atlantoaxial subluxation risk"))
story.append(bp("<b>Alkindi Sprinkle (paediatric):</b> Sprinkle capsule contents on tongue/soft food - do not swallow capsule; "
    "bioavailability differs from crushed/compounded tablets"))
story.append(spacer())

story.extend(sub_header("Monitoring Parameters"))
mon_data = [
    [Paragraph("Parameter", tbl_hdr),  Paragraph("Target / Action", tbl_hdr)],
    [Paragraph("Blood glucose", tbl_left),       Paragraph("Monitor 2-4 hourly intra-/post-op; treat >180 mg/dL", tbl_left)],
    [Paragraph("Blood pressure", tbl_left),      Paragraph("Watch for hypertension; manage fluid balance", tbl_left)],
    [Paragraph("Serum potassium", tbl_left),      Paragraph("Monitor; supplement if <3.5 mmol/L", tbl_left)],
    [Paragraph("Serum cortisol", tbl_left),       Paragraph("Basal morning cortisol >15 mcg/dL excludes adrenal insufficiency", tbl_left)],
    [Paragraph("Cosyntropin stimulation", tbl_left), Paragraph("250 mcg IV; cortisol <18 mcg/dL at 30-60 min = AI", tbl_left)],
    [Paragraph("Clinical response", tbl_left),   Paragraph("Resolution of hypotension, fever, abdominal pain in crisis", tbl_left)],
]
mon_tbl = Table(mon_data, colWidths=[5.5*cm, 11.5*cm])
mon_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), TEAL),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [GREY, white]),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.lightgrey),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(mon_tbl)

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 6 — CLINICAL DECISION ALGORITHM
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_header("6.  Clinical Decision Algorithm"))
story.append(spacer())

algo_data = [
    [Paragraph("<b>PATIENT ON CHRONIC GLUCOCORTICOIDS PRESENTING FOR SURGERY</b>", tbl_hdr)],
    [Paragraph(
        "<b>Step 1: Assess HPA Axis Status</b><br/><br/>"
        "&#9679;  &lt;3 weeks of steroids?  &#x2192;  <b>HPA intact</b><br/>"
        "&#9679;  &lt;5 mg prednisone/day (any duration)?  &#x2192;  <b>HPA intact</b><br/>"
        "&#9679;  &lt;10 mg prednisone every other day?  &#x2192;  <b>HPA intact</b><br/>"
        "&#9679;  &gt;20 mg prednisone/day for &gt;3 weeks?  &#x2192;  <b>HPA SUPPRESSED</b><br/>"
        "&#9679;  Cushing's syndrome?  &#x2192;  <b>HPA SUPPRESSED</b>",
        ParagraphStyle("algo", fontSize=10, textColor=DKGREY, leading=16, leftIndent=10))],
    [Paragraph(
        "<b>Step 2: If HPA Intact</b><br/>"
        "Continue usual daily dose peri-operatively. No supplemental hydrocortisone required.",
        ParagraphStyle("algoG", fontSize=10, textColor=HexColor("#1A6B3A"), leading=16, leftIndent=10))],
    [Paragraph(
        "<b>Step 3: If HPA Suppressed - dose by stress level</b><br/><br/>"
        "<b>Minor procedures:</b> 25 mg hydrocortisone IV on day of procedure only<br/>"
        "<b>Moderate procedures:</b> 50 mg IV before induction + 25 mg IV Q8h x 24 h; then resume outpatient dose<br/>"
        "<b>Major/intensive procedures:</b> 100 mg IV before induction + 50 mg IV Q8h x 24-48 h; taper to outpatient dose<br/>"
        "<b>Addison's disease (primary AI):</b> 100 mg IV before induction regardless of procedure type",
        ParagraphStyle("algoR", fontSize=10, textColor=HexColor("#7A1A1A"), leading=16, leftIndent=10))],
    [Paragraph(
        "<b>Step 4: Post-operative taper</b><br/>"
        "Expeditious taper over 1-2 days to pre-operative dose. Prolonged steroid courses increase infection risk, "
        "impair wound healing, and cause hyperglycaemia.",
        ParagraphStyle("algoB", fontSize=10, textColor=DKGREY, leading=16, leftIndent=10))],
]
algo_tbl = Table(algo_data, colWidths=[17*cm])
algo_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (0,0), NAVY),
    ("BACKGROUND",    (0,1), (0,1), HexColor("#FFF9E6")),
    ("BACKGROUND",    (0,2), (0,2), HexColor("#E8F8EE")),
    ("BACKGROUND",    (0,3), (0,3), HexColor("#FDE8E8")),
    ("BACKGROUND",    (0,4), (0,4), LIGHT),
    ("BOX",           (0,0), (-1,-1), 1, NAVY),
    ("LINEBELOW",     (0,0), (-1,0), 1, white),
    ("LINEBELOW",     (0,1), (-1,1), 1, TEAL),
    ("LINEBELOW",     (0,2), (-1,2), 1, TEAL),
    ("LINEBELOW",     (0,3), (-1,3), 1, TEAL),
    ("TOPPADDING",    (0,0), (-1,-1), 10),
    ("BOTTOMPADDING", (0,0), (-1,-1), 10),
    ("LEFTPADDING",   (0,0), (-1,-1), 14),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(algo_tbl)

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 7 — KEY CLINICAL NOTES
# ═══════════════════════════════════════════════════════════════════════════════
story.append(section_header("7.  Key Clinical Notes & Pearls"))
story.append(spacer())

notes = [
    ("<b>Etomidate and adrenal suppression:</b>", 
     "Even a single induction dose of etomidate inhibits 11-beta-hydroxylase and can "
     "cause clinically significant adrenocortical suppression for 24-48 hours. Consider "
     "hydrocortisone supplementation when etomidate is used, particularly in critically ill patients."),
    ("<b>Secondary vs. Primary AI:</b>",
     "Patients with secondary AI (chronic steroid use) have only a 1-2% risk of perioperative "
     "hypotensive crisis. However, patients with primary Addison's disease are at HIGH risk and "
     "always require 100 mg IV hydrocortisone before induction."),
    ("<b>Low-dose regimen advantages:</b>",
     "The 25 mg induction + 100 mg/24 h infusion regimen achieves cortisol levels equivalent "
     "to those in healthy patients under stress while minimising metabolic side effects. This is "
     "preferred in diabetic and hypertensive patients."),
    ("<b>Rheumatologic patients:</b>",
     "Recent evidence has questioned routine supraphysiological steroid cover for all rheumatologic "
     "patients. An individualised approach based on HPA axis assessment is now preferred. Methotrexate "
     "and hydroxychloroquine can be continued; biologic agents should be held 7 days pre-operatively."),
    ("<b>Paediatric dosing:</b>",
     "For Alkindi Sprinkle (granule capsules), sprinkle contents onto tongue or soft food - never "
     "swallow the capsule. Bioavailability differs from crushed/compounded tablet formulations. "
     "Different exposure profiles are expected when switching formulations."),
    ("<b>Septic shock:</b>",
     "Hydrocortisone 200 mg/day as continuous infusion or 50 mg IV Q6h is recommended in "
     "vasopressor-refractory septic shock (relative adrenal insufficiency). Taper once vasopressors "
     "are discontinued."),
]

for title, content in notes:
    box = Table([[Paragraph(f"{title}<br/>{content}", body)]], colWidths=[17*cm])
    box.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), LIGHT),
        ("LEFTBORDER",    (0,0), (0,-1), 4, TEAL),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("BOX",           (0,0), (-1,-1), 0.5, TEAL),
    ]))
    story.append(KeepTogether([box, Spacer(1, 0.2*cm)]))

story.append(spacer())

# ─── References ──────────────────────────────────────────────────────────────
story.extend(sub_header("References"))
refs = [
    "Morgan &amp; Mikhail's Clinical Anesthesiology, 7th Edition (2023), Chapter on Endocrine Disease, pp. 1430-1431.",
    "Fischer's Mastery of Surgery, 8th Edition (2023), Perioperative Management, pp. 189-190.",
    "Sabiston Textbook of Surgery - The Biological Basis of Modern Surgical Practice (2022), "
    "Perioperative Steroid Administration, p. 1759.",
    "Campbell's Operative Orthopaedics, 15th Edition (2026). Supplemental Hydrocortisone for Surgical Stress Levels. "
    "From: Howe CR, Gardner GC, Kadel NJ: J Am Acad Orthop Surg 14:544, 2006.",
    "The Harriet Lane Handbook - The Johns Hopkins Hospital, 23rd Edition. Hydrocortisone drug monograph, pp. 1172-1173.",
    "Katzung's Basic and Clinical Pharmacology, 16th Edition. The Naturally Occurring Glucocorticoids.",
    "The Washington Manual of Medical Therapeutics. Glucocorticoids - Potency Comparison.",
]
for i, r in enumerate(refs, 1):
    story.append(Paragraph(f"[{i}]  {r}", ParagraphStyle("ref", fontSize=9, textColor=DKGREY,
                                                           fontName="Helvetica", leading=13,
                                                           leftIndent=20, firstLineIndent=-20,
                                                           spaceBefore=4)))

story.append(spacer(0.5))
story.append(HRFlowable(width="100%", thickness=0.5, color=colors.lightgrey))
story.append(spacer(0.2))
story.append(Paragraph(
    "This document was generated by Orris Medical Intelligence for educational purposes. "
    "Clinical decisions should be based on current guidelines and individual patient assessment.",
    footer_s
))

# ── Build ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved to: {OUTPUT}")
Running Command

cd /tmp/workspace/hydrocortisone-pdf && python build_pdf.py 2>&1

Your PDF is ready. Here's your download link:

Hydrocortisone in Anaesthesia

PDF Document · PDF


Here's what the PDF covers across 7 detailed sections:
Section 1 - Overview & Pharmacology
  • Drug nomenclature, all formulations (oral, IV/IM, rectal, topical) with brand names
  • Mechanism of action (GR-alpha receptor, nuclear transcription, cytokine suppression)
  • Full pharmacokinetics table (absorption, protein binding, half-life ~90 min, metabolism, elimination)
Section 2 - HPA Axis & Surgical Stress
  • Normal cortisol output: ~20 mg/day; maximal surgical stress: >300 mg/day
  • Who IS at risk of adrenal crisis vs. who is NOT (clear criteria)
  • Addisonian crisis features
Section 3 - Perioperative Dosing Protocols (3 separate protocols)
  • Morgan & Mikhail: Traditional (100 mg IV Q8h) vs. low-dose (25 mg induction + 100 mg infusion/24 h)
  • Fischer's Mastery of Surgery: Moderate vs. major stress dosing
  • Campbell's Orthopaedics: Minor/moderate/intensive stress classification table
Section 4 - Dosing in Other Indications
  • Adrenal crisis, status asthmaticus (paediatric & adult), physiological replacement
  • Glucocorticoid potency comparison table (cortisone through dexamethasone)
Section 5 - Adverse Effects & Monitoring
  • Short-term vs. long-term effects
  • Special anaesthetic considerations (etomidate, diabetes, septic shock, rheumatoid arthritis)
  • Monitoring parameters with targets
Section 6 - Clinical Decision Algorithm
  • Step-by-step flowchart from HPA assessment to dose selection to taper
Section 7 - Clinical Pearls & References
  • 6 highlighted key clinical notes with full textbook references

Dexamethasone in anaesthesia but make it like a note that i can retain also sources

Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Writing File

~/hydrocortisone-pdf/build_dexa_note.py

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.lib.colors import HexColor, white, black
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY, TA_RIGHT
from reportlab.lib import colors

OUTPUT = "/tmp/workspace/hydrocortisone-pdf/Dexamethasone_in_Anaesthesia_Notes.pdf"

# ── Palette ──────────────────────────────────────────────────────────────────
PURPLE   = HexColor("#4B2E83")   # deep indigo/purple - heading
LAVENDER = HexColor("#EDE7F6")   # light purple bg
TEAL     = HexColor("#00796B")   # teal - subheadings
LTEAL    = HexColor("#E0F2F1")   # light teal bg
AMBER    = HexColor("#F57F17")   # amber - callout/key fact
LAMBER   = HexColor("#FFF8E1")   # light amber bg
RED      = HexColor("#C62828")   # danger/warning
LRED     = HexColor("#FFEBEE")   # light red bg
GREEN    = HexColor("#2E7D32")   # green - clinical pearl
LGREEN   = HexColor("#E8F5E9")   # light green bg
DKGREY   = HexColor("#2D2D2D")
MIDGREY  = HexColor("#555555")
LTGREY   = HexColor("#F5F5F5")
RULE     = HexColor("#CCCCCC")

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    leftMargin=1.8*cm, rightMargin=1.8*cm,
    topMargin=2*cm, bottomMargin=1.8*cm,
    title="Dexamethasone in Anaesthesia - Quick Notes",
    author="Orris Medical",
)

# ── Styles ───────────────────────────────────────────────────────────────────
def S(name, **kw):
    return ParagraphStyle(name, **kw)

BIG_TITLE  = S("BigTitle",  fontSize=22, textColor=PURPLE,  fontName="Helvetica-Bold",  alignment=TA_CENTER, leading=28, spaceBefore=0)
SUBTITLE   = S("Subtitle",  fontSize=11, textColor=TEAL,    fontName="Helvetica-Bold",  alignment=TA_CENTER, leading=15, spaceBefore=2)
DATELINE   = S("Dateline",  fontSize=8,  textColor=MIDGREY, fontName="Helvetica",       alignment=TA_CENTER, leading=12, spaceBefore=4)

SEC_STYLE  = S("Sec",  fontSize=12, textColor=white,  fontName="Helvetica-Bold", alignment=TA_LEFT, leading=16)
SUB_STYLE  = S("Sub",  fontSize=10, textColor=TEAL,   fontName="Helvetica-Bold", alignment=TA_LEFT, leading=14, spaceBefore=6)
BODY       = S("Body", fontSize=9.5,textColor=DKGREY, fontName="Helvetica",      alignment=TA_JUSTIFY, leading=14, spaceBefore=3)
BULLET     = S("Bul",  fontSize=9.5,textColor=DKGREY, fontName="Helvetica",      leftIndent=12, firstLineIndent=0, leading=14, spaceBefore=2)
KEY        = S("Key",  fontSize=9.5,textColor=DKGREY, fontName="Helvetica-Bold", leading=14, spaceBefore=2)
NOTE_S     = S("Note", fontSize=8.5,textColor=MIDGREY,fontName="Helvetica-Oblique", leading=12, spaceBefore=2)
REF_S      = S("Ref",  fontSize=8,  textColor=MIDGREY,fontName="Helvetica",      leftIndent=14, firstLineIndent=-14, leading=12, spaceBefore=2)
TH         = S("TH",   fontSize=9,  textColor=white,  fontName="Helvetica-Bold", alignment=TA_CENTER, leading=12)
TD         = S("TD",   fontSize=9,  textColor=DKGREY, fontName="Helvetica",      alignment=TA_LEFT,   leading=12)
TDC        = S("TDC",  fontSize=9,  textColor=DKGREY, fontName="Helvetica",      alignment=TA_CENTER, leading=12)
FOOT       = S("Foot", fontSize=7.5,textColor=HexColor("#999999"), fontName="Helvetica", alignment=TA_CENTER, leading=11)

W = 17.4*cm   # usable width

# ── Helpers ──────────────────────────────────────────────────────────────────
def sp(n=0.25): return Spacer(1, n*cm)

def section(label, color=PURPLE):
    t = Table([[Paragraph(label, SEC_STYLE)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), color),
        ("TOPPADDING",   (0,0),(-1,-1), 7),
        ("BOTTOMPADDING",(0,0),(-1,-1), 7),
        ("LEFTPADDING",  (0,0),(-1,-1), 10),
    ]))
    return [sp(0.3), t, sp(0.15)]

def sub(text):
    return [Paragraph(text, SUB_STYLE),
            HRFlowable(width=W, thickness=0.8, color=TEAL, spaceAfter=3)]

def bp(text): return Paragraph(f"\u25b8  {text}", BULLET)
def body(text): return Paragraph(text, BODY)

def callout(text, bg=LAMBER, border=AMBER, bold=False):
    st = KEY if bold else BODY
    t = Table([[Paragraph(text, st)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), bg),
        ("LEFTPADDING",  (0,0),(-1,-1), 10),
        ("RIGHTPADDING", (0,0),(-1,-1), 8),
        ("TOPPADDING",   (0,0),(-1,-1), 7),
        ("BOTTOMPADDING",(0,0),(-1,-1), 7),
        ("BOX",          (0,0),(-1,-1), 0.8, border),
    ]))
    return [t, sp(0.15)]

def two_col_table(data, col_w=None, hdr_color=PURPLE):
    if col_w is None: col_w = [5.5*cm, W - 5.5*cm]
    t = Table(data, colWidths=col_w)
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0),(-1,0), hdr_color),
        ("ROWBACKGROUNDS",(0,1),(-1,-1), [LTGREY, white]),
        ("GRID",          (0,0),(-1,-1), 0.3, RULE),
        ("TOPPADDING",    (0,0),(-1,-1), 5),
        ("BOTTOMPADDING", (0,0),(-1,-1), 5),
        ("LEFTPADDING",   (0,0),(-1,-1), 6),
        ("VALIGN",        (0,0),(-1,-1), "TOP"),
    ]))
    return [t, sp(0.2)]

# ═══════════════════════════════════════════════════════════════════════════════
story = []

# ── TITLE BLOCK ───────────────────────────────────────────────────────────────
title_tbl = Table([
    [Paragraph("DEXAMETHASONE", BIG_TITLE)],
    [Paragraph("in Anaesthesia", S("sub2", fontSize=16, textColor=TEAL, fontName="Helvetica-Bold", alignment=TA_CENTER, leading=20))],
    [sp(0.2)],
    [Paragraph("Quick-Retention Notes  |  Mechanisms · Dosing · PONV · Analgesia · Nerve Blocks · Pearls", SUBTITLE)],
    [sp(0.1)],
    [Paragraph("Orris Medical Intelligence  |  August 2026", DATELINE)],
], colWidths=[W])
title_tbl.setStyle(TableStyle([
    ("BACKGROUND",   (0,0),(-1,-1), LAVENDER),
    ("BOX",          (0,0),(-1,-1), 1.5, PURPLE),
    ("TOPPADDING",   (0,0),(-1,-1), 10),
    ("BOTTOMPADDING",(0,0),(-1,-1), 10),
    ("LEFTPADDING",  (0,0),(-1,-1), 14),
]))
story.append(title_tbl)
story.append(sp(0.4))

# ── WHY DEXAMETHASONE? ────────────────────────────────────────────────────────
story.extend(section("WHY DEXAMETHASONE IN ANAESTHESIA?"))
story.append(body(
    "Dexamethasone is a <b>synthetic fluorinated glucocorticoid</b> with "
    "<b>25-30x the anti-inflammatory potency</b> of hydrocortisone and "
    "<b>nil mineralocorticoid activity</b>. In anaesthesia it serves three "
    "principal roles: <b>(1)</b> prophylaxis/treatment of PONV, "
    "<b>(2)</b> multimodal analgesia/opioid-sparing, and "
    "<b>(3)</b> adjuvant to local anaesthetics in regional blocks."
))
story.append(sp(0.2))

# potency quick-ref box
story.extend(callout(
    "&#9733;  <b>KEY FACT - Potency:</b>  "
    "Hydrocortisone 1 : Prednisone 4 : Methylprednisolone 5 : "
    "<u>Dexamethasone 25-30</u>  |  Half-life: <b>36-54 hours (biological)</b>  |  "
    "Plasma t½: ~4 h  |  <b>No mineralocorticoid effect</b>",
    bg=LAVENDER, border=PURPLE, bold=True
))

# ── MECHANISM ─────────────────────────────────────────────────────────────────
story.extend(section("MECHANISM OF ACTION"))
story.extend(sub("Molecular Pathway"))
story.append(body(
    "Binds intracellular <b>glucocorticoid receptor-alpha (GR-alpha)</b> "
    "&#8594; nuclear translocation &#8594; transactivation of anti-inflammatory genes "
    "(lipocortin-1, IL-10) + transrepression of NF-κB and AP-1 "
    "&#8594; inhibits <b>phospholipase A2</b> (upstream of COX &amp; lipoxygenase) "
    "&#8594; &#8595; prostaglandins, leukotrienes, cytokines (TNF-alpha, IL-1, IL-6)."
))
story.append(sp(0.15))

mech_data = [
    [Paragraph("Action", TH), Paragraph("Effect in Anaesthesia", TH)],
    [Paragraph("Inhibits PLA2/COX-2", TD), Paragraph("Anti-inflammatory → reduces surgical oedema, pain", TD)],
    [Paragraph("Suppresses cytokines", TD), Paragraph("Attenuates stress response, reduces PONV trigger", TD)],
    [Paragraph("Central antiemetic", TD), Paragraph("Mechanism unclear; likely prostaglandin inhibition in CNS + serotonin modulation", TD)],
    [Paragraph("Peripheral nerve effect", TD), Paragraph("Prolongs conduction block via glucocorticoid receptors on nerve (+ possible systemic opioid-sparing)", TD)],
    [Paragraph("Stabilises membranes", TD), Paragraph("Reduces airway oedema post-intubation/extubation", TD)],
]
story.extend(two_col_table(mech_data, col_w=[4.5*cm, W-4.5*cm]))

# ── SECTION: PONV ─────────────────────────────────────────────────────────────
story.extend(section("1.  PONV PROPHYLAXIS & TREATMENT", color=TEAL))
story.extend(sub("Incidence & Risk (Apfel Score)"))
story.append(body(
    "Without prophylaxis, PONV affects <b>~30% of the general surgical population</b> "
    "and up to <b>70-80% in high-risk patients</b>. The Apfel simplified score uses "
    "4 factors (female sex, non-smoking, history of PONV/motion sickness, postoperative "
    "opioids) - each adds ~20% risk."
))
story.append(sp(0.15))

apfel_data = [
    [Paragraph("Apfel Score", TH), Paragraph("0", TDC), Paragraph("1", TDC), Paragraph("2", TDC), Paragraph("3", TDC), Paragraph("4", TDC)],
    [Paragraph("PONV Risk", TD),   Paragraph("10%", TDC), Paragraph("21%", TDC), Paragraph("39%", TDC), Paragraph("61%", TDC), Paragraph("79%", TDC)],
]
at = Table(apfel_data, colWidths=[4*cm, 2.68*cm, 2.68*cm, 2.68*cm, 2.68*cm, 2.68*cm])
at.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), TEAL),
    ("ROWBACKGROUNDS",(0,1),(-1,-1), [LTEAL]),
    ("GRID",          (0,0),(-1,-1), 0.3, RULE),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
    ("ALIGN",         (1,0),(-1,-1), "CENTER"),
]))
story.append(at)
story.append(sp(0.2))

story.extend(sub("Dexamethasone Dose for PONV"))
dose_data = [
    [Paragraph("Indication", TH), Paragraph("Dose", TH), Paragraph("Timing", TH), Paragraph("Notes", TH)],
    [Paragraph("PONV prophylaxis\n(adult)", TD), Paragraph("4-8 mg IV", TDC), Paragraph("At induction / before surgical start", TD), Paragraph("Give BEFORE incision; onset 1-2 h so must be pre-emptive", TD)],
    [Paragraph("PONV prophylaxis\n(paediatric)", TD), Paragraph("0.15 mg/kg IV\n(max 8 mg)", TDC), Paragraph("At induction", TD), Paragraph("Part of multi-modal PONV protocol", TD)],
    [Paragraph("Treatment of\nestablished PONV", TD), Paragraph("4 mg IV\n(if not already given)", TDC), Paragraph("Post-op rescue", TD), Paragraph("Use a different class if prophylaxis already given with dexa", TD)],
]
story.extend(two_col_table(dose_data, col_w=[3.5*cm, 2.5*cm, 4*cm, W-10*cm], hdr_color=TEAL))

story.extend(callout(
    "&#9888;  <b>TIMING IS CRITICAL:</b> Dexamethasone onset is <b>1-2 hours</b>. "
    "It MUST be given before surgical stimulus - ideally at induction. "
    "Given post-op, it offers little benefit for established PONV "
    "(use ondansetron instead as rescue if dexa was already given).",
    bg=LAMBER, border=AMBER
))

story.extend(sub("PONV Drug Classes - Quick Summary"))
story.append(bp("<b>5-HT3 antagonists</b> (ondansetron, granisetron, ramosetron) - first-line"))
story.append(bp("<b>Dexamethasone</b> - combine with 5-HT3 antagonist for 2-drug prophylaxis in moderate risk"))
story.append(bp("<b>NK1 antagonists</b> (aprepitant) - add as 3rd agent in high-risk; most effective"))
story.append(bp("<b>Butyrophenones</b> (droperidol, haloperidol) - QTc risk; small doses effective"))
story.append(bp("<b>Antihistamines + scopolamine patch</b> - useful adjuncts"))
story.append(sp(0.15))
story.extend(callout(
    "&#128204; <b>REMEMBER:</b> 2 antiemetics now recommended for ALL patients with "
    "1-2 Apfel risk factors (4th SAMBA Consensus Guidelines 2020). "
    "Dexamethasone + ondansetron is the most-studied combination.",
    bg=LGREEN, border=GREEN
))

story.append(PageBreak())

# ── SECTION: ANALGESIA ────────────────────────────────────────────────────────
story.extend(section("2.  MULTIMODAL ANALGESIA", color=PURPLE))
story.extend(sub("Role in Postoperative Pain"))
story.append(body(
    "Dexamethasone is a valuable component of multimodal analgesia alongside "
    "a gabapentinoid, paracetamol, and NSAID. It inhibits <b>phospholipase A2</b> "
    "upstream of COX and lipoxygenase, reducing prostaglandin and leukotriene "
    "production. This explains both its anti-inflammatory AND analgesic effects. "
    "The antiemetic mechanism is less clear but appears <b>centrally mediated</b>."
))
story.append(sp(0.15))

story.extend(callout(
    "&#9679; Meta-analysis: Dexamethasone &#8594; <b>less postoperative pain</b>, "
    "<b>fewer opioids needed</b>, <b>shorter PACU stay</b>.<br/>"
    "&#9679; Single-dose dexamethasone in abdominal surgery: most effective at "
    "<b>intermediate dose 6.4-10 mg</b>, given <b>preoperatively</b>.<br/>"
    "&#9679; Blood glucose raised at 24 h - but <b>no increase in wound infection</b> "
    "or delayed healing in large RCT (8 mg intraoperative). <i>(Miller's Anesthesia 10e)</i>",
    bg=LTEAL, border=TEAL
))

story.extend(sub("Analgesic Dosing"))
story.append(body(
    "<b>Preoperative IV dose for analgesia: 0.11-0.2 mg/kg</b> "
    "(higher than the antiemetic dose of 4-8 mg)."
))
story.append(sp(0.1))
story.extend(callout(
    "&#9888; <b>ADMINISTRATION TIP:</b> Dexamethasone causes <b>perineal burning/irritation "
    "in 50-70% of patients</b> on rapid IV push. "
    "Always dilute in 50 mL normal saline and give over <b>10 minutes</b> prior to surgery. "
    "<i>(Barash Clinical Anesthesia 9e)</i>",
    bg=LRED, border=RED
))
story.append(sp(0.1))

analg_data = [
    [Paragraph("Indication", TH), Paragraph("Dose", TH), Paragraph("Route", TH), Paragraph("Timing", TH)],
    [Paragraph("PONV prophylaxis", TD), Paragraph("4-8 mg", TDC), Paragraph("IV", TDC), Paragraph("Induction", TDC)],
    [Paragraph("Multimodal analgesia", TD), Paragraph("0.11-0.2 mg/kg\n(~8-16 mg adult)", TDC), Paragraph("IV", TDC), Paragraph("Pre-op / induction", TDC)],
    [Paragraph("Nerve block adjuvant\n(perineural)", TD), Paragraph("4-8 mg", TDC), Paragraph("Perineural\nor IV", TDC), Paragraph("With LA injection", TDC)],
    [Paragraph("Airway oedema\n(extubation)", TD), Paragraph("0.5 mg/kg", TDC), Paragraph("IV", TDC), Paragraph("Night before or\nat extubation", TDC)],
]
story.extend(two_col_table(analg_data, col_w=[4.2*cm, 4*cm, 2.5*cm, W-10.7*cm], hdr_color=PURPLE))

# ── SECTION: REGIONAL ─────────────────────────────────────────────────────────
story.extend(section("3.  REGIONAL ANAESTHESIA ADJUVANT", color=TEAL))
story.extend(sub("Mechanism of Block Prolongation"))
story.append(body(
    "Addition of dexamethasone to local anaesthetics (LA) extends block duration. "
    "The exact mechanism is debated - it may be <b>locally mediated via glucocorticoid "
    "receptors on the nerve</b>, or a <b>systemic anti-inflammatory/opioid-sparing</b> "
    "effect from absorbed drug. Both models are supported by evidence. "
    "Steroid receptor-dependent effects correlate with glucocorticoid potency in animal models. "
    "<i>(Barash Clinical Anesthesia 9e)</i>"
))
story.append(sp(0.15))

reg_data = [
    [Paragraph("Nerve Block", TH), Paragraph("Effect of Adding Dexa", TH), Paragraph("Dose", TH)],
    [Paragraph("Brachial plexus\n(interscalene, supraclavicular)", TD), Paragraph("Extends analgesia by 50-100% vs LA alone", TD), Paragraph("4-8 mg perineural\nor IV", TDC)],
    [Paragraph("Sciatic nerve block", TD), Paragraph("Prolonged sensory and motor block duration", TD), Paragraph("4-8 mg", TDC)],
    [Paragraph("Saphenous nerve block", TD), Paragraph("Prolonged analgesic duration", TD), Paragraph("4 mg", TDC)],
    [Paragraph("General peripheral\nnerve blocks", TD), Paragraph("Dose-response 1-4 mg; possible ceiling >4 mg", TD), Paragraph("1-4 mg optimal", TDC)],
]
story.extend(two_col_table(reg_data, col_w=[4.5*cm, 8*cm, W-12.5*cm], hdr_color=TEAL))

story.extend(callout(
    "&#128204; <b>PERINEURAL vs IV?</b>  A systematic review shows both routes prolong "
    "brachial plexus block duration. However, a dose-response is seen with perineural "
    "dexamethasone 1-4 mg; doses >4 mg show possible ceiling effect. "
    "The two mechanisms may be additive in surgical (vs. non-surgical) patients - "
    "active inflammation may be required for maximal steroid effect.",
    bg=LTEAL, border=TEAL
))
story.append(sp(0.1))

story.extend(sub("Airway Oedema & Extubation"))
story.append(body(
    "Dexamethasone <b>0.5 mg/kg IV</b> administered the night before extubation reduces "
    "laryngeal oedema risk following prolonged intubation or reconstructive head/neck "
    "surgery. Patient should be extubated fully awake with airway rescue equipment "
    "available. <i>(Scott-Brown's Otorhinolaryngology &amp; Head-Neck Surgery)</i>"
))

story.append(PageBreak())

# ── SECTION: PHARMACOLOGY QUICK-REF ──────────────────────────────────────────
story.extend(section("4.  PHARMACOLOGY QUICK REFERENCE", color=PURPLE))

pharm_data = [
    [Paragraph("Property", TH), Paragraph("Detail", TH)],
    [Paragraph("Class", TD), Paragraph("Synthetic fluorinated glucocorticoid", TD)],
    [Paragraph("Anti-inflammatory potency", TD), Paragraph("25-30x hydrocortisone (reference = 1)", TD)],
    [Paragraph("Mineralocorticoid activity", TD), Paragraph("NONE (no Na+/water retention)", TD)],
    [Paragraph("Plasma half-life", TD), Paragraph("~3-4 hours (IV)", TD)],
    [Paragraph("Biological half-life", TD), Paragraph("36-54 hours (long-acting)", TD)],
    [Paragraph("Onset (IV)", TD), Paragraph("1-2 hours (antiemetic effect); faster for anti-inflammatory", TD)],
    [Paragraph("Protein binding", TD), Paragraph("~77% (albumin)", TD)],
    [Paragraph("Metabolism", TD), Paragraph("Hepatic; renal excretion", TD)],
    [Paragraph("Available formulations", TD), Paragraph("IV/IM solution (4 mg/mL, 10 mg/mL); oral tablets 0.5, 0.75, 1, 1.5, 2, 4, 6 mg", TD)],
    [Paragraph("Equivalent dose", TD), Paragraph("0.75 mg dexamethasone = 5 mg prednisone = 20 mg hydrocortisone", TD)],
]
story.extend(two_col_table(pharm_data, col_w=[5*cm, W-5*cm]))

# ── SECTION: SIDE EFFECTS ─────────────────────────────────────────────────────
story.extend(section("5.  SIDE EFFECTS & CAUTIONS", color=HexColor("#B71C1C")))
story.extend(sub("Acute / Single-Dose (Perioperative)"))
story.append(bp("<b>Hyperglycaemia</b> - raised blood glucose at 24 h; monitor in diabetics and ICU patients"))
story.append(bp("<b>Perineal burning/irritation</b> - 50-70% with rapid IV bolus; dilute and give slowly"))
story.append(bp("Facial flushing - benign, transient"))
story.append(bp("Single 8 mg dose: <b>no increase in surgical site infection</b> (large RCT)"))
story.append(sp(0.15))
story.extend(sub("Concerns with Repeated / Chronic Use"))
story.append(bp("HPA axis suppression (less relevant for single perioperative dose)"))
story.append(bp("Impaired wound healing with multiple doses in already-compromised patients"))
story.append(bp("Immunosuppression - caution in active systemic infection"))
story.append(bp("Avoid in poorly controlled diabetes without glucose monitoring plan"))
story.append(sp(0.15))

story.extend(callout(
    "&#9989; <b>REASSURANCE:</b> For a <b>single perioperative dose</b> (4-10 mg), "
    "the evidence consistently shows NO increase in wound infection, anastomotic leak, "
    "or delayed healing in the general surgical population. The glycaemic rise is "
    "transient and manageable. Benefits outweigh risks in most patients.",
    bg=LGREEN, border=GREEN
))

# ── SECTION: CLINICAL PEARLS ─────────────────────────────────────────────────
story.extend(section("6.  CLINICAL PEARLS TO RETAIN", color=TEAL))

pearls = [
    ("&#9733; Give BEFORE incision",
     "Onset is 1-2 h. Dexamethasone given after induction is too late to prevent early PONV. "
     "Aim to give at or before start of anaesthesia."),
    ("&#9733; Dilute for IV push",
     "Always dilute in 50 mL NS and give over 10 min to avoid perineal irritation in 50-70% of patients."),
    ("&#9733; Dose matters for analgesia",
     "For PONV: 4-8 mg is sufficient. For analgesia: 0.11-0.2 mg/kg (higher). Best analgesic effect at 6.4-10 mg in abdominal surgery (meta-analysis)."),
    ("&#9733; Perineural adjuvant",
     "Adding 4-8 mg to a brachial plexus block extends analgesia by 50-100%. Dose-response seen at 1-4 mg; ceiling likely >4 mg. Effect may be systemic OR local."),
    ("&#9733; Combine antiemetics",
     "Dexa alone reduces PONV by ~26%. Combine with ondansetron for additive effect (~37% reduction together). For high-risk, add NK1 antagonist (aprepitant)."),
    ("&#9733; No mineralocorticoid",
     "Unlike hydrocortisone, dexamethasone has NO mineralocorticoid activity - no Na+ retention, no hypertension from this mechanism."),
    ("&#9733; Single dose = safe",
     "One perioperative dose of 8 mg does NOT increase surgical site infections (large RCT). Reassure patients and prescribers."),
    ("&#9733; Diabetics",
     "Still use dexamethasone - benefits are clear. Plan glucose monitoring for 24 h post-op and have an insulin sliding scale ready if needed."),
]

for icon_title, detail in pearls:
    pt = Table([[
        Paragraph(icon_title, S("ptitle", fontSize=9.5, textColor=TEAL, fontName="Helvetica-Bold", leading=13)),
        Paragraph(detail, BODY)
    ]], colWidths=[4.5*cm, W-4.5*cm])
    pt.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), LTEAL),
        ("TOPPADDING",   (0,0),(-1,-1), 6),
        ("BOTTOMPADDING",(0,0),(-1,-1), 6),
        ("LEFTPADDING",  (0,0),(-1,-1), 8),
        ("BOX",          (0,0),(-1,-1), 0.4, TEAL),
        ("VALIGN",       (0,0),(-1,-1), "TOP"),
        ("LINEAFTER",    (0,0),(0,-1),  1,   TEAL),
    ]))
    story.append(KeepTogether([pt, sp(0.12)]))

story.append(sp(0.3))

# ── SOURCES ───────────────────────────────────────────────────────────────────
story.extend(section("SOURCES", color=HexColor("#37474F")))
refs = [
    "Morgan &amp; Mikhail's Clinical Anesthesiology, 7th Edition (2023). "
    "Chapter 17: Postoperative Nausea &amp; Vomiting. pp. 513-519. "
    "(Includes SAMBA/PONV consensus guidelines 2020 - Gan TJ et al, Anesth Analg 2020;131:411-448.)",
    
    "Miller's Anesthesia, 2-Volume Set, 10th Edition (2023). "
    "Chapter 68: Dexamethasone as analgesic / PONV management. pp. 10025-10026. "
    "[Key data: meta-analysis of single-dose dexa in abdominal surgery; 8 mg RCT - no SSI increase]",
    
    "Barash, Cullen, and Stoelting's Clinical Anesthesia, 9th Edition (2023). "
    "Chapter 22: Steroids as regional anaesthesia adjuvants, pp. 1693-1695. "
    "Chapter 55: Dexamethasone in multimodal analgesia (dose 0.11-0.2 mg/kg; perineal irritation warning). "
    "[Perineural dexa extends brachial plexus/sciatic/saphenous block duration by 50-100%]",
    
    "Sabiston Textbook of Surgery, 21st Edition (2022). "
    "Chapter on Postoperative Nausea and Vomiting. "
    "[Cochrane review: aprepitant, ramosetron, granisetron, dexamethasone, ondansetron reduce POV]",
    
    "Current Surgical Therapy, 14th Edition (2023). "
    "ERAS Pathway - Nausea and Vomiting Prophylaxis. "
    "[Recommends PONV prophylaxis as standard within ERAS protocols]",
    
    "Scott-Brown's Otorhinolaryngology, Head &amp; Neck Surgery (2018). "
    "Single-Stage Reconstruction. "
    "[Dexamethasone 0.5 mg/kg the night before extubation for laryngeal oedema prevention]",
    
    "Washington Manual of Medical Therapeutics. Glucocorticoids - Potency Comparison Table. "
    "[Dexamethasone anti-inflammatory potency 25-30; equivalent dose 0.75 mg = 20 mg hydrocortisone]",
]
for i, r in enumerate(refs, 1):
    story.append(Paragraph(f"[{i}]  {r}", REF_S))
    story.append(sp(0.1))

story.append(sp(0.4))
story.append(HRFlowable(width=W, thickness=0.5, color=RULE))
story.append(sp(0.15))
story.append(Paragraph(
    "Orris Medical Intelligence · Dexamethasone in Anaesthesia Notes · August 2026 · "
    "For educational use only - clinical decisions require individual patient assessment and current guidelines.",
    FOOT
))

# ── Build ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"Saved: {OUTPUT}")
Running Command

cd /tmp/workspace/hydrocortisone-pdf && python build_dexa_note.py 2>&1

Your notes PDF is ready:

Dexamethasone in Anaesthesia Notes

PDF Document · PDF


Here's what's packed in the note - designed for quick reading and retention:
Style: Color-coded sections (purple = core pharmacology, teal = clinical use, amber = warnings, green = reassurance, red = cautions). Every key fact is in a colored callout box so your eye catches it first.
What's covered:
★ Why Dexamethasone? - One-glance potency comparison table (Hydrocortisone 1 : Dexa 25-30), zero mineralocorticoid activity, 3 roles in anaesthesia
★ Mechanism - GR-alpha → NF-κB suppression → PLA2/COX/lipoxygenase inhibition, plus the specific mechanism for each anaesthetic use
★ PONV (Section 1) - Apfel score table with % risk, dosing table (4-8 mg IV at induction), drug class summary, 4th SAMBA 2020 guideline reminder (2 agents for 1-2 risk factors)
★ Analgesia (Section 2) - 0.11-0.2 mg/kg dose, meta-analysis findings, the perineal burning warning (50-70% with rapid bolus → dilute in 50 mL NS over 10 min)
★ Regional Blocks (Section 3) - Extends brachial plexus/sciatic/saphenous block by 50-100%, dose-response 1-4 mg with ceiling >4 mg, perineural vs IV debate
★ Pharmacology Quick-Ref - Full table: t½, onset, protein binding, formulations, equivalent dosing
★ 8 Retention Pearls - Each in a teal strip: timing, dilution, dose matters, perineural use, combination antiemetics, no mineralocorticoid, single dose safety, diabetics
★ 7 Cited Sources - Morgan & Mikhail 7e, Miller's 10e, Barash 9e, Sabiston, Current Surgical Therapy, Scott-Brown's, Washington Manual

If i give you few pdf and notes can you make it more readable without changing content

Yes, absolutely! Just upload your PDFs and notes and I'll:
  • Extract all the content exactly as-is (no changes to facts, data, or wording)
  • Reformat it into a clean, well-structured, readable layout - proper headings, color-coded sections, tables where lists exist, callout boxes for key facts, clear visual hierarchy
  • Output a polished PDF you can study from
A few things that help me do a better job - feel free to answer or just upload and I'll figure it out:
  1. What type of content is it? (e.g. lecture notes, textbook excerpts, handwritten scans, slides)
  2. How many files / how long approximately? (so I know whether to merge into one PDF or keep separate)
  3. Any preference on style? - like the purple/teal note style from the Dexamethasone PDF, or something different (e.g. lighter, more minimal, A4 exam-note style)
Go ahead and upload whenever you're ready!
attachment
attachment

Like this but a bit fetter type

analyse_media
Writing File

~/hydrocortisone-pdf/build_periop_pain_notes.py

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib.colors import HexColor, white, black
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_LEFT, TA_JUSTIFY, TA_CENTER
from reportlab.lib import colors

OUTPUT = "/tmp/workspace/hydrocortisone-pdf/Periop_Pain_Management_Notes.pdf"

# ── Palette (matching the original green-highlight style, fatter fonts) ──────
GREEN_H  = HexColor("#4CAF50")   # green highlight for main headings
LGREEN   = HexColor("#E8F5E9")   # light green bg
TEAL     = HexColor("#00695C")   # teal for sub-headings
LTEAL    = HexColor("#E0F2F1")
YELLOW   = HexColor("#FFF9C4")   # yellow highlight (inline)
AMBER    = HexColor("#F9A825")
LAMBER   = HexColor("#FFFDE7")
BLUE     = HexColor("#1565C0")
LBLUE    = HexColor("#E3F2FD")
DKGREY   = HexColor("#1A1A1A")
MIDGREY  = HexColor("#444444")
RULE     = HexColor("#CCCCCC")
WHITE    = white

W = 17.4 * cm

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    leftMargin=1.8*cm, rightMargin=1.8*cm,
    topMargin=2*cm, bottomMargin=1.8*cm,
    title="Perioperative Pain Management – MD Anaesthesia Notes",
    author="Orris Medical",
)

# ── STYLES (fatter = larger font sizes) ──────────────────────────────────────
def S(name, **kw):
    return ParagraphStyle(name, **kw)

# Main section heading (GREEN background strip)
SEC   = S("Sec",  fontSize=13, textColor=white,    fontName="Helvetica-Bold",  leading=18)
# Sub-heading (no bg, teal bold)
SUB   = S("Sub",  fontSize=12, textColor=TEAL,     fontName="Helvetica-Bold",  leading=16, spaceBefore=6)
# Body text — FATTER (was ~9-10, now 11.5)
BODY  = S("Body", fontSize=11.5, textColor=DKGREY, fontName="Helvetica",       leading=17, spaceBefore=4, alignment=TA_JUSTIFY)
# Bullet — same size
BUL   = S("Bul",  fontSize=11.5, textColor=DKGREY, fontName="Helvetica",       leading=17, spaceBefore=3, leftIndent=14)
# Key bold inline label
KEY   = S("Key",  fontSize=11.5, textColor=DKGREY, fontName="Helvetica-Bold",  leading=17, spaceBefore=4)
# Citation / italic source
CIT   = S("Cit",  fontSize=10,   textColor=MIDGREY, fontName="Helvetica-Oblique", leading=14, spaceBefore=4)
# Table header
TH    = S("TH",   fontSize=10.5, textColor=white,  fontName="Helvetica-Bold",  alignment=TA_CENTER, leading=14)
# Table cell
TD    = S("TD",   fontSize=10.5, textColor=DKGREY, fontName="Helvetica",       leading=14)
TDC   = S("TDC",  fontSize=10.5, textColor=DKGREY, fontName="Helvetica",       alignment=TA_CENTER, leading=14)
FOOT  = S("Foot", fontSize=8.5,  textColor=HexColor("#888888"), fontName="Helvetica", alignment=TA_CENTER)
PAGE_TITLE = S("PT", fontSize=20, textColor=DKGREY, fontName="Helvetica-Bold", alignment=TA_LEFT, leading=26, spaceBefore=0)
PAGE_SUB   = S("PS", fontSize=13, textColor=TEAL,   fontName="Helvetica-Bold", alignment=TA_LEFT, leading=18)

def sp(n=0.25): return Spacer(1, n * cm)

# ── Section banner ────────────────────────────────────────────────────────────
def section(text, color=GREEN_H):
    t = Table([[Paragraph(text, SEC)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0),(-1,-1), color),
        ("TOPPADDING",    (0,0),(-1,-1), 8),
        ("BOTTOMPADDING", (0,0),(-1,-1), 8),
        ("LEFTPADDING",   (0,0),(-1,-1), 10),
    ]))
    return [sp(0.35), t, sp(0.2)]

def sub(text):
    return [Paragraph(text, SUB),
            HRFlowable(width=W, thickness=0.8, color=TEAL, spaceAfter=4)]

def bp(txt): return Paragraph(f"&#9632;  {txt}", BUL)
def body(txt): return Paragraph(txt, BODY)
def key(label, txt): return Paragraph(f"<b>{label}</b> {txt}", BODY)
def cite(txt): return Paragraph(f"<i>{txt}</i>", CIT)

def callout(text, bg=LGREEN, border=GREEN_H):
    t = Table([[Paragraph(text, BODY)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0),(-1,-1), bg),
        ("BOX",           (0,0),(-1,-1), 1, border),
        ("LEFTPADDING",   (0,0),(-1,-1), 10),
        ("RIGHTPADDING",  (0,0),(-1,-1), 8),
        ("TOPPADDING",    (0,0),(-1,-1), 8),
        ("BOTTOMPADDING", (0,0),(-1,-1), 8),
    ]))
    return [t, sp(0.15)]

# ══════════════════════════════════════════════════════════════════════════════
story = []

# ── PAGE TITLE ────────────────────────────────────────────────────────────────
story.append(Paragraph("POSTOPERATIVE PAIN MANAGEMENT", PAGE_TITLE))
story.append(Paragraph("MD ANAESTHESIA", PAGE_SUB))
story.append(sp(0.1))
story.append(HRFlowable(width=W, thickness=2, color=GREEN_H, spaceAfter=6))
story.append(sp(0.15))

# ══════════════════════════════════════════════════════════════════════════════
# INTRODUCTION
# ══════════════════════════════════════════════════════════════════════════════
story.extend(section("INTRODUCTION"))

story.append(body(
    'Postoperative pain management is one of the most important responsibilities of '
    'the anaesthesiologist. Pain is now recognised as the <b>"fifth vital sign"</b> '
    'and must be periodically assessed, documented, and treated throughout recovery.'
))
story.append(sp(0.2))

story.extend(sub("Goals of Postoperative Analgesia"))
story.append(bp("Improve patient comfort and satisfaction"))
story.append(bp("Reduce <b>sympathetic nervous system</b> activation (hypertension, tachycardia, dysrhythmias)"))
story.append(bp("Enable <b>early mobilisation and rehabilitation</b>"))
story.append(bp("Prevent <b>pulmonary, cardiovascular, and thromboembolic complications</b>"))
story.append(bp("Reduce <b>postoperative ileus</b>"))
story.append(bp("Prevent <b>transition</b> from acute to chronic pain"))
story.append(bp("Reduce <b>hospital length</b> of stay"))
story.append(sp(0.15))
story.append(cite("(Barash, 9e; Miller's Anesthesia, 10e)"))

# ══════════════════════════════════════════════════════════════════════════════
# NEUROBIOLOGY
# ══════════════════════════════════════════════════════════════════════════════
story.extend(section("NEUROBIOLOGY OF POSTOPERATIVE PAIN"))

story.append(body(
    "Understanding the pathophysiology is essential for targeting analgesia rationally."
))
story.append(sp(0.2))

story.extend(sub("Pathway"))

pathway_data = [
    [Paragraph("Step", TH), Paragraph("Process", TH)],
    [Paragraph("1", TDC),
     Paragraph("Surgery &#8594; tissue injury &#8594; release of <b>inflammatory mediators</b> "
               "(histamine, bradykinin, prostaglandins, serotonin, nerve growth factor)", TD)],
    [Paragraph("2", TDC),
     Paragraph("Activation of <b>peripheral nociceptors</b> &#8594; initiate <b>transduction and "
               "transmission</b> via <b>A&#948; and C fibres</b> &#8594; neurogenic inflammation "
               "(substance P, CGRP &#8594; vasodilatation, plasma extravasation)", TD)],
    [Paragraph("3", TDC),
     Paragraph("Signals reach <b>dorsal horn of spinal cord</b> &#8594; integration of peripheral "
               "nociceptive and descending modulatory input (serotonin, norepinephrine, GABA, enkephalin)", TD)],
    [Paragraph("4", TDC),
     Paragraph("<b>Segmental reflex responses:</b> increased skeletal muscle tone, inhibition of "
               "phrenic nerve, decreased GI motility", TD)],
    [Paragraph("5", TDC),
     Paragraph("<b>Spinothalamic and spinoreticular tracts</b> &#8594; supraspinal and cortical pain perception", TD)],
]
pt = Table(pathway_data, colWidths=[1.5*cm, W-1.5*cm])
pt.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), TEAL),
    ("ROWBACKGROUNDS",(0,1),(-1,-1), [LTEAL, WHITE, LTEAL, WHITE, LTEAL]),
    ("GRID",          (0,0),(-1,-1), 0.3, RULE),
    ("TOPPADDING",    (0,0),(-1,-1), 7),
    ("BOTTOMPADDING", (0,0),(-1,-1), 7),
    ("LEFTPADDING",   (0,0),(-1,-1), 8),
    ("VALIGN",        (0,0),(-1,-1), "TOP"),
    ("ALIGN",         (0,0),(0,-1), "CENTER"),
]))
story.append(pt)
story.append(sp(0.25))

story.extend(sub("Sensitisation"))

story.extend(callout(
    "<b>Peripheral sensitisation:</b>  Decreased threshold, increased discharge rate, "
    "spontaneous basal firing of nociceptors.",
    bg=LGREEN, border=GREEN_H
))

story.extend(callout(
    "<b>Central sensitisation:</b>  Persistent post-injury changes in the CNS that result in "
    "<b>pain hypersensitivity</b> — exaggerated responses in dorsal horn; "
    "<b>NMDA</b> receptors especially important.",
    bg=LBLUE, border=BLUE
))

story.extend(callout(
    "<b>Key clinical implication:</b>  The intensity of acute postoperative pain is a "
    "<b>significant predictor of chronic postoperative pain</b> — inadequately treated acute pain "
    "promotes central sensitisation and transition to chronic pain.",
    bg=LAMBER, border=AMBER
))
story.append(cite("(Miller's Anesthesia, 10e, p. 11687-11688)"))

# ══════════════════════════════════════════════════════════════════════════════
# ASSESSMENT
# ══════════════════════════════════════════════════════════════════════════════
story.extend(section("ASSESSMENT OF POSTOPERATIVE PAIN"))

story.append(bp("Use a <b>numeric pain scale</b> (NRS 0-10) or <b>visual analogue scale (VAS)</b>"))
story.append(bp("The Joint Commission mandates pain scoring with periodic documentation"))
story.append(bp("<b>Best measure = patient's own perception</b> (not HR, RR, or sweating alone)"))
story.append(bp("<b>Pain intensity</b> varies widely by surgery type, anaesthetic technique, and patient psychology"))
story.append(bp("Staff frequently misjudge pain: inexperienced nurses overestimate; experienced nurses tend to underestimate"))
story.append(bp("Distinguish <b>rest pain</b> from <b>dynamic (movement-related) pain</b> — dynamic pain is functionally more important"))

story.append(sp(0.3))
story.append(HRFlowable(width=W, thickness=0.5, color=RULE))
story.append(sp(0.2))
story.append(Paragraph(
    "Orris Medical Intelligence  ·  Perioperative Pain Management Notes  ·  "
    "Content sourced from original notes (Barash 9e; Miller's 10e)  ·  August 2026",
    FOOT
))

doc.build(story)
print(f"Saved: {OUTPUT}")
Running Command

cd /tmp/workspace/hydrocortisone-pdf && python build_periop_pain_notes.py 2>&1

Here you go:

Periop Pain Management Notes

PDF Document · PDF


What I kept exactly the same from your original:
  • Every word, sentence, and bullet point - zero content changes
  • All source citations in italics at the bottom of each section
  • Same section order: Introduction → Goals → Neurobiology → Pathway → Sensitisation → Assessment
What's improved:
  • Font size bumped from ~9-10pt to 11.5pt (body) and 12-13pt (headings) - much easier to read
  • Green banner headings (matching your green highlighted style)
  • Pathway converted to a numbered table instead of inline text - each step is clearly separated
  • Three callout boxes for Peripheral sensitisation, Central sensitisation, and Key clinical implication - each in a distinct colour so they stand out instantly
  • Teal subheadings with a rule line underneath
  • Cleaner spacing between sections
To use this for your other PDFs/notes - just share the files and I'll extract the content and reformat each one in this same style.
This is a shared conversation. Sign in to Orris to start your own chat.