attachment
attachment
attachment
attachment
attachment
attachment

She is suffering with fever busy ache chills sweating since 3 days further treatment what I need to suggest based on this reports

Reading File
analyse_media
analyse_media
analyse_media
Finding Sources
Finding Sources
Searching PubMed

"urinary tract infection" AND "pyelonephritis" AND treatment

Reading File
I now have all the information needed for a thorough clinical analysis. Here is the full assessment:

Clinical Assessment: K. Dhathri, 20F - 3 Days Fever, Body Ache, Chills, Sweating

Important notice: This analysis is intended to assist a clinician. It does not replace direct physical examination or physician judgment. Prescription decisions must be made by the treating doctor.

Lab Summary & Abnormal Findings

CBC (Complete Blood Count)

ParameterResultReferenceInterpretation
Haemoglobin12.9 g/dL11.5-16.5Normal
Total Leucocyte Count15.8 × 10⁹/L4-11HIGH - Leukocytosis
MID (monocytes/eosinophils)2.3 × 10⁹/L0.1-1.5HIGH
Granulocytes10.4 × 10⁹/L1.2-8.0HIGH - Neutrophilia
MID%15.1%2.0-15.0Borderline high
Granulocytes%65%35-80Normal
Platelets332 × 10⁹/L100-400Normal
Impression: Significant leukocytosis (WBC 15.8) with predominant neutrophilia (granulocytes 10.4) - classic bacterial infection pattern.

Biochemistry (LFT + RFT + CRP)

ParameterResultReferenceInterpretation
CRP128.9 µg/mL<10MARKEDLY ELEVATED - ~13× normal
SGOT62 U/L<40Mildly elevated
SGPT51 U/L<40Mildly elevated
ALP112 U/L42-142Normal
Bilirubin (Total)0.7 mg/dL0-1.0Normal
Serum Creatinine0.9 mg/dL0.6-1.1 (F)Normal (upper limit)
Blood Urea34 mg/dL10-50Normal
CRP of 128.9 µg/mL is a strong marker of active bacterial infection/sepsis (normal <10). Mild transaminase elevation (SGOT/SGPT) likely reflects systemic inflammatory response or early hepatic involvement - not primary liver disease.

Urine Examination

FindingResultSignificance
NitritePOSITIVEBacterial UTI (gram-negative organisms)
Protein+Renal inflammation
Blood++Haematuria - renal/bladder inflammation
Pus Cells15-20 cells/HPFSignificant pyuria - active UTI
Epithelial cells4-6/HPFMild
RBCs2-4/HPFHaematuria
Specific Gravity1.030Concentrated urine
Significant pyuria + positive nitrite + haematuria = confirmed urinary tract infection.

Serology / Malaria

TestResult
Dengue NS1 AgNEGATIVE
Dengue IgM/IgGNEGATIVE
Malaria (P. vivax/P. falciparum)NEGATIVE
Dengue and malaria excluded.

Working Diagnosis

Primary: Acute Pyelonephritis (Upper UTI / Urosepsis)

The clinical and lab picture is characteristic:
  • Fever + chills + sweating + body ache for 3 days
  • Leukocytosis with neutrophilia (WBC 15.8)
  • CRP 128.9 µg/mL - massive systemic inflammatory response
  • Pyuria (15-20 pus cells/HPF) + nitrite positive + haematuria - active upper UTI
  • Dengue and malaria ruled out
  • Renal function currently preserved (creatinine 0.9, borderline for female)
As per Smith and Tanagho's General Urology (19th Ed): "Patients with acute pyelonephritis present with chills, fever, and costovertebral angle tenderness... Leukocytosis, increased erythrocyte sedimentation, and elevated levels of C-reactive protein are commonly seen."

Recommended Management

Step 1 - Immediate (Today)

  1. Urine culture and sensitivity (C&S) - Send BEFORE starting antibiotics. This is critical to confirm the organism and guide antibiotic choice. Most common pathogen: E. coli (70-80%); also Klebsiella, Proteus, Enterobacter.
  2. Blood culture (x2 sets) - given high CRP 128.9 and systemic symptoms, bacteraemia must be excluded.
  3. Assess for sepsis criteria - If HR >90, RR >20, temp >38.5°C - consider hospital admission.

Step 2 - Antibiotic Therapy

