What is treatment protocol of DKA

I'll look up the DKA treatment protocol from the medical library right away.
Searching sources...
Reading File
Finding Sources
Searching PubMed

"diabetic ketoacidosis" AND management

Good - three excellent sources found. Let me read all of them in parallel.
Reading File
Reading File
Reading File
Reading File
Reading File
I now have comprehensive information. Let me compile the full DKA treatment protocol.

Treatment Protocol of Diabetic Ketoacidosis (DKA)

Diagnostic Criteria / Initial Workup

Before treatment, confirm DKA with:
  • Serum glucose, electrolytes, ketones, ABG
  • CBC with differential, urinalysis, chest X-ray, ECG (if indicated)
  • Calculate anion gap: AG = Na - (Cl + HCO3) - normal is 8-12 mEq/L
Severity classification:
SeveritypHHCO3Anion GapMental Status
Mild7.25-7.3015-18>10Alert
Moderate7.00-7.2410-14>12Alert/drowsy
Severe<7.00<10>12Stupor/coma

Step 1 - IV Fluid Resuscitation (FIRST PRIORITY)

Fluid deficit is typically 7-9% of body weight (3-5 L in adults).
Phase 1 - Restore circulating volume:
  • 0.9% Normal Saline: 1 L bolus, then 500-1000 mL/h (if cardiac and renal function normal)
  • If in hypovolemic shock: give NS as rapidly as possible until systolic BP >80 mmHg
  • Children: 20 mL/kg NS in the first hour
Phase 2 - Replenish total-body water deficit:
  • Switch to 0.45% saline at 150-500 mL/h (use 0.9% NS if hyponatremic)
  • Goal: positive fluid balance over 12-24 hours
  • Rate must not correct osmolality faster than 3 mOsm/kg/h (risk of osmotic encephalopathy)
  • Aim for urine output 1-2 mL/kg/h in children
Note: Fluid resuscitation alone can drop plasma glucose ~18% and improve acidosis before insulin is given, by improving tissue perfusion, lactate clearance, and renal glucose excretion.

Step 2 - Potassium Repletion (BEFORE Insulin)

Serum K is often normal or high on presentation despite total body depletion (acidosis shifts K out of cells). It drops rapidly once insulin is started.
Serum PotassiumAction
<3.3 mEq/LDo NOT give insulin - replete K first; give 20-40 mEq/h IV until K ≥3.3 mEq/L
3.3-5.5 mEq/LAdd 20-40 mEq KCl per liter of IV fluid; start insulin
>5.5 mEq/LHold potassium supplementation; start insulin; recheck K frequently
Telemetry monitoring is recommended given the risk of arrhythmias from electrolyte shifts.

Step 3 - Insulin Therapy

Do NOT start insulin until K ≥3.3 mEq/L.
  • IV bolus (optional): 0.1 units/kg regular insulin IV (no longer routinely recommended per ADA)
  • Continuous infusion (standard): Regular insulin 0.1 units/kg/h (up to 5-10 units/h) in 0.9% NS
    • Preparation: 100 units regular insulin in 100 mL 0.9% NS → 10 mL/h = 10 units/h
Glucose targets during infusion:
  • Goal drop: 50-75 mg/dL/h (2.8-4.2 mmol/L/h)
  • Do NOT correct faster than 100 mg/dL/h (risk of osmotic encephalopathy/cerebral edema)
When glucose drops to ≤250-300 mg/dL:
  • Add Dextrose 5% to IV fluids (prevent hypoglycemia while continuing insulin to clear ketones)
  • Reduce insulin infusion to 0.05 units/kg/h OR use the two-bag approach (separate glucose + insulin infusions - shown to shorten treatment duration)
Continue insulin until ketoacidosis resolves (not just until glucose normalizes):
  • pH >7.30
  • HCO3 ≥18 mEq/L
  • Anion gap closed
