Hey there
Sliding scale from harrison book
"Sliding scale, with short-acting or rapid-acting insulin alone, where no insulin is given unless the blood glucose is elevated, is inadequate for inpatient glucose management."
- Harrison's 22e, Chapter on Management of Diabetes in a Hospital Setting
| Component | Details |
|---|---|
| Basal insulin | SC long-acting insulin (e.g., glargine, detemir) |
| Prandial insulin | Rapid-acting insulin before meals (e.g., lispro, aspart) - based on anticipated carbohydrate intake |
| Corrective ("sliding") insulin | Added on top of the prandial dose, based on insulin sensitivity and current glucose |
| Setting | Target Glucose |
|---|---|
| Critically ill / non-critically ill | 7.8-10.0 mmol/L (140-180 mg/dL) |
| Selected patients (tighter control) | 6.1-7.8 mmol/L (110-140 mg/dL) - avoid hypoglycemia |
| Perioperative period | 4.4-10.0 mmol/L (80-180 mg/dL) |
Note: Strict glycemic control in acutely ill patients worsens outcomes and increases hypoglycemia risk. Very intensive control is not recommended.
"Avoid sliding scale in post-acute care settings" - it is associated with relatively high incidence of hypoglycemia, challenges of repeated glucose measurements, and high burden on caregivers.
Create a quick reference PDF comparing sliding scale vs basal-bolus insulin
ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace not found"
mkdir -p /home/daytona/workspace/insulin-pdf && python3 -c "import reportlab; print('reportlab ok')"
~/insulin-pdf/build_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import KeepTogether
OUTPUT = "/home/daytona/workspace/insulin-pdf/Sliding_Scale_vs_Basal_Bolus_Insulin.pdf"
# ── Colour palette ──────────────────────────────────────────────────────────
NAVY = colors.HexColor("#1A3A5C")
TEAL = colors.HexColor("#1B7A8C")
RED = colors.HexColor("#C0392B")
GREEN = colors.HexColor("#1E8449")
AMBER = colors.HexColor("#D68910")
LGRAY = colors.HexColor("#F4F6F7")
DGRAY = colors.HexColor("#555555")
WHITE = colors.white
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=1.8*cm, rightMargin=1.8*cm,
topMargin=1.8*cm, bottomMargin=1.8*cm,
)
styles = getSampleStyleSheet()
# Custom styles
def S(name, **kw):
return ParagraphStyle(name, **kw)
title_style = S("Title2", fontSize=20, leading=24, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=4)
subtitle_style = S("Sub", fontSize=10, leading=13, textColor=WHITE,
fontName="Helvetica", alignment=TA_CENTER)
h2 = S("H2", fontSize=13, leading=16, textColor=NAVY,
fontName="Helvetica-Bold", spaceBefore=10, spaceAfter=4)
body = S("Body2", fontSize=9, leading=13, textColor=DGRAY,
fontName="Helvetica", alignment=TA_JUSTIFY)
small = S("Small", fontSize=8, leading=11, textColor=DGRAY,
fontName="Helvetica-Oblique")
cell_hdr = S("CellHdr", fontSize=9, leading=11, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER)
cell_body = S("CellBody", fontSize=8.5, leading=12, textColor=DGRAY,
fontName="Helvetica", alignment=TA_LEFT)
cell_body_c = S("CellBodyC", fontSize=8.5, leading=12, textColor=DGRAY,
fontName="Helvetica", alignment=TA_CENTER)
verdict_bad = S("VBad", fontSize=9, leading=12, textColor=RED,
fontName="Helvetica-Bold", alignment=TA_CENTER)
verdict_good = S("VGood", fontSize=9, leading=12, textColor=GREEN,
fontName="Helvetica-Bold", alignment=TA_CENTER)
note_style = S("Note", fontSize=8, leading=11, textColor=DGRAY,
fontName="Helvetica-Oblique", alignment=TA_LEFT)
story = []
# ── TITLE BANNER ─────────────────────────────────────────────────────────────
banner_data = [[
Paragraph("Sliding Scale vs Basal-Bolus Insulin", title_style),
], [
Paragraph("Inpatient Diabetes Management — Quick Reference Card | Based on Harrison's Principles of Internal Medicine 22e (2025)", subtitle_style),
]]
banner = Table(banner_data, colWidths=[17.4*cm])
banner.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), NAVY),
("BACKGROUND", (0,1), (-1,1), TEAL),
("TOPPADDING", (0,0), (-1,-1), 8),
("BOTTOMPADDING",(0,0),(-1,-1), 8),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING",(0,0), (-1,-1), 10),
("ROUNDEDCORNERS", [6]),
]))
story.append(banner)
story.append(Spacer(1, 0.4*cm))
# ── SUMMARY VERDICT ROW ───────────────────────────────────────────────────────
verdict_data = [[
Paragraph("❌ SLIDING SCALE ALONE", verdict_bad),
Paragraph("✔ BASAL-BOLUS REGIMEN", verdict_good),
]]
verdict_table = Table(verdict_data, colWidths=[8.7*cm, 8.7*cm])
verdict_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,0), colors.HexColor("#FDECEA")),
("BACKGROUND", (1,0), (1,0), colors.HexColor("#E9F7EF")),
("BOX", (0,0),(0,0), 1, RED),
("BOX", (1,0),(1,0), 1, GREEN),
("TOPPADDING", (0,0),(-1,-1), 6),
("BOTTOMPADDING",(0,0),(-1,-1), 6),
("LEFTPADDING", (0,0),(-1,-1), 8),
("RIGHTPADDING", (0,0),(-1,-1), 8),
]))
story.append(verdict_table)
story.append(Spacer(1, 0.35*cm))
story.append(Paragraph(
'<font color="#C0392B"><b>Harrison\'s verdict:</b></font> '
'"Sliding scale with short-acting or rapid-acting insulin <b>alone</b> is '
'<b>inadequate</b> for inpatient glucose management." — Chap 416, Harrison\'s 22e',
S("Quote", fontSize=9, leading=13, textColor=DGRAY, fontName="Helvetica-Oblique",
borderPad=6, backColor=colors.HexColor("#FEF9E7"),
borderColor=AMBER, borderWidth=1, borderRadius=4)
))
story.append(Spacer(1, 0.4*cm))
# ── HEAD-TO-HEAD COMPARISON TABLE ────────────────────────────────────────────
story.append(Paragraph("Head-to-Head Comparison", h2))
story.append(HRFlowable(width="100%", thickness=1.5, color=NAVY, spaceAfter=6))
col_w = [4.8*cm, 6.3*cm, 6.3*cm]
def row(label, ss, bb, label_bg=LGRAY):
return [
Paragraph(f"<b>{label}</b>", S("RowLbl", fontSize=8.5, leading=12,
fontName="Helvetica-Bold", textColor=NAVY)),
Paragraph(ss, cell_body),
Paragraph(bb, cell_body),
]
comparison_rows = [
# Header
[
Paragraph("", cell_hdr),
Paragraph("Sliding Scale Insulin", cell_hdr),
Paragraph("Basal-Bolus Regimen", cell_hdr),
],
row("Definition",
"Short/rapid-acting insulin given reactively when BG exceeds a threshold. No basal component.",
"Long-acting (basal) insulin + rapid-acting insulin before meals (prandial) + corrective dose."),
row("Mechanism",
"Reactive — treats hyperglycemia only after it occurs.",
"Proactive — maintains euglycemia around the clock, covers meals and provides correction."),
row("Insulin components",
"Rapid- or short-acting insulin ONLY.",
"Basal (glargine/detemir) + Prandial (lispro/aspart/glulisine) + Correction factor."),
row("Glucose control",
"Unpredictable. Inadequate — does not prevent hyperglycemia between checks.",
"Consistent. Individualized to patient's insulin sensitivity and carbohydrate intake."),
row("Hypoglycemia risk",
"Higher — dosing not titrated to the patient's true insulin need.",
"Lower when properly titrated. Requires frequent monitoring to adjust."),
row("Hospital setting",
"NOT recommended as sole regimen. Acceptable only for ≤12-24 h or as additive correction.",
"Preferred regimen for non-ICU hospitalized patients (ADA & Harrison's)."),
row("ICU / critically ill",
"Not suitable.",
"IV insulin infusion preferred; SC basal-bolus when stable."),
row("Perioperative use",
"SC sliding-scale insulin is acceptable perioperatively (or use IV infusion).",
"Preferred for type 1 DM perioperative management. IV infusion for >4 h procedures."),
row("Older adults / LTC",
"AVOID — high hypoglycemia risk, caregiver burden, repeated glucose checks.",
"Basal insulin (once daily) preferred. Individualize glycemic targets."),
row("Oral agents",
"Oral agents should be STOPPED on admission (SGLT-2i: stop 1 week before surgery).",
"Same — oral agents discontinued; structured insulin plan initiated."),
]
comp_table = Table(comparison_rows, colWidths=col_w, repeatRows=1)
comp_table.setStyle(TableStyle([
# Header row
("BACKGROUND", (0,0), (-1,0), NAVY),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,0), 9),
("TOPPADDING", (0,0), (-1,0), 7),
("BOTTOMPADDING", (0,0), (-1,0), 7),
# Alternating rows
("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, LGRAY]),
# Label column
("BACKGROUND", (0,1), (0,-1), colors.HexColor("#EBF5FB")),
("FONTNAME", (0,1), (0,-1), "Helvetica-Bold"),
# Grid
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BDC3C7")),
("TOPPADDING", (0,1), (-1,-1), 5),
("BOTTOMPADDING", (0,1), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "TOP"),
("ROUNDEDCORNERS",[4]),
]))
story.append(comp_table)
story.append(Spacer(1, 0.4*cm))
# ── CORRECTIVE INSULIN DOSING ─────────────────────────────────────────────────
story.append(Paragraph("Corrective (Sliding) Insulin — The Right Way to Use It", h2))
story.append(HRFlowable(width="100%", thickness=1.5, color=TEAL, spaceAfter=6))
story.append(Paragraph(
"When used as a <b>correction dose added to basal-bolus insulin</b> (not as a standalone), "
"Harrison's recommends individualising the correction factor:",
body))
story.append(Spacer(1, 0.2*cm))
corr_data = [
[Paragraph("<b>Patient Type</b>", cell_hdr),
Paragraph("<b>Insulin Sensitivity</b>", cell_hdr),
Paragraph("<b>Correction Factor</b>", cell_hdr),
Paragraph("<b>Example</b>", cell_hdr)],
[Paragraph("Thin / low body weight", cell_body_c),
Paragraph("High (sensitive)", cell_body_c),
Paragraph("1 unit per 2.7 mmol/L\n(50 mg/dL) above target", cell_body_c),
Paragraph("BG 250 mg/dL, target 130 → +2.4 units correction", cell_body_c)],
[Paragraph("Obese / overweight", cell_body_c),
Paragraph("Low (resistant)", cell_body_c),
Paragraph("2 units per 2.7 mmol/L\n(50 mg/dL) above target", cell_body_c),
Paragraph("BG 250 mg/dL, target 130 → +4.8 units correction", cell_body_c)],
]
corr_table = Table(corr_data, colWidths=[4*cm, 3.5*cm, 5*cm, 4.9*cm])
corr_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), TEAL),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LGRAY]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BDC3C7")),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,0), 9),
("TOPPADDING", (0,0), (-1,-1), 6),
("BOTTOMPADDING", (0,0), (-1,-1), 6),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("ALIGN", (0,0), (-1,-1), "CENTER"),
]))
story.append(corr_table)
story.append(Spacer(1, 0.4*cm))
# ── GLYCAEMIC TARGETS ─────────────────────────────────────────────────────────
story.append(Paragraph("ADA Glycaemic Targets in Hospitalised Patients", h2))
story.append(HRFlowable(width="100%", thickness=1.5, color=TEAL, spaceAfter=6))
target_data = [
[Paragraph("<b>Setting</b>", cell_hdr),
Paragraph("<b>Target Glucose</b>", cell_hdr),
Paragraph("<b>Notes</b>", cell_hdr)],
[Paragraph("Critically ill / Non-critically ill (standard)", cell_body_c),
Paragraph("7.8–10.0 mmol/L\n(140–180 mg/dL)", cell_body_c),
Paragraph("Most hospitalised patients; avoid tight control", cell_body_c)],
[Paragraph("Selected patients — tighter control", cell_body_c),
Paragraph("6.1–7.8 mmol/L\n(110–140 mg/dL)", cell_body_c),
Paragraph("Only if hypoglycaemia can be safely avoided", cell_body_c)],
[Paragraph("Perioperative period", cell_body_c),
Paragraph("4.4–10.0 mmol/L\n(80–180 mg/dL)", cell_body_c),
Paragraph("IV infusion or SC sliding-scale acceptable perioperatively", cell_body_c)],
]
tgt_table = Table(target_data, colWidths=[5.5*cm, 5*cm, 6.9*cm])
tgt_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), TEAL),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, LGRAY]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#BDC3C7")),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,0), 9),
("TOPPADDING", (0,0), (-1,-1), 6),
("BOTTOMPADDING", (0,0), (-1,-1), 6),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("ALIGN", (0,0), (-1,-1), "CENTER"),
]))
story.append(tgt_table)
story.append(Spacer(1, 0.4*cm))
# ── KEY CLINICAL PEARLS ───────────────────────────────────────────────────────
story.append(Paragraph("Key Clinical Pearls", h2))
story.append(HRFlowable(width="100%", thickness=1.5, color=AMBER, spaceAfter=6))
pearls = [
("⚠", RED, "Oral hypoglycaemic agents should NOT be given on the morning of surgery."),
("⚠", RED, "SGLT-2 inhibitors must be stopped UP TO 1 WEEK before planned admission (risk of euglycaemic DKA)."),
("⚠", RED, "Metformin: hold if risk of declining renal function (contrast, unstable CHF)."),
("✔", GREEN, "For ICU patients: IV insulin infusion is preferred (short half-life, rapid titration)."),
("✔", GREEN, "For type 1 DM perioperative: IV infusion for procedures >4 h; reduced SC basal for <4 h procedures."),
("✔", GREEN, "When stopping IV insulin infusion, give long-acting SC insulin 2–4 h BEFORE stopping the infusion."),
("✔", GREEN, "TPN/TEN: IV insulin infusion preferred; once stable dose known, add portion directly to TPN bag."),
("✔", GREEN, "Consistently high BG on sliding scale → switch to basal-bolus; do not just keep increasing the scale."),
("ℹ", AMBER, "Strict (tight) glycaemic control in acutely ill patients worsens outcomes and increases hypoglycaemia risk."),
("ℹ", AMBER, "Prevent hypoglycaemia by anticipating drops: decreasing renal function, steroid taper, interrupted feeds."),
]
pearl_rows = []
for icon, col, text in pearls:
pearl_rows.append([
Paragraph(f'<font color="#{col.hexval()[1:]}"><b>{icon}</b></font>',
S("Icon", fontSize=11, leading=14, fontName="Helvetica-Bold",
alignment=TA_CENTER)),
Paragraph(text, cell_body),
])
pearl_table = Table(pearl_rows, colWidths=[0.7*cm, 16.7*cm])
pearl_table.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 3),
("LEFTPADDING", (0,0), (-1,-1), 2),
("RIGHTPADDING", (0,0), (-1,-1), 4),
("ROWBACKGROUNDS",(0,0), (-1,-1), [WHITE, LGRAY]),
("GRID", (0,0), (-1,-1), 0.3, colors.HexColor("#DADADA")),
]))
story.append(pearl_table)
story.append(Spacer(1, 0.5*cm))
# ── FOOTER ────────────────────────────────────────────────────────────────────
story.append(HRFlowable(width="100%", thickness=0.5, color=DGRAY, spaceAfter=4))
story.append(Paragraph(
"Source: Harrison's Principles of Internal Medicine 22nd Edition (2025), Chapters 415–417. "
"ADA Standards of Medical Care in Diabetes (referenced within). "
"For clinical decisions always consult current guidelines and individualise patient care.",
note_style
))
# ── BUILD ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved to {OUTPUT}")