If mild-moderate (outpatient):
  • Oral Ciprofloxacin 500 mg twice daily × 10-14 days, or
  • Oral Cefixime 200 mg twice daily × 10-14 days, or
  • Amoxicillin-Clavulanate 625 mg thrice daily × 10-14 days
If severe (hospital admission - WBC >15, CRP >100, systemic toxicity):
  • IV Ceftriaxone 1-2g once daily, OR
  • IV Piperacillin-Tazobactam 4.5g every 8 hours (if Pseudomonas risk)
  • Transition to oral once afebrile ≥48 hours
(Per Smith & Tanagho's Urology: "empiric therapy with IV ampicillin and aminoglycosides is effective... alternatively, amoxicillin with clavulanic acid or a third-generation cephalosporin can be used.")
Adjust antibiotic once C&S results are available (48-72 hrs).

Step 3 - Supportive Treatment

  • Antipyretics: Paracetamol 500-1000 mg every 6-8 hours (avoid NSAIDs - borderline creatinine 0.9)
  • IV fluids or aggressive oral hydration - maintain urine output >1 mL/kg/hr
  • Urine alkalisation - not required routinely

Step 4 - Monitor Liver Function

  • SGOT (62) and SGPT (51) are mildly elevated - likely systemic sepsis effect
  • Repeat LFTs after 1-2 weeks once infection resolves
  • If persistently elevated after treatment, investigate further (viral hepatitis screen: HBsAg, Anti-HCV)

Step 5 - Follow-up Tests

  • Repeat urine routine + culture at 1 week after completing antibiotics (test of cure)
  • Ultrasound KUB - to rule out renal abscess, hydronephrosis, or calculi (especially if no response in 48-72 hrs)
  • Repeat CBC + CRP at 72 hours - should show downtrend with treatment

Admission Criteria - Refer to Hospital If:

  • Temperature >39°C not responding to antipyretics
  • Signs of septic shock (hypotension, altered sensorium)
  • Vomiting precluding oral medications
  • No improvement after 48-72 hours of oral antibiotics
  • Creatinine worsening or rising

Red Flags to Watch

  • Creatinine is 0.9 mg/dL (normal for female is up to 1.1) - monitor closely; pyelonephritis can cause AKI
  • CRP of 128.9 is very high - suggests significant systemic response - early aggressive treatment is important
  • Mildly elevated liver enzymes - resolve after treatment of sepsis, but must be rechecked

Summary: This 20-year-old woman most likely has acute pyelonephritis with systemic inflammatory response (high CRP + leukocytosis). Dengue and malaria are ruled out. Priority actions are: send urine C&S + blood cultures NOW, start empiric antibiotics (3rd-generation cephalosporin or fluoroquinolone), ensure adequate hydration, and consider admission given the degree of systemic inflammation. Adjust therapy once culture sensitivity is available at 48-72 hours.

Create a summary PDF of this treatment plan to share with the patient

Reading File
Running Command

mkdir -p /tmp/workspace/patient-report && ls /tmp/workspace/patient-report/

Writing File

~/patient-report/generate_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether
)
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from datetime import date

OUTPUT = "/tmp/workspace/patient-report/Treatment_Summary_KDhathri.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
TEAL       = colors.HexColor("#0D7377")
TEAL_LIGHT = colors.HexColor("#E6F4F4")
ORANGE     = colors.HexColor("#E87722")
ORANGE_BG  = colors.HexColor("#FEF3E8")
RED        = colors.HexColor("#C0392B")
RED_BG     = colors.HexColor("#FDEDEC")
GREEN      = colors.HexColor("#1E8449")
GREEN_BG   = colors.HexColor("#EAFAF1")
GREY_DARK  = colors.HexColor("#2C3E50")
GREY_MED   = colors.HexColor("#566573")
GREY_LIGHT = colors.HexColor("#F2F3F4")
WHITE      = colors.white

# ── Document ────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=18*mm, rightMargin=18*mm,
    topMargin=14*mm, bottomMargin=18*mm,
    title="Treatment Summary – K. Dhathri",
    author="Rayalaseema Diagnostics / Dr. Dadireddy Sai Sree",
)

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

# ── Styles ──────────────────────────────────────────────────────────────────
base = getSampleStyleSheet()

def S(name, parent="Normal", **kw):
    return ParagraphStyle(name, parent=base[parent], **kw)

