Make a notes of pharmacology on diabetes Mellitus based on every details. Mechanism of action,types of DM,indications,contraindication ,treatment, drugs. For fmge ,usmle exam

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Loading Image
I now have all the material needed to write comprehensive, exam-focused notes. Here are your complete pharmacology notes on Diabetes Mellitus:

πŸ“š Pharmacology of Diabetes Mellitus

Complete Notes for FMGE & USMLE

Source: Lippincott Illustrated Reviews Pharmacology, Barash Clinical Anesthesia, Lippincott

PART 1 - OVERVIEW & CLASSIFICATION OF DIABETES MELLITUS

Definition

Diabetes Mellitus (DM) is a group of metabolic diseases characterized by chronic hyperglycemia resulting from defects in insulin secretion, insulin action, or both.

Types of Diabetes Mellitus

FeatureType 1 DMType 2 DMGestational DM
PathologyAutoimmune destruction of beta cellsInsulin resistance + relative insulin deficiencyInsulin resistance during pregnancy
Insulin levelsVery low / absentNormal to high early, then reducedVariable
Body habitusThinObese (usually)N/A
OnsetChildhood/young adultsMiddle-aged/elderlyDuring pregnancy
KetoacidosisCommonRareRare
TreatmentInsulin (mandatory)Lifestyle + oral agents + insulinDiet + insulin if needed
Genetic basisHLA-DR3, HLA-DR4Polygenic, strong FHGenetic + hormonal
Additional types: MODY (Maturity Onset Diabetes of the Young), drug-induced DM (steroids, thiazides, atypical antipsychotics), pancreatitis-related.

Diagnostic Criteria (ADA)

  • HbA1c β‰₯ 6.5%
  • Fasting plasma glucose β‰₯ 126 mg/dL (no caloric intake for β‰₯8 hours)
  • 2-hour plasma glucose β‰₯ 200 mg/dL during 75g OGTT
  • Random plasma glucose β‰₯ 200 mg/dL with classic symptoms
All results (except symptomatic random glucose) require confirmation by repeat testing.

PART 2 - INSULIN

Normal Physiology

  • Insulin is secreted by pancreatic beta (Ξ²) cells
  • Binds to insulin receptor tyrosine kinase β†’ glucose uptake via GLUT-4 transporters (muscle, adipose)
  • Promotes glycogenesis, lipogenesis, protein synthesis
  • Inhibits gluconeogenesis, glycogenolysis, lipolysis, ketogenesis

Insulin Preparations - Classification

Insulin onset and duration of action diagram
CategoryDrugOnsetPeakDurationKey Notes
Rapid-actingLispro, Aspart, Glulisine15-30 min30-90 min3-5 hrsGive 15 min before meal
Short-actingRegular (Soluble) insulin30-60 min50-120 min5-8 hrsIV use possible; give 30 min before meal
IntermediateNPH (Isophane)1-2 hrs4-8 hrs10-20 hrsContains protamine + zinc
Long-actingGlargine, Detemir1-2 hrsFlat/no peak20-24 hrsGlargine = "peakless basal"
Ultra-longDegludec1-2 hrsFlat>42 hrsOnce daily
InhaledInhaled insulinRapid10-20 min~3 hrsDry powder, pulmonary route
FMGE/USMLE Pearl: Lispro has inverted 28-29 amino acids (Pro-Lys becomes Lys-Pro). Glargine = "peakless" insulin, precipitates at subcutaneous pH. Cannot mix glargine with other insulins.

Insulin - Mechanism of Action

  1. Binds insulin receptor (alpha subunit) β†’ activates tyrosine kinase (beta subunit)
  2. Triggers phosphorylation cascade β†’ GLUT-4 translocation to cell membrane
  3. Increases glucose uptake in muscle and adipose
  4. Suppresses hepatic gluconeogenesis

Insulin Indications

  • Type 1 DM (mandatory)
  • Type 2 DM uncontrolled on oral agents
  • Diabetic ketoacidosis (DKA)
  • Hyperglycemic hyperosmolar state (HHS)
  • Gestational diabetes
  • Perioperative hyperglycemia
  • Hyperkalemia (regular insulin + dextrose)

Insulin Adverse Effects

  • Hypoglycemia (most common and dangerous)
  • Weight gain
  • Lipodystrophy - local atrophy or hypertrophy at injection site (due to repeated injection at same site)
  • Hypokalemia (insulin drives K+ into cells)
  • Injection site reactions
  • Insulin allergy (rare)

Intensive vs. Standard Insulin Therapy

  • Standard: 2 injections/day
  • Intensive: 3+ injections/day + frequent glucose monitoring; target HbA1c ≀ 7%
  • Intensive therapy: more hypoglycemic episodes BUT significantly reduces microvascular complications (retinopathy, nephropathy, neuropathy)
  • Avoid intensive therapy in: elderly, long-standing DM, severe microvascular disease, hypoglycemic unawareness

PART 3 - ORAL ANTIDIABETIC DRUGS

Class 1 - BIGUANIDES

Drug: Metformin (first-line for Type 2 DM)
PropertyDetail
MOAActivates AMPK β†’ reduces hepatic gluconeogenesis (primary); increases insulin sensitivity; delays glucose absorption
RouteOral
Effect on weightNeutral / slight weight loss
Hypoglycemia riskNone (does not stimulate insulin)
IndicationsType 2 DM (first-line), PCOS, prediabetes
ContraindicationseGFR < 30 mL/min (renal failure), IV contrast use (hold 48h), hepatic failure, alcoholism, sepsis/shock
Adverse effectsGI upset (N/V/D), lactic acidosis (rare but serious), metallic taste, B12 deficiency
Key pearlLactic acidosis risk increased in renal impairment - MUST HOLD before IV contrast
USMLE/FMGE Pearl: Metformin is the ONLY oral antidiabetic that reduces cardiovascular mortality (UKPDS trial).

Class 2 - SULFONYLUREAS

1st Generation: Tolbutamide, Chlorpropamide, Tolazamide 2nd Generation: Glipizide, Glyburide (Glibenclamide), Glimepiride
PropertyDetail
MOABlock ATP-sensitive K+ channels on beta cell membrane β†’ depolarization β†’ Ca2+ influx β†’ insulin secretion
RouteOral
Effect on weightWeight gain
Hypoglycemia riskHIGH (major concern)
IndicationsType 2 DM
ContraindicationsType 1 DM, renal failure (glyburide), sulfa allergy, pregnancy
Adverse effectsHypoglycemia, weight gain, disulfiram-like reaction (chlorpropamide + alcohol), SIADH (chlorpropamide)
FMGE Pearl: Glibenclamide/Glyburide = most potent sulfonylurea. Chlorpropamide has the longest half-life (35 hrs) and causes SIADH. Glimepiride = safest in elderly/CKD.

Class 3 - MEGLITINIDES (Glinides)

Drugs: Repaglinide, Nateglinide
PropertyDetail
MOABlock ATP-sensitive K+ channels (same as sulfonylureas) but faster onset, shorter duration
AdministrationBefore each meal ("prandial glucose regulators")
Hypoglycemia riskLower than sulfonylureas (short-acting)
AdvantageFlexible meal schedule
Pearl: Nateglinide derived from phenylalanine. Repaglinide has more hepatic metabolism - safer in renal impairment.

Class 4 - THIAZOLIDINEDIONES (TZDs/Glitazones)

