reworked structure

This commit is contained in:
2026-04-13 15:46:12 +02:00
parent 33514d2b94
commit e70bdd6496
16 changed files with 104 additions and 30 deletions
+5
View File
@@ -0,0 +1,5 @@
from fastapi import APIRouter
from api.egfr import ckd_epi_2021
router = APIRouter(prefix="/egfr", tags=["eGFR"])
router.include_router(ckd_epi_2021.router)
+2 -2
View File
@@ -8,7 +8,7 @@ REFERENCE = (
"without Race. N Engl J Med. 2021;385(19):1737-1749."
)
router = APIRouter(prefix="/egfr", tags=["eGFR"])
router = APIRouter()
@router.post("/ckd-epi-2021", response_model=CkdEpi2021Output)
def calculate_ckd_epi_2021(payload: CkdEpi2021Input) -> CkdEpi2021Output:
@@ -23,9 +23,9 @@ def calculate_ckd_epi_2021(payload: CkdEpi2021Input) -> CkdEpi2021Output:
try:
result = ckd_epi_2021(
serum_creatinine=payload.serum_creatinine,
unit=payload.unit,
age=payload.age,
sex=payload.sex,
unit=payload.unit,
)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Calculation error: {e}")
+3
View File
@@ -0,0 +1,3 @@
Metadata-Version: 2.4
Name: arithmedic
Version: 0.1.0
+15
View File
@@ -0,0 +1,15 @@
README.md
pyproject.toml
api/__init__.py
api/egfr/__init__.py
api/egfr/ckd_epi_2021.py
arithmedic.egg-info/PKG-INFO
arithmedic.egg-info/SOURCES.txt
arithmedic.egg-info/dependency_links.txt
arithmedic.egg-info/top_level.txt
calculators/__init__.py
calculators/egfr/__init__.py
calculators/egfr/ckd_epi_2021.py
schemas/__init__.py
schemas/egfr/__init__.py
schemas/egfr/ckd_epi_2021.py
+1
View File
@@ -0,0 +1 @@
+3
View File
@@ -0,0 +1,3 @@
api
calculators
schemas
View File
+2 -2
View File
@@ -1,5 +1,5 @@
from fastapi import FastAPI
from api.egfr import ckd_epi_2021 as egfr_router
from api.egfr import router as egfr_router
app = FastAPI(
title="ArithMedic",
@@ -7,4 +7,4 @@ app = FastAPI(
version="0.1.0",
)
app.include_router(egfr_router.router)
app.include_router(egfr_router)
+10
View File
@@ -0,0 +1,10 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "arithmedic"
version = "0.1.0"
[tool.setuptools.packages.find]
include = ["api*", "calculators*", "schemas*"]
+49
View File
@@ -0,0 +1,49 @@
annotated-doc==0.0.4
annotated-types==0.7.0
anyio==4.13.0
-e git+ssh://git@github.com/loysharosen/arithmedic.git@33514d2b9498beeb62d5506543ca75c031402bb4#egg=arithmedic
certifi==2026.2.25
click==8.3.2
dnspython==2.8.0
email-validator==2.3.0
fastapi==0.135.3
fastapi-cli==0.0.24
fastapi-cloud-cli==0.16.1
fastar==0.10.0
greenlet==3.4.0
h11==0.16.0
httpcore==1.0.9
httptools==0.7.1
httpx==0.28.1
idna==3.11
iniconfig==2.3.0
Jinja2==3.1.6
markdown-it-py==4.0.0
MarkupSafe==3.0.3
mdurl==0.1.2
packaging==26.0
pluggy==1.6.0
pydantic==2.12.5
pydantic-extra-types==2.11.2
pydantic-settings==2.13.1
pydantic_core==2.41.5
Pygments==2.20.0
pytest==9.0.3
python-dotenv==1.2.2
python-multipart==0.0.26
PyYAML==6.0.3
rich==15.0.0
rich-toolkit==0.19.7
rignore==0.7.6
sentry-sdk==2.57.0
shellingham==1.5.4
SQLAlchemy==2.0.49
starlette==1.0.0
typer==0.24.1
typing-inspection==0.4.2
typing_extensions==4.15.0
urllib3==2.6.3
uvicorn==0.44.0
uvloop==0.22.1
watchfiles==1.1.1
websockets==16.0
View File
View File
View File
@@ -0,0 +1,14 @@
from calculators.egfr.ckd_epi_2021 import ckd_epi_2021
def test_ckd_epi_2021_male_mg_dl():
assert ckd_epi_2021(serum_creatinine=1, age=60, sex="male", unit="mg/dL") == 86.16262077966914
def test_ckd_epi_2021_female_mg_dl():
assert ckd_epi_2021(serum_creatinine=1, age=60, sex="female", unit="mg/dL") == 64.4950003539451
def test_ckd_epi_2021_male_umol_l():
assert ckd_epi_2021(serum_creatinine=88.42, age=60, sex="male", unit="umol/L") == 86.16262077966914
def test_ckd_epi_2021_female_umol_l():
assert ckd_epi_2021(serum_creatinine=88.42, age=60, sex="female", unit="umol/L") == 64.4950003539451
-26
View File
@@ -1,26 +0,0 @@
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.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.ckd_epi_2021 import ckd_epi_2021
def test_ckd_epi_2021():
serum_creatinine = 1
age = 60
sex = "male"
assert ckd_epi_2021(serum_creatinine, age, sex) == 86.16262077966914
serum_creatinine = 1
age = 60
sex = "female"
assert ckd_epi_2021(serum_creatinine, age, sex) == 64.4950003539451