sTitle      = S("sTitle",      fontSize=20, textColor=WHITE, alignment=TA_CENTER,
                fontName="Helvetica-Bold", leading=26)
sSubtitle   = S("sSubtitle",   fontSize=10, textColor=WHITE, alignment=TA_CENTER,
                fontName="Helvetica", leading=14)
sSectionHdr = S("sSectionHdr", fontSize=11, textColor=WHITE,
                fontName="Helvetica-Bold", leading=15)
sBody       = S("sBody",       fontSize=9.5, textColor=GREY_DARK,
                fontName="Helvetica", leading=14, spaceAfter=3)
sBullet     = S("sBullet",     fontSize=9.5, textColor=GREY_DARK,
                fontName="Helvetica", leading=14, leftIndent=12, spaceAfter=2,
                bulletFontName="Helvetica", bulletFontSize=9.5)
sWarning    = S("sWarning",    fontSize=9,  textColor=RED,
                fontName="Helvetica-Bold", leading=13)
sNote       = S("sNote",       fontSize=8.5, textColor=GREY_MED,
                fontName="Helvetica-Oblique", leading=12, alignment=TA_CENTER)
sLabel      = S("sLabel",      fontSize=8.5, textColor=GREY_MED,
                fontName="Helvetica-Bold", leading=11)
sValue      = S("sValue",      fontSize=9.5, textColor=GREY_DARK,
                fontName="Helvetica", leading=13)
sDiag       = S("sDiag",       fontSize=13, textColor=TEAL,
                fontName="Helvetica-Bold", leading=18, alignment=TA_CENTER)
sFooter     = S("sFooter",     fontSize=7.5, textColor=GREY_MED,
                fontName="Helvetica-Oblique", alignment=TA_CENTER, leading=11)

# ── Helper: coloured section header bar ─────────────────────────────────────
def section_header(text, bg=TEAL, icon=""):
    full = f"{icon}  {text}" if icon else text
    data = [[Paragraph(full, sSectionHdr)]]
    t = Table(data, colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("ROUNDEDCORNERS", [4,4,4,4]),
    ]))
    return t

# ── Helper: two-column key/value row ────────────────────────────────────────
def kv_row(label, value, label_w=55*mm):
    return Table(
        [[Paragraph(label, sLabel), Paragraph(value, sValue)]],
        colWidths=[label_w, W - label_w],
        style=[
            ("VALIGN", (0,0), (-1,-1), "TOP"),
            ("TOPPADDING", (0,0), (-1,-1), 2),
            ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ]
    )

# ── Helper: highlighted info box ────────────────────────────────────────────
def info_box(text, bg=TEAL_LIGHT, border_color=TEAL, style=None):
    st = style or sBody
    data = [[Paragraph(text, st)]]
    t = Table(data, colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), bg),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("TOPPADDING",    (0,0), (-1,-1), 7),
        ("BOTTOMPADDING", (0,0), (-1,-1), 7),
        ("LINEAFTER",     (0,0), (0,-1), 3, border_color),  # left accent
        ("LINEBEFORE",    (0,0), (0,-1), 3, border_color),
        ("ROUNDEDCORNERS", [4,4,4,4]),
    ]))
    return t

# ── Build story ─────────────────────────────────────────────────────────────
story = []

# ── HEADER BLOCK ────────────────────────────────────────────────────────────
header_data = [[
    Paragraph("PATIENT TREATMENT SUMMARY", sTitle),
],[
    Paragraph("Acute Pyelonephritis (Upper Urinary Tract Infection)", sSubtitle),
],[
    Paragraph(f"Prepared by: Dr. Dadireddy Sai Sree  |  Date: {date.today().strftime('%d %B %Y')}  |  Lab ID: B26080741", sSubtitle),
]]
header_tbl = Table(header_data, colWidths=[W])
header_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), TEAL),
    ("TOPPADDING",    (0,0), (-1,-1), 8),
    ("BOTTOMPADDING", (0,0), (-1,-1), 8),
    ("LEFTPADDING",   (0,0), (-1,-1), 12),
    ("RIGHTPADDING",  (0,0), (-1,-1), 12),
    ("ROUNDEDCORNERS", [6,6,6,6]),
]))
story.append(header_tbl)
story.append(Spacer(1, 5*mm))