Drugs: Pioglitazone, Rosiglitazone (restricted)
PropertyDetail
MOAAgonists at PPAR-Ξ³ (peroxisome proliferator-activated receptor gamma) β†’ increase insulin sensitivity in muscle and adipose
OnsetSlow (weeks to months for full effect)
Effect on weightWeight gain
Hypoglycemia riskNone alone
IndicationsType 2 DM, insulin resistance
ContraindicationsHeart failure (NYHA Class III/IV), active liver disease, bladder cancer (pioglitazone - caution), pregnancy
Adverse effectsEdema, weight gain, osteoporosis/fractures (in women), heart failure, hepatotoxicity (rosiglitazone - now restricted), bladder cancer risk (pioglitazone)
USMLE Pearl: Rosiglitazone withdrawn/restricted due to increased MI risk. Pioglitazone used cautiously. TZDs cause fluid retention - avoid in heart failure.

Class 5 - ALPHA-GLUCOSIDASE INHIBITORS

Drugs: Acarbose, Miglitol, Voglibose
PropertyDetail
MOAInhibit alpha-glucosidase enzyme in intestinal brush border β†’ delay carbohydrate digestion and absorption β†’ blunt postprandial glucose
Effect on weightNeutral
Hypoglycemia riskNone alone
IndicationsType 2 DM (postprandial hyperglycemia), adjunct therapy
ContraindicationsIBD, cirrhosis, renal failure, inflammatory bowel disease
Adverse effectsFlatulence, bloating, diarrhea (GI side effects = most common)
Special noteIf hypoglycemia occurs (when used with insulin/SU), treat with glucose (dextrose), NOT sucrose - as sucrose breakdown is inhibited

Class 6 - DPP-4 INHIBITORS (Gliptins)

Drugs: Sitagliptin, Saxagliptin, Alogliptin, Linagliptin, Vildagliptin
PropertyDetail
MOAInhibit dipeptidyl peptidase-4 (DPP-4) β†’ prevent degradation of incretin hormones (GLP-1, GIP) β†’ increased insulin secretion + decreased glucagon in a glucose-dependent manner
Effect on weightNeutral
Hypoglycemia riskLow (glucose-dependent)
IndicationsType 2 DM, add-on to metformin
ContraindicationsPancreatitis history (caution), severe renal failure (dose adjust most; linagliptin - no dose adjust as hepatic excretion)
Adverse effectsNasopharyngitis, UTI, rare pancreatitis, joint pain (arthralgia)
FMGE Pearl: Linagliptin is the only DPP-4 inhibitor that does NOT require dose adjustment in renal failure (excreted via bile/feces). Saxagliptin associated with heart failure hospitalization.

Class 7 - GLP-1 RECEPTOR AGONISTS

Drugs: Exenatide, Liraglutide, Dulaglutide, Semaglutide, Lixisenatide
PropertyDetail
MOAMimic incretin hormone GLP-1 β†’ glucose-dependent insulin secretion, decrease glucagon, delay gastric emptying, increase satiety
RouteSubcutaneous injection (semaglutide also oral)
Effect on weightSignificant weight loss
Hypoglycemia riskLow (glucose-dependent)
CardiovascularLiraglutide and semaglutide have proven CV benefit (LEADER, SUSTAIN trials)
RenalBeneficial in CKD
IndicationsType 2 DM + obesity, T2DM + CVD, T2DM + CKD
ContraindicationsHistory of medullary thyroid carcinoma, MEN type 2, pancreatitis, pregnancy
Adverse effectsNausea, vomiting, diarrhea, pancreatitis, potential thyroid C-cell tumors
USMLE Pearl: GLP-1 agonists = weight loss (unlike insulin and sulfonylureas which cause weight gain). Liraglutide/Semaglutide also FDA-approved for obesity management.

Class 8 - SGLT-2 INHIBITORS (Gliflozins)

Drugs: Empagliflozin, Canagliflozin, Dapagliflozin, Ertugliflozin
PropertyDetail
MOAInhibit sodium-glucose cotransporter-2 (SGLT-2) in proximal convoluted tubule of kidney β†’ block glucose reabsorption β†’ glucosuria β†’ lower blood glucose
Effect on weightWeight loss
Blood pressureReduces BP (osmotic diuresis)
Hypoglycemia riskLow
CardiovascularProven CV benefit (EMPA-REG, CANVAS, DECLARE trials)
RenalSlows CKD progression
Heart failureReduces HF hospitalization (now used even in non-diabetics for HF)
ContraindicationseGFR < 45 mL/min (canagliflozin < 30), type 1 DM (euglycemic DKA risk), recurrent UTI
Adverse effectsGenital mycotic infections (most common), UTI, euglycemic DKA, Fournier's gangrene (rare), bone fractures (canagliflozin), limb amputation (canagliflozin)
USMLE/FMGE Pearl: SGLT-2 inhibitors cause glucosuria WITHOUT hypoglycemia because mechanism is insulin-independent. Risk of euglycemic DKA (glucose normal but DKA present) - important diagnostic trap.

Class 9 - AMYLIN ANALOGS

Drug: Pramlintide
PropertyDetail
MOASynthetic amylin analog β†’ delays gastric emptying, decreases postprandial glucagon, increases satiety
RouteSubcutaneous injection (before meals)
IndicationsAdjunct to mealtime insulin in Type 1 AND Type 2 DM
ContraindicationsDiabetic gastroparesis, hypoglycemic unawareness, cresol hypersensitivity
ImportantWhen starting pramlintide, reduce mealtime insulin by 50% to prevent severe hypoglycemia; cannot mix in same syringe as insulin

PART 4 - QUICK COMPARISON TABLE (HIGH YIELD)

Drug ClassMOAHypoglycemiaWeightKey ADRContraindication
Metformin↓ hepatic gluconeogenesisNoneNeutral/↓Lactic acidosisRenal failure
Sulfonylureas↑ insulin secretion (K+ channel block)High↑HypoglycemiaRenal failure
Meglitinides↑ insulin secretion (fast/short)Low↑Hypoglycemia--
TZDsPPAR-Ξ³ agonist, ↑ insulin sensitivityNone↑↑Edema, fracturesHeart failure
Ξ±-Glucosidase inhibitors↓ carb digestionNoneNeutralFlatulenceIBD
DPP-4 inhibitors↑ incretin levelsLowNeutralNasopharyngitisPancreatitis hx
GLP-1 agonists↑ glucose-dep. insulin, ↓ glucagonLow↓↓Nausea, pancreatitisMTC, MEN2
SGLT-2 inhibitors↓ renal glucose reabsorptionLow↓Genital infections, euDKAeGFR < 45
InsulinReceptor tyrosine kinase activationHigh↑Hypoglycemia, lipodystrophyHypoglycemia

PART 5 - TREATMENT ALGORITHM

Type 1 DM

Insulin is mandatory - no oral agents work alone
  • Basal-Bolus regimen (ideal): Long-acting basal (glargine/detemir) + rapid-acting bolus (lispro/aspart) before meals
  • May add pramlintide as adjunct

Type 2 DM (ADA Stepwise Approach)

Step 1: Lifestyle modification (diet + exercise)
Step 2: Metformin (first-line) -- unless contraindicated
Step 3: Add second agent based on patient profile:
    - With CVD/HF β†’ SGLT-2 inhibitor OR GLP-1 agonist
    - With CKD    β†’ SGLT-2 inhibitor (empagliflozin/canagliflozin)
    - Obesity     β†’ GLP-1 agonist or SGLT-2 inhibitor
    - Cost concern β†’ Sulfonylurea or TZD
Step 4: Triple combination or add insulin if HbA1c uncontrolled

Targets

  • HbA1c < 7% (most patients)
  • HbA1c < 8% (elderly, comorbidities, hypoglycemia unawareness)
  • Fasting glucose: 80-130 mg/dL
  • Postprandial glucose: <180 mg/dL

