Type 2 diabetes pharmacology and management according to recent guidelines

Reading File
Finding Sources
Searching PubMed

"type 2 diabetes" AND "management guidelines"

Searching the Web

ADA 2025 2026 type 2 diabetes guidelines pharmacology management update

Reading File
Finding Sources
Reading Web Page

https://pmc.ncbi.nlm.nih.gov/articles/PMC12690167

Finding Sources
Finding Sources
Searching PubMed

"GLP-1 receptor agonist" AND "SGLT2 inhibitor" AND "type 2 diabetes" AND cardiovascular

Reading File
Reading File
I now have comprehensive material. Let me compile the full, detailed answer.

Type 2 Diabetes Mellitus: Pharmacology & Management (ADA 2026 Standards)

Overview

Type 2 diabetes (T2DM) is a progressive, multifactorial disease driven by insulin resistance and declining beta-cell function. Management now extends far beyond glycemic control - the 2026 ADA Standards of Care represent a philosophical shift toward disease modification and cardiorenal protection from the point of diagnosis.

Goals of Therapy

  1. Achieve individualized glycemic targets (HbA1c typically <7% for most adults; less stringent [<8%] for elderly, frail, or those with limited life expectancy)
  2. Prevent cardiovascular disease (CVD), heart failure (HF), and chronic kidney disease (CKD)
  3. Promote weight loss where relevant
  4. Prevent microvascular complications (retinopathy, nephropathy, neuropathy)
  5. Encourage lifestyle modification throughout

Stepwise Management Framework (ADA 2026)

Step 1: Lifestyle Modification (All Patients)

  • Medical nutrition therapy: low-glycemic index diet, caloric restriction in obesity
  • Physical activity: 150 min/week moderate-intensity aerobic exercise + resistance training
  • Weight loss of 5-10% improves glycemia, BP, and lipids
  • Self-monitoring of blood glucose (SMBG) or continuous glucose monitoring (CGM)
  • 2026 update: CGM is now recommended soon after diagnosis for most patients with T2DM on insulin; AID (automated insulin delivery) systems are recommended for those on insulin

Step 2: First-Line Pharmacotherapy (at or near Diagnosis)

A. Metformin - The Biguanide Foundation

Mechanism: Primarily reduces hepatic gluconeogenesis via AMPK activation (inhibition of mitochondrial complex I); also slows intestinal glucose absorption and improves peripheral insulin sensitivity.
  • HbA1c reduction: ~1-2%
  • Weight: neutral/modest loss
  • Advantages: inexpensive, long safety record, no hypoglycemia, possible CV benefit
  • Contraindications: eGFR <30 mL/min, iodinated contrast (hold temporarily), acute illness with dehydration risk
  • Key ADR: GI intolerance (nausea, diarrhea - minimize with food); lactic acidosis (rare)
"The biguanide metformin is the preferred initial agent for type 2 diabetes. The primary mechanism of action of metformin is reduced hepatic gluconeogenesis." - Lippincott Illustrated Reviews: Pharmacology
2026 update: Metformin remains a core agent, but GLP-1 RAs and SGLT2 inhibitors can now be initiated simultaneously at diagnosis, not just added later.

Step 3: Disease-Modifying Agents (2026: Use Early, Regardless of HbA1c)

B. GLP-1 Receptor Agonists (GLP-1 RAs)

Drugs: Semaglutide (oral/SC), dulaglutide, liraglutide, exenatide, lixisenatide, tirzepatide (dual GIP/GLP-1)
Mechanism: Mimic incretin effect - stimulate glucose-dependent insulin secretion, suppress glucagon, delay gastric emptying, increase satiety. The gut releases GLP-1 and GIP in response to meals, accounting for 60-70% of postprandial insulin secretion (reduced in T2DM). GLP-1 RAs restore this response.
PropertyDetail
HbA1c reduction1-1.5% (semaglutide up to 1.8%)
WeightSignificant loss (3-5 kg with liraglutide; >10% with high-dose semaglutide/tirzepatide)
CV benefitReduced MACE in patients with established CVD (LEADER, SUSTAIN-6, REWIND trials)
RenalReduced albuminuria; GLP-1 RAs can now be continued in advanced CKD (ADA 2026 Rec 9.11)
ADRsNausea, vomiting, diarrhea (dose-dependent; improves over time); pancreatitis (rare); thyroid C-cell tumors (contraindicated with personal/family history of MTC or MEN2)
2026 Key Updates:
  • GLP-1 RAs and dual GIP/GLP-1 agonists (tirzepatide) are now recommended for T2DM with HFpEF (Rec 9.9a/9.9b)
  • Preferred for T2DM + MASLD/MASH (metabolic fatty liver disease) - semaglutide demonstrated histologic benefit
  • Tirzepatide (dual GIP/GLP-1) recommended for T2DM + MASH or at risk for liver fibrosis (Rec 9.12/9.13)
  • Earlier, broader initiation recommended from diagnosis as disease-modifying therapy

C. SGLT2 Inhibitors