Transition to subcutaneous insulin:
  • Administer SC basal insulin 2 hours before stopping IV infusion to prevent rebound hyperglycemia
  • In mild DKA, SC/IM insulin is a proven alternative to IV infusion
2024-2026 evidence update: A recent meta-analysis (PMID 39090718) confirmed subcutaneous insulin is comparable to continuous IV infusion in adult DKA. A 2026 meta-analysis of RCTs (PMID 41208563) found that early co-administration of SC basal insulin alongside IV infusion reduces rebound hyperglycemia and may shorten DKA resolution time.

Step 4 - Phosphate and Magnesium

  • Phosphate: Not routinely replaced unless serum phosphorus <1.0 mEq/L - use potassium phosphate (KPhos) if not eating
  • Magnesium: Give 1-2 g MgSO4 IV if ventricular arrhythmias or symptomatic hypomagnesemia; serum levels may not reflect body stores

Step 5 - Bicarbonate (Selective Use Only)

NOT routinely recommended. Consider only in:
  1. Shock or coma
  2. pH <6.9
  3. HCO3 <5 mEq/L
  4. Cardiac or respiratory dysfunction
  5. Severe hyperkalemia (to shift K intracellularly temporarily)
Dose: 50-100 mEq in 1 L of 0.45% saline over 30-60 min; always add 10 mEq KCl to avoid hypokalemia; follow arterial pH closely.

Step 6 - Monitoring

ParameterFrequency
Blood glucoseEvery hour
Serum K+, Cl-, HCO3, NaEvery 2-4 hours
ABG / venous pHAs needed (especially if severely acidotic)
β-hydroxybutyrateSerial measurements to track ketosis resolution
Urine outputContinuous
Vital signsContinuous
Key monitoring points:
  • Serum Na should rise as hyperglycemia corrects. If it doesn't, patient may be over-hydrated with free water.
  • Hyperchloremia (from NS) can close the anion gap before HCO3 normalizes - use serum HCO3 normalization as the more reliable marker of DKA resolution.
  • ICU/telemetry admission is preferred; mild-moderate DKA may be managed in a step-down unit.

Step 7 - Treat the Precipitant

Always identify and treat the underlying cause:
  • Infection (most common - note: DKA itself causes leukocytosis, so fever specifically suggests infection; start empiric antibiotics if sepsis suspected)
  • Missed insulin doses
  • New-onset diabetes
  • Myocardial infarction, stroke, pancreatitis (check lipase, not amylase)
  • Medications (steroids, SGLT2 inhibitors - euglycemic DKA)

Special Populations

Children: Same principles apply; be especially cautious with fluid rates to avoid cerebral edema (leading cause of death in pediatric DKA). Avoid rapid osmolality correction.
Pregnancy: A 2025 systematic review (PMID 40447103) highlights that DKA in pregnancy carries significant fetal risk; aggressive early treatment and fetal monitoring are essential.

Criteria for DKA Resolution

  • Blood glucose <200 mg/dL
  • Serum HCO3 ≥18 mEq/L
  • Venous pH >7.30
  • Anion gap ≤12 mEq/L
  • Patient tolerating oral fluids

Sources: The Washington Manual of Medical Therapeutics, p. 890-891; Rosen's Emergency Medicine, p. 2543-2544; ADA Guidelines as cited in Tintinalli's Emergency Medicine.

Create a quick-reference DKA protocol card (PDF) for the ICU

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or not found"

Running Command

mkdir -p /home/daytona/workspace/dka-protocol && python3 -c "from reportlab.lib import colors; print('reportlab ok')"

Writing File

~/dka-protocol/generate_dka_card.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.platypus import (
    SimpleDocTemplate, Table, TableStyle, Paragraph,
    Spacer, HRFlowable
)
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus import KeepTogether

OUTPUT = "/home/daytona/workspace/dka-protocol/DKA_Protocol_Card.pdf"

