Anemia – Complete Diagnostic Approach (Stepwise) Also extract high quality images wherever necessary for showcasing any clinical findings

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Searching Images

anemia blood smear peripheral smear microcytic hypochromic iron deficiency

Searching Images

sickle cell anemia target cells schistocytes spherocytes blood smear morphology

Finding Sources
Loading Image
Loading Image
Loading Image
Loading Image
Loading Image
Loading Image
Loading Image
Reading File
Now I have all the material needed. Let me compile the comprehensive stepwise diagnostic guide.

Anemia — Complete Diagnostic Approach (Stepwise)

Sources: Harrison's Principles of Internal Medicine 22E (2025), Robbins & Kumar Pathologic Basis of Disease, Goldman-Cecil Medicine, Tintinalli's Emergency Medicine

Physiologic Basis

The size of the red cell mass reflects the balance between red cell production and destruction. The master regulator is erythropoietin (EPO), produced primarily by peritubular capillary cells of the kidney in response to tissue hypoxia via the HIF-1α pathway. When hemoglobin falls below 100–120 g/L (10–12 g/dL), EPO rises proportionally. A defect in any of three components — renal EPO production, bone marrow function, or substrate supply (especially iron) — can produce anemia. — Harrison's 22E

Definition: Normal Hemoglobin/Hematocrit Values

PopulationHemoglobin (g/dL)Hematocrit (%)
Adult man16 (±2)47 (±6)
Adult woman (menstruating)13 (±2)40 (±6)
Adult woman (postmenopausal)14 (±2)42 (±6)
Pregnancy12 (±2)37 (±6)
Childhood1236
Newborn1752
WHO defines anemia as Hb <13 g/dL in men, <12 g/dL in non-pregnant women, <11 g/dL in pregnant women.

Step 1 — History

The first step is a focused history:
  • Previous episodes of anemia, prior iron pills or transfusions
  • Family history (hemoglobinopathies, hereditary spherocytosis)
  • Menstrual history: duration of periods, number of pads/tampons, large clots
  • Blood donation
  • Dietary history (vegetarian/vegan → B12 risk; poor diet → folate risk)
  • Alcohol use, liver disease, hypothyroidism
  • Symptoms pointing to underlying cause: diarrhea (celiac, IBD), bone pain (myeloma), weight loss (malignancy), neurological symptoms (B12 deficiency)
  • Medications (chemotherapy, methotrexate, antiseizure drugs, ACE inhibitors, NSAIDs → GI blood loss)
  • Geography/ethnicity (sickle cell, thalassemia in relevant populations)

Step 2 — Physical Examination

The exam should focus on:
  • Consequences of anemia: pallor of mucosa/conjunctiva, resting tachycardia, cardiac flow murmur, dyspnea
  • Clues to cause:
    • Splenomegaly → hemolysis, lymphoma, portal hypertension
    • Lymphadenopathy → lymphoma, leukemia
    • Hepatomegaly/jaundice → hemolytic anemia, liver disease
    • Glossitis, angular cheilitis, koilonychia → iron deficiency
    • Neurologic signs (subacute combined degeneration) → B12 deficiency
    • Petechiae/bleeding → aplastic anemia, thrombocytopenia
    • Rectal exam/occult blood → GI blood loss

Step 3 — Initial Laboratory Work-Up

Complete Blood Count (CBC) with Differential

The CBC is the cornerstone. Key indices:
IndexNormal RangeSignificance
Hemoglobin/HematocritSee aboveDefines severity
MCV (Mean Corpuscular Volume)80–100 fLSize classification
MCH27–33 pgHemoglobin content per cell
MCHC32–36 g/dLHemoglobin concentration
RDW (Red Cell Distribution Width)11.5–14.5%Anisocytosis
WBC + differentialPancytopenia, leukocytosis
Platelet countBone marrow function

Reticulocyte Count — The Critical Branching Point

The absolute reticulocyte count (ARC) is the most important first indicator of anemia mechanism:
  • Elevated ARC (>100,000/μL) → Bone marrow is responding → anemia due to increased loss or destruction (bleeding or hemolysis)
  • Low/normal ARC (<50,000/μL) → Bone marrow is failing to respond → anemia due to impaired production (hypoproliferative)
The reticulocyte production index (RPI) = [reticulocyte % × Hct/45] / maturation factor. An RPI <2 indicates hypoproliferation; RPI >3 indicates hyperproliferation.

Step 4 — Peripheral Blood Smear (MANDATORY)

"A review of the blood smear is a crucial part of any evaluation for anemia as changes in red cell morphology can point to specific causes of anemia." — Harrison's 22E

Normal Blood Smear (Reference)

Normal peripheral blood smear showing uniform biconcave red cells, a neutrophil, and platelets
Normal blood smear (Wright stain). Uniform, biconcave red cells with central pallor comprising one-third of cell diameter, a neutrophil, and a few platelets. — Harrison's 22E, Fig. 66-3

Key Red Cell Morphology and Diagnostic Significance

MorphologyPathophysiologyDisease States
Microcytosis / HypochromiaInadequate hemoglobinizationIron deficiency, thalassemia, sideroblastic anemia, anemia of chronic disease
Macro-ovalocytesNuclear-cytoplasmic dyssynchronyB12 / folate deficiency, myelodysplasia, chemotherapy
SpherocytesLoss of red cell membraneHereditary spherocytosis, autoimmune hemolytic anemia
SchistocytesMechanical fragmentationTTP/HUS, DIC, prosthetic heart valve hemolysis, march hemoglobinuria
Sickle cellsHemoglobin polymerizationSickle cell disease (HbSS, HbSC)
Target cellsRelative membrane excessLiver disease, thalassemia, hemoglobinopathies
PolychromasiaPersistence of RNA in reticulocytesHemolytic anemia, blood loss
Basophilic stipplingPathologic polyribosome precipitationThalassemia, lead poisoning
Howell-Jolly bodiesNuclear remnantsAsplenia, functional hyposplenism
Teardrop cells + nucleated RBCsMarrow architecture disruptionMyelofibrosis, myelophthisic anemia
Hypersegmented neutrophilsImpaired DNA synthesisB12/folate deficiency (megaloblastic anemia)

Step 5 — MCV-Based Classification and Targeted Workup

5A — Microcytic Anemia (MCV < 80 fL)

Caused by any process that interferes with hemoglobin production — less hemoglobin → smaller red cells.
Differential: Iron deficiency · Thalassemia · Anemia of chronic disease/inflammation · Sideroblastic anemia · Lead poisoning

Peripheral Smear: Severe Iron Deficiency Anemia

Severe iron-deficiency anemia: microcytic, hypochromic red cells with marked anisocytosis and poikilocytosis, cells smaller than a lymphocyte nucleus
Severe iron-deficiency anemia. Microcytic, hypochromic red cells, smaller than the nucleus of a lymphocyte, with marked anisocytosis and poikilocytosis. — Harrison's 22E, Fig. 66-4
Key Laboratory Panel for Microcytic Anemia:
TestIron DeficiencyAnemia of InflammationThalassemiaSideroblastic Anemia
SmearMicro/hypoNormal or micro/hypoMicro/hypo + targetingVariable
Serum iron (μg/dL)<30<50Normal–highNormal–high
TIBC (μg/dL)>360<300NormalNormal
Transferrin saturation<10%10–20%30–80%30–80%
Ferritin (μg/L)<1530–20050–30050–300
Hb electrophoresisNormalNormalAbnormal (β-thal); may be normal (α-thal)Normal
RDWHigh (anisocytosis)NormalLow (homogeneous cells)Variable
Key distinguishing clue: RDW is high in iron deficiency (anisocytosis) but low in thalassemia (uniform microcytosis). — Harrison's 22E
Ferritin <30 μg/L = depleted iron stores. Ferritin >200 μg/L = some tissue stores remain. However, ferritin is an acute-phase reactant — it may be falsely elevated in inflammation even with concurrent iron deficiency.

5B — Macrocytic Anemia (MCV > 100 fL)

Two morphologic subtypes guide further workup:

Oval Macrocytes (Megaloblastic pattern)