Drugs: Empagliflozin (Jardiance), dapagliflozin (Farxiga), canagliflozin (Invokana), ertugliflozin (Steglatro)
Mechanism: Inhibit SGLT2 in renal proximal tubule, which accounts for ~90% of glucose reabsorption. Lowers renal glucose threshold from ~180 mg/dL to ~40 mg/dL, causing glycosuria and caloric loss.
PropertyDetail
HbA1c reduction0.5-1%
Weight loss2-5 kg
BP~3-4 mmHg systolic reduction
HFConsistently reduced HF hospitalizations (HFrEF and HFpEF)
RenalSlows CKD progression; now usable down to eGFR 20-25 for cardiorenal benefit
ADRsUrinary tract infections, genital mycotic infections (Fournier's gangrene rare), volume depletion, DKA (euglycemic DKA, rare in T2DM), lower limb amputation risk (canagliflozin)
2026 Key Updates:
  • Positioned as coequal priorities alongside glucose lowering for CV/renal risk reduction
  • New Rec 11.9: Simultaneous initiation of SGLT2 inhibitor + nsMRA (finerenone) can be considered in T2DM with urine ACR ≥100 mg/g and eGFR 30-90 mL/1.73m² on RAS inhibitor
  • Finerenone (non-steroidal mineralocorticoid receptor antagonist) received new recognition for favorable HF outcomes in T2DM
  • BP target updated: new encouragement to achieve SBP <120 mmHg where feasible

Additional Drug Classes

D. DPP-4 Inhibitors (Gliptins)

Drugs: Sitagliptin, linagliptin, saxagliptin, alogliptin, vildagliptin
Mechanism: Inhibit DPP-4 enzyme that degrades native GLP-1 and GIP, prolonging their incretin effect.
  • HbA1c reduction: 0.4-0.8%
  • Weight: neutral
  • Hypoglycemia: minimal (glucose-dependent)
  • Renally dosed (except linagliptin, which is biliary excreted)
  • ADRs: nasopharyngitis, rare pancreatitis; saxagliptin/alogliptin associated with slightly increased HF risk - FDA warning
  • Cardioneutral (not disease-modifying)

E. Sulfonylureas

Drugs: Glipizide, glimepiride, glyburide
Mechanism: Close K⁺-ATP channels on beta cells → membrane depolarization → Ca²⁺ influx → insulin secretion (glucose-independent)
  • HbA1c reduction: 1-1.5%
  • Weight: gain (1-4 kg)
  • Hypoglycemia: significant risk, especially glyburide in elderly
  • No CV benefit; some evidence of CV harm with older agents
  • Now considered second-line when cost is a barrier; de-emphasized by ADA 2026

F. Thiazolidinediones (TZDs)

Drugs: Pioglitazone (preferred); rosiglitazone (restricted)
Mechanism: PPAR-γ agonists → increase insulin sensitivity in adipose, muscle, and liver
  • HbA1c reduction: 0.5-1.4%
  • Weight: gain (water retention + fat redistribution)
  • Benefits: pioglitazone reduces MACE (PROactive trial); beneficial in MASH/NAFLD
  • ADRs: edema, HF exacerbation (contraindicated in NYHA III/IV HF), bladder cancer risk (pioglitazone, long-term), fractures (especially women)
  • Role: still useful in T2DM + MASH (ADA 2026 Rec 9.13)

G. Alpha-Glucosidase Inhibitors

Drugs: Acarbose, miglitol
Mechanism: Inhibit intestinal alpha-glucosidases → delay carbohydrate absorption → blunt postprandial glucose spikes
  • HbA1c reduction: 0.5-0.8%
  • ADRs: flatulence, diarrhea, abdominal cramping (limits use)
  • Weight: neutral
  • Rarely used in clinical practice in the West

H. Meglitinides

Drugs: Repaglinide, nateglinide
Mechanism: Same as sulfonylureas (K⁺-ATP channel closure) but shorter duration → meal-time use only
  • Useful in patients with irregular meal patterns
  • Higher risk of weight gain and hypoglycemia than DPP-4 inhibitors

Insulin Therapy in T2DM

Indicated when HbA1c remains uncontrolled on oral agents, symptomatic hyperglycemia, or HbA1c >10% at presentation.
TypeExamplesOnset/Duration
Rapid-actingLispro, aspart, glulisine15 min / 3-5 hr
Short-acting (regular)Regular insulin30-60 min / 6-10 hr
IntermediateNPH2-4 hr / 12-18 hr
Long-actingGlargine, detemir, degludec1-2 hr / 20-42 hr
Ultra-longDegludec>42 hr, very flat profile
Strategy:
  • Start with basal insulin (e.g., glargine 10 units at bedtime, titrate by 2 units every 3 days)
  • Add prandial insulin if postprandial glucose uncontrolled (basal-bolus regimen)
  • GLP-1 RA + basal insulin combinations (e.g., IDegLira, iGlarLixi) reduce hypoglycemia and weight gain
2026 Update: AID systems are now recommended as preferred insulin delivery for T2DM patients on insulin who are willing and able to use them.

Cardiovascular & Cardiorenal Risk Reduction (2026 Core Principles)

The 2026 ADA Standards explicitly reposition CV and kidney risk reduction as coequal priorities alongside glucose lowering. Key principles:
ComorbidityPreferred Agent(s)
Established ASCVDGLP-1 RA with proven CV benefit (liraglutide, semaglutide, dulaglutide) or SGLT2i
HF (HFrEF or HFpEF)SGLT2i (first choice); tirzepatide or GLP-1 RA for HFpEF
CKD (eGFR 20-90)SGLT2i + RAS inhibitor ± finerenone; GLP-1 RA for additional CV/metabolic benefit
Obesity + T2DMGLP-1 RA or dual GIP/GLP-1 (tirzepatide) - most potent for weight loss
MASLD/MASHSemaglutide (preferred GLP-1 RA); pioglitazone or tirzepatide as alternatives
High hypoglycemia riskDPP-4i, GLP-1 RA, SGLT2i (avoid sulfonylureas)

Summary: Drug Properties Comparison

Drug ClassHbA1c ↓WeightHypo RiskCV BenefitCost
Metformin1-2%NeutralNonePossibleLow
GLP-1 RA1-1.8%↓↓NoneYes (MACE)High
SGLT2i0.5-1%NoneYes (HF/CKD)High
DPP-4i0.4-0.8%NeutralMinimalNeutralModerate
Sulfonylurea1-1.5%SignificantNeutral/↓Low
TZD0.5-1.4%NonePioglitazone: modestLow
InsulinVariableYesNeutralVariable

Monitoring Targets

ParameterTarget
HbA1c<7% (most adults); <8% (elderly/frail)
Fasting glucose80-130 mg/dL
2-hr postprandial<180 mg/dL
Blood pressure<130/80 mmHg; SBP <120 where feasible (2026 update)
LDL cholesterol<70 mg/dL (high CV risk) or <55 mg/dL (very high risk)
ACR (urine)<30 mg/g (if elevated, initiate SGLT2i + RAS inhibitor)

Recent Evidence (PubMed)

  • Combination SGLT2i + GLP-1 RA (PMID: 41029853): 2025 meta-analysis confirms additive cardiovascular and renal benefits from dual combination vs. either agent alone
  • SGLT2i efficacy with/without GLP-1 RA (PMID: 38991584, Lancet Diabetes Endocrinol 2024): SGLT2i benefits on CV and renal outcomes consistent regardless of background GLP-1 RA use
  • AID systems in T2DM (PMID: 41940799, Diabetes Care 2026): Automated insulin delivery improves time-in-range and reduces HbA1c in T2DM

Key 2026 ADA Paradigm Shifts

  1. Earlier GLP-1 RA and SGLT2i use - consider from diagnosis, not just after metformin failure
  2. Holistic care framework - extends to fatty liver disease, cognitive function, and osteoarthritis
  3. HFpEF now has specific drug recommendations (tirzepatide/GLP-1 RA)
  4. Finerenone recognized for HF and CKD outcomes in T2DM
  5. Technology integration - CGM and AID systems encouraged broadly from early in T2DM course
  6. Personalized weight-loss dosing - most effective dose may not be the highest approved; individualize
  7. Simultaneous SGLT2i + nsMRA initiation now endorsed for CKD patients on RAS inhibitors
Sources: Lippincott Illustrated Reviews: Pharmacology, Katzung's Basic & Clinical Pharmacology 16e, Textbook of Family Medicine 9e, ADA Standards of Care in Diabetes 2026 (PMC12690167), Pharmacy Times ADA 2026 expert interviews

Create a quick reference PDF guide comparing all T2DM drugs, dosing, and monitoring parameters

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null && echo "---" && ls /home/daytona/skills/pdf/

Running Command

mkdir -p /home/daytona/workspace/t2dm-guide && python3 -c "import reportlab; print(reportlab.Version)"

Writing File

~/t2dm-guide/generate_pdf.py

from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
from reportlab.platypus import (
    SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer,
    HRFlowable, KeepTogether, PageBreak
)
from reportlab.graphics.shapes import Drawing, Rect, String
from reportlab.graphics import renderPDF
from reportlab.pdfbase import pdfmetrics
import datetime

OUTPUT = "/home/daytona/workspace/t2dm-guide/T2DM_Quick_Reference_Guide.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
NAVY      = colors.HexColor("#1A3A5C")
TEAL      = colors.HexColor("#0B7D8A")
TEAL_LIGHT= colors.HexColor("#E0F4F6")
ORANGE    = colors.HexColor("#E8621A")
ORANGE_LT = colors.HexColor("#FEF0E8")
GREEN     = colors.HexColor("#1E7C45")
GREEN_LT  = colors.HexColor("#E5F5EC")
PURPLE    = colors.HexColor("#5A3E8E")
PURPLE_LT = colors.HexColor("#EDE8F8")
RED_LT    = colors.HexColor("#FDECEA")
RED       = colors.HexColor("#C0392B")
YELLOW_LT = colors.HexColor("#FEFAE0")
YELLOW    = colors.HexColor("#D4AC0D")
GREY_DARK = colors.HexColor("#2C3E50")
GREY_MID  = colors.HexColor("#7F8C8D")
GREY_LIGHT= colors.HexColor("#F2F4F4")
GREY_LINE = colors.HexColor("#D5D8DC")
WHITE     = colors.white
BLACK     = colors.black

# ── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, **kw)

TITLE_STYLE = S("title_s",
    fontName="Helvetica-Bold", fontSize=22, textColor=WHITE,
    alignment=TA_CENTER, spaceAfter=2)

SUBTITLE_STYLE = S("sub_s",
    fontName="Helvetica", fontSize=10, textColor=colors.HexColor("#BDC3C7"),
    alignment=TA_CENTER, spaceAfter=0)

SECTION_STYLE = S("section_s",
    fontName="Helvetica-Bold", fontSize=12, textColor=WHITE,
    alignment=TA_LEFT, spaceBefore=4, spaceAfter=4,
    leftIndent=8)

BODY = S("body_s",
    fontName="Helvetica", fontSize=7.5, textColor=GREY_DARK,
    leading=10, alignment=TA_LEFT)

BODY_BOLD = S("body_bold",
    fontName="Helvetica-Bold", fontSize=7.5, textColor=GREY_DARK,
    leading=10, alignment=TA_LEFT)

CELL = S("cell_s",
    fontName="Helvetica", fontSize=7, textColor=GREY_DARK,
    leading=9, alignment=TA_LEFT)

CELL_BOLD = S("cell_bold",
    fontName="Helvetica-Bold", fontSize=7, textColor=GREY_DARK,
    leading=9, alignment=TA_LEFT)

CELL_CENTER = S("cell_center",
    fontName="Helvetica", fontSize=7, textColor=GREY_DARK,
    leading=9, alignment=TA_CENTER)

CELL_BOLD_CENTER = S("cell_bold_c",
    fontName="Helvetica-Bold", fontSize=7.2, textColor=WHITE,
    leading=9, alignment=TA_CENTER)

NOTE_STYLE = S("note_s",
    fontName="Helvetica-Oblique", fontSize=6.5, textColor=GREY_MID,
    leading=8, alignment=TA_LEFT)

FOOTNOTE = S("footnote",
    fontName="Helvetica", fontSize=6, textColor=GREY_MID,
    leading=7.5, alignment=TA_LEFT)

# ── Helper: coloured section header bar ─────────────────────────────────────
def section_header(text, bg=NAVY, width=None):
    return Table(
        [[Paragraph(text, SECTION_STYLE)]],
        colWidths=[width or 260*mm],
        style=TableStyle([
            ("BACKGROUND", (0,0), (-1,-1), bg),
            ("TOPPADDING",    (0,0), (-1,-1), 5),
            ("BOTTOMPADDING", (0,0), (-1,-1), 5),
            ("LEFTPADDING",   (0,0), (-1,-1), 8),
            ("RIGHTPADDING",  (0,0), (-1,-1), 8),
            ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
        ])
    )

def badge(text, bg, fg=WHITE, width=30*mm):
    style = S("badge", fontName="Helvetica-Bold", fontSize=6.5,
              textColor=fg, alignment=TA_CENTER, leading=8)
    return Table([[Paragraph(text, style)]],
        colWidths=[width],
        style=TableStyle([
            ("BACKGROUND", (0,0), (-1,-1), bg),
            ("TOPPADDING",    (0,0), (-1,-1), 2),
            ("BOTTOMPADDING", (0,0), (-1,-1), 2),
            ("LEFTPADDING",   (0,0), (-1,-1), 3),
            ("RIGHTPADDING",  (0,0), (-1,-1), 3),
            ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
            ("BOX", (0,0), (-1,-1), 0.3, bg),
        ])
    )

# ── Document setup (landscape A4) ──────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=landscape(A4),
    leftMargin=12*mm, rightMargin=12*mm,
    topMargin=12*mm, bottomMargin=14*mm,
    title="T2DM Quick Reference Guide",
    author="Orris Medical Reference",
    subject="Type 2 Diabetes Mellitus – Drug Comparison & Monitoring"
)