PART 6 - COMPLICATIONS OF DM (Pharmacological relevance)

Microvascular

  • Retinopathy - tight glycemic control reduces risk
  • Nephropathy - SGLT-2 inhibitors + ACE inhibitors/ARBs (renoprotective)
  • Neuropathy - glycemic control; gabapentin/pregabalin/duloxetine/amitriptyline for pain

Macrovascular

  • CAD, Stroke, PVD - GLP-1 agonists and SGLT-2 inhibitors have proven CV benefit
  • Statins (atorvastatin 40-80 mg) for all diabetics >40 years with CVD risk
  • ACE inhibitors/ARBs for hypertension in DM

Diabetic Ketoacidosis (DKA) - Treatment

  • IV fluids (0.9% NaCl)
  • Regular insulin IV infusion
  • Potassium replacement (monitor K+ - insulin drives K+ into cells)
  • Treat precipitant (infection, missed insulin dose)

PART 7 - HIGH-YIELD EXAM PEARLS

FMGE Favorites

  1. First-line drug for Type 2 DM = Metformin
  2. Drug causing SIADH = Chlorpropamide (1st gen sulfonylurea)
  3. Lactic acidosis = Metformin (especially in renal failure)
  4. Contraindicated in heart failure = TZDs (pioglitazone, rosiglitazone)
  5. Peakless long-acting insulin = Glargine
  6. Most potent sulfonylurea = Glibenclamide (Glyburide)
  7. Weight loss with antidiabetic = GLP-1 agonists, SGLT-2 inhibitors
  8. Euglycemic DKA = SGLT-2 inhibitors
  9. Contraindication: medullary thyroid cancer = GLP-1 agonists
  10. DPP-4 inhibitor safe in renal failure = Linagliptin

USMLE Favorites

  1. CV mortality reduction = Metformin (UKPDS), Liraglutide (LEADER), Empagliflozin (EMPA-REG)
  2. Heart failure hospitalization reduction = SGLT-2 inhibitors
  3. Pancreatitis risk = GLP-1 agonists and DPP-4 inhibitors
  4. Fournier's gangrene = SGLT-2 inhibitors (rare, serious)
  5. Hypoglycemia treatment with alpha-glucosidase inhibitor = Use dextrose (NOT sucrose)
  6. Insulin + pramlintide = Reduce insulin dose by 50% when starting
  7. Hold metformin before IV contrast = Risk of lactic acidosis (resume 48h after if renal function stable)
  8. Glyburide contraindicated in pregnancy = Crosses placenta; use insulin instead
  9. Sulfonylurea mechanism = Block K-ATP channels on beta cells
  10. SGLT-2 inhibitors in HFrEF = Reduce mortality even in non-diabetics (dapagliflozin, empagliflozin)

PART 8 - DRUG-DRUG INTERACTIONS (High Yield)

DrugInteractionEffect
Sulfonylureas + FluconazoleFluconazole inhibits CYP2C9↑ sulfonylurea levels β†’ hypoglycemia
Sulfonylureas + NSAIDs (phenylbutazone)Inhibit sulfonylurea metabolism↑ hypoglycemia risk
Metformin + IV contrastBoth nephrotoxicLactic acidosis risk - HOLD metformin
Insulin + alcoholAlcohol inhibits gluconeogenesisPotentiates hypoglycemia
Chlorpropamide + alcoholDisulfiram-like reactionFlushing, nausea, vomiting
SaxagliptinAssociatedIncreased HF hospitalization
CanagliflozinRifampin (inducer)Reduced efficacy

Sources: Lippincott Illustrated Reviews Pharmacology 7th Ed. | Barash Clinical Anesthesia 9th Ed. | ADA Standards of Medical Care in Diabetes

Please make a pfd with all these details you shown above

Reading File
Running Command

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

Running Command

mkdir -p /tmp/workspace/diabetes-notes && python3 -c "from reportlab.lib import colors; print('reportlab ok')"

Writing File

~/diabetes-notes/generate_pdf.py


from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
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.platypus import Image as RLImage
import urllib.request, io

OUTPUT = "/tmp/workspace/diabetes-notes/DM_Pharmacology_Notes_FMGE_USMLE.pdf"

# ── Color palette ──────────────────────────────────────────────────────────
NAVY       = colors.HexColor("#1a3a5c")
TEAL       = colors.HexColor("#0d6e8f")
LIGHT_TEAL = colors.HexColor("#e6f4f8")
GOLD       = colors.HexColor("#d4a017")
LIGHT_GOLD = colors.HexColor("#fdf6e3")
RED_DARK   = colors.HexColor("#b22222")
GREEN_DARK = colors.HexColor("#1a5c2a")
GRAY_BG    = colors.HexColor("#f5f5f5")
GRAY_LINE  = colors.HexColor("#cccccc")
WHITE      = colors.white
BLACK      = colors.black
ORANGE     = colors.HexColor("#e07b00")

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    rightMargin=1.8*cm, leftMargin=1.8*cm,
    topMargin=2*cm, bottomMargin=2*cm,
    title="Pharmacology of Diabetes Mellitus",
    author="Orris Medical Notes"
)

styles = getSampleStyleSheet()
W = A4[0] - 3.6*cm   # usable width

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

st_cover_title = S("CoverTitle", fontSize=28, textColor=WHITE,
                   fontName="Helvetica-Bold", alignment=TA_CENTER, leading=34)
st_cover_sub   = S("CoverSub", fontSize=14, textColor=LIGHT_TEAL,
                   fontName="Helvetica", alignment=TA_CENTER, leading=20)
st_cover_tag   = S("CoverTag", fontSize=11, textColor=GOLD,
                   fontName="Helvetica-BoldOblique", alignment=TA_CENTER)

st_part  = S("Part", fontSize=16, textColor=WHITE, fontName="Helvetica-Bold",
             alignment=TA_LEFT, leading=20, spaceBefore=14, spaceAfter=6,
             backColor=NAVY, leftIndent=-4, rightIndent=-4, borderPadding=(6,8,6,8))
st_h2    = S("H2", fontSize=13, textColor=NAVY, fontName="Helvetica-Bold",
             spaceBefore=10, spaceAfter=4, leading=16)
st_h3    = S("H3", fontSize=11, textColor=TEAL, fontName="Helvetica-Bold",
             spaceBefore=8, spaceAfter=3, leading=14)
st_body  = S("Body", fontSize=9.5, fontName="Helvetica", leading=13,
             spaceAfter=3, alignment=TA_JUSTIFY)
st_bullet= S("Bullet", fontSize=9.5, fontName="Helvetica", leading=13,
             leftIndent=14, firstLineIndent=-10, spaceAfter=2)
st_pearl = S("Pearl", fontSize=9.5, fontName="Helvetica-BoldOblique",
             textColor=RED_DARK, leading=13, leftIndent=10,
             backColor=colors.HexColor("#fff8f8"), borderPadding=4, spaceAfter=4)
st_green = S("Green", fontSize=9.5, fontName="Helvetica-BoldOblique",
             textColor=GREEN_DARK, leading=13, leftIndent=10,
             backColor=colors.HexColor("#f0fff0"), borderPadding=4, spaceAfter=4)
st_src   = S("Source", fontSize=8, textColor=colors.gray,
             fontName="Helvetica-Oblique", alignment=TA_CENTER, spaceAfter=2)
st_toc_h = S("TocH", fontSize=11, textColor=NAVY, fontName="Helvetica-Bold",
             spaceBefore=6, spaceAfter=2)
st_toc_i = S("TocI", fontSize=10, fontName="Helvetica", textColor=BLACK,
             leftIndent=16, spaceAfter=1)

