Skip to content

Commit bf0d3d5

Browse files
committed
fix small errors in MDRD
* raise error if crea is 0 * make sure gender is of correct type * add description * remove (ignored!) height
1 parent be617ff commit bf0d3d5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/medimetry/renal.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,32 @@ def cockcroft_gault(
77
weight: float,
88
creatinine: float,
99
gender: Gender,
10-
height: float | None = None,
1110
) -> int:
1211
"""
1312
Calculate creatinine clearance using Cockcroft-Gault formula.
1413
14+
This formula is still occasionally used, but it is no longer recommended in the
15+
literature. Its disadvantages include the fact that it was derived from an
16+
evaluation of only 249 participants, requires laboratories to know the patient's
17+
body weight, and does not normalize the result to body surface area.
18+
1519
Args:
1620
age (int): Age in years
1721
weight (float): Weight in kg
1822
creatinine (float): Serum creatinine in mg/dl
1923
gender (str): Gender (MALE or FEMALE)
20-
height (float, optional): Height in cm (not used in standard formula)
2124
2225
Returns:
2326
float: Creatinine clearance in mL/min
2427
"""
2528
assert weight > 0, "Weight must be positive"
2629
assert weight < 400, "Weight must be less than 400 kg"
2730
assert age > 0, "Age must be positive"
28-
assert creatinine >= 0, "Creatinine must be non-negative"
29-
assert gender in (Gender.MALE, Gender.FEMALE), "Gender must be MALE or FEMALE"
30-
assert height is None or (0 < height < 150), "Height must be positive and less than 150 cm"
31+
assert creatinine >= 0, "Creatinine must not be negative"
32+
assert isinstance(gender, Gender), "gender must be a Gender instance"
3133

34+
if float(creatinine) == 0.0:
35+
raise ValueError("Creatinine must be non-zero")
3236
# Base calculation: ((140 - age) * weight) / (72 * creatinine)
3337
clearance = ((140 - age) * weight) / (72 * creatinine)
3438

0 commit comments

Comments
 (0)