Give laboratory investigations for ascites in pdf format with values
mkdir -p /home/daytona/workspace/ascites-pdf
~/ascites-pdf/generate_ascites_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table,
TableStyle, HRFlowable, PageBreak)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import KeepTogether
OUTPUT = "/home/daytona/workspace/ascites-pdf/Ascites_Laboratory_Investigations.pdf"
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
rightMargin=2*cm, leftMargin=2*cm,
topMargin=2.2*cm, bottomMargin=2.2*cm,
title="Laboratory Investigations for Ascites"
)
# ------------------------------------------------------------------
# Styles
# ------------------------------------------------------------------
styles = getSampleStyleSheet()
title_style = ParagraphStyle(
"TitleStyle",
parent=styles["Title"],
fontSize=20,
textColor=colors.HexColor("#1a3a5c"),
spaceAfter=4,
fontName="Helvetica-Bold",
alignment=TA_CENTER,
)
subtitle_style = ParagraphStyle(
"SubtitleStyle",
parent=styles["Normal"],
fontSize=11,
textColor=colors.HexColor("#4a6fa5"),
spaceAfter=14,
fontName="Helvetica",
alignment=TA_CENTER,
)
section_style = ParagraphStyle(
"SectionStyle",
parent=styles["Heading1"],
fontSize=13,
textColor=colors.white,
spaceBefore=14,
spaceAfter=4,
fontName="Helvetica-Bold",
leftIndent=0,
backColor=colors.HexColor("#1a3a5c"),
borderPad=5,
)
sub_section_style = ParagraphStyle(
"SubSectionStyle",
parent=styles["Heading2"],
fontSize=11,
textColor=colors.HexColor("#1a3a5c"),
spaceBefore=8,
spaceAfter=3,
fontName="Helvetica-Bold",
)
body_style = ParagraphStyle(
"BodyStyle",
parent=styles["Normal"],
fontSize=9.5,
textColor=colors.HexColor("#222222"),
spaceAfter=4,
fontName="Helvetica",
leading=14,
alignment=TA_JUSTIFY,
)
note_style = ParagraphStyle(
"NoteStyle",
parent=styles["Normal"],
fontSize=8.5,
textColor=colors.HexColor("#555555"),
spaceAfter=4,
fontName="Helvetica-Oblique",
leftIndent=8,
leading=12,
)
footer_style = ParagraphStyle(
"FooterStyle",
parent=styles["Normal"],
fontSize=8,
textColor=colors.HexColor("#888888"),
alignment=TA_CENTER,
)
# ------------------------------------------------------------------
# Table helpers
# ------------------------------------------------------------------
HEADER_BG = colors.HexColor("#1a3a5c")
ALT_BG = colors.HexColor("#eaf0f8")
WHITE_BG = colors.white
BORDER_CLR = colors.HexColor("#adc4e0")
def make_table(data, col_widths=None, alt=True):
if col_widths is None:
col_widths = None
t = Table(data, colWidths=col_widths, repeatRows=1)
style_cmds = [
("BACKGROUND", (0, 0), (-1, 0), HEADER_BG),
("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
("FONTSIZE", (0, 0), (-1, 0), 9),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [WHITE_BG, ALT_BG] if alt else [WHITE_BG]),
("FONTNAME", (0, 1), (-1, -1), "Helvetica"),
("FONTSIZE", (0, 1), (-1, -1), 8.8),
("TEXTCOLOR", (0, 1), (-1, -1), colors.HexColor("#222222")),
("GRID", (0, 0), (-1, -1), 0.4, BORDER_CLR),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("TOPPADDING", (0, 0), (-1, -1), 5),
("BOTTOMPADDING", (0, 0), (-1, -1), 5),
("LEFTPADDING", (0, 0), (-1, -1), 6),
("RIGHTPADDING", (0, 0), (-1, -1), 6),
]
t.setStyle(TableStyle(style_cmds))
return t
def section_header(text):
return Paragraph(f" {text}", section_style)
# ------------------------------------------------------------------
# Content builder
# ------------------------------------------------------------------
story = []
# ---- TITLE BLOCK ----
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("Laboratory Investigations for Ascites", title_style))
story.append(Paragraph("A Comprehensive Reference with Diagnostic Values", subtitle_style))
story.append(HRFlowable(width="100%", thickness=2, color=colors.HexColor("#4a6fa5"), spaceAfter=10))
# ---- INTRODUCTION ----
story.append(Paragraph(
"Ascites is the pathological accumulation of excess fluid (>25 mL) in the peritoneal cavity. "
"It is most commonly caused by cirrhosis (~80%), followed by malignancy (~10%), cardiac failure (~5%), "
"and other causes. Diagnostic paracentesis with fluid analysis is the most rapid and cost-effective "
"method for determining the aetiology of ascites and should be performed in all patients with new-onset ascites.",
body_style
))
# ---- SECTION 1: SERUM TESTS ----
story.append(section_header("1. Serum (Blood) Investigations"))
story.append(Spacer(1, 4))
story.append(Paragraph("These tests evaluate underlying hepatic, renal, and metabolic status.", body_style))
story.append(Spacer(1, 4))
serum_data = [
["Investigation", "Normal / Reference Value", "Significance in Ascites"],
["Serum Albumin", "3.5 – 5.0 g/dL", "Low in cirrhosis; needed to calculate SAAG"],
["Total Protein", "6.0 – 8.0 g/dL", "Reduced in chronic liver disease"],
["Serum Bilirubin (Total)", "0.1 – 1.2 mg/dL", "Elevated in hepatic dysfunction"],
["AST (SGOT)", "10 – 40 U/L", "Elevated in hepatitis, alcoholic liver disease"],
["ALT (SGPT)", "7 – 56 U/L", "More specific for hepatocellular damage"],
["Alkaline Phosphatase (ALP)", "44 – 147 U/L", "Elevated in cholestasis, biliary disease"],
["GGT", "8 – 61 U/L", "Raised in alcohol-related liver disease"],
["Prothrombin Time (PT/INR)", "INR 0.8 – 1.1", "Prolonged PT indicates poor hepatic synthetic function"],
["Serum Creatinine", "0.6 – 1.2 mg/dL", "Elevated in hepatorenal syndrome (HRS)"],
["Blood Urea Nitrogen (BUN)", "7 – 20 mg/dL", "Elevated in HRS, dehydration"],
["Serum Electrolytes (Na, K)", "Na 136–145 mEq/L; K 3.5–5.0 mEq/L", "Hyponatraemia common; hyperkalaemia with spironolactone"],
["Serum Glucose", "70 – 100 mg/dL (fasting)", "Reduced in severe hepatic failure"],
["CBC / Full Blood Count", "WBC 4–11 × 10³/µL; Hb ≥12 g/dL", "Leucocytosis in SBP; anaemia of chronic disease"],
["AFP (Alpha-Fetoprotein)", "< 10 ng/mL", "Elevated in hepatocellular carcinoma"],
["CA-125", "< 35 U/mL", "Elevated in ovarian carcinoma, also raised in any ascites"],
["CEA", "< 2.5 ng/mL (non-smoker)", "Elevated in colorectal/gastric carcinoma"],
["CA 19-9", "< 37 U/mL", "Elevated in pancreatic carcinoma"],
["HBsAg / Anti-HCV", "Negative", "Identify viral hepatitis as underlying cause"],
["Thyroid Function (TSH, T4)", "TSH 0.4–4.0 mIU/L", "Hypothyroidism rarely causes ascites (myxoedema)"],
["Serum LDH", "140 – 280 U/L", "Elevated in malignancy, SBP"],
["Serum Amylase / Lipase", "Amylase 25–125 U/L; Lipase 0–160 U/L", "Elevated in pancreatic ascites"],
]
story.append(make_table(serum_data, col_widths=[5.2*cm, 5.5*cm, 6.5*cm]))
story.append(Spacer(1, 6))
# ---- SECTION 2: ASCITIC FLUID ANALYSIS ----
story.append(section_header("2. Ascitic Fluid Analysis (Paracentesis)"))
story.append(Spacer(1, 4))
story.append(Paragraph(
"Ascitic fluid obtained by paracentesis is the cornerstone of aetiological diagnosis. "
"Initial mandatory tests include: cell count with differential, serum-ascites albumin gradient (SAAG), "
"total protein, and culture. A minimum of 30 mL is required for complete evaluation.",
body_style
))
story.append(Spacer(1, 6))
# 2A - Macroscopic
story.append(Paragraph("2A. Macroscopic Appearance", sub_section_style))
macro_data = [
["Appearance", "Interpretation"],
["Clear / Straw-coloured", "Uncomplicated cirrhosis (most common)"],
["Turbid / Cloudy", "Infection (SBP), elevated WBCs or triglycerides (pseudochylous)"],
["Bloody / Haemorrhagic", "Malignancy, trauma, HCC, pancreatitis (homogeneous staining; clots suggest traumatic tap)"],
["Milky / Chylous", "Lymphatic obstruction — lymphoma, retroperitoneal tumour, thoracic duct injury; triglycerides >200 mg/dL"],
["Dark brown", "Biliary leak, ruptured gallbladder, high bilirubin"],
["Viscous / Mucinous", "Pseudomyxoma peritonei"],
]
story.append(make_table(macro_data, col_widths=[5.5*cm, 11.7*cm]))
story.append(Spacer(1, 8))
# 2B - KEY SAAG
story.append(Paragraph("2B. Serum-Ascites Albumin Gradient (SAAG) — The Gold Standard", sub_section_style))
story.append(Paragraph(
"<b>SAAG = Serum albumin – Ascitic fluid albumin</b> (both measured on the same day). "
"The SAAG has replaced the exudate/transudate concept. Diagnostic accuracy is <b>97–98%</b>.",
body_style
))
story.append(Spacer(1, 4))
saag_data = [
["SAAG Value", "Interpretation", "Common Causes"],
["≥ 1.1 g/dL (≥ 11 g/L)", "Portal hypertension-related\n(TRANSUDATE-like)", "Cirrhosis, alcoholic hepatitis,\ncongestive heart failure, Budd-Chiari,\nportal/splenic vein thrombosis,\nfulminant hepatic failure, fatty liver"],
["< 1.1 g/dL (< 11 g/L)", "NON-portal hypertension\n(EXUDATE-like)", "Peritoneal carcinomatosis, tuberculosis,\npancreatic ascites, nephrotic syndrome,\nbiliary peritonitis, connective tissue disease"],
]
story.append(make_table(saag_data, col_widths=[4.0*cm, 5.5*cm, 7.7*cm]))
story.append(Spacer(1, 4))
story.append(Paragraph(
"LR+ for portal hypertension when SAAG ≥1.1: 4.6. LR− when SAAG <1.1: 0.06. "
"(Accuracy 98% vs 52–80% for total protein, LDH, or protein ratios alone.)",
note_style
))
story.append(Spacer(1, 8))
# 2C - Biochemical tests table
story.append(Paragraph("2C. Biochemical Tests on Ascitic Fluid", sub_section_style))
biochem_data = [
["Test", "Normal / Cut-off", "Interpretation / Significance"],
["Total Protein", "< 25 g/L → transudate\n≥ 25–30 g/L → exudate", "Less reliable than SAAG alone; useful adjunct. "
"Cardiac ascites: protein >25 g/L despite high SAAG"],
["Glucose", "Similar to serum (70–100 mg/dL)", "Low in SBP, TB, carcinomatosis "
"(consumed by bacteria/tumour cells or WBCs)"],
["LDH (Lactate Dehydrogenase)", "< 400 U/L\nFluid:serum ratio < 0.6", "Elevated (>400 U/L) in malignancy, SBP; "
"helps identify non-hepatic causes"],
["Amylase", "< 100 U/L\n(or fluid:serum ratio < 1)", "Markedly elevated in pancreatic ascites "
"(ratio >6); also in bowel perforation"],
["Triglycerides", "< 200 mg/dL", "≥ 200 mg/dL confirms chylous ascites; "
"> 1000 mg/dL is diagnostic"],
["Cholesterol", "< 45–48 mg/dL", "≥ 45 mg/dL favours malignant ascites "
"(higher vascular permeability)"],
["Bilirubin", "Fluid:serum ratio < 0.6", "Ratio ≥ 0.6 suggests biliary leak or "
"gut perforation; dark brown fluid"],
["Creatinine", "Similar to serum", "Elevated fluid creatinine > serum suggests "
"bladder/urinary tract rupture (uroperitoneum)"],
["Adenosine Deaminase (ADA)", "< 36 IU/L", "≥ 36–40 IU/L: TB peritonitis "
"(sensitivity 94%, specificity 94%); also raised in lymphoma, RA"],
["pH", "≈ 7.35 – 7.45", "Low pH (<7.35) associated with SBP, "
"malignancy; adds little to PMN count alone"],
["CA-125", "< 35 U/mL", "Elevated in malignant ascites (especially ovarian); "
"non-specific — also elevated in any ascites"],
["CEA / CA 19-9 / AFP", "See serum reference values", "Malignant ascites marker; "
"AFP elevated in HCC-related ascites"],
["Fibronectin", "> 75 µg/mL suggests malignancy", "Adjunct for malignant vs. benign ascites"],
]
story.append(make_table(biochem_data, col_widths=[4.3*cm, 4.5*cm, 8.4*cm]))
story.append(Spacer(1, 8))
# 2D - Cell count
story.append(Paragraph("2D. Cell Count and Differential", sub_section_style))
cell_data = [
["Cell Count Finding", "Cut-off / Value", "Diagnosis / Interpretation"],
["Total WBC", "< 500 cells/µL", "Normal ascitic fluid"],
["PMN (Polymorphonuclear neutrophils) — SBP", "≥ 250 cells/µL", "Spontaneous Bacterial Peritonitis (SBP) — treat empirically, do NOT wait for cultures"],
["PMN — Secondary Bacterial Peritonitis", "Often > 10,000 cells/µL", "Suggests bowel perforation or intraabdominal abscess"],
["Lymphocyte predominance", "> 70% lymphocytes", "Tuberculosis peritonitis, malignancy, chylous ascites"],
["RBCs — haemorrhagic ascites", "> 10,000 RBCs/µL", "Malignancy, trauma, HCC, pancreatitis"],
["RBCs — traumatic tap", "Non-homogeneous; clots form", "Blood clears as fluid drains; not a true haemorrhagic ascites"],
["Eosinophilia", "> 10% eosinophils", "Parasitic infection, vasculitis, eosinophilic gastroenteritis"],
]
story.append(make_table(cell_data, col_widths=[4.5*cm, 4.5*cm, 8.2*cm]))
story.append(Spacer(1, 4))
story.append(Paragraph(
"Note: Sample for cell count must be placed in EDTA tube. Culture bottles (blood culture bottles) "
"should be inoculated at the bedside (10 mL per bottle) to maximise yield.",
note_style
))
story.append(Spacer(1, 8))
# 2E - Microbiology
story.append(Paragraph("2E. Microbiological Tests", sub_section_style))
micro_data = [
["Test", "Method", "Clinical Significance"],
["Gram Stain", "Microscopy", "Sensitivity ~10–20% in SBP; immediate result for secondary peritonitis (polymicrobial = secondary)"],
["Aerobic & Anaerobic Culture", "Blood culture bottles at bedside", "Gold standard for SBP organism ID; sensitivity 85–90% with bedside inoculation vs 40–50% with standard culture tube"],
["AFB (Acid-Fast Bacilli) Smear", "Ziehl-Neelsen stain", "Low sensitivity (~3%) for TB ascites; culture more sensitive (65%)"],
["Mycobacterial Culture (MGIT)", "Liquid culture", "Sensitivity ~65% for TB; takes 2–8 weeks"],
["TB PCR (Molecular)", "Nucleic acid amplification", "Sensitivity 84%, specificity 100% for TB peritonitis; faster than culture"],
["Fungal Culture / KOH", "Microscopy + culture", "In immunocompromised patients; Candida, Cryptococcus"],
]
story.append(make_table(micro_data, col_widths=[3.8*cm, 4.0*cm, 9.4*cm]))
story.append(Spacer(1, 8))
# 2F - Cytology
story.append(Paragraph("2F. Cytology", sub_section_style))
cyto_data = [
["Test", "Indication", "Yield / Note"],
["Cytological examination", "Suspected malignant ascites / peritoneal carcinomatosis", "Positive in ~60–80% of peritoneal carcinomatosis. Requires ≥100 mL for best sensitivity. Negative in >90% of HCC with ascites and usually negative in liver metastases."],
["Cell block preparation", "Immunohistochemistry of malignant cells", "Identifies tumour origin (e.g. CK7/CK20, ER, TTF-1)"],
["Flow cytometry", "Suspected lymphoma", "Immunophenotyping of lymphocytes"],
]
story.append(make_table(cyto_data, col_widths=[3.5*cm, 5.0*cm, 8.7*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 3: SAAG + PROTEIN ALGORITHM ----
story.append(section_header("3. Diagnostic Algorithm — SAAG + Protein"))
story.append(Spacer(1, 6))
algo_data = [
["SAAG", "Ascitic Fluid Protein", "Most Likely Diagnosis"],
["≥ 1.1 g/dL\n(Portal HTN)", "< 25 g/L\n(Low protein)", "Cirrhosis (most common)"],
["≥ 1.1 g/dL\n(Portal HTN)", "≥ 25 g/L\n(High protein)", "Congestive heart failure, Budd-Chiari syndrome, constrictive pericarditis"],
["< 1.1 g/dL\n(Non-portal HTN)", "< 25 g/L\n(Low protein)", "Nephrotic syndrome"],
["< 1.1 g/dL\n(Non-portal HTN)", "≥ 25 g/L\n(High protein)", "Malignancy, TB peritonitis, pancreatitis, secondary bacterial peritonitis"],
]
t = Table(algo_data, colWidths=[4.5*cm, 5.0*cm, 7.7*cm], repeatRows=1)
t.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), HEADER_BG),
("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
("FONTSIZE", (0, 0), (-1, 0), 9),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [WHITE_BG, ALT_BG]),
("FONTNAME", (0, 1), (-1, -1), "Helvetica"),
("FONTSIZE", (0, 1), (-1, -1), 8.8),
("TEXTCOLOR", (0, 1), (-1, -1), colors.HexColor("#222222")),
("GRID", (0, 0), (-1, -1), 0.4, BORDER_CLR),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("TOPPADDING", (0, 0), (-1, -1), 6),
("BOTTOMPADDING", (0, 0), (-1, -1), 6),
("LEFTPADDING", (0, 0), (-1, -1), 6),
("RIGHTPADDING", (0, 0), (-1, -1), 6),
# colour rows
("BACKGROUND", (0, 1), (-1, 2), colors.HexColor("#d6eaf8")),
("BACKGROUND", (0, 3), (-1, 4), colors.HexColor("#fde8d8")),
]))
story.append(t)
story.append(Spacer(1, 8))
# ---- SECTION 4: IMAGING ----
story.append(section_header("4. Imaging Investigations"))
story.append(Spacer(1, 4))
imaging_data = [
["Modality", "Findings / Role"],
["Abdominal Ultrasound (USG)", "First-line; detects ≥100 mL fluid; identifies loculation, liver texture (cirrhosis), portal hypertension, splenomegaly, Doppler for portal vein flow; guides paracentesis"],
["CT Abdomen + Pelvis", "Identifies cause (liver lesions, peritoneal deposits, lymphadenopathy, pancreatic disease); staging of malignancy"],
["MRI Abdomen", "Better soft tissue characterisation; useful when CT contrast is contraindicated (renal failure)"],
["Portal Venous Doppler", "Assesses portal vein patency, flow velocity; detects Budd-Chiari (hepatic vein thrombosis)"],
["Echocardiography", "Rules out congestive cardiac failure, constrictive pericarditis as cause of ascites"],
["Chest X-Ray", "May show pleural effusions (hepatic hydrothorax); cardiomegaly (cardiac ascites)"],
]
story.append(make_table(imaging_data, col_widths=[5.0*cm, 12.2*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 5: Additional Specialised ----
story.append(section_header("5. Additional Specialised Investigations"))
story.append(Spacer(1, 4))
special_data = [
["Investigation", "Indication", "Cut-off / Result"],
["Serum-Urine Electrolytes (24-hr Na)", "Monitor diuretic response", "Urinary Na > 78 mEq/day indicates adequate natriuresis"],
["Spot Urine Na:K ratio", "Diuretic monitoring", "Ratio > 1 suggests adequate response to spironolactone"],
["HVPG (Hepatic Venous Pressure Gradient)", "Assess portal hypertension severity", "Normal <5 mmHg; ≥10 mmHg = clinically significant portal HTN; ≥12 mmHg = risk of variceal bleed"],
["Liver Biopsy", "Confirm cirrhosis histology, assess fibrosis", "Metavir F4 = cirrhosis; also for infiltrative disease"],
["Serum-Ascites Bilirubin Ratio", "Biliary peritonitis/gut perforation", "Ratio ≥ 0.6 indicates biliary communication"],
["Peritoneal Biopsy / Laparoscopy", "TB, peritoneal carcinomatosis", "When cytology negative, ADA elevated, or malignancy suspected"],
["Cardiac BNP / NT-proBNP", "Cardiac ascites", "> 300–400 pg/mL: cardiac cause likely"],
["Serum Cortisol / Aldosterone", "Adrenal causes", "Rule out adrenal insufficiency in refractory cases"],
["TIPS Assessment (Angiography)", "Refractory ascites", "Portal gradient reduction goal <12 mmHg post-TIPS"],
]
story.append(make_table(special_data, col_widths=[5.0*cm, 5.5*cm, 6.7*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 6: QUICK REFERENCE BOX ----
story.append(section_header("6. Quick Reference — Ascitic Fluid Diagnostic Criteria Summary"))
story.append(Spacer(1, 4))
qr_data = [
["Condition", "Key Diagnostic Finding"],
["Spontaneous Bacterial Peritonitis (SBP)", "PMN ≥ 250 cells/µL; positive culture (often monomicrobial: E. coli, Klebsiella, S. pneumoniae)"],
["Malignant Ascites", "SAAG < 1.1 g/dL; protein ≥ 25 g/L; positive cytology; raised LDH (>400 U/L); raised cholesterol (>45 mg/dL)"],
["TB Peritonitis", "SAAG < 1.1 g/dL; ADA ≥ 36–40 IU/L; lymphocyte predominance; AFB culture positive; PCR specific"],
["Pancreatic Ascites", "SAAG < 1.1 g/dL; amylase very high (>1000 U/L; fluid:serum ratio >6); lipase elevated"],
["Chylous Ascites", "Milky fluid; triglycerides > 200 mg/dL (diagnostic >1000 mg/dL); Sudan red fat droplets"],
["Cardiac / Budd-Chiari Ascites", "SAAG ≥ 1.1 g/dL + protein ≥ 25 g/L; abnormal Doppler / echo"],
["Hepatic Cirrhosis", "SAAG ≥ 1.1 g/dL; protein < 25 g/L; PMN < 250 cells/µL (unless SBP)"],
["Biliary Peritonitis", "SAAG < 1.1 g/dL; fluid:serum bilirubin ratio ≥ 0.6; dark brown fluid; elevated ALP"],
["Uroperitoneum", "SAAG < 1.1 g/dL; fluid creatinine > serum creatinine; fluid:serum creatinine ratio > 1"],
["Nephrotic Syndrome", "SAAG < 1.1 g/dL; protein < 25 g/L; proteinuria on urine dipstick; hypoalbuminaemia"],
]
story.append(make_table(qr_data, col_widths=[5.8*cm, 11.4*cm]))
story.append(Spacer(1, 8))
# ---- REFERENCES ----
story.append(HRFlowable(width="100%", thickness=0.7, color=colors.HexColor("#adc4e0"), spaceAfter=6))
story.append(Paragraph("<b>Sources</b>", ParagraphStyle("ref_head", parent=styles["Normal"], fontName="Helvetica-Bold", fontSize=9, textColor=colors.HexColor("#1a3a5c"))))
refs = [
"1. Henry's Clinical Diagnosis and Management by Laboratory Methods (9780323673204) — Chapter 30: Peritoneal Fluid",
"2. Tietz Textbook of Laboratory Medicine, 7th Edition (9780323775724) — Chapter 45: Body Fluids",
"3. Sleisenger and Fordtran's Gastrointestinal and Liver Disease (9780323609623)",
"4. Yamada's Textbook of Gastroenterology, 7th Edition (9781119600169) — Chapter 105",
"5. Symptom to Diagnosis: An Evidence-Based Guide, 4th Edition (9781260121117)",
"6. Goldman-Cecil Medicine International Edition (9780323930345) — Ascites Chapter",
"7. ROSEN's Emergency Medicine: Concepts and Clinical Practice (9780323757898)",
]
for r in refs:
story.append(Paragraph(r, note_style))
story.append(Spacer(1, 6))
story.append(Paragraph(
"Generated by Orris AI Medical Assistant | July 2026 | For educational purposes only. "
"Always correlate with clinical findings and local guidelines.",
footer_style
))
# ------------------------------------------------------------------
# Build
# ------------------------------------------------------------------
doc.build(story)
print(f"PDF created: {OUTPUT}")
cd /home/daytona/workspace/ascites-pdf && python generate_ascites_pdf.py 2>&1
ls -lh /home/daytona/workspace/ascites-pdf/Ascites_Laboratory_Investigations.pdf
Ascites Laboratory Investigations
PDF Document · PDF
| Test | Key Value | Significance |
|---|---|---|
| SAAG | ≥ 1.1 g/dL = Portal HTN | Gold standard; 97–98% accurate |
| PMN count | ≥ 250 cells/µL | Diagnoses SBP - treat empirically |
| Total Protein | ≥ 25 g/L = exudate | Used with SAAG for classification |
| Glucose | Low in SBP, TB | Consumed by bacteria/WBCs |
| LDH | > 400 U/L = malignancy/SBP | Fluid:serum ratio < 0.6 = normal |
| Amylase | Very high (>1000 U/L) | Pancreatic ascites |
| Triglycerides | > 200 mg/dL | Chylous ascites |
| ADA | ≥ 36–40 IU/L | TB peritonitis (Sn 94%, Sp 94%) |
| Cytology | Positive | Peritoneal carcinomatosis |
| TB PCR | Sn 84%, Sp 100% | Rapid TB diagnosis |
Give laboratory investigations for rheumatoid arthritis with findings and values in pdf format
~/ra-pdf/generate_ra_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table,
TableStyle, HRFlowable, KeepTogether)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
import os
os.makedirs("/home/daytona/workspace/ra-pdf", exist_ok=True)
OUTPUT = "/home/daytona/workspace/ra-pdf/Rheumatoid_Arthritis_Laboratory_Investigations.pdf"
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
rightMargin=2*cm, leftMargin=2*cm,
topMargin=2.2*cm, bottomMargin=2.2*cm,
title="Laboratory Investigations for Rheumatoid Arthritis"
)
styles = getSampleStyleSheet()
title_style = ParagraphStyle("TitleStyle", parent=styles["Title"],
fontSize=20, textColor=colors.HexColor("#6b1a1a"),
spaceAfter=4, fontName="Helvetica-Bold", alignment=TA_CENTER)
subtitle_style = ParagraphStyle("SubtitleStyle", parent=styles["Normal"],
fontSize=11, textColor=colors.HexColor("#a03030"),
spaceAfter=14, fontName="Helvetica", alignment=TA_CENTER)
section_style = ParagraphStyle("SectionStyle", parent=styles["Heading1"],
fontSize=12, textColor=colors.white, spaceBefore=14, spaceAfter=4,
fontName="Helvetica-Bold", backColor=colors.HexColor("#6b1a1a"), borderPad=5)
sub_section_style = ParagraphStyle("SubSectionStyle", parent=styles["Heading2"],
fontSize=11, textColor=colors.HexColor("#6b1a1a"),
spaceBefore=8, spaceAfter=3, fontName="Helvetica-Bold")
body_style = ParagraphStyle("BodyStyle", parent=styles["Normal"],
fontSize=9.5, textColor=colors.HexColor("#222222"),
spaceAfter=4, fontName="Helvetica", leading=14, alignment=TA_JUSTIFY)
note_style = ParagraphStyle("NoteStyle", parent=styles["Normal"],
fontSize=8.5, textColor=colors.HexColor("#555555"),
spaceAfter=4, fontName="Helvetica-Oblique", leftIndent=8, leading=12)
footer_style = ParagraphStyle("FooterStyle", parent=styles["Normal"],
fontSize=8, textColor=colors.HexColor("#888888"), alignment=TA_CENTER)
HEADER_BG = colors.HexColor("#6b1a1a")
ALT_BG = colors.HexColor("#f7eaea")
WHITE_BG = colors.white
BORDER_CLR = colors.HexColor("#d4a0a0")
def make_table(data, col_widths=None, alt=True):
t = Table(data, colWidths=col_widths, repeatRows=1)
t.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,0), HEADER_BG),
("TEXTCOLOR", (0,0),(-1,0), colors.white),
("FONTNAME", (0,0),(-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0),(-1,0), 9),
("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE_BG, ALT_BG] if alt else [WHITE_BG]),
("FONTNAME", (0,1),(-1,-1), "Helvetica"),
("FONTSIZE", (0,1),(-1,-1), 8.8),
("TEXTCOLOR", (0,1),(-1,-1), colors.HexColor("#222222")),
("GRID", (0,0),(-1,-1), 0.4, BORDER_CLR),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING",(0,0),(-1,-1), 6),
("RIGHTPADDING",(0,0),(-1,-1), 6),
]))
return t
def section_header(text):
return Paragraph(f" {text}", section_style)
story = []
# ---- TITLE ----
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("Laboratory Investigations for Rheumatoid Arthritis", title_style))
story.append(Paragraph("Comprehensive Reference with Diagnostic Values, Sensitivity & Specificity", subtitle_style))
story.append(HRFlowable(width="100%", thickness=2, color=colors.HexColor("#a03030"), spaceAfter=10))
story.append(Paragraph(
"Rheumatoid arthritis (RA) is a systemic autoimmune disorder characterised by chronic, symmetric, "
"erosive arthritis of peripheral joints, with associated extra-articular manifestations. "
"RA is a <b>clinical diagnosis</b> confirmed by laboratory testing interpreted in clinical context. "
"Autoantibodies (RF, anti-CCP/ACPA) may precede clinical onset by years and serve as both diagnostic "
"and prognostic biomarkers. The 2010 ACR/EULAR classification criteria require a score ≥6/10 for diagnosis.",
body_style
))
story.append(Spacer(1, 6))
# ---- SECTION 1: SEROLOGICAL / AUTOANTIBODY TESTS ----
story.append(section_header("1. Serological / Autoantibody Tests"))
story.append(Spacer(1, 4))
sero_data = [
["Test", "Normal / Cut-off", "Finding in RA", "Sensitivity", "Specificity", "Clinical Notes"],
["Rheumatoid Factor (RF) — IgM",
"< 14–20 IU/mL\n(lab-dependent)",
"Positive (elevated titre)",
"66–85%", "72%",
"Directed against Fc portion of IgG. Present in 70–80% of RA. "
"False positives in chronic infections (TB, EBV, SBE), SLE, Sjögren's, healthy elderly. "
"High titre → more severe disease, nodules, vasculitis. "
"Seronegative RA (~15–20%) exists."],
["Anti-CCP (Anti-Cyclic Citrullinated Peptide) — 2nd gen ELISA",
"< 20 U/mL\n(negative)",
"Positive",
"73%", "95–98%",
"Most specific RA marker. May precede clinical onset by up to 10 years. "
"Positive anti-CCP linked to more severe joint erosions. "
"Useful when RF negative. Also raised in TB and some other autoimmune conditions."],
["RF IgA",
"Negative",
"Positive in severe RA",
"~60%", "~85%",
"Associated with more aggressive disease and erosions. "
"Not routinely ordered but has prognostic value."],
["Anti-Sa (Citrullinated Vimentin)",
"Negative",
"Positive in seropositive RA",
"42%", "92–98%",
"Highly specific; useful in RF-negative / anti-CCP borderline cases."],
["Anticarbamylated Proteins (anti-CarP)",
"Negative",
"May be positive",
"45–67%", "70–94%",
"Seen in seronegative RA; can predict transition from undifferentiated to RA."],
["Anti-PAD4 Antibodies",
"Negative",
"Positive in ~30–38%",
"30–38%", "96%",
"Biomarker for severe, erosive RA. PAD4 citrullinates fibrinogen, vimentin, and histones."],
["ANA (Antinuclear Antibodies)",
"< 1:40 titre\n(negative)",
"Positive in 30% of RA",
"30% (non-specific)", "Low",
"Low titre often present in RA. High titres favour SLE, Sjögren's, or scleroderma. "
"Helps exclude other autoimmune diagnoses."],
["Anti-dsDNA",
"< 10 IU/mL\n(negative)",
"Negative in RA",
"—", "—",
"Positive in SLE. Useful to differentiate SLE from RA."],
["Anti-Sm",
"Negative",
"Negative in RA",
"—", "—",
"Highly specific for SLE. Negative in RA."],
["ANCA (MPO / PR3)",
"Negative",
"Usually negative",
"—", "—",
"May be positive in RA-associated vasculitis or overlap with other vasculitides."],
["HLA-DR4 (Shared Epitope)",
"Not a routine\ndiagnostic test",
"Present in ~70% of RA\n(esp. DRB1*04:01, *04:04)",
"~70%", "Moderate",
"Genetic risk marker; associated with more severe erosive disease and extra-articular features. "
"Not routinely ordered clinically but used in research/prognostication."],
]
story.append(make_table(sero_data, col_widths=[3.8*cm, 2.8*cm, 2.8*cm, 1.8*cm, 1.8*cm, 4.2*cm]))
story.append(Spacer(1, 4))
story.append(Paragraph(
"Key point: RF + anti-CCP both positive → very high specificity for RA; combined, they strongly confirm "
"seropositive RA and predict more erosive, aggressive disease course. Seronegative RA (RF and anti-CCP both "
"negative) occurs in ~15–20% of patients and is diagnosed on clinical grounds.",
note_style
))
story.append(Spacer(1, 8))
# ---- SECTION 2: ACUTE PHASE REACTANTS & INFLAMMATORY MARKERS ----
story.append(section_header("2. Acute Phase Reactants & Inflammatory Markers"))
story.append(Spacer(1, 4))
apr_data = [
["Test", "Normal Value", "Finding in RA", "Clinical Significance"],
["ESR (Erythrocyte Sedimentation Rate)",
"Males: < 15 mm/hr\nFemales: < 20 mm/hr\n(age-adjusted: age/2 for males,\nage+10/2 for females)",
"Elevated (often 30–100+ mm/hr in active disease)",
"Sensitive but non-specific marker of inflammation. Correlates with disease activity. "
"Used to monitor treatment response (target normalisation). Rises more slowly than CRP."],
["CRP (C-Reactive Protein)",
"< 5 mg/L\n(< 1 mg/L high-sensitivity)",
"Elevated (often 10–100 mg/L in active disease)",
"More specific and responsive than ESR. Rises within hours of inflammation onset. "
"More reliable for monitoring disease activity and therapeutic response. "
"Better correlates with joint damage progression."],
["Serum Ferritin",
"12–300 ng/mL (males)\n12–150 ng/mL (females)",
"Elevated (acute phase reactant)",
"Markedly elevated in Still's disease / systemic JIA. Moderately raised in active RA. "
"Very high levels (>500 ng/mL) may suggest macrophage activation syndrome."],
["Serum Fibrinogen",
"200–400 mg/dL",
"Elevated in active disease",
"Acute phase protein. Elevation correlates with disease activity."],
["Complement (C3, C4, CH50)",
"C3: 90–180 mg/dL\nC4: 16–47 mg/dL",
"Normal or elevated (RA)\nDecreased (SLE, vasculitis)",
"Complements are normal or increased in RA (positive acute phase reactants). "
"Low complement differentiates SLE from RA. Helpful in distinguishing RA from lupus arthritis."],
["Serum Albumin",
"3.5–5.0 g/dL",
"Low in severe/active RA",
"Negative acute phase reactant. Falls with active inflammation. "
"Also reflects nutritional status and treatment with corticosteroids."],
["Serum Globulins (Total)",
"2.0–3.5 g/dL",
"Elevated (hypergammaglobulinaemia)",
"Polyclonal hypergammaglobulinaemia seen in active RA, reflecting immune activation."],
["Serum Uric Acid",
"Males: 3.5–7.2 mg/dL\nFemales: 2.6–6.0 mg/dL",
"Normal in RA",
"Measured to exclude gout (which can mimic or co-exist with RA). "
"Normal or low in RA (elevated in gout). Low levels also seen in RA patients on certain DMARDs."],
]
story.append(make_table(apr_data, col_widths=[4.0*cm, 4.0*cm, 3.5*cm, 5.7*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 3: COMPLETE BLOOD COUNT ----
story.append(section_header("3. Complete Blood Count (CBC / FBC)"))
story.append(Spacer(1, 4))
cbc_data = [
["Parameter", "Normal Value", "Finding in RA", "Interpretation"],
["Haemoglobin (Hb)",
"Males: 13.5–17.5 g/dL\nFemales: 12.0–16.0 g/dL",
"Low (10–12 g/dL typically)",
"Normochromic, normocytic anaemia of chronic disease (most common). "
"Occasionally microcytic (iron deficiency from GI blood loss due to NSAIDs). "
"Rarely haemolytic anaemia."],
["MCV (Mean Corpuscular Volume)",
"80–100 fL",
"Normal or low",
"Normal in ACD; low (<80 fL) suggests iron deficiency (NSAID-related GI bleed). "
"High MCV (macrocytosis) with methotrexate therapy — indicates folate deficiency."],
["WBC (Total Leukocyte Count)",
"4.0–11.0 × 10³/µL",
"Usually normal",
"Mild leucocytosis in severe/systemic RA. "
"Leucopenia (< 4000/µL) with Felty syndrome (RA + splenomegaly + neutropenia). "
"Neutropenia also a side effect of DMARDs (methotrexate, leflunomide, rituximab)."],
["Neutrophils",
"2.0–7.5 × 10³/µL",
"Normal; low in Felty syndrome",
"Neutropenia (<1500/µL) defines Felty syndrome. Monitor on DMARDs."],
["Lymphocytes",
"1.0–4.8 × 10³/µL",
"Usually normal",
"Lymphopenia may occur with methotrexate, azathioprine, or cyclophosphamide therapy."],
["Eosinophils",
"0.05–0.5 × 10³/µL",
"May be mildly elevated",
"Eosinophilia in ~20% of RA; can also occur in vasculitis or drug reactions."],
["Platelets (Thrombocytes)",
"150–400 × 10³/µL",
"Often elevated\n(400–700 × 10³/µL)",
"Reactive thrombocytosis is an acute phase response correlating with disease activity. "
"Thrombocytopenia with Felty syndrome, gold therapy, or methotrexate toxicity."],
]
story.append(make_table(cbc_data, col_widths=[3.5*cm, 4.0*cm, 3.5*cm, 6.2*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 4: SYNOVIAL FLUID ----
story.append(section_header("4. Synovial Fluid Analysis"))
story.append(Spacer(1, 4))
story.append(Paragraph(
"Joint aspiration (arthrocentesis) provides definitive information about joint inflammation. "
"In RA, the synovial fluid is characteristically inflammatory but sterile. "
"Aspiration is essential to exclude septic arthritis and crystal arthropathies.",
body_style
))
story.append(Spacer(1, 6))
sf_data = [
["Parameter", "Normal", "RA (Inflammatory)", "Septic Arthritis", "Gout / CPPD"],
["Appearance", "Clear, colourless\n–pale yellow", "Turbid, yellow-white,\nstraw to opalescent", "Purulent,\nopaque, creamy", "Turbid or\ncloudy"],
["Viscosity", "High (viscous)", "Reduced / low", "Very low", "Low to normal"],
["WBC Count", "< 200 cells/mm³\n(< 0.2 × 10⁹/L)", "2,000–50,000/mm³\n(typically 10,000–20,000)", "> 50,000–100,000/mm³", "2,000–50,000/mm³"],
["Neutrophils (%)", "< 25%", "> 75% PMNs", "> 90% PMNs", "60–95% PMNs"],
["Glucose", "~Blood glucose\n(70–100 mg/dL)", "Decreased; serum–fluid\ndifference > 30 mg/dL", "Very low\n(< 40 mg/dL or\n< 50% serum)", "Normal"],
["Protein", "< 20 g/L", "Elevated (> 30 g/L)", "Very elevated\n(> 40 g/L)", "Elevated"],
["LDH", "< Serum", "Elevated", "Markedly elevated", "Elevated"],
["Complement\n(C3, C4, CH50)", "~33% of serum", "Decreased (<33% of serum)", "Variable", "Normal"],
["Culture / Gram Stain", "Negative", "Negative\n(sterile)", "Positive (50–80%)\nGram stain ~50%", "Negative"],
["Crystals", "None", "None\n(no crystals)", "None", "Monosodium urate\n(gout) — needle-shaped\nnegative birefringent;\nor CPPD — rhomboid\npositive birefringent"],
["RF in Synovial Fluid", "Absent", "Present", "Variable", "Absent"],
["Mucin Clot Test", "Firm, ropy clot", "Poor, friable clot", "Very poor clot", "Fair clot"],
]
story.append(make_table(sf_data, col_widths=[3.0*cm, 3.2*cm, 3.8*cm, 3.3*cm, 3.9*cm]))
story.append(Spacer(1, 4))
story.append(Paragraph(
"RA hallmark: Synovial fluid WBC 10,000–20,000 cells/mm³ (minimum >2,000) with >75% PMNs, "
"sterile culture, no crystals. Synovial complement CH50 lower than serum (consumed by immune complexes). "
"Serum–synovial fluid glucose difference typically >30 mg/dL.",
note_style
))
story.append(Spacer(1, 8))
# ---- SECTION 5: RENAL AND METABOLIC / DRUG MONITORING ----
story.append(section_header("5. Metabolic, Renal & Liver Function Tests — Disease & Drug Monitoring"))
story.append(Spacer(1, 4))
metabolic_data = [
["Test", "Normal Value", "Finding / Significance"],
["Serum Creatinine & eGFR", "Creatinine 0.6–1.2 mg/dL;\neGFR > 60 mL/min/1.73m²",
"Renal involvement in RA (membranous nephropathy, AA amyloidosis). "
"Essential baseline before starting NSAIDs, methotrexate, gold, cyclosporin."],
["Liver Function Tests (AST, ALT, ALP, GGT)",
"AST 10–40 U/L; ALT 7–56 U/L;\nALP 44–147 U/L",
"Hepatotoxicity monitoring with methotrexate and leflunomide. "
"Elevated transaminases → dose reduction or discontinuation. Baseline required."],
["Serum Albumin", "3.5–5.0 g/dL",
"Low in active RA. Also monitors nutritional status. "
"Important for drug binding (e.g. methotrexate)."],
["Blood Glucose (Fasting)", "70–100 mg/dL",
"Corticosteroid therapy causes glucose intolerance/diabetes mellitus. "
"Monitor glycaemia regularly in patients on long-term steroids."],
["Serum Lipid Profile\n(TC, LDL, HDL, TG)",
"TC < 200 mg/dL;\nLDL < 100 mg/dL;\nHDL > 40 (M) / 50 (F) mg/dL;\nTG < 150 mg/dL",
"RA is an independent cardiovascular risk factor. Dyslipidaemia is common. "
"Tocilizumab raises LDL. Corticosteroids raise cholesterol. Baseline + periodic monitoring required."],
["Bone Profile (Ca, PO4, ALP)",
"Ca 8.5–10.5 mg/dL;\nPO4 2.5–4.5 mg/dL",
"Osteoporosis is a common complication. "
"Low Ca and ALP may indicate osteomalacia in vitamin D deficient patients on corticosteroids."],
["25-OH Vitamin D", "30–80 ng/mL\n(< 20 ng/mL = deficient)",
"Deficiency common in RA; associated with disease activity and bone loss. "
"Supplement in all patients on long-term steroids."],
["Serum Uric Acid", "Males: 3.5–7.2 mg/dL;\nFemales: 2.6–6.0 mg/dL",
"Normal in RA. Low levels may be seen with some DMARDs. "
"Elevated in gout (differential diagnosis)."],
["Thyroid Function (TSH)", "0.4–4.0 mIU/L",
"Autoimmune thyroid disease co-exists with RA in ~10% of patients. "
"Hypothyroidism can exacerbate fatigue and joint symptoms."],
["Urinalysis (Protein, Cells)",
"No protein; no cells",
"Proteinuria with amyloidosis (AA), gold nephropathy, penicillamine toxicity. "
"Haematuria may indicate vasculitis or drug nephrotoxicity."],
]
story.append(make_table(metabolic_data, col_widths=[4.0*cm, 4.2*cm, 9.0*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 6: IMAGING ----
story.append(section_header("6. Imaging Investigations"))
story.append(Spacer(1, 4))
imaging_data = [
["Modality", "Findings in RA"],
["Plain X-Ray (hands, wrists, feet — PA view)",
"Early: periarticular soft tissue swelling, juxta-articular osteopenia (periarticular bone loss). "
"Late: marginal bone erosions (MCP, PIP, wrist), uniform joint space narrowing, subluxation, "
"ulnar deviation of MCP joints, swan-neck / boutonniere deformities, carpal collapse."],
["Ultrasound (musculoskeletal)",
"Detects synovitis, tenosynovitis, power Doppler signal (active inflammation), effusions, "
"erosions earlier than plain X-ray. Guides diagnostic and therapeutic joint injections. "
"More sensitive than clinical exam for subclinical synovitis."],
["MRI (joint MRI)",
"Most sensitive for early erosions, bone marrow oedema, synovitis, and tendon involvement. "
"RAMRIS (RA MRI Scoring) used for disease progression. "
"Detects pannus formation and cartilage loss."],
["DEXA (Dual-Energy X-Ray Absorptiometry)",
"Measures BMD; T-score ≤ −2.5 = osteoporosis; T-score −1.0 to −2.5 = osteopenia. "
"Baseline and periodic monitoring in RA patients on corticosteroids. "
"Essential for fracture risk assessment."],
["CT (Computed Tomography)",
"Better evaluation of complex erosions in small joints and cervical spine (C1–C2 subluxation). "
"Not first-line for routine RA monitoring."],
["Echocardiography",
"Pericardial effusion, myocarditis in extra-articular RA. "
"Baseline before biologic therapy in patients with cardiac risk."],
]
story.append(make_table(imaging_data, col_widths=[4.5*cm, 12.7*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 7: 2010 ACR/EULAR CRITERIA SCORING ----
story.append(section_header("7. 2010 ACR/EULAR Classification Criteria for RA (Score ≥ 6/10 = Definite RA)"))
story.append(Spacer(1, 4))
criteria_data = [
["Domain", "Score"],
["A. JOINT INVOLVEMENT", ""],
["1 large joint (shoulder, elbow, hip, knee, ankle)", "0"],
["2–10 large joints", "1"],
["1–3 small joints (MCP, PIP, 2nd–5th MTP, thumb IP, wrist)", "2"],
["4–10 small joints", "3"],
["> 10 joints (including ≥1 small joint)", "5"],
["B. SEROLOGY", ""],
["Negative RF AND negative anti-CCP", "0"],
["Low positive RF OR anti-CCP (> ULN to ≤ 3× ULN)", "2"],
["High positive RF OR anti-CCP (> 3× ULN)", "3"],
["C. ACUTE PHASE REACTANTS", ""],
["Normal CRP AND normal ESR", "0"],
["Abnormal CRP OR abnormal ESR", "1"],
["D. DURATION OF SYMPTOMS", ""],
["< 6 weeks", "0"],
["≥ 6 weeks", "1"],
]
t = Table(criteria_data, colWidths=[14.5*cm, 2.7*cm], repeatRows=1)
t.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,0), HEADER_BG),
("TEXTCOLOR", (0,0),(-1,0), colors.white),
("FONTNAME", (0,0),(-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0),(-1,0), 9.5),
("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE_BG, ALT_BG]),
("FONTNAME", (0,1),(-1,-1), "Helvetica"),
("FONTSIZE", (0,1),(-1,-1), 9),
("TEXTCOLOR", (0,1),(-1,-1), colors.HexColor("#222222")),
("GRID", (0,0),(-1,-1), 0.4, BORDER_CLR),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING",(0,0),(-1,-1), 8),
("RIGHTPADDING",(0,0),(-1,-1), 6),
# Bold section headings
("BACKGROUND", (0,1),(-1,1), colors.HexColor("#c46060")),
("TEXTCOLOR", (0,1),(-1,1), colors.white),
("FONTNAME", (0,1),(-1,1), "Helvetica-Bold"),
("BACKGROUND", (0,7),(-1,7), colors.HexColor("#c46060")),
("TEXTCOLOR", (0,7),(-1,7), colors.white),
("FONTNAME", (0,7),(-1,7), "Helvetica-Bold"),
("BACKGROUND", (0,11),(-1,11), colors.HexColor("#c46060")),
("TEXTCOLOR", (0,11),(-1,11), colors.white),
("FONTNAME", (0,11),(-1,11), "Helvetica-Bold"),
("BACKGROUND", (0,14),(-1,14), colors.HexColor("#c46060")),
("TEXTCOLOR", (0,14),(-1,14), colors.white),
("FONTNAME", (0,14),(-1,14), "Helvetica-Bold"),
]))
story.append(t)
story.append(Spacer(1, 4))
story.append(Paragraph(
"Score ≥ 6/10 = Definite RA. Score 0–5 = Not classifiable as RA at this time; "
"reassess with time. Applies to patients with ≥1 joint with definite clinical synovitis "
"not explained by another diagnosis. (2010 ACR/EULAR criteria — Aletaha et al., Arthritis Rheum 2010)",
note_style
))
story.append(Spacer(1, 8))
# ---- SECTION 8: SPECIALISED & SCREENING TESTS ----
story.append(section_header("8. Pre-Treatment Screening & Monitoring Panel"))
story.append(Spacer(1, 4))
monitor_data = [
["Test", "When / Why"],
["Chest X-Ray + TB screening (IGRA / Mantoux)", "Before biologic therapy (TNF inhibitors, rituximab, JAK inhibitors). Latent TB must be excluded and treated prior to biologics."],
["HIV, HBV (HBsAg, anti-HBc), HCV serology", "Before rituximab and TNF inhibitors. HBV reactivation risk is high."],
["Varicella zoster IgG titre", "Before rituximab / JAK inhibitors; vaccination if non-immune (live vaccines contraindicated on biologics)."],
["Pregnancy test (urine/serum β-hCG)", "Before methotrexate, leflunomide (highly teratogenic — Category X)."],
["Full blood count (CBC) baseline + monitoring", "Baseline before DMARDs; monthly for first 3 months, then quarterly. Flag: Hb <10 g/dL, WBC <3.0 × 10³/µL, platelet <150 × 10³/µL."],
["LFTs (AST/ALT) — methotrexate monitoring", "Every 4–8 weeks on methotrexate. ALT/AST >3× ULN = dose reduction. Persistent elevation = liver biopsy."],
["Serum creatinine / eGFR", "Baseline and every 3–6 months. NSAIDs and cyclosporin are nephrotoxic."],
["Lipid profile", "Baseline; repeat 4–8 weeks after starting tocilizumab or corticosteroids. JAK inhibitors also affect lipids."],
["DEXA scan (bone mineral density)", "Baseline in all patients starting long-term corticosteroids. Repeat every 1–2 years."],
["25-OH Vitamin D level", "At diagnosis and annually. Supplement if <30 ng/mL (especially with steroids)."],
["DAS28 Score (Disease Activity Score)", "Composite score using: tender joint count (TJC28), swollen joint count (SJC28), ESR or CRP, and patient global assessment (VAS 0–100 mm). "
"Remission: DAS28-ESR < 2.6. Low activity: 2.6–3.2. Moderate: 3.2–5.1. High: > 5.1."],
["CDAI / SDAI Score", "Clinical Disease Activity Index (CDAI) uses TJC28 + SJC28 + evaluator + patient global assessment. Remission CDAI ≤2.8. Avoids lab results — useful at clinic."],
]
story.append(make_table(monitor_data, col_widths=[5.5*cm, 11.7*cm]))
story.append(Spacer(1, 8))
# ---- SECTION 9: QUICK REFERENCE SUMMARY ----
story.append(section_header("9. Quick Reference — Autoantibody Comparison in RA vs Mimics"))
story.append(Spacer(1, 4))
qr_data = [
["Autoantibody / Test", "RA", "SLE", "Sjögren's", "Gout", "OA", "Septic Arthritis"],
["RF", "++", "+", "++", "-", "–/+", "–"],
["Anti-CCP (ACPA)", "+++", "–/+","–", "–", "–", "–"],
["ANA", "+", "+++","+/++", "–", "–", "–"],
["Anti-dsDNA", "–", "+++","–", "–", "–", "–"],
["Anti-Sm", "–", "+++","–", "–", "–", "–"],
["Anti-Ro/La", "–/+", "+/+","+++", "–", "–", "–"],
["ANCA", "–/+", "–", "–", "–", "–", "–"],
["ESR / CRP", "+++", "+++","++", "+++","–/+", "+++"],
["Complement", "N/↑", "↓↓", "N/↓", "N", "N", "N/↑"],
["Synovial WBC", "2,000–20,000\n(>75% PMNs)", "2,000–5,000", "2,000–10,000", "2,000–100,000\n(>80% PMNs)", "<2,000", ">50,000–100,000\n(>90% PMNs)"],
["Crystals in joint", "None", "None","None", "MSU (gout)\nCPPD (pseudo-gout)", "CPPD (late)", "None"],
["Uric Acid", "N", "N", "N", "↑↑", "N", "N"],
]
t2 = Table(qr_data, colWidths=[3.5*cm, 2.4*cm, 2.0*cm, 2.2*cm, 2.0*cm, 1.8*cm, 3.3*cm], repeatRows=1)
t2.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,0), HEADER_BG),
("TEXTCOLOR", (0,0),(-1,0), colors.white),
("FONTNAME", (0,0),(-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0),(-1,0), 8.5),
("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE_BG, ALT_BG]),
("FONTNAME", (0,1),(-1,-1), "Helvetica"),
("FONTSIZE", (0,1),(-1,-1), 8.2),
("TEXTCOLOR", (0,1),(-1,-1), colors.HexColor("#222222")),
("GRID", (0,0),(-1,-1), 0.4, BORDER_CLR),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
("ALIGN", (1,0),(-1,-1), "CENTER"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING",(0,0),(-1,-1), 5),
("RIGHTPADDING",(0,0),(-1,-1), 5),
]))
story.append(t2)
story.append(Spacer(1, 4))
story.append(Paragraph(
"Key: +++ = strongly positive / highly characteristic; ++ = often positive; + = sometimes positive; "
"–/+ = usually negative; – = typically absent; N = normal; ↑ = elevated; ↓ = decreased. "
"MSU = monosodium urate; CPPD = calcium pyrophosphate dihydrate; OA = osteoarthritis.",
note_style
))
story.append(Spacer(1, 8))
# ---- REFERENCES ----
story.append(HRFlowable(width="100%", thickness=0.7, color=BORDER_CLR, spaceAfter=6))
story.append(Paragraph("<b>Sources</b>", ParagraphStyle("ref_head", parent=styles["Normal"],
fontName="Helvetica-Bold", fontSize=9, textColor=colors.HexColor("#6b1a1a"))))
refs = [
"1. Henry's Clinical Diagnosis and Management by Laboratory Methods (9780323673204) — Ch. 53: Autoantibodies in Rheumatoid Arthritis",
"2. Tietz Textbook of Laboratory Medicine, 7th Edition (9780323775724) — Ch. 45: Synovial Fluid",
"3. Textbook of Family Medicine, 9th Edition (9780323239905) — Ch. 32: Rheumatoid Arthritis",
"4. Firestein & Kelley's Textbook of Rheumatology, 2-Volume Set (9780323935364)",
"5. Goldman-Cecil Medicine International Edition (9780323930345)",
"6. Aletaha D et al. 2010 Rheumatoid arthritis classification criteria: ACR/EULAR collaborative initiative. Arthritis Rheum 2010;62(9):2569–2581.",
"7. Nishimura K et al. Meta-analysis: diagnostic accuracy of anti-CCP antibody and RF for RA. Ann Intern Med 2007;146:797–808.",
]
for r in refs:
story.append(Paragraph(r, note_style))
story.append(Spacer(1, 6))
story.append(Paragraph(
"Generated by Orris AI Medical Assistant | July 2026 | For educational purposes only. "
"Always correlate with clinical findings and current local/international guidelines.",
footer_style
))
doc.build(story)
print(f"PDF created: {OUTPUT}")
Failed to create session: bad request: failed to resolve container IP after 3 attempts: no IP address found. Is the Sandbox started?
We encountered an error while processing your request. Please try again or reach out to us for help.
Give laboratory investigations for rheumatoid arthritis with its findings and values
mkdir -p /home/daytona/workspace/ra-pdf && python3 - <<'PYEOF' from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.units import cm from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable) from reportlab.lib.enums import TA_CENTER, TA_JUSTIFY OUTPUT = "/home/daytona/workspace/ra-pdf/Rheumatoid_Arthritis_Lab_Investigations.pdf" doc = SimpleDocTemplate(OUTPUT, pagesize=A4, rightMargin=2*cm, leftMargin=2*cm, topMargin=2.2*cm, bottomMargin=2.2*cm, title="Laboratory Investigations for Rheumatoid Arthritis") styles = getSampleStyleSheet() title_s = ParagraphStyle("T", parent=styles["Title"], fontSize=19, textColor=colors.HexColor("#6b1a1a"), spaceAfter=4, fontName="Helvetica-Bold", alignment=TA_CENTER) sub_s = ParagraphStyle("S", parent=styles["Normal"], fontSize=10.5, textColor=colors.HexColor("#a03030"), spaceAfter=12, fontName="Helvetica", alignment=TA_CENTER) sec_s = ParagraphStyle("SEC", parent=styles["Heading1"], fontSize=11.5, textColor=colors.white, spaceBefore=12, spaceAfter=4, fontName="Helvetica-Bold", backColor=colors.HexColor("#6b1a1a"), borderPad=5) sub2_s = ParagraphStyle("SUB2", parent=styles["Heading2"], fontSize=10.5, textColor=colors.HexColor("#6b1a1a"), spaceBefore=7, spaceAfter=3, fontName="Helvetica-Bold") body_s = ParagraphStyle("B", parent=styles["Normal"], fontSize=9.2, textColor=colors.HexColor("#222222"), spaceAfter=4, fontName="Helvetica", leading=13.5, alignment=TA_JUSTIFY) note_s = ParagraphStyle("N", parent=styles["Normal"], fontSize=8.3, textColor=colors.HexColor("#555555"), spaceAfter=3, fontName="Helvetica-Oblique", leftIndent=8, leading=12) foot_s = ParagraphStyle("F", parent=styles["Normal"], fontSize=7.8, textColor=colors.HexColor("#888888"), alignment=TA_CENTER) HDR = colors.HexColor("#6b1a1a") ALT = colors.HexColor("#f7eaea") WHT = colors.white BDR = colors.HexColor("#d4a0a0") def tbl(data, widths=None): t = Table(data, colWidths=widths, repeatRows=1) t.setStyle(TableStyle([ ("BACKGROUND",(0,0),(-1,0),HDR),("TEXTCOLOR",(0,0),(-1,0),WHT), ("FONTNAME",(0,0),(-1,0),"Helvetica-Bold"),("FONTSIZE",(0,0),(-1,0),9), ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHT,ALT]), ("FONTNAME",(0,1),(-1,-1),"Helvetica"),("FONTSIZE",(0,1),(-1,-1),8.7), ("TEXTCOLOR",(0,1),(-1,-1),colors.HexColor("#222222")), ("GRID",(0,0),(-1,-1),0.4,BDR),("VALIGN",(0,0),(-1,-1),"MIDDLE"), ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5), ("LEFTPADDING",(0,0),(-1,-1),6),("RIGHTPADDING",(0,0),(-1,-1),6), ])) return t def sec(txt): return Paragraph(f" {txt}", sec_s) story = [] story.append(Spacer(1,0.3*cm)) story.append(Paragraph("Laboratory Investigations for Rheumatoid Arthritis",title_s)) story.append(Paragraph("Findings, Values, Sensitivity & Specificity — A Complete Reference",sub_s)) story.append(HRFlowable(width="100%",thickness=2,color=colors.HexColor("#a03030"),spaceAfter=8)) story.append(Paragraph( "Rheumatoid arthritis (RA) is a systemic autoimmune disorder characterised by chronic, symmetric, " "erosive arthritis of peripheral joints with extra-articular features. RA is a <b>clinical diagnosis</b> " "confirmed by laboratory tests interpreted in context. Autoantibodies — particularly RF and anti-CCP — " "may precede clinical onset by years and serve as both diagnostic and prognostic markers. " "A score ≥6/10 on the 2010 ACR/EULAR classification criteria establishes definite RA.",body_s)) story.append(Spacer(1,5)) # ======= SECTION 1: AUTOANTIBODIES ======= story.append(sec("1. Serological / Autoantibody Tests")) story.append(Spacer(1,3)) d = [ ["Test","Normal / Cut-off","Finding in RA","Sensitivity","Specificity","Key Points"], ["Rheumatoid Factor (RF) — IgM\n(most commonly measured)","< 14–20 IU/mL\n(lab-specific)","Positive\n(elevated titre)","66–85%","72%", "Antibody against Fc portion of IgG. Positive in ~70–80% of RA patients. " "False positives in chronic infections (TB, SBE, EBV), SLE, Sjögren's, and healthy elderly. " "High titre = more severe disease, nodules, vasculitis. Seronegative RA (~15–20%) exists."], ["RF IgA / RF IgG","Negative","Positive in aggressive RA","~60%","~85%", "IgA-RF linked to more severe erosive disease. Not routinely ordered; additive prognostic value."], ["Anti-CCP (Anti-Cyclic Citrullinated Peptide)\n2nd generation ELISA","< 20 U/mL (negative)","Positive","73%","95–98%", "Most specific RA marker available. 2nd-gen ELISA: 98% specificity, 70–73% sensitivity. " "Detected in 50% of early RA when RF still negative. Predicts erosive, progressive disease. " "May precede onset by up to 10 years. Also positive in TB, hepatitis C, and some SLE cases."], ["Anti-Sa (Citrullinated Vimentin)","Negative","Positive","42%","92–98%", "Highly specific; useful in RF-negative / borderline anti-CCP cases. Additive to anti-CCP."], ["Anticarbamylated Proteins (anti-CarP)","Negative","Positive in ~16–30%","45–67%","70–94%", "Seen in seronegative RA; anti-CarP-positive, ACPA-negative patients often have refractory disease."], ["Anti-PAD4 Antibodies","Negative","Positive in ~30–38%","30–38%","96%", "PAD4 catalyses citrullination. Anti-PAD4 = marker for severe, erosive disease."], ["ANA (Antinuclear Antibodies)","< 1:40 titre (negative)","Positive in 30% of RA","30% (non-specific)","Low", "Low titre ANA is common in RA. High titre (≥1:160) favours SLE or Sjögren's. Helps exclude overlap syndromes."], ["Anti-dsDNA","< 10 IU/mL (negative)","Negative in RA","—","—", "Highly specific for SLE. Negative in RA. Key differential diagnostic test."], ["HLA-DR4 / Shared Epitope\n(DRB1*04:01, *04:04)","Not a routine test","Present in ~70% of RA","~70%","Moderate", "Genetic risk marker. Associated with seropositive, erosive, severe RA and extra-articular disease. " "Used in research/prognostication rather than routine clinical testing."], ] story.append(tbl(d, widths=[3.8*cm,2.7*cm,2.7*cm,1.7*cm,1.7*cm,4.6*cm])) story.append(Spacer(1,4)) story.append(Paragraph( "RF + anti-CCP both positive → very high specificity for seropositive RA and predicts aggressive erosive course. " "Seronegative RA (both negative, ~15–20%) is diagnosed on clinical and imaging grounds.",note_s)) story.append(Spacer(1,7)) # ======= SECTION 2: ACUTE PHASE REACTANTS ======= story.append(sec("2. Acute Phase Reactants & Inflammatory Markers")) story.append(Spacer(1,3)) d2 = [ ["Test","Normal Value","Finding in Active RA","Clinical Significance"], ["ESR (Erythrocyte Sedimentation Rate)","Males: < 15 mm/hr\nFemales: < 20 mm/hr\n(Westergren method)\nAge-adj: age/2 (M), (age+10)/2 (F)", "Elevated\n(often 30–100+ mm/hr)","Non-specific marker of systemic inflammation. Correlates with disease activity and joint damage. " "Used to monitor treatment response. Rises slower than CRP. Part of DAS28 scoring."], ["CRP (C-Reactive Protein)","< 5 mg/L (standard)\n< 1 mg/L (high-sensitivity)", "Elevated\n(often 10–100 mg/L)","Responds faster than ESR (within hours). More reliable for monitoring disease activity " "and therapeutic response. Better correlates with joint damage progression. Included in DAS28-CRP."], ["Serum Ferritin","12–300 ng/mL (males)\n12–150 ng/mL (females)","Elevated (acute phase reactant)", "Markedly elevated (> 500–1000 ng/mL) in Still's disease / systemic JIA. Moderate elevation in active RA. " "Very high ferritin → consider macrophage activation syndrome."], ["Fibrinogen","200–400 mg/dL","Elevated in active disease","Acute phase protein; rises with inflammation. Contributes to raised ESR."], ["Complement (C3, C4, CH50)","C3: 90–180 mg/dL\nC4: 16–47 mg/dL\nCH50: 75–160 U/mL", "Normal or elevated (serum)\nDecreased in synovial fluid","Serum complement is NORMAL or ELEVATED in RA (positive acute phase reactant). " "Low serum complement differentiates SLE from RA. Synovial CH50 is low (<33% of serum) — consumed by immune complexes."], ["Serum Albumin","3.5–5.0 g/dL","Low in severe/active RA","Negative acute phase reactant; falls with active inflammation. " "Reflects nutritional status. Also reduced with corticosteroid-related catabolism."], ["Serum Globulins","2.0–3.5 g/dL","Elevated\n(polyclonal hypergammaglobulinaemia)","Reflects chronic immune activation. Globulin:albumin ratio rises with disease activity."], ["Uric Acid","Males: 3.5–7.2 mg/dL\nFemales: 2.6–6.0 mg/dL","Normal in RA", "Ordered to exclude gout (which can mimic RA). Normal / low in RA. Elevated in gout, Lesch-Nyhan."], ] story.append(tbl(d2, widths=[4.0*cm,4.0*cm,3.3*cm,5.9*cm])) story.append(Spacer(1,7)) # ======= SECTION 3: CBC ======= story.append(sec("3. Complete Blood Count (CBC / Full Blood Count)")) story.append(Spacer(1,3)) d3 = [ ["Parameter","Normal Value","Finding in RA","Interpretation"], ["Haemoglobin (Hb)","Males: 13.5–17.5 g/dL\nFemales: 12.0–16.0 g/dL","Low\n(typically 10–12 g/dL)", "Normochromic, normocytic anaemia of chronic disease (ACD) — most common pattern. " "Microcytic if iron deficient (NSAID-related GI bleed). " "Macrocytic if methotrexate-induced folate deficiency."], ["MCV (Mean Corpuscular Volume)","80–100 fL","Normal (80–100 fL) in ACD\nLow (<80 fL) if IDA\nHigh (>100 fL) if B12/folate deficient", "Helps differentiate ACD (normal MCV) from iron deficiency (low MCV) or methotrexate-related macrocytosis."], ["MCHC / MCH","MCHC: 32–36 g/dL\nMCH: 27–33 pg","Normal in ACD","Normal MCHC distinguishes ACD from IDA."], ["WBC (Total Leukocyte Count)","4.0–11.0 × 10³/µL","Usually normal; mild leucocytosis in active/systemic RA", "Leucopenia (<4,000/µL) in Felty syndrome (RA + splenomegaly + neutropenia). " "Neutropenia also a side effect of DMARDs (methotrexate, leflunomide, rituximab, azathioprine)."], ["Neutrophils","2.0–7.5 × 10³/µL","Normal; low in Felty syndrome\n(<1,500/µL = neutropenia)", "Felty syndrome: RA + splenomegaly + neutropenia + recurrent infections. Monitor on DMARDs."], ["Lymphocytes","1.0–4.8 × 10³/µL","Usually normal","Lymphopenia may occur with methotrexate, azathioprine, cyclophosphamide, or biologics."], ["Eosinophils","0.05–0.5 × 10³/µL","Mildly elevated in ~20%","Eosinophilia in RA vasculitis, drug reactions, or Felty-associated eosinophilic features."], ["Platelets","150–400 × 10³/µL","Often elevated\n(400–700 × 10³/µL)", "Reactive thrombocytosis — acute phase response correlating with disease activity. " "Thrombocytopenia with Felty syndrome, gold therapy, or DMARD toxicity."], ] story.append(tbl(d3, widths=[3.5*cm,4.0*cm,3.5*cm,6.2*cm])) story.append(Spacer(1,7)) # ======= SECTION 4: SYNOVIAL FLUID ======= story.append(sec("4. Synovial Fluid Analysis (Arthrocentesis)")) story.append(Spacer(1,3)) story.append(Paragraph( "Joint aspiration is essential to exclude septic arthritis and crystal arthropathies. " "In RA, the fluid is characteristically inflammatory but sterile and crystal-free.",body_s)) story.append(Spacer(1,4)) d4 = [ ["Parameter","Normal","RA (Inflammatory)","Septic Arthritis","Gout / CPPD"], ["Appearance","Clear, pale yellow","Turbid, yellow-white,\nstraw to opalescent","Purulent, opaque,\ncreamy/green","Turbid or cloudy"], ["Viscosity","High (viscous, ropy)","Reduced","Very low","Low to normal"], ["WBC Count","< 200 cells/mm³","2,000–50,000/mm³\n(typically 10,000–20,000)\nMinimum > 2,000","> 50,000–100,000/mm³\n(often > 100,000)","2,000–100,000/mm³"], ["Neutrophils (%)","< 25%","> 75% PMNs","> 90% PMNs","60–95% PMNs"], ["Glucose","~Serum (70–100 mg/dL)","Decreased; serum–fluid\ndifference > 30 mg/dL","Very low (< 40 mg/dL\nor < 50% of serum)","Normal"], ["Protein","< 20 g/L","Elevated (> 30 g/L)","Very elevated\n(> 40 g/L)","Elevated"], ["Synovial CH50 / Complement","~33% of serum","Decreased\n(< 33% of serum)","Variable","Normal"], ["Culture / Gram Stain","Negative","Negative (sterile)","Positive (50–80%)\nGram stain ~50%","Negative"], ["Crystals (polarised microscopy)","None","None (no crystals)","None","MSU: needle-shaped,\nnegatively birefringent\nCPPD: rhomboid,\npositively birefringent"], ["Mucin Clot Test","Firm, ropy clot","Poor, friable clot","Very poor clot","Fair clot"], ["RF in synovial fluid","Absent","Present","Variable","Absent"], ] story.append(tbl(d4, widths=[3.2*cm,3.0*cm,3.8*cm,3.5*cm,3.7*cm])) story.append(Spacer(1,4)) story.append(Paragraph( "RA hallmark: WBC 10,000–20,000 cells/mm³ (>75% PMNs), sterile, no crystals, " "synovial CH50 < serum (immune complex consumption), serum–synovial glucose gap > 30 mg/dL.",note_s)) story.append(Spacer(1,7)) # ======= SECTION 5: METABOLIC / DRUG MONITORING ======= story.append(sec("5. Metabolic, Renal, Hepatic & Drug Monitoring Tests")) story.append(Spacer(1,3)) d5 = [ ["Test","Normal Value","Significance in RA / Monitoring"], ["Serum Creatinine / eGFR","Creatinine: 0.6–1.2 mg/dL\neGFR > 60 mL/min/1.73m²", "Renal involvement in RA: membranous nephropathy, AA amyloidosis. Baseline before NSAIDs, methotrexate, cyclosporin, gold."], ["LFTs (AST, ALT, ALP, GGT)","AST: 10–40 U/L\nALT: 7–56 U/L\nALP: 44–147 U/L", "Hepatotoxicity monitoring with methotrexate & leflunomide. ALT/AST >3× ULN → dose reduction. Baseline required."], ["Serum Albumin","3.5–5.0 g/dL","Low in active RA. Monitors nutritional status and disease activity. Important for drug binding."], ["Blood Glucose (Fasting)","70–100 mg/dL","Corticosteroids cause glucose intolerance and diabetes. Monitor glycaemia regularly on long-term steroids."], ["Lipid Profile (TC, LDL, HDL, TG)","TC < 200 mg/dL; LDL < 100 mg/dL\nHDL > 40 (M)/50 (F) mg/dL\nTG < 150 mg/dL", "RA is an independent CV risk factor. Dyslipidaemia is common. Tocilizumab raises LDL. Steroids raise cholesterol. Periodic monitoring."], ["Serum Calcium / ALP / Vitamin D","Ca: 8.5–10.5 mg/dL\n25-OH Vit D: 30–80 ng/mL", "Osteoporosis is a major RA complication, worsened by corticosteroids. Vitamin D deficiency is common; supplement if < 30 ng/mL."], ["Thyroid Function (TSH)","TSH: 0.4–4.0 mIU/L","Autoimmune thyroid disease co-exists with RA in ~10%. Hypothyroidism exacerbates fatigue and joint symptoms."], ["Urinalysis (Protein, RBC, casts)","Negative protein; no cells","Proteinuria: amyloidosis (AA), gold nephropathy, penicillamine toxicity. Haematuria: vasculitis, drug nephrotoxicity."], ["Bone Marrow Aspirate / Biopsy","—","Performed in Felty syndrome with severe cytopenias or if haematological malignancy suspected (RA raises risk of NHL)."], ] story.append(tbl(d5, widths=[4.2*cm,4.3*cm,8.7*cm])) story.append(Spacer(1,7)) # ======= SECTION 6: IMAGING ======= story.append(sec("6. Imaging Investigations")) story.append(Spacer(1,3)) d6 = [ ["Modality","Findings in RA"], ["Plain X-Ray (PA hands, wrists, feet) — first-line", "Early: periarticular soft tissue swelling; juxta-articular osteopenia (periarticular bone loss). " "Late: marginal bone erosions (MCP, PIP, wrist), uniform joint space narrowing, ulnar deviation at MCPs, " "swan-neck & boutonniere deformities, carpal collapse, atlanto-axial subluxation (cervical spine)."], ["Musculoskeletal Ultrasound (MSUS)", "Detects synovitis, tenosynovitis, joint effusions, power Doppler signal (active inflammation), and erosions " "earlier than plain X-ray. More sensitive than clinical exam for subclinical synovitis. Guides joint injections."], ["MRI (joint MRI)", "Most sensitive for early erosions, bone marrow oedema (BMOE), synovitis, tendon pathology, and pannus. " "RAMRIS score used for disease progression assessment. Detects cervical cord compression at C1–C2."], ["DEXA (Bone Mineral Density)", "T-score ≤ −2.5 = osteoporosis; T-score −1.0 to −2.5 = osteopenia. " "Baseline in all patients on long-term corticosteroids. Repeat every 1–2 years. " "RA itself raises fracture risk independent of steroid use."], ["CT (Computed Tomography)", "Complex erosions in small joints, C1–C2 subluxation assessment. Not first-line for joint monitoring."], ["Echocardiography","Pericardial effusion and myocarditis in extra-articular RA. Baseline for cardiac risk before biologic therapy."], ["Chest X-Ray", "Pulmonary manifestations: pleural effusions, rheumatoid nodules (round opacities), interstitial fibrosis (ILD), " "and Caplan syndrome (pneumoconiosis + RA). Mandatory baseline before biologic therapy."], ] story.append(tbl(d6, widths=[4.2*cm,13.0*cm])) story.append(Spacer(1,7)) # ======= SECTION 7: 2010 ACR/EULAR CRITERIA ======= story.append(sec("7. 2010 ACR/EULAR Classification Criteria for RA (Score ≥ 6/10 = Definite RA)")) story.append(Spacer(1,3)) c_data = [ ["Domain & Criterion","Points"], ["A. JOINT INVOLVEMENT",""], ["1 large joint (shoulder, elbow, hip, knee, ankle)","0"], ["2–10 large joints","1"], ["1–3 small joints (MCP, PIP, 2nd–5th MTP, thumb IP, wrist)","2"], ["4–10 small joints","3"], ["> 10 joints (including ≥ 1 small joint)","5"], ["B. SEROLOGY",""], ["Negative RF AND negative anti-CCP","0"], ["Low positive RF OR anti-CCP (> ULN to ≤ 3× ULN)","2"], ["High positive RF OR anti-CCP (> 3× ULN)","3"], ["C. ACUTE PHASE REACTANTS",""], ["Normal CRP AND normal ESR","0"], ["Abnormal CRP OR abnormal ESR","1"], ["D. DURATION OF SYMPTOMS",""], ["< 6 weeks","0"], ["≥ 6 weeks","1"], ] ct = Table(c_data, colWidths=[14.5*cm,2.7*cm], repeatRows=1) sub_hdr = colors.HexColor("#c46060") ct.setStyle(TableStyle([ ("BACKGROUND",(0,0),(-1,0),HDR),("TEXTCOLOR",(0,0),(-1,0),WHT), ("FONTNAME",(0,0),(-1,0),"Helvetica-Bold"),("FONTSIZE",(0,0),(-1,0),9.5), ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHT,ALT]), ("FONTNAME",(0,1),(-1,-1),"Helvetica"),("FONTSIZE",(0,1),(-1,-1),9), ("TEXTCOLOR",(0,1),(-1,-1),colors.HexColor("#222222")), ("GRID",(0,0),(-1,-1),0.4,BDR),("VALIGN",(0,0),(-1,-1),"MIDDLE"), ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5), ("LEFTPADDING",(0,0),(-1,-1),8),("RIGHTPADDING",(0,0),(-1,-1),6), ("BACKGROUND",(0,1),(-1,1),sub_hdr),("TEXTCOLOR",(0,1),(-1,1),WHT),("FONTNAME",(0,1),(-1,1),"Helvetica-Bold"), ("BACKGROUND",(0,7),(-1,7),sub_hdr),("TEXTCOLOR",(0,7),(-1,7),WHT),("FONTNAME",(0,7),(-1,7),"Helvetica-Bold"), ("BACKGROUND",(0,11),(-1,11),sub_hdr),("TEXTCOLOR",(0,11),(-1,11),WHT),("FONTNAME",(0,11),(-1,11),"Helvetica-Bold"), ("BACKGROUND",(0,14),(-1,14),sub_hdr),("TEXTCOLOR",(0,14),(-1,14),WHT),("FONTNAME",(0,14),(-1,14),"Helvetica-Bold"), ])) story.append(ct) story.append(Spacer(1,4)) story.append(Paragraph( "Score ≥6/10 = Definite RA. Applies to patients with ≥1 joint with definite clinical synovitis not explained by another diagnosis. " "Also applies when erosions typical of RA are present on imaging. (Aletaha et al., Arthritis Rheum 2010;62:2569–2581.)",note_s)) story.append(Spacer(1,7)) # ======= SECTION 8: QUICK REFERENCE COMPARISON ======= story.append(sec("8. Quick Reference — RA vs Key Differential Diagnoses")) story.append(Spacer(1,3)) qr = [ ["Test / Finding","RA","SLE","Sjögren's","Gout","Osteoarthritis","Septic Arthritis"], ["RF","++ (70–80%)","+ (20%)","++ (70%)","–","–/+ (elderly)","–"], ["Anti-CCP (ACPA)","+++ (73%)","–/+ (<5%)","– (<5%)","–","–","–"], ["ANA","+ (30%)","+++ (95%)","++ (70%)","–","–","–"], ["Anti-dsDNA","–","+++ (70%)","–","–","–","–"], ["Anti-Ro/La (SSA/SSB)","–/+","+ (40%)","+++ (75%)","–","–","–"], ["ESR / CRP","Elevated","Elevated","Elevated","Elevated (acute)","Normal/mild","Markedly elevated"], ["Serum Complement","Normal or ↑","↓↓ (low)","Normal/↓","Normal","Normal","Normal or ↑"], ["Uric Acid","Normal","Normal","Normal","↑↑ (>7 mg/dL)","Normal","Normal"], ["Synovial WBC","2,000–20,000\n>75% PMNs","2,000–5,000","2,000–10,000","5,000–50,000\n>80% PMNs","< 2,000","50,000–200,000\n>90% PMNs"], ["Synovial Crystals","None","None","None","MSU (–ve biref.)","CPPD (late)","None"], ["Hb / Anaemia","ACD (Hb 10–12)","Haemolytic/ACD","ACD/mild","Normal","Normal","Acute (WBC ↑)"], ["Platelets","↑ (thrombocytosis)","↓ (thrombocytopenia)","Normal","Normal","Normal","↑"], ] qt = Table(qr, colWidths=[3.5*cm,2.4*cm,2.0*cm,2.2*cm,2.0*cm,2.5*cm,3.0*cm], repeatRows=1) qt.setStyle(TableStyle([ ("BACKGROUND",(0,0),(-1,0),HDR),("TEXTCOLOR",(0,0),(-1,0),WHT), ("FONTNAME",(0,0),(-1,0),"Helvetica-Bold"),("FONTSIZE",(0,0),(-1,0),8.5), ("ROWBACKGROUNDS",(0,1),(-1,-1),[WHT,ALT]), ("FONTNAME",(0,1),(-1,-1),"Helvetica"),("FONTSIZE",(0,1),(-1,-1),8.2), ("TEXTCOLOR",(0,1),(-1,-1),colors.HexColor("#222222")), ("GRID",(0,0),(-1,-1),0.4,BDR),("VALIGN",(0,0),(-1,-1),"MIDDLE"), ("ALIGN",(1,0),(-1,-1),"CENTER"), ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5), ("LEFTPADDING",(0,0),(-1,-1),5),("RIGHTPADDING",(0,0),(-1,-1),5), ])) story.append(qt) story.append(Spacer(1,4)) story.append(Paragraph( "+++ = strongly positive / highly characteristic; ++ = often positive; + = sometimes positive; " "–/+ = usually negative; – = absent; ↑ = elevated; ↓ = decreased; ACD = anaemia of chronic disease; " "MSU = monosodium urate; CPPD = calcium pyrophosphate dihydrate.",note_s)) story.append(Spacer(1,7)) # ======= SECTION 9: PRE-TREATMENT SCREENING ======= story.append(sec("9. Pre-Treatment Screening & Monitoring Panel (DMARDs / Biologics)")) story.append(Spacer(1,3)) d9 = [ ["Test","Timing / Indication"], ["Chest X-Ray + TB screening (IGRA / Mantoux / Quantiferon-TB Gold)","Before all biologic therapy. Latent TB must be excluded and treated (9 months isoniazid) before starting TNF inhibitors, rituximab, or JAK inhibitors."], ["HIV, HBV (HBsAg, anti-HBc, anti-HBs), HCV serology","Before rituximab and TNF inhibitors. HBV reactivation is a life-threatening risk with immunosuppression."], ["Varicella Zoster IgG titre","Before rituximab / JAK inhibitors. Vaccinate if non-immune (live vaccines contraindicated once on biologics)."], ["Pregnancy test (urine/serum β-hCG)","Before every course of methotrexate and leflunomide (both Category X — teratogenic). Effective contraception is mandatory."], ["CBC — baseline + regular monitoring","Baseline before DMARDs; monthly for first 3 months, then every 3 months. Alert: Hb < 10 g/dL, WBC < 3.0 × 10³/µL, neutrophils < 1.5 × 10³/µL, platelets < 100 × 10³/µL."], ["LFTs (AST/ALT) — methotrexate monitoring","Every 4–8 weeks on methotrexate. Persistent ALT/AST > 3× ULN requires dose reduction or switch. Alcohol abstinence mandatory."], ["Serum creatinine / eGFR","Baseline + every 3–6 months. NSAIDs and cyclosporin are nephrotoxic. Dose-adjust methotrexate for eGFR < 60."], ["Lipid profile","Baseline + 4–8 weeks after starting tocilizumab or corticosteroids. JAK inhibitors (tofacitinib, baricitinib) also raise LDL — statin therapy may be needed."], ["DEXA scan (BMD)","Baseline in all starting long-term corticosteroids (≥ 7.5 mg/day prednisone > 3 months). Repeat every 1–2 years. Start bisphosphonate + calcium + vitamin D."], ["DAS28 Score (Disease Activity)","Composite: TJC28 + SJC28 + ESR or CRP + patient VAS (0–100). Remission: DAS28-ESR < 2.6. Low: 2.6–3.2. Moderate: 3.2–5.1. High: > 5.1. Target DAS28 < 2.6 ('treat-to-target' strategy)."], ] story.append(tbl(d9, widths=[5.3*cm,11.9*cm])) story.append(Spacer(1,7)) # ======= REFERENCES ======= story.append(HRFlowable(width="100%",thickness=0.7,color=BDR,spaceAfter=6)) story.append(Paragraph("<b>Sources</b>",ParagraphStyle("rh",parent=styles["Normal"], fontName="Helvetica-Bold",fontSize=9,textColor=colors.HexColor("#6b1a1a")))) for r in [ "1. Henry's Clinical Diagnosis and Management by Laboratory Methods (9780323673204) — Ch. 53: Autoantibodies in RA", "2. Tietz Textbook of Laboratory Medicine, 7th Ed. (9780323775724) — Ch. 45: Synovial Fluid", "3. Textbook of Family Medicine, 9th Ed. (9780323239905) — Ch. 32: RA Diagnosis & Laboratory Studies", "4. Quick Compendium of Clinical Pathology, 5th Ed. (9780891896852) — Synovial Fluid Table", "5. Firestein & Kelley's Textbook of Rheumatology (9780323935364)", "6. Aletaha D et al. 2010 ACR/EULAR classification criteria for RA. Arthritis Rheum 2010;62:2569–2581.", "7. Nishimura K et al. Diagnostic accuracy of anti-CCP antibody and RF for RA. Ann Intern Med 2007;146:797–808.", ]: story.append(Paragraph(r, note_s)) story.append(Spacer(1,6)) story.append(Paragraph( "Generated by Orris AI Medical Assistant | July 2026 | For educational purposes only. " "Always correlate with clinical findings and current ACR/EULAR guidelines.",foot_s)) doc.build(story) print("PDF created:", OUTPUT) PYEOF
ls -lh /home/daytona/workspace/ra-pdf/Rheumatoid_Arthritis_Lab_Investigations.pdf
Rheumatoid Arthritis Lab Investigations
PDF Document · PDF
| Test | Normal | RA Finding | Sensitivity | Specificity |
|---|---|---|---|---|
| RF (IgM) | < 14–20 IU/mL | Positive | 66–85% | 72% |
| Anti-CCP (2nd gen ELISA) | < 20 U/mL | Positive | 73% | 95–98% |
| Anti-Sa | Negative | Positive | 42% | 92–98% |
| Anti-CarP | Negative | Positive (~16–30%) | 45–67% | 70–94% |
| Anti-PAD4 | Negative | Positive (~30–38%) | 30–38% | 96% |
| ANA | < 1:40 | Positive in 30% of RA | 30% | Low |
| Parameter | RA Value |
|---|---|
| Appearance | Turbid, yellow-white |
| WBC count | 2,000–20,000 cells/mm³ (minimum >2,000) |
| Neutrophils | > 75% PMNs |
| Glucose gap | Serum – fluid > 30 mg/dL |
| Synovial CH50 | Low (< 33% of serum) — immune complex consumption |
| Culture | Negative (sterile) |
| Crystals | None |