Caused by defects in DNA synthesis → abnormal nuclear-cytoplasmic maturation (megaloblasts in marrow).
  • Causes: Vitamin B12 deficiency · Folate deficiency · Chemotherapy agents (hydroxyurea, methotrexate) · Myelodysplastic syndrome (MDS)

Round Macrocytes (Non-megaloblastic)

Caused by membrane defects (cholesterol/phospholipid changes).
  • Causes: Alcohol use · Liver disease · Hypothyroidism · Reticulocytosis · Dysproteinemia · Smoking · Hypoxia

Peripheral Smear + Bone Marrow: Severe Megaloblastic Anemia

Severe megaloblastic anemia: Panel A shows peripheral blood with oval macrocytes and a hypersegmented neutrophil; Panel B shows bone marrow with giant megaloblasts, abnormal erythroid and myeloid precursors
(A) Peripheral blood in severe megaloblastic anemia: oval macrocytes and a hypersegmented neutrophil (>5 lobes). (B) Bone marrow: giant megaloblasts with open, immature chromatin; nuclear-cytoplasmic asynchrony in erythroid and myeloid precursors; giant metamyelocytes. — Harrison's 22E, Fig. 99-2
Macrocytic Workup:
  1. Blood smear — oval vs. round macrocytes? Hypersegmented neutrophils?
  2. If megaloblastic pattern: Serum B12 + serum folate / RBC folate
  3. If B12 low: anti-intrinsic factor antibodies (pernicious anemia), Schilling test if needed
  4. If B12/folate normal with macro-ovalocytes: bone marrow biopsy (suspect MDS)
  5. If round macrocytes: check TSH, LFTs, alcohol history

5C — Normocytic Anemia (MCV 80–100 fL)