W, H = landscape(A4)
PAGE_W = W - 24*mm   # usable width

story = []

# ══════════════════════════════════════════════════════════════════════════════
# HEADER BANNER
# ══════════════════════════════════════════════════════════════════════════════
banner_data = [[
    Paragraph("TYPE 2 DIABETES MELLITUS", TITLE_STYLE),
    Paragraph("Quick Reference Guide — Drugs, Dosing &amp; Monitoring  |  Based on ADA 2026 Standards of Care", SUBTITLE_STYLE),
]]
banner = Table(banner_data, colWidths=[PAGE_W],
    style=TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), NAVY),
        ("TOPPADDING",    (0,0), (-1,-1), 12),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("RIGHTPADDING",  (0,0), (-1,-1), 12),
        ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
        ("SPAN", (0,0), (-1,-1)),
    ])
)
story.append(banner)
story.append(Spacer(1, 4*mm))

# ══════════════════════════════════════════════════════════════════════════════
# SECTION 1 – MAIN DRUG COMPARISON TABLE
# ══════════════════════════════════════════════════════════════════════════════
story.append(section_header("① DRUG CLASS COMPARISON — MECHANISMS, DOSING & KEY PROPERTIES", TEAL, PAGE_W))
story.append(Spacer(1, 2*mm))

