# CHANGELOG — InHospGlyWard-Kor (인합글라이워드코어)

## [2026-05-27]

### 수행 내용
- 종합병원 입원 환자 glycemic management cohort dashboard MVP (idx=1) 빌드
- 5개 핵심 기능을 5개 modules + Streamlit `app.py` + CLI `main.py` 로 구현
- 320명 환자 / 8 ward (MICU/SICU/CCU/NICU/ER/GW-IM/GW-SG/GW-OG) / 6 DM type
  합성 데이터 4종 (patients · poct_bg · insulin_orders · episodes) 생성
- ADA Standards of Care 2025 inpatient TIR (100-180 GW / 140-180 ICU) +
  KDA 2023 입원당뇨 + AACE + SHM GCMIP + NICE-SUGAR / DIGAMI / GIK 표준 매핑
- 한국어/영문 SHM GCMIP-analog KPI 리포트 (md + docx) 4개 샘플 생성

### 주요 결정 사항
- **표준 lib first**: argparse, csv, hashlib 등 표준 lib 만으로 `--help` /
  `--gen-data` / `--analyze` / `--report` 전체 흐름이 동작하도록 작성.
  무거운 deps (streamlit/plotly/lifelines/python-docx) 누락 시 friendly fallback.
  (이유: 검수 환경이 venv 없이도 syntax/CLI 검증 가능해야 함)
- **lifelines KM 폴백**: lifelines 가 없으면 step-wise KM 수동 추정. 결과 거의 동일.
- **de-identification audit trail**: SHA-256(salt+pid)[:10] surrogate +
  study-day index date-shift. `IngestReport.deid_method` 에 기록.
- **합성 데이터 규모**: 명세 200~500 범위에서 중간값 320 선택 (POCT 17k+).
- **단순한 protocol compliance heuristic**: DKA/HHS 는 IV rate band + K+ supp +
  fluid + transition regimen all-or-none. 정교한 임상 채점은 후속.

### 변경된 파일
- `README.md` — 5개 기능·실행법·검수 체크리스트·출처·디스클레이머
- `requirements.txt` — pinned deps (streamlit 1.36.0, lifelines 0.28.0 등)
- `main.py` — CLI 진입점 (--gen-data / --analyze / --report / --all)
- `app.py` — Streamlit 대시보드 6 탭
- `modules/__init__.py`
- `modules/ingest.py` — ingest + de-id + synthetic generator
- `modules/tir.py` — ward TIR / hypo / hyper / persistent + KDA score
- `modules/regimen.py` — basal-bolus vs sliding-scale-only 비율
- `modules/episode.py` — DKA/HHS/hypo/hyper episode trajectory + protocol 부합
- `modules/subgroup.py` — perioperative / steroid / TPN-PN / ER 서브그룹
- `modules/transition.py` — discharge transition + 30-day readmission KM
- `modules/report.py` — SHM GCMIP-analog 한국어/영문 md + docx
- `data/patients.csv`, `poct_bg.csv`, `insulin_orders.csv`, `episodes.csv` — 합성
- `reports/inhospglyward_ko.{md,docx}`, `inhospglyward_en.{md,docx}` — 샘플
- `QA.md` — 검수 로그

### 재현 방법
```bash
cd projects/2026-05-27-1-in-hosp-gly-ward-kor
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python3 main.py --all              # gen -> analyze -> report
streamlit run app.py               # 대시보드
```
