# DKDComposite-Adj (디케이디컴포지트엣지)

> DKD trial composite endpoint auto-adjudication MVP — 단일 `index.html` standalone web app

## 한 줄 요약
DKD trial 환자별 eGFR/UACR/creatinine/동반약물 longitudinal 입력 → CKD-EPI 2021 race-free + sustained decline 자동 confirmation → 5점 composite endpoint 자동 도달 판정 → 2-reader paired blinded adjudication → DSMB-ready dashboard.

## 도메인 / 카테고리
- **도메인**: DM (Diabetic Kidney Disease)
- **카테고리**: 인체실험 도구 (RCT/observational study 설계·데이터 수집·계산기)
- **사용 대상**: trial sponsor, CRO, DSMB, CEC 보조

## ⚠️ 디스클레이머
본 도구는 **연구용 · DSMB 보조용 prototype**이며, 실제 trial endpoint 판정은 sponsor/CEC의 공식 SOP 및 통계분석계획서(SAP)를 따라야 합니다. 의학적 의사결정의 단독 근거로 사용하지 마십시오.

## 5개 핵심 기능
1. **Multi-source ingest + 표준 schema 변환** — REDCap/Medidata 호환 eCRF CSV 업로드 + 표준 schema preview.
2. **eGFR sustained decline + UACR doubling 자동 판정** — CKD-EPI 2021 race-free formula 구현, configurable threshold (30%/40%/57%) × sustained window (≥28/30/90일) × consecutive confirmation visits.
3. **5점 composite endpoint 자동 도달** — (i) eGFR sustained decline (ii) UACR doubling (iii) ESKD (dialysis≥90d · transplant · eGFR<15 sustained) (iv) renal death (v) CV death. First event date + censoring + Kaplan-Meier plot.
4. **2-reader paired blinded adjudication UI** — case별 patient ID 마스킹, reader1/reader2 칸 좌우 random order, 불일치 시 3rd adjudicator routing, Cohen's κ 자동 계산.
5. **DSMB dashboard + 한국어 보고서** — per-group KPI · primary composite KM · 동반약물 covariate sensitivity (SGLT2i / Finerenone / GLP-1RA ever-use 토글) · CDISC ADRENAL/ADKID schema preview · 인쇄용 한국어 site-level summary.

## 파일 구성
```
2026-05-12-1-dkd-composite-adj/
├── README.md
├── index.html                # 단일 standalone web app
├── data/
│   └── demo_subjects.csv     # 30명 합성 longitudinal 데이터
└── QA.md
```

## 실행법

### 권장 (전 기능 정상 동작)
프로젝트 디렉토리에서 로컬 정적 서버 실행 후 브라우저 접속:
```
cd "2026-05-12-1-dkd-composite-adj"
python3 -m http.server 8765
# → http://localhost:8765/index.html
```

### 간이 (CSV 직접 업로드)
1. `index.html`을 브라우저에서 더블클릭으로 연다.
2. "CSV 업로드" 입력으로 `data/demo_subjects.csv`를 선택한다.
   (file:// 환경에서는 fetch가 막혀 "demo 로드" 버튼이 동작하지 않을 수 있다.)

### 의존성
- 외부 네트워크 호출 0개 (pinned CDN: Chart.js 4.4.0, Papa Parse 5.4.1).
- CDN 차단 환경에서도 핵심 표/판정 로직은 동작 (KM plot만 비활성).

## CKD-EPI 2021 race-free formula 구현
```
여성: eGFR = 142 × min(Scr/0.7, 1)^-0.241 × max(Scr/0.7, 1)^-1.200 × 0.9938^age × 1.012
남성: eGFR = 142 × min(Scr/0.9, 1)^-0.302 × max(Scr/0.9, 1)^-1.200 × 0.9938^age
```

## 동반약물 ATC 매핑 (sensitivity covariate)
| Flag | ATC prefix | 예시 약물 |
|---|---|---|
| SGLT2i | A10BK | empagliflozin (A10BK03), dapagliflozin (A10BK01), canagliflozin (A10BK02) |
| Finerenone | C03DA05 | finerenone (MRA) |
| GLP-1RA | A10BJ | semaglutide (A10BJ06), liraglutide (A10BJ02) |

## 검수 체크리스트
- [x] `index.html` HTML 구문 정상 (`<html>`/`</html>`/`<script>` 닫힘 grep)
- [x] `data/demo_subjects.csv` 존재 + 헤더 일치
- [x] 30명 환자 (S001~S030), 각 baseline + 최대 6 follow-up visit
- [x] decline events 포함: S005 / S012 / S020 (40% eGFR drop)
- [x] UACR doubling: S008 / S015
- [x] ESKD: S020 (HD @ 30mo), S012 (transplant @ 36mo)
- [x] renal death: S025, CV death: S018
- [x] 동반약물 ATC: ARB · SGLT2i · finerenone · GLP-1RA · statin 혼합
- [x] 의학적 디스클레이머 본문 상단 + 보고서 footer 양쪽 포함

## 출처 / 근거 참고
- KDIGO 2024 CKD guideline (composite endpoint 정의 framework)
- Inker LA et al. NEJM 2021 — CKD-EPI 2021 race-free equation
- FDA Guidance (2024) — Chronic Kidney Disease: Developing Drugs for Treatment (composite endpoint, sustained decline confirmation 요건)
- ICH E9(R1) — adjudication & blinded review