COL_DRUG    = 38*mm
COL_MECH    = 50*mm
COL_DOSE    = 46*mm
COL_HBA1C   = 18*mm
COL_WT      = 16*mm
COL_HYPO    = 14*mm
COL_CV      = 22*mm
COL_RENAL   = 22*mm
COL_ADR     = 40*mm
TOTAL = COL_DRUG+COL_MECH+COL_DOSE+COL_HBA1C+COL_WT+COL_HYPO+COL_CV+COL_RENAL+COL_ADR

def H(t): return Paragraph(t, CELL_BOLD_CENTER)
def C(t, bold=False): return Paragraph(t, CELL_BOLD if bold else CELL)
def CC(t): return Paragraph(t, CELL_CENTER)

main_table_data = [
    # Header row
    [H("DRUG CLASS / Agents"), H("Mechanism of Action"), H("Typical Dosing"),
     H("HbA1c\nReduction"), H("Weight\nEffect"), H("Hypo\nRisk"),
     H("CV / Cardiac\nBenefit"), H("Renal\nConsiderations"), H("Key ADRs / Precautions")],

    # ── Metformin ──
    [C("BIGUANIDE\nMetformin\n(Glucophage)", bold=True),
     C("↓ Hepatic gluconeogenesis (AMPK activation); slows intestinal glucose absorption; improves peripheral insulin sensitivity"),
     C("500–1000 mg PO BID with meals\nMax: 2550 mg/day\nER: 500–2000 mg QD with evening meal"),
     CC("↓ 1–2%"),
     CC("Neutral /\nSlight ↓"),
     CC("None"),
     CC("Possible CV benefit (UKPDS);\nWeight neutral"),
     C("HOLD if eGFR <30\nUse caution 30–45\nHold before IV contrast"),
     C("GI (N/V/D) – dose with food\nLactic acidosis (rare, mainly eGFR<30)\nVit B12 depletion (monitor annually)")],

    # ── GLP-1 RA ──
    [C("GLP-1 RECEPTOR\nAGONISTS\nSemaglutide (Ozempic/Rybelsus)\nLiraglutide (Victoza)\nDulaglutide (Trulicity)\nExenatide (Byetta/Bydureon)\nTirzepatide* (Mounjaro)", bold=True),
     C("Mimic incretin effect: ↑ glucose-dependent insulin secretion, ↓ glucagon, delay gastric emptying, ↑ satiety. Tirzepatide: dual GIP+GLP-1 agonist"),
     C("Semaglutide SC: 0.25mg QW→1mg QW (up to 2mg)\nSemaglutide PO: 3mg QD→14mg QD\nLiraglutide: 0.6→1.2→1.8 mg SC QD\nDulaglutide: 0.75→1.5mg SC QW\nExenatide ER: 2mg SC QW\nTirzepatide: 2.5mg QW→max 15mg QW"),
     CC("↓ 1–1.8%\n(*Tirzepatide\nup to 2.4%)"),
     CC("↓↓\n(2–7 kg;\ntirzepatide\n>10%)"),
     CC("Minimal\n(glucose-\ndependent)"),
     C("✓ Proven MACE reduction (LEADER, SUSTAIN-6, REWIND, SOUL trials)\nBenefit in HFpEF (tirzepatide/sema)\n✓ Approved for weight loss"),
     C("No dose adjustment for most agents\nCan initiate/continue in advanced CKD (ADA 2026)\nExenatide avoid if eGFR <30"),
     C("N/V/D common at start (transient)\nPancreatitis (rare – monitor)\nThyroid C-cell tumors: CONTRAINDICATED in MEN2 / MTC hx\nInjection site reactions\nDelayed gastric emptying – drug interactions")],

    # ── SGLT2i ──
    [C("SGLT2 INHIBITORS\nEmpagliflozin (Jardiance)\nDapagliflozin (Farxiga)\nCanagliflozin (Invokana)\nErtugliflozin (Steglatro)", bold=True),
     C("Inhibit SGLT2 in proximal tubule → glycosuria (lowers glucose threshold 180→40 mg/dL); osmotic diuresis; ↓ renal sodium reabsorption"),
     C("Empagliflozin: 10–25 mg PO QD\nDapagliflozin: 10 mg PO QD\n  (5 mg if hepatic impairment)\nCanagliflozin: 100–300 mg PO QD\nErtugliflozin: 5–15 mg PO QD\n(All taken in AM before first meal)"),
     CC("↓ 0.5–1%"),
     CC("↓\n(2–5 kg)"),
     CC("Low"),
     C("✓ Reduced HF hospitalisations (HFrEF & HFpEF)\n✓ Slows CKD progression\nEmpagliflozin: ↓ CV mortality (EMPA-REG)\nDapa: DAPA-HF, DAPA-CKD"),
     C("eGFR 20–45: limited glycemic effect but cardioprotection preserved\nStop if eGFR <20 for glycemic use\nADA 2026: combine with finerenone (nsMRA) if ACR ≥100 & eGFR 30–90"),
     C("Genital mycotic infections ↑↑\nUTI ↑\nVolume depletion / hypotension\nEuglycemic DKA (rare in T2DM)\nFournier's gangrene (rare)\nCanagliflozin: ↑ amputation risk (lower limb)")],

    # ── DPP-4i ──
    [C("DPP-4 INHIBITORS\nSitagliptin (Januvia)\nLinagliptin (Tradjenta)\nSaxagliptin (Onglyza)\nAlogliptin (Nesina)\nVildagliptin (not in US)", bold=True),
     C("Inhibit DPP-4 enzyme → prevent degradation of endogenous GLP-1 & GIP → prolonged incretin effect → ↑ glucose-dependent insulin, ↓ glucagon"),
     C("Sitagliptin: 100 mg PO QD\n  (50 mg if eGFR 30–45; 25 mg if <30)\nLinagliptin: 5 mg PO QD\n  (NO renal dose adjustment – biliary)\nSaxagliptin: 2.5–5 mg PO QD\n  (2.5 mg if eGFR ≤50)\nAlogliptin: 25 mg PO QD\n  (renal dose if eGFR <60)"),
     CC("↓ 0.4–0.8%"),
     CC("Neutral"),
     CC("Minimal"),
     C("Cardioneutral overall\nSaxagliptin & alogliptin: possible ↑ HF hospitalization (use caution in HF)"),
     C("Linagliptin: safe in all CKD stages\nOthers: dose-reduce per eGFR\nSitagliptin safest in renal impairment after linagliptin"),
     C("Nasopharyngitis / URTI\nPancreatitis (rare)\nHypersensitivity: angioedema, SJS (rare)\nJoint pain (FDA warning – reversible)\nAlogliptin: rare hepatic failure")],

    # ── Sulfonylureas ──
    [C("SULFONYLUREAS\nGlimepiride (Amaryl)\nGlipizide (Glucotrol)\nGlyburide (DiaBeta)\n[2nd gen preferred]", bold=True),
     C("Close K⁺-ATP channels on pancreatic β cells → membrane depolarisation → Ca²⁺ influx → insulin secretion (GLUCOSE-INDEPENDENT – hence hypoglycemia risk)"),
     C("Glimepiride: 1–8 mg PO QD with breakfast\nGlipizide: 5–40 mg PO QD-BID (IR);\n  5–20 mg PO QD (XL)\nGlyburide: 1.25–20 mg PO QD-BID\n(Start low, titrate every 1–2 weeks)\n⚠ Avoid glyburide in elderly/CKD"),
     CC("↓ 1–1.5%"),
     CC("↑\n(1–4 kg)"),
     CC("SIGNIFICANT\n(glucose-\nindependent)"),
     C("No established CV benefit\nOlder agents: possible ↑ CV risk\nNow second-line/cost-driven choice"),
     C("Glipizide preferred in CKD\nGlyburide AVOID in eGFR <60 (active metabolites → hypoglycemia)\nGlimepiride: use caution if eGFR <60"),
     C("HYPOGLYCEMIA (main concern – prolonged with glyburide)\nWeight gain\nPhotodermatitis\nDisulfiram-like reaction (glyburide)\nBeta-cell exhaustion over time")],

    # ── TZDs ──
    [C("THIAZOLIDINEDIONES (TZDs)\nPioglitazone (Actos)\nRosiglitazone (Avandia)\n[Pioglitazone preferred]", bold=True),
     C("PPAR-γ agonists → ↑ transcription of insulin-responsive genes → ↑ peripheral insulin sensitivity in adipose, muscle, liver; ↓ hepatic glucose production"),
     C("Pioglitazone: 15–45 mg PO QD\n  (no food restriction)\nRosiglitazone: 4–8 mg PO QD/BID\n  (restricted use – CV concerns)\nFull effect takes 8–12 weeks"),
     CC("↓ 0.5–1.4%"),
     CC("↑\n(fluid +\nfat)"),
     CC("None"),
     C("Pioglitazone: modest ↓ MACE (PROactive trial)\nROSIGLITAZONE: ↑ MI risk (restricted/banned in some countries)\nPioglitazone beneficial in MASH/NAFLD (ADA 2026)"),
     C("No dose adjustment in CKD\nUse with caution if fluid retention concerns\nContraindicated: active/hx bladder cancer"),
     C("Edema / fluid retention ↑↑\nHF exacerbation (CONTRAINDICATED NYHA III-IV)\nWeight gain\nFractures ↑ (esp. women – distal)\nBladder cancer risk (pioglitazone – long term)\nMacular edema (rare)")],

    # ── Meglitinides ──
    [C("MEGLITINIDES\nRepaglinide (Prandin)\nNateglinide (Starlix)", bold=True),
     C("Close K⁺-ATP channels on β cells (same as SUs) but shorter duration of action → rapid, short-burst insulin release for meal coverage"),
     C("Repaglinide: 0.5–4 mg PO with each meal\n  (up to 3x/day with meals; skip dose if skipping meal)\nNateglinide: 60–120 mg PO TID with meals\n(Take 0–30 min before each meal)"),
     CC("↓ 0.5–1.5%"),
     CC("↑\n(modest)"),
     CC("Moderate\n(less than\nSUs)"),
     C("No proven CV benefit"),
     C("Repaglinide: can use in CKD (hepatic metabolism)\nNateglinide: caution in severe renal impairment"),
     C("Hypoglycemia (less than SUs; flexible dosing)\nWeight gain\nFlexible dosing for irregular meal schedules\nNot cost-effective vs SUs in most settings")],

    # ── Alpha-glucosidase ──
    [C("α-GLUCOSIDASE\nINHIBITORS\nAcarbose (Precose)\nMiglitol (Glyset)", bold=True),
     C("Inhibit intestinal alpha-glucosidases (maltase, sucrase, glucoamylase) → delayed CHO digestion & glucose absorption → ↓ postprandial glucose spikes"),
     C("Acarbose: 25 mg PO TID with first bite of meals → titrate to 50–100 mg TID over weeks\nMiglitol: 25–100 mg PO TID with meals\nMax: 100 mg TID\nStart low to minimize GI side effects"),
     CC("↓ 0.5–0.8%"),
     CC("Neutral"),
     CC("None"),
     C("No proven CV benefit\nMay offer modest benefit in IGT progression"),
     C("Avoid if eGFR <25 (acarbose)\nMiglitol: avoid in significant renal impairment"),
     C("GI: flatulence, bloating, diarrhea, abdominal cramps (often limits use)\nHypoglycemia: does not cause alone; if combined with SU/insulin use GLUCOSE (not sucrose) to treat\nLiver enzyme elevation (rare – high dose acarbose)")],

    # ── Insulin ──
    [C("INSULIN THERAPY\nRapid: Lispro, Aspart, Glulisine\nShort: Regular\nIntermediate: NPH\nLong-acting: Glargine, Detemir\nUltra-long: Degludec\nCombinations: IDegLira, iGlarLixi", bold=True),
     C("Replaces endogenous insulin: ↑ glucose uptake (muscle/adipose), ↓ hepatic glucose output, ↑ glycogen synthesis, ↓ lipolysis, ↓ glucagon"),
     C("Basal START: Glargine/Degludec 10 U SC QHS\n  Titrate: ↑2U q3 days until FBG 80–130\nRapid: 4U per meal (titrate)\nRule of 1500/1800 for correction dose\nRapid onset: 15 min before meal\nRegular: 30 min before meal\n2026: AID systems preferred if on insulin"),
     CC("Variable\n(1–3%+\ndepending\non dose)"),
     CC("↑↑\n(2–8 kg)"),
     CC("YES –\nSIGNIFICANT"),
     C("Neutral CV effect (ORIGIN trial)\nFlexible in all patients\nAID (automated insulin delivery) recommended by ADA 2026"),
     C("Dose not restricted by renal function per se\nBut hypoglycemia risk ↑ in CKD\nInsulin requirements may fall with worsening CKD\nDegludec: more stable profile"),
     C("Hypoglycemia (main risk)\nWeight gain\nInjection site: lipohypertrophy, lipoatrophy\nEdema at initiation\nInsulin resistance with high doses\nHypoglycemia unawareness (with chronic use)")],
]

