# InsuTrialKit-Kor (인슐린트라이얼킷한국)

> **연구·교육용 MVP. 실제 임상의사결정에 사용 금지.**
> This tool is for research and educational use only. Do NOT use for clinical decision making.

## 목적
인슐린펌프·CGM 다기기(multi-device) raw data를 long-form 표준 포맷으로 통합하고, ADA 2023 Standards of Care 기반 CGM outcome 14종을 일괄 산출하며, 한국 reference effect size 기반 sample size calculator와 Korean RCT report를 생성하는 CLI 도구.

## 도메인 / 카테고리
- **도메인**: DM (T1DM/T2DM closed-loop)
- **카테고리**: 인체실험 도구 (RCT 데이터 수집·계산기)

## 지원 기기 (8종)
| Device | Type | Adapter |
|---|---|---|
| Dexcom Clarity | CGM | Full (CSV) |
| Abbott Libre LibreView | CGM | Full (CSV) |
| Tandem t:connect | Pump | Full (CSV) |
| Medtronic CareLink | Pump | Full (CSV/XLSX header pattern) |
| Omnipod View | Pump | Stub (signature dispatch) |
| CamAPS Cloud | Hybrid CL | Stub |
| MiniMed 780G | AID | Stub |
| Guardian 4 | CGM | Stub |

## 표준 long-form schema
```
subject_id, timestamp_KST, glucose_mg_dl, sensor_type,
pump_basal_uph, pump_bolus_u, meal_carb_g, exercise_flag
```

## ADA 2023 outcome 14종
1. TIR (70-180 mg/dL)
2. TBR Level 1 (<70)
3. TBR Level 2 (<54)
4. TAR Level 1 (>180)
5. TAR Level 2 (>250)
6. Mean glucose
7. GMI (Glucose Management Indicator)
8. CV%
9. SD (mg/dL)
10. MAGE (간이 추정, mean amplitude of glycemic excursion)
11. J-index
12. Hypoglycemia event count (≥15min <70)
13. Sensor wear time %
14. Days with data

## 설치 / 실행
- Python 3.9+ (3.11 권장), pandas, numpy
- 외부 네트워크/API 호출 없음

```bash
# 1) 합성 데이터 생성 + end-to-end 데모
python3 main.py demo

# 2) raw 폴더 → long-form 표준화
python3 main.py ingest --input data/ --output out.csv

# 3) outcome 산출 + report 생성
python3 main.py outcomes --input out.csv --output report.md

# 4) sample size 계산
python3 main.py samplesize --delta 5 --sd 12 --alpha 0.05 --power 0.8

# 5) 합성 데이터만 재생성
python3 main.py gendata
```

## 검수 체크리스트
- [ ] `python3 -c "import ast; ast.parse(open('FILE').read())"` 모든 .py 통과
- [ ] `python3 main.py --help` 동작
- [ ] `python3 main.py demo` end-to-end 통과 (out.csv + report.md 생성)
- [ ] TIR ∈ [0,100], GMI ∈ [4,14] sanity check
- [ ] sample size (ΔTIR=5, SD=12, α=0.05, power=0.8) → N ≈ 90~100/arm

## 출처 / Reference
- ADA 2023 Standards of Care, Chapter on "Diabetes Technology" (CGM metrics)
- Battelino T et al. ATTD 2019 / ATTD 2022 consensus on CGM time-in-range
- Bergenstal RM et al. GMI formula (Diabetes Care 2018)
- Korean reference effect size: 가상의 한국인 closed-loop 임상연구 메타 (placeholder, 실제 적용 시 KDA/KAID 데이터로 교체 필요)

## 디스클레이머 (재강조)
이 도구는 **연구 및 교육 목적**으로만 사용되며, 어떠한 경우에도 환자 진료, 약물 용량 조정, 또는 임상 의사결정에 직접 사용되어서는 안 됩니다. 실제 사용자/환자 raw data 처리 시에는 IRB 승인과 적절한 보안/개인정보 보호 절차를 반드시 거쳐야 합니다.
