Physiological changes during pregnancy from dc dutta textbook and at the end make a detailed summary chart to download for easy visual memory
mkdir -p /home/daytona/workspace/pregnancy-physiology && ls /home/daytona/workspace/pregnancy-physiology/
~/pregnancy-physiology/make_chart.py
import openpyxl
from openpyxl.styles import (
PatternFill, Font, Alignment, Border, Side, GradientFill
)
from openpyxl.utils import get_column_letter
from openpyxl.styles.numbers import FORMAT_TEXT
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "Physiological Changes"
# ── Color Palette ──────────────────────────────────────────────────────────
COLORS = {
"navy": "1B2A4A",
"white": "FFFFFF",
"cns": "6A0DAD", # purple
"cns_light": "EDE7F6",
"cvs": "C0392B", # red
"cvs_light": "FDEDEC",
"resp": "1A6B8A", # teal
"resp_light":"E8F4F8",
"heme": "D35400", # orange
"heme_light":"FEF9E7",
"renal": "1E8449", # green
"renal_light":"E9F7EF",
"gi": "8E44AD", # violet
"gi_light": "F5EEF8",
"endo": "2874A6", # blue
"endo_light":"EBF5FB",
"msk": "6D4C41", # brown
"msk_light": "EFEBE9",
"skin": "B7950B", # gold
"skin_light":"FEF9E7",
"inc": "D5F5E3", # light green tint for ↑
"dec": "FADBD8", # light red tint for ↓
"neut": "EBF5FB", # light blue for ~no change
"row_alt": "F7F9FC",
"header_row":"2C3E50",
}
def mkfill(hex_color):
return PatternFill("solid", fgColor=hex_color)
def mkfont(bold=False, color="000000", size=10, italic=False):
return Font(bold=bold, color=color, size=size, italic=italic, name="Arial")
def mkalign(h="center", v="center", wrap=True):
return Alignment(horizontal=h, vertical=v, wrap_text=wrap)
thin = Side(style="thin", color="CCCCCC")
med = Side(style="medium", color="888888")
def thin_border():
return Border(left=thin, right=thin, top=thin, bottom=thin)
def med_border():
return Border(left=med, right=med, top=med, bottom=med)
# ─── Title ────────────────────────────────────────────────────────────────
ws.merge_cells("A1:F1")
ws["A1"] = "PHYSIOLOGICAL CHANGES DURING PREGNANCY"
ws["A1"].fill = mkfill(COLORS["navy"])
ws["A1"].font = mkfont(bold=True, color=COLORS["white"], size=16)
ws["A1"].alignment = mkalign()
ws.row_dimensions[1].height = 36
ws.merge_cells("A2:F2")
ws["A2"] = "Based on DC Dutta's Textbook of Obstetrics | Ref: Morgan & Mikhail's Clinical Anesthesiology 7e, Braunwald's Heart Disease, Creasy & Resnik's Maternal-Fetal Medicine"
ws["A2"].fill = mkfill("3D566E")
ws["A2"].font = mkfont(italic=True, color=COLORS["white"], size=9)
ws["A2"].alignment = mkalign()
ws.row_dimensions[2].height = 20
# ─── Column Headers ───────────────────────────────────────────────────────
headers = ["System", "Parameter", "Change", "Magnitude / Value", "Mechanism / Notes", "Clinical Significance"]
col_widths = [18, 26, 10, 28, 52, 44]
for i, (h, w) in enumerate(zip(headers, col_widths), 1):
c = ws.cell(row=3, column=i, value=h)
c.fill = mkfill(COLORS["header_row"])
c.font = mkfont(bold=True, color=COLORS["white"], size=11)
c.alignment = mkalign()
c.border = thin_border()
ws.column_dimensions[get_column_letter(i)].width = w
ws.row_dimensions[3].height = 26
# ─── Data ─────────────────────────────────────────────────────────────────
# Format: (system, system_color, system_light, parameter, arrow, magnitude, mechanism, clinical)
data = [
# ═══ CARDIOVASCULAR ═══
("CARDIOVASCULAR", "cvs", "cvs_light",
"Blood Volume", "↑", "+35–45% by 32–34 wks",
"Increased EPO → RBC mass ↑ 20–30%; plasma volume ↑ 40–55%; plasma rises more → dilutional anaemia",
"Hb falls to ~10.5 g/dL = physiological anaemia; supports uteroplacental flow"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Plasma Volume", "↑", "+50–55%",
"Aldosterone & oestrogen-mediated Na+ and water retention; peak at 32–34 weeks",
"Haemodilution of all blood elements; important in haemorrhage tolerance"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Cardiac Output", "↑", "+40–50% (peaks ~28–32 wks)",
"HR ↑ 15–20 bpm + stroke volume ↑ 30%; further ↑ 60–80% during labour/delivery",
"Heart disease may decompensate; greatest strain immediately postpartum"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Heart Rate", "↑", "+15–20 bpm (≈+20%)",
"Progesterone, autonomic shift; sinus tachycardia is normal",
"Baseline tachycardia may mask pathological tachyarrhythmias"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Stroke Volume", "↑", "+30%",
"Increased preload from plasma volume expansion; decreased afterload",
"Combined with HR rise → large CO increase"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Systolic BP", "↓", "-5 to -10 mmHg (1st/2nd trim)",
"Peripheral vasodilation due to progesterone & NO; returns to baseline by 3rd trimester",
"May mimic hypotension; DBP falls more than SBP"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Diastolic BP", "↓", "-10 to -15 mmHg",
"Marked peripheral vasodilation; nadir at 24 wks; rises back at term",
"Wide pulse pressure; useful in diagnosing PIH/pre-eclampsia"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Peripheral Vascular Resistance", "↓", "-15 to -20%",
"Progesterone, oestrogen, prostacyclin, NO-mediated smooth muscle relaxation",
"Protective against hypertension; low SVR mimics septic physiology"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"Pulmonary Vascular Resistance", "↓", "-30%",
"Pulmonary vasodilation parallels systemic changes",
"Important in pre-existing pulmonary hypertension management"),
("CARDIOVASCULAR", "cvs", "cvs_light",
"IVC Compression (supine)", "↑ risk", "After 20 weeks",
"Gravid uterus compresses IVC → ↓ venous return → ↓ CO; aortocaval compression syndrome",
"Supine hypotension in ~5% (pallor, nausea, syncope); left lateral tilt mandatory"),
# ═══ RESPIRATORY ═══
("RESPIRATORY", "resp", "resp_light",
"Tidal Volume (VT)", "↑", "+40% (~500→700 mL)",
"Progesterone stimulates respiratory centre; diaphragm elevation by 4 cm offsets",
"Increased minute ventilation → respiratory alkalosis"),
("RESPIRATORY", "resp", "resp_light",
"Respiratory Rate", "↑", "+15% (16→18–19/min)",
"Progesterone-mediated central respiratory drive increase",
"Tachypnoea > 20/min at rest is abnormal"),
("RESPIRATORY", "resp", "resp_light",
"Minute Ventilation (MV)", "↑", "+50%",
"Mainly VT increase; hyperventilation is physiological",
"Leads to chronic compensated respiratory alkalosis"),
("RESPIRATORY", "resp", "resp_light",
"Functional Residual Capacity (FRC)", "↓", "-20 to -25%",
"Diaphragm elevation by 4 cm due to uterus; closing volume may exceed FRC in supine",
"Rapid desaturation on apnoea; prone to atelectasis; difficult intubation risk"),
("RESPIRATORY", "resp", "resp_light",
"Residual Volume (RV)", "↓", "-20%",
"Diaphragm elevation; reduced chest wall compliance",
"Part of FRC reduction"),
("RESPIRATORY", "resp", "resp_light",
"Inspiratory Capacity (IC)", "↑", "+5–10%",
"Compensatory increase; TLC essentially unchanged",
"Maintains adequate tidal breathing despite diaphragm elevation"),
("RESPIRATORY", "resp", "resp_light",
"TLC", "↓ slightly", "-5%",
"Minimal change; IC ↑ partially compensates RV+ERV ↓",
"FVC and FEV1 not significantly changed"),
("RESPIRATORY", "resp", "resp_light",
"Airway Resistance", "↓", "-35%",
"Progesterone-mediated bronchodilation; mucosal oedema increases upper airway resistance",
"Asthma may improve; upper airway oedema worsens intubation difficulty"),
("RESPIRATORY", "resp", "resp_light",
"PaO₂", "↑", "+10% (~104–108 mmHg)",
"Hyperventilation increases alveolar O₂; progesterone raises hypoxic drive",
"Protects fetus; falls significantly in supine position"),
("RESPIRATORY", "resp", "resp_light",
"PaCO₂", "↓", "-15% (40→28–32 mmHg)",
"Hyperventilation; CO₂ eliminated faster; gradient favours fetal CO₂ transfer",
"Respiratory alkalosis; compensated by renal HCO₃ excretion"),
("RESPIRATORY", "resp", "resp_light",
"HCO₃", "↓", "-15% (~18–22 mEq/L)",
"Renal compensation for respiratory alkalosis; pre-pregnant norm ~24 mEq/L",
"ABG interpretation: normal in pregnancy = slightly alkalotic pH ~7.44"),
("RESPIRATORY", "resp", "resp_light",
"O₂ Consumption", "↑", "+20–50%",
"Fetal metabolic demand + increased maternal cardiac/respiratory work",
"Rapid hypoxaemia during apnoea; pre-oxygenation essential before GA"),
# ═══ HAEMATOLOGICAL ═══
("HAEMATOLOGICAL", "heme", "heme_light",
"Haemoglobin", "↓", "~11.5–12 g/dL (non-preg ~13)",
"Plasma volume ↑ > RBC mass ↑ → dilutional; physiological not pathological if ≥10.5",
"WHO defines anaemia in pregnancy as Hb < 11 g/dL (1st/3rd trim) or < 10.5 (2nd trim)"),
("HAEMATOLOGICAL", "heme", "heme_light",
"RBC Mass", "↑", "+20–30%",
"Erythropoietin ↑ (especially with iron supplementation); iron demand ~1000 mg total",
"Iron and folate supplementation essential; without iron, RBC rise is blunted"),
("HAEMATOLOGICAL", "heme", "heme_light",
"Platelets", "↓ slightly", "-10% (gestational thrombocytopenia)",
"Dilution + increased consumption; rarely pathological if >100,000",
"Gestational thrombocytopenia: mild (>70k), no foetal risk; resolves postpartum"),
("HAEMATOLOGICAL", "heme", "heme_light",
"Clotting Factors", "↑", "+30–250% (I, VII, VIII, IX, X, XII)",
"Oestrogen-driven hepatic synthesis ↑; fibrinogen rises to 400–600 mg/dL",
"Hypercoagulable state: DVT/PE risk ↑ 5×; Virchow's triad present"),
("HAEMATOLOGICAL", "heme", "heme_light",
"Fibrinogen", "↑", "400–600 mg/dL (norm 200–400)",
"Markedly elevated; contributes to raised ESR in pregnancy",
"High ESR is normal in pregnancy; elevated D-dimer unreliable for DVT diagnosis"),
("HAEMATOLOGICAL", "heme", "heme_light",
"Protein S / Antithrombin III", "↓", "Protein S ↓ ~55%",
"Acquired thrombophilia state in pregnancy; protein C essentially unchanged",
"Thromboprophylaxis critical in high-risk cases; warfarin teratogenic"),
("HAEMATOLOGICAL", "heme", "heme_light",
"WBC", "↑", "Up to 15,000/mm³ (labour: up to 25,000)",
"Demargination + increased production; mainly neutrophilia",
"Leukocytosis is normal; cannot reliably diagnose infection by WBC alone"),
("HAEMATOLOGICAL", "heme", "heme_light",
"ESR", "↑", "Markedly elevated",
"Elevated fibrinogen and globulins cause increased rouleaux formation",
"ESR not useful diagnostically in pregnancy"),
# ═══ RENAL ═══
("RENAL", "renal", "renal_light",
"Renal Blood Flow (RBF)", "↑", "+50–80% by 16 wks",
"Renal vasodilation parallels systemic vasodilation; relaxin mediates early rise",
"Returns to normal by late 3rd trimester; important for drug clearance"),
("RENAL", "renal", "renal_light",
"GFR", "↑", "+50% (120→180 mL/min)",
"Increased RBF + glomerular hyperfiltration; filtration fraction also increases",
"Serum creatinine, urea, uric acid fall – 'normal' values indicate renal impairment in pregnancy"),
("RENAL", "renal", "renal_light",
"Serum Creatinine", "↓", "0.4–0.6 mg/dL (norm ~0.8)",
"Dilution + increased GFR; >0.8 mg/dL may indicate renal pathology",
"Interpret creatinine cautiously; lower normal range in pregnancy"),
("RENAL", "renal", "renal_light",
"Serum Urea / BUN", "↓", "~8–10 mg/dL (norm ~13)",
"Increased filtration + anabolic state",
"BUN > 13 should raise concern in pregnancy"),
("RENAL", "renal", "renal_light",
"Glycosuria", "Present", "Normally absent in non-pregnant",
"Tubular reabsorptive capacity not increased despite ↑ GFR → glucose spills",
"Glycosuria is normal in pregnancy; screen for GDM with OGTT, not dipstick"),
("RENAL", "renal", "renal_light",
"Proteinuria", "↑ slightly", "Up to 300 mg/24 h",
"Increased glomerular filtration; ≤300 mg/24 h is upper limit of normal",
">300 mg/24h = significant proteinuria; cardinal feature of pre-eclampsia"),
("RENAL", "renal", "renal_light",
"Ureteric Dilation (Hydronephrosis)", "↑", "Right > Left",
"Progesterone-mediated smooth muscle relaxation + mechanical compression by uterus",
"Urinary stasis → ↑ UTI / pyelonephritis risk; asymmetric right-sided hydronephrosis is normal"),
("RENAL", "renal", "renal_light",
"Bladder Capacity", "↓", "Reduced, urgency common",
"Mechanical pressure from uterus; vesicoureteric reflux more common",
"Frequency and urgency are physiological; screen for UTI regardless"),
# ═══ GASTROINTESTINAL ═══
("GASTROINTESTINAL", "gi", "gi_light",
"Gastric Motility", "↓", "Delayed gastric emptying",
"Progesterone → smooth muscle relaxation → ↓ motility; displacement of stomach by uterus",
"↑ risk of aspiration during GA (Mendelson's syndrome); RSI mandatory"),
("GASTROINTESTINAL", "gi", "gi_light",
"Lower Oesophageal Sphincter (LOS) Tone", "↓", "Reduced barrier pressure",
"Progesterone relaxes LOS; uterus elevates intragastric pressure",
"Heartburn (pyrosis) universal; GERD; aspiration risk ↑ under GA"),
("GASTROINTESTINAL", "gi", "gi_light",
"Gastric Acid Secretion", "↓ (1st/2nd trim)", "Hypochlorhydria",
"hCG inhibits gastrin; 3rd trimester acid may ↑ due to placental gastrin",
"Nausea/vomiting of pregnancy (NVP); peaks at 6–12 wks"),
("GASTROINTESTINAL", "gi", "gi_light",
"Small Bowel Transit", "↓", "Prolonged transit time",
"Progesterone reduces peristalsis throughout GI tract",
"Constipation common; ↑ water/iron absorption; ↑ drug absorption from gut"),
("GASTROINTESTINAL", "gi", "gi_light",
"Haemorrhoids", "↑ risk", "Common",
"IVC compression → venous congestion; constipation + straining",
"Symptomatic treatment; resolves postpartum in most cases"),
("GASTROINTESTINAL", "gi", "gi_light",
"Liver (size, function)", "~", "Size unchanged",
"Liver position displaced; ALP ↑ (placental isoform); GGT, ALT, AST normal",
"Elevated ALP is normal; raised ALT/AST is pathological (e.g., HELLP, ICP)"),
("GASTROINTESTINAL", "gi", "gi_light",
"Gallbladder", "↓ motility", "Bile stasis",
"Progesterone reduces gallbladder emptying; bile more lithogenic (↑ cholesterol)",
"Cholelithiasis risk ↑; pregnancy is gallstone-prone state ('stone age of life')"),
# ═══ ENDOCRINE ═══
("ENDOCRINE", "endo", "endo_light",
"hCG", "↑ then ↓", "Peaks 8–10 wks, then ↓",
"Produced by syncytiotrophoblast; maintains corpus luteum progesterone till 10 wks",
"Basis of pregnancy test; extremely high in molar pregnancy/choriocarcinoma"),
("ENDOCRINE", "endo", "endo_light",
"Progesterone", "↑", "~150 ng/mL at term (20× normal)",
"Corpus luteum (1st trim) → placenta (from 10 wks); essential for uterine quiescence",
"Sedating; responsible for ↓ MAC, smooth muscle relaxation, nasal congestion, GI effects"),
("ENDOCRINE", "endo", "endo_light",
"Oestrogens (estriol)", "↑", "1000× non-pregnant levels at term",
"Placenta uses DHEAS from fetal adrenal; oestradiol and oestriol rise",
"Drives uterine growth, breast development, SHBG rise; monitoring of fetoplacental unit"),
("ENDOCRINE", "endo", "endo_light",
"Thyroid (Total T3/T4)", "↑", "↑ (bound); free T4 normal",
"hCG stimulates TSH receptor (weak agonist); TBG rises (oestrogen ↑); TSH may ↓ in 1st trim",
"Interpret TFTs with pregnancy-specific ranges; TSH 0.1–2.5 mU/L acceptable in 1st trim"),
("ENDOCRINE", "endo", "endo_light",
"Insulin Resistance", "↑", "Increases progressively from 2nd trim",
"HPL (human placental lactogen), progesterone, cortisol → anti-insulin effect; fasting glucose ↓",
"GDM risk in predisposed; OGTT screen at 24–28 wks; fasting glucose lower in normal pregnancy"),
("ENDOCRINE", "endo", "endo_light",
"Cortisol", "↑", "Total ↑↑; free cortisol ↑",
"CBG rises (oestrogen effect); ACTH from placenta; normal Cushing's-like picture",
"Striae gravidarum; impaired wound healing; immune modulation"),
("ENDOCRINE", "endo", "endo_light",
"Prolactin", "↑", "10× by term",
"Oestrogen-driven pituitary lactotroph hypertrophy; pituitary doubles in size",
"Prepares breast for lactation; galactorrhoea; pituitary enlargement → visual field risk"),
("ENDOCRINE", "endo", "endo_light",
"Relaxin", "↑", "Peak at 10 wks; persists",
"Corpus luteum + placenta; relaxes pelvic ligaments, cervix, and systemic vasodilation",
"Pelvic girdle pain (symphysis pubis dysfunction); facilitates delivery"),
("ENDOCRINE", "endo", "endo_light",
"Aldosterone / RAAS", "↑", "↑↑ (10× non-pregnant)",
"Oestrogen ↑ angiotensinogen; ↑ renin; ↑ angiotensin; ↑ aldosterone → Na/water retention",
"Physiological hyperaldosteronism; suppressed in pre-eclampsia (paradox)"),
# ═══ CNS / NEUROLOGICAL ═══
("CNS / NEUROLOGICAL", "cns", "cns_light",
"MAC (Anaesthetic)", "↓", "-40% by term",
"Progesterone (sedating); β-endorphin surge in labour; returns to normal by day 3 postpartum",
"Requires lower GA doses; volatile agents effective at reduced concentrations"),
("CNS / NEUROLOGICAL", "cns", "cns_light",
"Local Anaesthetic Sensitivity", "↑", "Dose reduced by ~30%",
"Engorgement of epidural venous plexus (IVC compression) ↓ epidural space volume; hormonal neural sensitivity",
"Regional block spreads further and higher; reduce epidural/spinal doses"),
("CNS / NEUROLOGICAL", "cns", "cns_light",
"Epidural Venous Plexus", "↑ engorgement", "From 2nd trimester",
"IVC obstruction by uterus → collateral drainage via epidural veins → epidural vascular congestion",
"↑ risk of intravascular catheter placement; aspiration of blood before epidural injection essential"),
("CNS / NEUROLOGICAL", "cns", "cns_light",
"Mood / Cognition", "Variable", "Mood lability, 'pregnancy brain'",
"Hormonal changes, sleep deprivation, neuroplastic changes; hippocampal grey matter ↓ (1st time)",
"Prenatal depression/anxiety common; screen routinely"),
# ═══ MUSCULOSKELETAL ═══
("MUSCULOSKELETAL", "msk", "msk_light",
"Pelvic Ligaments", "↑ laxity", "Relaxation from relaxin",
"Relaxin + progesterone → symphysis pubis and SI joint laxity from 1st trimester",
"Symphysis pubis diastasis; pelvic girdle pain; postural instability"),
("MUSCULOSKELETAL", "msk", "msk_light",
"Lumbar Lordosis", "↑", "Progressive",
"Anterior shift of centre of gravity due to gravid uterus; compensatory lordosis",
"Low back pain in 50–80%; muscle strain; altered gait"),
("MUSCULOSKELETAL", "msk", "msk_light",
"Weight Gain", "↑", "Recommended: 11–16 kg (normal BMI)",
"Fetus ~3.3 kg; placenta ~0.6 kg; liquor ~0.8 kg; uterus ~0.9 kg; breasts ~0.4 kg; blood/fluid ~3–4 kg",
"Excess gain → GDM, pre-eclampsia, macrosomia; inadequate gain → FGR"),
# ═══ SKIN ═══
("SKIN / DERMATOLOGY", "skin", "skin_light",
"Pigmentation", "↑", "Melasma, linea nigra",
"↑ MSH (melanocyte-stimulating hormone); oestrogen and progesterone stimulate melanocytes",
"Melasma ('mask of pregnancy'); linea nigra; darkening of nipples, axillae, genitalia"),
("SKIN / DERMATOLOGY", "skin", "skin_light",
"Striae Gravidarum", "Appear", "Abdomen, breasts, thighs",
"Mechanical stretching + cortisol-mediated collagen disruption in dermis",
"Irreversible; creams minimally effective; worsened by excess weight gain"),
("SKIN / DERMATOLOGY", "skin", "skin_light",
"Spider Angiomata / Palmar Erythema", "↑", "Common in 2nd trim onwards",
"Oestrogen-mediated vasodilation and angiogenesis",
"Normal finding; distinguish from signs of hepatic failure"),
("SKIN / DERMATOLOGY", "skin", "skin_light",
"Hair", "↑ thickness", "Anagen prolonged; shedding ↓",
"High oestrogen prolongs hair growth phase; mass telogen effluvium postpartum",
"Postpartum hair loss (telogen effluvium) at 3–6 months is normal and self-limiting"),
]
arrow_fill = {
"↑": mkfill("D5F5E3"),
"↓": mkfill("FADBD8"),
"~": mkfill(COLORS["neut"]),
"↑ risk": mkfill("FDEBD0"),
"↓ motility": mkfill("FADBD8"),
"Variable": mkfill(COLORS["neut"]),
"Present": mkfill("FDEBD0"),
"Appear": mkfill("FDEBD0"),
"↑ then ↓": mkfill("EBF5FB"),
"↑ engorgement": mkfill("FADBD8"),
"↑ laxity": mkfill("FDEBD0"),
"↑ thickness": mkfill("D5F5E3"),
"↓ (1st/2nd trim)": mkfill("FADBD8"),
}
row = 4
current_system = None
system_start = 4
for entry in data:
system, sys_color, sys_light, param, arrow, magnitude, mechanism, clinical = entry
# System merge – group rows for same system
fill = mkfill(COLORS[sys_light])
sys_fill = mkfill(COLORS[sys_color])
c_sys = ws.cell(row=row, column=1, value=system if system != current_system else "")
c_sys.fill = sys_fill
c_sys.font = mkfont(bold=True, color=COLORS["white"], size=10)
c_sys.alignment = mkalign()
c_sys.border = thin_border()
c_param = ws.cell(row=row, column=2, value=param)
c_param.fill = fill
c_param.font = mkfont(bold=True, size=10)
c_param.alignment = mkalign(h="left")
c_param.border = thin_border()
arrow_cell = ws.cell(row=row, column=3, value=arrow)
arrow_cell.fill = arrow_fill.get(arrow, mkfill(COLORS["neut"]))
arrow_cell.font = mkfont(bold=True, size=14, color="2C3E50")
arrow_cell.alignment = mkalign()
arrow_cell.border = thin_border()
c_mag = ws.cell(row=row, column=4, value=magnitude)
c_mag.fill = fill
c_mag.font = mkfont(size=10)
c_mag.alignment = mkalign(h="left")
c_mag.border = thin_border()
c_mech = ws.cell(row=row, column=5, value=mechanism)
c_mech.fill = fill
c_mech.font = mkfont(size=9, italic=False)
c_mech.alignment = mkalign(h="left")
c_mech.border = thin_border()
c_clin = ws.cell(row=row, column=6, value=clinical)
c_clin.fill = mkfill("FDFEFE")
c_clin.font = mkfont(size=9, color="1A252F")
c_clin.alignment = mkalign(h="left")
c_clin.border = thin_border()
ws.row_dimensions[row].height = 45
current_system = system
row += 1
# ─── Legend Row ───────────────────────────────────────────────────────────
ws.merge_cells(f"A{row}:F{row}")
legend = ws.cell(row=row, column=1,
value="LEGEND: ↑ = Increase (green) | ↓ = Decrease (red) | ~ = Unchanged (blue) | ↑ risk / Present = Notable change (orange)")
legend.fill = mkfill(COLORS["navy"])
legend.font = mkfont(italic=True, color=COLORS["white"], size=9)
legend.alignment = mkalign()
ws.row_dimensions[row].height = 18
# ─── Freeze panes ─────────────────────────────────────────────────────────
ws.freeze_panes = "A4"
# ─── Sheet tab color ──────────────────────────────────────────────────────
ws.sheet_properties.tabColor = "1B2A4A"
# ─── Auto-filter ──────────────────────────────────────────────────────────
ws.auto_filter.ref = f"A3:F{row - 1}"
out_path = "/home/daytona/workspace/pregnancy-physiology/Physiological_Changes_Pregnancy_DC_Dutta.xlsx"
wb.save(out_path)
print(f"Saved: {out_path}")
print(f"Total data rows: {row - 4}")
cd /home/daytona/workspace/pregnancy-physiology && python make_chart.py
python3 -c " import openpyxl wb = openpyxl.Workbook() ws = wb.active ws['A1'] = 'test' wb.save('/tmp/test_openpyxl.xlsx') print('OK') "
python3 /home/daytona/workspace/pregnancy-physiology/make_chart.py 2>&1; echo "EXIT: $?"
~/pregnancy-physiology/make_chart.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/pregnancy-physiology/make_chart.py'
python3 /home/daytona/workspace/pregnancy-physiology/make_chart.py && cp /tmp/Physiological_Changes_Pregnancy_DC_Dutta.xlsx /home/daytona/workspace/pregnancy-physiology/Physiological_Changes_Pregnancy_DC_Dutta.xlsx && ls -lh /home/daytona/workspace/pregnancy-physiology/Physiological_Changes_Pregnancy_DC_Dutta.xlsx