| Test | Result | Reference Range | Status |
|---|---|---|---|
| HbA1c | 9.1% | <5.6% (Normal) / ≥6.5% (Diabetic) | ⚠️ HIGH - Diabetic range |
| Fasting Plasma Glucose | 165.64 mg/dL | 60-110 mg/dL | ⚠️ HIGH |
| TSH (Ultrasensitive) | 8.183 uIU/mL | 0.55-4.78 | ⚠️ HIGH - Hypothyroidism |
| Triglycerides | 221.08 mg/dL | 40-149 (Desirable) | ⚠️ HIGH |
| Serum Uric Acid | 8.29 mg/dL | 3.5-7.20 | ⚠️ HIGH - Hyperuricemia |
| Haemoglobin | 11.7 g/dL | 13.0-17.0 | ⚠️ LOW - Anaemia |
| PCV/Haematocrit | 35.8% | 40-50% | ⚠️ LOW |
| MCV | 72 fL | 80-100 | ⚠️ LOW - Microcytic |
| MCH | 23.6 pg | 27-32 | ⚠️ LOW - Hypochromic |
| Test | Result | Reference Range |
|---|---|---|
| Ferritin | 27.46 ng/mL | 21.81-274.66 ✓ |
| FT4 | 0.97 ng/dL | 0.89-1.76 ✓ |
| T3 | 0.67 ng/mL | 0.61-1.81 ✓ |
| T4 | 7.20 ug/dL | 5.01-12.45 ✓ |
| Vitamin D (25-OH) | 39.21 ng/mL | 30-100 (Sufficient) ✓ |
| Vitamin B12 | 285 pg/mL | 211-911 ✓ |
| Serum Iron | 72 ug/dL | 35-150 ✓ |
| Total Cholesterol | 172.6 mg/dL | <200 (Desirable) ✓ |
| HDL Cholesterol | 41.13 mg/dL | 40-60 ✓ |
| LDL Cholesterol | 87.25 mg/dL | 70-129 (Near Optimal) ✓ |
| Serum Creatinine | 0.72 mg/dL | 0.60-1.30 ✓ |
| Serum Urea | 19.83 mg/dL | 15-39 ✓ |
| Liver enzymes (SGOT/SGPT/GGT/ALP) | All within range | ✓ |
| Total Bilirubin | 0.35 mg/dL | 0.1-1.2 ✓ |
| Albumin | 4.09 g/dL | 3.5-5.0 ✓ |
| Serum Calcium | 9.62 mg/dL | 8.3-10.3 ✓ |
| Platelet Count | 157 thou/mm³ | 150-450 ✓ |
Disclaimer: This is an educational analysis of lab values. All findings must be reviewed and acted upon by a qualified physician who can assess these results in the full clinical context of the patient.
Find recent guidelines for managing diabetes with HbA1c >9%
diabetes management HbA1c guidelines
ADA 2025 guidelines diabetes HbA1c greater than 9 management recommendations
type 2 diabetes intensification therapy HbA1c AND insulin initiation
https://diabetes.org/newsroom/press-releases/american-diabet…
GLP-1 SGLT2 type 2 diabetes cardiovascular outcomes
PMID: 38639549