# ── Colour palette ─────────────────────────────────────────────────────────────
NAVY      = colors.HexColor("#0D2B4E")
TEAL      = colors.HexColor("#0B7A75")
AMBER     = colors.HexColor("#E07B00")
RED       = colors.HexColor("#C0392B")
LIGHT_BG  = colors.HexColor("#F4F8FB")
AMBER_BG  = colors.HexColor("#FFF7E6")
RED_BG    = colors.HexColor("#FFF0EE")
WHITE     = colors.white
GREY      = colors.HexColor("#6B7280")
MID_GREY  = colors.HexColor("#E5E7EB")

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

H_CARD  = S("hcard",  fontSize=18, leading=22, textColor=WHITE,      fontName="Helvetica-Bold", alignment=TA_CENTER)
SUBHEAD = S("subh",   fontSize=9,  leading=11, textColor=WHITE,       fontName="Helvetica-Bold", alignment=TA_CENTER)
SEC_HDR = S("sechdr", fontSize=9,  leading=11, textColor=WHITE,       fontName="Helvetica-Bold")
BODY    = S("body",   fontSize=8,  leading=10, textColor=colors.black, fontName="Helvetica")
BODY_B  = S("bodyb",  fontSize=8,  leading=10, textColor=colors.black, fontName="Helvetica-Bold")
SMALL   = S("small",  fontSize=7,  leading=9,  textColor=GREY,         fontName="Helvetica")
WARN    = S("warn",   fontSize=8,  leading=10, textColor=RED,          fontName="Helvetica-Bold")
TBL_HDR = S("tblh",   fontSize=7.5, leading=9, textColor=WHITE,        fontName="Helvetica-Bold", alignment=TA_CENTER)
TBL_CEL = S("tblc",   fontSize=7.5, leading=9.5, textColor=colors.black, fontName="Helvetica")
TBL_B   = S("tblcb",  fontSize=7.5, leading=9.5, textColor=colors.black, fontName="Helvetica-Bold")
NOTE    = S("note",   fontSize=7,  leading=9,  textColor=GREY,         fontName="Helvetica-Oblique")
FOOT    = S("foot",   fontSize=6.5,leading=8,  textColor=GREY,         fontName="Helvetica", alignment=TA_CENTER)

def section_header(text, bg=NAVY):
    return Table(
        [[Paragraph(text, SEC_HDR)]],
        colWidths=["100%"],
        style=TableStyle([
            ("BACKGROUND", (0,0), (-1,-1), bg),
            ("LEFTPADDING",  (0,0), (-1,-1), 6),
            ("RIGHTPADDING", (0,0), (-1,-1), 6),
            ("TOPPADDING",   (0,0), (-1,-1), 4),
            ("BOTTOMPADDING",(0,0), (-1,-1), 4),
            ("ROUNDEDCORNERS", [3]),
        ])
    )

def p(txt, style=BODY):
    return Paragraph(txt, style)

def sp(h=4):
    return Spacer(1, h)

# ── Document setup ─────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=12*mm, rightMargin=12*mm,
    topMargin=12*mm, bottomMargin=12*mm,
    title="DKA ICU Protocol Quick-Reference Card",
    author="Orris Clinical Reference"
)

W = A4[0] - 24*mm   # usable width
story = []

# ══════════════════════════════════════════════════════════════════════════════
# HEADER BANNER
# ══════════════════════════════════════════════════════════════════════════════
header_tbl = Table(
    [[
        Paragraph("DKA ICU PROTOCOL", H_CARD),
        Paragraph("Quick-Reference Card<br/><font size=8>Adult &amp; Paediatric</font>", SUBHEAD)
    ]],
    colWidths=[W*0.62, W*0.38],
    style=TableStyle([
        ("BACKGROUND",   (0,0), (-1,-1), NAVY),
        ("LEFTPADDING",  (0,0), (-1,-1), 10),
        ("RIGHTPADDING", (0,0), (-1,-1), 10),
        ("TOPPADDING",   (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0), (-1,-1), 8),
        ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
        ("ROUNDEDCORNERS", [5]),
    ])
)
story += [header_tbl, sp(6)]

