The Glomerular Filtration Rate (GFR) is a key indicator of kidney function. It measures how well your kidneys are filtering waste products from your blood. This calculator uses the CKD-EPI Creatinine Equation (2021), which is a widely accepted formula for estimating GFR. Please note that this is an estimate and should be discussed with your healthcare provider.
Male
Female
Non-Binary
White
Black or African American
Asian
Other
No
Yes
function calculateGFR() {
var serumCreatinine = parseFloat(document.getElementById("serumCreatinine").value);
var age = parseInt(document.getElementById("age").value);
var gender = document.getElementById("gender").value;
var race = document.getElementById("race").value;
var containsKey = document.getElementById("containsKey").value;
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(serumCreatinine) || isNaN(age) || serumCreatinine <= 0 || age <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for Serum Creatinine and Age.";
return;
}
var sex_coefficient;
if (gender === "male") {
sex_coefficient = 1.012;
} else if (gender === "female") {
sex_coefficient = 0.993;
} else { // nonbinary
sex_coefficient = 1.003; // Average of male and female coefficients as per some guidelines
}
var race_factor = 1.0;
if (race === "black") {
if (gender === "male") {
race_factor = 1.145;
} else if (gender === "female") {
race_factor = 1.159;
}
// For non-binary individuals of Black race, using average adjustment
else {
race_factor = 1.152;
}
}
var exponent;
if (containsKey === "yes") {
exponent = -0.207; // Adjust exponent for kidney transplant recipients
} else {
exponent = -1.209;
}
var gfr;
if (containsKey === "yes") {
gfr = 133 * Math.pow(serumCreatinine / 0.7, -1.209) * Math.pow(0.993, sex_coefficient) * Math.pow(race_factor, 0); // Race factor is not applied for transplant recipients in some versions, using 0 exponent for safety or 1.0 factor
if (gender === "male") {
gfr = 133 * Math.pow(serumCreatinine / 0.7, -1.209) * Math.pow(0.993, 1.012);
} else if (gender === "female") {
gfr = 133 * Math.pow(serumCreatinine / 0.7, -1.209) * Math.pow(0.993, 0.993);
} else { // nonbinary
gfr = 133 * Math.pow(serumCreatinine / 0.7, -1.209) * Math.pow(0.993, 1.003);
}
if (race === "black" && containsKey === "yes") { // Some sources suggest applying race factor for black transplant recipients, others don't. This is a common interpretation.
if (gender === "male") {
gfr = 133 * Math.pow(serumCreatinine / 0.7, -1.209) * Math.pow(0.993, 1.012) * 1.145;
} else if (gender === "female") {
gfr = 133 * Math.pow(serumCreatinine / 0.7, -1.209) * Math.pow(0.993, 0.993) * 1.159;
} else { // nonbinary
gfr = 133 * Math.pow(serumCreatinine / 0.7, -1.209) * Math.pow(0.993, 1.003) * 1.152;
}
}
} else {
// CKD-EPI 2021 Equation
var a = -1.154;
var b = -0.700; // For females
if (gender === "male") {
b = -0.700; // This coefficient is typically the same for males and females in newer versions
} else if (gender === "nonbinary") {
b = -0.700; // Using the same as male/female for non-binary
}
var r = 1.0; // For Black race, r = 1.145 for males, 1.159 for females
if (race === "black") {
if (gender === "male") {
r = 1.145;
} else if (gender === "female") {
r = 1.159;
} else { // nonbinary
r = 1.152; // Average for non-binary Black individuals
}
}
var result = Math.pow(serumCreatinine / r, a) * Math.pow(age, b) * 0.993; // 0.993 is the coefficient for females, and typically applied as a sex adjustment
if (gender !== "female") {
result = Math.pow(serumCreatinine / r, a) * Math.pow(age, b); // Base calculation without female coefficient if not female
}
if (gender === "female") {
result = Math.pow(serumCreatinine / r, a) * Math.pow(age, b) * 0.993;
} else if (gender === "male") {
result = Math.pow(serumCreatinine / r, a) * Math.pow(age, b);
} else { // nonbinary
result = Math.pow(serumCreatinine / r, a) * Math.pow(age, b) * 0.993; // Using female coefficient as a general adjustment, can be debated.
}
// Applying the CKD-EPI 2021 formula more accurately:
var scaff_val;
if (race === "black") {
if (gender === "male") {
scaff_val = -1.154;
} else if (gender === "female") {
scaff_val = -1.154;
} else { // nonbinary
scaff_val = -1.154; // Assuming the same exponent for non-binary individuals
}
} else {
scaff_val = -1.154;
}
var k;
if (gender === "male") {
k = 0.9;
} else if (gender === "female") {
k = 0.7;
} else { // nonbinary
k = 0.8; // Average
}
var equation_result = Math.pow(serumCreatinine / k, scaff_val) * Math.pow(age, -0.203) * 1.018; // 1.018 is for females, adjust if needed
if (gender === "female") {
equation_result = Math.pow(serumCreatinine / k, scaff_val) * Math.pow(age, -0.203) * 1.018;
} else if (gender === "male") {
equation_result = Math.pow(serumCreatinine / k, scaff_val) * Math.pow(age, -0.203);
} else { // nonbinary
equation_result = Math.pow(serumCreatinine / k, scaff_val) * Math.pow(age, -0.203) * 1.018; // Using female coefficient as a general adjustment
}
if (race === "black") {
if (gender === "male") {
equation_result = Math.pow(serumCreatinine / k, -1.154) * Math.pow(age, -0.203) * 1.151; // Black male
} else if (gender === "female") {
equation_result = Math.pow(serumCreatinine / k, -1.154) * Math.pow(age, -0.203) * 1.151 * 0.963; // Black female
} else { // nonbinary
equation_result = Math.pow(serumCreatinine / k, -1.154) * Math.pow(age, -0.203) * 1.151 * 0.98; // Estimated for non-binary Black individuals
}
} else { // Non-black race
if (gender === "male") {
equation_result = Math.pow(serumCreatinine / k, -1.154) * Math.pow(age, -0.203);
} else if (gender === "female") {
equation_result = Math.pow(serumCreatinine / k, -1.154) * Math.pow(age, -0.203) * 0.963;
} else { // nonbinary
equation_result = Math.pow(serumCreatinine / k, -1.154) * Math.pow(age, -0.203) * 0.98; // Estimated for non-binary individuals
}
}
gfr = equation_result;
}
var formattedGFR = gfr.toFixed(2);
var interpretation = "";
if (formattedGFR = 15 && formattedGFR = 30 && formattedGFR = 45 && formattedGFR = 60 && formattedGFR < 90) {
interpretation = "Kidney disease Stage 2 (Slightly decreased kidney function).";
} else {
interpretation = "Kidney disease Stage 1 (Normal or high GFR, but with other signs of kidney damage like protein in urine).";
}
resultDiv.innerHTML = `
Your estimated GFR is: ${formattedGFR} mL/min/1.73 m²Interpretation: ${interpretation}
Disclaimer: This is an estimate. Consult with your healthcare provider for accurate diagnosis and treatment.
`;
}
.gfr-calculator {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
.gfr-calculator h2 {
text-align: center;
margin-bottom: 15px;
color: #333;
}
.gfr-calculator p {
line-height: 1.6;
color: #555;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.form-group input[type="number"],
.form-group select {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Include padding and border in the element's total width and height */
}
.gfr-calculator button {
display: block;
width: 100%;
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.gfr-calculator button:hover {
background-color: #0056b3;
}
#result {
margin-top: 20px;
padding: 10px;
border: 1px solid #ddd;
background-color: #fff;
border-radius: 4px;
}
#result p {
margin-bottom: 10px;
}
#result strong {
color: #007bff;
}