def part_heading(text):
    tbl = Table([[Paragraph(text, st_part)]], colWidths=[W])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), NAVY),
        ("ROUNDEDCORNERS", [4]),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("TOPPADDING", (0,0), (-1,-1), 6),
    ]))
    return tbl

def drug_class_box(title_text, color=TEAL):
    tbl = Table([[Paragraph(title_text, S("dct", fontSize=12, textColor=WHITE,
                   fontName="Helvetica-Bold", alignment=TA_LEFT))]], colWidths=[W])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("TOPPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING", (0,0), (-1,-1), 10),
    ]))
    return tbl

def make_table(headers, rows, col_widths=None, stripe=True):
    if col_widths is None:
        col_widths = [W / len(headers)] * len(headers)
    hs = S("th", fontSize=9, textColor=WHITE, fontName="Helvetica-Bold",
           alignment=TA_CENTER, leading=12)
    ds = S("td", fontSize=8.5, fontName="Helvetica", leading=12, alignment=TA_LEFT)
    data = [[Paragraph(h, hs) for h in headers]]
    for i, row in enumerate(rows):
        data.append([Paragraph(str(c), ds) for c in row])
    t = Table(data, colWidths=col_widths, repeatRows=1)
    style = [
        ("BACKGROUND",  (0,0), (-1,0), NAVY),
        ("TEXTCOLOR",   (0,0), (-1,0), WHITE),
        ("GRID",        (0,0), (-1,-1), 0.4, GRAY_LINE),
        ("FONTSIZE",    (0,0), (-1,-1), 8.5),
        ("VALIGN",      (0,0), (-1,-1), "MIDDLE"),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, LIGHT_TEAL] if stripe else [WHITE]),
        ("BOTTOMPADDING",(0,0),(-1,-1), 4),
        ("TOPPADDING",  (0,0),(-1,-1), 4),
        ("LEFTPADDING", (0,0),(-1,-1), 5),
    ]
    t.setStyle(TableStyle(style))
    return t

def pearl(text):
    return Paragraph(f"<b>β˜… Exam Pearl:</b> {text}", st_pearl)

def green_box(text):
    return Paragraph(f"<b>βœ” Key Point:</b> {text}", st_green)

def bullet(text):
    return Paragraph(f"β€’ {text}", st_bullet)

def sp(n=1):
    return Spacer(1, n*4*mm)

def hr():
    return HRFlowable(width="100%", thickness=0.5, color=GRAY_LINE, spaceAfter=4)

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

# ── COVER PAGE ────────────────────────────────────────────────────
cover_bg = Table([
    [Paragraph("PHARMACOLOGY OF", st_cover_sub)],
    [Paragraph("DIABETES MELLITUS", st_cover_title)],
    [Spacer(1, 6)],
    [Paragraph("Complete Notes for FMGE &amp; USMLE", st_cover_tag)],
    [Spacer(1, 4)],
    [Paragraph("Insulin Β· Oral Antidiabetics Β· Treatment Algorithm Β· Drug Interactions", st_cover_sub)],
    [Spacer(1, 10)],
    [Paragraph("Based on Lippincott Illustrated Reviews Pharmacology 7th Ed.", st_src)],
    [Paragraph("Barash Clinical Anesthesia 9th Ed. Β· ADA Standards of Medical Care", st_src)],
], colWidths=[W])
cover_bg.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), 20),
    ("RIGHTPADDING",  (0,0), (-1,-1), 20),
    ("ROUNDEDCORNERS", [8]),
]))
story.append(sp(4))
story.append(cover_bg)
story.append(sp(6))

# Gold accent bar
accent = Table([["FMGE Β· USMLE Β· Medical Examinations"]], colWidths=[W])
accent.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), GOLD),
    ("FONTNAME", (0,0), (-1,-1), "Helvetica-Bold"),
    ("FONTSIZE", (0,0), (-1,-1), 12),
    ("ALIGNMENT", (0,0), (-1,-1), "CENTER"),
    ("BOTTOMPADDING", (0,0), (-1,-1), 8),
    ("TOPPADDING", (0,0), (-1,-1), 8),
]))
story.append(accent)
story.append(PageBreak())

# ── PART 1: Overview & Classification ────────────────────────────
story.append(part_heading("PART 1 β€” OVERVIEW & CLASSIFICATION OF DIABETES MELLITUS"))
story.append(sp())

story.append(Paragraph("Definition", st_h2))
story.append(Paragraph(
    "Diabetes Mellitus (DM) is a group of metabolic diseases characterized by chronic hyperglycemia "
    "resulting from defects in insulin secretion, insulin action, or both.", st_body))
story.append(sp())

story.append(Paragraph("Types of Diabetes Mellitus", st_h2))
story.append(make_table(
    ["Feature", "Type 1 DM", "Type 2 DM", "Gestational DM"],
    [
        ["Pathology", "Autoimmune destruction of beta cells", "Insulin resistance + relative insulin deficiency", "Insulin resistance during pregnancy"],
        ["Insulin levels", "Very low / absent", "Normal→high early, then reduced", "Variable"],
        ["Body habitus", "Thin", "Obese (usually)", "N/A"],
        ["Onset", "Childhood / young adults", "Middle-aged / elderly", "During pregnancy"],
        ["Ketoacidosis", "Common", "Rare", "Rare"],
        ["Treatment", "Insulin (mandatory)", "Lifestyle + oral agents + insulin", "Diet + insulin if needed"],
        ["Genetic basis", "HLA-DR3, HLA-DR4", "Polygenic, strong FH", "Genetic + hormonal"],
    ],
    col_widths=[3.2*cm, 4*cm, 5*cm, 4.4*cm]
))
story.append(sp())
story.append(Paragraph(
    "<b>Additional types:</b> MODY (Maturity Onset Diabetes of the Young), "
    "drug-induced DM (steroids, thiazides, atypical antipsychotics), pancreatitis-related.", st_body))
story.append(sp())

story.append(Paragraph("Diagnostic Criteria (ADA)", st_h2))
story.append(make_table(
    ["Criterion", "Threshold"],
    [
        ["HbA1c", "β‰₯ 6.5%"],
        ["Fasting plasma glucose (β‰₯8 h fast)", "β‰₯ 126 mg/dL (7 mmol/L)"],
        ["2-h plasma glucose (75 g OGTT)", "β‰₯ 200 mg/dL (11.1 mmol/L)"],
        ["Random plasma glucose + classic symptoms", "β‰₯ 200 mg/dL"],
    ],
    col_widths=[10*cm, 6.6*cm]
))
story.append(sp(0.5))
story.append(pearl("All results (except symptomatic random glucose) require confirmation by repeat testing."))
story.append(PageBreak())

# ── PART 2: Insulin ───────────────────────────────────────────────
story.append(part_heading("PART 2 β€” INSULIN"))
story.append(sp())

story.append(Paragraph("Normal Physiology", st_h2))
for t in [
    "Insulin is secreted by pancreatic <b>beta (Ξ²) cells</b> of islets of Langerhans.",
    "Binds to <b>insulin receptor tyrosine kinase</b> β†’ glucose uptake via <b>GLUT-4</b> transporters (muscle, adipose).",
    "Promotes: glycogenesis, lipogenesis, protein synthesis.",
    "Inhibits: gluconeogenesis, glycogenolysis, lipolysis, ketogenesis.",
]:
    story.append(bullet(t))
story.append(sp())