| Symptoms | Recommendation |
|---|---|
| No symptoms | Start Dual Therapy OR Triple Therapy |
| Yes symptoms | Insulin ± Other Agents immediately |
| Drug Class | Notes |
|---|---|
| GLP-1 Receptor Agonist (e.g., semaglutide, liraglutide) | Preferred - reduces A1C by 1-2%, weight loss, CV benefit |
| SGLT2 Inhibitor (e.g., empagliflozin, dapagliflozin) | Preferred - reduces A1C 0.5-1%, protects kidney and heart |
| DPP-4 Inhibitor (e.g., sitagliptin) | Modest A1C reduction, well tolerated |
| TZD (pioglitazone) | Use with caution (weight gain, fluid retention) |
| Sulfonylurea / Glinide | Use with caution - hypoglycemia risk |
| Basal Insulin | When oral/injectable agents insufficient |
| Comorbidity | Preferred Agent |
|---|---|
| Established/high ASCVD risk | GLP-1 RA (liraglutide, semaglutide) AND/OR SGLT2i |
| CKD (eGFR ≥30, stage 3) | SGLT2i (canagliflozin preferred) |
| Heart Failure with reduced EF | SGLT2i (dapagliflozin preferred) |
| Obesity | GLP-1 RA or tirzepatide (dual GIP/GLP-1) |
For Mr. Mirgund (50M with HbA1c 9.1%, triglycerides 221, and hypothyroidism): he is asymptomatic, so dual or triple therapy is appropriate. GLP-1 RA would also address his hypertriglyceridaemia. His uric acid and kidney function should be checked before adding SGLT2i.
| Target | AACE | ADA |
|---|---|---|
| HbA1c | ≤6.5% | ≤7.0% |
| Fasting glucose | <110 mg/dL | 70-130 mg/dL |
| 2-hr postprandial | <140 mg/dL | <180 mg/dL |
| Blood pressure | <130/80 | <140/80 |
| LDL | <100 mg/dL | <100 mg/dL |
| Triglycerides | <150 mg/dL | <150 mg/dL |
Disclaimer: These are general clinical guidelines. Individual patient management should always be decided by a qualified physician with full knowledge of the patient's clinical context, comorbidities, medications, and preferences.
Create a management plan summary document for Mr. Mirgund
ls -la /tmp/workspace/ 2>/dev/null && mkdir -p /tmp/workspace/mirgund-management/
~/mirgund-management/create_plan.py
from docx import Document
from docx.shared import Pt, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import datetime
doc = Document()
# ── Page margins ──────────────────────────────────────────────────────────────
section = doc.sections[0]
section.top_margin = Inches(1.0)
section.bottom_margin = Inches(1.0)
section.left_margin = Inches(1.1)
section.right_margin = Inches(1.1)
# ── Default font ──────────────────────────────────────────────────────────────
normal = doc.styles["Normal"]
normal.font.name = "Calibri"
normal.font.size = Pt(11)
# ── Helper: coloured heading ──────────────────────────────────────────────────
def add_section_heading(doc, text, color_hex="1F4E79"):
p = doc.add_heading(text, level=2)
p.runs[0].font.color.rgb = RGBColor.from_string(color_hex)
p.runs[0].font.bold = True
p.runs[0].font.size = Pt(12)
return p
def add_subsection(doc, text):
p = doc.add_heading(text, level=3)
p.runs[0].font.color.rgb = RGBColor.from_string("2E74B5")
p.runs[0].font.size = Pt(11)
return p
def add_body(doc, text):
p = doc.add_paragraph(text)
p.paragraph_format.space_after = Pt(4)
return p
def add_bullet(doc, text, level=0):
p = doc.add_paragraph(text, style="List Bullet")
p.paragraph_format.left_indent = Inches(0.3 + level * 0.25)
p.paragraph_format.space_after = Pt(2)
return p
def add_table_row(table, cells, bold_first=False, header=False, bg_hex=None):
row = table.add_row()
for i, (cell, text) in enumerate(zip(row.cells, cells)):
cell.text = str(text)
run = cell.paragraphs[0].runs[0] if cell.paragraphs[0].runs else cell.paragraphs[0].add_run(str(text))
if not cell.paragraphs[0].runs:
cell.paragraphs[0].clear()
run = cell.paragraphs[0].add_run(str(text))
run = cell.paragraphs[0].runs[0]
run.font.size = Pt(10)
if header or (bold_first and i == 0):
run.font.bold = True
cell.paragraphs[0].paragraph_format.space_after = Pt(2)
cell.paragraphs[0].paragraph_format.space_before = Pt(2)
if bg_hex:
tc_pr = cell._tc.get_or_add_tcPr()
shd = OxmlElement("w:shd")
shd.set(qn("w:val"), "clear")
shd.set(qn("w:color"), "auto")
shd.set(qn("w:fill"), bg_hex)
tc_pr.append(shd)
return row
def set_header_row(table, cells, bg="1F4E79"):
row = table.rows[0]
for i, (cell, text) in enumerate(zip(row.cells, cells)):
cell.text = ""
run = cell.paragraphs[0].add_run(text)
run.font.bold = True
run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
run.font.size = Pt(10)
cell.paragraphs[0].paragraph_format.space_after = Pt(2)
cell.paragraphs[0].paragraph_format.space_before = Pt(2)
tc_pr = cell._tc.get_or_add_tcPr()
shd = OxmlElement("w:shd")
shd.set(qn("w:val"), "clear")
shd.set(qn("w:color"), "auto")
shd.set(qn("w:fill"), bg)
tc_pr.append(shd)
def set_col_widths(table, widths_inches):
for row in table.rows:
for i, cell in enumerate(row.cells):
if i < len(widths_inches):
cell.width = Inches(widths_inches[i])
# ══════════════════════════════════════════════════════════════════════════════
# HEADER / TITLE BLOCK
# ══════════════════════════════════════════════════════════════════════════════
title = doc.add_heading("PATIENT MANAGEMENT PLAN", level=1)
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
title.runs[0].font.color.rgb = RGBColor.from_string("1F4E79")
title.runs[0].font.size = Pt(18)
title.runs[0].font.bold = True
subtitle = doc.add_paragraph("Comprehensive Clinical Summary & Treatment Strategy")
subtitle.alignment = WD_ALIGN_PARAGRAPH.CENTER
subtitle.runs[0].font.size = Pt(12)
subtitle.runs[0].font.color.rgb = RGBColor.from_string("595959")
subtitle.runs[0].font.italic = True
doc.add_paragraph("")
# Patient info box (table)
info_table = doc.add_table(rows=2, cols=4)
info_table.style = "Table Grid"
info_data = [
["Patient Name", "Mr. Mohd Ibrahim Mirgund", "Date of Birth / Age", "50 Years / Male"],
["Report Date", "23 July 2026", "Ref. Doctor", "Dr. Self (AL AQSA CLINICAL LAB)"],
]
for r_idx, row_data in enumerate(info_data):
for c_idx, cell_text in enumerate(row_data):
cell = info_table.rows[r_idx].cells[c_idx]
cell.text = ""
run = cell.paragraphs[0].add_run(cell_text)
run.font.size = Pt(10)
run.font.bold = (c_idx % 2 == 0)
if c_idx % 2 == 0:
run.font.color.rgb = RGBColor.from_string("1F4E79")
cell.paragraphs[0].paragraph_format.space_after = Pt(2)
cell.paragraphs[0].paragraph_format.space_before = Pt(2)
set_col_widths(info_table, [1.5, 2.2, 1.8, 2.0])
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 1. LAB RESULTS SUMMARY
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "1. Laboratory Results Summary (23 July 2026)")
# Abnormal results
add_subsection(doc, "Abnormal Results - Requiring Immediate Attention")
ab_table = doc.add_table(rows=1, cols=5)
ab_table.style = "Table Grid"
set_header_row(ab_table, ["Test", "Result", "Unit", "Reference Range", "Status"], bg="C00000")
data_ab = [
["HbA1c", "9.1", "%", "< 5.6 (Normal) / ≥ 6.5 (Diabetic)", "HIGH - Diabetic"],
["Fasting Plasma Glucose", "165.64", "mg/dL", "60-110", "HIGH"],
["Est. Average Glucose", "214.47", "mg/dL", "Target < 154 (ADA)", "HIGH"],
["TSH (Ultrasensitive)", "8.183", "uIU/mL", "0.55-4.78", "HIGH - Hypothyroidism"],
["Triglycerides", "221.08", "mg/dL", "< 150 (Desirable)", "HIGH"],
["Serum Uric Acid", "8.29", "mg/dL", "3.5-7.20", "HIGH - Hyperuricemia"],
["Haemoglobin", "11.7", "g/dL", "13.0-17.0", "LOW - Anaemia"],
["PCV/Haematocrit", "35.8", "%", "40-50", "LOW"],
["MCV", "72", "fL", "80-100", "LOW - Microcytic"],
["MCH", "23.6", "pg", "27-32", "LOW - Hypochromic"],
]
for row_data in data_ab:
r = add_table_row(ab_table, row_data)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
# Status cell - colour red
status_cell = r.cells[4]
status_cell.paragraphs[0].runs[0].font.color.rgb = RGBColor(0xC0, 0x00, 0x00)
status_cell.paragraphs[0].runs[0].font.bold = True
set_col_widths(ab_table, [1.8, 0.9, 0.7, 2.3, 1.8])
doc.add_paragraph("")
# Normal results
add_subsection(doc, "Key Normal Results")
norm_table = doc.add_table(rows=1, cols=4)
norm_table.style = "Table Grid"
set_header_row(norm_table, ["Test", "Result", "Unit", "Reference Range"], bg="375623")
data_norm = [
["Ferritin", "27.46", "ng/mL", "21.81-274.66"],
["FT4", "0.97", "ng/dL", "0.89-1.76"],
["T3 / T4", "0.67 / 7.20", "ng/mL / ug/dL", "0.61-1.81 / 5.01-12.45"],
["Vitamin D (25-OH)", "39.21", "ng/mL", "30-100 (Sufficient)"],
["Vitamin B12", "285", "pg/mL", "211-911"],
["Serum Iron", "72", "ug/dL", "35-150"],
["Total Cholesterol", "172.6", "mg/dL", "< 200 (Desirable)"],
["LDL Cholesterol", "87.25", "mg/dL", "70-129 (Near Optimal)"],
["HDL Cholesterol", "41.13", "mg/dL", "40-60"],
["Serum Creatinine", "0.72", "mg/dL", "0.60-1.30"],
["Serum Urea", "19.83", "mg/dL", "15-39"],
["Liver Enzymes (SGOT/SGPT/GGT/ALP)", "Within range", "-", "Normal"],
]
for row_data in data_norm:
r = add_table_row(norm_table, row_data)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
r.cells[3].paragraphs[0].runs[0].font.color.rgb = RGBColor(0x37, 0x56, 0x23)
set_col_widths(norm_table, [2.3, 1.0, 1.0, 2.2])
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 2. PROBLEM LIST & DIAGNOSES
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "2. Active Problem List & Clinical Diagnoses")
prob_table = doc.add_table(rows=1, cols=4)
prob_table.style = "Table Grid"
set_header_row(prob_table, ["#", "Diagnosis", "Key Finding", "Priority"], bg="1F4E79")
problems = [
["1", "Type 2 Diabetes Mellitus - Poorly Controlled", "HbA1c 9.1%, FPG 165.64 mg/dL", "URGENT"],
["2", "Primary Hypothyroidism (Subclinical/Overt)", "TSH 8.183 uIU/mL (ref: 0.55-4.78)", "URGENT"],
["3", "Microcytic Hypochromic Anaemia", "Hb 11.7, MCV 72, MCH 23.6", "HIGH"],
["4", "Hypertriglyceridaemia", "Triglycerides 221 mg/dL", "HIGH"],
["5", "Hyperuricaemia", "Uric Acid 8.29 mg/dL (ref: 3.5-7.20)", "MODERATE"],
["6", "Low HDL Cholesterol", "HDL 41.13 mg/dL (borderline)", "MONITOR"],
]
priority_colors = {
"URGENT": RGBColor(0xC0, 0x00, 0x00),
"HIGH": RGBColor(0xFF, 0x7F, 0x00),
"MODERATE": RGBColor(0xFF, 0xA5, 0x00),
"MONITOR": RGBColor(0x37, 0x56, 0x23),
}
for row_data in problems:
r = add_table_row(prob_table, row_data)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
priority = row_data[3]
r.cells[3].paragraphs[0].runs[0].font.color.rgb = priority_colors.get(priority, RGBColor(0,0,0))
r.cells[3].paragraphs[0].runs[0].font.bold = True
set_col_widths(prob_table, [0.3, 2.8, 2.5, 1.0])
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 3. MANAGEMENT PLAN
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "3. Management Plan")
# 3a Diabetes
add_subsection(doc, "3a. Diabetes Mellitus (HbA1c 9.1%) - ADA 2026 Guidelines")
add_body(doc, "Patient is ASYMPTOMATIC with HbA1c >9%. Per ADA Standards of Care 2026 and AACE guidelines, this warrants DUAL or TRIPLE therapy:")
dm_table = doc.add_table(rows=1, cols=3)
dm_table.style = "Table Grid"
set_header_row(dm_table, ["Category", "Recommendation", "Notes"], bg="1F4E79")
dm_rows = [
["Pharmacotherapy", "Metformin (backbone) + GLP-1 RA (preferred)", "GLP-1 RA also addresses hypertriglyceridaemia & weight"],
["Alternative Add-on", "SGLT2 Inhibitor (e.g., empagliflozin)", "Check eGFR first; renal & cardiac protective"],
["Consider", "Basal Insulin if A1C not controlled in 3 months", "Glargine 10 units/day; titrate to FPG 80-130 mg/dL"],
["Target HbA1c", "< 7.0% (ADA) / < 6.5% (AACE)", "Reassess every 3 months"],
["Diet", "Low-carbohydrate / Mediterranean diet", "Target: reduce refined carbs, sugars, saturated fat"],
["Exercise", "≥ 150 min/week moderate aerobic activity", "E.g., brisk walking 30 min/day x 5 days"],
["Self-monitoring", "CGM preferred (ADA 2026) or SMBG", "Fasting glucose target: 80-130 mg/dL"],
["Follow-up", "HbA1c every 3 months until at goal", "Then every 6 months once stable"],
]
for row_data in dm_rows:
r = add_table_row(dm_table, row_data, bold_first=True)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
set_col_widths(dm_table, [1.6, 2.6, 2.3])
doc.add_paragraph("")
# 3b Hypothyroidism
add_subsection(doc, "3b. Hypothyroidism (TSH 8.183 uIU/mL)")
add_body(doc, "TSH elevated with normal T3 and T4 - consistent with PRIMARY HYPOTHYROIDISM (subclinical to overt). T4 levels at lower end of normal further supports this.")
hypo_table = doc.add_table(rows=1, cols=3)
hypo_table.style = "Table Grid"
set_header_row(hypo_table, ["Category", "Recommendation", "Notes"], bg="1F4E79")
hypo_rows = [
["Pharmacotherapy", "Levothyroxine (L-T4) initiation", "Start at 25-50 mcg/day; titrate every 4-6 weeks"],
["Target TSH", "0.5 - 2.5 uIU/mL (ATA)", "For age 50+, accept slightly higher upper limit"],
["Monitoring", "TSH + FT4 at 6 weeks after each dose change", "Once stable, check TSH every 6-12 months"],
["Drug Interactions", "Take Levothyroxine 30-60 min before food/other drugs", "Calcium, iron, PPI can reduce absorption"],
["Note", "Hypothyroidism worsens insulin resistance", "Treating thyroid will likely improve glycemic control too"],
]
for row_data in hypo_rows:
r = add_table_row(hypo_table, row_data, bold_first=True)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
set_col_widths(hypo_table, [1.6, 2.6, 2.3])
doc.add_paragraph("")
# 3c Anaemia
add_subsection(doc, "3c. Microcytic Hypochromic Anaemia")
add_body(doc, "Low Hb (11.7), MCV (72), MCH (23.6) with normal serum iron (72) and borderline ferritin (27.46) - pattern consistent with iron deficiency or thalassaemia trait.")
ana_table = doc.add_table(rows=1, cols=3)
ana_table.style = "Table Grid"
set_header_row(ana_table, ["Category", "Recommendation", "Notes"], bg="1F4E79")
ana_rows = [
["Further Investigation", "Haemoglobin Electrophoresis", "Rule out Beta-Thalassaemia trait"],
["Further Investigation", "Serum Ferritin + TIBC + Peripheral Smear", "Confirm iron deficiency pattern"],
["If Iron Deficiency Confirmed", "Oral Iron Supplementation x 3-6 months", "Ferrous sulphate 200mg TDS with Vitamin C"],
["Monitor", "Repeat CBC at 4-6 weeks", "Target: Hb > 13 g/dL"],
["Diet", "Iron-rich foods: red meat, leafy greens, legumes", "Avoid tea/coffee with meals (reduce iron absorption)"],
]
for row_data in ana_rows:
r = add_table_row(ana_table, row_data, bold_first=True)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
set_col_widths(ana_table, [1.6, 2.6, 2.3])
doc.add_paragraph("")
# 3d Hypertriglyceridaemia
add_subsection(doc, "3d. Hypertriglyceridaemia (TG 221 mg/dL)")
tg_table = doc.add_table(rows=1, cols=3)
tg_table.style = "Table Grid"
set_header_row(tg_table, ["Category", "Recommendation", "Notes"], bg="1F4E79")
tg_rows = [
["Primary strategy", "Improve glycemic control first", "Elevated TG often secondary to poorly controlled DM"],
["Diet", "Reduce refined carbs, sugars, alcohol, fructose", "Omega-3 rich foods (fish, walnuts, flaxseed)"],
["Exercise", "Aerobic exercise 150+ min/week", "Significantly reduces triglycerides"],
["Pharmacotherapy", "Consider Fenofibrate if TG > 500 or unresponsive to lifestyle", "Check liver function before starting"],
["GLP-1 RA benefit", "GLP-1 RA (for DM) also lowers TG", "Dual benefit - primary choice for this patient"],
["Target", "TG < 150 mg/dL", "Recheck after 3 months of lifestyle + DM treatment"],
]
for row_data in tg_rows:
r = add_table_row(tg_table, row_data, bold_first=True)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
set_col_widths(tg_table, [1.6, 2.6, 2.3])
doc.add_paragraph("")
# 3e Hyperuricaemia
add_subsection(doc, "3e. Hyperuricaemia (Uric Acid 8.29 mg/dL)")
ua_table = doc.add_table(rows=1, cols=3)
ua_table.style = "Table Grid"
set_header_row(ua_table, ["Category", "Recommendation", "Notes"], bg="1F4E79")
ua_rows = [
["Lifestyle", "Reduce purine-rich foods: red meat, organ meats, shellfish", "Increase water intake to > 2L/day"],
["Lifestyle", "Avoid alcohol (especially beer) and fructose", "High fructose corn syrup in soft drinks - avoid"],
["Monitor", "Repeat uric acid in 3 months after lifestyle change", "If symptomatic gout or uric acid > 9: consider Allopurinol"],
["Drug consideration", "Allopurinol if urate-lowering indicated", "Start at 100 mg/day; titrate to target UA < 6 mg/dL"],
["SGLT2 benefit", "SGLT2 inhibitors (if added for DM) lower uric acid", "Dual benefit for this patient"],
]
for row_data in ua_rows:
r = add_table_row(ua_table, row_data, bold_first=True)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
set_col_widths(ua_table, [1.6, 2.6, 2.3])
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 4. TREATMENT TARGETS
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "4. Treatment Targets (3-Month & 6-Month Goals)")
targets_table = doc.add_table(rows=1, cols=4)
targets_table.style = "Table Grid"
set_header_row(targets_table, ["Parameter", "Current Value", "3-Month Target", "6-Month Target"], bg="1F4E79")
targets = [
["HbA1c", "9.1%", "< 8.0%", "< 7.0%"],
["Fasting Glucose", "165.64 mg/dL", "< 130 mg/dL", "80-110 mg/dL"],
["TSH", "8.183 uIU/mL", "1.0-3.0 uIU/mL (on L-T4)", "0.5-2.5 uIU/mL"],
["Haemoglobin", "11.7 g/dL", "> 12.5 g/dL", "> 13.0 g/dL"],
["Triglycerides", "221 mg/dL", "< 180 mg/dL", "< 150 mg/dL"],
["Uric Acid", "8.29 mg/dL", "< 7.5 mg/dL", "< 6.0 mg/dL"],
["Blood Pressure", "Not recorded", "< 130/80 mmHg", "< 130/80 mmHg"],
["LDL Cholesterol", "87.25 mg/dL", "< 100 mg/dL", "< 100 mg/dL"],
["Body Weight", "Not recorded", "-5% baseline", "-10% baseline"],
]
for row_data in targets:
r = add_table_row(targets_table, row_data)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
r.cells[2].paragraphs[0].runs[0].font.color.rgb = RGBColor(0xFF, 0x7F, 0x00)
r.cells[3].paragraphs[0].runs[0].font.color.rgb = RGBColor(0x37, 0x56, 0x23)
set_col_widths(targets_table, [2.0, 1.6, 2.0, 1.9])
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 5. FOLLOW-UP SCHEDULE
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "5. Follow-Up Schedule & Monitoring Plan")
fu_table = doc.add_table(rows=1, cols=3)
fu_table.style = "Table Grid"
set_header_row(fu_table, ["Timeframe", "Tests / Actions", "Purpose"], bg="1F4E79")
fu_rows = [
["Immediate (1-2 weeks)", "Physician review of this report; initiate Levothyroxine + diabetes treatment", "Prevent further deterioration"],
["4-6 weeks", "TSH + FT4 recheck", "Assess response to Levothyroxine"],
["3 months", "HbA1c, Fasting glucose, Lipid profile, CBC, TSH, Uric acid, Liver function", "Comprehensive treatment response assessment"],
["3 months", "Renal function (urea, creatinine, eGFR)", "Baseline before SGLT2i consideration"],
["6 months", "Full metabolic panel + HbA1c + Thyroid + CBC + Lipids", "Full reassessment"],
["Annual", "HbA1c, Lipids, Renal, Liver, Thyroid, CBC, ECG, Eye exam (fundus), Urine microalbumin, Foot exam", "Diabetic complication screening"],
["If Anaemia persists", "Haemoglobin Electrophoresis + TIBC + Peripheral Blood Smear", "Rule out thalassaemia trait"],
]
for row_data in fu_rows:
r = add_table_row(fu_table, row_data, bold_first=True)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
set_col_widths(fu_table, [1.8, 3.2, 2.5])
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 6. LIFESTYLE RECOMMENDATIONS
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "6. Lifestyle & Dietary Recommendations")
add_body(doc, "The following lifestyle changes are evidence-based and applicable across all diagnosed conditions:")
life_items = [
("DIET", [
"Follow a low-carbohydrate or Mediterranean diet pattern",
"Limit refined carbohydrates, white rice, bread, sugary beverages",
"Reduce red meat, organ meats, shellfish (uric acid control)",
"Increase fibre intake: vegetables, legumes, whole grains",
"Omega-3 sources: fatty fish (salmon, mackerel), walnuts, flaxseed (lowers TG)",
"Target calorie deficit for weight reduction of 5-10% body weight",
]),
("PHYSICAL ACTIVITY", [
"Minimum 150 minutes/week of moderate aerobic exercise (e.g., brisk walking)",
"Resistance training 2-3 times/week improves insulin sensitivity",
"Avoid prolonged sedentary periods - break every 30 minutes",
]),
("HYDRATION", [
"Drink > 2 litres water daily (helps uric acid excretion)",
"Avoid sugary drinks, fruit juices, and carbonated beverages",
"Limit or eliminate alcohol (worsens triglycerides and uric acid)",
]),
("OTHER HABITS", [
"No smoking / tobacco use",
"Regular sleep 7-8 hours per night (poor sleep worsens insulin resistance)",
"Stress management: yoga, meditation, or relaxation techniques",
]),
]
for category, items in life_items:
p = doc.add_paragraph()
run = p.add_run(category)
run.font.bold = True
run.font.color.rgb = RGBColor.from_string("1F4E79")
run.font.size = Pt(11)
p.paragraph_format.space_after = Pt(2)
for item in items:
add_bullet(doc, item)
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 7. DIABETIC COMPLICATION SCREENING
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "7. Diabetic Complication Screening (Annual)")
add_body(doc, "Given HbA1c of 9.1% (poorly controlled diabetes), screening for end-organ complications should begin now and be repeated annually:")
comp_table = doc.add_table(rows=1, cols=3)
comp_table.style = "Table Grid"
set_header_row(comp_table, ["Complication", "Screening Method", "Frequency"], bg="C00000")
comp_rows = [
["Diabetic Nephropathy", "Urine microalbumin/creatinine ratio + eGFR", "Annual"],
["Diabetic Retinopathy", "Dilated fundus examination (ophthalmologist)", "Annual"],
["Diabetic Neuropathy", "Monofilament test + vibration sense (foot exam)", "Annual"],
["Cardiovascular Disease", "ECG, Blood pressure, Lipid profile, BMI", "Annual"],
["Diabetic Foot", "Peripheral pulses + foot inspection", "Every visit"],
["Hepatic steatosis", "Liver enzymes + abdominal ultrasound", "Annual (already on LFT - normal)"],
]
for row_data in comp_rows:
r = add_table_row(comp_rows, row_data) # intentional - will fix below
pass
# Rebuild properly
comp_table2 = doc.add_table(rows=1, cols=3)
comp_table2.style = "Table Grid"
set_header_row(comp_table2, ["Complication", "Screening Method", "Frequency"], bg="C00000")
for row_data in comp_rows:
r = add_table_row(comp_table2, row_data, bold_first=True)
for cell in r.cells:
cell.paragraphs[0].runs[0].font.size = Pt(10)
set_col_widths(comp_table2, [2.0, 3.2, 1.3])
# Remove the malformed table
tbl_to_remove = comp_table._tbl
tbl_to_remove.getparent().remove(tbl_to_remove)
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# 8. KEY DRUG INTERACTIONS
# ══════════════════════════════════════════════════════════════════════════════
add_section_heading(doc, "8. Key Drug Interaction Notes")
add_body(doc, "When prescribing for this patient, be aware of the following:")
int_items = [
"Levothyroxine: Take 30-60 minutes before breakfast. Iron supplements and calcium reduce absorption - space by 4+ hours.",
"Metformin: Hold for 48 hours around iodinated contrast procedures. Check renal function regularly.",
"GLP-1 RA: May delay gastric emptying - counsel patient on nausea management; start at low dose.",
"SGLT2 Inhibitors: Monitor for urinary tract infections, genital fungal infections, and euglycaemic DKA.",
"Allopurinol (if used): Do NOT start during acute gout attack. Check renal function. Risk of skin reactions.",
"Sulfonylureas / Insulin: Caution - risk of hypoglycaemia especially with physical activity or missed meals.",
]
for item in int_items:
add_bullet(doc, item)
doc.add_paragraph("")
# ══════════════════════════════════════════════════════════════════════════════
# DISCLAIMER
# ══════════════════════════════════════════════════════════════════════════════
disc_para = doc.add_paragraph()
disc_para.paragraph_format.space_before = Pt(10)
run = disc_para.add_run(
"DISCLAIMER: This management plan is generated as a clinical summary aid based on the laboratory results provided. "
"It does not replace the clinical judgement of a qualified physician. All treatment decisions must be made by a "
"licensed healthcare professional with full knowledge of the patient's history, clinical findings, and individual circumstances. "
"Drug doses mentioned are approximate starting points and require individual titration."
)
run.font.size = Pt(9)
run.font.italic = True
run.font.color.rgb = RGBColor(0x59, 0x59, 0x59)
disc_para.paragraph_format.left_indent = Inches(0.3)
disc_para.paragraph_format.right_indent = Inches(0.3)
# ── Footer with date ──────────────────────────────────────────────────────────
from docx.oxml.ns import qn as qname
footer = doc.sections[0].footer
footer_para = footer.paragraphs[0]
footer_para.alignment = WD_ALIGN_PARAGRAPH.CENTER
run_f = footer_para.add_run(f"Generated: 24 July 2026 | Modern Diagnostic & Research Centre | Patient: Mr. Mohd Ibrahim Mirgund")
run_f.font.size = Pt(8)
run_f.font.color.rgb = RGBColor(0x59, 0x59, 0x59)
run_f.font.italic = True
# ── Save ──────────────────────────────────────────────────────────────────────
out_path = "/tmp/workspace/mirgund-management/Mirgund_Management_Plan.docx"
doc.save(out_path)
print(f"Saved: {out_path}")
cd /tmp/workspace/mirgund-management && python3 create_plan.py 2>&1
~/mirgund-management/create_plan.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/mirgund-management/create_plan.py'
cd /tmp/workspace/mirgund-management && python3 create_plan.py 2>&1
python3 -c " from docx import Document doc = Document('/tmp/workspace/mirgund-management/Mirgund_Management_Plan.docx') headings = [p.text for p in doc.paragraphs if p.style.name.startswith('Heading') and p.text.strip()] print('Sections found:') for h in headings: print(' -', h) print(f'Total paragraphs: {len(doc.paragraphs)}') print(f'Total tables: {len(doc.tables)}') "
Mirgund Management Plan
Word Document · DOCX
| Section | Contents |
|---|---|
| Patient Header | Name, age, date, lab reference |
| 1. Lab Results Summary | Abnormal results (red-highlighted) + normal results (green) in tabular format |
| 2. Problem List | 6 active diagnoses with priority levels (Urgent / High / Moderate) |
| 3. Management Plan | Individual treatment tables for each condition: |
| - 3a | Diabetes (ADA 2026 guidelines - dual/triple therapy) |
| - 3b | Hypothyroidism (Levothyroxine initiation + monitoring) |
| - 3c | Anaemia (investigations + iron supplementation) |
| - 3d | Hypertriglyceridaemia (lifestyle + GLP-1 RA dual benefit) |
| - 3e | Hyperuricaemia (diet + SGLT2i dual benefit noted) |
| 4. Treatment Targets | 3-month and 6-month goals for every parameter |
| 5. Follow-Up Schedule | Week 4, Month 3, Month 6, and Annual timelines |
| 6. Lifestyle Guidance | Diet, exercise, hydration, habits |
| 7. Complication Screening | Full diabetic annual screening checklist |
| 8. Drug Interactions | Key alerts for all anticipated medications |
| Disclaimer | Medical/legal disclaimer footer |