main_tbl = Table(main_table_data,
    colWidths=[COL_DRUG, COL_MECH, COL_DOSE, COL_HBA1C, COL_WT, COL_HYPO, COL_CV, COL_RENAL, COL_ADR],
    repeatRows=1)

# Build alternating row colours and header style
tbl_style = [
    # Header
    ("BACKGROUND", (0,0), (-1,0), TEAL),
    ("TEXTCOLOR",  (0,0), (-1,0), WHITE),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,0), 7),
    ("ALIGN",      (0,0), (-1,0), "CENTER"),
    ("VALIGN",     (0,0), (-1,-1), "TOP"),
    # Grid
    ("GRID",       (0,0), (-1,-1), 0.3, GREY_LINE),
    ("LINEBELOW",  (0,0), (-1,0), 1, TEAL),
    # Padding
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 4),
    ("RIGHTPADDING",  (0,0), (-1,-1), 4),
]

# Alternating row bg + drug class colour coding
row_colours = [
    TEAL_LIGHT,   # metformin
    GREEN_LT,     # GLP-1
    colors.HexColor("#E8F0FE"),  # SGLT2
    YELLOW_LT,    # DPP4
    ORANGE_LT,    # SU
    PURPLE_LT,    # TZD
    RED_LT,       # meglitinides
    colors.HexColor("#F0FFF4"),  # alpha-gluc
    colors.HexColor("#F5F0FF"),  # insulin
]