story.append(Paragraph("Mechanism of Action", st_h2))
for t in [
    "Binds insulin receptor (alpha subunit) β†’ activates <b>tyrosine kinase</b> (beta subunit).",
    "Triggers phosphorylation cascade β†’ GLUT-4 translocation to cell membrane.",
    "Increases glucose uptake in muscle and adipose tissue.",
    "Suppresses hepatic gluconeogenesis and glycogenolysis.",
]:
    story.append(bullet(t))
story.append(sp())

story.append(Paragraph("Insulin Preparations β€” Classification", st_h2))
story.append(make_table(
    ["Category", "Drugs", "Onset", "Peak", "Duration", "Key Notes"],
    [
        ["Rapid-acting", "Lispro, Aspart, Glulisine, Inhaled", "15–30 min", "30–90 min", "3–5 h", "Give 15 min before meal"],
        ["Short-acting", "Regular (Soluble) insulin", "30–60 min", "50–120 min", "5–8 h", "IV use possible; give 30 min before meal"],
        ["Intermediate", "NPH (Isophane)", "1–2 h", "4–8 h", "10–20 h", "Zinc + protamine complex"],
        ["Long-acting", "Glargine, Detemir", "1–2 h", "Flat / no peak", "20–24 h", "Glargine = peakless basal"],
        ["Ultra-long", "Degludec", "1–2 h", "Flat", ">42 h", "Once daily"],
        ["Inhaled", "Inhaled insulin (dry powder)", "Rapid", "10–20 min", "~3 h", "Pulmonary route"],
    ],
    col_widths=[2.5*cm, 4.2*cm, 1.8*cm, 2.2*cm, 2.2*cm, 3.7*cm]
))
story.append(sp(0.5))
story.append(pearl("Lispro = inverted Pro28-Lys29 amino acids. Glargine precipitates at subcutaneous pH β€” peakless. NEVER mix glargine with other insulins."))
story.append(sp())

story.append(Paragraph("Insulin Indications", st_h2))
for t in ["Type 1 DM (mandatory)", "Type 2 DM uncontrolled on oral agents",
          "Diabetic ketoacidosis (DKA)", "Hyperglycemic hyperosmolar state (HHS)",
          "Gestational diabetes", "Perioperative hyperglycemia",
          "Hyperkalemia (regular insulin IV + dextrose)"]:
    story.append(bullet(t))
story.append(sp())

story.append(Paragraph("Insulin Adverse Effects", st_h2))
story.append(make_table(
    ["Adverse Effect", "Notes"],
    [
        ["Hypoglycemia", "Most common and dangerous; more risk with intensive regimens"],
        ["Weight gain", "All insulins except inhaled (minimal)"],
        ["Lipodystrophy", "Local atrophy OR hypertrophy at injection site; rotate sites"],
        ["Hypokalemia", "Insulin drives K+ into cells"],
        ["Injection site reactions", "Pain, redness, swelling"],
        ["Insulin allergy", "Rare with recombinant human insulin"],
    ],
    col_widths=[5.5*cm, 11.1*cm]
))
story.append(sp())

story.append(Paragraph("Intensive vs. Standard Insulin Therapy", st_h2))
story.append(make_table(
    ["Feature", "Standard Therapy", "Intensive Therapy"],
    [
        ["Injections/day", "2 injections", "3 or more injections"],
        ["HbA1c target", ">7%", "≀7% (ADA target)"],
        ["Hypoglycemia risk", "Lower", "Higher"],
        ["Microvascular complications", "Higher risk", "Significantly reduced"],
        ["When to AVOID intensive Rx", "β€”", "Elderly, long-standing DM, hypoglycemic unawareness"],
    ],
    col_widths=[4.5*cm, 5.5*cm, 6.6*cm]
))
story.append(PageBreak())

# ── PART 3: Oral Antidiabetics ────────────────────────────────────
story.append(part_heading("PART 3 β€” ORAL & INJECTABLE ANTIDIABETIC DRUGS"))
story.append(sp())

# Helper for drug section
def drug_section(num, name, color, rows_prop, indications, contraindications, adr, pearls):
    story.append(drug_class_box(f"Class {num}: {name}", color))
    story.append(sp(0.5))
    # Properties table
    story.append(make_table(["Property", "Detail"], rows_prop, col_widths=[4.5*cm, 12.1*cm]))
    story.append(sp(0.5))
    story.append(Paragraph("<b>Indications:</b> " + indications, st_body))
    story.append(Paragraph("<b>Contraindications:</b> " + contraindications, st_body))
    story.append(Paragraph("<b>Adverse Effects:</b> " + adr, st_body))
    for p in pearls:
        story.append(pearl(p))
    story.append(sp())

drug_section(
    1, "BIGUANIDES β€” Metformin (First-line for T2DM)", TEAL,
    [
        ["Mechanism of Action", "Activates AMPK β†’ reduces hepatic gluconeogenesis (primary effect); increases insulin sensitivity in peripheral tissues; delays intestinal glucose absorption"],
        ["Route", "Oral"],
        ["Hypoglycemia risk", "NONE β€” does not stimulate insulin secretion"],
        ["Effect on weight", "Neutral or slight weight loss"],
        ["HbA1c reduction", "1–2%"],
    ],
    "Type 2 DM (first-line), PCOS, prediabetes prevention",
    "eGFR &lt;30 mL/min (renal failure), hepatic failure, alcoholism, sepsis/shock, IV contrast (hold 48h before and after)",
    "GI upset β€” nausea/vomiting/diarrhea (take with food), lactic acidosis (rare but serious), metallic taste, B12 deficiency with long-term use",
    [
        "Metformin is the ONLY oral antidiabetic proven to reduce cardiovascular mortality (UKPDS trial).",
        "HOLD metformin before IV contrast β€” risk of lactic acidosis if contrast causes acute kidney injury.",
    ]
)

drug_section(
    2, "SULFONYLUREAS β€” Glipizide, Glyburide, Glimepiride, Chlorpropamide", colors.HexColor("#1565a0"),
    [
        ["Mechanism of Action", "Block ATP-sensitive K+ (KATP) channels on beta cell membrane β†’ membrane depolarization β†’ Ca2+ influx β†’ insulin secretion"],
        ["Generations", "1st gen: Tolbutamide, Chlorpropamide, Tolazamide. 2nd gen: Glipizide, Glyburide (Glibenclamide), Glimepiride"],
        ["Hypoglycemia risk", "HIGH β€” stimulate insulin regardless of blood glucose"],
        ["Effect on weight", "Weight GAIN"],
        ["HbA1c reduction", "1–2%"],
    ],
    "Type 2 DM (add-on or monotherapy)",
    "Type 1 DM, renal failure (avoid glyburide), sulfa allergy, pregnancy, hepatic failure",
    "Hypoglycemia (most common), weight gain, disulfiram-like reaction with alcohol (chlorpropamide), SIADH (chlorpropamide)",
    [
        "Glibenclamide/Glyburide = most potent sulfonylurea. Chlorpropamide = longest half-life (~35 h) β€” causes SIADH.",
        "Glimepiride is safest in elderly/CKD (less hypoglycemia risk). 2nd gen sulfonylureas are more potent with fewer side effects than 1st gen.",
    ]
)

drug_section(
    3, "MEGLITINIDES (Glinides) β€” Repaglinide, Nateglinide", colors.HexColor("#5c6bc0"),
    [
        ["Mechanism of Action", "Block KATP channels (same as sulfonylureas) but faster onset and shorter duration β€” 'prandial glucose regulators'"],
        ["Administration", "Before each meal (3x/day dosing)"],
        ["Hypoglycemia risk", "Lower than sulfonylureas (short-acting, glucose-dependent)"],
        ["Effect on weight", "Slight weight gain"],
    ],
    "Type 2 DM with irregular meal schedule, postprandial hyperglycemia",
    "Hepatic failure (repaglinide caution)",
    "Hypoglycemia, weight gain",
    [
        "Repaglinide = more hepatic metabolism β†’ safer in mild–moderate renal impairment. Nateglinide derived from phenylalanine.",
        "If a meal is skipped, SKIP the dose β€” prevents hypoglycemia.",
    ]
)