# ── PATIENT DETAILS ─────────────────────────────────────────────────────────
story.append(section_header("PATIENT DETAILS", bg=GREY_DARK))
story.append(Spacer(1, 2*mm))

pd_data = [
    [Paragraph("Name", sLabel),        Paragraph("K. Dhathri", sValue),
     Paragraph("Age / Sex", sLabel),   Paragraph("20 Years / Female", sValue)],
    [Paragraph("Lab ID", sLabel),      Paragraph("B26080741", sValue),
     Paragraph("Report Date", sLabel), Paragraph("07 August 2026", sValue)],
    [Paragraph("Referred by", sLabel), Paragraph("Dr. Dadireddy Sai Sree", sValue),
     Paragraph("Facility", sLabel),    Paragraph("Rayalaseema Diagnostics, Kurnool", sValue)],
]
pd_tbl = Table(pd_data, colWidths=[40*mm, 65*mm, 40*mm, W-145*mm])
pd_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), GREY_LIGHT),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("ROUNDEDCORNERS", [4,4,4,4]),
]))
story.append(pd_tbl)
story.append(Spacer(1, 4*mm))

# ── DIAGNOSIS ───────────────────────────────────────────────────────────────
story.append(section_header("DIAGNOSIS", bg=TEAL))
story.append(Spacer(1, 2*mm))
diag_box_data = [[Paragraph(
    "Acute Pyelonephritis (Upper Urinary Tract Infection) with Systemic Inflammatory Response",
    sDiag
)]]
diag_tbl = Table(diag_box_data, colWidths=[W])
diag_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), TEAL_LIGHT),
    ("TOPPADDING",    (0,0), (-1,-1), 10),
    ("BOTTOMPADDING", (0,0), (-1,-1), 10),
    ("LEFTPADDING",   (0,0), (-1,-1), 10),
    ("BOX",           (0,0), (-1,-1), 1.5, TEAL),
    ("ROUNDEDCORNERS", [4,4,4,4]),
]))
story.append(diag_tbl)
story.append(Spacer(1, 2*mm))
story.append(Paragraph(
    "Dengue (NS1 Ag, IgM, IgG) and Malaria (P. vivax, P. falciparum) have been <b>ruled out</b> by serology.",
    sBody
))
story.append(Spacer(1, 4*mm))

# ── KEY LAB FINDINGS ────────────────────────────────────────────────────────
story.append(section_header("KEY LAB FINDINGS", bg=TEAL))
story.append(Spacer(1, 2*mm))

lab_header = ["Test", "Your Result", "Normal Range", "Status"]
lab_data = [
    lab_header,
    ["WBC (Total Leucocytes)", "15.8 × 10⁹/L", "4 – 11 × 10⁹/L", "HIGH"],
    ["Granulocytes (Neutrophils)", "10.4 × 10⁹/L", "1.2 – 8.0 × 10⁹/L", "HIGH"],
    ["C-Reactive Protein (CRP)", "128.9 µg/mL", "Up to 10 µg/mL", "VERY HIGH"],
    ["SGOT (Liver enzyme)", "62 U/L", "< 40 U/L", "Mildly elevated"],
    ["SGPT (Liver enzyme)", "51 U/L", "< 40 U/L", "Mildly elevated"],
    ["Serum Creatinine", "0.9 mg/dL", "0.6 – 1.1 mg/dL (F)", "Normal"],
    ["Haemoglobin", "12.9 g/dL", "11.5 – 16.5 g/dL", "Normal"],
    ["Platelets", "332 × 10⁹/L", "100 – 400 × 10⁹/L", "Normal"],
    ["Urine Pus Cells", "15 – 20 / HPF", "< 5 / HPF", "HIGH"],
    ["Urine Nitrite", "POSITIVE", "Negative", "Infection marker"],
    ["Urine Blood", "++", "Negative", "Present"],
]

def status_color(s):
    s = s.upper()
    if "VERY HIGH" in s:  return RED
    if "HIGH" in s:       return ORANGE
    if "ELEVATED" in s:   return ORANGE
    if "NORMAL" in s:     return GREEN
    if "INFECTION" in s:  return ORANGE
    if "PRESENT" in s:    return ORANGE
    return GREY_DARK

