added eGFR calc and test

This commit is contained in:
2026-04-12 23:58:05 +02:00
parent 12d2aa54f6
commit 637a392edb
8 changed files with 41 additions and 1 deletions
+1 -1
View File
@@ -10,4 +10,4 @@ ArithMedic offers:
Healthtech startups, EHR/EMR vendors, AIagentasaservice platforms, and large healthcare systems that pay for a managed, SLAbacked medicalscore API.
### Free / selfhosted users:
Clinicians, small medtech teams, research labs, universities, and internal dev teams who selfhost WiseMed for privacy, control, or prototyping without peruse fees..
Clinicians, small medtech teams, research labs, universities, and internal dev teams who selfhost ArithMedic for privacy, control, or prototyping without peruse fees.
View File
View File
+15
View File
@@ -0,0 +1,15 @@
def ckd_epi_2021(serum_creatinine: int, age: int, sex: str) -> int:
"""Returns estimated GFR in mL/min/1.73 m^2."""
if sex == "female":
alpha = -0.241
k = 0.7
else:
alpha = -0.302
k = 0.9
result = 142 * min(serum_creatinine/k, 1)**alpha * max(serum_creatinine/k, 1)**(-1.200) * 0.9938**age
return round(result * 1.012) if sex == "female" else round(result)
print("Female:", ckd_epi_2021(1, 60, "female"))
print("Male:", ckd_epi_2021(1, 60, "male"))
View File
View File
View File
+25
View File
@@ -0,0 +1,25 @@
import sys
import os
# Get the directory that contains the 'calculators' folder (the project root)
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Add the project root to the Python path
sys.path.append(project_root)
# Now you can import from the calculators module
from calculators.egfr import ckd_epi_2021
def test_egfr():
serum_creatinine = 1
age = 60
sex = "male"
assert ckd_epi_2021(serum_creatinine, age, sex) == 86
serum_creatinine = 1
age = 60
sex = "female"
assert ckd_epi_2021(serum_creatinine, age, sex) == 64