drug_section(
    4, "THIAZOLIDINEDIONES (TZDs/Glitazones) β€” Pioglitazone, Rosiglitazone", colors.HexColor("#6a1010"),
    [
        ["Mechanism of Action", "Agonists at PPAR-Ξ³ (peroxisome proliferator-activated receptor gamma) in adipose/muscle β†’ increase insulin sensitivity; reduce hepatic glucose output"],
        ["Onset of full effect", "Weeks to months (slow onset)"],
        ["Hypoglycemia risk", "NONE alone"],
        ["Effect on weight", "Weight GAIN + edema"],
    ],
    "Type 2 DM with insulin resistance; NASH (pioglitazone)",
    "Heart failure (NYHA Class III/IV) β€” ABSOLUTE contraindication; active liver disease; bladder cancer (pioglitazone caution); pregnancy",
    "Edema/fluid retention, weight gain, osteoporosis/fractures (especially in women), heart failure exacerbation, hepatotoxicity (rosiglitazone β€” now restricted), bladder cancer risk (pioglitazone)",
    [
        "Rosiglitazone restricted/withdrawn in many countries due to increased MI risk. Pioglitazone used cautiously.",
        "TZDs are the most potent insulin sensitizers. NEVER use in heart failure.",
    ]
)

drug_section(
    5, "ALPHA-GLUCOSIDASE INHIBITORS β€” Acarbose, Miglitol, Voglibose", colors.HexColor("#2e7d32"),
    [
        ["Mechanism of Action", "Inhibit alpha-glucosidase enzyme at intestinal brush border β†’ delay carbohydrate digestion and absorption β†’ blunt postprandial glucose spikes"],
        ["Hypoglycemia risk", "NONE alone"],
        ["Effect on weight", "Neutral"],
        ["HbA1c reduction", "0.5–1%"],
    ],
    "Type 2 DM (postprandial hyperglycemia); adjunct therapy",
    "IBD, intestinal obstruction, cirrhosis, renal failure (serum creatinine >2 mg/dL)",
    "FLATULENCE, bloating, diarrhea, abdominal cramps (most common and most limiting side effects)",
    [
        "If hypoglycemia occurs (when combined with insulin/sulfonylurea), treat with GLUCOSE (dextrose tablets) β€” NOT sucrose, because sucrose breakdown is inhibited by the drug.",
    ]
)

drug_section(
    6, "DPP-4 INHIBITORS (Gliptins) β€” Sitagliptin, Saxagliptin, Linagliptin, Alogliptin, Vildagliptin", colors.HexColor("#00695c"),
    [
        ["Mechanism of Action", "Inhibit dipeptidyl peptidase-4 (DPP-4) enzyme β†’ prevent breakdown of endogenous GLP-1 and GIP β†’ increased glucose-dependent insulin secretion + decreased glucagon"],
        ["Hypoglycemia risk", "LOW (glucose-dependent mechanism)"],
        ["Effect on weight", "NEUTRAL"],
        ["HbA1c reduction", "0.5–1%"],
    ],
    "Type 2 DM; add-on to metformin or other agents",
    "Pancreatitis history (caution); severe renal failure (dose-adjust most agents; linagliptin = NO dose adjustment needed)",
    "Nasopharyngitis, UTI, rare pancreatitis, arthralgia (joint pain), increased HF hospitalization (saxagliptin, alogliptin)",
    [
        "Linagliptin is the ONLY DPP-4 inhibitor that does NOT require dose adjustment in renal failure β€” excreted via bile/feces, not kidneys.",
        "Saxagliptin and alogliptin associated with increased heart failure hospitalization risk β€” avoid in HF patients.",
    ]
)

drug_section(
    7, "GLP-1 RECEPTOR AGONISTS β€” Exenatide, Liraglutide, Dulaglutide, Semaglutide, Lixisenatide", colors.HexColor("#4a148c"),
    [
        ["Mechanism of Action", "Mimic incretin hormone GLP-1 β†’ glucose-dependent insulin secretion ↑, glucagon ↓, gastric emptying delayed, satiety ↑ (weight loss)"],
        ["Route", "Subcutaneous injection (semaglutide also available as oral)"],
        ["Hypoglycemia risk", "LOW (glucose-dependent)"],
        ["Effect on weight", "Significant WEIGHT LOSS (2–5 kg)"],
        ["CV benefit", "Liraglutide (LEADER trial) and semaglutide (SUSTAIN trial) β€” proven CV mortality reduction"],
    ],
    "Type 2 DM + obesity; T2DM + CVD; T2DM + CKD",
    "History of medullary thyroid carcinoma (MTC) or MEN type 2 (C-cell tumors in animal studies); active pancreatitis; pregnancy",
    "Nausea, vomiting, diarrhea (most common, often transient), pancreatitis (rare), potential thyroid C-cell tumors",
    [
        "GLP-1 agonists = weight loss + CV benefit. Preferred in T2DM with established CVD or obesity.",
        "Contraindication: personal/family history of medullary thyroid carcinoma or MEN2.",
        "Incretin effect: oral glucose stimulates MORE insulin than IV glucose due to gut-released GLP-1/GIP β€” this effect is reduced in T2DM.",
    ]
)

drug_section(
    8, "SGLT-2 INHIBITORS (Gliflozins) β€” Empagliflozin, Canagliflozin, Dapagliflozin, Ertugliflozin", colors.HexColor("#bf360c"),
    [
        ["Mechanism of Action", "Inhibit SGLT-2 (sodium-glucose cotransporter-2) in proximal convoluted tubule β†’ block renal glucose reabsorption β†’ glucosuria β†’ lower blood glucose (insulin-independent)"],
        ["Hypoglycemia risk", "LOW (insulin-independent mechanism)"],
        ["Effect on weight", "WEIGHT LOSS (osmotic diuresis, caloric loss)"],
        ["BP effect", "Reduces blood pressure"],
        ["CV benefit", "Empagliflozin (EMPA-REG), Canagliflozin (CANVAS), Dapagliflozin (DECLARE) β€” reduce MACE and HF hospitalization"],
        ["HF benefit", "Reduce HF hospitalization even in non-diabetics (now indicated for HFrEF independently)"],
    ],
    "Type 2 DM + CVD; T2DM + HF; T2DM + CKD; HFrEF (dapagliflozin, empagliflozin β€” even without diabetes)",
    "eGFR &lt;45 mL/min (canagliflozin &lt;30); Type 1 DM (euglycemic DKA risk); recurrent genitourinary infections; pregnancy",
    "Genital mycotic infections (most common), UTI, EUGLYCEMIC DKA (glucose may be normal), Fournier's gangrene (rare, necrotizing fasciitis of perineum), bone fractures/limb amputation (canagliflozin)",
    [
        "SGLT-2 inhibitors cause glucosuria WITHOUT hypoglycemia because the mechanism is insulin-independent.",
        "EUGLYCEMIC DKA: DKA may occur with normal/near-normal glucose β€” classic USMLE trap. Suspect in SGLT-2 inhibitor users with anion gap metabolic acidosis.",
        "Fournier's gangrene: FDA black box warning β€” necrotizing fasciitis of the genital/perineal area. Rare but life-threatening.",
    ]
)