lab_para = []
for i, row in enumerate(lab_data):
    if i == 0:
        lab_para.append([Paragraph(f"<b>{c}</b>", ParagraphStyle(
            "lh", parent=base["Normal"], fontSize=9, fontName="Helvetica-Bold",
            textColor=WHITE, leading=12)) for c in row])
    else:
        sc = status_color(row[3])
        lab_para.append([
            Paragraph(row[0], ParagraphStyle("lc", parent=base["Normal"], fontSize=9,
                                              textColor=GREY_DARK, leading=12)),
            Paragraph(f"<b>{row[1]}</b>", ParagraphStyle("lv", parent=base["Normal"],
                                                           fontSize=9, fontName="Helvetica-Bold",
                                                           textColor=GREY_DARK, leading=12)),
            Paragraph(row[2], ParagraphStyle("lr", parent=base["Normal"], fontSize=9,
                                              textColor=GREY_MED, leading=12)),
            Paragraph(f"<b>{row[3]}</b>", ParagraphStyle("ls", parent=base["Normal"],
                                                           fontSize=9, fontName="Helvetica-Bold",
                                                           textColor=sc, leading=12)),
        ])

col_w = [W*0.32, W*0.24, W*0.26, W*0.18]
lab_tbl = Table(lab_para, colWidths=col_w)
ts = TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  TEAL),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("RIGHTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#BDC3C7")),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, GREY_LIGHT]),
])
lab_tbl.setStyle(ts)
story.append(lab_tbl)
story.append(Spacer(1, 4*mm))

# ── WHAT THIS MEANS ─────────────────────────────────────────────────────────
story.append(section_header("WHAT THESE RESULTS MEAN", bg=GREY_DARK))
story.append(Spacer(1, 2*mm))
meanings = [
    ("<b>High WBC + Neutrophils:</b> Your body is actively fighting a bacterial infection. "
     "This is expected and confirms an infection is present."),
    ("<b>Very High CRP (128.9):</b> C-Reactive Protein is a key marker of inflammation. "
     "A level ~13x above normal means your body is under significant stress from infection. "
     "This number should come down quickly with the right antibiotics."),
    ("<b>Urine findings (pus cells, nitrite, blood):</b> Confirm that the infection has "
     "reached the kidneys (upper urinary tract). This is called pyelonephritis."),
    ("<b>Mildly elevated liver enzymes (SGOT/SGPT):</b> A mild, temporary rise during "
     "systemic infection. Not a liver disease — expected to return to normal after treatment."),
    ("<b>Kidney function (creatinine 0.9):</b> Currently within normal limits. "
     "Must be monitored closely as kidney infections can sometimes affect function."),
]
for m in meanings:
    story.append(Paragraph(f"• {m}", sBullet))
story.append(Spacer(1, 4*mm))

# ── TREATMENT PLAN ──────────────────────────────────────────────────────────
story.append(KeepTogether([
    section_header("YOUR TREATMENT PLAN", bg=TEAL),
    Spacer(1, 2*mm),
]))

# --- Antibiotics
story.append(info_box(
    "<b>Step 1 — Antibiotic Treatment (Most Important)</b><br/>"
    "You will be prescribed one of the following antibiotics. Take the <b>complete course</b> even if you feel better earlier.",
    bg=TEAL_LIGHT, border_color=TEAL
))
story.append(Spacer(1, 1.5*mm))

abx_data = [
    [Paragraph("<b>Antibiotic Option</b>", sLabel),
     Paragraph("<b>Dose</b>", sLabel),
     Paragraph("<b>Duration</b>", sLabel)],
    [Paragraph("Ciprofloxacin (oral)", sBody),
     Paragraph("500 mg twice daily", sBody),
     Paragraph("10 – 14 days", sBody)],
    [Paragraph("Cefixime (oral)", sBody),
     Paragraph("200 mg twice daily", sBody),
     Paragraph("10 – 14 days", sBody)],
    [Paragraph("Amoxicillin-Clavulanate (oral)", sBody),
     Paragraph("625 mg three times daily", sBody),
     Paragraph("10 – 14 days", sBody)],
    [Paragraph("Ceftriaxone (injection — if admitted)", sBody),
     Paragraph("1 – 2 g once daily (IV)", sBody),
     Paragraph("Until oral possible", sBody)],
]
abx_tbl = Table(abx_data, colWidths=[W*0.38, W*0.34, W*0.28])
abx_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  GREY_LIGHT),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 8),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#BDC3C7")),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, GREY_LIGHT]),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(abx_tbl)
story.append(Spacer(1, 1*mm))
story.append(Paragraph(
    "* Final antibiotic choice will be confirmed by your urine culture & sensitivity results (available in 48–72 hours).",
    sNote
))
story.append(Spacer(1, 3*mm))

