elevated blood caesium level health effects reference range toxicology
elemental cesium blood test elevated non-radioactive sources exposure significance heavy metal panel
triglyceride HDL ratio insulin resistance cardiovascular risk marker
Generate a quick reference PDF comparing your lipid ratios to cardiovascular risk thresholds
mkdir -p /tmp/workspace/lipid-report && ls -la /tmp/workspace/
~/lipid-report/build_pdf.py
"""
Quick-reference PDF: Patient lipid ratios vs. cardiovascular risk thresholds.
"""
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import inch
from reportlab.platypus import (
SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT
OUT = "/tmp/workspace/lipid-report/Lipid_Ratio_CV_Risk_Reference.pdf"
styles = getSampleStyleSheet()
title_style = ParagraphStyle(
"TitleStyle", parent=styles["Title"], fontSize=18, textColor=colors.HexColor("#1a3c5e"),
spaceAfter=4
)
sub_style = ParagraphStyle(
"SubStyle", parent=styles["Normal"], fontSize=10, textColor=colors.HexColor("#555555"),
spaceAfter=14
)
section_style = ParagraphStyle(
"SectionStyle", parent=styles["Heading2"], fontSize=13, textColor=colors.HexColor("#1a3c5e"),
spaceBefore=16, spaceAfter=6
)
body_style = ParagraphStyle(
"BodyStyle", parent=styles["Normal"], fontSize=9.5, leading=13.5
)
note_style = ParagraphStyle(
"NoteStyle", parent=styles["Normal"], fontSize=8.5, leading=12, textColor=colors.HexColor("#555555")
)
flag_style_bad = ParagraphStyle("flagbad", parent=styles["Normal"], fontSize=9.5, textColor=colors.HexColor("#b00020"), fontName="Helvetica-Bold")
flag_style_ok = ParagraphStyle("flagok", parent=styles["Normal"], fontSize=9.5, textColor=colors.HexColor("#1e7d32"), fontName="Helvetica-Bold")
doc = SimpleDocTemplate(
OUT, pagesize=letter,
topMargin=0.6*inch, bottomMargin=0.6*inch,
leftMargin=0.6*inch, rightMargin=0.6*inch,
title="Lipid Ratio Cardiovascular Risk Reference"
)
elements = []
elements.append(Paragraph("Lipid Ratio Quick Reference", title_style))
elements.append(Paragraph(
"Comparing your reported lipid values/ratios against standard cardiovascular (CV) risk thresholds",
sub_style
))
elements.append(HRFlowable(width="100%", thickness=1, color=colors.HexColor("#1a3c5e")))
elements.append(Spacer(1, 12))
# ---- Table 1: Your values vs thresholds ----
elements.append(Paragraph("1. Your Results vs. Risk Thresholds", section_style))
data = [
["Measure", "Your\nValue", "Optimal /\nDesired", "Borderline", "High Risk", "Your\nCategory"],
["LDL Cholesterol\n(mg/dL)", "117", "<100", "100-129\n(near optimal)\n130-159\n(borderline high)", "\u2265160", "Near optimal\n(above ideal)"],
["Triglycerides\n(mg/dL)", "151", "<150", "150-199", "\u2265200", "Borderline\nhigh"],
["HDL/LDL Ratio", "0.37", ">0.40\n(favorable)", "0.30-0.40", "<0.30", "Below\nfavorable"],
["TG/HDL Ratio", "3.47", "<3.12", "3.12-3.5", ">3.5\n(insulin\nresistance risk)", "Borderline\nelevated"],
]
table1 = Table(data, colWidths=[1.15*inch, 0.7*inch, 1.05*inch, 1.25*inch, 1.15*inch, 1.0*inch])
table1.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), colors.HexColor("#1a3c5e")),
("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
("FONTSIZE", (0, 0), (-1, -1), 8.3),
("ALIGN", (0, 0), (-1, -1), "CENTER"),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("GRID", (0, 0), (-1, -1), 0.6, colors.HexColor("#cccccc")),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [colors.white, colors.HexColor("#f2f6fa")]),
("TOPPADDING", (0, 0), (-1, -1), 6),
("BOTTOMPADDING", (0, 0), (-1, -1), 6),
# Highlight "Your Value" column
("BACKGROUND", (1, 1), (1, -1), colors.HexColor("#fde9e9")),
("FONTNAME", (1, 1), (1, -1), "Helvetica-Bold"),
# Highlight "Your Category" column
("BACKGROUND", (5, 1), (5, -1), colors.HexColor("#fff4e0")),
("FONTNAME", (0, 1), (0, -1), "Helvetica-Bold"),
]))
elements.append(table1)
elements.append(Spacer(1, 14))
# ---- Table 2: What each ratio means ----
elements.append(Paragraph("2. What Each Marker Tells You", section_style))
data2 = [
["Marker", "What it reflects", "Why it matters"],
["LDL Cholesterol",
"\"Bad\" cholesterol carried by low-density lipoproteins.",
"Directly drives plaque buildup in arteries (atherosclerosis). Each ~39 mg/dL reduction lowers ASCVD risk proportionally."],
["Triglycerides",
"Fat circulating in blood, largely from diet and liver production.",
"High levels (especially with low HDL) mark an atherogenic, often insulin-resistant lipid pattern."],
["HDL/LDL Ratio",
"Balance between protective (HDL) and harmful (LDL) cholesterol.",
"A LOWER ratio is worse: HDL is relatively too low or LDL too high. >0.40 is generally considered favorable."],
["TG/HDL Ratio",
"Surrogate marker for insulin resistance.",
"A HIGHER ratio signals more insulin resistance and greater cardiometabolic/CV risk; used as a low-cost alternative to HOMA-IR."],
]
table2 = Table(data2, colWidths=[1.3*inch, 2.55*inch, 2.45*inch])
table2.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), colors.HexColor("#1a3c5e")),
("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
("FONTSIZE", (0, 0), (-1, -1), 8.3),
("VALIGN", (0, 0), (-1, -1), "TOP"),
("GRID", (0, 0), (-1, -1), 0.6, colors.HexColor("#cccccc")),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [colors.white, colors.HexColor("#f2f6fa")]),
("TOPPADDING", (0, 0), (-1, -1), 6),
("BOTTOMPADDING", (0, 0), (-1, -1), 6),
("LEFTPADDING", (0, 0), (-1, -1), 6),
("RIGHTPADDING", (0, 0), (-1, -1), 6),
("FONTNAME", (0, 1), (0, -1), "Helvetica-Bold"),
]))
elements.append(table2)
elements.append(Spacer(1, 14))
# ---- Summary box ----
elements.append(Paragraph("3. Overall Pattern", section_style))
elements.append(Paragraph(
"All four markers point in the same direction: an <b>atherogenic dyslipidemia pattern</b> "
"(LDL above optimal, triglycerides borderline-high, HDL relatively too low versus both LDL and "
"triglycerides). This combination is associated with increased cardiovascular risk and often "
"co-occurs with insulin resistance / early metabolic syndrome. None of the individual values are "
"in the \"high risk\" tier, but all sit past the \"optimal\" cutoff, so this is a pattern worth "
"addressing through diet, weight/activity changes, and re-testing rather than a single outlier value.",
body_style
))
elements.append(Spacer(1, 10))
elements.append(HRFlowable(width="100%", thickness=0.75, color=colors.HexColor("#cccccc")))
elements.append(Spacer(1, 6))
elements.append(Paragraph(
"Sources: NCEP ATP III LDL classification; TG/HDL ratio as insulin-resistance surrogate "
"(Giannini et al.; McLaughlin et al.; multiple validation cohorts). Thresholds shown are general "
"reference points from the literature and the reported lab's own bio-reference intervals; "
"individual lab reference ranges can vary by method and population. This document is for "
"educational purposes only and does not replace evaluation by a physician.",
note_style
))
doc.build(elements)
print("PDF created at", OUT)
cd /tmp/workspace/lipid-report && python3 build_pdf.py
cd /tmp/workspace/lipid-report && python3 -c " import pdfplumber with pdfplumber.open('Lipid_Ratio_CV_Risk_Reference.pdf') as pdf: print('pages:', len(pdf.pages)) for p in pdf.pages: print(p.extract_text()[:300]) " ls -la /tmp/workspace/lipid-report/
Lipid Ratio CV Risk Reference
PDF Document · PDF
Similarly compare with insulin resistance risk
triglyceride glucose index TyG cutoff insulin resistance risk categories
TG/HDL ratio cutoff value insulin resistance high risk threshold
hyperuricemia uric acid marker insulin resistance metabolic syndrome risk
~/lipid-report/build_pdf_insulin_resistance.py
"""
Quick-reference PDF: Patient markers vs. insulin resistance (IR) risk thresholds.
"""
import math
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import inch
from reportlab.platypus import (
SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
OUT = "/tmp/workspace/lipid-report/Insulin_Resistance_Risk_Reference.pdf"
# ---- Derived calculation: TyG index = ln(TG[mg/dL] x Glucose[mg/dL] / 2) ----
TG = 151
GLUCOSE = 88
TYG = round(math.log(TG * GLUCOSE / 2), 2) # ~8.80
styles = getSampleStyleSheet()
title_style = ParagraphStyle(
"TitleStyle", parent=styles["Title"], fontSize=18, textColor=colors.HexColor("#1a3c5e"),
spaceAfter=4
)
sub_style = ParagraphStyle(
"SubStyle", parent=styles["Normal"], fontSize=10, textColor=colors.HexColor("#555555"),
spaceAfter=14
)
section_style = ParagraphStyle(
"SectionStyle", parent=styles["Heading2"], fontSize=13, textColor=colors.HexColor("#1a3c5e"),
spaceBefore=16, spaceAfter=6
)
body_style = ParagraphStyle(
"BodyStyle", parent=styles["Normal"], fontSize=9.5, leading=13.5
)
note_style = ParagraphStyle(
"NoteStyle", parent=styles["Normal"], fontSize=8.3, leading=11.8, textColor=colors.HexColor("#555555")
)
doc = SimpleDocTemplate(
OUT, pagesize=letter,
topMargin=0.6*inch, bottomMargin=0.6*inch,
leftMargin=0.6*inch, rightMargin=0.6*inch,
title="Insulin Resistance Risk Reference"
)
elements = []
elements.append(Paragraph("Insulin Resistance Quick Reference", title_style))
elements.append(Paragraph(
"Comparing your reported markers against standard insulin resistance (IR) risk thresholds",
sub_style
))
elements.append(HRFlowable(width="100%", thickness=1, color=colors.HexColor("#1a3c5e")))
elements.append(Spacer(1, 12))
# ---- Table 1: Your values vs thresholds ----
elements.append(Paragraph("1. Your Results vs. IR Risk Thresholds", section_style))
data = [
["Marker", "Your\nValue", "Low Risk", "Moderate Risk", "High Risk", "Your\nCategory"],
["TG/HDL Ratio", "3.47",
"<2.0",
"2.0-3.0",
"\u22653.0-3.5\n(strong IR\npredictor)",
"High risk\nzone"],
[f"TyG Index*\n(calculated)", f"{TYG}",
"<8.0",
"8.0-8.3",
"\u22658.3\n(T2D risk)\n\u22658.7-8.9\n(MetS risk)",
"High risk\nzone"],
["Average/Fasting\nGlucose (mg/dL)", "88",
"<100\n(normal)",
"100-125\n(prediabetes)",
"\u2265126\n(diabetes\nrange)",
"Normal"],
["Uric Acid\n(mg/dL)", "7.99",
"<7.0 (men)\n<6.0 (women)",
"7.0-9.0",
"\u22659.0\n(~5x MetS\nodds)",
"Hyperuricemic\n(elevated)"],
]
table1 = Table(data, colWidths=[1.25*inch, 0.75*inch, 0.95*inch, 1.05*inch, 1.25*inch, 1.05*inch])
table1.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), colors.HexColor("#1a3c5e")),
("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
("FONTSIZE", (0, 0), (-1, -1), 8.0),
("ALIGN", (0, 0), (-1, -1), "CENTER"),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("GRID", (0, 0), (-1, -1), 0.6, colors.HexColor("#cccccc")),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [colors.white, colors.HexColor("#f2f6fa")]),
("TOPPADDING", (0, 0), (-1, -1), 6),
("BOTTOMPADDING", (0, 0), (-1, -1), 6),
("BACKGROUND", (1, 1), (1, -1), colors.HexColor("#fde9e9")),
("FONTNAME", (1, 1), (1, -1), "Helvetica-Bold"),
("BACKGROUND", (5, 1), (5, -1), colors.HexColor("#fff4e0")),
("FONTNAME", (0, 1), (0, -1), "Helvetica-Bold"),
]))
elements.append(table1)
elements.append(Spacer(1, 6))
elements.append(Paragraph(
"*TyG Index = ln(Triglycerides [mg/dL] \u00d7 Glucose [mg/dL] / 2) = ln(151 \u00d7 88 / 2) = ln(6644) \u2248 "
f"<b>{TYG}</b>. Not a lab-reported value — calculated here from your triglycerides and glucose results.",
note_style
))
elements.append(Spacer(1, 14))
# ---- Table 2: What each marker means ----
elements.append(Paragraph("2. What Each Marker Tells You", section_style))
data2 = [
["Marker", "What it reflects", "Why it matters"],
["TG/HDL Ratio",
"Ratio of circulating fat (triglycerides) to protective HDL cholesterol.",
"A simple, low-cost surrogate for insulin resistance. Ratios \u22653.0-3.5 correlate with hyperinsulinemia and roughly double the odds of insulin resistance in validation studies."],
["TyG Index",
"Combines triglycerides and glucose into a single log-transformed score.",
"Outperforms TG/HDL and rivals HOMA-IR in several cohorts for predicting insulin resistance, metabolic syndrome, and future type 2 diabetes; no insulin assay needed."],
["Fasting/Avg. Glucose",
"Circulating blood sugar level.",
"Still normal at this stage; glucose usually rises only after insulin resistance has been present for a while, so a normal value does not rule out IR."],
["Uric Acid",
"Byproduct of purine metabolism, cleared by the kidneys.",
"Insulin resistance reduces renal uric acid clearance, so elevated uric acid often accompanies (and can help flag) early metabolic dysfunction, independent of diet."],
]
table2 = Table(data2, colWidths=[1.2*inch, 2.6*inch, 2.5*inch])
table2.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), colors.HexColor("#1a3c5e")),
("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
("FONTNAME", (0, 0), (-1, 0), "Helvetica-Bold"),
("FONTSIZE", (0, 0), (-1, -1), 8.3),
("VALIGN", (0, 0), (-1, -1), "TOP"),
("GRID", (0, 0), (-1, -1), 0.6, colors.HexColor("#cccccc")),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [colors.white, colors.HexColor("#f2f6fa")]),
("TOPPADDING", (0, 0), (-1, -1), 6),
("BOTTOMPADDING", (0, 0), (-1, -1), 6),
("LEFTPADDING", (0, 0), (-1, -1), 6),
("RIGHTPADDING", (0, 0), (-1, -1), 6),
("FONTNAME", (0, 1), (0, -1), "Helvetica-Bold"),
]))
elements.append(table2)
elements.append(Spacer(1, 14))
# ---- Summary box ----
elements.append(Paragraph("3. Overall Pattern", section_style))
elements.append(Paragraph(
"Two independent surrogate markers — the TG/HDL ratio (3.47) and the calculated TyG Index "
f"({TYG}) — both fall in ranges associated with increased insulin resistance risk, and this is "
"reinforced by the elevated uric acid (7.99 mg/dL), which independently tracks with early metabolic "
"dysfunction. Glucose itself is still normal (88 mg/dL), which is expected: glucose typically stays "
"normal in the earlier, compensated stage of insulin resistance before beta-cell function declines. "
"Together, this pattern suggests it would be reasonable to discuss formal insulin resistance testing "
"(fasting insulin/HOMA-IR or an oral glucose tolerance test with insulin) and lifestyle measures "
"(weight, diet, activity) with a physician, even though standard glucose is currently normal.",
body_style
))
elements.append(Spacer(1, 10))
elements.append(HRFlowable(width="100%", thickness=0.75, color=colors.HexColor("#cccccc")))
elements.append(Spacer(1, 6))
elements.append(Paragraph(
"Sources: McLaughlin et al. (TG/HDL and IR, 2003); TG/HDL ratio as IR surrogate, multiple validation "
"cohorts (MDPI 2024 review); triglyceride-glucose (TyG) index cutoffs from Spanish Vascular-Metabolic "
"CNS cohort and Korean prospective cohort studies (metabolic syndrome cutoffs ~8.7-8.9); ADA glucose "
"categories; hyperuricemia and metabolic syndrome association studies. Cutoffs vary by population, sex, "
"and study; thresholds shown are general reference points from the literature, not a personalized "
"diagnosis. This document is for educational purposes only and does not replace evaluation by a "
"physician, including confirmatory testing such as fasting insulin or HOMA-IR.",
note_style
))
doc.build(elements)
print("PDF created at", OUT, "| TyG =", TYG)
cd /tmp/workspace/lipid-report && python3 build_pdf_insulin_resistance.py
cd /tmp/workspace/lipid-report && python3 -c " import pdfplumber with pdfplumber.open('Insulin_Resistance_Risk_Reference.pdf') as pdf: print('pages:', len(pdf.pages)) print(pdf.pages[0].extract_text()[:400]) " ls -la /tmp/workspace/lipid-report/
cd /tmp/workspace/lipid-report && python3 -c " import pdfplumber with pdfplumber.open('Insulin_Resistance_Risk_Reference.pdf') as pdf: for i,p in enumerate(pdf.pages): print('--- page', i+1, '---') print(p.extract_text()) "
cd /tmp/workspace/lipid-report && python3 -c " import pdfplumber with pdfplumber.open('Lipid_Ratio_CV_Risk_Reference.pdf') as pdf: print(pdf.pages[0].extract_text()) "
~/lipid-report
~/lipid-report/build_pdf_insulin_resistance.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/lipid-report/build_pdf_insulin_resistance.py'
~/lipid-report/build_pdf_insulin_resistance.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/lipid-report/build_pdf_insulin_resistance.py'
cd /tmp/workspace/lipid-report && python3 build_pdf_insulin_resistance.py
cd /tmp/workspace/lipid-report && python3 -c " import pdfplumber with pdfplumber.open('Insulin_Resistance_Risk_Reference.pdf') as pdf: print('pages:', len(pdf.pages)) for i,p in enumerate(pdf.pages): print('--- page', i+1,'---') print(p.extract_text()) "
Insulin Resistance Risk Reference
PDF Document · PDF