drug_section(
    9, "AMYLIN ANALOG β€” Pramlintide", colors.HexColor("#37474f"),
    [
        ["Mechanism of Action", "Synthetic amylin analog β†’ delays gastric emptying, decreases postprandial glucagon secretion, increases satiety"],
        ["Route", "Subcutaneous injection immediately BEFORE meals"],
        ["Hypoglycemia risk", "Moderate (used with insulin β€” reduce insulin dose!)"],
    ],
    "Adjunct to mealtime insulin in Type 1 AND Type 2 DM",
    "Diabetic gastroparesis (delays gastric emptying further), hypoglycemic unawareness, cresol hypersensitivity",
    "Nausea, anorexia, vomiting",
    [
        "When starting pramlintide, REDUCE mealtime insulin dose by 50% to avoid severe hypoglycemia.",
        "CANNOT be mixed in the same syringe as insulin.",
    ]
)

story.append(PageBreak())

# ── PART 4: Quick Comparison Table ────────────────────────────────
story.append(part_heading("PART 4 β€” QUICK COMPARISON TABLE (HIGH YIELD)"))
story.append(sp())
story.append(make_table(
    ["Drug Class", "MOA", "Hypoglycemia", "Weight", "Key ADR", "Contraindication"],
    [
        ["Metformin", "↓ hepatic gluconeogenesis (AMPK)", "None", "Neutral/↓", "Lactic acidosis", "Renal failure"],
        ["Sulfonylureas", "↑ insulin secretion (KATP block)", "HIGH", "↑", "Hypoglycemia", "Renal failure / sulfa allergy"],
        ["Meglitinides", "↑ insulin (fast/short KATP block)", "Low", "↑", "Hypoglycemia", "Hepatic failure"],
        ["TZDs", "PPAR-Ξ³ agonist, ↑ insulin sensitivity", "None", "↑↑", "Edema, fractures, HF", "Heart failure"],
        ["Ξ±-Glucosidase inhibitors", "↓ carb digestion/absorption", "None", "Neutral", "Flatulence", "IBD, renal failure"],
        ["DPP-4 inhibitors", "↑ GLP-1/GIP (incretin)", "Low", "Neutral", "Nasopharyngitis", "Pancreatitis hx"],
        ["GLP-1 agonists", "↑ glucose-dep. insulin, ↓ glucagon", "Low", "↓↓", "Nausea, pancreatitis", "MTC, MEN2"],
        ["SGLT-2 inhibitors", "↓ renal glucose reabsorption", "Low", "↓", "Genital infections, euDKA", "eGFR &lt;45, T1DM"],
        ["Insulin", "Receptor tyrosine kinase activation", "HIGH", "↑", "Hypoglycemia, lipodystrophy", "Hypoglycemia"],
        ["Pramlintide", "Amylin analog: ↓ glucagon, ↓ gastric emptying", "Moderate", "↓", "Nausea, vomiting", "Gastroparesis"],
    ],
    col_widths=[3.5*cm, 4.5*cm, 2.2*cm, 1.8*cm, 3.5*cm, 3.1*cm]
))
story.append(PageBreak())

# ── PART 5: Treatment Algorithm ───────────────────────────────────
story.append(part_heading("PART 5 β€” TREATMENT ALGORITHM"))
story.append(sp())

story.append(Paragraph("Type 1 DM", st_h2))
story.append(green_box("Insulin is MANDATORY in Type 1 DM. No oral agents work alone."))
story.append(make_table(
    ["Regimen", "Details"],
    [
        ["Basal-Bolus (Ideal)", "Long-acting basal (glargine/detemir) + rapid-acting bolus (lispro/aspart) before each meal"],
        ["Split-Mixed", "NPH + Regular insulin twice daily (less physiologic)"],
        ["Insulin pump (CSII)", "Continuous subcutaneous insulin infusion using rapid-acting insulin"],
        ["Add pramlintide", "As adjunct to mealtime insulin for postprandial control"],
    ],
    col_widths=[4.5*cm, 12.1*cm]
))
story.append(sp())

story.append(Paragraph("Type 2 DM β€” ADA Stepwise Approach", st_h2))
story.append(make_table(
    ["Step", "Action"],
    [
        ["Step 1", "Lifestyle modification β€” diet, exercise, weight loss"],
        ["Step 2", "Metformin (first-line drug, unless contraindicated)"],
        ["Step 3 β€” CVD/HF", "Add SGLT-2 inhibitor OR GLP-1 agonist (CV/renal benefit proven)"],
        ["Step 3 β€” CKD", "Add SGLT-2 inhibitor (empagliflozin, canagliflozin)"],
        ["Step 3 β€” Obesity", "Add GLP-1 agonist or SGLT-2 inhibitor (weight loss benefit)"],
        ["Step 3 β€” Cost concern", "Add sulfonylurea or TZD"],
        ["Step 4", "Triple combination or add insulin if HbA1c remains uncontrolled"],
    ],
    col_widths=[4.5*cm, 12.1*cm]
))
story.append(sp())

story.append(Paragraph("Glycemic Targets", st_h2))
story.append(make_table(
    ["Parameter", "Target"],
    [
        ["HbA1c (most patients)", "&lt;7%"],
        ["HbA1c (elderly/comorbidities/hypoglycemia unawareness)", "&lt;8%"],
        ["Fasting plasma glucose", "80–130 mg/dL"],
        ["2-h postprandial glucose", "&lt;180 mg/dL"],
        ["Blood pressure", "&lt;130/80 mmHg"],
        ["LDL cholesterol", "&lt;70 mg/dL (with CVD) / &lt;100 mg/dL (without CVD)"],
    ],
    col_widths=[8*cm, 8.6*cm]
))
story.append(sp())

story.append(Paragraph("DKA (Diabetic Ketoacidosis) β€” Emergency Treatment", st_h2))
story.append(make_table(
    ["Step", "Treatment"],
    [
        ["1. Fluids", "0.9% NaCl IV β€” 1 L over 1st hour, then guided by clinical status"],
        ["2. Insulin", "Regular insulin IV infusion (0.1 units/kg/h); NOT subcutaneous in acute DKA"],
        ["3. Potassium", "Monitor K+ closely β€” insulin drives K+ into cells; replace if K+ &lt;5.5 mEq/L"],
        ["4. Bicarbonate", "Only if pH &lt;6.9 (controversial)"],
        ["5. Treat precipitant", "Infection, missed insulin dose, MI, stress"],
    ],
    col_widths=[3.5*cm, 13.1*cm]
))
story.append(PageBreak())

# ── PART 6: Complications ─────────────────────────────────────────
story.append(part_heading("PART 6 β€” COMPLICATIONS OF DM & PHARMACOLOGICAL RELEVANCE"))
story.append(sp())

story.append(Paragraph("Microvascular Complications", st_h2))
story.append(make_table(
    ["Complication", "Pharmacological Approach"],
    [
        ["Retinopathy", "Tight glycemic control (HbA1c ≀7%); laser photocoagulation; anti-VEGF injections (severe)"],
        ["Nephropathy", "SGLT-2 inhibitors + ACE inhibitors/ARBs (first-line renoprotective); tight BP control"],
        ["Neuropathy (painful)", "Glycemic control + Gabapentin/Pregabalin, Duloxetine, Amitriptyline, Capsaicin"],
    ],
    col_widths=[4*cm, 12.6*cm]
))
story.append(sp())