for i, clr in enumerate(row_colours):
    tbl_style.append(("BACKGROUND", (0, i+1), (-1, i+1), clr))

# First col bold
for r in range(1, len(main_table_data)):
    tbl_style.append(("FONTNAME", (0, r), (0, r), "Helvetica-Bold"))
    tbl_style.append(("FONTSIZE", (0, r), (0, r), 6.8))

main_tbl.setStyle(TableStyle(tbl_style))
story.append(main_tbl)
story.append(Spacer(1, 3*mm))

# ══════════════════════════════════════════════════════════════════════════════
# PAGE 2
# ══════════════════════════════════════════════════════════════════════════════
story.append(PageBreak())

# PAGE 2 BANNER
banner2 = Table([[Paragraph("TYPE 2 DIABETES MELLITUS — Monitoring, Targets &amp; Clinical Decision Framework", TITLE_STYLE)]],
    colWidths=[PAGE_W],
    style=TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), NAVY),
        ("TOPPADDING",    (0,0), (-1,-1), 10),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
    ]))
story.append(banner2)
story.append(Spacer(1, 4*mm))

# ── Layout: 3-column grid ───────────────────────────────────────────────────
COL3 = (PAGE_W - 6*mm) / 3

# ── Column 1: Monitoring Targets ─────────────────────────────────────────────
def monitoring_table():
    rows = [
        [Paragraph("PARAMETER", CELL_BOLD_CENTER), Paragraph("TARGET (GENERAL)", CELL_BOLD_CENTER), Paragraph("NOTES", CELL_BOLD_CENTER)],
        [C("HbA1c"), CC("<7.0%"), C("< 8% for elderly/frail/limited life expectancy\n> 6.5% acceptable in young/short duration")],
        [C("Fasting glucose"), CC("80–130 mg/dL"), C("Adjust target to individual")],
        [C("2-hr postprandial"), CC("< 180 mg/dL"), C("Postprandial monitoring important with prandial insulin or SU")],
        [C("Blood pressure"), CC("< 130/80 mmHg"), C("ADA 2026: target SBP < 120 mmHg where feasible")],
        [C("LDL cholesterol"), CC("< 70 mg/dL"), C("< 55 mg/dL if very high CV risk\nStatin therapy for most with T2DM age > 40")],
        [C("Triglycerides"), CC("< 150 mg/dL"), C("Fibrate or icosapentaenoic acid (REDUCE-IT) if > 200")],
        [C("eGFR / Creatinine"), CC("Monitor annually"), C("More frequent if declining; adjust drug doses")],
        [C("Urine ACR"), CC("< 30 mg/g"), C("If ≥ 30: start SGLT2i + ACE/ARB\nIf ≥ 100 + eGFR 30–90: add finerenone")],
        [C("BMI / Weight"), CC("Monitor each visit"), C("Target ≥ 5–10% weight loss if overweight\nConsider GLP-1 RA / bariatric surgery")],
        [C("HbA1c frequency"), CC("Q3 months (unstable)\nQ6 months (stable)"), C("CGM preferred over SMBG if on insulin (ADA 2026)")],
        [C("Eye exam"), CC("Annually"), C("Dilated fundus exam; telemedicine retinal imaging acceptable")],
        [C("Foot exam"), CC("Annually (+ each visit if high risk)"), C("Inspect for neuropathy, PVD, ulcers")],
        [C("Dental / psych"), CC("Regularly"), C("Dental disease common; screen for diabetes distress")],
        [C("Vitamin B12"), CC("Annually if on metformin"), C("Long-term metformin → B12 depletion; supplement if low")],
    ]
    t = Table(rows, colWidths=[COL3*0.38, COL3*0.28, COL3*0.34])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,0), TEAL),
        ("TEXTCOLOR",  (0,0), (-1,0), WHITE),
        ("GRID", (0,0), (-1,-1), 0.3, GREY_LINE),
        ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
        ("TOPPADDING",    (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("LEFTPADDING",   (0,0), (-1,-1), 4),
        ("RIGHTPADDING",  (0,0), (-1,-1), 4),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, GREY_LIGHT]),
    ]))
    return t