The broadest and most heterogeneous category. Workup is mechanistically driven.
Differential:
  • Aplastic anemia · Pure red cell aplasia
  • Renal disease (EPO deficiency)
  • Anemia of inflammation/chronic disease
  • Endocrinopathies (hypothyroidism, Addison's)
  • Marrow infiltration (myeloma, metastases, granulomas)
  • Stem cell defects (leukemia, MDS)
  • Acute blood loss/early iron deficiency
Normocytic Workup:
  1. Reticulocyte count (see Step 4 above)
  2. Renal function (Cr/eGFR), EPO level
  3. TSH, cortisol (endocrine causes)
  4. Serum protein electrophoresis (SPEP) for myeloma
  5. LDH, haptoglobin, bilirubin (if hemolysis suspected)
  6. Consider bone marrow exam if no clear cause found

Step 6 — Reticulocyte-Guided Mechanistic Workup

6A — High Reticulocyte Count → Hemolysis / Blood Loss

Rule out bleeding first (clinical history, occult stool blood, imaging). If no bleeding:

Hemolysis Workup:

TestFinding in Hemolysis
LDHElevated (abundant in RBCs)
Serum haptoglobinLow (binds free Hb; consumed)
Indirect bilirubinElevated
Urine hemoglobin/hemosiderinPositive in intravascular hemolysis
Direct Antiglobulin Test (DAT/Coombs)Positive → immune-mediated (AIHA)
Peripheral smearSpherocytes (AIHA, HS), schistocytes (TTP/HUS), sickle cells
Osmotic fragilityIncreased in hereditary spherocytosis
G6PD assayLow in G6PD deficiency
Hb electrophoresisAbnormal in hemoglobinopathies
Flow cytometry (CD55/CD59)Absent in PNH

Autoimmune Hemolytic Anemia — Peripheral Smear

Peripheral blood smear showing spherocytes in autoimmune hemolytic anemia complicating CLL: numerous small lymphocytes and spherocytes with reduced central pallor, polychromasia, and rare nucleated RBCs
Peripheral smear in AIHA complicating CLL. Spherocytes with markedly reduced central pallor, polychromasia, and rare nucleated RBCs indicating brisk reticulocyte response. Smudge cells (CLL lymphocytes) visible. — Webpathology

Sickle Cell Disease — Peripheral Smear

Sickle cell disease blood smear: numerous sickle-shaped, crescent/elongated red cells with some round forms and a neutrophil
Sickle cell disease: elongated, crescent-shaped sickle cells mixed with round cells. HbS polymerization causes rigid, deformed cells that obstruct microvasculature. — Harrison's 22E

6B — Low Reticulocyte Count → Hypoproliferative (Underproduction)

"At least 75% of all cases of anemia are hypoproliferative in nature." — Harrison's 22E

Sub-classification by mechanism:

MechanismKey FeaturesDiagnostic Test
Nutritional (Iron)Microcytic, low ferritin, high TIBCFerritin, serum iron, TIBC
Nutritional (B12/Folate)Macrocytic, hypersegmented PMNsSerum B12, folate, MMA, homocysteine
Renal (EPO deficiency)Normocytic, eGFR <30–60Creatinine, eGFR, EPO level
Anemia of inflammationNormocytic or mild microcytic; high ferritin, low TIBCCRP, ESR, ferritin, underlying disease
Marrow replacementMyelophthisic picture (teardrops, nRBCs, leukoerythroblastosis)BM biopsy
Aplastic anemiaPancytopenia, hypocellular marrowBM biopsy (hypocellular)
Pure red cell aplasiaVery low retics, normal WBC/plt, absent erythroid precursorsBM biopsy, parvovirus B19 serology
MDSMacro-ovalocytes, dysplastic WBCs/plateletsBM biopsy + cytogenetics
LeukemiaPancytopenia, blasts on smearBM biopsy + molecular testing

Anemia of Chronic Inflammation — Mechanism

The predominant mechanism is hepcidin upregulation by inflammatory cytokines (TNF, IL-6). Hepcidin blocks:
  1. Iron absorption from the gut
  2. Iron release from macrophages/stores → Functional iron deficiency despite normal/high stores. EPO levels are also suppressed by cytokines. Laboratory: normocytic or mild microcytic anemia; ferritin high (acute-phase reactant); serum iron low; TIBC low (distinguishes from true iron deficiency where TIBC is high). — Harrison's 22E, Robbins & Kumar

Step 7 — Bone Marrow Examination

Indications (from Histology: A Text and Atlas):
  1. Unexplained severe anemia
  2. Abnormal peripheral blood smear morphology suggesting marrow pathology
  3. Suspected aplastic anemia, MDS, or leukemia
  4. Circulating nucleated red blood cells
  5. Myelophthisic picture (teardrop cells + leukoerythroblastosis)
  6. Staging of lymphoma or certain malignancies
  7. Macro-ovalocytes with normal B12/folate (suspect MDS)
  8. Marrow infiltration suspected (myeloma, metastases, granulomas)
Bone marrow examination includes aspirate (cytology + flow cytometry) and trephine biopsy (cellularity, architecture, molecular testing).

Step 8 — Additional Targeted Tests by Clinical Context

Clinical SuspicionAdditional Tests
Pernicious anemiaAnti-intrinsic factor Ab, anti-parietal cell Ab
ThalassemiaHb electrophoresis, α-gene deletion (PCR), family study
HemoglobinopathyHb electrophoresis, sickling test
PNHFlow cytometry (CD55, CD59 deficiency)
TTP/HUSADAMTS13 activity, schistocytes, platelet count, creatinine
Lead poisoningBlood lead level, basophilic stippling on smear
Liver diseaseLFTs, coagulation panel
HypothyroidismTSH
MyelomaSPEP, UPEP, serum free light chains, BM biopsy
AutoimmuneANA, RF (underlying connective tissue disease)

Summary Algorithm

Hemoglobin low?
       │
       ▼
History + Physical → Severity, Symptoms, Clues to Cause
       │
       ▼
CBC + Reticulocyte Count + Peripheral Blood Smear
       │
       ├── Retic ↑ (>100K) ─── Bleeding? ── YES → GI workup, imaging
       │                         │
       │                         NO → Hemolysis workup:
       │                              LDH ↑, Haptoglobin ↓, Indirect bili ↑
       │                              DAT (Coombs), smear morphology
       │                              G6PD, Hb electrophoresis, PNH screen
       │
       └── Retic ↓ / normal ── MCV?
                                │
                    ┌───────────┼──────────────┐
                    ▼           ▼              ▼
               Microcytic   Normocytic     Macrocytic
               (MCV <80)   (MCV 80–100)   (MCV >100)
                    │           │              │
              Ferritin +    Renal Fn,      Smear →
              Serum Fe +    EPO level,     Oval macros?
              TIBC +        TSH, SPEP,     → B12/Folate
              Hb electro    BM if needed   Round macros?
              RDW                          → Alcohol/Liver/
              (↑ IDA,                        Thyroid
              ↓ Thal)                      Normal B12/folate
                                           + oval macros?
                                           → BM (MDS)

Comparison: Iron Deficiency vs. Anemia of Inflammation (Common Clinical Dilemma)

FeatureIron DeficiencyAnemia of Inflammation
Ferritin↓ (<15 μg/L)Normal to ↑ (30–200)
Serum iron
TIBC↑ (>360)↓ (<300)
Transferrin sat<10%10–20%
Hepcidin
RBC morphologyMicro/hypoNormocytic or mildly micro
CauseBlood loss, malabsorption, poor intakeInfection, cancer, RA, IBD
When both conditions coexist (common), ferritin may be falsely normal. The soluble transferrin receptor (sTfR) or sTfR/log ferritin index can help — it rises in true iron deficiency but not in inflammation alone.

Macrocytic Anemia: B12 vs. Folate vs. MDS

FeatureB12 DeficiencyFolate DeficiencyMDS
SmearOval macrocytes, hyperseg PMNsSameOval macrocytes ± dysplasia
Serum B12Low (<200 pg/mL)NormalNormal
Serum folateNormalLowNormal
HomocysteineNormal
Methylmalonic acid (MMA) (B12-specific)NormalNormal
Neurological signsYES (posterior column)NoNo
Bone marrowMegaloblasticMegaloblasticDysplastic (ringed sideroblasts, etc.)

Severity Classification

SeverityHemoglobin
Mild10–12 g/dL (women) / 10–13 g/dL (men)
Moderate8–10 g/dL
Severe6–8 g/dL
Very severe / life-threatening<6 g/dL

Key Points

  1. Reticulocyte count is the single most important test after the CBC — it divides anemia into hyperproliferative (hemolysis/bleeding) vs. hypoproliferative (underproduction).
  2. Peripheral blood smear is mandatory and often diagnostic without further testing.
  3. MCV classifies by morphology and drives targeted testing in hypoproliferative anemia.
  4. RDW distinguishes iron deficiency (high, anisocytosis) from thalassemia (low, uniform cells).
  5. Ferritin is an acute-phase reactant — it can be normal or high in combined iron deficiency + inflammation.
  6. Hepcidin is the master iron regulator — elevated in anemia of inflammation; suppressed in iron deficiency.
  7. Bone marrow biopsy is reserved for unexplained anemia with myelophthisic features, pancytopenia, suspected malignancy, or when initial workup is unrevealing.
  8. At least 75% of all anemia is hypoproliferative; the most common cause globally is iron deficiency.

— Harrison's Principles of Internal Medicine 22E (2025, McGraw Hill) | Robbins, Cotran & Kumar Pathologic Basis of Disease | Goldman-Cecil Medicine | Tintinalli's Emergency Medicine

Create a single page note taking like image of this content and add infographics and illustrations wherever needed for quick understanding

Checking Date & Time
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or does not exist"

Running Command

mkdir -p /home/daytona/workspace/anemia-note && python3 -c "from PIL import Image; print('PIL ok')" && python3 -c "import cairo; print('cairo ok')" 2>/dev/null; python3 -c "import reportlab; print('reportlab ok')"

Writing File

~/anemia-note/generate_note.py

#!/usr/bin/env python3
"""
Anemia – Complete Diagnostic Approach
Single-page note-taking style infographic using Pillow
"""

from PIL import Image, ImageDraw, ImageFont
import math, os, textwrap

# ── Canvas ────────────────────────────────────────────────────────────────────
W, H = 3200, 4800
img = Image.new("RGB", (W, H), "#FAFAF8")
draw = ImageDraw.Draw(img)

# ── Colour palette ────────────────────────────────────────────────────────────
C = {
    "bg":        "#FAFAF8",
    "header_bg": "#1A2B4A",   # deep navy
    "micro_bg":  "#FFF3E0",   # warm orange tint
    "macro_bg":  "#E8F5E9",   # green tint
    "normo_bg":  "#E3F2FD",   # blue tint
    "hemo_bg":   "#FCE4EC",   # pink tint
    "box_bg":    "#FFFFFF",
    "border":    "#CFD8DC",
    "step_blue": "#1565C0",
    "step_text": "#FFFFFF",
    "navy":      "#1A2B4A",
    "orange":    "#E65100",
    "green":     "#2E7D32",
    "teal":      "#00695C",
    "red":       "#C62828",
    "purple":    "#6A1B9A",
    "text":      "#1C1C1E",
    "subtext":   "#455A64",
    "arrow":     "#37474F",
    "retic_hi":  "#D32F2F",
    "retic_lo":  "#1565C0",
    "micro_c":   "#E65100",
    "macro_c":   "#2E7D32",
    "normo_c":   "#0277BD",
    "gold":      "#F9A825",
    "light_line":"#B0BEC5",
}

# ── Font loader ───────────────────────────────────────────────────────────────
def font(size, bold=False, italic=False):
    candidates = []
    if bold and italic:
        candidates = ["/usr/share/fonts/truetype/dejavu/DejaVuSans-BoldOblique.ttf"]
    elif bold:
        candidates = ["/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",
                      "/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf"]
    elif italic:
        candidates = ["/usr/share/fonts/truetype/dejavu/DejaVuSans-Oblique.ttf"]
    else:
        candidates = ["/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
                      "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf"]
    for p in candidates:
        if os.path.exists(p):
            return ImageFont.truetype(p, size)
    return ImageFont.load_default()

# ── Drawing helpers ───────────────────────────────────────────────────────────
def rrect(draw, xy, radius=18, fill="#FFF", outline=None, width=2):
    x0,y0,x1,y1 = xy
    r = radius
    draw.rounded_rectangle([x0,y0,x1,y1], radius=r, fill=fill,
                            outline=outline, width=width)

def text_c(draw, xy, txt, fnt, color="#1C1C1E", anchor="mm"):
    draw.text(xy, txt, font=fnt, fill=color, anchor=anchor)

def wrap_text(draw, x, y, txt, fnt, max_w, color="#1C1C1E", line_gap=6, anchor="la"):
    words = txt.split()
    lines, cur = [], ""
    for w in words:
        test = (cur + " " + w).strip()
        bb = draw.textbbox((0,0), test, font=fnt)
        if bb[2]-bb[0] <= max_w:
            cur = test
        else:
            if cur: lines.append(cur)
            cur = w
    if cur: lines.append(cur)
    lh = draw.textbbox((0,0),"Ag",font=fnt)[3] + line_gap
    for i,ln in enumerate(lines):
        draw.text((x, y+i*lh), ln, font=fnt, fill=color, anchor=anchor)
    return y + len(lines)*lh

def arrow(draw, x1,y1,x2,y2, color="#37474F", w=4, head=18):
    draw.line([(x1,y1),(x2,y2)], fill=color, width=w)
    angle = math.atan2(y2-y1, x2-x1)
    for da in [0.45, -0.45]:
        ax = x2 - head*math.cos(angle-da)
        ay = y2 - head*math.sin(angle-da)
        draw.line([(x2,y2),(ax,ay)], fill=color, width=w)

def badge(draw, cx, cy, r, fill, text, fnt, tcol="white"):
    draw.ellipse([cx-r,cy-r,cx+r,cy+r], fill=fill)
    draw.text((cx,cy), text, font=fnt, fill=tcol, anchor="mm")

def step_pill(draw, x, y, w, h, num, label, bg, fg="white"):
    rrect(draw, [x,y,x+w,y+h], radius=h//2, fill=bg)
    f_num  = font(32, bold=True)
    f_lbl  = font(28, bold=True)
    badge(draw, x+h//2, y+h//2, h//2-4, "#FFFFFF44", str(num), f_num, tcol="white")
    draw.text((x+h+14, y+h//2), label, font=f_lbl, fill=fg, anchor="lm")

def divider(draw, y, color="#B0BEC5", pad=60):
    draw.line([(pad,y),(W-pad,y)], fill=color, width=2)

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 1 – HEADER
# ═══════════════════════════════════════════════════════════════════════════════
rrect(draw, [0,0,W,170], radius=0, fill=C["header_bg"])
draw.text((W//2, 58),  "ANEMIA", font=font(86,bold=True),  fill="#FFFFFF", anchor="mm")
draw.text((W//2, 128), "Complete Diagnostic Approach – Stepwise Reference",
          font=font(34), fill="#90CAF9", anchor="mm")

# red bar accent
draw.rectangle([0,170,W,182], fill="#EF5350")

# ── Hb normal values strip ──
yy = 196
rrect(draw, [40,yy,W-40,yy+80], radius=14, fill="#E3F2FD", outline="#1565C0", width=2)
vals = [
    ("Adult ♂",  "≥13 g/dL"),
    ("Adult ♀",  "≥12 g/dL"),
    ("Pregnant", "≥11 g/dL"),
    ("Child",    "≥11 g/dL"),
    ("Newborn",  "17 g/dL"),
]
col_w = (W-80) // len(vals)
for i,(lbl,val) in enumerate(vals):
    cx = 40 + i*col_w + col_w//2
    draw.text((cx, yy+22), lbl, font=font(24, bold=True), fill=C["step_blue"], anchor="mm")
    draw.text((cx, yy+56), val, font=font(28, bold=True), fill=C["red"],       anchor="mm")
    if i < len(vals)-1:
        draw.line([(40+i*col_w+col_w, yy+8),(40+i*col_w+col_w, yy+72)], fill=C["light_line"], width=2)

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 2 – STEPS 1-2 (History + Physical) side by side
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 300
step_pill(draw, 40, y0, 420, 48, 1, "HISTORY", C["step_blue"])
step_pill(draw, 1640, y0, 520, 48, 2, "PHYSICAL EXAM", C["teal"])

# history box
rrect(draw, [40,y0+56,1580,y0+56+260], radius=14, fill="#E8EAF6", outline="#3949AB", width=2)
hist = [
    "• Prior anemia, iron pills, transfusions, blood donation",
    "• Menstrual hx: duration, pads/clots (premenopausal ♀)",
    "• Family hx: hemoglobinopathy, hereditary spherocytosis",
    "• Diet: vegan/vegetarian (B12↓), poor diet (folate↓), alcohol",
    "• GI: diarrhea (celiac/IBD), melena, NSAID use → occult loss",
    "• Meds: chemo, methotrexate, antiseizure, ACE inhibitors",
    "• Ethnicity/geography: sickle cell, thalassemia",
]
fy = y0+76
for h in hist:
    draw.text((60, fy), h, font=font(24), fill=C["text"]); fy+=34

# physical box
rrect(draw, [1640,y0+56,W-40,y0+56+260], radius=14, fill="#E0F2F1", outline="#00695C", width=2)
phys = [
    "• Pallor: conjunctiva, mucosa, nail beds",
    "• Tachycardia, flow murmur, dyspnoea",
    "• Splenomegaly → hemolysis / lymphoma",
    "• Koilonychia, glossitis → iron deficiency",
    "• Neuro signs (posterior column) → B12↓",
    "• Lymphadenopathy → lymphoma/leukemia",
    "• Rectal exam / FOBT → GI blood loss",
]
fy = y0+76
for p in phys:
    draw.text((1660, fy), p, font=font(24), fill=C["text"]); fy+=34

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 3 – STEP 3: CBC indices
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 640
step_pill(draw, 40, y0, 620, 48, 3, "CBC + RETICULOCYTE COUNT", C["purple"])

rrect(draw, [40,y0+56,W-40,y0+56+110], radius=14, fill="#F3E5F5", outline="#7B1FA2", width=2)
indices = [
    ("MCV",  "80–100 fL", "Size classification"),
    ("MCH",  "27–33 pg",  "Hb per cell"),
    ("MCHC", "32–36 g/dL","Hb concentration"),
    ("RDW",  "11.5–14.5%","Anisocytosis"),
    ("Retic","0.5–1.5%",  "Marrow output"),
]
cw = (W-80)//len(indices)
for i,(nm,nrm,desc) in enumerate(indices):
    cx = 40 + i*cw + cw//2
    draw.text((cx, y0+76),  nm,   font=font(28,bold=True), fill=C["purple"],  anchor="mm")
    draw.text((cx, y0+106), nrm,  font=font(24,bold=True), fill=C["red"],     anchor="mm")
    draw.text((cx, y0+134), desc, font=font(20),           fill=C["subtext"], anchor="mm")
    if i < len(indices)-1:
        draw.line([(40+i*cw+cw,y0+62),(40+i*cw+cw,y0+154)], fill=C["light_line"], width=2)

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 4 – RETICULOCYTE BRANCH (big infographic)
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 820
step_pill(draw, 40, y0, 820, 48, 4, "RETICULOCYTE COUNT – MASTER BRANCH POINT", C["red"])

# Central retic box
cx_retic = W//2
rrect(draw, [cx_retic-280, y0+60, cx_retic+280, y0+138], radius=20,
      fill="#B71C1C", outline="#FFCDD2", width=3)
draw.text((cx_retic, y0+99), "ABSOLUTE RETICULOCYTE COUNT",
          font=font(28,bold=True), fill="white", anchor="mm")

# LEFT branch – HIGH
lx = 240
rrect(draw, [40, y0+164, 980, y0+164+90], radius=16,
      fill=C["retic_hi"], outline="#EF9A9A", width=3)
draw.text((510, y0+164+30), "RETIC  HIGH  (>100K/μL)",
          font=font(30,bold=True), fill="white", anchor="mm")
draw.text((510, y0+164+62), "Bone marrow IS responding → Loss/Destruction",
          font=font(22), fill="#FFCDD2", anchor="mm")

arrow(draw, cx_retic-280, y0+99, 980, y0+164+45, color=C["retic_hi"], w=5)

# RIGHT branch – LOW
rrect(draw, [W-980, y0+164, W-40, y0+164+90], radius=16,
      fill=C["retic_lo"], outline="#90CAF9", width=3)
draw.text((W-510, y0+164+30), "RETIC  LOW  (<50K/μL)",
          font=font(30,bold=True), fill="white", anchor="mm")
draw.text((W-510, y0+164+62), "Bone marrow NOT responding → Underproduction",
          font=font(22), fill="#BBDEFB", anchor="mm")

arrow(draw, cx_retic+280, y0+99, W-980, y0+164+45, color=C["retic_lo"], w=5)

# Sub-boxes HIGH
yh = y0+280
hboxes = [
    ("BLEEDING?",     "GI loss, menstrual\noccult blood, trauma",        "#FF8F00"),
    ("HEMOLYSIS",     "LDH↑, Haptoglobin↓\nIndir. bili↑",               "#C62828"),
    ("IMMUNE",        "DAT+  →  AIHA\nanti-IgG/complement",             "#AD1457"),
    ("NON-IMMUNE",    "G6PD, HS, PNH\nHb electrophoresis",               "#6A1B9A"),
]
bw = 930//len(hboxes)
for i,(t,d,col) in enumerate(hboxes):
    bx = 40 + i*bw
    rrect(draw, [bx, yh, bx+bw-10, yh+110], radius=12, fill=col, outline=None)
    draw.text((bx+bw//2-5, yh+26), t,  font=font(22,bold=True), fill="white", anchor="mm")
    wrap_text(draw, bx+12, yh+44, d, font(19), bw-24, color="#FFECB3")

# Sub-boxes LOW  
lboxes = [
    ("MICROCYTIC\nMCV<80",   "Fe def · Thal\nACD · Sideroblastic", C["micro_c"]),
    ("NORMOCYTIC\nMCV80-100","Renal · Inflam\nAplastic · Endocrine",C["normo_c"]),
    ("MACROCYTIC\nMCV>100",  "B12/Folate def\nAlcohol · MDS",       C["macro_c"]),
    ("BONE MARROW\n(if unclear)", "Aplastic · MDS\nLeukemia · Myeloma","#4A148C"),
]
bw2 = 930//len(lboxes)
for i,(t,d,col) in enumerate(lboxes):
    bx = W-980 + i*bw2
    rrect(draw, [bx, yh, bx+bw2-10, yh+110], radius=12, fill=col, outline=None)
    for j,ln in enumerate(t.split("\n")):
        draw.text((bx+bw2//2-5, yh+22+j*26), ln, font=font(21,bold=True), fill="white", anchor="mm")
    wrap_text(draw, bx+12, yh+74, d, font(19), bw2-24, color="#FFFFFF")

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 5 – MCV CLASSIFICATION (3 columns)
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 1100
step_pill(draw, 40, y0, 700, 48, 5, "MCV-BASED CLASSIFICATION", C["navy"])

col_w3 = (W-80)//3
titles = ["MICROCYTIC  (MCV < 80 fL)", "NORMOCYTIC  (MCV 80–100 fL)", "MACROCYTIC  (MCV > 100 fL)"]
colors = [C["micro_bg"], C["normo_bg"], C["macro_bg"]]
borders = [C["micro_c"], C["normo_c"], C["macro_c"]]
hdr_cols= [C["micro_c"], C["normo_c"], C["macro_c"]]

micro_content = [
    ("Iron Deficiency",   "Ferritin↓, TIBC↑\nSat <10%, RDW↑"),
    ("Thalassemia",       "Ferritin N/↑, TIBC N\nRDW LOW, Hb electro"),
    ("Anemia of Inflam.", "Ferritin↑, TIBC↓\nhepcidin↑, Fe↓"),
    ("Sideroblastic",     "Ring sideroblasts\nFe↑, saturation↑"),
]
normo_content = [
    ("Renal disease",     "eGFR<60, EPO↓\nNormocytic, EPO Rx"),
    ("Anemia of Inflam.", "If early/mild\nCRP/ESR↑"),
    ("Aplastic anemia",   "Pancytopenia\nBM hypocellular"),
    ("Endocrinopathy",    "TSH, cortisol\nHypothyroid/Addison"),
    ("Marrow invasion",   "Teardrops, nRBCs\nBM biopsy"),
]
macro_content = [
    ("B12 deficiency",    "Oval macros\nHyperseg PMNs, MMA↑"),
    ("Folate deficiency", "Oval macros\nHomocysteine↑"),
    ("Alcohol/Liver",     "Round macros\nLFT abnormal"),
    ("Hypothyroidism",    "Round macros\nTSH↑"),
    ("MDS",               "Oval macros\nNormal B12/folate\n→ BM biopsy"),
]
all_content = [micro_content, normo_content, macro_content]

box_top = y0+56
for col,(title,bg,bord,hc,content) in enumerate(zip(titles,colors,borders,hdr_cols,all_content)):
    x0c = 40 + col*col_w3
    rrect(draw, [x0c, box_top, x0c+col_w3-12, box_top+580], radius=16, fill=bg, outline=bord, width=3)
    # header
    rrect(draw, [x0c, box_top, x0c+col_w3-12, box_top+46], radius=14, fill=hc)
    draw.text((x0c+(col_w3-12)//2, box_top+23), title, font=font(24,bold=True),
              fill="white", anchor="mm")
    iy = box_top+60
    for (nm,details) in content:
        # sub-item
        rrect(draw, [x0c+12, iy, x0c+col_w3-24, iy+90], radius=10,
              fill="white", outline=bord, width=1)
        draw.text((x0c+22, iy+14), "▶  "+nm, font=font(22,bold=True), fill=hc)
        wrap_text(draw, x0c+22, iy+40, details, font(19), col_w3-60, color=C["subtext"])
        iy += 100

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 6 – IRON STUDIES TABLE + DIFFERENTIAL
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 1730
step_pill(draw, 40, y0, 820, 48, 6, "IRON STUDIES: KEY DIFFERENTIAL", C["orange"])

# table
table_y = y0+60
cols_t = ["TEST", "IRON DEFICIENCY", "ANEMIA OF INFLAM.", "THALASSEMIA", "SIDEROBLASTIC"]
col_ws = [340, 480, 480, 380, 380]
col_xs = [40]
for w in col_ws[:-1]: col_xs.append(col_xs[-1]+w)

# header row
hrow_y = table_y
total_w = sum(col_ws)
rrect(draw, [40, hrow_y, 40+total_w, hrow_y+52], radius=10, fill=C["navy"])
for i,(c,cw,cx) in enumerate(zip(cols_t,col_ws,col_xs)):
    draw.text((cx+cw//2, hrow_y+26), c, font=font(22,bold=True), fill="white", anchor="mm")

rows = [
    ("Smear",         "Micro/hypo",          "Normal or micro/hypo",  "Micro+targeting",   "Variable"),
    ("Serum Fe",      "↓ (<30 μg/dL)",        "↓ (<50)",               "Normal–High",       "Normal–High"),
    ("TIBC",          "↑ (>360 μg/dL)",       "↓ (<300)",              "Normal",            "Normal"),
    ("Sat%",          "< 10%",               "10–20%",                "30–80%",            "30–80%"),
    ("Ferritin",      "↓ (<15 μg/L) ⚠",      "↑ (30–200)",            "↑ (50–300)",        "↑ (50–300)"),
    ("RDW",           "↑ HIGH",              "Normal",                "↓ LOW",             "Variable"),
    ("Hb Electro",    "Normal",              "Normal",                "Abnormal (β-thal)", "Normal"),
]
row_colors = ["#FFF8E1","#FFF3E0","#FFF8E1","#FFF3E0","#FFEBEE","#FFF8E1","#FFF3E0"]
highlight_cols = {"↓ (<15 μg/L) ⚠": "#EF5350", "↑ HIGH":"#E65100", "↓ LOW":"#1565C0",
                  "< 10%":"#C62828"}

for ri,(row) in enumerate(rows):
    ry = table_y + 52 + ri*54
    rrect(draw, [40, ry, 40+total_w, ry+54], radius=0, fill=row_colors[ri])
    for ci,(cell,cw,cx) in enumerate(zip(row,col_ws,col_xs)):
        clr = C["text"]
        for k,v in highlight_cols.items():
            if k in cell: clr=v; break
        fw = font(21,bold=(ci==0))
        draw.text((cx+cw//2, ry+27), cell, font=fw, fill=clr, anchor="mm")
    draw.line([(40,ry),(40+total_w,ry)], fill=C["light_line"], width=1)

# border around table
draw.rectangle([40, table_y, 40+total_w, table_y+52+len(rows)*54], outline=C["orange"], width=2)

# ferritin note
note_y = table_y + 52 + len(rows)*54 + 10
draw.text((60, note_y), "⚠  Ferritin is an acute-phase reactant — may be falsely NORMAL/HIGH in combined iron deficiency + inflammation. Use sTfR/log ferritin index to distinguish.",
          font=font(21,italic=True), fill=C["red"])

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 7 – PERIPHERAL SMEAR MORPHOLOGY TABLE (visual icons)
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 2310
step_pill(draw, 40, y0, 820, 48, 7, "PERIPHERAL BLOOD SMEAR – MORPHOLOGY GUIDE", C["teal"])

morph_data = [
    ("Microcytic\nHypochromic",  "Small cells, large central pallor\n>1/3 diameter",      "Iron def · Thalassemia · ACD",         "#FF8F00"),
    ("Macro-ovalocytes\n+ Hyperseg PMNs", "Large oval cells, PMN >5 lobes\n(megaloblastic)", "B12 / Folate deficiency · MDS",   "#2E7D32"),
    ("Spherocytes",              "No central pallor\n(sphere, not biconcave disc)",         "AIHA · Hereditary spherocytosis",      "#C62828"),
    ("Schistocytes",             "Red cell fragments\n(helmet cells, triangles)",           "TTP · HUS · DIC · Valve hemolysis",    "#AD1457"),
    ("Sickle cells",             "Elongated, crescent-shaped\ncells",                       "Sickle cell disease (HbSS/HbSC)",      "#4A148C"),
    ("Target cells",             "Bulls-eye/shooting-target\nappearance",                  "Thalassemia · Liver disease · HbC",    "#1565C0"),
    ("Teardrop cells\n+ nRBCs",  "Teardrop shape + nucleated RBCs\n+ immature WBCs",       "Myelofibrosis · Marrow infiltration",  "#37474F"),
    ("Basophilic\nStippling",    "Blue dots in RBCs\n(precipitated ribosomes)",             "Thalassemia · Lead poisoning",         "#6A1B9A"),
]

cols_m = 4
rows_m = math.ceil(len(morph_data)/cols_m)
bw_m = (W-80)//cols_m
bh_m = 140
my_start = y0+60

for idx,(nm,desc,dx,col) in enumerate(morph_data):
    mc = idx % cols_m
    mr = idx // cols_m
    mx = 40 + mc*bw_m
    my = my_start + mr*(bh_m+12)
    rrect(draw, [mx, my, mx+bw_m-10, my+bh_m], radius=12, fill="#FFFFFF", outline=col, width=3)
    # coloured left accent
    draw.rectangle([mx, my, mx+10, my+bh_m], fill=col)
    for j,ln in enumerate(nm.split("\n")):
        draw.text((mx+22, my+16+j*28), ln, font=font(22,bold=True), fill=col)
    wrap_text(draw, mx+22, my+66, desc, font(19), bw_m-50, color=C["subtext"])
    wrap_text(draw, mx+22, my+104, "→ "+dx, font(19,italic=True), bw_m-50, color=C["text"])

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 8 – HEMOLYSIS WORKUP
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 2680
step_pill(draw, 40, y0, 620, 48, 8, "HEMOLYSIS WORKUP", C["red"])

hemo_tests = [
    ("LDH",          "↑ (RBC enzyme released)", "#EF5350"),
    ("Haptoglobin",  "↓ (binds free Hb)", "#C62828"),
    ("Indirect bili","↑ (Hb breakdown)", "#FF8F00"),
    ("Urine Hb/Hemosidin","+ (intravascular)", "#AD1457"),
    ("DAT (Coombs)", "+ → immune AIHA", "#1565C0"),
    ("G6PD assay",   "Low → G6PD def", "#2E7D32"),
    ("Hb electrophoresis","Abnormal → hemoglobinopathy","#6A1B9A"),
    ("Flow cytometry","CD55/CD59 absent → PNH","#00695C"),
]

bw_h = (W-80)//4
for i,(nm,val,col) in enumerate(hemo_tests):
    hx = 40 + (i%4)*bw_h
    hy = y0+60 + (i//4)*90
    rrect(draw, [hx, hy, hx+bw_h-10, hy+82], radius=12, fill="#FFF",
          outline=col, width=2)
    draw.rectangle([hx, hy, hx+bw_h-10, hy+8], fill=col)
    draw.text((hx+16, hy+18), nm,  font=font(22,bold=True), fill=col)
    draw.text((hx+16, hy+48), val, font=font(20),           fill=C["text"])

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 9 – B12 vs FOLATE vs MDS
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 2940
step_pill(draw, 40, y0, 820, 48, 9, "MACROCYTIC: B12 vs FOLATE vs MDS", C["green"])

macro_cols = ["FEATURE", "B12 DEFICIENCY", "FOLATE DEFICIENCY", "MDS"]
macro_rows = [
    ("Serum B12",    "LOW  (<200 pg/mL)", "Normal",           "Normal"),
    ("Serum Folate", "Normal",            "LOW",              "Normal"),
    ("Homocysteine", "↑↑",               "↑↑",              "Normal"),
    ("MMA",          "↑↑ (B12-specific)","Normal",           "Normal"),
    ("Neurology",    "YES (post. column)","No",               "No"),
    ("Bone marrow",  "Megaloblastic",     "Megaloblastic",    "Dysplastic\n± ring sideroblasts"),
    ("Treatment",    "B12 IM/oral",       "Folic acid oral",  "Supportive / azacitidine"),
]
col_ws_m = [380, 520, 520, 460]
col_xs_m = [40]; 
for w in col_ws_m[:-1]: col_xs_m.append(col_xs_m[-1]+w)
t_total = sum(col_ws_m)
th = y0+60
rrect(draw, [40, th, 40+t_total, th+50], radius=10, fill=C["green"])
for c,cw,cx in zip(macro_cols, col_ws_m, col_xs_m):
    draw.text((cx+cw//2, th+25), c, font=font(22,bold=True), fill="white", anchor="mm")

for ri,row in enumerate(macro_rows):
    ry = th+50+ri*60
    fill = "#F1F8E9" if ri%2==0 else "#FFFFFF"
    draw.rectangle([40,ry,40+t_total,ry+60], fill=fill)
    for ci,(cell,cw,cx) in enumerate(zip(row,col_ws_m,col_xs_m)):
        clr = C["red"] if "LOW" in cell and ci<2 else (C["green"] if ci==0 else C["text"])
        if "↑↑" in cell: clr=C["red"]
        wrap_text(draw, cx+8, ry+12, cell, font(20,bold=(ci==0)), cw-16, color=clr)
    draw.line([(40,ry),(40+t_total,ry)], fill=C["light_line"],width=1)
draw.rectangle([40,th,40+t_total,th+50+len(macro_rows)*60], outline=C["green"],width=2)

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 10 – BONE MARROW INDICATIONS
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 3400
step_pill(draw, 40, y0, 620, 48, 10, "BONE MARROW BIOPSY – INDICATIONS", "#4A148C")

bm_indications = [
    "Unexplained severe / refractory anemia",
    "Pancytopenia",
    "Myelophthisic picture (teardrops + nRBCs + leukoerythroblastosis)",
    "Macro-ovalocytes with normal B12 / folate → suspect MDS",
    "Suspected aplastic anemia",
    "Staging of lymphoma, myeloma, other malignancies",
    "Unexplained circulating blasts or nucleated RBCs",
]
rrect(draw, [40, y0+60, W//2-20, y0+60+270], radius=14, fill="#EDE7F6", outline="#4A148C", width=2)
for i,ind in enumerate(bm_indications):
    draw.text((70, y0+84+i*36), f"{'①②③④⑤⑥⑦'[i]}  {ind}", font=font(22), fill=C["text"])

# BM findings box
rrect(draw, [W//2+20, y0+60, W-40, y0+60+270], radius=14, fill="#EDE7F6", outline="#4A148C", width=2)
draw.text((W//2+40, y0+82), "BM FINDINGS:", font=font(24,bold=True), fill="#4A148C")
bm_finds = [
    ("Hypocellular marrow",        "→ Aplastic anemia"),
    ("Absent erythroid precursors","→ Pure red cell aplasia"),
    ("Ring sideroblasts",          "→ Sideroblastic anemia / MDS"),
    ("Megaloblasts",               "→ B12/Folate (if not treated)"),
    ("Fibrosis + teardrops",       "→ Myelofibrosis"),
    ("Blasts >20%",                "→ Acute leukemia (AML/ALL)"),
]
for i,(f,r) in enumerate(bm_finds):
    fy2 = y0+114+i*34
    draw.text((W//2+50, fy2), f"• {f}", font=font(21), fill=C["text"])
    draw.text((W//2+50+450, fy2), r, font=font(21,bold=True), fill="#4A148C")

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 11 – SEVERITY BOX
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 3720
rrect(draw, [40, y0, W-40, y0+100], radius=16, fill="#263238", outline="#37474F", width=2)
draw.text((W//2, y0+20), "SEVERITY CLASSIFICATION", font=font(26,bold=True), fill="#80CBC4", anchor="mm")
sev = [("MILD","10–12 g/dL","#4CAF50"),("MODERATE","8–10 g/dL","#FF9800"),
       ("SEVERE","6–8 g/dL","#F44336"),("LIFE-THREATENING","<6 g/dL","#B71C1C")]
sw = (W-80)//len(sev)
for i,(nm,rng,col) in enumerate(sev):
    sx = 40 + i*sw + sw//2
    draw.text((sx, y0+55), nm,  font=font(24,bold=True), fill=col,     anchor="mm")
    draw.text((sx, y0+82), rng, font=font(22),           fill="#ECEFF1",anchor="mm")
    if i<len(sev)-1:
        draw.line([(40+i*sw+sw, y0+30),(40+i*sw+sw, y0+95)], fill="#546E7A", width=2)

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 12 – ALGORITHM FLOWCHART (central visual)
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 3860
step_pill(draw, 40, y0, 620, 48, 11, "DIAGNOSTIC ALGORITHM", C["navy"])

# flowchart nodes
def flow_box(draw, cx, cy, w, h, text, fill, text_col="white", fsize=22, radius=14):
    rrect(draw, [cx-w//2, cy-h//2, cx+w//2, cy+h//2], radius=radius, fill=fill)
    lines = text.split("\n")
    lh = fsize+6
    ty = cy - (len(lines)-1)*lh//2
    for ln in lines:
        draw.text((cx, ty), ln, font=font(fsize, bold=True), fill=text_col, anchor="mm")
        ty += lh

def diamond(draw, cx, cy, w, h, text, fill, text_col="white"):
    pts = [(cx,cy-h//2),(cx+w//2,cy),(cx,cy+h//2),(cx-w//2,cy)]
    draw.polygon(pts, fill=fill)
    draw.polygon(pts, outline="#FFFFFF", width=2)
    draw.text((cx, cy), text, font=font(21,bold=True), fill=text_col, anchor="mm")

fa = y0+68
# Start
flow_box(draw, W//2, fa,    600, 50, "LOW HEMOGLOBIN (CBC)", C["navy"], fsize=24)
arrow(draw, W//2, fa+25, W//2, fa+80, color=C["arrow"], w=4)

# Smear + retic
flow_box(draw, W//2, fa+100, 700, 50, "Peripheral Blood Smear  +  Reticulocyte Count", C["teal"], fsize=22)
arrow(draw, W//2, fa+125, W//2, fa+175, color=C["arrow"], w=4)

# Diamond retic
diamond(draw, W//2, fa+210, 580, 90, "RETIC HIGH?", C["red"])

# YES left
arrow(draw, W//2-290, fa+210, W//2-560, fa+210, color=C["retic_hi"], w=4)
flow_box(draw, W//2-700, fa+210, 300, 60, "BLEEDING\nor\nHEMOLYSIS", C["retic_hi"], fsize=20)

# NO right
arrow(draw, W//2+290, fa+210, W//2+560, fa+210, color=C["retic_lo"], w=4)
flow_box(draw, W//2+700, fa+210, 300, 60, "UNDER-\nPRODUCTION", C["retic_lo"], fsize=20)

# down arrow to MCV
arrow(draw, W//2, fa+255, W//2, fa+310, color=C["arrow"], w=4)
diamond(draw, W//2, fa+345, 400, 80, "MCV?", C["purple"])

# micro
arrow(draw, W//2-200, fa+345, W//2-560, fa+345, color=C["micro_c"], w=4)
flow_box(draw, W//2-700, fa+345, 300, 60, "< 80 fL\nMICROCYTIC", C["micro_c"], fsize=20)
arrow(draw, W//2-700, fa+375, W//2-700, fa+430, color=C["micro_c"], w=3)
flow_box(draw, W//2-700, fa+465, 300, 60, "Ferritin · Fe ·\nTIBC · RDW\nHb Electro", C["micro_c"], fsize=18)

# normo
arrow(draw, W//2, fa+385, W//2, fa+430, color=C["normo_c"], w=4)
flow_box(draw, W//2, fa+465, 300, 60, "80–100 fL\nNORMOCYTIC", C["normo_c"], fsize=20)
arrow(draw, W//2, fa+495, W//2, fa+540, color=C["normo_c"], w=3)
flow_box(draw, W//2, fa+580, 300, 80, "eGFR · EPO\nTSH · SPEP\nBM biopsy?", C["normo_c"], fsize=18)

# macro
arrow(draw, W//2+200, fa+345, W//2+560, fa+345, color=C["macro_c"], w=4)
flow_box(draw, W//2+700, fa+345, 300, 60, "> 100 fL\nMACROCYTIC", C["macro_c"], fsize=20)
arrow(draw, W//2+700, fa+375, W//2+700, fa+430, color=C["macro_c"], w=3)
flow_box(draw, W//2+700, fa+465, 300, 60, "B12 · Folate\nTSH · LFTs\nBM if normal", C["macro_c"], fsize=18)

# ═══════════════════════════════════════════════════════════════════════════════
# SECTION 13 – KEY PEARLS
# ═══════════════════════════════════════════════════════════════════════════════
y0 = 4620
rrect(draw, [40, y0, W-40, y0+120], radius=16, fill="#1A237E", outline="#3F51B5", width=2)
draw.text((W//2, y0+22), "⚡  KEY DIAGNOSTIC PEARLS",
          font=font(30,bold=True), fill="#FFD54F", anchor="mm")
pearls = [
    "Retic count = Master branch point",
    "Ferritin <15 = Iron-depleted stores",
    "RDW HIGH + micro = IDA  |  RDW LOW + micro = Thalassemia",
    "Haptoglobin LOW = Hemolysis",
    "Hyperseg PMNs + oval macros = Megaloblastic",
    "MMA↑ (normal folate) = B12-specific",
    "Teardrops + nRBCs = Myelophthisic → Bone marrow biopsy",
    "≥75% anemia = Hypoproliferative",
]
px = 60; py = y0+52
for i,p in enumerate(pearls):
    col = "#FFD54F" if i%2==0 else "#80CBC4"
    draw.text((px, py), f"✦ {p}", font=font(21), fill=col)
    px += (W-80)//4
    if (i+1)%4==0: px=60; py+=36

# ═══════════════════════════════════════════════════════════════════════════════
# FOOTER
# ═══════════════════════════════════════════════════════════════════════════════
rrect(draw, [0,H-52,W,H], radius=0, fill=C["navy"])
draw.text((W//2, H-26),
          "Harrison's 22E (2025)  |  Robbins & Kumar Pathologic Basis of Disease  |  Goldman-Cecil Medicine  |  Tintinalli's Emergency Medicine",
          font=font(20), fill="#90CAF9", anchor="mm")

# ── Save ──────────────────────────────────────────────────────────────────────
out = "/home/daytona/workspace/anemia-note/Anemia_Diagnostic_Note.png"
img.save(out, "PNG", dpi=(200,200))
print(f"Saved → {out}")
print(f"Size: {W}x{H}px")
Running Command

cd /home/daytona/workspace/anemia-note && python3 generate_note.py 2>&1

Reading File
Running Command

python3 -c " from PIL import Image img = Image.open('/home/daytona/workspace/anemia-note/Anemia_Diagnostic_Note.png') print('Size:', img.size, 'Mode:', img.mode) # make a preview thumbnail thumb = img.copy() thumb.thumbnail((800, 1200)) thumb.save('/home/daytona/workspace/anemia-note/preview.png') print('Preview saved') "

Loading Image
Running Command

python3 -c " from PIL import Image import base64, sys img = Image.open('/home/daytona/workspace/anemia-note/preview.png') print(img.size) # encode and print first 200 chars to confirm import io buf = io.BytesIO() img.save(buf, 'PNG') b64 = base64.b64encode(buf.getvalue()).decode() print('b64 length:', len(b64)) "

Running Command

ls -lh /home/daytona/workspace/anemia-note/

Your single-page diagnostic note is ready!

Anemia Diagnostic Note

Image · PNG


Here's what's packed into the note (11 labeled sections):
#SectionVisual Style
1Header + Normal Hb valuesDeep navy banner with colour-coded reference strip
2History + Physical ExamSide-by-side tinted panels
3CBC IndicesQuick-reference bar with normal ranges
4Reticulocyte Count – Master Branch PointCentral red diamond → High (red) / Low (blue) branches with sub-boxes
5MCV Classification3-column colour-coded grid (micro/normo/macro) with cause + test per entry
6Iron Studies Differential Table5-column table (IDA vs AoI vs Thal vs Sideroblastic) with red highlights
7Peripheral Smear Morphology Guide8 morphology tiles with coloured left-accent and → diagnosis
8Hemolysis Workup8 test cards (LDH, haptoglobin, DAT, G6PD, PNH screen, etc.)
9B12 vs Folate vs MDS Table7-row differential with MMA/homocysteine row highlighted
10Bone Marrow – Indications + FindingsSplit box (when to do it / what it shows)
11Diagnostic Algorithm FlowchartFull flowchart: Hb↓ → Smear+Retic → Retic branch → MCV branch → Tests
Key Pearls footerDark navy strip with 8 high-yield memory anchors

Create a single page note taking like image of this content and add infographics and illustrations wherever needed for quick understanding (Use generate poster tool)

Generating Image

Single-page medical note-taking style reference poster titled "ANEMIA – Complete Diagnostic Approach (Stepwise)". Dark navy and white clinical design with color-coded sections. Include: TOP HEADER: Bold title "ANEMIA – Complete Diagnostic Approach" in deep navy banner. Below: Normal Hb values strip showing Adult Male ≥13 g/dL, Adult Female ≥12 g/dL, Pregnant ≥11 g/dL, Child ≥11 g/dL in colored badges. STEP 1 – HISTORY & PHYSICAL (two side-by-side boxes): Left box (blue): History bullets: prior anemia/transfusions, menstrual history (clots, pads), family hx hemoglobinopathy, dietary hx (vegan=B12↓), GI symptoms/NSAIDs, alcohol, medications, ethnicity (sickle cell/thal). Right box (teal): Physical Exam bullets: conjunctival/mucosal pallor, tachycardia, splenomegaly→hemolysis, koilonychia+glossitis→iron def, neurological signs→B12 def, lymphadenopathy, rectal exam/FOBT. STEP 2 – CBC INDICES: Horizontal strip showing MCV (80–100 fL), MCH (27–33 pg), MCHC (32–36 g/dL), RDW (11.5–14.5%), Reticulocyte (0.5–1.5%) in colored badge boxes. STEP 3 – RETICULOCYTE MASTER BRANCH (central infographic diamond): Large red diamond labeled "RETICULOCYTE COUNT?" in center. LEFT arrow → RED box: "RETIC HIGH >100K → Hemolysis/Bleeding" with sub-boxes: Bleeding?, AIHA (DAT+), Non-immune hemolysis (G6PD/HS/PNH), LDH↑ Haptoglobin↓ Bili↑ RIGHT arrow → BLUE box: "RETIC LOW → Underproduction" with sub-boxes: Microcytic (IDA/Thal), Normocytic (Renal/Aplastic), Macrocytic (B12/Folate/MDS) STEP 4 – MCV CLASSIFICATION (3 colored columns): Orange column "MICROCYTIC MCV<80": Iron Def (ferritin↓ TIBC↑ RDW↑), Thalassemia (RDW↓ Hb electro), ACD (ferritin↑ TIBC↓ hepcidin↑), Sideroblastic (ring sideroblasts) Blue column "NORMOCYTIC MCV 80-100": Renal disease (EPO↓), Aplastic anemia (pancytopenia BM hypocellular), Endocrinopathy (TSH), Marrow invasion (teardrops+nRBCs) Green column "MACROCYTIC MCV>100": B12 def (MMA↑ neuro signs), Folate def (homocysteine↑), Alcohol/Liver (round macros), MDS (BM biopsy) STEP 5 – IRON STUDIES TABLE (color-highlighted): 5-column table: Test | Iron Deficiency | Anemia of Inflammation | Thalassemia | Sideroblastic Rows: Serum Fe, TIBC, Sat%, Ferritin, RDW, Hb Electro Key highlights: Ferritin <15=IDA (red), TIBC >360=IDA (orange), RDW HIGH=IDA, RDW LOW=Thal (blue) Footer note: ⚠ Ferritin is acute-phase reactant – may be falsely normal in combined IDA + inflammation STEP 6 – PERIPHERAL SMEAR MORPHOLOGY (8 illustrated tiles in 2 rows): Each tile has colored left border, name, description, and → diagnosis: 1. Microcytic/Hypochromic → Iron def/Thal/ACD 2. Macro-ovalocytes + Hyperseg PMNs → B12/Folate/MDS 3. Spherocytes (no central pallor) → AIHA/Hereditary spherocytosis 4. Schistocytes (helmet cells) → TTP/HUS/DIC/Valve 5. Sickle cells (crescent) → HbSS sickle cell disease 6. Target cells (bull's-eye) → Thal/Liver/HbC 7. Teardrop cells + nRBCs → Myelofibrosis/Myelophthisic 8. Basophilic stippling → Thal/Lead poisoning STEP 7 – HEMOLYSIS WORKUP (8 test cards in grid): LDH ↑, Haptoglobin ↓, Indirect bili ↑, Urine Hb/hemosiderin +, DAT+ → AIHA, G6PD assay low → G6PD def, Hb electrophoresis abnormal, Flow cytometry CD55/CD59 absent → PNH STEP 8 – MACROCYTIC DIFFERENTIAL TABLE: Feature | B12 Deficiency | Folate Deficiency | MDS B12: LOW / Normal / Normal Folate: Normal / LOW / Normal MMA: ↑↑ / Normal / Normal Neurology: YES / No / No BM: Megaloblastic / Megaloblastic / Dysplastic STEP 9 – DIAGNOSTIC ALGORITHM FLOWCHART (bottom center): Box: "Hb LOW" → Box: "PBS + Retic Count" → Diamond: "Retic HIGH?" → Yes: Hemolysis/Bleeding workup → No: Diamond "MCV?" → 3 branches: <80 Microcytic (Ferritin/TIBC/RDW), 80-100 Normocytic (eGFR/EPO/TSH), >100 Macrocytic (B12/Folate/BM) STEP 10 – BONE MARROW INDICATIONS (two boxes): Left: Indications: unexplained severe anemia, pancytopenia, teardrops+nRBCs, oval macros + normal B12/folate, suspected aplastic, staging lymphoma/myeloma Right: BM findings: hypocellular→aplastic, ring sideroblasts→MDS, megaloblasts→B12/folate, fibrosis+teardrops→myelofibrosis, blasts >20%→AML SEVERITY BAND: Mild 10-12 (green) | Moderate 8-10 (orange) | Severe 6-8 (red) | Life-threatening <6 g/dL (dark red) KEY PEARLS FOOTER (dark navy): ✦ Retic count = master branch point ✦ Ferritin <15 = iron depleted ✦ RDW HIGH+micro=IDA, RDW LOW+micro=Thal ✦ Haptoglobin LOW = hemolysis ✦ Hyperseg PMNs + oval macros = megaloblastic ✦ MMA↑ normal folate = B12-specific ✦ Teardrops+nRBCs = myelophthisic → BM biopsy ✦ 75% anemia is hypoproliferative Sources: Harrison's 22E (2025) | Robbins & Kumar | Goldman-Cecil Medicine | Tintinalli's Emergency Medicine Clean medical infographic style, professional color coding, well-organized layout, all text legible, suitable for medical students and clinicians.

Anemia – Complete Diagnostic Approach (Stepwise) — single-page note-taking poster
Here's your single-page diagnostic note poster. It covers all 10 stepwise sections in one visual:
  • Header — title + normal Hb reference values by population
  • Steps 1–2 — History & Physical Exam side-by-side
  • Step 3 — CBC indices quick-reference bar
  • Step 4 — Reticulocyte count master branch diamond (High → Hemolysis/Bleeding | Low → Underproduction)
  • Step 5 — MCV 3-column classification (Microcytic / Normocytic / Macrocytic) with causes and tests
  • Step 6 — Iron studies differential table (IDA vs ACD vs Thal vs Sideroblastic) with key highlights
  • Step 7 — Peripheral smear morphology tiles (8 RBC abnormalities → diagnoses)
  • Step 8 — Hemolysis workup grid (LDH, haptoglobin, DAT, G6PD, PNH screen)
  • Step 9 — B12 vs Folate vs MDS differential table
  • Step 10 — Diagnostic algorithm flowchart + Bone marrow indications
  • Footer — Severity band + 8 high-yield pearls
This is a shared conversation. Sign in to Orris to start your own chat.