# ══════════════════════════════════════════════════════════════════════════════
# SEVERITY CLASSIFICATION
# ══════════════════════════════════════════════════════════════════════════════
story += [section_header("SEVERITY CLASSIFICATION"), sp(3)]

sev_data = [
    [p("Parameter", TBL_HDR), p("Mild", TBL_HDR), p("Moderate", TBL_HDR), p("Severe", TBL_HDR)],
    [p("pH",         TBL_B),  p("7.25–7.30", TBL_CEL), p("7.00–7.24", TBL_CEL), p("< 7.00", TBL_CEL)],
    [p("HCO₃⁻",     TBL_B),  p("15–18 mEq/L", TBL_CEL), p("10–14 mEq/L", TBL_CEL), p("< 10 mEq/L", TBL_CEL)],
    [p("Anion Gap",  TBL_B),  p("> 10", TBL_CEL), p("> 12", TBL_CEL), p("> 12", TBL_CEL)],
    [p("Mental Status", TBL_B), p("Alert", TBL_CEL), p("Alert / Drowsy", TBL_CEL), p("Stupor / Coma", TBL_CEL)],
    [p("Setting",    TBL_B),  p("Ward / SC insulin", TBL_CEL), p("HDU / IV insulin", TBL_CEL), p("ICU mandatory", TBL_CEL)],
]
sev_tbl = Table(sev_data, colWidths=[W*0.22, W*0.22, W*0.26, W*0.30],
    style=TableStyle([
        ("BACKGROUND",   (0,0), (-1,0),  NAVY),
        ("BACKGROUND",   (0,1), (0,-1),  LIGHT_BG),
        ("ROWBACKGROUNDS",(1,1),(-1,-1), [WHITE, LIGHT_BG]),
        ("GRID",         (0,0), (-1,-1), 0.4, MID_GREY),
        ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
        ("ALIGN",        (1,0), (-1,-1), "CENTER"),
        ("TOPPADDING",   (0,0), (-1,-1), 3),
        ("BOTTOMPADDING",(0,0), (-1,-1), 3),
        ("LEFTPADDING",  (0,0), (-1,-1), 5),
    ])
)
story += [sev_tbl, sp(6)]

# ══════════════════════════════════════════════════════════════════════════════
# TWO-COLUMN LAYOUT: Fluids | Potassium
# ══════════════════════════════════════════════════════════════════════════════
# Left col: IV Fluids
fluid_inner = [
    [p("• Fluid deficit: <b>7–9% body weight</b> (~3–5 L adult)", TBL_CEL)],
    [p("<b>Phase 1 – Restore circulation:</b>", TBL_CEL)],
    [p("  0.9% NS: <b>1 L bolus</b>, then <b>500–1000 mL/h</b>", TBL_CEL)],
    [p("  Shock: NS wide open (child: 20 mL/kg) → SBP >80 mmHg", TBL_CEL)],
    [p("<b>Phase 2 – Replenish total water:</b>", TBL_CEL)],
    [p("  0.45% NS at <b>150–500 mL/h</b>", TBL_CEL)],
    [p("  (Use 0.9% NS if hyponatraemic)", TBL_CEL)],
    [p("  Max correction: <b>3 mOsm/kg/h</b>  UO target: 1–2 mL/kg/h", TBL_CEL)],
    [p("  Positive balance over <b>12–24 h</b>", TBL_CEL)],
    [p("• Add D5W when BG ≤250 mg/dL (consider 2-bag approach)", TBL_CEL)],
]
fluid_tbl = Table(fluid_inner, colWidths=[(W/2)-4],
    style=TableStyle([
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("RIGHTPADDING",  (0,0), (-1,-1), 5),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ("BACKGROUND",    (0,0), (-1,-1), LIGHT_BG),
    ])
)