# ── Column 2: Drug choice by comorbidity ──────────────────────────────────────
def comorbidity_table():
    rows = [
        [Paragraph("COMORBIDITY / SITUATION", CELL_BOLD_CENTER), Paragraph("PREFERRED AGENTS", CELL_BOLD_CENTER)],
        [C("Established ASCVD / High CV risk", bold=True), C("GLP-1 RA with proven MACE benefit\n(liraglutide, semaglutide, dulaglutide)\nOR SGLT2i")],
        [C("Heart Failure (HFrEF or HFpEF)", bold=True), C("SGLT2i first\nFor HFpEF: tirzepatide or GLP-1 RA\n(ADA 2026 Rec 9.9a/9.9b)")],
        [C("CKD (eGFR 20–90)", bold=True), C("SGLT2i + ACE/ARB (eGFR ≥30)\nGLP-1 RA (can continue in advanced CKD)\nFinerenone if ACR ≥100")],
        [C("Obesity / Weight loss priority", bold=True), C("Tirzepatide (highest weight loss)\nor semaglutide 2.4 mg (Wegovy)\nConsider bariatric surgery if BMI ≥35")],
        [C("MASLD / MASH", bold=True), C("Semaglutide (preferred GLP-1 RA)\nPioglitazone (biopsy-proven MASH)\nTirzepatide – potential MASH benefit")],
        [C("Hypoglycemia risk", bold=True), C("GLP-1 RA, SGLT2i, DPP-4i\nAvoid sulfonylureas / meglitinides")],
        [C("Cost constraint", bold=True), C("Metformin + sulfonylurea (glipizide)\n+ NPH insulin\n(Avoid glyburide in elderly)")],
        [C("Pregnancy (T2DM)", bold=True), C("Insulin preferred (all trimesters)\nMetformin may be used\nAvoid GLP-1 RA, SGLT2i in pregnancy")],
        [C("Post-transplant diabetes", bold=True), C("Insulin preferred perioperatively\n(DPP-4i for mild hyperglycemia)\nLong-term: noninsulin options; GLP-1 RA for cardiometabolic benefit")],
        [C("Elderly (>75 y / frail)", bold=True), C("DPP-4i (safe, well tolerated)\nAvoid glyburide, meglitinides\nRelax HbA1c target to <8%")],
        [C("Hepatic impairment", bold=True), C("Avoid metformin in severe hepatic failure\nDapagliflozin: 5 mg starting dose\nInsulin or DPP-4i generally safe")],
        [C("High HbA1c at diagnosis (≥10%)", bold=True), C("Consider insulin initiation\nOR GLP-1 RA + metformin\nReassess once stabilised")],
    ]
    t = Table(rows, colWidths=[COL3*0.46, COL3*0.54])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,0), ORANGE),
        ("TEXTCOLOR",  (0,0), (-1,0), WHITE),
        ("GRID", (0,0), (-1,-1), 0.3, GREY_LINE),
        ("VALIGN", (0,0), (-1,-1), "TOP"),
        ("TOPPADDING",    (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("LEFTPADDING",   (0,0), (-1,-1), 4),
        ("RIGHTPADDING",  (0,0), (-1,-1), 4),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, ORANGE_LT]),
    ]))
    return t

# ── Column 3: Insulin types + ADA step algorithm ─────────────────────────────
def insulin_table():
    rows = [
        [Paragraph("INSULIN TYPE", CELL_BOLD_CENTER), Paragraph("ONSET", CELL_BOLD_CENTER),
         Paragraph("PEAK", CELL_BOLD_CENTER), Paragraph("DURATION", CELL_BOLD_CENTER)],
        [C("Rapid-acting\n(Lispro, Aspart,\nGlulisine)"), CC("5–15 min"), CC("30–90 min"), CC("3–5 hr")],
        [C("Short-acting\n(Regular)"), CC("30–60 min"), CC("2–4 hr"), CC("6–10 hr")],
        [C("Intermediate\n(NPH)"), CC("2–4 hr"), CC("4–10 hr"), CC("12–18 hr")],
        [C("Long-acting\n(Glargine, Detemir)"), CC("1–2 hr"), CC("Peakless"), CC("20–24 hr")],
        [C("Ultra-long\n(Degludec)"), CC("30–90 min"), CC("Peakless"), CC(">42 hr")],
    ]
    t = Table(rows, colWidths=[COL3*0.38, COL3*0.2, COL3*0.2, COL3*0.22])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,0), PURPLE),
        ("TEXTCOLOR",  (0,0), (-1,0), WHITE),
        ("GRID", (0,0), (-1,-1), 0.3, GREY_LINE),
        ("VALIGN", (0,0), (-1,-1), "MIDDLE"),
        ("TOPPADDING",    (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("LEFTPADDING",   (0,0), (-1,-1), 4),
        ("RIGHTPADDING",  (0,0), (-1,-1), 4),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, PURPLE_LT]),
    ]))
    return t

def step_algo():
    steps = [
        ("STEP 1\nDIAGNOSIS", "Lifestyle modification (MNT, exercise, weight)\n+ Metformin\n+ Consider GLP-1 RA or SGLT2i\n  if CVD / HF / CKD present", TEAL),
        ("STEP 2\n3 MONTHS", "If HbA1c still above target:\nAdd GLP-1 RA (weight ↑, CVD)\nor SGLT2i (HF, CKD, weight)\nor DPP-4i (well tolerated, neutral)\nor SU (if cost is barrier)", GREEN),
        ("STEP 3\n3–6 MO", "Triple therapy:\nCombine agents from different classes\nConsider tirzepatide (dual GIP/GLP-1)\nfor maximum weight + glucose lowering", ORANGE),
        ("STEP 4\nBASAL INS.", "Add basal insulin (glargine/degludec)\n10U QHS; titrate by 2U q3 days\nTarget FBG 80–130 mg/dL\nContinue non-insulin agents if possible", PURPLE),
        ("STEP 5\nINTENSIFY", "Basal-bolus insulin\nor AID system (preferred 2026)\nIDegLira / iGlarLixi: reduce\nhypoglycemia + weight gain", RED),
    ]
    data = []
    for label, text, clr in steps:
        data.append([
            Paragraph(label, S("steplabel", fontName="Helvetica-Bold", fontSize=6.5,
                               textColor=WHITE, alignment=TA_CENTER, leading=8)),
            Paragraph(text, CELL)
        ])
    t = Table(data, colWidths=[COL3*0.27, COL3*0.73])
    style = [
        ("GRID", (0,0), (-1,-1), 0.3, GREY_LINE),
        ("VALIGN", (0,0), (-1,-1), "TOP"),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 4),
        ("RIGHTPADDING",  (0,0), (-1,-1), 4),
    ]
    clrs = [TEAL, GREEN, ORANGE, PURPLE, RED]
    for i, clr in enumerate(clrs):
        style.append(("BACKGROUND", (0, i), (0, i), clr))
        style.append(("BACKGROUND", (1, i), (1, i), WHITE if i % 2 == 0 else GREY_LIGHT))
    t.setStyle(TableStyle(style))
    return t

