~/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 & 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 <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 <45 mL/min (canagliflozin <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 <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)", "<7%"],
["HbA1c (elderly/comorbidities/hypoglycemia unawareness)", "<8%"],
["Fasting plasma glucose", "80β130 mg/dL"],
["2-h postprandial glucose", "<180 mg/dL"],
["Blood pressure", "<130/80 mmHg"],
["LDL cholesterol", "<70 mg/dL (with CVD) / <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+ <5.5 mEq/L"],
["4. Bicarbonate", "Only if pH <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}")