MIPD β Model-Informed Precision Dosing
Hα» thα»ng tα»i Ζ°u liα»u lượng thuα»c dα»±a trΓͺn Pharmacokinetics/Pharmacodynamics (PK/PD) cho bα»nh viα»n Viα»t Nam.
Dashboard
Results (PK Curve 3 lα»p)
VPC Chart
Bland-Altman Plot
NPDE Histogram + QQ
XΓ’y dα»±ng hα» thα»ng MIPD hα» trợ dược sΔ© lΓ’m sΓ ng tα»i Ζ°u liα»u vancomycin:
𧬠MΓ΄ hΓ¬nh PK dΓ’n sα» (Population PK) β 2-compartment IV
π Bayesian estimation cΓ‘ thα» hΓ³a (MAP, Laplace, ADVI, EP, SMC, MCMC, Adaptive Pipeline)
π Tα»i Ζ°u liα»u AUCββ/MIC-guided vα»i Monte Carlo PTA
π‘οΈ Hα» thα»ng an toΓ n 5 lα»p bαΊ£o vα» bα»nh nhΓ’n
π€ AI/ML: phΓ‘t hiα»n bαΊ₯t thΖ°α»ng TDM, sΓ ng lα»c covariate
β
ThαΊ©m Δα»nh mΓ΄ hΓ¬nh (MPE, MAPE, CCC, NPDE, VPC, Bland-Altman)
ποΈ KiαΊΏn trΓΊc hα» thα»ng
Frontend (:5173) β API Gateway (:5000) β PK Engine (:8000)
React/Vite ASP.NET + YARP Python/FastAPI
JWT Auth
RBAC 4 roles
Audit Trail
MIPD/
βββ src/
β βββ frontend/ # React SPA (Vite)
β β βββ src/
β β β βββ pages/
β β β β βββ Dashboard.jsx # Tα»ng quan + API health check
β β β β βββ Dosing.jsx # Dose Calculator β Bayesian API
β β β β βββ Results.jsx # PK curve 3 lα»p + SHAP + params
β β β β βββ Validation.jsx # VPC, Bland-Altman, NPDE + CSV upload
β β β β βββ Patients.jsx # QuαΊ£n lΓ½ bα»nh nhΓ’n
β β β β βββ Settings.jsx # CΓ i ΔαΊ·t hα» thα»ng
β β β β βββ Login.jsx # ΔΔng nhαΊp JWT
β β β βββ auth/AuthContext.jsx # JWT context + protected routes
β β β βββ api/client.js # API client (auto JWT injection)
β β β βββ styles.css # Design system
β β βββ sample_data/ # CSV mαΊ«u cho Validation
β β βββ vite.config.js # Proxy β Gateway
β β
β βββ backend/MIPD.ApiGateway/ # .NET 8 API Gateway
β β βββ Program.cs # YARP + JWT + CORS + Health
β β βββ appsettings.json # Route config
β β βββ Services/
β β β βββ AuthService.cs # User management + login
β β β βββ JwtService.cs # JWT token generation
β β β βββ AuditService.cs # Audit trail logging
β β β βββ CacheService.cs # Redis/InMemory cache
β β βββ Middleware/
β β βββ AuditMiddleware.cs # Request/response auditing
β β
β βββ pk-engine/ # Python PK Engine (FastAPI)
β βββ pk/ # Core PK models
β β βββ models.py # PatientData, DoseEvent, PKParams
β β βββ analytical.py # Analytical 2-comp solutions
β β βββ solver.py # RK45 ODE solver
β β βββ population.py # Population PK (Vancomycin VN)
β β βββ clinical.py # CrCL, eGFR, IBW, ABW
β βββ bayesian/ # 7 inference methods
β β βββ map_estimator.py # MAP
β β βββ laplace.py # Laplace approximation
β β βββ advi.py # Variational Inference
β β βββ ep.py # Expectation Propagation
β β βββ smc.py # Sequential Monte Carlo
β β βββ mcmc.py # MCMC/NUTS (NumPyro)
β β βββ engine.py # Adaptive 3-Layer Pipeline β
β βββ dosing/optimizer.py # Dose optimization + PTA
β βββ ai/ # AI/ML features
β β βββ anomaly_detection.py # Swift Hydra 4-head QC
β β βββ ml_screening.py # RF+NN+SVR covariate screening
β β βββ gp_bnn.py # GP + BNN models
β βββ validation/metrics.py # MPE, MAPE, RMSE, CCC, NPDE
β βββ api/ # FastAPI routes + schemas
β β βββ main.py # App entry + CORS
β β βββ schemas.py # Pydantic models
β β βββ safety.py # 5-layer guardrails
β β βββ routes_pk.py # /pk/*
β β βββ routes_bayesian.py # /bayesian/*
β β βββ routes_dosing.py # /dosing/*
β β βββ routes_ai.py # /ai/*
β βββ tests/ # pytest test suite
β
βββ docker/
β βββ init-db.sh # Database init script
βββ docker-compose.yml # Multi-service orchestration
βββ .github/workflows/ci.yml # GitHub Actions CI/CD
βββ .env.example # Environment variables template
π Quick Start (Demo cα»₯c bα»)
Python 3.11+ (PK Engine)
.NET 8 SDK (API Gateway)
Node.js 18+ (Frontend)
git clone https://github.com/< your-org> /MIPD.git
cd MIPD
2. ChαΊ‘y PK Engine (Terminal 1)
cd src/pk-engine
python -m venv .venv
.venv\S cripts\a ctivate # Windows
pip install -r requirements.txt
uvicorn api.main:app --port 8000 --reload
β Swagger UI: http://localhost:8000/docs
3. ChαΊ‘y API Gateway (Terminal 2)
cd src/backend/MIPD.ApiGateway
dotnet run --urls " http://localhost:5000"
β Gateway: http://localhost:5000 (JSON info)
β Health: http://localhost:5000/health
4. ChαΊ‘y Frontend (Terminal 3)
cd src/frontend
npm install
npm run dev
β App: http://localhost:5173
Email
MαΊt khαΊ©u
Vai trΓ²
admin@mipd.vn
admin123
Admin
dr.nguyen@mipd.vn
doctor123
Physician
ds.tran@mipd.vn
pharma123
Pharmacist
nurse.le@mipd.vn
nurse123
Nurse
Method
Endpoint
Chα»©c nΔng
POST
/auth/login
ΔΔng nhαΊp β JWT token
POST
/auth/register
ΔΔng kΓ½ tΓ i khoαΊ£n
GET
/auth/me
ThΓ΄ng tin user [Authorized]
GET
/health
Health check
GET
/audit/recent
Audit log [Admin]
PK Engine (:8000 qua Gateway /api/*)
Method
Endpoint
Chα»©c nΔng
GET
/
PK Engine health
GET
/docs
Swagger UI
POST
/pk/predict
Dα»± ΔoΓ‘n nα»ng Δα» + AUC
POST
/pk/clinical
CrCL, eGFR, IBW, ABW
POST
/bayesian/estimate
Bayesian estimation (7 methods)
POST
/dosing/recommend
KhuyαΊΏn nghα» liα»u + PTA
POST
/dosing/cfr
Cumulative Fraction of Response
POST
/ai/anomaly-check
Kiα»m tra chαΊ₯t lượng TDM
POST
/ai/screen-covariates
SΓ ng lα»c covariate
POST
/ai/validate-metrics
MPE, MAPE, RMSE, CCC
Routing (Vite β Gateway β PK Engine)
Frontend /api/bayesian/estimate
β Vite proxy β localhost:5000/api/bayesian/estimate
β YARP Gateway β localhost:8000/bayesian/estimate (strip /api prefix)
π‘οΈ Hα» thα»ng An toΓ n (5 Lα»p)
Lα»p
BαΊ£o vα»
VΓ dα»₯
1. Input Validation
ChαΊ·n dα»― liα»u vΓ΄ lΓ½
Weight < 10 kg, Age > 120
2. PK Plausibility
PK params bαΊ₯t thΖ°α»ng
CL = 0.01 L/h
3. Dose Limits
Hard cap liα»u tα»i Δa
Max 3000 mg vancomycin
4. Confidence Check
Reject CI quΓ‘ rα»ng
CI ratio > 3.0
5. Risk Score
Tα»ng hợp cαΊ£nh bΓ‘o
0.0 (safe) β 1.0 (reject)
π Validation (CSV Upload)
Trang Validation hỠtrợ upload CSV trực tiếp. File CSV mẫu nằm trong src/frontend/sample_data/:
File
Cα»t
Mα»₯c ΔΓch
vpc_sample.csv
ID, TIME, DV, PRED, DOSE, WT
Visual Predictive Check
bland_altman_sample.csv
Patient, Method1, Method2
Bland-Altman plot
npde_sample.csv
ID, TIME, DV, PRED, IPRED
NPDE histogram + QQ plot
# Copy .env
cp .env.example .env
# Build & run all services
docker compose up --build -d
# Check logs
docker compose logs -f
# PK Engine tests
cd src/pk-engine
python -m pytest tests/ -v
# Specific test suites
python -m pytest tests/test_bayesian.py -v # Bayesian methods
python -m pytest tests/test_api_safety.py -v # Safety guardrails
python -m pytest tests/test_validation_ai.py -v # AI + validation
Component
Technology
Frontend
React 18, Vite 5, Recharts
API Gateway
.NET 8, YARP, JWT Bearer
PK Engine
Python 3.11, FastAPI, NumPy, SciPy
MCMC
JAX, NumPyro (Linux/WSL)
AI/ML
scikit-learn, BNN
Cache
Redis / InMemory fallback
CI/CD
GitHub Actions
Container
Docker, docker-compose
Vai trΓ²
Quyα»n
Admin
Full access + audit log
Physician
Xem kαΊΏt quαΊ£ + ra y lα»nh
Pharmacist
Dose calculator + validation
Nurse
Xem phΓ‘c Δα» Δiα»u trα»
MIT License