added eGFR calc and test
This commit is contained in:
@@ -10,4 +10,4 @@ ArithMedic offers:
|
||||
Health‑tech startups, EHR/EMR vendors, AI‑agent‑as‑a‑service platforms, and large healthcare systems that pay for a managed, SLA‑backed medical‑score API.
|
||||
|
||||
### Free / self‑hosted users:
|
||||
Clinicians, small med‑tech teams, research labs, universities, and internal dev teams who self‑host WiseMed for privacy, control, or prototyping without per‑use fees..
|
||||
Clinicians, small med‑tech teams, research labs, universities, and internal dev teams who self‑host ArithMedic for privacy, control, or prototyping without per‑use fees.
|
||||
|
||||
@@ -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"))
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user