# Right col: Potassium
k_data_inner = [
    [p("Check K⁺ before insulin — DO NOT give insulin if K < 3.3 mEq/L", WARN)],
    [sp(2)],
    [Table(
        [
            [p("<b>K⁺ level</b>", TBL_HDR), p("<b>Action</b>", TBL_HDR)],
            [p("< 3.3 mEq/L", TBL_B), p("Give 20–40 mEq/h IV; hold insulin", TBL_CEL)],
            [p("3.3–5.5 mEq/L", TBL_B), p("Add 20–40 mEq KCl/L fluid + start insulin", TBL_CEL)],
            [p("> 5.5 mEq/L", TBL_B), p("Hold K⁺ supplement; start insulin; monitor", TBL_CEL)],
        ],
        colWidths=[W*0.15, (W/2 - W*0.15 - 8)],
        style=TableStyle([
            ("BACKGROUND",   (0,0), (-1,0),  TEAL),
            ("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, LIGHT_BG]),
            ("GRID",         (0,0), (-1,-1), 0.3, MID_GREY),
            ("TOPPADDING",   (0,0), (-1,-1), 2),
            ("BOTTOMPADDING",(0,0), (-1,-1), 2),
            ("LEFTPADDING",  (0,0), (-1,-1), 4),
        ])
    )],
    [p("• Telemetry monitoring throughout", NOTE)],
]
k_inner_tbl = Table(k_data_inner, colWidths=[(W/2)-4],
    style=TableStyle([
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("RIGHTPADDING",  (0,0), (-1,-1), 5),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ("BACKGROUND",    (0,0), (-1,-1), AMBER_BG),
    ])
)

col2_tbl = Table(
    [[
        Table([[section_header("IV FLUIDS", TEAL)], [sp(3)], [fluid_tbl]], colWidths=[(W/2)-4]),
        Table([[section_header("POTASSIUM REPLACEMENT", AMBER)], [sp(3)], [k_inner_tbl]], colWidths=[(W/2)-4]),
    ]],
    colWidths=[W/2, W/2],
    style=TableStyle([
        ("VALIGN",       (0,0), (-1,-1), "TOP"),
        ("LEFTPADDING",  (0,0), (-1,-1), 0),
        ("RIGHTPADDING", (0,0), (-1,-1), 4),
        ("TOPPADDING",   (0,0), (-1,-1), 0),
        ("BOTTOMPADDING",(0,0), (-1,-1), 0),
    ])
)
story += [col2_tbl, sp(6)]

# ══════════════════════════════════════════════════════════════════════════════
# INSULIN PROTOCOL
# ══════════════════════════════════════════════════════════════════════════════
story += [section_header("INSULIN PROTOCOL  (only after K⁺ ≥ 3.3 mEq/L)"), sp(3)]

ins_data = [
    [p("Route", TBL_HDR), p("Dose", TBL_HDR), p("Target / Notes", TBL_HDR)],
    [p("IV infusion (preferred)", TBL_B),
     p("Regular insulin 0.1 units/kg/h<br/><i>Prep: 100 u in 100 mL NS → 10 mL/h = 10 u/h</i>", TBL_CEL),
     p("BG drop: <b>50–75 mg/dL/h</b> (2.8–4.2 mmol/L/h)<br/>Do NOT exceed 100 mg/dL/h drop", TBL_CEL)],
    [p("IV bolus (optional)", TBL_B),
     p("0.1 units/kg bolus before infusion", TBL_CEL),
     p("Not routinely recommended (ADA)", TBL_CEL)],
    [p("When BG ≤ 250 mg/dL", TBL_B),
     p("Reduce infusion to 0.05 units/kg/h<br/>+ Add D5W to fluids", TBL_CEL),
     p("Continue insulin until ketoacidosis resolves, not just until BG normalises", TBL_CEL)],
    [p("Transition to SC", TBL_B),
     p("Give SC basal insulin <b>2 h before</b> stopping IV infusion", TBL_CEL),
     p("Prevents rebound hyperglycaemia", TBL_CEL)],
    [p("Mild DKA (SC route)", TBL_B),
     p("SC / IM regular insulin acceptable", TBL_CEL),
     p("IV preferred if poor perfusion / sicker patient", TBL_CEL)],
]
ins_tbl = Table(ins_data, colWidths=[W*0.20, W*0.40, W*0.40],
    style=TableStyle([
        ("BACKGROUND",    (0,0), (-1,0),  TEAL),
        ("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, LIGHT_BG]),
        ("GRID",          (0,0), (-1,-1), 0.4, MID_GREY),
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
        ("TOPPADDING",    (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ])
)
story += [ins_tbl, sp(6)]

# ══════════════════════════════════════════════════════════════════════════════
# BICARBONATE  |  PHOSPHATE & MAGNESIUM
# ══════════════════════════════════════════════════════════════════════════════
bicarb_rows = [
    [p("NOT routinely recommended", WARN)],
    [p("<b>Consider ONLY if ANY of:</b>", TBL_CEL)],
    [p("  • Shock or coma", TBL_CEL)],
    [p("  • pH < 6.9", TBL_CEL)],
    [p("  • HCO₃⁻ < 5 mEq/L", TBL_CEL)],
    [p("  • Cardiac / respiratory dysfunction", TBL_CEL)],
    [p("  • Severe hyperkalaemia", TBL_CEL)],
    [p("<b>Dose:</b> 50–100 mEq in 1 L 0.45% NS over 30–60 min<br/>Always add <b>10 mEq KCl</b> to avoid hypokalaemia<br/>Monitor arterial pH closely", TBL_CEL)],
]
bicarb_inner = Table(bicarb_rows, colWidths=[(W/2)-4],
    style=TableStyle([
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ("BACKGROUND",    (0,0), (-1,-1), RED_BG),
    ])
)

phos_rows = [
    [p("<b>Phosphate:</b> Not routinely replaced", TBL_CEL)],
    [p("  Replace if PO₄ < 1.0 mEq/L → use KPhos IV", TBL_CEL)],
    [p("<b>Magnesium:</b>", TBL_CEL)],
    [p("  1–2 g MgSO₄ IV if ventricular arrhythmia", TBL_CEL)],
    [p("  Serum Mg may not reflect body stores", NOTE)],
]
phos_inner = Table(phos_rows, colWidths=[(W/2)-4],
    style=TableStyle([
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ("BACKGROUND",    (0,0), (-1,-1), LIGHT_BG),
    ])
)

col3_tbl = Table(
    [[
        Table([[section_header("BICARBONATE", RED)], [sp(3)], [bicarb_inner]], colWidths=[(W/2)-4]),
        Table([[section_header("PHOSPHATE & MAGNESIUM", TEAL)], [sp(3)], [phos_inner]], colWidths=[(W/2)-4]),
    ]],
    colWidths=[W/2, W/2],
    style=TableStyle([
        ("VALIGN",       (0,0), (-1,-1), "TOP"),
        ("LEFTPADDING",  (0,0), (-1,-1), 0),
        ("RIGHTPADDING", (0,0), (-1,-1), 4),
        ("TOPPADDING",   (0,0), (-1,-1), 0),
        ("BOTTOMPADDING",(0,0), (-1,-1), 0),
    ])
)
story += [col3_tbl, sp(6)]

# ══════════════════════════════════════════════════════════════════════════════
# MONITORING
# ══════════════════════════════════════════════════════════════════════════════
story += [section_header("MONITORING"), sp(3)]

mon_data = [
    [p("Parameter", TBL_HDR), p("Frequency", TBL_HDR), p("Key Point", TBL_HDR)],
    [p("Blood glucose", TBL_B), p("Every 1 h", TBL_CEL), p("Target drop 50–75 mg/dL/h; start D5W when BG ≤250 mg/dL", TBL_CEL)],
    [p("K⁺, Na, Cl, HCO₃⁻", TBL_B), p("Every 2–4 h", TBL_CEL), p("Na should rise as BG falls; if not → over-hydration with free water", TBL_CEL)],
    [p("ABG / venous pH", TBL_B), p("As needed", TBL_CEL), p("Use HCO₃⁻ normalisation (not AG closure) as DKA resolution marker", TBL_CEL)],
    [p("β-hydroxybutyrate", TBL_B), p("Serial", TBL_CEL), p("Best direct measure of ketosis resolution", TBL_CEL)],
    [p("Urine output", TBL_B), p("Continuous", TBL_CEL), p("Target ≥0.5 mL/kg/h adult | 1–2 mL/kg/h child", TBL_CEL)],
    [p("ECG / telemetry", TBL_B), p("Continuous", TBL_CEL), p("Detect K⁺-related arrhythmias early", TBL_CEL)],
]
mon_tbl = Table(mon_data, colWidths=[W*0.22, W*0.18, W*0.60],
    style=TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), NAVY),
        ("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, LIGHT_BG]),
        ("GRID",          (0,0), (-1,-1), 0.4, MID_GREY),
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
        ("TOPPADDING",    (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ])
)
story += [mon_tbl, sp(6)]

# ══════════════════════════════════════════════════════════════════════════════
# RESOLUTION CRITERIA  |  COMMON PRECIPITANTS
# ══════════════════════════════════════════════════════════════════════════════
res_rows = [
    [p("All of the following must be met:", TBL_B)],
    [p("  ✓ Blood glucose < 200 mg/dL", TBL_CEL)],
    [p("  ✓ Serum HCO₃⁻ ≥ 18 mEq/L", TBL_CEL)],
    [p("  ✓ Venous pH > 7.30", TBL_CEL)],
    [p("  ✓ Anion gap ≤ 12 mEq/L", TBL_CEL)],
    [p("  ✓ Tolerating oral fluids", TBL_CEL)],
    [p("Give SC basal insulin 2 h before stopping IV", NOTE)],
]
res_inner = Table(res_rows, colWidths=[(W/2)-4],
    style=TableStyle([
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ("BACKGROUND",    (0,0), (-1,-1), LIGHT_BG),
    ])
)

prec_rows = [
    [p("• Infection (most common) — fever suggests sepsis", TBL_CEL)],
    [p("• Missed insulin / new-onset T1DM", TBL_CEL)],
    [p("• Myocardial infarction (get ECG)", TBL_CEL)],
    [p("• Pancreatitis (check lipase ×3 ULN)", TBL_CEL)],
    [p("• Stroke / acute illness", TBL_CEL)],
    [p("• SGLT2 inhibitors → euglycaemic DKA", TBL_CEL)],
    [p("• Steroids, thiazides, antipsychotics", TBL_CEL)],
]
prec_inner = Table(prec_rows, colWidths=[(W/2)-4],
    style=TableStyle([
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ("BACKGROUND",    (0,0), (-1,-1), AMBER_BG),
    ])
)

col4_tbl = Table(
    [[
        Table([[section_header("RESOLUTION CRITERIA", TEAL)], [sp(3)], [res_inner]], colWidths=[(W/2)-4]),
        Table([[section_header("COMMON PRECIPITANTS", AMBER)], [sp(3)], [prec_inner]], colWidths=[(W/2)-4]),
    ]],
    colWidths=[W/2, W/2],
    style=TableStyle([
        ("VALIGN",       (0,0), (-1,-1), "TOP"),
        ("LEFTPADDING",  (0,0), (-1,-1), 0),
        ("RIGHTPADDING", (0,0), (-1,-1), 4),
        ("TOPPADDING",   (0,0), (-1,-1), 0),
        ("BOTTOMPADDING",(0,0), (-1,-1), 0),
    ])
)
story += [col4_tbl, sp(6)]

# ══════════════════════════════════════════════════════════════════════════════
# COMPLICATIONS TO WATCH
# ══════════════════════════════════════════════════════════════════════════════
story += [section_header("COMPLICATIONS TO WATCH"), sp(3)]
comp_data = [
    [p("Complication", TBL_HDR), p("Cause", TBL_HDR), p("Prevention / Action", TBL_HDR)],
    [p("Hypokalaemia", TBL_B),    p("Insulin shifts K⁺ into cells", TBL_CEL),    p("Potassium replacement protocol above; monitor every 2 h", TBL_CEL)],
    [p("Hypoglycaemia", TBL_B),   p("Insulin without glucose replacement", TBL_CEL), p("Add D5W when BG ≤250; reduce insulin to 0.05 u/kg/h", TBL_CEL)],
    [p("Cerebral oedema", TBL_B), p("Rapid osmolality correction", TBL_CEL),     p("Correct ≤3 mOsm/kg/h; especially critical in children", TBL_CEL)],
    [p("Hyperchloraemic acidosis", TBL_B), p("Large NS volumes", TBL_CEL),       p("AG closure ≠ DKA resolution — always check HCO₃⁻", TBL_CEL)],
    [p("Aspiration", TBL_B),      p("AMS + vomiting", TBL_CEL),                 p("Intubate if comatose / vomiting; avoid if possible", TBL_CEL)],
]
comp_tbl = Table(comp_data, colWidths=[W*0.22, W*0.30, W*0.48],
    style=TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), NAVY),
        ("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, LIGHT_BG]),
        ("GRID",          (0,0), (-1,-1), 0.4, MID_GREY),
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
        ("TOPPADDING",    (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ])
)
story += [comp_tbl, sp(8)]

# ══════════════════════════════════════════════════════════════════════════════
# FOOTER
# ══════════════════════════════════════════════════════════════════════════════
story += [
    HRFlowable(width="100%", thickness=0.5, color=MID_GREY),
    sp(3),
    p("Sources: Washington Manual of Medical Therapeutics | Rosen's Emergency Medicine | Tintinalli's Emergency Medicine | ADA Guidelines  •  July 2026", FOOT),
    p("⚠ This card is a clinical aide-memoire. Always apply individual patient clinical judgement. Not a substitute for local institutional protocols.", FOOT),
]

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

python3 /home/daytona/workspace/dka-protocol/generate_dka_card.py

Running Command

ls -lh /home/daytona/workspace/dka-protocol/DKA_Protocol_Card.pdf

Your DKA ICU Quick-Reference Card is ready to download:

DKA Protocol Card

PDF Document · PDF


What's on the card (single A4 page, colour-coded for fast scanning):
SectionColour
Severity Classification - pH, HCO₃, AG, mental status, settingNavy
IV Fluids - Phase 1 (NS bolus/shock) & Phase 2 (0.45% NS, 2-bag approach)Teal
Potassium Replacement - 3-tier table with insulin hold ruleAmber
Insulin Protocol - IV infusion prep, dose, BG targets, transition to SCTeal
Bicarbonate - "NOT routine" warning + 5 criteria for useRed
Phosphate & Magnesium - replacement thresholdsTeal
Monitoring - BG/electrolyte/ABG/telemetry frequenciesNavy
Resolution Criteria - all 5 must be met before stoppingTeal
Common Precipitants - including SGLT2i / euglycaemic DKAAmber
Complications - hypokalaemia, cerebral oedema, hyperchloraemic acidosisNavy
The footer includes a disclaimer and source references (Washington Manual, Rosen's, Tintinalli's, ADA Guidelines).
This is a shared conversation. Sign in to Orris to start your own chat.