# --- Fever / Pain
story.append(info_box(
    "<b>Step 2 — Fever & Pain Relief</b><br/>"
    "Take <b>Paracetamol (Paracetamol 500 – 1000 mg)</b> every 6 – 8 hours as needed for fever or body ache.<br/>"
    "<font color='#C0392B'><b>Avoid ibuprofen / aspirin / diclofenac (NSAIDs)</b></font> — these can stress the kidneys.",
    bg=ORANGE_BG, border_color=ORANGE
))
story.append(Spacer(1, 3*mm))

# --- Hydration
story.append(info_box(
    "<b>Step 3 — Stay Well Hydrated</b><br/>"
    "Drink <b>at least 2.5 – 3 litres of water</b> per day. Good hydration flushes the bacteria from "
    "the urinary tract and helps protect your kidneys. Aim for pale yellow urine throughout the day.",
    bg=GREEN_BG, border_color=GREEN
))
story.append(Spacer(1, 4*mm))

# ── PENDING TESTS ────────────────────────────────────────────────────────────
story.append(KeepTogether([
    section_header("IMPORTANT TESTS STILL NEEDED", bg=ORANGE),
    Spacer(1, 2*mm),
]))

tests = [
    ("Urine Culture & Sensitivity (C&S)",
     "Identifies the exact bacteria causing your infection and which antibiotics will work best. "
     "<b>Send sample BEFORE starting antibiotics.</b> Results in 48–72 hours."),
    ("Blood Culture (x2 sets)",
     "Rules out bacteria in the bloodstream (bacteraemia/sepsis). Your very high CRP makes this necessary."),
    ("Ultrasound KUB (Kidney-Ureter-Bladder)",
     "To check for kidney abscess, blockage (hydronephrosis), or kidney stones that may need treatment."),
    ("Repeat CBC + CRP at 72 hours",
     "To confirm your WBC and CRP are coming down with antibiotics. If not improving, treatment may need to change."),
    ("Repeat LFT (Liver tests) in 1–2 weeks",
     "To confirm SGOT/SGPT have returned to normal after infection resolves."),
    ("Repeat Urine Routine + Culture (1 week post-treatment)",
     "Test of cure — confirms the infection is completely cleared."),
]
for name, desc in tests:
    row_data = [[
        Paragraph(f"<b>{name}</b>", ParagraphStyle("tn", parent=base["Normal"],
                                                    fontSize=9, fontName="Helvetica-Bold",
                                                    textColor=ORANGE, leading=13)),
        Paragraph(desc, ParagraphStyle("td", parent=base["Normal"], fontSize=9,
                                        textColor=GREY_DARK, leading=13)),
    ]]
    row_tbl = Table(row_data, colWidths=[55*mm, W-55*mm])
    row_tbl.setStyle(TableStyle([
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 0),
        ("LINEBELOW",     (0,0), (-1,-1), 0.3, colors.HexColor("#BDC3C7")),
    ]))
    story.append(row_tbl)
story.append(Spacer(1, 4*mm))

# ── RED FLAGS ────────────────────────────────────────────────────────────────
story.append(KeepTogether([
    section_header("GO TO HOSPITAL IMMEDIATELY IF YOU NOTICE:", bg=RED),
    Spacer(1, 2*mm),
    info_box(
        "• Temperature above 39°C (102.2°F) that does not come down with Paracetamol<br/>"
        "• Feeling faint, confused, or extremely weak<br/>"
        "• Unable to keep down fluids or tablets due to vomiting<br/>"
        "• Severe pain in your back or sides (kidney area)<br/>"
        "• No improvement after 48 – 72 hours of antibiotics<br/>"
        "• Decreased urine output or very dark / no urine",
        bg=RED_BG, border_color=RED,
        style=ParagraphStyle("rf", parent=base["Normal"], fontSize=9.5,
                              textColor=GREY_DARK, leading=15, fontName="Helvetica")
    ),
    Spacer(1, 4*mm),
]))