story.append(Paragraph("Macrovascular Complications", st_h2))
story.append(make_table(
    ["Complication", "Pharmacological Approach"],
    [
        ["Coronary artery disease / Stroke", "GLP-1 agonists + SGLT-2 inhibitors (proven CV benefit); statins; aspirin; BP control"],
        ["Hypertension in DM", "ACE inhibitors or ARBs (first-line β€” also renoprotective); thiazides, CCBs"],
        ["Dyslipidemia", "High-intensity statin (atorvastatin 40–80 mg) for all T2DM patients >40 yr with CVD risk"],
        ["Heart failure in DM", "SGLT-2 inhibitors (dapagliflozin, empagliflozin) reduce HF hospitalization + mortality"],
    ],
    col_widths=[4.5*cm, 12.1*cm]
))
story.append(PageBreak())

# ── PART 7: High-Yield Pearls ──────────────────────────────────────
story.append(part_heading("PART 7 β€” HIGH-YIELD EXAM PEARLS"))
story.append(sp())

story.append(Paragraph("FMGE Favorites", st_h2))
fmge_pearls = [
    ("1", "First-line drug for Type 2 DM", "Metformin"),
    ("2", "Drug causing SIADH", "Chlorpropamide (1st gen sulfonylurea)"),
    ("3", "Lactic acidosis risk", "Metformin (especially in renal failure)"),
    ("4", "Contraindicated in heart failure", "TZDs β€” pioglitazone, rosiglitazone"),
    ("5", "Peakless long-acting insulin", "Glargine (insulin glargine)"),
    ("6", "Most potent sulfonylurea", "Glibenclamide (Glyburide)"),
    ("7", "Antidiabetic causing weight loss", "GLP-1 agonists, SGLT-2 inhibitors"),
    ("8", "Euglycemic DKA", "SGLT-2 inhibitors"),
    ("9", "Contraindicated in medullary thyroid cancer", "GLP-1 receptor agonists"),
    ("10", "DPP-4 inhibitor safe in renal failure", "Linagliptin (no dose adjustment needed)"),
    ("11", "Antidiabetic causing disulfiram-like reaction", "Chlorpropamide + alcohol"),
    ("12", "Antidiabetic causing bladder cancer", "Pioglitazone (long-term use)"),
    ("13", "Insulin that can be given IV", "Regular insulin ONLY"),
    ("14", "Drug used in PCOS", "Metformin"),
    ("15", "Hypoglycemia treatment when on acarbose", "Dextrose (NOT sucrose)"),
]
story.append(make_table(
    ["#", "Question", "Answer"],
    fmge_pearls,
    col_widths=[1*cm, 8*cm, 7.6*cm]
))
story.append(sp())

story.append(Paragraph("USMLE Favorites", st_h2))
usmle_pearls = [
    ("1", "CV mortality reduction in T2DM", "Metformin (UKPDS), Liraglutide (LEADER trial), Empagliflozin (EMPA-REG)"),
    ("2", "HF hospitalization reduction", "SGLT-2 inhibitors β€” even in non-diabetic HFrEF patients"),
    ("3", "Pancreatitis association", "GLP-1 agonists and DPP-4 inhibitors"),
    ("4", "Fournier's gangrene (necrotizing fasciitis)", "SGLT-2 inhibitors β€” FDA black box warning"),
    ("5", "Hold before IV contrast", "Metformin β€” 48h hold, risk of lactic acidosis"),
    ("6", "Reduce insulin dose by 50% when adding", "Pramlintide β€” severe hypoglycemia risk"),
    ("7", "Glyburide contraindicated in", "Pregnancy β€” crosses placenta; use insulin instead"),
    ("8", "Sulfonylurea mechanism", "Block KATP channels on pancreatic beta cells"),
    ("9", "GLP-1 agonist contraindication", "MTC or MEN type 2 (C-cell tumor risk)"),
    ("10", "Drug effective in T2DM + HFrEF (non-DM too)", "Dapagliflozin, empagliflozin (SGLT-2 inhibitors)"),
    ("11", "Incretin effect definition", "Oral glucose β†’ more insulin than IV glucose; due to GLP-1/GIP; reduced in T2DM"),
    ("12", "Cannot mix in same syringe as insulin", "Pramlintide; also glargine cannot mix with other insulins"),
]
story.append(make_table(
    ["#", "Question/Scenario", "Answer"],
    usmle_pearls,
    col_widths=[1*cm, 8.5*cm, 7.1*cm]
))
story.append(PageBreak())

# ── PART 8: Drug Interactions ─────────────────────────────────────
story.append(part_heading("PART 8 β€” DRUG–DRUG INTERACTIONS"))
story.append(sp())
story.append(make_table(
    ["Drug", "Interacting Agent", "Mechanism", "Effect"],
    [
        ["Sulfonylureas", "Fluconazole / CYP2C9 inhibitors", "Inhibit CYP2C9 metabolism of sulfonylurea", "↑ Sulfonylurea levels β†’ hypoglycemia"],
        ["Sulfonylureas", "NSAIDs (phenylbutazone)", "Displace from protein binding + inhibit metabolism", "↑ Hypoglycemia risk"],
        ["Metformin", "IV iodinated contrast", "Contrast β†’ nephrotoxicity β†’ impaired metformin excretion", "Lactic acidosis β€” HOLD metformin"],
        ["Insulin", "Alcohol", "Alcohol inhibits hepatic gluconeogenesis", "Potentiates hypoglycemia (especially fasting)"],
        ["Chlorpropamide", "Alcohol", "Disulfiram-like reaction", "Flushing, nausea, vomiting, tachycardia"],
        ["Saxagliptin / Alogliptin", "None specific", "Unknown mechanism", "Increased HF hospitalization risk"],
        ["Canagliflozin", "Rifampin (inducer)", "Induces UGT enzymes β†’ ↑ canagliflozin clearance", "Reduced efficacy β€” increase dose if needed"],
        ["Thiazolidinediones", "Insulin", "Additive fluid retention", "Increased edema and HF risk"],
        ["GLP-1 agonists", "Oral medications (any)", "Delayed gastric emptying β†’ delayed oral drug absorption", "May alter absorption of other oral drugs"],
    ],
    col_widths=[3.5*cm, 4*cm, 5*cm, 4.1*cm]
))
story.append(sp())

# ── Footer / Sources ─────────────────────────────────────────────
story.append(hr())
story.append(Paragraph(
    "<b>Sources:</b> Lippincott Illustrated Reviews Pharmacology 7th Ed. | "
    "Barash, Cullen & Stoelting's Clinical Anesthesia 9th Ed. | "
    "ADA Standards of Medical Care in Diabetes 2024",
    st_src
))
story.append(Paragraph("Compiled by Orris Medical Notes β€” For Educational Use Only", st_src))

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

cd /tmp/workspace/diabetes-notes && python3 generate_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/diabetes-notes/DM_Pharmacology_Notes_FMGE_USMLE.pdf

Your PDF is ready! Here's the download link:

DM Pharmacology Notes FMGE USMLE

PDF Document Β· PDF


What's included in the PDF (8 sections, color-coded):
SectionContent
Part 1Overview, Types of DM, Diagnostic Criteria (ADA)
Part 2Insulin - MOA, all preparations table, indications, adverse effects, intensive vs. standard therapy
Part 3All 9 drug classes - Metformin, Sulfonylureas, Meglitinides, TZDs, Alpha-glucosidase inhibitors, DPP-4 inhibitors, GLP-1 agonists, SGLT-2 inhibitors, Pramlintide - each with MOA, indications, contraindications, ADRs, and exam pearls
Part 4Master comparison table of all drug classes
Part 5Treatment algorithm (T1DM, T2DM stepwise), glycemic targets, DKA emergency treatment
Part 6Complications and their pharmacological management
Part 715 FMGE favorites + 12 USMLE favorites in Q&A format
Part 8Drug-drug interactions table
This is a shared conversation. Sign in to Orris to start your own chat.