These are my reports my name is doctor muhammad daniyal MBBS graduated written wrong name here in my reports try me to evaluate the diagnosis with these reports
| Test | Result | Normal Range | Status |
|---|---|---|---|
| Haemoglobin | 14.3 g/dL | 13.0 - 18.0 | ✅ Normal |
| RBC | 4.72 /cumm | - | ✅ Normal |
| PCV | 39.8% | 37.4 - 52.0 | ✅ Normal |
| MCV | 84.3 fL | 77 - 97 | ✅ Normal |
| MCH | 30.3 pg | 27 - 32 | ✅ Normal |
| MCHC | 36.0 g/dL | 31 - 35 | ⚠️ Marginally High |
| WBC | 10.74 x10⁹/L | 4.0 - 11.0 | ⚠️ High-Normal |
| Neutrophils | 63% | 40-75 | ✅ Normal |
| Lymphocytes | 31% | 20-45 | ✅ Normal |
| Monocytes | 4% | 2-10 | ✅ Normal |
| Eosinophils | 2% | 1-6 | ✅ Normal |
| Platelets | 247 x10⁹/L | 150-450 | ✅ Normal |
| Test | Result | Normal Range | Status |
|---|---|---|---|
| Sodium | 136.9 mEq/L | 135-145 | ✅ Normal |
| Potassium | 3.93 mEq/L | 3.5-5.5 | ✅ Normal |
| Chloride | 101.7 mEq/L | 98-107 | ✅ Normal |
| Bicarbonate | 24.54 mEq/L | 22.3-31.0 | ✅ Normal |
| Test | Result | Normal Range | Status |
|---|---|---|---|
| Urea | 29 mg/dL | 15-45 | ✅ Normal |
| Creatinine | 1.2 mg/dL | 0.7-1.2 | ✅ Upper Normal |
| Bilirubin (Total) | 0.7 mg/dL | Up to 1.4 (male) | ✅ Normal |
| SGPT (ALT) | 92 U/L | Male up to 43 U/L | 🔴 HIGH (2x ULN) |
| Alkaline Phosphatase | 197 U/L | 40-129 (adult male) | 🔴 HIGH |
| HbA1c | 6.0% | 4.8 - 5.9 | ⚠️ Borderline Elevated |
| Magnesium | 2.2 mg/dL | 1.2-2.5 | ✅ Normal |
| Uric Acid | 4.5 mg/dL | 3.4-7.0 (male) | ✅ Normal |
| Calcium | 10.2 mg/dL | 8.4-10.2 (adult) | ⚠️ Upper Limit |
| Test | Result | Normal Range | Status |
|---|---|---|---|
| Free T3 | 2.88 ng/mL | 0.8 - 1.5 ng/mL | 🔴 HIGH (nearly 2x ULN) |
| Free T4 (CLIA) | 1.08 ng/mL | 0.8 - 2.0 (adult) | ✅ Normal |
| TSH | Not done | - | ⚠️ MISSING - Critical |
| Priority | Finding | Likely Diagnosis |
|---|---|---|
| 🔴 Urgent | Free T3 very high, T4 normal, TSH missing | T3 Thyrotoxicosis - probable Graves' disease |
| 🔴 Important | SGPT 2x high + ALP high | Hepatitis (viral vs. NAFLD vs. thyroid-related) |
| ⚠️ Monitor | HbA1c 6.0% | Prediabetes |
| ⚠️ Watch | WBC high-normal | Likely reactive, monitor |
⚕️ Disclaimer: This interpretation is a clinical reasoning exercise provided at your request as a fellow medical professional (MBBS). It does not replace formal clinical assessment. Please correlate with full history, symptoms, physical examination, and clinical judgment before initiating treatment.
Generate a summary report for your patient records
ls /home/daytona/workspace/ 2>/dev/null && ls /home/daytona/skills/docx/scripts/office/ 2>/dev/null
mkdir -p /home/daytona/workspace/patient-report && cat > /home/daytona/workspace/patient-report/generate_report.js << 'EOF' const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, AlignmentType, HeadingLevel, BorderStyle, WidthType, ShadingType, VerticalAlign, Header, Footer, PageNumber, NumberFormat } = require('docx'); const fs = require('fs'); const DARK_RED = "8B0000"; const LIGHT_RED = "FFE5E5"; const LIGHT_YELLOW = "FFFBE5"; const LIGHT_GREEN = "E8F5E9"; const HEADER_BLUE = "1A3A5C"; const LIGHT_BLUE = "EBF3FB"; const GREY = "F5F5F5"; const BORDER_GREY = "CCCCCC"; const WHITE = "FFFFFF"; function makeCell(text, opts = {}) { const { bold = false, color = "000000", bg = WHITE, width = null, align = AlignmentType.LEFT, vAlign = VerticalAlign.CENTER, size = 18, italic = false, shade = null } = opts; const cellOpts = { verticalAlign: vAlign, shading: shade || { fill: bg, type: ShadingType.CLEAR }, margins: { top: 80, bottom: 80, left: 120, right: 120 }, children: [ new Paragraph({ alignment: align, children: [new TextRun({ text, bold, color, size, italics: italic, font: "Calibri" })] }) ] }; if (width) cellOpts.width = { size: width, type: WidthType.DXA }; return new TableCell(cellOpts); } function sectionHeading(text) { return new Paragraph({ spacing: { before: 300, after: 100 }, children: [ new TextRun({ text, bold: true, size: 24, color: HEADER_BLUE, font: "Calibri", allCaps: true }) ], border: { bottom: { style: BorderStyle.SINGLE, size: 6, color: HEADER_BLUE } } }); } function labTableHeader(cols) { return new TableRow({ tableHeader: true, children: cols.map(c => makeCell(c, { bold: true, color: WHITE, bg: HEADER_BLUE, size: 18, align: AlignmentType.CENTER }) ) }); } function labRow(test, result, range, status, flag) { let bg = WHITE; if (flag === "HIGH") bg = LIGHT_RED; else if (flag === "WARN") bg = LIGHT_YELLOW; else if (flag === "NORMAL") bg = WHITE; const statusColor = flag === "HIGH" ? "CC0000" : flag === "WARN" ? "CC7700" : "007700"; return new TableRow({ children: [ makeCell(test, { bg, size: 18 }), makeCell(result, { bg, bold: flag === "HIGH", color: flag === "HIGH" ? "CC0000" : "000000", size: 18, align: AlignmentType.CENTER }), makeCell(range, { bg, size: 16, color: "444444" }), makeCell(status, { bg, bold: true, color: statusColor, size: 18, align: AlignmentType.CENTER }) ] }); } const colWidths = [3200, 1600, 3200, 1500]; function labTable(rows) { return new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, insideH: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY }, insideV: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY } }, rows: [ labTableHeader(["Test", "Result", "Reference Range", "Status"]), ...rows ] }); } function noteBox(label, text, color = LIGHT_YELLOW, labelColor = "CC7700") { return new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 6, color: labelColor }, bottom: { style: BorderStyle.SINGLE, size: 6, color: labelColor }, left: { style: BorderStyle.SINGLE, size: 12, color: labelColor }, right: { style: BorderStyle.SINGLE, size: 6, color: labelColor }, }, rows: [ new TableRow({ children: [ new TableCell({ shading: { fill: color, type: ShadingType.CLEAR }, margins: { top: 100, bottom: 100, left: 160, right: 160 }, children: [ new Paragraph({ children: [ new TextRun({ text: label + " ", bold: true, size: 18, color: labelColor, font: "Calibri" }), new TextRun({ text, size: 18, font: "Calibri" }) ] }) ] }) ] }) ] }); } function gap(lines = 1) { return Array.from({ length: lines }, () => new Paragraph({ text: "", spacing: { before: 0, after: 0 } })); } const doc = new Document({ styles: { default: { document: { run: { font: "Calibri", size: 20 } } } }, sections: [{ properties: { page: { margin: { top: 900, bottom: 900, left: 1000, right: 1000 } } }, headers: { default: new Header({ children: [ new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.NONE }, bottom: { style: BorderStyle.SINGLE, size: 6, color: HEADER_BLUE }, left: { style: BorderStyle.NONE }, right: { style: BorderStyle.NONE }, insideH: { style: BorderStyle.NONE }, insideV: { style: BorderStyle.NONE } }, rows: [ new TableRow({ children: [ new TableCell({ width: { size: 6000, type: WidthType.DXA }, borders: { top: { style: BorderStyle.NONE }, bottom: { style: BorderStyle.NONE }, left: { style: BorderStyle.NONE }, right: { style: BorderStyle.NONE } }, children: [ new Paragraph({ children: [new TextRun({ text: "PATIENT INVESTIGATION SUMMARY", bold: true, size: 24, color: HEADER_BLUE, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Dr. Muhammad Daniyal, MBBS", size: 18, color: "555555", font: "Calibri" })] }) ] }), new TableCell({ width: { size: 3500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.NONE }, bottom: { style: BorderStyle.NONE }, left: { style: BorderStyle.NONE }, right: { style: BorderStyle.NONE } }, children: [ new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun({ text: "Indus Medical College Hospital", size: 18, color: "555555", font: "Calibri" })] }), new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun({ text: "Tando Muhammad Khan", size: 18, color: "555555", font: "Calibri" })] }), new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun({ text: "Date: 13-Jul-2026", size: 18, color: "555555", font: "Calibri" })] }) ] }) ] }) ] }) ] }) }, footers: { default: new Footer({ children: [ new Paragraph({ alignment: AlignmentType.CENTER, border: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY } }, children: [ new TextRun({ text: "CONFIDENTIAL - For Treating Physician Use Only | Lab No: 387999 / 388003 | Page ", size: 16, color: "888888", font: "Calibri" }), new TextRun({ children: [new PageNumber()], size: 16, color: "888888", font: "Calibri" }) ] }) ] }) }, children: [ // Title block new Paragraph({ spacing: { before: 200, after: 60 } }), new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, bottom: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, left: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, right: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, insideH: { style: BorderStyle.NONE }, insideV: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY } }, rows: [ new TableRow({ children: [ new TableCell({ shading: { fill: HEADER_BLUE, type: ShadingType.CLEAR }, width: { size: 4750, type: WidthType.DXA }, margins: { top: 120, bottom: 120, left: 160, right: 160 }, children: [ new Paragraph({ children: [new TextRun({ text: "PATIENT", bold: true, size: 16, color: "AACCEE", font: "Calibri", allCaps: true })] }), new Paragraph({ children: [new TextRun({ text: "Dr. Muhammad Daniyal", bold: true, size: 26, color: WHITE, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "MBBS", size: 20, color: "BBDDFF", font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Male, 26 Years", size: 18, color: "CCDDEE", font: "Calibri" })] }) ] }), new TableCell({ shading: { fill: LIGHT_BLUE, type: ShadingType.CLEAR }, width: { size: 4750, type: WidthType.DXA }, margins: { top: 120, bottom: 120, left: 160, right: 160 }, children: [ new Paragraph({ children: [new TextRun({ text: "Lab No: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "387999 / 388003", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "OPD: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "26-0 | Ref: PRIVATE", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Sample Collected: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "12-Jul-2026", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Report Generated: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "13-Jul-2026", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Facility: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "IMC Hospital, Tando Muhammad Khan", size: 18, font: "Calibri" })] }) ] }) ] }) ] }), ...gap(1), // FINDINGS OVERVIEW sectionHeading("Clinical Findings Overview"), ...gap(1), new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, insideH: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY }, insideV: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY } }, rows: [ new TableRow({ children: [ makeCell("Priority", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 1200 }), makeCell("Parameter", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 2800 }), makeCell("Finding", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 2600 }), makeCell("Impression", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 2900 }) ] }), new TableRow({ children: [ makeCell("URGENT", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18, align: AlignmentType.CENTER }), makeCell("Free T3", { bg: LIGHT_RED, size: 18 }), makeCell("2.88 ng/mL (Ref: 0.8-1.5)", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18 }), makeCell("T3 Thyrotoxicosis - TSH URGENTLY NEEDED", { bg: LIGHT_RED, size: 17 }) ]}), new TableRow({ children: [ makeCell("HIGH", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18, align: AlignmentType.CENTER }), makeCell("SGPT (ALT)", { bg: LIGHT_RED, size: 18 }), makeCell("92 U/L (Ref: up to 43)", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18 }), makeCell("Hepatocellular injury / NAFLD / viral hepatitis", { bg: LIGHT_RED, size: 17 }) ]}), new TableRow({ children: [ makeCell("HIGH", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18, align: AlignmentType.CENTER }), makeCell("Alkaline Phosphatase", { bg: LIGHT_RED, size: 18 }), makeCell("197 U/L (Ref: 40-129)", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18 }), makeCell("Cholestatic / bone / thyroid-related", { bg: LIGHT_RED, size: 17 }) ]}), new TableRow({ children: [ makeCell("WATCH", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18, align: AlignmentType.CENTER }), makeCell("HbA1c", { bg: LIGHT_YELLOW, size: 18 }), makeCell("6.0% (Ref: 4.8-5.9%)", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18 }), makeCell("Prediabetes range - lifestyle intervention", { bg: LIGHT_YELLOW, size: 17 }) ]}), new TableRow({ children: [ makeCell("NOTE", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18, align: AlignmentType.CENTER }), makeCell("WBC Count", { bg: LIGHT_YELLOW, size: 18 }), makeCell("10.74 x10\u2079/L (Ref: 4.0-11.0)", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18 }), makeCell("High-normal - monitor; likely reactive", { bg: LIGHT_YELLOW, size: 17 }) ]}), new TableRow({ children: [ makeCell("NORMAL", { bg: LIGHT_GREEN, bold: true, color: "007700", size: 18, align: AlignmentType.CENTER }), makeCell("Electrolytes, Renal, CBC morphology", { bg: LIGHT_GREEN, size: 18 }), makeCell("All within normal limits", { bg: LIGHT_GREEN, size: 18 }), makeCell("No action required", { bg: LIGHT_GREEN, size: 17 }) ]}) ] }), ...gap(1), // HAEMATOLOGY sectionHeading("1. Haematology - CBC + ESR Profile"), ...gap(1), labTable([ labRow("Haemoglobin", "14.3 g/dL", "13.0 - 18.0 g/dL", "Normal", "NORMAL"), labRow("RBC", "4.72 /cumm", "-", "Normal", "NORMAL"), labRow("PCV", "39.8%", "37.4 - 52.0%", "Normal", "NORMAL"), labRow("MCV", "84.3 fL", "77 - 97 fL", "Normal", "NORMAL"), labRow("MCH", "30.3 pg", "27 - 32 pg", "Normal", "NORMAL"), labRow("MCHC", "36.0 g/dL", "31 - 35 g/dL", "Marginally High", "WARN"), labRow("WBC", "10.74 x10\u2079/L", "4.0 - 11.0 x10\u2079/L", "High-Normal", "WARN"), labRow("Neutrophils", "63%", "40 - 75%", "Normal", "NORMAL"), labRow("Lymphocytes", "31%", "20 - 45%", "Normal", "NORMAL"), labRow("Monocytes", "4%", "2 - 10%", "Normal", "NORMAL"), labRow("Eosinophils", "2%", "1 - 6%", "Normal", "NORMAL"), labRow("Platelet Count", "247 x10\u2079/L", "150 - 450 x10\u2079/L", "Normal", "NORMAL") ]), ...gap(1), noteBox("Smear Remarks:", "Normocytic, Normochromic. WBCs show normal count. Platelets adequate on smear.", LIGHT_GREEN, "007700"), ...gap(1), // ELECTROLYTES sectionHeading("2. Biochemistry - Electrolytes"), ...gap(1), labTable([ labRow("Sodium", "136.9 mEq/L", "135 - 145 mEq/L", "Normal", "NORMAL"), labRow("Potassium", "3.93 mEq/L", "3.5 - 5.5 mEq/L", "Normal", "NORMAL"), labRow("Chloride", "101.7 mEq/L", "98 - 107 mEq/L", "Normal", "NORMAL"), labRow("Bicarbonate", "24.54 mEq/L", "22.3 - 31.0 mEq/L", "Normal", "NORMAL") ]), ...gap(1), // ROUTINE CHEMISTRY sectionHeading("3. Routine Chemistry - Renal, Liver, Glucose & Minerals"), ...gap(1), labTable([ labRow("Urea", "29 mg/dL", "15 - 45 mg/dL", "Normal", "NORMAL"), labRow("Creatinine", "1.2 mg/dL", "0.7 - 1.2 mg/dL", "Upper Normal", "NORMAL"), labRow("Bilirubin (Total)", "0.7 mg/dL", "Up to 1.4 mg/dL (male)", "Normal", "NORMAL"), labRow("SGPT (ALT)", "92 U/L", "Up to 43 U/L (male)", "\u26A0 HIGH (>2x ULN)", "HIGH"), labRow("Alkaline Phosphatase", "197 U/L", "40 - 129 U/L (male)", "\u26A0 HIGH", "HIGH"), labRow("HbA1c (Glycosylated Hb)", "6.0%", "4.8 - 5.9%", "\u26A0 Borderline (Prediabetes)", "WARN"), labRow("Magnesium", "2.2 mg/dL", "1.2 - 2.5 mg/dL", "Normal", "NORMAL"), labRow("Uric Acid", "4.5 mg/dL", "3.4 - 7.0 mg/dL (male)", "Normal", "NORMAL"), labRow("Calcium", "10.2 mg/dL", "8.4 - 10.2 mg/dL (adult)", "Upper Limit", "WARN") ]), ...gap(1), // THYROID sectionHeading("4. Thyroid Function Tests"), ...gap(1), labTable([ labRow("Free T3", "2.88 ng/mL", "0.8 - 1.5 ng/mL", "\u26A0 HIGH (nearly 2x ULN)", "HIGH"), labRow("Free T4 (CLIA)", "1.08 ng/mL", "0.8 - 2.0 ng/mL (adult)", "Normal", "NORMAL"), labRow("TSH", "NOT DONE", "-", "\u26A0 CRITICAL - Order Urgently", "HIGH") ]), ...gap(1), noteBox("\u26A0 CRITICAL:", "TSH has not been ordered. Free T3 is nearly double the upper limit with normal Free T4. This pattern is consistent with T3 Thyrotoxicosis. TSH must be measured URGENTLY to confirm/exclude hyperthyroidism.", LIGHT_RED, "CC0000"), ...gap(1), // DIAGNOSTIC IMPRESSION sectionHeading("Diagnostic Impression & Recommended Workup"), ...gap(1), // Finding 1 new Paragraph({ spacing: { before: 120, after: 60 }, children: [new TextRun({ text: "1. Probable T3 Thyrotoxicosis (Rule out Graves Disease)", bold: true, size: 22, color: "CC0000", font: "Calibri" })] }), new Paragraph({ spacing: { before: 40, after: 40 }, children: [new TextRun({ text: "Free T3 at 2.88 ng/mL (nearly 2x upper limit) with normal Free T4 (1.08) is the hallmark pattern of T3 thyrotoxicosis, seen in ~5% of hyperthyroid patients. Without TSH, formal diagnosis cannot be established. If TSH is suppressed (<0.1 \u03BCIU/mL), this confirms overt hyperthyroidism.", size: 18, font: "Calibri" })] }), noteBox("Recommended:", "TSH (STAT) | Anti-TPO Antibodies | TSH Receptor Antibodies (TRAb/TSI) | Thyroid Ultrasound | Consider Endocrinology referral", LIGHT_YELLOW, "CC7700"), ...gap(1), // Finding 2 new Paragraph({ spacing: { before: 120, after: 60 }, children: [new TextRun({ text: "2. Hepatocellular Injury / Transaminitis", bold: true, size: 22, color: "CC0000", font: "Calibri" })] }), new Paragraph({ spacing: { before: 40, after: 40 }, children: [new TextRun({ text: "SGPT (ALT) elevated at 92 U/L (>2x ULN of 43) with raised Alkaline Phosphatase (197 U/L). This mixed hepatocellular and cholestatic pattern may be due to: (a) Hyperthyroidism-related hepatic dysfunction, (b) NAFLD, (c) Viral hepatitis (HBV/HCV). The liver enzyme elevation may resolve with treatment of the underlying thyroid disorder.", size: 18, font: "Calibri" })] }), noteBox("Recommended:", "HBsAg | Anti-HCV | SGOT/AST | GGT | Liver Ultrasound | Complete LFTs (SGOT, GGT, Albumin, PT/INR)", LIGHT_YELLOW, "CC7700"), ...gap(1), // Finding 3 new Paragraph({ spacing: { before: 120, after: 60 }, children: [new TextRun({ text: "3. Prediabetes (HbA1c 6.0%)", bold: true, size: 22, color: "CC7700", font: "Calibri" })] }), new Paragraph({ spacing: { before: 40, after: 40 }, children: [new TextRun({ text: "HbA1c of 6.0% falls in the prediabetes range (5.7%-6.4%). Formal diabetes threshold is 6.5%. At 26 years, aggressive lifestyle intervention is appropriate. Note that hyperthyroidism can mildly worsen glucose metabolism; re-check HbA1c after thyroid treatment.", size: 18, font: "Calibri" })] }), noteBox("Recommended:", "Fasting Blood Glucose | 2-hr OGTT | Dietary counseling | Repeat HbA1c in 3-6 months after thyroid management", LIGHT_YELLOW, "CC7700"), ...gap(1), // NORMAL SUMMARY sectionHeading("Parameters Within Normal Limits"), ...gap(1), new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, insideH: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY }, insideV: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY } }, rows: [ new TableRow({ children: [ makeCell("System", { bold: true, bg: "E8F5E9", color: "007700", size: 18, width: 3000 }), makeCell("Tests", { bold: true, bg: "E8F5E9", color: "007700", size: 18, width: 6500 }) ]}), new TableRow({ children: [ makeCell("Haematology", { size: 18 }), makeCell("Hb, RBC, PCV, MCV, MCH, Platelets, Neutrophils, Lymphocytes, Monocytes, Eosinophils - all normal", { size: 18 }) ]}), new TableRow({ children: [ makeCell("Electrolytes", { size: 18 }), makeCell("Sodium, Potassium, Chloride, Bicarbonate - all normal", { size: 18 }) ]}), new TableRow({ children: [ makeCell("Renal Function", { size: 18 }), makeCell("Urea 29 mg/dL, Creatinine 1.2 mg/dL (upper normal), Calcium and Magnesium normal", { size: 18 }) ]}), new TableRow({ children: [ makeCell("Liver (Bilirubin)", { size: 18 }), makeCell("Total Bilirubin 0.7 mg/dL - normal", { size: 18 }) ]}), new TableRow({ children: [ makeCell("Thyroid (FT4)", { size: 18 }), makeCell("Free T4 (CLIA) 1.08 ng/mL - within adult normal range (0.8-2.0)", { size: 18 }) ]}) ] }), ...gap(1), // DISCLAIMER new Paragraph({ spacing: { before: 300, after: 100 }, border: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY } }, children: [ new TextRun({ text: "Disclaimer: ", bold: true, size: 16, color: "888888", font: "Calibri" }), new TextRun({ text: "This summary report was generated for Dr. Muhammad Daniyal (MBBS) as a clinical interpretation aid. All findings must be correlated with clinical history, physical examination, and professional medical judgment. This document does not constitute a formal medical diagnosis or treatment recommendation.", size: 16, color: "888888", font: "Calibri", italics: true }) ] }) ] }] }); Packer.toBuffer(doc).then(buffer => { fs.writeFileSync("/home/daytona/workspace/patient-report/Patient_Summary_DrDaniyal_13Jul2026.docx", buffer); console.log("SUCCESS"); }).catch(err => { console.error("ERROR:", err.message); }); EOF echo "Script written"
cd /home/daytona/workspace/patient-report && node generate_report.js
~/patient-report/generate_report.js
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/patient-report/generate_report.js'
cd /home/daytona/workspace/patient-report && node generate_report.js
python /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/patient-report/Patient_Summary_DrDaniyal_13Jul2026.docx
ls -lh /home/daytona/workspace/patient-report/Patient_Summary_DrDaniyal_13Jul2026.docx && python3 -c "import zipfile; z = zipfile.ZipFile('/home/daytona/workspace/patient-report/Patient_Summary_DrDaniyal_13Jul2026.docx'); print('Valid ZIP, files:', len(z.namelist())); print(z.namelist()[:5])"
Patient Summary DrDaniyal 13Jul2026
Word Document · DOCX
Vitamin D is 26.74 Vitamin B 12 205.70 TSH- 1.644
cat > /home/daytona/workspace/patient-report/generate_report_v2.js << 'JSEOF' const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, AlignmentType, HeadingLevel, BorderStyle, WidthType, ShadingType, VerticalAlign, Header, Footer } = require('docx'); const fs = require('fs'); const DARK_RED = "8B0000"; const LIGHT_RED = "FFE5E5"; const LIGHT_YELLOW = "FFFBE5"; const LIGHT_GREEN = "E8F5E9"; const HEADER_BLUE = "1A3A5C"; const LIGHT_BLUE = "EBF3FB"; const BORDER_GREY = "CCCCCC"; const WHITE = "FFFFFF"; const ORANGE_BG = "FFF0E0"; function makeCell(text, opts = {}) { const { bold=false, color="000000", bg=WHITE, width=null, align=AlignmentType.LEFT, vAlign=VerticalAlign.CENTER, size=18, italic=false } = opts; const cellOpts = { verticalAlign: vAlign, shading: { fill: bg, type: ShadingType.CLEAR }, margins: { top: 80, bottom: 80, left: 120, right: 120 }, children: [new Paragraph({ alignment: align, children: [ new TextRun({ text, bold, color, size, italics: italic, font: "Calibri" }) ]})] }; if (width) cellOpts.width = { size: width, type: WidthType.DXA }; return new TableCell(cellOpts); } function sectionHeading(text) { return new Paragraph({ spacing: { before: 300, after: 100 }, border: { bottom: { style: BorderStyle.SINGLE, size: 6, color: HEADER_BLUE } }, children: [new TextRun({ text, bold: true, size: 24, color: HEADER_BLUE, font: "Calibri", allCaps: true })] }); } function labTableHeader(cols) { return new TableRow({ tableHeader: true, children: cols.map(c => makeCell(c, { bold: true, color: WHITE, bg: HEADER_BLUE, size: 18, align: AlignmentType.CENTER }) )}); } function labRow(test, result, range, status, flag) { let bg = WHITE; if (flag === "HIGH") bg = LIGHT_RED; else if (flag === "WARN") bg = LIGHT_YELLOW; else if (flag === "LOW") bg = ORANGE_BG; const statusColor = flag === "HIGH" ? "CC0000" : flag === "WARN" ? "CC7700" : flag === "LOW" ? "AA5500" : "007700"; return new TableRow({ children: [ makeCell(test, { bg, size: 18 }), makeCell(result, { bg, bold: flag !== "NORMAL", color: flag === "HIGH" ? "CC0000" : flag === "LOW" ? "AA5500" : flag === "WARN" ? "CC7700" : "000000", size: 18, align: AlignmentType.CENTER }), makeCell(range, { bg, size: 16, color: "444444" }), makeCell(status, { bg, bold: true, color: statusColor, size: 18, align: AlignmentType.CENTER }) ]}); } function labTable(rows) { return new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, insideH: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY }, insideV: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY } }, rows: [labTableHeader(["Test", "Result", "Reference Range", "Status"]), ...rows] }); } function noteBox(label, text, bg=LIGHT_YELLOW, labelColor="CC7700") { return new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 6, color: labelColor }, bottom: { style: BorderStyle.SINGLE, size: 6, color: labelColor }, left: { style: BorderStyle.SINGLE, size: 12, color: labelColor }, right: { style: BorderStyle.SINGLE, size: 6, color: labelColor } }, rows: [new TableRow({ children: [new TableCell({ shading: { fill: bg, type: ShadingType.CLEAR }, margins: { top: 100, bottom: 100, left: 160, right: 160 }, children: [new Paragraph({ children: [ new TextRun({ text: label + " ", bold: true, size: 18, color: labelColor, font: "Calibri" }), new TextRun({ text, size: 18, font: "Calibri" }) ]})] })})] }); } function gap() { return new Paragraph({ text: "", spacing: { before: 0, after: 60 } }); } function bullet(text, bold_part="", rest="") { return new Paragraph({ bullet: { level: 0 }, spacing: { before: 40, after: 40 }, children: [ new TextRun({ text: bold_part, bold: true, size: 18, font: "Calibri" }), new TextRun({ text: rest || text, size: 18, font: "Calibri" }) ] }); } function bodyText(text) { return new Paragraph({ spacing: { before: 40, after: 60 }, children: [ new TextRun({ text, size: 18, font: "Calibri" }) ]}); } function findingTitle(num, title, color="CC0000") { return new Paragraph({ spacing: { before: 160, after: 60 }, children: [ new TextRun({ text: `${num}. ${title}`, bold: true, size: 22, color, font: "Calibri" }) ]}); } const doc = new Document({ styles: { default: { document: { run: { font: "Calibri", size: 20 } } } }, sections: [{ properties: { page: { margin: { top: 900, bottom: 900, left: 1000, right: 1000 } } }, headers: { default: new Header({ children: [ new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.NONE }, bottom: { style: BorderStyle.SINGLE, size: 6, color: HEADER_BLUE }, left: { style: BorderStyle.NONE }, right: { style: BorderStyle.NONE }, insideH: { style: BorderStyle.NONE }, insideV: { style: BorderStyle.NONE } }, rows: [new TableRow({ children: [ new TableCell({ width: { size: 6000, type: WidthType.DXA }, borders: { top:{style:BorderStyle.NONE}, bottom:{style:BorderStyle.NONE}, left:{style:BorderStyle.NONE}, right:{style:BorderStyle.NONE} }, children: [ new Paragraph({ children: [new TextRun({ text: "PATIENT INVESTIGATION SUMMARY (UPDATED)", bold: true, size: 22, color: HEADER_BLUE, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Dr. Muhammad Daniyal, MBBS", size: 18, color: "555555", font: "Calibri" })] }) ] }), new TableCell({ width: { size: 3500, type: WidthType.DXA }, borders: { top:{style:BorderStyle.NONE}, bottom:{style:BorderStyle.NONE}, left:{style:BorderStyle.NONE}, right:{style:BorderStyle.NONE} }, children: [ new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun({ text: "IMC Hospital, Tando Muhammad Khan", size: 18, color: "555555", font: "Calibri" })] }), new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun({ text: "Date: 13-Jul-2026 | Lab No: 387999 / 388003", size: 18, color: "555555", font: "Calibri" })] }) ] }) ]})] }) ]}) }, footers: { default: new Footer({ children: [ new Paragraph({ alignment: AlignmentType.CENTER, border: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY } }, children: [new TextRun({ text: "CONFIDENTIAL - For Treating Physician Use Only | Dr. Muhammad Daniyal, MBBS | Male, 26 Years", size: 16, color: "888888", font: "Calibri" })] }) ]}) }, children: [ gap(), // PATIENT HEADER TABLE new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, bottom: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, left: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, right: { style: BorderStyle.SINGLE, size: 8, color: HEADER_BLUE }, insideH: { style: BorderStyle.NONE }, insideV: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY } }, rows: [new TableRow({ children: [ new TableCell({ shading: { fill: HEADER_BLUE, type: ShadingType.CLEAR }, width: { size: 4750, type: WidthType.DXA }, margins: { top: 120, bottom: 120, left: 160, right: 160 }, children: [ new Paragraph({ children: [new TextRun({ text: "PATIENT", bold: true, size: 16, color: "AACCEE", font: "Calibri", allCaps: true })] }), new Paragraph({ children: [new TextRun({ text: "Dr. Muhammad Daniyal", bold: true, size: 26, color: WHITE, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "MBBS", size: 20, color: "BBDDFF", font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Male, 26 Years", size: 18, color: "CCDDEE", font: "Calibri" })] }) ] }), new TableCell({ shading: { fill: LIGHT_BLUE, type: ShadingType.CLEAR }, width: { size: 4750, type: WidthType.DXA }, margins: { top: 120, bottom: 120, left: 160, right: 160 }, children: [ new Paragraph({ children: [new TextRun({ text: "Lab No: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "387999 / 388003", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "OPD: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "26-0 | Ref: PRIVATE", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Sample Collected: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "12-Jul-2026", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Report Date: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "13-Jul-2026", size: 18, font: "Calibri" })] }), new Paragraph({ children: [new TextRun({ text: "Facility: ", bold: true, size: 18, font: "Calibri" }), new TextRun({ text: "IMC Hospital, T.M. Khan", size: 18, font: "Calibri" })] }) ] }) ]})] }), gap(), // FINDINGS OVERVIEW sectionHeading("Clinical Findings Overview — Complete Panel"), gap(), new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, insideH: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY }, insideV: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY } }, rows: [ new TableRow({ children: [ makeCell("Priority", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 1200 }), makeCell("Parameter", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 2800 }), makeCell("Result", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 2000 }), makeCell("Impression", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 3500 }) ]},), new TableRow({ children: [ makeCell("HIGH", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18, align: AlignmentType.CENTER }), makeCell("Free T3", { bg: LIGHT_RED, size: 18 }), makeCell("2.88 ng/mL (Ref: 0.8-1.5)", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18 }), makeCell("T3 Thyrotoxicosis - see TSH below", { bg: LIGHT_RED, size: 17 }) ]}), new TableRow({ children: [ makeCell("HIGH", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18, align: AlignmentType.CENTER }), makeCell("SGPT (ALT)", { bg: LIGHT_RED, size: 18 }), makeCell("92 U/L (Ref: up to 43)", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18 }), makeCell("Hepatocellular injury / NAFLD / thyroid-related", { bg: LIGHT_RED, size: 17 }) ]}), new TableRow({ children: [ makeCell("HIGH", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18, align: AlignmentType.CENTER }), makeCell("Alkaline Phosphatase", { bg: LIGHT_RED, size: 18 }), makeCell("197 U/L (Ref: 40-129)", { bg: LIGHT_RED, bold: true, color: "CC0000", size: 18 }), makeCell("Cholestatic / bone / thyroid-related", { bg: LIGHT_RED, size: 17 }) ]}), new TableRow({ children: [ makeCell("LOW", { bg: ORANGE_BG, bold: true, color: "AA5500", size: 18, align: AlignmentType.CENTER }), makeCell("Vitamin D (25-OH)", { bg: ORANGE_BG, size: 18 }), makeCell("26.74 ng/mL (Ref: >30)", { bg: ORANGE_BG, bold: true, color: "AA5500", size: 18 }), makeCell("Vitamin D Insufficiency - supplement needed", { bg: ORANGE_BG, size: 17 }) ]}), new TableRow({ children: [ makeCell("WATCH", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18, align: AlignmentType.CENTER }), makeCell("Vitamin B12", { bg: LIGHT_YELLOW, size: 18 }), makeCell("205.70 pg/mL (Ref: 200-900)", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18 }), makeCell("Borderline low-normal - monitor closely", { bg: LIGHT_YELLOW, size: 17 }) ]}), new TableRow({ children: [ makeCell("RESOLVED", { bg: LIGHT_GREEN, bold: true, color: "007700", size: 18, align: AlignmentType.CENTER }), makeCell("TSH", { bg: LIGHT_GREEN, size: 18 }), makeCell("1.644 \u03BCIU/mL (Ref: 0.4-4.0)", { bg: LIGHT_GREEN, bold: true, color: "007700", size: 18 }), makeCell("NORMAL - Rules out overt hyperthyroidism", { bg: LIGHT_GREEN, size: 17 }) ]}), new TableRow({ children: [ makeCell("WATCH", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18, align: AlignmentType.CENTER }), makeCell("HbA1c", { bg: LIGHT_YELLOW, size: 18 }), makeCell("6.0% (Ref: 4.8-5.9%)", { bg: LIGHT_YELLOW, bold: true, color: "CC7700", size: 18 }), makeCell("Prediabetes range - lifestyle intervention", { bg: LIGHT_YELLOW, size: 17 }) ]}), new TableRow({ children: [ makeCell("NORMAL", { bg: LIGHT_GREEN, bold: true, color: "007700", size: 18, align: AlignmentType.CENTER }), makeCell("Electrolytes, Renal, CBC, Free T4, Lipids", { bg: LIGHT_GREEN, size: 18 }), makeCell("All within normal limits", { bg: LIGHT_GREEN, size: 18 }), makeCell("No action required", { bg: LIGHT_GREEN, size: 17 }) ]}) ] }), gap(), // HAEMATOLOGY sectionHeading("1. Haematology — CBC + ESR Profile"), gap(), labTable([ labRow("Haemoglobin", "14.3 g/dL", "13.0 - 18.0 g/dL", "Normal", "NORMAL"), labRow("RBC", "4.72 /cumm", "Normal range", "Normal", "NORMAL"), labRow("PCV", "39.8%", "37.4 - 52.0%", "Normal", "NORMAL"), labRow("MCV", "84.3 fL", "77 - 97 fL", "Normal", "NORMAL"), labRow("MCH", "30.3 pg", "27 - 32 pg", "Normal", "NORMAL"), labRow("MCHC", "36.0 g/dL", "31 - 35 g/dL", "Marginally High", "WARN"), labRow("WBC", "10.74 x10\u2079/L", "4.0 - 11.0 x10\u2079/L", "High-Normal", "WARN"), labRow("Neutrophils", "63%", "40 - 75%", "Normal", "NORMAL"), labRow("Lymphocytes", "31%", "20 - 45%", "Normal", "NORMAL"), labRow("Monocytes", "4%", "2 - 10%", "Normal", "NORMAL"), labRow("Eosinophils", "2%", "1 - 6%", "Normal", "NORMAL"), labRow("Platelet Count", "247 x10\u2079/L", "150 - 450 x10\u2079/L", "Normal", "NORMAL") ]), gap(), noteBox("Smear Remarks:", "Normocytic, Normochromic. WBCs show normal count. Platelets adequate on smear.", LIGHT_GREEN, "007700"), gap(), // ELECTROLYTES sectionHeading("2. Biochemistry — Electrolytes"), gap(), labTable([ labRow("Sodium", "136.9 mEq/L", "135 - 145 mEq/L", "Normal", "NORMAL"), labRow("Potassium", "3.93 mEq/L", "3.5 - 5.5 mEq/L", "Normal", "NORMAL"), labRow("Chloride", "101.7 mEq/L", "98 - 107 mEq/L", "Normal", "NORMAL"), labRow("Bicarbonate", "24.54 mEq/L", "22.3 - 31.0 mEq/L", "Normal", "NORMAL") ]), gap(), // ROUTINE CHEMISTRY sectionHeading("3. Routine Chemistry — Renal, Liver, Glucose & Minerals"), gap(), labTable([ labRow("Urea", "29 mg/dL", "15 - 45 mg/dL", "Normal", "NORMAL"), labRow("Creatinine", "1.2 mg/dL", "0.7 - 1.2 mg/dL", "Upper Normal", "NORMAL"), labRow("Bilirubin (Total)", "0.7 mg/dL", "Up to 1.4 mg/dL (male)", "Normal", "NORMAL"), labRow("SGPT (ALT)", "92 U/L", "Up to 43 U/L (male)", "\u26A0 HIGH (>2x ULN)", "HIGH"), labRow("Alkaline Phosphatase", "197 U/L", "40 - 129 U/L (male)", "\u26A0 HIGH", "HIGH"), labRow("HbA1c", "6.0%", "4.8 - 5.9%", "\u26A0 Prediabetes Range", "WARN"), labRow("Magnesium", "2.2 mg/dL", "1.2 - 2.5 mg/dL", "Normal", "NORMAL"), labRow("Uric Acid", "4.5 mg/dL", "3.4 - 7.0 mg/dL (male)", "Normal", "NORMAL"), labRow("Calcium", "10.2 mg/dL", "8.4 - 10.2 mg/dL", "Upper Limit", "WARN") ]), gap(), // THYROID — COMPLETE sectionHeading("4. Thyroid Function Tests — Complete"), gap(), labTable([ labRow("Free T3", "2.88 ng/mL", "0.8 - 1.5 ng/mL", "\u26A0 HIGH (nearly 2x ULN)", "HIGH"), labRow("Free T4 (CLIA)", "1.08 ng/mL", "0.8 - 2.0 ng/mL (adult)", "Normal", "NORMAL"), labRow("TSH", "1.644 \u03BCIU/mL", "0.4 - 4.0 \u03BCIU/mL", "\u2714 Normal", "NORMAL") ]), gap(), noteBox("\u2714 TSH Normal — Overt Hyperthyroidism EXCLUDED:", "TSH of 1.644 \u03BCIU/mL is solidly within normal range. This rules out overt hyperthyroidism and subclinical hyperthyroidism. The elevated Free T3 (2.88) is likely due to a non-thyroidal cause (see Diagnostic Impression below).", LIGHT_GREEN, "007700"), gap(), // VITAMINS sectionHeading("5. Vitamins"), gap(), labTable([ labRow("Vitamin D (25-OH)", "26.74 ng/mL", ">30 ng/mL (sufficient)\n20-30 = Insufficiency\n<20 = Deficiency", "\u26A0 Insufficiency", "LOW"), labRow("Vitamin B12 (Cobalamin)", "205.70 pg/mL", "200 - 900 pg/mL", "\u26A0 Borderline Low-Normal", "WARN") ]), gap(), noteBox("Vitamin D Note:", "26.74 ng/mL falls in the insufficiency range (20-30 ng/mL) per US Endocrine Society guidelines (deficiency <20, insufficiency 20-30, sufficient >30). Supplementation is recommended. Note: low Vitamin D can worsen musculoskeletal symptoms, immune function, and mood.", ORANGE_BG, "AA5500"), gap(), noteBox("Vitamin B12 Note:", "205.70 pg/mL is technically within normal range (200-900 pg/mL) but sits at the very lower boundary. Values between 100-200 pg/mL are considered borderline deficient; between 200-300 pg/mL warrant clinical correlation with symptoms (fatigue, tingling, memory issues). CBC is normal (no megaloblastic changes), which is reassuring.", LIGHT_YELLOW, "CC7700"), gap(), // DIAGNOSTIC IMPRESSION sectionHeading("Diagnostic Impression & Clinical Reasoning"), gap(), findingTitle("1", "Elevated Free T3 with Normal TSH and Free T4 — Non-Thyroidal Illness / Lab Artefact", "CC7700"), bodyText("The most significant update from this panel is TSH = 1.644 \u03BCIU/mL (normal). This is a pivotal result:"), bullet("Normal TSH", " rules out both overt hyperthyroidism and subclinical hyperthyroidism."), bullet("Normal Free T4", " (1.08 ng/mL) was already noted."), bullet("The combination of elevated Free T3 + normal T4 + normal TSH", " is not consistent with primary hyperthyroidism."), gap(), bodyText("Differential diagnosis for isolated elevated Free T3 with normal TSH:"), bullet("", "Non-Thyroidal Illness Syndrome (NTIS) / sick euthyroid: peripheral conversion of T4 to T3 is increased in inflammatory or hepatic states, elevating serum T3 without pituitary suppression."), bullet("", "Liver disease (the patient already has elevated ALT + ALP): the liver is a key site for T4-to-T3 conversion and thyroid hormone binding proteins; hepatocellular injury can distort T3 levels."), bullet("", "Vitamin D insufficiency is associated with altered thyroid hormone metabolism in some studies."), bullet("", "Assay variation: Free T3 measurement is technically the most variable of the thyroid tests; some labs use ng/mL, others use pmol/L. Confirm units and consider repeat testing."), gap(), noteBox("Recommended:", "Repeat Free T3 in 4-6 weeks after addressing liver disease and Vitamin D insufficiency. If persistently elevated, consider anti-TPO, TRAb, and endocrinology referral. At this point, no antithyroid treatment is indicated.", LIGHT_YELLOW, "CC7700"), gap(), findingTitle("2", "Hepatocellular Transaminitis (SGPT 2x ULN + Elevated ALP)", "CC0000"), bodyText("SGPT 92 U/L (>2x ULN) and ALP 197 U/L remain the most actionable abnormalities. In the context of a normal TSH, thyroid-related hepatopathy is now less likely as the sole explanation."), bullet("", "Most probable: NAFLD (non-alcoholic fatty liver disease) or viral hepatitis (HBV/HCV)."), bullet("", "The elevated ALP alongside ALT suggests both hepatocellular and cholestatic involvement."), bullet("", "Vitamin D insufficiency can itself coexist with and worsen liver inflammation (low Vit D is common in NAFLD)."), gap(), noteBox("Recommended (Priority):", "HBsAg | Anti-HCV antibody | SGOT/AST | GGT | Serum Albumin | PT/INR | Liver Ultrasound", LIGHT_RED, "CC0000"), gap(), findingTitle("3", "Vitamin D Insufficiency (26.74 ng/mL)", "AA5500"), bodyText("Per Endocrine Society guidelines: insufficiency is defined as 20-30 ng/mL. At 26.74, supplementation is clearly indicated. Vitamin D insufficiency in a 26-year-old male is extremely common in South Asia (limited sun exposure, dietary factors). Clinical consequences include:"), bullet("", "Musculoskeletal pain, fatigue, and muscle weakness."), bullet("", "Impaired calcium absorption (though serum calcium here is at the upper normal limit - 10.2 mg/dL)."), bullet("", "Immune dysregulation and increased susceptibility to infection."), bullet("", "Association with worsened metabolic syndrome and NAFLD."), gap(), noteBox("Recommended:", "Cholecalciferol (Vitamin D3) 50,000 IU weekly for 8 weeks (loading dose), then 1000-2000 IU/day maintenance. Recheck 25-OH Vitamin D at 3 months. Ensure adequate calcium intake (1000 mg/day from diet).", ORANGE_BG, "AA5500"), gap(), findingTitle("4", "Vitamin B12 Borderline Low-Normal (205.70 pg/mL)", "CC7700"), bodyText("B12 of 205.70 pg/mL is technically within range but only just above the lower limit (200 pg/mL). Henry's Clinical Diagnosis notes that 200-300 pg/mL values require correlation with symptoms. Key points:"), bullet("", "CBC is reassuringly normal - no megaloblastic anemia, no macrocytosis (MCV 84.3 fL is normal)."), bullet("", "However, neurological manifestations (peripheral tingling, fatigue, memory fog) can precede hematological changes."), bullet("", "Risk factors in South Asia: vegetarian/low-meat diet, H. pylori gastritis."), gap(), noteBox("Recommended:", "Correlate with symptoms. If fatigue, tingling, or neurological symptoms are present, supplement with Methylcobalamin 1500 mcg/day orally or IM B12 1000 mcg monthly. Recheck serum B12 in 3 months. Consider checking Methylmalonic Acid (MMA) if symptomatic.", LIGHT_YELLOW, "CC7700"), gap(), findingTitle("5", "Prediabetes — HbA1c 6.0%", "CC7700"), bodyText("Unchanged from prior analysis. HbA1c 6.0% is in the prediabetes range (5.7%-6.4%). Vitamin D insufficiency is independently associated with insulin resistance and impaired glucose metabolism. Correcting Vitamin D may help improve glycaemic control."), noteBox("Recommended:", "Fasting glucose + 2-hr OGTT | Lifestyle intervention (diet, 150 min/week moderate exercise) | Recheck HbA1c in 3-6 months | Vitamin D correction may benefit glucose metabolism.", LIGHT_YELLOW, "CC7700"), gap(), // NORMAL SUMMARY sectionHeading("Parameters Within Normal Limits"), gap(), new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, insideH: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY }, insideV: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY } }, rows: [ new TableRow({ children: [ makeCell("System", { bold: true, bg: "E8F5E9", color: "007700", size: 18, width: 3000 }), makeCell("Tests Confirmed Normal", { bold: true, bg: "E8F5E9", color: "007700", size: 18, width: 6500 }) ]}), new TableRow({ children: [makeCell("Haematology", {size:18}), makeCell("Hb, RBC, PCV, MCV, MCH, Platelets, WBC differential — all normal. Normochromic normocytic smear.", {size:18})]}), new TableRow({ children: [makeCell("Electrolytes", {size:18}), makeCell("Sodium, Potassium, Chloride, Bicarbonate — all within range.", {size:18})]}), new TableRow({ children: [makeCell("Renal Function", {size:18}), makeCell("Urea 29 mg/dL, Creatinine 1.2 mg/dL (upper normal), Magnesium normal.", {size:18})]}), new TableRow({ children: [makeCell("Liver (Bilirubin)", {size:18}), makeCell("Total Bilirubin 0.7 mg/dL — normal. Uric acid normal.", {size:18})]}), new TableRow({ children: [makeCell("Thyroid (TSH + FT4)", {size:18}), makeCell("TSH 1.644 \u03BCIU/mL (normal). Free T4 1.08 ng/mL (normal). Overt and subclinical hyperthyroidism excluded.", {size:18})]}), new TableRow({ children: [makeCell("Calcium", {size:18}), makeCell("10.2 mg/dL — at upper limit of normal, no clinical hypercalcaemia.", {size:18})]}), ] }), gap(), // MANAGEMENT PLAN sectionHeading("Suggested Management Plan Summary"), gap(), new Table({ width: { size: 9500, type: WidthType.DXA }, borders: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, bottom: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, left: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, right: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY }, insideH: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY }, insideV: { style: BorderStyle.SINGLE, size: 2, color: BORDER_GREY } }, rows: [ new TableRow({ children: [ makeCell("Timeframe", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 1800 }), makeCell("Action", { bold: true, bg: HEADER_BLUE, color: WHITE, size: 18, width: 7700 }) ]}), new TableRow({ children: [makeCell("Immediate", {bg:LIGHT_RED,bold:true,color:"CC0000",size:18}), makeCell("LFT workup: HBsAg, Anti-HCV, AST, GGT, Albumin, PT/INR, Liver USS", {bg:LIGHT_RED,size:18})]}), new TableRow({ children: [makeCell("This week", {bg:ORANGE_BG,bold:true,color:"AA5500",size:18}), makeCell("Start Vitamin D3 50,000 IU weekly x 8 weeks. Assess B12 symptoms; start Methylcobalamin if symptomatic.", {bg:ORANGE_BG,size:18})]}), new TableRow({ children: [makeCell("This month", {bg:LIGHT_YELLOW,bold:true,color:"CC7700",size:18}), makeCell("Fasting glucose + OGTT for prediabetes confirmation. Lifestyle counseling.", {bg:LIGHT_YELLOW,size:18})]}), new TableRow({ children: [makeCell("3 months", {bg:LIGHT_YELLOW,bold:true,color:"CC7700",size:18}), makeCell("Recheck: Vitamin D, B12, Free T3, LFTs, HbA1c. If Free T3 still elevated: Anti-TPO + TRAb, endocrinology referral.", {bg:LIGHT_YELLOW,size:18})]}), new TableRow({ children: [makeCell("Ongoing", {bg:LIGHT_GREEN,bold:true,color:"007700",size:18}), makeCell("Annual metabolic panel. Diet and exercise for prediabetes prevention. Vitamin D maintenance 1000-2000 IU/day.", {bg:LIGHT_GREEN,size:18})]}), ] }), gap(), new Paragraph({ spacing: { before: 300, after: 100 }, border: { top: { style: BorderStyle.SINGLE, size: 4, color: BORDER_GREY } }, children: [ new TextRun({ text: "Disclaimer: ", bold: true, size: 16, color: "888888", font: "Calibri" }), new TextRun({ text: "This summary was generated for Dr. Muhammad Daniyal (MBBS) as a clinical reasoning aid. All findings must be correlated with full history, examination, and professional clinical judgment. This document is not a formal diagnosis or treatment prescription.", size: 16, color: "888888", font: "Calibri", italics: true }) ] }) ] }] }); Packer.toBuffer(doc).then(buffer => { fs.writeFileSync("/home/daytona/workspace/patient-report/Patient_Summary_DrDaniyal_Updated_13Jul2026.docx", buffer); console.log("SUCCESS"); }).catch(e => console.error("ERROR:", e.message)); JSEOF echo "Script written"
cd /home/daytona/workspace/patient-report && node generate_report_v2.js
~/patient-report/generate_report_v2.js
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/patient-report/generate_report_v2.js'
cd /home/daytona/workspace/patient-report && node generate_report_v2.js
python3 -c "import zipfile; z = zipfile.ZipFile('/home/daytona/workspace/patient-report/Patient_Summary_DrDaniyal_Updated_13Jul2026.docx'); print('Valid, files:', len(z.namelist()))" && ls -lh /home/daytona/workspace/patient-report/Patient_Summary_DrDaniyal_Updated_13Jul2026.docx
Patient Summary DrDaniyal Updated 13Jul2026
Word Document · DOCX
| Priority | Finding | Action |
|---|---|---|
| ✅ Resolved | TSH normal - no hyperthyroidism | No thyroid treatment needed |
| 🔴 Still urgent | SGPT 92 + ALP 197 | HBsAg, Anti-HCV, Liver USS |
| 🟠 Treat now | Vitamin D 26.74 (insufficiency) | D3 50,000 IU weekly x 8 wks |
| ⚠️ Monitor | B12 205.70 (borderline) | Supplement if symptomatic |
| ⚠️ Monitor | HbA1c 6.0% (prediabetes) | OGTT + lifestyle changes |
Yesterday, I goes to the general physician here, which is the top general physician and endocrinologist here in Sindh, Dr. Bikaram. He examined me clearly and, uh, he asked me several question about that, "You feel tired when you awake or, uh, there is a sleep disturbance?" I said, "Yes, sir." So he diagnosed my case as well as, uh, a sinusitis for, uh, that purpose also. He gave me the Rhinoclinal 100, uh, for the nasal, uh, drops, I guess, and, uh, I bide myself sunny day injection every week and neutrophil factor for myself, and he also gave me free health montelukast tablet and, uh, Panadol. Uh, these are the things which he gave me. Uh, what about your opinion now? What I should have to do next? And today, I have taken the tea, which is sugar-free, without sugar.
Rhinoclinal 100 nasal drops mometasone fluticasone Pakistan composition
| Medication | Generic Name | Purpose |
|---|---|---|
| Rhinoclinal 100 | Beclomethasone Dipropionate 100 mcg nasal spray | Intranasal corticosteroid - reduces nasal inflammation, sinusitis, allergic rhinitis |
| Sunny Day injection weekly | Vitamin D3 (Cholecalciferol) IM/SC injection | Vitamin D supplementation - directly addresses your deficiency (26.74 ng/mL) |
| Neutrophil factor | Most likely Methylcobalamin (Vitamin B12 injection) | B12 supplementation - addresses your borderline B12 (205.70 pg/mL) |
| Montelukast tablet | Montelukast 10 mg (Singulair / Freehale) | Leukotriene receptor antagonist - for sinusitis, allergic rhinitis, and nasal congestion |
| Panadol | Paracetamol 500/1000 mg | Symptomatic relief - pain, sinus headache |
⚕️ This is a peer-level clinical discussion, not a replacement for Dr. Bikaram's in-person assessment. Continue following his instructions.
Doctor Vikram tell to me that, uh, TSH is normal and T3 is raised. It means there is no any huge problem. There is no problem. Uh, and further about HDPT and ALT, I ask about him that what could be the reason for that. He said, "It's a fatty liver. You must have to avoid the food, food, uh, junky food like that."
| Avoid Completely | Reduce Significantly | Eat More Of |
|---|---|---|
| Deep-fried foods (samosas, pakoras, fries) | White rice, white bread, naan | Green vegetables (spinach, broccoli, bitter gourd) |
| Soft drinks, juices, sugary drinks | Red meat (beef, mutton) | Salad, cucumbers, tomatoes |
| Bakery items (biscuits, cakes, pastries) | Full-fat dairy | Fruit (whole, not juice) |
| Desi ghee, margarine, hydrogenated oils | Potatoes, polished grains | Fish (tuna, salmon) - 2x per week |
| Fast food (burgers, pizza) | Biryani/pilao (high-fat rice) | Lentils, chickpeas, beans |
Fatty Liver (NAFLD)
↓ causes
Raised ALT + ALP
↓ causes (via liver T4→T3 conversion dysregulation)
Mildly raised Free T3 (with normal TSH - so NOT true hyperthyroidism)
Vitamin D Insufficiency
↓ worsens
Liver inflammation (low Vit D is associated with worse NAFLD)
↓ also worsens
Insulin resistance → HbA1c 6.0% (Prediabetes)
↓ also worsens
Fatigue + poor sleep (alongside sinusitis)
⚕️ Continue following Dr. Bikaram's prescription. Discuss adding a liver ultrasound at your next visit with him.
Should i take neutrifactor which contain bit C , B12 and iron while i have no iron defies anemia or should I discontinue???
| Component | Status | Action |
|---|---|---|
| Vitamin B12 | ✅ Needed (borderline B12) | Continue |
| Vitamin C | ✅ Safe and helpful | Continue |
| Iron | ⚠️ Not needed, mild concern with fatty liver | Discuss with Dr. Bikaram |
Mm. Should I continue this, uh, iron for just one min- month of, uh, this NutriFactor? Because every day I should-- I will be taking a one capsule of it. Should I go with, uh, just one month, and after that I should move to the vitamin B12? And how much month I should have to take vitamin B12, and, uh, how much I should have to go with vitamin D? And what about these nasal drops I should have to do? How many times a day? And, uh, tell me about that. And, uh, should I go with the Montelukast tablet the doctor gave me? For how many days?
| Phase | What | Duration |
|---|---|---|
| Now | Continue Neutrifactor 1 capsule daily (morning with food) | 1 month |
| After 1 month | Switch to Methylcobalamin (B12 only) 1500 mcg daily | 3 months |
| After 3 months | Recheck B12 level. If normalized (>400 pg/mL), reduce to 1000 mcg/day or every other day as maintenance | Ongoing as needed |
| Phase | Dose | Duration |
|---|---|---|
| Loading phase | Sunny Day injection once weekly | 8 weeks (2 months) |
| Maintenance phase | Switch to oral Vitamin D3 1000-2000 IU/day tablet | Long-term, possibly indefinitely |
| Recheck | Test Vitamin D (25-OH) level | At 3 months |
2 sprays into EACH nostril, TWICE daily (morning + evening) Total = 4 sprays × 100 mcg = 400 mcg/day
| Time | What to Take |
|---|---|
| Morning (with breakfast) | Neutrifactor 1 capsule |
| Morning | Rhinoclinal - 2 sprays each nostril |
| Evening | Rhinoclinal - 2 sprays each nostril |
| Night (before bed) | Montelukast 10 mg tablet |
| Weekly | Sunny Day injection (on a fixed day e.g. every Sunday) |
| As needed | Panadol for pain only |
| Medication | Change |
|---|---|
| Neutrifactor | Stop - switch to Methylcobalamin 1500 mcg/day alone |
| Sunny Day injection | Continue weekly until week 8, then switch to oral Vit D3 tablet daily |
| Rhinoclinal | Review with Dr. Bikaram - continue if symptoms persist |
| Montelukast | Review with Dr. Bikaram - likely stop at 4-6 weeks |
I am taking oral Suny D. Which is a capsule of 200 lakh international unit. Okay.
200,000 ÷ 7 = ~28,570 IU/day average
| Week | Action |
|---|---|
| Week 1 to 8 | One 200,000 IU capsule every week (same day each week, e.g. every Sunday) |
| After week 8 | Stop the 200,000 IU capsule |
| From week 9 onwards | Switch to oral Vitamin D3 1000-2000 IU/day (maintenance tablet - available as Calcirol D3, D-Sol, or any generic Vit D3 sachet/tablet) |
| At 3 months | Recheck your Vitamin D level (25-OH Vitamin D blood test) |
Now make a complete summary which I should have to follow me from today. All the summary of my case, all A to Z, and make it short and complete for me that I should understand and I should follow that summary for two to three months.
cat > /home/daytona/workspace/patient-report/generate_plan.js << 'JSEOF' const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, AlignmentType, BorderStyle, WidthType, ShadingType, VerticalAlign, Header, Footer } = require('docx'); const fs = require('fs'); const BLUE = "1A3A5C"; const LBLUE = "EBF3FB"; const RED = "CC0000"; const LRED = "FFE5E5"; const ORANGE = "AA5500"; const LORANGE = "FFF0E0"; const GREEN = "007700"; const LGREEN = "E8F5E9"; const YELLOW = "CC7700"; const LYELLOW = "FFFBE5"; const GREY = "CCCCCC"; const WHITE = "FFFFFF"; const DGREY = "555555"; const F = "Calibri"; function cell(text, {bold=false,color="000000",bg=WHITE,w=null,align=AlignmentType.LEFT,size=18,italic=false,vAlign=VerticalAlign.CENTER}={}) { const o = { verticalAlign: vAlign, shading:{fill:bg,type:ShadingType.CLEAR}, margins:{top:90,bottom:90,left:130,right:130}, children:[new Paragraph({alignment:align,children:[new TextRun({text,bold,color,size,italics:italic,font:F})]})] }; if(w) o.width={size:w,type:WidthType.DXA}; return new TableCell(o); } function hdr(cols,bg=BLUE) { return new TableRow({tableHeader:true,children:cols.map(([t,w])=>cell(t,{bold:true,color:WHITE,bg,size:18,align:AlignmentType.CENTER,w}))}); } function row(...cells) { return new TableRow({children:cells}); } function tbl(rows,{width=9500}={}) { return new Table({ width:{size:width,type:WidthType.DXA}, borders:{ top:{style:BorderStyle.SINGLE,size:4,color:GREY}, bottom:{style:BorderStyle.SINGLE,size:4,color:GREY}, left:{style:BorderStyle.SINGLE,size:4,color:GREY}, right:{style:BorderStyle.SINGLE,size:4,color:GREY}, insideH:{style:BorderStyle.SINGLE,size:2,color:GREY}, insideV:{style:BorderStyle.SINGLE,size:2,color:GREY} }, rows }); } function sec(text) { return new Paragraph({ spacing:{before:280,after:80}, border:{bottom:{style:BorderStyle.SINGLE,size:6,color:BLUE}}, children:[new TextRun({text,bold:true,size:24,color:BLUE,font:F,allCaps:true})] }); } function para(text,{bold=false,color="000000",size=18,before=40,after=60}={}) { return new Paragraph({spacing:{before,after},children:[new TextRun({text,bold,color,size,font:F})]}); } function bul(text,{bold=false,color="000000"}={}) { return new Paragraph({bullet:{level:0},spacing:{before:30,after:30}, children:[new TextRun({text,bold,color,size:18,font:F})]}); } function box(label,text,bg=LYELLOW,lc=YELLOW) { return new Table({ width:{size:9500,type:WidthType.DXA}, borders:{ top:{style:BorderStyle.SINGLE,size:6,color:lc}, bottom:{style:BorderStyle.SINGLE,size:6,color:lc}, left:{style:BorderStyle.SINGLE,size:14,color:lc}, right:{style:BorderStyle.SINGLE,size:4,color:lc} }, rows:[new TableRow({children:[new TableCell({ shading:{fill:bg,type:ShadingType.CLEAR}, margins:{top:100,bottom:100,left:160,right:160}, children:[new Paragraph({children:[ new TextRun({text:label+" ",bold:true,size:18,color:lc,font:F}), new TextRun({text,size:18,font:F}) ]})] })]})] }); } function gap(n=1){return Array.from({length:n},()=>new Paragraph({text:"",spacing:{before:0,after:50}}));} // ── document ────────────────────────────────────────────────────────────── const doc = new Document({ styles:{default:{document:{run:{font:F,size:20}}}}, sections:[{ properties:{page:{margin:{top:850,bottom:850,left:950,right:950}}}, headers:{default:new Header({children:[ new Table({ width:{size:9500,type:WidthType.DXA}, borders:{top:{style:BorderStyle.NONE},bottom:{style:BorderStyle.SINGLE,size:6,color:BLUE},left:{style:BorderStyle.NONE},right:{style:BorderStyle.NONE},insideH:{style:BorderStyle.NONE},insideV:{style:BorderStyle.NONE}}, rows:[new TableRow({children:[ new TableCell({borders:{top:{style:BorderStyle.NONE},bottom:{style:BorderStyle.NONE},left:{style:BorderStyle.NONE},right:{style:BorderStyle.NONE}},width:{size:6500,type:WidthType.DXA},children:[ new Paragraph({children:[new TextRun({text:"MY HEALTH ACTION PLAN — July 2026",bold:true,size:22,color:BLUE,font:F})]}), new Paragraph({children:[new TextRun({text:"Dr. Muhammad Daniyal, MBBS | Male, 26 Years",size:17,color:DGREY,font:F})]}) ]}), new TableCell({borders:{top:{style:BorderStyle.NONE},bottom:{style:BorderStyle.NONE},left:{style:BorderStyle.NONE},right:{style:BorderStyle.NONE}},width:{size:3000,type:WidthType.DXA},children:[ new Paragraph({alignment:AlignmentType.RIGHT,children:[new TextRun({text:"Duration: Jul – Oct 2026",size:17,color:DGREY,font:F})]}), new Paragraph({alignment:AlignmentType.RIGHT,children:[new TextRun({text:"IMC Hospital, T.M. Khan",size:17,color:DGREY,font:F})]}) ]}) ]})] }) ]})}, footers:{default:new Footer({children:[new Paragraph({alignment:AlignmentType.CENTER,border:{top:{style:BorderStyle.SINGLE,size:4,color:GREY}},children:[new TextRun({text:"CONFIDENTIAL — Personal Health Record of Dr. Muhammad Daniyal, MBBS",size:15,color:"999999",font:F})]})]})}, children:[ ...gap(1), // ── DIAGNOSIS BANNER ─────────────────────────────────────────────── tbl([ hdr([["MY DIAGNOSES (What is Wrong With Me)",9500]],BLUE), row( cell("1",{bold:true,bg:LRED,color:RED,size:20,align:AlignmentType.CENTER,w:500}), cell("Fatty Liver (NAFLD)",{bold:true,bg:LRED,color:RED,size:19,w:3000}), cell("Raised SGPT 92 U/L + ALP 197 U/L. Cause: poor diet. REVERSIBLE with lifestyle.",{bg:LRED,size:17,w:6000}) ), row( cell("2",{bold:true,bg:LORANGE,color:ORANGE,size:20,align:AlignmentType.CENTER,w:500}), cell("Vitamin D Insufficiency",{bold:true,bg:LORANGE,color:ORANGE,size:19,w:3000}), cell("Level 26.74 ng/mL (should be >40). Causing fatigue, poor sleep, weak immunity.",{bg:LORANGE,size:17,w:6000}) ), row( cell("3",{bold:true,bg:LORANGE,color:ORANGE,size:20,align:AlignmentType.CENTER,w:500}), cell("Borderline Vitamin B12",{bold:true,bg:LORANGE,color:ORANGE,size:19,w:3000}), cell("Level 205.70 pg/mL (just at floor of normal 200-900). Contributing to fatigue.",{bg:LORANGE,size:17,w:6000}) ), row( cell("4",{bold:true,bg:LYELLOW,color:YELLOW,size:20,align:AlignmentType.CENTER,w:500}), cell("Sinusitis / Allergic Rhinitis",{bold:true,bg:LYELLOW,color:YELLOW,size:19,w:3000}), cell("Causing blocked nose, disturbed sleep, morning tiredness. Diagnosed by Dr. Bikaram.",{bg:LYELLOW,size:17,w:6000}) ), row( cell("5",{bold:true,bg:LYELLOW,color:YELLOW,size:20,align:AlignmentType.CENTER,w:500}), cell("Prediabetes (HbA1c 6.0%)",{bold:true,bg:LYELLOW,color:YELLOW,size:19,w:3000}), cell("Not diabetes yet (threshold is 6.5%). Fully reversible with diet + exercise.",{bg:LYELLOW,size:17,w:6000}) ), row( cell("6",{bold:true,bg:LGREEN,color:GREEN,size:20,align:AlignmentType.CENTER,w:500}), cell("Thyroid — NOT a problem",{bold:true,bg:LGREEN,color:GREEN,size:19,w:3000}), cell("TSH 1.644 (normal). Free T3 slightly high but this is SECONDARY to fatty liver. No thyroid treatment needed.",{bg:LGREEN,size:17,w:6000}) ), row( cell("7",{bold:true,bg:LGREEN,color:GREEN,size:20,align:AlignmentType.CENTER,w:500}), cell("Blood, Kidneys, Electrolytes — All Normal",{bold:true,bg:LGREEN,color:GREEN,size:19,w:3000}), cell("Haemoglobin, RBC, sodium, potassium, urea, creatinine — all perfectly normal.",{bg:LGREEN,size:17,w:6000}) ) ]), ...gap(1), // ── DAILY SCHEDULE ───────────────────────────────────────────────── sec("SECTION 1 — My Daily Medication Schedule"), ...gap(1), tbl([ hdr([["Time",1400],["Medicine",3000],["Dose & How",3100],["Until When",2000]]), row( cell("MORNING\nwith breakfast",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1400}), cell("Neutrifactor capsule\n(Vit C + B12 + Iron)",{bg:LBLUE,size:17,w:3000}), cell("1 capsule with food (never empty stomach)",{bg:LBLUE,size:17,w:3100}), cell("1 month only\nthen STOP",{bold:true,bg:LRED,color:RED,size:16,align:AlignmentType.CENTER,w:2000}) ), row( cell("MORNING\n+ EVENING",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1400}), cell("Rhinoclinal 100\n(Beclomethasone nasal spray)",{bg:LBLUE,size:17,w:3000}), cell("2 sprays in EACH nostril = 4 sprays total\nTechnique: tilt head forward, aim outward, breathe in gently",{bg:LBLUE,size:17,w:3100}), cell("4-8 weeks\nReview with Dr. Bikaram",{bg:LYELLOW,size:16,align:AlignmentType.CENTER,w:2000}) ), row( cell("NIGHT\nbefore sleep",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1400}), cell("Montelukast 10 mg tablet\n(Freehale)",{bg:LBLUE,size:17,w:3000}), cell("1 tablet at night — MUST be taken at night (leukotrienes peak at night)",{bg:LBLUE,size:17,w:3100}), cell("4-6 weeks\nReview with Dr. Bikaram",{bg:LYELLOW,size:16,align:AlignmentType.CENTER,w:2000}) ), row( cell("AS NEEDED",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1400}), cell("Panadol 500/1000 mg\n(Paracetamol)",{bg:LBLUE,size:17,w:3000}), cell("Only for headache or sinus pain. Max 2 tabs at a time. Max 3 days in a row.",{bg:LBLUE,size:17,w:3100}), cell("On demand\nDo not overuse",{bg:LGREEN,color:GREEN,size:16,align:AlignmentType.CENTER,w:2000}) ), row( cell("WEEKLY\n(e.g. every Sunday)",{bold:true,bg:LGREEN,color:GREEN,size:17,align:AlignmentType.CENTER,w:1400}), cell("Sunny D 200,000 IU capsule\n(Cholecalciferol / Vit D3)",{bg:LGREEN,size:17,w:3000}), cell("1 capsule with your biggest meal (lunch or dinner — needs fat for absorption). Same day every week.",{bg:LGREEN,size:17,w:3100}), cell("8 weeks\nthen switch to\ndaily low dose",{bold:true,bg:LORANGE,color:ORANGE,size:16,align:AlignmentType.CENTER,w:2000}) ) ]), ...gap(1), box("⚠️ Important:","Do NOT take Sunny D capsule on an empty stomach. Always with food containing fat (normal Pakistani meal is fine). Vitamin D is fat-soluble — without fat it is poorly absorbed.",LORANGE,ORANGE), ...gap(1), // ── MONTH BY MONTH ───────────────────────────────────────────────── sec("SECTION 2 — Month-by-Month Plan"), ...gap(1), tbl([ hdr([["Month",1400],["Medicines",4000],["Lifestyle Target",4100]]), row( cell("MONTH 1\nJul 15 – Aug 15",{bold:true,bg:LRED,color:RED,size:17,align:AlignmentType.CENTER,w:1400}), cell("✔ Neutrifactor 1 cap/day (morning)\n✔ Rhinoclinal 100 spray — 2x daily\n✔ Montelukast 10 mg — every night\n✔ Sunny D 200,000 IU — every Sunday\n✔ Panadol as needed only",{bg:LRED,size:16,w:4000}), cell("✔ Stop all junk food, fried food, sugary drinks\n✔ Start 30-min walk daily\n✔ Sugar-free tea/coffee (already doing!)\n✔ No extra calcium supplement during this month",{bg:LRED,size:16,w:4100}) ), row( cell("MONTH 2\nAug 15 – Sep 15",{bold:true,bg:LORANGE,color:ORANGE,size:17,align:AlignmentType.CENTER,w:1400}), cell("✖ STOP Neutrifactor\n✔ START Methylcobalamin 1500 mcg/day (B12 only capsule)\n✔ Rhinoclinal — continue if still needed\n✔ Montelukast — stop if nose is clear (discuss with Dr. Bikaram)\n✔ Sunny D 200,000 IU — last 4 weeks of 8-week course",{bg:LORANGE,size:16,w:4000}), cell("✔ Continue daily 30-min walk — non-negotiable\n✔ Mediterranean diet pattern: more vegetables, fish, lentils, less white rice/bread\n✔ No sugar in anything\n✔ Try to reduce body weight slightly (even 3-4 kg helps fatty liver significantly)",{bg:LORANGE,size:16,w:4100}) ), row( cell("MONTH 3\nSep 15 – Oct 15",{bold:true,bg:LGREEN,color:GREEN,size:17,align:AlignmentType.CENTER,w:1400}), cell("✔ Methylcobalamin 1500 mcg/day (continue)\n✖ STOP Sunny D 200,000 IU weekly\n✔ START Vitamin D3 1000-2000 IU/day oral tablet (maintenance — Calcirol D3 or equivalent)\n✔ Rhinoclinal and Montelukast — only if symptoms persist",{bg:LGREEN,size:16,w:4000}), cell("✔ All lifestyle changes firmly established by now\n✔ Book follow-up with Dr. Bikaram\n✔ Get all blood tests done (list below)\n✔ Assess improvement: energy levels, sleep quality, nasal symptoms",{bg:LGREEN,size:16,w:4100}) ) ]), ...gap(1), // ── 3-MONTH BLOOD TESTS ──────────────────────────────────────────── sec("SECTION 3 — Blood Tests to Repeat at 3 Months (Mid-October)"), ...gap(1), tbl([ hdr([["Test",3500],["Why",6000]]), row(cell("Vitamin D (25-OH)",{bold:true,w:3500}), cell("Check if level has risen above 40 ng/mL (target). Adjust dose accordingly.",{w:6000})), row(cell("Vitamin B12",{bold:true,w:3500}), cell("Should rise well above 300-400 pg/mL. If normalized, can reduce B12 dose.",{w:6000})), row(cell("SGPT (ALT) + ALP",{bold:true,w:3500,bg:LRED}), cell("Most important test. Should drop significantly if fatty liver improving with diet+exercise. Target: ALT <43 U/L.",{w:6000,bg:LRED})), row(cell("HbA1c",{bold:true,w:3500}), cell("Should drop below 5.9% with diet and exercise. Confirms prediabetes reversal.",{w:6000})), row(cell("Free T3",{bold:true,w:3500}), cell("Expected to normalize as fatty liver improves. Should come closer to normal range.",{w:6000})), row(cell("TSH",{bold:true,w:3500}), cell("Reconfirm remains normal.",{w:6000})), row(cell("CBC (Blood count)",{bold:true,w:3500}), cell("Routine check. Confirm Hb, WBC remain normal.",{w:6000})), row(cell("HBsAg + Anti-HCV (ONE TIME)",{bold:true,color:RED,w:3500,bg:LRED}), cell("IMPORTANT — Do this ONCE to formally rule out Hepatitis B and C. If negative, confirmed as pure fatty liver. You can do this test anytime this month.",{w:6000,bg:LRED})) ]), ...gap(1), box("📋 Tell Dr. Bikaram at follow-up:","My ALT/ALP were elevated in July 2026. I have not yet done HBsAg and Anti-HCV. Please advise. I have been on diet, exercise, and Vitamin D for 3 months.",LYELLOW,YELLOW), ...gap(1), // ── DIET RULES ───────────────────────────────────────────────────── sec("SECTION 4 — Diet Rules (Fatty Liver + Prediabetes)"), ...gap(1), tbl([ hdr([["❌ NEVER EAT / DRINK",3000],["⚠️ REDUCE SIGNIFICANTLY",3200],["✅ EAT MORE OF",3300]]), row( cell("Deep fried food\n(samosa, pakora, fries, puri)\n\nSugary drinks\n(cola, juice, energy drinks)\n\nBakery items\n(biscuits, cakes, pastries)\n\nFast food\n(burger, pizza, shawarma)\n\nDesi ghee/margarine in excess",{bg:LRED,size:16,w:3000}), cell("White rice (1 small portion OK)\nNaan / white bread\nRed meat (beef, mutton)\nFull-fat milk/cream\nHigh-sugar fruit (mango, grapes)\nBiryani/pilao\nExtra salt",{bg:LYELLOW,size:16,w:3200}), cell("Green vegetables\n(spinach, bitter gourd, salad)\n\nLentils & chickpeas\n(daal, chana)\n\nFish (tuna, sardines)\n\nWhole grains\n(brown rice, oats)\n\nEggs (boiled/poached)\n\nYogurt (plain, low fat)\n\nWater — 8-10 glasses/day",{bg:LGREEN,size:16,w:3300}) ) ]), ...gap(1), // ── EXERCISE ────────────────────────────────────────────────────── sec("SECTION 5 — Exercise (Non-Negotiable for Fatty Liver)"), ...gap(1), tbl([ hdr([["Week",1600],["Target",7900]]), row(cell("Week 1-2",{bg:LYELLOW,bold:true,color:YELLOW,size:17,w:1600}), cell("20 minutes brisk walk every day. Start gentle. Morning or evening — whatever you will actually do.",{bg:LYELLOW,size:17,w:7900})), row(cell("Week 3-4",{bg:LORANGE,bold:true,color:ORANGE,size:17,w:1600}), cell("30 minutes brisk walk daily. Pick up pace. Should feel slightly breathless but able to talk.",{bg:LORANGE,size:17,w:7900})), row(cell("Month 2-3",{bg:LGREEN,bold:true,color:GREEN,size:17,w:1600}), cell("30-45 minutes daily. Add 2x per week light resistance: 3 sets of squats, push-ups, or any gym exercise. This accelerates liver fat loss.",{bg:LGREEN,size:17,w:7900})) ]), ...gap(1), box("Why exercise matters for fatty liver:","Exercise reduces liver fat INDEPENDENTLY of weight loss. Even without losing weight, consistent aerobic activity lowers ALT and ALP. Think of it as your free liver medicine.",LGREEN,GREEN), ...gap(1), // ── QUICK REFERENCE ──────────────────────────────────────────────── sec("SECTION 6 — Quick Reference Card (Pin This Somewhere Visible)"), ...gap(1), tbl([ hdr([["Every Day",3160],["Every Week",3160],["Every Month",3180]]), row( cell("☀ Morning: Neutrifactor + Rhinoclinal spray\n🌙 Night: Montelukast tablet\n🚶 30-min walk\n🚫 No sugar, no fried food\n💧 8 glasses of water",{bg:LBLUE,size:16,w:3160}), cell("💊 Sunday: Sunny D 200,000 IU capsule with food\n📅 Track your symptoms (sleep quality, energy, nose)\n⚖ Weigh yourself once a week",{bg:LYELLOW,size:16,w:3160}), cell("Month 1 end: Stop Neutrifactor → start Methylcobalamin B12\nWeek 8 end: Stop Sunny D weekly → start daily Vit D3 tablet\nMonth 3: Get all blood tests. Visit Dr. Bikaram.",{bg:LGREEN,size:16,w:3180}) ) ]), ...gap(1), // ── EXPECTED OUTCOMES ────────────────────────────────────────────── sec("SECTION 7 — What to Expect (Realistic Timeline)"), ...gap(1), tbl([ hdr([["Timeframe",2000],["What Should Improve",7500]]), row(cell("2-4 weeks",{bold:true,bg:LBLUE,color:BLUE,size:17,w:2000}), cell("Nasal blockage and sleep quality should improve (Rhinoclinal + Montelukast kicking in). Less morning fatigue.",{bg:LBLUE,size:17,w:7500})), row(cell("4-6 weeks",{bold:true,bg:LYELLOW,color:YELLOW,size:17,w:2000}), cell("Vitamin D rising — energy levels improving. Less body aches. B12 also rebuilding. Better mood and concentration.",{bg:LYELLOW,size:17,w:7500})), row(cell("8-12 weeks",{bold:true,bg:LORANGE,color:ORANGE,size:17,w:2000}), cell("Liver enzymes (ALT/ALP) should start dropping if diet and exercise are consistent. HbA1c trending down.",{bg:LORANGE,size:17,w:7500})), row(cell("3 months",{bold:true,bg:LGREEN,color:GREEN,size:17,w:2000}), cell("Blood tests should show significant improvement across all parameters. Free T3 likely to normalize. This is your goal.",{bg:LGREEN,size:17,w:7500})) ]), ...gap(1), // ── DISCLAIMER ───────────────────────────────────────────────────── new Paragraph({ spacing:{before:280,after:80}, border:{top:{style:BorderStyle.SINGLE,size:4,color:GREY}}, children:[ new TextRun({text:"Clinical Note: ",bold:true,size:16,color:DGREY,font:F}), new TextRun({text:"This plan was prepared for Dr. Muhammad Daniyal (MBBS) based on his lab results dated 13-Jul-2026, and clinical assessment by Dr. Bikaram (GP & Endocrinologist). All medications follow Dr. Bikaram's prescription. Lifestyle and follow-up recommendations are evidence-based additions. Always follow your treating physician's instructions if they differ from this plan. Report any new or worsening symptoms to Dr. Bikaram promptly.",size:16,color:DGREY,font:F,italics:true}) ] }) ] }] }); Packer.toBuffer(doc).then(buf => { fs.writeFileSync("/home/daytona/workspace/patient-report/MyHealthPlan_DrDaniyal_Jul2026.docx", buf); console.log("SUCCESS"); }).catch(e => console.error("ERROR:", e.message)); JSEOF echo "Written"
ls /home/daytona/workspace/patient-report/
ls /tmp/workspace/ 2>/dev/null || echo "no tmp workspace" && ls /home/daytona/ 2>/dev/null
mkdir -p /tmp/workspace/patient-report && echo "dir created"
~/patient-report/generate_plan.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
AlignmentType, BorderStyle, WidthType, ShadingType, VerticalAlign,
Header, Footer
} = require('docx');
const fs = require('fs');
const BLUE="1A3A5C",LBLUE="EBF3FB",RED="CC0000",LRED="FFE5E5",ORANGE="AA5500",LORANGE="FFF0E0",
GREEN="007700",LGREEN="E8F5E9",YELLOW="CC7700",LYELLOW="FFFBE5",GREY="CCCCCC",
WHITE="FFFFFF",DGREY="555555",F="Calibri";
function cell(text,{bold=false,color="000000",bg=WHITE,w=null,align=AlignmentType.LEFT,size=18,italic=false,vAlign=VerticalAlign.CENTER}={}) {
const o={verticalAlign:vAlign,shading:{fill:bg,type:ShadingType.CLEAR},margins:{top:90,bottom:90,left:130,right:130},
children:[new Paragraph({alignment:align,children:[new TextRun({text,bold,color,size,italics:italic,font:F})]})]};
if(w) o.width={size:w,type:WidthType.DXA};
return new TableCell(o);
}
function hdr(cols,bg=BLUE){return new TableRow({tableHeader:true,children:cols.map(([t,w])=>cell(t,{bold:true,color:WHITE,bg,size:18,align:AlignmentType.CENTER,w}))});}
function row(...cells){return new TableRow({children:cells});}
function tbl(rows){return new Table({width:{size:9500,type:WidthType.DXA},borders:{top:{style:BorderStyle.SINGLE,size:4,color:GREY},bottom:{style:BorderStyle.SINGLE,size:4,color:GREY},left:{style:BorderStyle.SINGLE,size:4,color:GREY},right:{style:BorderStyle.SINGLE,size:4,color:GREY},insideH:{style:BorderStyle.SINGLE,size:2,color:GREY},insideV:{style:BorderStyle.SINGLE,size:2,color:GREY}},rows});}
function sec(text){return new Paragraph({spacing:{before:280,after:80},border:{bottom:{style:BorderStyle.SINGLE,size:6,color:BLUE}},children:[new TextRun({text,bold:true,size:24,color:BLUE,font:F,allCaps:true})]});}
function para(text,{bold=false,color="000000",size=18,before=40,after=60}={}){return new Paragraph({spacing:{before,after},children:[new TextRun({text,bold,color,size,font:F})]});}
function box(label,text,bg=LYELLOW,lc=YELLOW){
return new Table({width:{size:9500,type:WidthType.DXA},borders:{top:{style:BorderStyle.SINGLE,size:6,color:lc},bottom:{style:BorderStyle.SINGLE,size:6,color:lc},left:{style:BorderStyle.SINGLE,size:14,color:lc},right:{style:BorderStyle.SINGLE,size:4,color:lc}},
rows:[new TableRow({children:[new TableCell({shading:{fill:bg,type:ShadingType.CLEAR},margins:{top:100,bottom:100,left:160,right:160},
children:[new Paragraph({children:[new TextRun({text:label+" ",bold:true,size:18,color:lc,font:F}),new TextRun({text,size:18,font:F})]})]})]})]}); }
function gap(){return new Paragraph({text:"",spacing:{before:0,after:55}});}
const doc=new Document({
styles:{default:{document:{run:{font:F,size:20}}}},
sections:[{
properties:{page:{margin:{top:850,bottom:850,left:950,right:950}}},
headers:{default:new Header({children:[new Table({
width:{size:9500,type:WidthType.DXA},
borders:{top:{style:BorderStyle.NONE},bottom:{style:BorderStyle.SINGLE,size:6,color:BLUE},left:{style:BorderStyle.NONE},right:{style:BorderStyle.NONE},insideH:{style:BorderStyle.NONE},insideV:{style:BorderStyle.NONE}},
rows:[new TableRow({children:[
new TableCell({borders:{top:{style:BorderStyle.NONE},bottom:{style:BorderStyle.NONE},left:{style:BorderStyle.NONE},right:{style:BorderStyle.NONE}},width:{size:6500,type:WidthType.DXA},children:[
new Paragraph({children:[new TextRun({text:"MY HEALTH ACTION PLAN | July – October 2026",bold:true,size:22,color:BLUE,font:F})]}),
new Paragraph({children:[new TextRun({text:"Dr. Muhammad Daniyal, MBBS | Male, 26 Years | IMC Hospital, T.M. Khan",size:17,color:DGREY,font:F})]})
]}),
new TableCell({borders:{top:{style:BorderStyle.NONE},bottom:{style:BorderStyle.NONE},left:{style:BorderStyle.NONE},right:{style:BorderStyle.NONE}},width:{size:3000,type:WidthType.DXA},children:[
new Paragraph({alignment:AlignmentType.RIGHT,children:[new TextRun({text:"Lab No: 387999 / 388003",size:17,color:DGREY,font:F})]}),
new Paragraph({alignment:AlignmentType.RIGHT,children:[new TextRun({text:"Treating Physician: Dr. Bikaram",size:17,color:DGREY,font:F})]})
]})
]})]
})]})}},
footers:{default:new Footer({children:[new Paragraph({alignment:AlignmentType.CENTER,border:{top:{style:BorderStyle.SINGLE,size:4,color:GREY}},children:[new TextRun({text:"CONFIDENTIAL — Personal Health Record of Dr. Muhammad Daniyal, MBBS",size:15,color:"999999",font:F})]})]})},
children:[
gap(),
// ── DIAGNOSES ────────────────────────────────────────────────────────
tbl([
hdr([["MY DIAGNOSES — What Is Wrong and Why",9500]]),
row(cell("1",{bold:true,bg:LRED,color:RED,size:20,align:AlignmentType.CENTER,w:500}),cell("Fatty Liver (NAFLD)",{bold:true,bg:LRED,color:RED,size:18,w:2800}),cell("SGPT 92 U/L + ALP 197 U/L (both raised). Cause: junk food, sedentary life. FULLY REVERSIBLE with diet + exercise.",{bg:LRED,size:17,w:6200})),
row(cell("2",{bold:true,bg:LORANGE,color:ORANGE,size:20,align:AlignmentType.CENTER,w:500}),cell("Vitamin D Insufficiency",{bold:true,bg:LORANGE,color:ORANGE,size:18,w:2800}),cell("Level 26.74 ng/mL (target >40). Causing fatigue, poor sleep, weakened immunity. Also worsening fatty liver.",{bg:LORANGE,size:17,w:6200})),
row(cell("3",{bold:true,bg:LORANGE,color:ORANGE,size:20,align:AlignmentType.CENTER,w:500}),cell("Borderline Vitamin B12",{bold:true,bg:LORANGE,color:ORANGE,size:18,w:2800}),cell("Level 205.70 pg/mL (just at the floor of normal 200-900). Contributing to fatigue, poor concentration.",{bg:LORANGE,size:17,w:6200})),
row(cell("4",{bold:true,bg:LYELLOW,color:YELLOW,size:20,align:AlignmentType.CENTER,w:500}),cell("Sinusitis / Allergic Rhinitis",{bold:true,bg:LYELLOW,color:YELLOW,size:18,w:2800}),cell("Blocked nose causing disturbed sleep and morning tiredness. Diagnosed by Dr. Bikaram.",{bg:LYELLOW,size:17,w:6200})),
row(cell("5",{bold:true,bg:LYELLOW,color:YELLOW,size:20,align:AlignmentType.CENTER,w:500}),cell("Prediabetes (HbA1c 6.0%)",{bold:true,bg:LYELLOW,color:YELLOW,size:18,w:2800}),cell("Not diabetes yet (threshold is 6.5%). Fully reversible with diet and exercise.",{bg:LYELLOW,size:17,w:6200})),
row(cell("6",{bold:true,bg:LGREEN,color:GREEN,size:20,align:AlignmentType.CENTER,w:500}),cell("Thyroid — NOT a problem",{bold:true,bg:LGREEN,color:GREEN,size:18,w:2800}),cell("TSH 1.644 (normal). Free T3 slightly high but SECONDARY to fatty liver — will normalize on its own. NO thyroid medication needed.",{bg:LGREEN,size:17,w:6200})),
row(cell("7",{bold:true,bg:LGREEN,color:GREEN,size:20,align:AlignmentType.CENTER,w:500}),cell("All Else Normal",{bold:true,bg:LGREEN,color:GREEN,size:18,w:2800}),cell("Blood count, kidneys, electrolytes, heart function markers — all perfectly within range.",{bg:LGREEN,size:17,w:6200}))
]),
gap(),
// ── DAILY MEDICINES ──────────────────────────────────────────────────
sec("Section 1 — My Daily Medicine Schedule"),
gap(),
tbl([
hdr([["When",1500],["Medicine",2800],["Exact Dose & How to Take",3200],["For How Long",2000]]),
row(cell("MORNING\nwith breakfast",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1500}),cell("Neutrifactor\n(Vit C + B12 + Iron)",{bg:LBLUE,size:17,w:2800}),cell("1 capsule with food. Never on empty stomach.",{bg:LBLUE,size:17,w:3200}),cell("1 MONTH only\nthen STOP",{bold:true,bg:LRED,color:RED,size:16,align:AlignmentType.CENTER,w:2000})),
row(cell("MORNING\n+ EVENING",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1500}),cell("Rhinoclinal 100\n(Beclomethasone nasal spray)",{bg:LBLUE,size:17,w:2800}),cell("2 sprays each nostril = 4 sprays total, twice daily.\nTechnique: head slightly forward, aim nozzle outward (away from nose septum), breathe in gently while spraying.",{bg:LBLUE,size:17,w:3200}),cell("4-8 weeks\nReview with\nDr. Bikaram",{bg:LYELLOW,size:16,align:AlignmentType.CENTER,w:2000})),
row(cell("NIGHT\nbefore sleep",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1500}),cell("Montelukast 10 mg\n(Freehale tablet)",{bg:LBLUE,size:17,w:2800}),cell("1 tablet at night ONLY — leukotrienes (inflammation chemicals) peak at night so night timing is essential.",{bg:LBLUE,size:17,w:3200}),cell("4-6 weeks\nReview with\nDr. Bikaram",{bg:LYELLOW,size:16,align:AlignmentType.CENTER,w:2000})),
row(cell("EVERY SUNDAY\nwith lunch/dinner",{bold:true,bg:LGREEN,color:GREEN,size:17,align:AlignmentType.CENTER,w:1500}),cell("Sunny D 200,000 IU capsule\n(Vitamin D3)",{bg:LGREEN,size:17,w:2800}),cell("1 capsule once weekly with your biggest meal (must have fat in it — normal Pakistani food is fine). Fat-soluble: needs fat to absorb.",{bg:LGREEN,size:17,w:3200}),cell("8 WEEKS only\nthen switch to\ndaily low dose",{bold:true,bg:LORANGE,color:ORANGE,size:16,align:AlignmentType.CENTER,w:2000})),
row(cell("AS NEEDED",{bold:true,bg:LBLUE,color:BLUE,size:17,align:AlignmentType.CENTER,w:1500}),cell("Panadol\n(Paracetamol)",{bg:LBLUE,size:17,w:2800}),cell("Only when sinus headache or pain. Max 2 tablets at a time. Do not take more than 3 days in a row — liver processes it.",{bg:LBLUE,size:17,w:3200}),cell("On demand\nOnly when\nneeded",{bg:LBLUE,size:16,align:AlignmentType.CENTER,w:2000}))
]),
gap(),
box("Important — Do NOT take Sunny D on an empty stomach.","It is fat-soluble (like Vitamin A, E, K). Without fat in the meal, only a fraction gets absorbed. Always take with lunch or dinner.",LORANGE,ORANGE),
gap(),
box("Do NOT take extra calcium tablets during the 8-week loading phase.","Your calcium is already at the upper limit (10.2 mg/dL). Vitamin D will raise calcium absorption further. No extra calcium supplements needed right now.",LRED,RED),
gap(),
// ── MONTH BY MONTH ───────────────────────────────────────────────────
sec("Section 2 — Month-by-Month Plan"),
gap(),
tbl([
hdr([["Period",1600],["Medicines",3800],["Lifestyle Actions",4100]]),
row(
cell("MONTH 1\nJul 15 – Aug 15",{bold:true,bg:LRED,color:RED,size:17,align:AlignmentType.CENTER,w:1600}),
cell("+ Neutrifactor 1 cap/morning\n+ Rhinoclinal spray 2x daily\n+ Montelukast 10 mg every night\n+ Sunny D 200,000 IU every Sunday\n+/- Panadol as needed only",{bg:LRED,size:16,w:3800}),
cell("+ Start 20-30 min brisk walk daily\n+ Stop all fried food and sugary drinks completely\n+ Sugar-free tea/coffee (keep it up!)\n+ Drink 8-10 glasses of water daily\n+ No extra calcium or iron supplements",{bg:LRED,size:16,w:4100})
),
row(
cell("MONTH 2\nAug 15 – Sep 15",{bold:true,bg:LORANGE,color:ORANGE,size:17,align:AlignmentType.CENTER,w:1600}),
cell("- STOP Neutrifactor\n+ START Methylcobalamin 1500 mcg/day (B12-only capsule — available at any pharmacy)\n+ Continue Rhinoclinal (if symptoms persist)\n+ Montelukast — likely stop at 4-6 weeks if nose is clear (confirm with Dr. Bikaram)\n+ Continue Sunny D weekly (weeks 5-8)",{bg:LORANGE,size:16,w:3800}),
cell("+ Increase walk to 30-45 min daily\n+ Add 2x per week light exercise (squats, push-ups, cycling)\n+ Mediterranean diet: more vegetables, fish, lentils — less white rice and naan\n+ Target losing 3-5 kg body weight if you have any excess\n+ No sugar in any form",{bg:LORANGE,size:16,w:4100})
),
row(
cell("MONTH 3\nSep 15 – Oct 15",{bold:true,bg:LGREEN,color:GREEN,size:17,align:AlignmentType.CENTER,w:1600}),
cell("+ Continue Methylcobalamin 1500 mcg/day\n- STOP Sunny D 200,000 IU weekly\n+ START Vitamin D3 1000-2000 IU/day oral tablet (maintenance — Calcirol D3, D-Sol, or any generic)\n+ Rhinoclinal/Montelukast: only if symptoms persist\n\nGet ALL blood tests done this month",{bg:LGREEN,size:16,w:3800}),
cell("+ All lifestyle habits should be firmly established\n+ Book follow-up with Dr. Bikaram\n+ Bring all 3-month blood results to appointment\n+ Assess: energy levels, sleep quality, nasal symptoms\n+ If ALT/ALP normalized — celebrate and maintain!",{bg:LGREEN,size:16,w:4100})
)
]),
gap(),
// ── BLOOD TESTS ──────────────────────────────────────────────────────
sec("Section 3 — Blood Tests to Repeat at 3 Months (October 2026)"),
gap(),
tbl([
hdr([["Test to Order",3500],["Target / Why Important",6000]]),
row(cell("SGPT (ALT) + ALP",{bold:true,bg:LRED,color:RED,size:18,w:3500}),cell("Most important. ALT should fall below 43 U/L. ALP should fall below 129 U/L. This confirms fatty liver is improving.",{bg:LRED,size:17,w:6000})),
row(cell("Vitamin D (25-OH)",{bold:true,w:3500}),cell("Target: above 40 ng/mL. If still low (<30), continue weekly Sunny D for 4 more weeks then recheck.",{w:6000})),
row(cell("Vitamin B12",{bold:true,w:3500}),cell("Should now be well above 300-400 pg/mL. If normalized, can reduce to 1000 mcg/day.",{w:6000})),
row(cell("HbA1c",{bold:true,w:3500}),cell("Should fall below 5.9% (prediabetes reversal). Target with 3 months of diet + exercise.",{w:6000})),
row(cell("Free T3 + TSH",{bold:true,w:3500}),cell("Free T3 expected to normalize as fatty liver improves. TSH should remain normal.",{w:6000})),
row(cell("CBC (Blood Count)",{bold:true,w:3500}),cell("Routine confirmation that Hb, WBC, platelets remain normal.",{w:6000})),
row(cell("HBsAg + Anti-HCV (ONE TIME ONLY)",{bold:true,color:RED,bg:LRED,w:3500}),cell("Do this test ONCE (anytime this month or next) to formally rule out Hepatitis B and C. If both negative, fatty liver diagnosis is confirmed.",{bg:LRED,size:17,w:6000}))
]),
gap(),
// ── DIET ─────────────────────────────────────────────────────────────
sec("Section 4 — Diet Rules (Fatty Liver + Prediabetes)"),
gap(),
tbl([
hdr([["NEVER / STOP COMPLETELY",3100],["REDUCE — Eat Less Of",3100],["EAT MORE — Start Today",3300]]),
row(
cell("Deep fried food\n(samosa, pakora, fries, puri)\n\nSugary drinks\n(Pepsi, juice, energy drinks)\n\nBakery / sweets\n(biscuits, cakes, mithai)\n\nFast food\n(burger, pizza, shawarma)\n\nHydrogenated oil / margarine\n\nAll sugar (you already doing — keep it up!)",{bg:LRED,size:16,w:3100}),
cell("White rice (1 small cup max)\n\nNaan / white bread\n(switch to 1 roti or brown bread)\n\nRed meat\n(beef, mutton — max 2x/week)\n\nFull-fat dairy\n\nMango, grapes, banana\n(high sugar fruit)\n\nExtra salt\n\nLate-night eating",{bg:LYELLOW,size:16,w:3100}),
cell("Green vegetables\n(palak, karela, salad daily)\n\nLentils & legumes\n(every day if possible)\n\nFish (tuna, sardines)\n(2-3x per week)\n\nEggs (boiled/poached)\n\nYogurt (plain, low fat)\n\nWhole grain roti\n\nNuts (small handful)\n\nWater 8-10 glasses daily\n\nGreen tea (no sugar)",{bg:LGREEN,size:16,w:3300})
)
]),
gap(),
// ── EXERCISE ─────────────────────────────────────────────────────────
sec("Section 5 — Exercise Plan"),
gap(),
tbl([
hdr([["Period",1800],["Daily Target",7700]]),
row(cell("Week 1-2",{bold:true,bg:LYELLOW,color:YELLOW,size:17,w:1800}),cell("20 minutes brisk walk. Any time of day. Just start — consistency matters more than intensity at first.",{bg:LYELLOW,size:17,w:7700})),
row(cell("Week 3-4",{bold:true,bg:LORANGE,color:ORANGE,size:17,w:1800}),cell("30 minutes brisk walk daily. Pace should make you slightly breathless but still able to speak in sentences.",{bg:LORANGE,size:17,w:7700})),
row(cell("Month 2 onwards",{bold:true,bg:LGREEN,color:GREEN,size:17,w:1800}),cell("30-45 min daily walk PLUS 2x per week resistance exercise (bodyweight squats, push-ups, or gym). Resistance training reduces liver fat independently of cardio.",{bg:LGREEN,size:17,w:7700}))
]),
gap(),
box("Why is exercise the most important thing for fatty liver?","Exercise burns liver fat directly — even without losing weight. Studies show consistent walking reduces ALT and ALP in 8-12 weeks. Think of it as free liver medicine you cannot buy at a pharmacy.",LGREEN,GREEN),
gap(),
// ── QUICK REFERENCE ──────────────────────────────────────────────────
sec("Section 6 — Quick Reference (Print and Stick on Your Wall)"),
gap(),
tbl([
hdr([["Every Day",3160],["Every Week",3160],["At 3 Months",3180]]),
row(
cell("Morning:\n+ Neutrifactor capsule (Month 1)\n+ Rhinoclinal nasal spray\n\nNight:\n+ Montelukast tablet\n\nLifestyle:\n+ 30-min walk\n+ No sugar, no fried food\n+ 8 glasses of water",{bg:LBLUE,size:16,w:3160}),
cell("Every Sunday:\n+ Sunny D 200,000 IU capsule\n (with food — mandatory)\n\nMonitor:\n+ Sleep quality (improving?)\n+ Energy level (improving?)\n+ Nasal symptoms (clearing?)\n+ Body weight once weekly",{bg:LYELLOW,size:16,w:3160}),
cell("Blood tests:\nSGPT, ALP, Vit D, B12,\nHbA1c, TSH, Free T3, CBC,\nHBsAg + Anti-HCV\n\nMedicine change:\n+ Stop Sunny D weekly\n+ Start Vit D3 1000-2000 IU/day\n+ Adjust B12 dose based on result\n\nVisit Dr. Bikaram",{bg:LGREEN,size:16,w:3180})
)
]),
gap(),
// ── EXPECTED RESULTS ─────────────────────────────────────────────────
sec("Section 7 — What You Should Expect Week by Week"),
gap(),
tbl([
hdr([["Timeline",1800],["Expected Improvement",7700]]),
row(cell("Weeks 1-2",{bold:true,bg:LBLUE,color:BLUE,size:17,w:1800}),cell("Nasal blockage starts to clear. Sleep becomes less disturbed. Morning tiredness begins to reduce. (Rhinoclinal + Montelukast working.)",{bg:LBLUE,size:17,w:7700})),
row(cell("Weeks 3-4",{bold:true,bg:LYELLOW,color:YELLOW,size:17,w:1800}),cell("Energy levels noticeably better as Vitamin D rebuilds. Less body aches. Better focus and concentration (B12 rising).",{bg:LYELLOW,size:17,w:7700})),
row(cell("Month 2",{bold:true,bg:LORANGE,color:ORANGE,size:17,w:1800}),cell("Liver enzymes (ALT/ALP) begin to fall if diet and exercise are consistent. Weight may reduce slightly. Feel significantly better overall.",{bg:LORANGE,size:17,w:7700})),
row(cell("Month 3",{bold:true,bg:LGREEN,color:GREEN,size:17,w:1800}),cell("Blood tests should show clear improvement. ALT target below 43. Vitamin D above 40. HbA1c falling. Free T3 likely normalized. This is your goal.",{bg:LGREEN,size:17,w:7700}))
]),
gap(),
// ── DISCLAIMER ───────────────────────────────────────────────────────
new Paragraph({
spacing:{before:280,after:80},
border:{top:{style:BorderStyle.SINGLE,size:4,color:GREY}},
children:[
new TextRun({text:"Clinical Note: ",bold:true,size:16,color:DGREY,font:F}),
new TextRun({text:"This plan is prepared for Dr. Muhammad Daniyal (MBBS) based on lab results dated 13-Jul-2026 and clinical assessment by Dr. Bikaram (GP & Endocrinologist, Sindh). All medications follow Dr. Bikaram's prescription. Lifestyle and monitoring recommendations are evidence-based additions. Always follow Dr. Bikaram's instructions if they differ from this plan. Report any worsening symptoms to him promptly.",size:16,color:DGREY,font:F,italics:true})
]
})
]
}]
});
Packer.toBuffer(doc).then(buf=>{
fs.writeFileSync("/tmp/workspace/patient-report/MyHealthPlan_DrDaniyal_Jul2026.docx",buf);
console.log("SUCCESS");
}).catch(e=>console.error("ERROR:",e.message));
cd /tmp/workspace/patient-report && node generate_plan.js
~/patient-report/generate_plan.js
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/patient-report/generate_plan.js'
cd /tmp/workspace/patient-report && node generate_plan.js 2>&1
python3 -c "from docx import Document; print('python-docx ok')" 2>&1
~/patient-report/build_plan.py
from docx import Document
from docx.shared import Pt, RGBColor, Inches, Cm, Twips
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT, WD_ALIGN_VERTICAL
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy
OUT = "/tmp/workspace/patient-report/MyHealthPlan_DrDaniyal_Jul2026.docx"
# ── colours ──────────────────────────────────────────────────────────────────
C = {
"blue": "1A3A5C", "lblue": "EBF3FB",
"red": "CC0000", "lred": "FFE5E5",
"orange": "AA5500", "lorange":"FFF0E0",
"green": "007700", "lgreen": "E8F5E9",
"yellow": "CC7700", "lyellow":"FFFBE5",
"grey": "CCCCCC", "white": "FFFFFF",
"dgrey": "555555", "black": "000000",
}
def rgb(hex6):
h = hex6.lstrip("#")
return RGBColor(int(h[0:2],16), int(h[2:4],16), int(h[4:6],16))
def set_cell_bg(cell, hex6):
tc = cell._tc
tcPr = 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"), hex6.lstrip("#"))
tcPr.append(shd)
def set_cell_margins(cell, top=80, bottom=80, left=120, right=120):
tc = cell._tc
tcPr = tc.get_or_add_tcPr()
tcMar = OxmlElement("w:tcMar")
for side, val in [("top",top),("bottom",bottom),("left",left),("right",right)]:
el = OxmlElement(f"w:{side}")
el.set(qn("w:w"), str(val))
el.set(qn("w:type"), "dxa")
tcMar.append(el)
tcPr.append(tcMar)
def set_col_width(cell, twips):
tc = cell._tc
tcPr = tc.get_or_add_tcPr()
tcW = OxmlElement("w:tcW")
tcW.set(qn("w:w"), str(twips))
tcW.set(qn("w:type"), "dxa")
tcPr.append(tcW)
def cell_para(cell, text, bold=False, fg="black", size=9, align="left", italic=False):
cell.vertical_alignment = WD_ALIGN_VERTICAL.CENTER
p = cell.paragraphs[0] if cell.paragraphs else cell.add_paragraph()
p.clear()
aligns = {"left":WD_ALIGN_PARAGRAPH.LEFT,"center":WD_ALIGN_PARAGRAPH.CENTER,"right":WD_ALIGN_PARAGRAPH.RIGHT}
p.alignment = aligns.get(align, WD_ALIGN_PARAGRAPH.LEFT)
run = p.add_run(text)
run.bold = bold
run.italic = italic
run.font.size = Pt(size)
run.font.color.rgb = rgb(C.get(fg, fg))
run.font.name = "Calibri"
return p
def add_header_row(table, labels_widths, bg="blue"):
row = table.add_row()
for i,(lbl,w) in enumerate(labels_widths):
c = row.cells[i]
set_cell_bg(c, C[bg])
set_cell_margins(c)
if w: set_col_width(c, w)
cell_para(c, lbl, bold=True, fg="white", size=9, align="center")
return row
def make_table(doc, col_count, style="Table Grid"):
t = doc.add_table(rows=0, cols=col_count)
t.style = style
t.alignment = WD_TABLE_ALIGNMENT.LEFT
return t
def add_section(doc, title):
doc.add_paragraph()
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(8)
p.paragraph_format.space_after = Pt(3)
run = p.add_run(title.upper())
run.bold = True
run.font.size = Pt(12)
run.font.color.rgb = rgb(C["blue"])
run.font.name = "Calibri"
# bottom border
pPr = p._p.get_or_add_pPr()
pBdr = OxmlElement("w:pBdr")
bottom = OxmlElement("w:bottom")
bottom.set(qn("w:val"), "single")
bottom.set(qn("w:sz"), "6")
bottom.set(qn("w:space"), "1")
bottom.set(qn("w:color"), C["blue"])
pBdr.append(bottom)
pPr.append(pBdr)
def add_note(doc, label, text, bg="lyellow", lc="yellow"):
doc.add_paragraph()
t = make_table(doc, 1)
row = t.add_row()
c = row.cells[0]
set_cell_bg(c, C[bg])
set_cell_margins(c, top=100, bottom=100, left=160, right=160)
p = c.paragraphs[0]
p.clear()
r1 = p.add_run(label + " ")
r1.bold = True; r1.font.size = Pt(9); r1.font.color.rgb = rgb(C[lc]); r1.font.name = "Calibri"
r2 = p.add_run(text)
r2.font.size = Pt(9); r2.font.name = "Calibri"
# left thick border
tbl_el = t._tbl
tblPr = tbl_el.find(qn("w:tblPr"))
if tblPr is None:
tblPr = OxmlElement("w:tblPr")
tbl_el.insert(0, tblPr)
tblBorders = OxmlElement("w:tblBorders")
for side in ["top","bottom","left","right"]:
sz = "14" if side == "left" else "6"
el = OxmlElement(f"w:{side}")
el.set(qn("w:val"), "single")
el.set(qn("w:sz"), sz)
el.set(qn("w:space"), "0")
el.set(qn("w:color"), C[lc])
tblBorders.append(el)
tblPr.append(tblBorders)
# ─────────────────────────────────────────────────────────────────────────────
doc = Document()
# page margins
for section in doc.sections:
section.top_margin = Cm(1.8)
section.bottom_margin = Cm(1.8)
section.left_margin = Cm(2.0)
section.right_margin = Cm(2.0)
# ── TITLE ─────────────────────────────────────────────────────────────────────
title_p = doc.add_paragraph()
title_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r = title_p.add_run("MY HEALTH ACTION PLAN — July to October 2026")
r.bold = True; r.font.size = Pt(16); r.font.color.rgb = rgb(C["blue"]); r.font.name = "Calibri"
sub_p = doc.add_paragraph()
sub_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r2 = sub_p.add_run("Dr. Muhammad Daniyal, MBBS | Male, 26 Years | IMC Hospital, Tando Muhammad Khan")
r2.font.size = Pt(10); r2.font.color.rgb = rgb(C["dgrey"]); r2.font.name = "Calibri"
r3_p = doc.add_paragraph()
r3_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r3 = r3_p.add_run("Treating Physician: Dr. Bikaram (GP & Endocrinologist, Sindh) | Lab: 387999 / 388003 | Date: 13-Jul-2026")
r3.font.size = Pt(9); r3.italic = True; r3.font.color.rgb = rgb(C["dgrey"]); r3.font.name = "Calibri"
# ── DIAGNOSES ─────────────────────────────────────────────────────────────────
add_section(doc, "My Diagnoses — What Is Wrong and Why")
diag_data = [
("1","Fatty Liver (NAFLD)","SGPT 92 U/L + ALP 197 U/L (both raised). Cause: poor diet, sedentary life. FULLY REVERSIBLE with diet + exercise.","red","lred"),
("2","Vitamin D Insufficiency","Level 26.74 ng/mL (target >40). Causing fatigue, poor sleep, weak immunity. Also worsening fatty liver and prediabetes.","orange","lorange"),
("3","Borderline Vitamin B12","Level 205.70 pg/mL (just at the floor of normal 200-900). Contributing to fatigue and poor concentration.","orange","lorange"),
("4","Sinusitis / Allergic Rhinitis","Blocked nose causing disturbed sleep and morning tiredness. Diagnosed and treated by Dr. Bikaram.","yellow","lyellow"),
("5","Prediabetes (HbA1c 6.0%)","Not diabetes yet — threshold is 6.5%. Fully reversible with diet and exercise.","yellow","lyellow"),
("6","Thyroid — NOT a problem","TSH 1.644 (normal). Free T3 slightly high but SECONDARY to fatty liver — will normalize as liver improves. NO thyroid medication needed.","green","lgreen"),
("7","All Else Normal","Blood count, kidneys, electrolytes, calcium, uric acid — all perfectly within range.","green","lgreen"),
]
t = make_table(doc, 3)
add_header_row(t, [("No.",600),("Diagnosis",2800),("What It Means",6100)], bg="blue")
for num, name, desc, fg, bg in diag_data:
r = t.add_row()
set_cell_bg(r.cells[0], C[bg]); set_col_width(r.cells[0],600); set_cell_margins(r.cells[0])
set_cell_bg(r.cells[1], C[bg]); set_col_width(r.cells[1],2800); set_cell_margins(r.cells[1])
set_cell_bg(r.cells[2], C[bg]); set_col_width(r.cells[2],6100); set_cell_margins(r.cells[2])
cell_para(r.cells[0], num, bold=True, fg=fg, size=11, align="center")
cell_para(r.cells[1], name, bold=True, fg=fg, size=9)
cell_para(r.cells[2], desc, size=9)
# ── DAILY MEDICINES ───────────────────────────────────────────────────────────
add_section(doc, "Section 1 — My Daily Medicine Schedule")
med_data = [
("MORNING\nwith breakfast","Neutrifactor\n(Vit C + B12 + Iron)","1 capsule with food. NEVER on empty stomach.","1 MONTH ONLY\nthen STOP","blue","lblue","red","lred"),
("MORNING\n+ EVENING","Rhinoclinal 100\n(Beclomethasone nasal spray)","2 sprays each nostril = 4 sprays total, twice daily.\nTechnique: head slightly forward, aim nozzle outward (away from nasal septum in the middle), breathe in gently while pressing.","4-8 WEEKS\nReview with\nDr. Bikaram","blue","lblue","yellow","lyellow"),
("EVERY NIGHT\nbefore sleep","Montelukast 10 mg\n(Freehale tablet)","1 tablet at night ONLY. Night timing is essential — leukotrienes (inflammation chemicals) are highest at night and early morning.","4-6 WEEKS\nReview with\nDr. Bikaram","blue","lblue","yellow","lyellow"),
("EVERY SUNDAY\nwith lunch/dinner","Sunny D 200,000 IU capsule\n(Vitamin D3 oral)","1 capsule once per week with your biggest meal (must contain fat — normal Pakistani meal is fine). Fat-soluble: MUST be taken with food.","8 WEEKS\nthen switch to\ndaily low dose","green","lgreen","orange","lorange"),
("AS NEEDED\nonly","Panadol\n(Paracetamol)","Only for sinus headache or pain. Max 2 tablets at a time. Do not use more than 3 days in a row (liver processes it).","On demand\nDo not overuse","blue","lblue","blue","lblue"),
]
t2 = make_table(doc, 4)
add_header_row(t2, [("When",1500),("Medicine",2600),("How to Take",3700),("For How Long",1700)], bg="blue")
for when, med, how, dur, wfg, wbg, dfg, dbg in med_data:
r = t2.add_row()
for i,(txt,fg,bg,w) in enumerate([(when,wfg,wbg,1500),(med,"black",wbg,2600),(how,"black",wbg,3700),(dur,dfg,dbg,1700)]):
set_cell_bg(r.cells[i], C[bg]); set_col_width(r.cells[i],w); set_cell_margins(r.cells[i])
cell_para(r.cells[i], txt, bold=(i==0 or i==3), fg=fg, size=9, align="center" if i in (0,3) else "left")
add_note(doc, "Important:", "Always take Sunny D 200,000 IU with a fat-containing meal (lunch or dinner). Vitamin D is fat-soluble — without fat it absorbs poorly.", "lorange", "orange")
add_note(doc, "Important:", "Do NOT take extra calcium tablets during the 8-week Sunny D loading phase. Your calcium is already at the upper limit of normal (10.2 mg/dL).", "lred", "red")
# ── MONTH BY MONTH ────────────────────────────────────────────────────────────
add_section(doc, "Section 2 — Month-by-Month Plan")
months = [
("MONTH 1\nJul 15 – Aug 15",
"+ Neutrifactor 1 capsule/morning\n+ Rhinoclinal nasal spray 2x daily\n+ Montelukast 10 mg every night\n+ Sunny D 200,000 IU every Sunday\n+/- Panadol only when needed",
"+ Start 20-30 min brisk walk daily\n+ Stop all fried food + sugary drinks completely\n+ Sugar-free tea/coffee (keep it up!)\n+ Drink 8-10 glasses of water daily\n+ Do NOT add extra calcium or iron supplements",
"red","lred"),
("MONTH 2\nAug 15 – Sep 15",
"STOP Neutrifactor\nSTART Methylcobalamin 1500 mcg/day (B12-only capsule — at any pharmacy)\n+ Continue Rhinoclinal if still needed\n+ Montelukast — stop if nose clear (confirm with Dr. Bikaram)\n+ Continue Sunny D weekly (weeks 5-8 of loading course)",
"+ Increase walk to 30-45 min daily\n+ Add 2x/week light resistance exercise (squats, push-ups)\n+ Mediterranean diet: more vegetables, lentils, fish, less white rice/naan\n+ Target losing 3-5 kg if you have any excess weight\n+ Zero sugar in any form",
"orange","lorange"),
("MONTH 3\nSep 15 – Oct 15",
"+ Continue Methylcobalamin 1500 mcg/day\nSTOP Sunny D 200,000 IU weekly\nSTART Vitamin D3 1000-2000 IU/day oral tablet (maintenance — Calcirol D3 or D-Sol)\n+ Rhinoclinal/Montelukast: only if symptoms persist\n\nGet ALL blood tests this month (list in Section 3)",
"+ All healthy habits should be firmly established by now\n+ Book follow-up with Dr. Bikaram\n+ Bring blood test results to appointment\n+ Assess: energy, sleep, nasal symptoms — all should be significantly better",
"green","lgreen"),
]
t3 = make_table(doc, 3)
add_header_row(t3, [("Period",1600),("Medicines",3850),("Lifestyle Actions",4050)], bg="blue")
for period, meds, life, fg, bg in months:
r = t3.add_row()
set_cell_bg(r.cells[0], C[bg]); set_col_width(r.cells[0],1600); set_cell_margins(r.cells[0])
set_cell_bg(r.cells[1], C[bg]); set_col_width(r.cells[1],3850); set_cell_margins(r.cells[1])
set_cell_bg(r.cells[2], C[bg]); set_col_width(r.cells[2],4050); set_cell_margins(r.cells[2])
cell_para(r.cells[0], period, bold=True, fg=fg, size=9, align="center")
cell_para(r.cells[1], meds, size=9)
cell_para(r.cells[2], life, size=9)
# ── BLOOD TESTS ───────────────────────────────────────────────────────────────
add_section(doc, "Section 3 — Blood Tests to Repeat at 3 Months (October 2026)")
tests = [
("SGPT (ALT) + ALP","Most important. ALT target below 43 U/L. ALP below 129 U/L. Confirms fatty liver improvement.","red","lred"),
("Vitamin D (25-OH)","Target above 40 ng/mL. If still low (<30), continue loading for 4 more weeks.","orange","lorange"),
("Vitamin B12","Should be above 300-400 pg/mL. Adjust dose based on result.","black","white"),
("HbA1c","Should fall below 5.9% (prediabetes reversal) with diet + exercise.","black","white"),
("Free T3 + TSH","Free T3 expected to normalize as fatty liver improves. TSH should remain normal.","black","white"),
("CBC (Blood Count)","Confirm Hb, WBC, platelets remain normal.","black","white"),
("HBsAg + Anti-HCV (ONE TIME ONLY)","Do this ONCE to formally rule out Hepatitis B and C. If both negative, pure fatty liver is confirmed.","red","lred"),
]
t4 = make_table(doc, 2)
add_header_row(t4, [("Test to Order",3500),("Why It Matters / Target",6000)], bg="blue")
for test, why, fg, bg in tests:
r = t4.add_row()
set_cell_bg(r.cells[0], C[bg]); set_col_width(r.cells[0],3500); set_cell_margins(r.cells[0])
set_cell_bg(r.cells[1], C[bg]); set_col_width(r.cells[1],6000); set_cell_margins(r.cells[1])
cell_para(r.cells[0], test, bold=True, fg=fg, size=9)
cell_para(r.cells[1], why, size=9)
add_note(doc, "Tell Dr. Bikaram at follow-up:", "My ALT/ALP were elevated in July 2026. I have done HBsAg and Anti-HCV to confirm pure fatty liver. I have been on diet, exercise, Vitamin D, and B12 supplementation for 3 months. Here are my new results.", "lyellow", "yellow")
# ── DIET ──────────────────────────────────────────────────────────────────────
add_section(doc, "Section 4 — Diet Rules (Fatty Liver + Prediabetes)")
t5 = make_table(doc, 3)
add_header_row(t5, [("NEVER — Stop Completely",3100),("REDUCE — Eat Less Of",3200),("EAT MORE — Start Today",3200)], bg="blue")
r = t5.add_row()
set_cell_bg(r.cells[0], C["lred"]); set_col_width(r.cells[0],3100); set_cell_margins(r.cells[0])
set_cell_bg(r.cells[1], C["lyellow"]); set_col_width(r.cells[1],3200); set_cell_margins(r.cells[1])
set_cell_bg(r.cells[2], C["lgreen"]); set_col_width(r.cells[2],3200); set_cell_margins(r.cells[2])
cell_para(r.cells[0], "Deep fried food (samosa, pakora, fries, puri)\n\nSugary drinks (Pepsi, juice, energy drinks)\n\nBakery & sweets (biscuits, cakes, mithai)\n\nFast food (burger, pizza, shawarma)\n\nHydrogenated oil / margarine in excess\n\nAll added sugar", size=9)
cell_para(r.cells[1], "White rice (1 small cup max)\n\nNaan / white bread — switch to 1 roti or whole wheat\n\nRed meat (beef, mutton — max 2x/week)\n\nFull-fat dairy\n\nHigh-sugar fruit (mango, grapes, banana)\n\nExtra salt\n\nLate-night eating", size=9)
cell_para(r.cells[2], "Green vegetables daily (palak, karela, salad)\n\nLentils & chickpeas every day if possible\n\nFish (tuna, sardines) — 2-3x per week\n\nEggs (boiled or poached)\n\nYogurt (plain, low fat)\n\nWhole grain roti\n\nSmall handful of nuts\n\nWater 8-10 glasses daily\n\nGreen tea (no sugar)", size=9)
# ── EXERCISE ──────────────────────────────────────────────────────────────────
add_section(doc, "Section 5 — Exercise Plan (Non-Negotiable for Fatty Liver)")
t6 = make_table(doc, 2)
add_header_row(t6, [("Period",1800),("Daily Target",7700)], bg="blue")
for period, target, bg in [
("Week 1-2","20 minutes brisk walk. Any time of day. Just start — consistency matters more than intensity at first.","lyellow"),
("Week 3-4","30 minutes brisk walk daily. Pace should make you slightly breathless but still able to speak in sentences.","lorange"),
("Month 2 onwards","30-45 min daily walk PLUS 2x per week resistance exercise (bodyweight squats, push-ups, or gym). Resistance training reduces liver fat independently of cardio.","lgreen"),
]:
r = t6.add_row()
set_cell_bg(r.cells[0], C[bg]); set_col_width(r.cells[0],1800); set_cell_margins(r.cells[0])
set_cell_bg(r.cells[1], C[bg]); set_col_width(r.cells[1],7700); set_cell_margins(r.cells[1])
cell_para(r.cells[0], period, bold=True, fg="black", size=9, align="center")
cell_para(r.cells[1], target, size=9)
add_note(doc, "Why exercise is the most important thing for fatty liver:", "Exercise burns liver fat DIRECTLY — even without losing weight. Consistent walking reduces ALT and ALP in 8-12 weeks. Think of it as free liver medicine you cannot buy at a pharmacy.", "lgreen", "green")
# ── QUICK REFERENCE ───────────────────────────────────────────────────────────
add_section(doc, "Section 6 — Quick Reference Card (Print and Stick on Your Wall)")
t7 = make_table(doc, 3)
add_header_row(t7, [("Every Day",3160),("Every Week",3160),("At 3 Months",3180)], bg="blue")
r = t7.add_row()
for i,(txt,bg) in enumerate([
("Morning: Neutrifactor capsule (Month 1 only) + Rhinoclinal nasal spray\n\nNight: Montelukast tablet\n\nLifestyle:\n+ 30-min walk\n+ No sugar, no fried food\n+ 8 glasses of water","lblue"),
("Every Sunday:\n+ Sunny D 200,000 IU capsule with food (mandatory — needs fat)\n\nMonitor once a week:\n+ Sleep quality improving?\n+ Energy level improving?\n+ Nasal symptoms clearing?\n+ Body weight","lyellow"),
("Medicine change:\n+ Stop Sunny D weekly\n+ Start Vit D3 1000-2000 IU/day daily tablet\n+ Adjust B12 dose based on result\n\nBlood tests:\nSGPT, ALP, Vit D, B12, HbA1c, TSH, Free T3, CBC, HBsAg, Anti-HCV\n\nVisit Dr. Bikaram","lgreen"),
]):
set_cell_bg(r.cells[i], C[bg]); set_col_width(r.cells[i],3160+i*10); set_cell_margins(r.cells[i])
cell_para(r.cells[i], txt, size=9)
# ── EXPECTED RESULTS ──────────────────────────────────────────────────────────
add_section(doc, "Section 7 — What You Should Expect (Realistic Timeline)")
t8 = make_table(doc, 2)
add_header_row(t8, [("Timeline",1800),("Expected Improvement",7700)], bg="blue")
for tl, exp, bg in [
("Weeks 1-2","Nasal blockage starts to clear. Sleep becomes less disturbed. Morning tiredness begins to reduce. (Rhinoclinal + Montelukast taking effect.)","lblue"),
("Weeks 3-4","Energy levels noticeably better as Vitamin D rebuilds. Less body aches. Better focus and concentration as B12 rises.","lyellow"),
("Month 2","Liver enzymes (ALT/ALP) begin to fall if diet and exercise are consistent. Weight may reduce slightly. Feel significantly better overall.","lorange"),
("Month 3","Blood tests should show clear improvement across all parameters. ALT below 43 target. Vitamin D above 40. HbA1c falling. Free T3 likely normalized.","lgreen"),
]:
r = t8.add_row()
set_cell_bg(r.cells[0], C[bg]); set_col_width(r.cells[0],1800); set_cell_margins(r.cells[0])
set_cell_bg(r.cells[1], C[bg]); set_col_width(r.cells[1],7700); set_cell_margins(r.cells[1])
cell_para(r.cells[0], tl, bold=True, size=9, align="center")
cell_para(r.cells[1], exp, size=9)
# ── DISCLAIMER ────────────────────────────────────────────────────────────────
doc.add_paragraph()
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(6)
pPr = p._p.get_or_add_pPr()
pBdr = OxmlElement("w:pBdr")
top = OxmlElement("w:top")
top.set(qn("w:val"), "single"); top.set(qn("w:sz"), "4"); top.set(qn("w:space"), "1"); top.set(qn("w:color"), C["grey"])
pBdr.append(top); pPr.append(pBdr)
r1 = p.add_run("Clinical Note: ")
r1.bold = True; r1.font.size = Pt(8); r1.font.color.rgb = rgb(C["dgrey"]); r1.font.name = "Calibri"
r2 = p.add_run("This plan is prepared for Dr. Muhammad Daniyal (MBBS) based on lab results dated 13-Jul-2026 and clinical assessment by Dr. Bikaram (GP & Endocrinologist, Sindh). All medications follow Dr. Bikaram's prescription. Lifestyle and monitoring recommendations are evidence-based additions. Always follow Dr. Bikaram's instructions if they differ from this plan. Report any worsening symptoms to him promptly.")
r2.italic = True; r2.font.size = Pt(8); r2.font.color.rgb = rgb(C["dgrey"]); r2.font.name = "Calibri"
doc.save(OUT)
print("SUCCESS:", OUT)
python3 /tmp/workspace/patient-report/build_plan.py 2>&1
python3 -c "import zipfile; z=zipfile.ZipFile('/tmp/workspace/patient-report/MyHealthPlan_DrDaniyal_Jul2026.docx'); print('Valid, files:',len(z.namelist()))" && ls -lh /tmp/workspace/patient-report/MyHealthPlan_DrDaniyal_Jul2026.docx
MyHealthPlan DrDaniyal Jul2026
Word Document · DOCX
| # | Diagnosis | Status |
|---|---|---|
| 1 | Fatty Liver (NAFLD) | SGPT 92 + ALP 197 — reversible with diet & exercise |
| 2 | Vitamin D Insufficiency | 26.74 ng/mL — causing fatigue, poor sleep |
| 3 | Borderline Vitamin B12 | 205.70 — contributing to fatigue |
| 4 | Sinusitis / Allergic Rhinitis | Causing blocked nose + disturbed sleep |
| 5 | Prediabetes (HbA1c 6.0%) | Not diabetes yet — reversible |
| 6 | Thyroid — NOT a problem | TSH normal. T3 high = secondary to fatty liver only |
| 7 | Everything else normal | Blood, kidneys, electrolytes all fine |
| When | Medicine | How Long |
|---|---|---|
| Morning with food | Neutrifactor 1 capsule | 1 month only — then STOP |
| Morning + Evening | Rhinoclinal 100 — 2 sprays each nostril | 4-8 weeks |
| Every night | Montelukast 10 mg tablet | 4-6 weeks |
| Every Sunday with food | Sunny D 200,000 IU capsule | 8 weeks only |
| As needed only | Panadol for headache | On demand |
When i should use this medication and how
Right timing example: You sit down for Sunday lunch (daal + roti + a little oil/ghee) → take the Sunny D capsule right at the start of that meal.
| Time | What to Take |
|---|---|
| 🌅 Every morning after breakfast | Neutrifactor 1 capsule |
| 🌅 Every morning | Rhinoclinal spray — 2 presses each nostril |
| 🌆 Every evening | Rhinoclinal spray — 2 presses each nostril |
| 🌙 Every night before sleep | Montelukast 10 mg tablet |
| ☀️ Every Sunday with lunch/dinner | Sunny D 200,000 IU capsule |
| 🤕 Only when head/sinus pain | Panadol 1-2 tablets |