Diabetic mellitus Notes
Detail pdf of diabetes mellitus
ls /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"
mkdir -p /home/daytona/workspace/diabetes-notes && python3 -c "from reportlab.li…
~/diabetes-notes/build_dm_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 ListFlowable, ListItem
OUTPUT = "/home/daytona/workspace/diabetes-notes/Diabetes_Mellitus_Notes.pdf"
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
rightMargin=2*cm, leftMargin=2*cm,
topMargin=2.5*cm, bottomMargin=2.5*cm,
title="Diabetes Mellitus – Comprehensive Clinical Notes",
author="Orris Medical Library"
)
W, H = A4
styles = getSampleStyleSheet()
# ── Custom styles ────────────────────────────────────────────────────────────
BLUE = colors.HexColor("#1565C0")
DBLUE = colors.HexColor("#0D47A1")
TEAL = colors.HexColor("#00695C")
RED = colors.HexColor("#B71C1C")
AMBER = colors.HexColor("#E65100")
LGREY = colors.HexColor("#F5F5F5")
MGREY = colors.HexColor("#BDBDBD")
WHITE = colors.white
cover_title = ParagraphStyle("cover_title", fontSize=30, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=6)
cover_sub = ParagraphStyle("cover_sub", fontSize=14, textColor=WHITE,
fontName="Helvetica", alignment=TA_CENTER, spaceAfter=4)
cover_note = ParagraphStyle("cover_note", fontSize=10, textColor=colors.HexColor("#CFD8DC"),
fontName="Helvetica-Oblique", alignment=TA_CENTER)
h1 = ParagraphStyle("h1", fontSize=16, textColor=WHITE, fontName="Helvetica-Bold",
spaceBefore=14, spaceAfter=6, leftIndent=0, backColor=BLUE,
borderPad=(6, 6, 6, 6), leading=22)
h2 = ParagraphStyle("h2", fontSize=13, textColor=DBLUE, fontName="Helvetica-Bold",
spaceBefore=10, spaceAfter=4, borderPad=2)
h3 = ParagraphStyle("h3", fontSize=11, textColor=TEAL, fontName="Helvetica-Bold",
spaceBefore=7, spaceAfter=3)
body = ParagraphStyle("body", fontSize=10, fontName="Helvetica",
leading=15, spaceAfter=5, alignment=TA_JUSTIFY)
bullet = ParagraphStyle("bullet", fontSize=10, fontName="Helvetica",
leading=14, spaceAfter=3, leftIndent=14, bulletIndent=4)
note_box = ParagraphStyle("note_box", fontSize=9.5, fontName="Helvetica-Oblique",
leading=14, textColor=colors.HexColor("#37474F"),
backColor=colors.HexColor("#E3F2FD"), borderPad=6,
spaceAfter=6)
warn_box = ParagraphStyle("warn_box", fontSize=9.5, fontName="Helvetica-Bold",
leading=14, textColor=RED,
backColor=colors.HexColor("#FFEBEE"), borderPad=6,
spaceAfter=6)
small = ParagraphStyle("small", fontSize=8.5, fontName="Helvetica", leading=12,
textColor=colors.grey, spaceAfter=3)
def H1(text): return Paragraph(f" {text}", h1)
def H2(text): return Paragraph(text, h2)
def H3(text): return Paragraph(text, h3)
def B(text): return Paragraph(text, body)
def BU(text): return Paragraph(f"• {text}", bullet)
def NOTE(text): return Paragraph(f"📋 {text}", note_box)
def WARN(text): return Paragraph(f"⚠ {text}", warn_box)
def HR(): return HRFlowable(width="100%", thickness=0.5, color=MGREY, spaceAfter=4)
def SP(h=6): return Spacer(1, h)
def section_table(rows, col_widths=None):
"""Helper: coloured table."""
if col_widths is None:
col_widths = [4.5*cm, 11*cm]
t = Table(rows, colWidths=col_widths, repeatRows=1)
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), BLUE),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [LGREY, WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
return t
def wide_table(rows, col_widths):
t = Table(rows, colWidths=col_widths, repeatRows=1)
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), DBLUE),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [LGREY, WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
return t
# ─────────────────────────────────────────────────────────────────────────────
story = []
# ══════════════════════ COVER PAGE ═════════════════════════════════════════
cover_data = [[
Paragraph("DIABETES MELLITUS", cover_title),
Paragraph("Comprehensive Clinical Notes", cover_sub),
Paragraph("Based on Harrison's Principles of Internal Medicine 22e (2025) •\nRobbins & Kumar Basic Pathology • Tintinalli's Emergency Medicine •\nGoodman & Gilman's Pharmacology • Washington Manual of Medical Therapeutics", cover_note),
]]
cover_tbl = Table([[Paragraph("DIABETES MELLITUS", cover_title)],
[Paragraph("Comprehensive Clinical Notes", cover_sub)],
[Paragraph("Based on Harrison's Principles of Internal Medicine 22e (2025) | Robbins & Kumar Basic Pathology\nTintinalli's Emergency Medicine | Goodman & Gilman's Pharmacology\nWashington Manual of Medical Therapeutics | Creasy & Resnik's Maternal-Fetal Medicine", cover_note)]],
colWidths=[16.5*cm])
cover_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), BLUE),
("TOPPADDING", (0,0), (-1,-1), 18),
("BOTTOMPADDING",(0,0), (-1,-1), 18),
("LEFTPADDING", (0,0), (-1,-1), 20),
("RIGHTPADDING", (0,0), (-1,-1), 20),
("ROUNDEDCORNERS", (0,0), (-1,-1), 8),
]))
story += [SP(60), cover_tbl, SP(30)]
date_p = Paragraph("Prepared: July 2026 • Orris AI Medical Notes", small)
story += [date_p, PageBreak()]
# ══════════════════════ 1. DEFINITION & EPIDEMIOLOGY ══════════════════════
story += [H1("1. DEFINITION & EPIDEMIOLOGY"), SP(4)]
story += [B("Diabetes mellitus (DM) is a group of common metabolic disorders that share the phenotype of "
"hyperglycemia. It results from defects in insulin secretion, insulin action, or both. "
"Chronic hyperglycemia leads to damage, dysfunction, and failure of various organs — especially "
"the eyes, kidneys, nerves, heart, and blood vessels."), SP(4)]
epi_rows = [
[Paragraph("Parameter", h3), Paragraph("Data", h3)],
["Global prevalence (2021)", "537 million adults; projected 783 million by 2045 (IDF)"],
["USA prevalence", "~34 million (10.5% of population); ~1 in 3 undiagnosed"],
["Type 2 DM share", "~90–95% of all DM cases"],
["Type 1 DM share", "~5–10%; incidence rising especially in children <5 years"],
["Highest risk groups", "American Indians/Alaska Natives (14.5%), Hispanic (12.5%), Non-Hispanic Black (11.7%)"],
["Leading complications", "CV disease (main cause of death), retinopathy, nephropathy, neuropathy"],
]
story += [section_table(epi_rows), SP(8)]
# ══════════════════════ 2. CLASSIFICATION ══════════════════════════════════
story += [H1("2. CLASSIFICATION (ADA 2024)"), SP(4)]
story += [B("The American Diabetes Association (ADA) recognises four principal categories:"), SP(4)]
class_rows = [
[Paragraph("Type", h3), Paragraph("Key Features", h3)],
["Type 1 DM (T1DM)",
"Autoimmune destruction of β-cells → absolute insulin deficiency. "
"Accounts for 5–10% of DM. Autoantibodies: islet-cell Ab (ICA), anti-GAD65, anti-IA-2, anti-insulin Ab (IAA), anti-ZnT8. "
"HLA-DR3 / DR4 association. Often presents in lean young patients with DKA."],
["Type 2 DM (T2DM)",
"Progressive β-cell failure on background of insulin resistance. "
"90–95% of cases. Strong association with obesity, sedentary lifestyle, age >40. "
"Usually does NOT present with ketoacidosis. Genetic predisposition: concordance ~60–90% in MZ twins."],
["Gestational DM (GDM)",
"Diabetes first diagnosed in 2nd–3rd trimester; not overt DM prior to pregnancy. "
"Increases risk of macrosomia, neonatal hypoglycaemia, pre-eclampsia, and future T2DM in mother."],
["Other Specific Types",
"MODY (monogenic, AR/AD inheritance), pancreatic disease (chronic pancreatitis, cystic fibrosis, haemochromatosis), "
"drug-induced (glucocorticoids, thiazides, antipsychotics, antiretrovirals, tacrolimus), "
"endocrinopathies (Cushing's, acromegaly, phaeochromocytoma, glucagonoma)."],
]
story += [section_table(class_rows, col_widths=[4*cm, 12*cm]), SP(8)]
story += [NOTE("LADA (Latent Autoimmune Diabetes of Adults): slowly progressive autoimmune DM in adults; "
"initially misclassified as T2DM. Anti-GAD antibodies are positive. Requires insulin sooner."), SP(6)]
# ══════════════════════ 3. PATHOPHYSIOLOGY ═════════════════════════════════
story += [H1("3. PATHOPHYSIOLOGY"), SP(4)]
story += [H2("3.1 Type 1 DM"), SP(3)]
story += [B("T1DM is a multigenic, immune-mediated disorder in which T-cell-mediated autoimmune destruction "
"of pancreatic β-cells leads to absolute insulin deficiency. Key steps:"), SP(3)]
for txt in [
"Genetic susceptibility: HLA-DR3, DR4 (linked to DQ2/DQ8) confer highest risk; >60 susceptibility loci identified.",
"Environmental trigger (possible enteroviruses, dietary factors) initiates autoimmunity in genetically susceptible individuals.",
"Insulitis: lymphocytic infiltration of islets. Autoantibodies (anti-GAD65, ICA, IA-2, ZnT8) precede clinical onset.",
"Progressive β-cell loss; clinical DM appears when ~90% of β-cell mass is destroyed.",
"Absolute insulin deficiency → unchecked glucagon → glycogenolysis, gluconeogenesis, lipolysis → DKA.",
]:
story += [BU(txt)]
story += [SP(6)]
story += [H2("3.2 Type 2 DM"), SP(3)]
story += [B("T2DM results from two major defects: peripheral insulin resistance and progressive β-cell failure. "
"The 'ominous octet' (DeFronzo) includes:"), SP(3)]
octet = [
["Organ/Tissue", "Defect in T2DM"],
["Pancreatic β-cells", "Impaired insulin secretion (1st and 2nd phase)"],
["Liver", "Increased hepatic glucose production; gluconeogenesis ↑"],
["Skeletal Muscle", "Reduced glucose uptake (GLUT-4 translocation impaired)"],
["Adipose Tissue", "Increased lipolysis → elevated free fatty acids → lipotoxicity"],
["Kidney", "Increased glucose reabsorption (SGLT-2 upregulation)"],
["Brain", "Insulin resistance in CNS; impaired satiety signalling"],
["GI Tract", "Reduced incretin (GLP-1, GIP) secretion/effect"],
["α-cells (Pancreas)", "Excess glucagon secretion → hepatic glucose output ↑"],
]
story += [wide_table(octet, [5*cm, 11*cm]), SP(6)]
story += [B("Insulin resistance activates compensatory hyperinsulinaemia. Over years, β-cells 'burn out', "
"insulin secretion falls, and frank T2DM develops. Obesity (especially visceral adiposity) drives "
"insulin resistance via adipokines (↓ adiponectin, ↑ TNF-α, IL-6, resistin) and lipotoxicity."), SP(6)]
# ══════════════════════ 4. DIAGNOSIS ═══════════════════════════════════════
story += [H1("4. DIAGNOSIS (ADA 2024 Criteria)"), SP(4)]
diag_rows = [
["Test", "Prediabetes", "Diabetes"],
["Fasting Plasma Glucose (FPG)\n(fasting ≥8 h)", "100–125 mg/dL\n(5.6–6.9 mmol/L)", "≥126 mg/dL\n(≥7.0 mmol/L)"],
["2-h OGTT (75 g glucose)", "140–199 mg/dL\n(7.8–11.0 mmol/L)", "≥200 mg/dL\n(≥11.1 mmol/L)"],
["HbA1c", "5.7–6.4%\n(39–47 mmol/mol)", "≥6.5%\n(≥48 mmol/mol)"],
["Random Plasma Glucose", "—", "≥200 mg/dL + classic symptoms\n(polyuria, polydipsia, weight loss)"],
]
t_diag = Table(diag_rows, colWidths=[5*cm, 5*cm, 6.5*cm], repeatRows=1)
t_diag.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), RED),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#FFF8F8"), WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("ALIGN", (1,0), (-1,-1), "CENTER"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
story += [t_diag, SP(6)]
story += [WARN("In the absence of unequivocal hyperglycaemia symptoms, two abnormal tests on separate occasions are required for diagnosis."), SP(4)]
story += [NOTE("HbA1c reflects average blood glucose over ~3 months. Not valid in haemolytic anaemia, haemoglobinopathy, "
"G6PD deficiency, or recent blood transfusion. Use glucose-based criteria in these situations."), SP(8)]
# ══════════════════════ 5. CLINICAL FEATURES ═══════════════════════════════
story += [H1("5. CLINICAL FEATURES"), SP(4)]
cf_rows = [
["Feature", "Type 1 DM", "Type 2 DM"],
["Onset", "Acute / rapid (days–weeks)", "Insidious (years)"],
["Age", "Typically <30 years (can be any age)", "Usually >40 years (but rising in youth)"],
["Body habitus", "Lean / normal weight", "Usually obese (BMI >25)"],
["Classic 'Poly' symptoms", "Pronounced polyuria, polydipsia, polyphagia, weight loss", "Often asymptomatic or mild"],
["Ketosis tendency", "High (absolute insulin lack)", "Low (residual insulin present)"],
["Autoantibodies", "Positive (anti-GAD, ICA, IA-2, ZnT8)", "Negative"],
["C-peptide", "Very low / undetectable", "Normal or elevated (early); low (late)"],
["Acanthosis nigricans", "Absent", "Often present (insulin resistance marker)"],
["Family history", "10–15% 1st-degree relative", "Strong (60–90% MZ twin concordance)"],
["Insulin dependence", "Always required", "May not require insulin initially"],
]
t_cf = Table(cf_rows, colWidths=[4*cm, 6*cm, 6.5*cm], repeatRows=1)
t_cf.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), TEAL),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#E8F5E9"), WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
story += [t_cf, SP(8)]
story += [PageBreak()]
# ══════════════════════ 6. ACUTE COMPLICATIONS ═════════════════════════════
story += [H1("6. ACUTE COMPLICATIONS"), SP(4)]
story += [H2("6.1 Diabetic Ketoacidosis (DKA)"), SP(3)]
story += [B("DKA is a life-threatening emergency primarily of T1DM (but can occur in T2DM). "
"Absolute insulin deficiency + stress-hormone excess (glucagon, cortisol, catecholamines) leads to:"), SP(3)]
for txt in [
"Unrestrained lipolysis → free fatty acids → hepatic ketogenesis (acetoacetate, β-hydroxybutyrate)",
"Hyperglycaemia (usually >250 mg/dL) + osmotic diuresis → dehydration, electrolyte loss",
"High anion-gap metabolic acidosis (AG = Na – [Cl + HCO₃] normally 8–12; in DKA typically >20)",
"Precipitants: infection (most common), missed insulin, new-onset T1DM, surgery, MI, drugs",
]:
story += [BU(txt)]
story += [SP(4)]
dka_rows = [
["Parameter", "Mild DKA", "Moderate DKA", "Severe DKA"],
["Blood glucose", ">250 mg/dL", ">250 mg/dL", ">250 mg/dL"],
["Arterial pH", "7.25–7.30", "7.00–7.24", "<7.00"],
["Serum HCO₃", "15–18 mEq/L", "10–14 mEq/L", "<10 mEq/L"],
["Anion gap", ">10", ">12", ">12"],
["Mental status", "Alert", "Alert/drowsy", "Stupor/coma"],
["Urine/serum ketones", "Positive", "Positive", "Positive"],
]
t_dka = Table(dka_rows, colWidths=[3.5*cm, 3.3*cm, 3.3*cm, 3.3*cm], repeatRows=1)
t_dka.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), AMBER),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#FFF3E0"), WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("ALIGN", (1,0), (-1,-1), "CENTER"),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
story += [t_dka, SP(5)]
story += [H3("DKA Treatment (ABCDE approach)"), SP(3)]
for txt in [
"Fluids: 0.9% NaCl 1 L over 1 h, then 250–500 mL/h; switch to 0.45% NaCl if Na corrected, then D5W when glucose <250 mg/dL",
"Insulin: Regular insulin 0.1 unit/kg/h IV infusion (or 0.1 unit/kg bolus then 0.1 unit/kg/h); do NOT start insulin until K⁺ ≥3.5 mEq/L",
"Potassium: Replace K⁺ aggressively (target 4–5 mEq/L); insulin shifts K⁺ intracellularly",
"Bicarbonate: Only if pH <6.9 (controversial; 100 mEq NaHCO₃ over 2 h)",
"Phosphate: Replace if <1 mg/dL or cardiac dysfunction; risk of hypocalcaemia",
"Monitor: Glucose hourly, BMP q2–4h, watch for cerebral oedema (esp. in children)",
]:
story += [BU(txt)]
story += [SP(8)]
story += [H2("6.2 Hyperosmolar Hyperglycaemic State (HHS)"), SP(3)]
story += [B("Primarily T2DM. Characterised by severe hyperglycaemia (glucose 600–1200 mg/dL), "
"profound dehydration, hyperosmolality (>320 mOsm/kg), and minimal ketosis. "
"Occurs in older adults who cannot maintain fluid intake (stroke, infection, nursing-home residents). "
"Mortality higher than DKA (~15%). Treatment: aggressive IV fluids (0.9% then 0.45% NaCl), "
"insulin infusion (lower rate than DKA), electrolyte replacement."), SP(6)]
story += [H2("6.3 Hypoglycaemia"), SP(3)]
story += [B("Most common acute complication in insulin-treated patients. Symptoms appear at glucose <70 mg/dL "
"(adrenergic: sweating, tremor, palpitations, anxiety) and cognitive impairment at <55 mg/dL "
"(neuroglycopenic: confusion, seizure, coma)."), SP(3)]
for txt in [
"Causes: missed meal, excessive insulin/sulphonylurea dose, heavy exercise, alcohol",
"Rule of 15: 15 g fast-acting carb (4 glucose tablets or 150 mL juice), recheck in 15 min; repeat if <70 mg/dL",
"Severe (unable to self-treat): 1 mg glucagon IM/SC or IV dextrose (25–50 mL of D50W)",
"Hypoglycaemia unawareness: loss of adrenergic warning signs after repeated episodes; manage by relaxing glucose targets",
]:
story += [BU(txt)]
story += [SP(8), PageBreak()]
# ══════════════════════ 7. CHRONIC COMPLICATIONS ═══════════════════════════
story += [H1("7. CHRONIC COMPLICATIONS"), SP(4)]
story += [B("Chronic hyperglycaemia damages small (microvascular) and large (macrovascular) blood vessels via "
"four main mechanisms: (1) Advanced Glycation End-products (AGEs) → RAGE activation → ROS, TGF-β, VEGF; "
"(2) Polyol pathway (aldose reductase) → sorbitol accumulation → osmotic stress; "
"(3) PKC activation → vascular permeability, pro-inflammatory cytokines; "
"(4) Hexosamine pathway → altered gene expression."), SP(5)]
story += [H2("7.1 Microvascular Complications"), SP(3)]
story += [H3("Diabetic Retinopathy (DR)"), SP(2)]
for txt in [
"Leading cause of new-onset blindness in adults aged 20–74 years in developed countries",
"Non-proliferative DR (NPDR): microaneurysms, dot/blot haemorrhages, hard exudates, cotton-wool spots, intraretinal microvascular abnormalities (IRMA)",
"Proliferative DR (PDR): neovascularisation (driven by VEGF) → vitreous haemorrhage, tractional retinal detachment",
"Clinically significant macular oedema (CSME): main cause of visual loss",
"Screening: dilated fundus exam at T1DM diagnosis + 5 years, then annually; T2DM at diagnosis, then annually",
"Treatment: glycaemic control (1st line); laser photocoagulation (NPDR with CSME, PDR); intravitreal anti-VEGF (ranibizumab, bevacizumab); vitrectomy for severe PDR",
]:
story += [BU(txt)]
story += [SP(4)]
story += [H3("Diabetic Nephropathy (DKD)"), SP(2)]
for txt in [
"Occurs in 20–40% of diabetic patients; leading cause of end-stage renal disease (ESRD) worldwide",
"Stages: hyperfiltration → microalbuminuria (30–300 mg/day) → macroalbuminuria (>300 mg/day) → declining GFR → ESRD",
"Histology: Kimmelstiel-Wilson nodular glomerulosclerosis (pathognomonic), diffuse mesangial expansion, GBM thickening",
"Screening: UACR annually from diagnosis in T2DM; 5 years after T1DM diagnosis",
"Treatment: strict glycaemic control (HbA1c <7%); RAS blockade (ACE-i or ARB — first-line for albuminuria); BP <130/80 mmHg; "
"SGLT-2 inhibitors (empagliflozin, dapagliflozin) slow DKD progression independent of glucose lowering; "
"finerenone (non-steroidal MRA) reduces CKD progression and CV events in T2DM + CKD",
]:
story += [BU(txt)]
story += [SP(4)]
story += [H3("Diabetic Neuropathy"), SP(2)]
for txt in [
"Affects ~50% of patients with long-standing DM; correlates with duration and glycaemic control",
"Distal Symmetric Polyneuropathy (DSPN): most common; 'stocking-glove' sensory loss, burning/tingling, pain worse at night; "
"loss of protective sensation (LOPS) → foot ulcers → amputation",
"Autonomic Neuropathy: cardiovascular (resting tachycardia, orthostatic hypotension), gastroparesis (bloating, vomiting, hypoglycaemia), "
"bladder dysfunction (urinary retention), erectile dysfunction, anhidrosis, hypoglycaemia unawareness",
"Mononeuropathy: cranial nerve III (diplopia, ptosis without pupil involvement), carpal tunnel syndrome, common peroneal nerve palsy",
"Treatment: optimise glycaemia; pain management — duloxetine (SNRi, 1st line), pregabalin/gabapentin, amitriptyline, capsaicin cream, opioids (last resort)",
"Annual foot screening from DM diagnosis (T2DM) or 5 years post-diagnosis (T1DM)",
]:
story += [BU(txt)]
story += [SP(6)]
story += [H2("7.2 Macrovascular Complications"), SP(3)]
story += [B("Atherosclerotic cardiovascular disease (ASCVD) is the leading cause of morbidity and mortality in T2DM. "
"DM patients have 2–4× higher risk of MI and stroke. Pathogenesis involves endothelial dysfunction, "
"dyslipidaemia (↑ TG, ↓ HDL, small dense LDL), hypertension, and a pro-thrombotic state."), SP(3)]
macro_rows = [
["Complication", "Key Points"],
["Coronary Artery Disease", "2–4× increased risk; may be silent (autonomic neuropathy); aspirin 75–100 mg/day in high-risk; statins for all DM >40 years"],
["Peripheral Arterial Disease", "ABI screening; claudication → rest pain → gangrene; revascularisation + wound care; risk of amputation"],
["Cerebrovascular Disease", "Ischaemic stroke 2× more common; risk further multiplied with HTN and dyslipidaemia"],
["Heart Failure", "DM is independent HF risk factor; SGLT-2 inhibitors reduce HF hospitalisation and CV death (landmark EMPA-REG, DAPA-HF trials)"],
["Diabetic Foot", "Neuropathy + ischaemia + infection triad; Wagner classification grades 0–5; multidisciplinary team care"],
]
story += [wide_table(macro_rows, [4.5*cm, 12*cm]), SP(8), PageBreak()]
# ══════════════════════ 8. MANAGEMENT ══════════════════════════════════════
story += [H1("8. MANAGEMENT"), SP(4)]
story += [H2("8.1 Treatment Goals (ADA 2024)"), SP(3)]
goals_rows = [
["Parameter", "ADA Target"],
["HbA1c (most patients)", "<7.0% (<53 mmol/mol)"],
["HbA1c (selected patients*)", "<6.5% if achievable without hypoglycaemia"],
["HbA1c (elderly/comorbidities)", "<8.0% (relaxed goal)"],
["Pre-meal glucose", "80–130 mg/dL (4.4–7.2 mmol/L)"],
["Post-meal glucose (1–2 h peak)", "<180 mg/dL (<10.0 mmol/L)"],
["Blood pressure", "<130/80 mmHg"],
["LDL-cholesterol", "<100 mg/dL (<70 mg/dL in very high CV risk)"],
["Triglycerides", "<150 mg/dL"],
]
story += [section_table(goals_rows), SP(4)]
story += [small.clone("small2") and Paragraph("* Young patients, short disease duration, no significant CVD, low hypoglycaemia risk.", small), SP(6)]
story += [H2("8.2 Non-Pharmacological Treatment"), SP(3)]
story += [H3("Medical Nutrition Therapy (MNT)"), SP(2)]
for txt in [
"No single 'diabetic diet'; individualize based on metabolic goals, preferences, culture",
"Emphasise vegetables, whole grains, legumes, lean protein, low-fat dairy (Mediterranean or DASH pattern)",
"Limit refined carbohydrates, added sugars, saturated fats, trans fats, and alcohol",
"Carbohydrate counting essential for insulin dosing in T1DM; use glycaemic index to reduce postprandial spikes",
"Caloric restriction (500–750 kcal/day deficit) for weight loss in T2DM; 5–10% weight loss improves glycaemia significantly",
"Sodium <2300 mg/day; avoid fructose-sweetened beverages",
]:
story += [BU(txt)]
story += [SP(4)]
story += [H3("Physical Activity"), SP(2)]
for txt in [
"150+ min/week moderate-intensity aerobic exercise (brisk walking, cycling, swimming) spread over ≥3 days",
"Resistance training ≥2 days/week (improves insulin sensitivity, muscle glucose uptake)",
"Reduces HbA1c by ~0.5–1.0% in T2DM",
"Monitor glucose before/during/after exercise; risk of delayed hypoglycaemia especially with insulin therapy",
]:
story += [BU(txt)]
story += [SP(6)]
story += [H2("8.3 Pharmacological Treatment — Type 1 DM"), SP(3)]
story += [B("Lifelong insulin therapy is mandatory. Goal: mimic physiological insulin secretion (basal + bolus)."), SP(3)]
ins_rows = [
["Insulin Type", "Preparation", "Onset", "Peak", "Duration"],
["Rapid-acting", "Aspart, Lispro, Glulisine", "<15 min", "0.5–1.5 h", "3–5 h"],
["Short-acting", "Regular (Humulin R, Novolin)", "30–60 min", "2–3 h", "4–8 h"],
["Intermediate", "NPH (Humulin N)", "2–4 h", "4–10 h", "10–16 h"],
["Long-acting", "Glargine (U100/U300), Detemir", "2–4 h", "Flat (peakless)", "20–24 h / 42 h"],
["Ultra-long", "Degludec (Tresiba)", "1–9 h", "Flat", ">42 h"],
["Inhaled", "Afrezza (inhaled human)", "<15 min", "1–2 h", "~3 h"],
]
t_ins = Table(ins_rows, colWidths=[2.8*cm, 4*cm, 2.5*cm, 2.5*cm, 2.5*cm], repeatRows=1)
t_ins.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), DBLUE),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [LGREY, WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("ALIGN", (2,0), (-1,-1), "CENTER"),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
story += [t_ins, SP(5)]
story += [NOTE("Basal-bolus regimen: Long-acting insulin once/twice daily (basal) + rapid-acting with each meal (bolus). "
"CSII (insulin pump) + CGM (continuous glucose monitor) = most physiological approach; "
"AID (automated insulin delivery) systems further reduce hypoglycaemia risk."), SP(6)]
story += [H2("8.4 Pharmacological Treatment — Type 2 DM"), SP(3)]
story += [B("Stepwise approach: MNT + exercise → metformin (unless contraindicated) → add-on agents based on "
"comorbidities (ASCVD, HF, CKD, obesity) → insulin if needed."), SP(4), PageBreak()]
drug_rows = [
["Drug Class", "Example(s)", "Mechanism", "Key Benefits", "Key Risks/Cautions"],
["Biguanides\n(1st line)", "Metformin", "↓ hepatic glucose output\n(AMPK activation)", "Weight neutral/loss\nCV benefit (UKPDS)\nCheap", "GI upset; lactic acidosis (rare)\nHold if GFR <30, contrast, surgery"],
["Sulfonylureas", "Glipizide\nGlimepiride\nGlyburide", "↑ Insulin secretion\n(ATP-K⁺ channel blockade)", "Cheap\n↓ HbA1c 1–2%", "Hypoglycaemia\nWeight gain\nAvoid in elderly (glyburide)"],
["Meglitinides", "Repaglinide\nNateglinide", "Short-acting insulin secretagogues\n(same K⁺ channel)", "Flexible dosing\nPostprandial control", "Hypoglycaemia\nTake with meals"],
["Thiazolidinediones\n(TZDs)", "Pioglitazone\nRosiglitazone", "PPAR-γ agonist\n↑ Insulin sensitivity", "↓ TG (pioglitazone)\nPossible CV benefit", "Weight gain, oedema\nHF risk\nBone fractures\nBladder cancer (pioglitazone)"],
["DPP-4 Inhibitors\n(Gliptins)", "Sitagliptin\nSaxagliptin\nAlogliptin", "Inhibit GLP-1/GIP degradation\n→ ↑ insulin, ↓ glucagon", "Weight neutral\nLow hypoglycaemia risk", "Pancreatitis (rare)\nHF risk (saxagliptin)"],
["GLP-1 RAs", "Liraglutide\nSemaglutide\nDulaglutide\nExenatide", "Stimulate insulin secretion\n(glucose-dependent)\nSlow gastric emptying\nReduce appetite", "Weight loss\nCV protection (LEADER, SUSTAIN)\nRenal protection", "GI nausea/vomiting\nPancreatitis\nMTC risk (rodents)\nSubcutaneous injection"],
["SGLT-2 Inhibitors", "Empagliflozin\nDapagliflozin\nCanagliflozin", "Block renal glucose reabsorption\n→ glycosuria", "CV death ↓ (EMPA-REG)\nHF hospitalisation ↓\nRenal protection\nWeight loss", "UTI/genital mycosis\nDKA (euglycaemic)\nFractures (canagliflozin)\nAmputation risk"],
["Alpha-Glucosidase\nInhibitors", "Acarbose\nMiglitol", "Delay intestinal carb absorption", "Postprandial glucose\nNo weight gain", "GI flatulence, diarrhoea\nPoor GI tolerability"],
["Amylin Analogue", "Pramlintide", "↓ Glucagon, slow gastric emptying, ↓ appetite", "Weight loss\nPostprandial control", "GI nausea\nHypoglycaemia with insulin"],
["Insulin\n(T2DM)", "NPH, Glargine\nDegludec, Aspart\nPremixed", "Direct glucose lowering", "Universal efficacy\nNo ceiling dose", "Hypoglycaemia\nWeight gain\nInjection burden"],
]
t_drug = Table(drug_rows, colWidths=[2.8*cm, 2.5*cm, 3*cm, 3.2*cm, 3.5*cm], repeatRows=1)
t_drug.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), TEAL),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 8),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#E8F5E9"), WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 4),
("RIGHTPADDING", (0,0), (-1,-1), 4),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING",(0,0), (-1,-1), 3),
]))
story += [t_drug, SP(6)]
story += [NOTE("ADA 2024 recommends individualising therapy based on 4 key comorbidities: "
"(1) Established ASCVD or high CV risk → GLP-1 RA or SGLT-2i; "
"(2) Heart failure → SGLT-2i; "
"(3) CKD → SGLT-2i (if GFR ≥20) + finerenone; "
"(4) Obesity → GLP-1 RA or dual GIP/GLP-1 RA (tirzepatide)."), SP(8), PageBreak()]
# ══════════════════════ 9. MONITORING ══════════════════════════════════════
story += [H1("9. MONITORING & FOLLOW-UP"), SP(4)]
monitor_rows = [
["Parameter", "Frequency / Target"],
["HbA1c", "Every 3 months if not at goal; every 6 months if stable (<7%)"],
["Self-Monitoring Blood Glucose (SMBG)", "T1DM: ≥4–6 times/day (before meals & bedtime); T2DM: variable based on regimen"],
["Continuous Glucose Monitor (CGM)", "Recommended for all T1DM and many insulin-treated T2DM; Time-in-Range (TIR) target >70% (70–180 mg/dL)"],
["Lipid panel", "Annually; more frequent if not at goal"],
["Urine Albumin-Creatinine Ratio (UACR)", "Annually from T1DM diagnosis +5 yrs; T2DM from diagnosis"],
["Serum creatinine/eGFR", "Annually"],
["Dilated eye exam", "T1DM: 5 years after diagnosis, then annually; T2DM: at diagnosis, then annually"],
["Foot examination", "Every visit (visual) + comprehensive annual exam (monofilament, vibration, pulses)"],
["Blood pressure", "Every visit; target <130/80 mmHg"],
["Dental examination", "Twice yearly (periodontal disease more frequent in DM)"],
["Immunisations", "Influenza (annual), pneumococcal, Hepatitis B (if not vaccinated), COVID-19"],
["Depression/psychosocial", "Annual screening (PHQ-9)"],
]
story += [section_table(monitor_rows, col_widths=[5*cm, 11*cm]), SP(8)]
# ══════════════════════ 10. SPECIAL POPULATIONS ═══════════════════════════
story += [H1("10. SPECIAL POPULATIONS"), SP(4)]
story += [H2("10.1 Gestational Diabetes (GDM)"), SP(3)]
for txt in [
"Screen all pregnant women at 24–28 weeks with 75-g OGTT; earlier if high-risk (prior GDM, obesity, family history)",
"Diagnosis: fasting ≥92 mg/dL, 1h ≥180 mg/dL, or 2h ≥153 mg/dL (any one criterion)",
"Targets: fasting <95 mg/dL, 1h post-meal <140 mg/dL, 2h post-meal <120 mg/dL",
"MNT + exercise first; insulin if targets not met (metformin and glibenclamide are used but not FDA-approved for GDM)",
"Complications: macrosomia, neonatal hypoglycaemia, pre-eclampsia, shoulder dystocia, stillbirth",
"Post-partum: 75-g OGTT at 4–12 weeks; 50% lifetime risk of T2DM",
]:
story += [BU(txt)]
story += [SP(4)]
story += [H2("10.2 Diabetes in Children & Adolescents"), SP(3)]
for txt in [
"T1DM: increasing incidence especially <5 years; honeymoon period common; risk of DKA at presentation",
"T2DM in youth: rising with obesity epidemic; more aggressive disease course than adult T2DM; metformin + lifestyle is first-line",
"CGM and AID systems strongly recommended in T1DM youth; liraglutide and empagliflozin have paediatric indications",
"Growth and puberty monitoring essential; HbA1c target <7% (>13 years), <7.5% (6–12 years)",
]:
story += [BU(txt)]
story += [SP(4)]
story += [H2("10.3 Diabetes in the Elderly"), SP(3)]
for txt in [
"Relaxed glycaemic targets (HbA1c <8.0–8.5%) to avoid hypoglycaemia-related falls and cognitive impairment",
"Prefer agents with low hypoglycaemia risk (DPP-4i, GLP-1 RA, SGLT-2i) over sulfonylureas",
"Assess for frailty, polypharmacy, cognitive impairment, depression",
"Avoid SGLT-2i in recurrent UTI or volume-depleted elderly",
]:
story += [BU(txt)]
story += [SP(8), PageBreak()]
# ══════════════════════ 11. PREVENTION ═════════════════════════════════════
story += [H1("11. PREVENTION OF TYPE 2 DM"), SP(4)]
story += [B("The Diabetes Prevention Program (DPP) trial showed that lifestyle intervention (7% weight loss "
"+ 150 min/week exercise) reduced T2DM incidence by 58% in high-risk individuals with prediabetes, "
"outperforming metformin (31% reduction) over 3 years."), SP(4)]
prev_rows = [
["Intervention", "Risk Reduction", "Notes"],
["Intensive Lifestyle (DPP)", "58%", "5–7% weight loss + 150 min/week exercise; most effective"],
["Metformin", "31%", "Especially effective in BMI ≥35, age <60, history of GDM"],
["GLP-1 RAs (e.g. semaglutide)", "~60–70%", "Weight loss-driven; approved for obesity + prediabetes"],
["Acarbose", "25%", "Particularly useful in Asian populations"],
["Bariatric surgery", "Up to 80%", "In morbid obesity; can induce T2DM remission"],
]
t_prev = Table(prev_rows, colWidths=[5*cm, 3*cm, 8.5*cm], repeatRows=1)
t_prev.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), TEAL),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#E8F5E9"), WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
story += [t_prev, SP(8)]
# ══════════════════════ 12. HIGH-YIELD SUMMARY ════════════════════════════
story += [H1("12. HIGH-YIELD EXAM SUMMARY"), SP(4)]
story += [B("Key facts for rapid review:"), SP(3)]
hy_rows = [
["Topic", "High-Yield Fact"],
["DKA hallmark", "High AG metabolic acidosis + ketonaemia; glucose usually >250; bicarb <18; pH <7.3"],
["DKA vs HHS", "DKA = ketonaemia + acidosis (T1DM); HHS = extreme hyperglycaemia >600, no ketosis, hyperosmolar (T2DM)"],
["Kimmelstiel-Wilson", "Pathognomonic nodular glomerulosclerosis of diabetic nephropathy"],
["DCCT trial", "Intensive glycaemic control in T1DM → 76% ↓ retinopathy, 54% ↓ nephropathy, 60% ↓ neuropathy"],
["UKPDS trial", "Intensive control in T2DM → ↓ microvascular complications; metformin ↓ macrovascular events"],
["EMPA-REG OUTCOME", "Empagliflozin → ↓ CV death 38%, ↓ HF hospitalisation 35% in T2DM + CVD"],
["LEADER trial", "Liraglutide → ↓ MACE by 13% in T2DM + high CV risk"],
["Somogyi effect", "Rebound hyperglycaemia from nocturnal hypoglycaemia → ↑ counter-regulatory hormones"],
["Dawn phenomenon", "Early morning hyperglycaemia due to physiological surge in growth hormone/cortisol"],
["1st-line T2DM drug", "Metformin (unless GFR <30, acidosis, liver disease, contrast, unstable CHF)"],
["Insulin for T1DM", "Basal (glargine/degludec) + bolus (aspart/lispro/glulisine) regimen; adjust for carb intake"],
["Acanthosis nigricans", "Velvety hyperpigmentation at skin folds = marker of severe insulin resistance → screen for T2DM"],
["HbA1c interference", "Falsely low: haemolysis, sickle cell, G6PD deficiency. Falsely high: iron deficiency, renal failure"],
["Diabetic foot Wagner", "Grade 0: no ulcer; Grade 1: superficial; Grade 2: deep; Grade 3: osteomyelitis; Grade 4: partial gangrene; Grade 5: whole foot"],
["Anti-VEGF therapy", "Intravitreal ranibizumab/bevacizumab for diabetic macular oedema and proliferative DR"],
]
t_hy = Table(hy_rows, colWidths=[5.5*cm, 11*cm], repeatRows=1)
t_hy.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), RED),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 8.5),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#FFF8F8"), WHITE]),
("GRID", (0,0), (-1,-1), 0.4, MGREY),
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
]))
story += [t_hy, SP(8)]
# ─── Footer note ─────────────────────────────────────────────────────────────
story += [HR(), SP(4)]
story += [Paragraph(
"Sources: Harrison's Principles of Internal Medicine 22E (2025) | Robbins & Kumar Basic Pathology | "
"Tintinalli's Emergency Medicine | Goodman & Gilman's Pharmacological Basis of Therapeutics | "
"Washington Manual of Medical Therapeutics | Creasy & Resnik's Maternal-Fetal Medicine | ADA Standards of Care 2024. "
"These notes are for educational purposes only.",
small
)]
# ─── Build ────────────────────────────────────────────────────────────────────
doc.build(story)
print("PDF built successfully:", OUTPUT)
cd /home/daytona/workspace/diabetes-notes && python3 build_dm_pdf.py 2>&1
ls -lh /home/daytona/workspace/diabetes-notes/Diabetes_Mellitus_Notes.pdf
Diabetes Mellitus Notes
PDF Document · PDF
| Section | Content |
|---|---|
| 1. Definition & Epidemiology | Global prevalence, at-risk populations, burden of disease |
| 2. Classification | T1DM, T2DM, GDM, Other types (MODY, drug-induced, endocrinopathies); LADA note |
| 3. Pathophysiology | T1DM autoimmune mechanism (HLA, autoantibodies, insulitis); T2DM "ominous octet" table (8 defect organs) |
| 4. Diagnosis | ADA 2024 criteria table: FPG / OGTT / HbA1c / random glucose; prediabetes ranges |
| 5. Clinical Features | T1DM vs T2DM comparison table (11 parameters) |
| 6. Acute Complications | DKA (severity grading table, treatment protocol); HHS; Hypoglycaemia (Rule of 15) |
| 7. Chronic Complications | Microvascular (retinopathy, nephropathy - Kimmelstiel-Wilson, neuropathy); Macrovascular (CAD, PAD, stroke, HF, diabetic foot Wagner grading) |
| 8. Management | ADA treatment targets; MNT + exercise; Insulin types table (onset/peak/duration); Full T2DM drug class table (10 classes with mechanism, benefits, risks) |
| 9. Monitoring | All parameters with frequency - HbA1c, CGM (TIR), UACR, dilated eye exam, foot exam, etc. |
| 10. Special Populations | GDM (OGTT criteria, targets, complications); Paediatric DM; Elderly DM (relaxed targets) |
| 11. Prevention | DPP trial results; lifestyle vs metformin vs GLP-1 RA vs bariatric surgery |
| 12. High-Yield Exam Summary | 15-row rapid-review table (DCCT, UKPDS, EMPA-REG, LEADER, Dawn/Somogyi, HbA1c interference, etc.) |