# ── FOLLOW UP ────────────────────────────────────────────────────────────────
story.append(section_header("FOLLOW-UP SCHEDULE", bg=TEAL))
story.append(Spacer(1, 2*mm))
fu_data = [
    [Paragraph("<b>When</b>", sLabel),    Paragraph("<b>Action</b>", sLabel)],
    [Paragraph("Today / Tomorrow", sBody), Paragraph("Send urine C&S + blood cultures", sBody)],
    [Paragraph("Day 3 (72 hours)", sBody), Paragraph("Review: CBC + CRP to confirm improvement; adjust antibiotic if needed", sBody)],
    [Paragraph("Day 7 – 10", sBody),       Paragraph("Ultrasound KUB; review culture results; ensure feeling better", sBody)],
    [Paragraph("1 week after finishing antibiotics", sBody), Paragraph("Repeat urine routine + culture (test of cure)", sBody)],
    [Paragraph("2 weeks", sBody),          Paragraph("Repeat LFT to confirm liver enzymes normalised", sBody)],
]
fu_tbl = Table(fu_data, colWidths=[50*mm, W-50*mm])
fu_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  TEAL_LIGHT),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 8),
    ("GRID",          (0,0), (-1,-1), 0.4, colors.HexColor("#BDC3C7")),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, GREY_LIGHT]),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
]))
story.append(fu_tbl)
story.append(Spacer(1, 4*mm))

# ── LIFESTYLE TIPS ────────────────────────────────────────────────────────────
story.append(section_header("TIPS FOR FASTER RECOVERY", bg=GREEN))
story.append(Spacer(1, 2*mm))
tips = [
    "Rest adequately — let your body fight the infection.",
    "Complete the <b>full course of antibiotics</b>. Stopping early can cause the infection to return, harder to treat.",
    "Drink 2.5–3 litres of water daily. Cranberry juice (unsweetened) may help symptom relief.",
    "Avoid holding urine — urinate whenever you feel the urge.",
    "Maintain good personal hygiene (front to back wiping).",
    "Avoid caffeine and alcohol until fully recovered.",
    "Light, nutritious meals — avoid heavy spicy food while unwell.",
]
for t in tips:
    story.append(Paragraph(f"✓  {t}", sBullet))
story.append(Spacer(1, 5*mm))

# ── FOOTER ───────────────────────────────────────────────────────────────────
story.append(HRFlowable(width=W, thickness=0.5, color=GREY_MED))
story.append(Spacer(1, 2*mm))
story.append(Paragraph(
    "This document is a clinical summary prepared to assist the patient in understanding their diagnosis and treatment plan.<br/>"
    "It does not replace direct medical advice. Please follow up with your treating doctor for all prescription decisions.<br/>"
    "Rayalaseema Diagnostics, Opp. Govt. General Hospital, Budhawarapeta, Kurnool | Ph: 9989722996, 9949585088",
    sFooter
))

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

cd /tmp/workspace/patient-report && python generate_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/patient-report/Treatment_Summary_KDhathri.pdf

The PDF has been generated successfully. Here is your download link:

Treatment Summary KDhathri

PDF Document · PDF


Here is what's included in the PDF:
Page structure (patient-friendly, colour-coded):
  1. Header - Patient name, Lab ID, referring doctor, date
  2. Patient Details - Full demographics at a glance
  3. Diagnosis - Clear statement: Acute Pyelonephritis - with dengue & malaria ruled out noted
  4. Key Lab Findings Table - All 11 critical results with colour-coded status (red = very high, orange = elevated, green = normal)
  5. What These Results Mean - Plain-language explanations of each abnormal finding
  6. Treatment Plan - 3 clear steps: antibiotics (table with options/doses/duration), fever relief with NSAID warning, hydration advice
  7. Tests Still Needed - Urine C&S, blood cultures, ultrasound KUB, repeat bloods - each with a plain explanation of why
  8. Red Flags / Go to Hospital - Bold red box listing danger signs
  9. Follow-up Schedule - Timeline from today through 2 weeks
  10. Recovery Tips - Practical lifestyle advice
  11. Footer - Disclaimer and facility contact details
The design uses teal/orange/green/red colour coding so the patient can quickly identify what is urgent, what is normal, and what to watch for.
This is a shared conversation. Sign in to Orris to start your own chat.