# ── Build 3-column layout ────────────────────────────────────────────────────
def col_header(text, bg):
    return Table([[Paragraph(f"<b>{text}</b>",
        S("ch", fontName="Helvetica-Bold", fontSize=8, textColor=WHITE,
          alignment=TA_CENTER))]],
        colWidths=[COL3],
        style=TableStyle([
            ("BACKGROUND", (0,0), (-1,-1), bg),
            ("TOPPADDING",    (0,0), (-1,-1), 5),
            ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ]))

col1_content = [
    col_header("② MONITORING TARGETS & FREQUENCY", TEAL),
    monitoring_table(),
]
col2_content = [
    col_header("③ DRUG CHOICE BY COMORBIDITY (ADA 2026)", ORANGE),
    comorbidity_table(),
]
col3_content = [
    col_header("④ INSULIN REFERENCE", PURPLE),
    insulin_table(),
    Spacer(1, 3*mm),
    col_header("⑤ ADA 2026 STEPWISE MANAGEMENT ALGORITHM", GREEN),
    step_algo(),
]

from reportlab.platypus import KeepInFrame

def wrap_col(items, width, height=175*mm):
    frame_content = []
    for item in items:
        frame_content.append(item)
        frame_content.append(Spacer(1, 2*mm))
    kif = KeepInFrame(width, height, frame_content, mode='shrink')
    return kif

grid_data = [[
    wrap_col(col1_content, COL3),
    wrap_col(col2_content, COL3),
    wrap_col(col3_content, COL3),
]]

grid = Table(grid_data, colWidths=[COL3, COL3, COL3],
    style=TableStyle([
        ("VALIGN",      (0,0), (-1,-1), "TOP"),
        ("LEFTPADDING", (0,0), (-1,-1), 0),
        ("RIGHTPADDING",(0,0), (-1,-1), 3),
        ("TOPPADDING",  (0,0), (-1,-1), 0),
        ("BOTTOMPADDING",(0,0), (-1,-1), 0),
    ]))
story.append(grid)

story.append(Spacer(1, 3*mm))
story.append(HRFlowable(width=PAGE_W, thickness=0.5, color=GREY_LINE))
story.append(Spacer(1, 2*mm))

# ── ADA 2026 Highlights box ──────────────────────────────────────────────────
highlights = [
    "⭐ <b>GLP-1 RAs & SGLT2i now recommended from point of T2DM diagnosis</b> – not only after metformin failure",
    "⭐ <b>Tirzepatide (dual GIP/GLP-1)</b> – for HFpEF, MASH, and maximum weight loss",
    "⭐ <b>SGLT2i + finerenone</b> simultaneous initiation endorsed for CKD (ACR ≥100 mg/g, eGFR 30–90, on RAS inhibitor)",
    "⭐ <b>BP target</b>: SBP < 120 mmHg where feasible  |  ⭐ <b>AID systems</b> preferred for insulin-requiring T2DM",
    "⭐ <b>GLP-1 RA</b> can now be continued / initiated in <b>advanced CKD</b>  |  ⭐ Holistic care: liver, cognition, bone now addressed",
]
hi_text = "   ".join(highlights)
hi_para = Paragraph(hi_text, S("hi", fontName="Helvetica", fontSize=6.5, textColor=NAVY,
                                leading=9, alignment=TA_LEFT))
hi_box = Table([[hi_para]], colWidths=[PAGE_W],
    style=TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), colors.HexColor("#EBF5FB")),
        ("BOX", (0,0), (-1,-1), 1, TEAL),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
    ]))
story.append(hi_box)
story.append(Spacer(1, 2*mm))

# Footer
footer_text = (
    f"Generated by Orris Medical Reference  |  Based on ADA Standards of Care in Diabetes 2026  |  "
    f"Sources: Lippincott Pharmacology, Katzung's Basic & Clinical Pharmacology 16e, Goodman & Gilman's  |  "
    f"Date: {datetime.date.today().strftime('%B %d, %Y')}  |  "
    "⚠ For clinical decision support only – always verify with current guidelines and patient-specific factors"
)
story.append(Paragraph(footer_text, FOOTNOTE))

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

cd /home/daytona/workspace/t2dm-guide && python3 generate_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/t2dm-guide/T2DM_Quick_Reference_Guide.pdf

The PDF was generated successfully. Here's your download link:

T2DM Quick Reference Guide

PDF Document · PDF


What's inside (2 landscape A4 pages):
Page 1 - Drug Class Comparison Table All 9 drug classes side-by-side across 9 columns:
  • Drug class / agents (colour-coded rows)
  • Mechanism of action
  • Typical dosing (with titration details)
  • HbA1c reduction
  • Weight effect
  • Hypoglycemia risk
  • CV/cardiac benefit
  • Renal considerations and dose adjustments
  • Key ADRs and precautions
Page 2 - Monitoring, Targets & Clinical Framework Three columns:
  • Monitoring targets table (HbA1c, BP, lipids, ACR, eGFR, foot/eye exam frequency, B12 monitoring)
  • Drug choice by comorbidity table (ASCVD, HF, CKD, obesity, MASH, elderly, pregnancy, post-transplant, etc.)
  • Insulin types reference (onset/peak/duration for all formulations)
  • ADA 2026 stepwise management algorithm (5-step, colour-coded)
  • ADA 2026 key updates highlight bar at the bottom
This is a shared conversation. Sign in to Orris to start your own chat.