# QA — BariERASRecov-Kor

검수 일자: 2026-05-27
검수자: Claude (자동) — 인간 review 권장

> 본 도구는 합성 데이터 기반 참고용·연구용 KPI 대시보드입니다.
> 임상 의사결정용 아님. (Not for clinical decision making.)

---

## 1. Python 구문 체크 (ast.parse)

명령:
```bash
python3 -c "import ast; ast.parse(open('<file>').read())"
```

| 파일 | 결과 |
| --- | --- |
| `main.py` | OK |
| `app.py` | OK |
| `modules/__init__.py` | OK |
| `modules/ingest.py` | OK |
| `modules/eras.py` | OK |
| `modules/procedure.py` | OK |
| `modules/hypo.py` | OK |
| `modules/outpatient.py` | OK |
| `modules/report.py` | OK |

**→ 9/9 PASS**

---

## 2. CLI `--help` 실행 가능성

명령:
```bash
python3 main.py --help
```

결과: **PASS** — `argparse` 기반 help 정상 출력 (한글 description / 5개 핵심 액션 인자 노출).

---

## 3. 합성 데이터 생성 (`--gen-data`)

명령:
```bash
python3 main.py --gen-data --n 400 --seed 42
```

결과: **PASS**
- N=400, 5개 술식 stratify (RYGB / SG / OAGB / SADI / DJB)
- 4개 ward (GS-A/B/C/D), 5명 surgeon (PI-1..5)
- de-id: `SHA-256 trunc(8) + date-shift` (offset = 343d, random per seed)
- 6 CSV 생성 (`patients.csv`, `intraop.csv`, `pod0_3.csv`, `pod4_30.csv`, `pod90_outpt.csv`, `hypo_events.csv`)

CSV 로드 smoke test:

| 파일 | rows | cols |
| --- | --- | --- |
| patients.csv | 400 | 28 |
| intraop.csv | 400 | 9 |
| pod0_3.csv | 400 | 13 |
| pod4_30.csv | 400 | 22 |
| pod90_outpt.csv | 400 | 14 |
| hypo_events.csv | 158 | 6 |

→ **PASS**

---

## 4. 분석 (`--analyze`)

명령:
```bash
python3 main.py --analyze --top 8
```

표준 라이브러리만으로 실행됨 (numpy/pandas 등 사용 안 함). 결과 발췌:

- **ERAS bundle ward radar** (overall %):
  GS-A 91.7, GS-B 86.8, GS-C 81.3, GS-D 75.0
- **MBSAQIP analog measures** (target 대비):
  - leak 2.20% [WATCH, target ≤ 1.5]
  - bleeding 4.50% [WATCH]
  - VTE 0.00% [PASS]
  - reop 2.80% [WATCH]
  - readmit30 6.00% [WATCH]
  - mortality30 0.00% [PASS]
  - marginal ulcer 1.00% [PASS]
- **Procedure stratification**: 5/5 술식 표시, O/E ratio 계산.
- **Hypo time distribution**: 4 buckets (POD0_3 immediate, POD30_90 delayed,
  POD4_30 dumping early/late), KDA action flag (L2+ ≥ 20%) 표기됨.
- **POD0-90 outpatient adherence**: 술식별 POD7/30/60/90 visit %, %TWL,
  HbA1c, GLP-1RA add-on, reop trigger.
- **30-day readmit/mortality + KM step**: KM curve `S(t)` head 10일 출력.

→ **PASS**

---

## 5. 리포트 생성 (`--report`)

명령:
```bash
python3 main.py --report --lang ko --out reports/bari_eras_recov_kor_ko.docx
python3 main.py --report --lang en --out reports/bari_eras_recov_kor_en.docx
```

(또는 `python3 main.py --all` 로 ko + en 일괄 생성됨)

산출물:
- `reports/bari_eras_recov_kor_ko.md` (~4.7 KB)
- `reports/bari_eras_recov_kor_ko.docx` (~38 KB) — `python-docx` 가용 시 생성
- `reports/bari_eras_recov_kor_en.md` (~4.5 KB)
- `reports/bari_eras_recov_kor_en.docx` (~38 KB)

리포트 구성:
1. 데이터 개요 (N, de-id 방법)
2. ERAS Society 비만수술 protocol 부합률 (ward radar 표)
3. MBSAQIP / ASMBS quality measure 패널
4. 5+ 술식 stratification (O/E ratio 포함)
5. post-bariatric hypoglycemia + dumping 시간 분포 (KDA action flag)
6. POD0-90 outpatient follow-up & transition
7. 30-day readmission / mortality + KM head
8. KASMBS / KSSO / KOSSO 호환 quality summary
9. 디스클레이머 (참고용·연구용)

→ **PASS**

---

## 6. Streamlit dashboard (`app.py`)

`app.py` 는 streamlit / plotly / pandas / numpy 가 설치된 가상환경에서만 실제 기동
가능. 구문은 `ast.parse` 로 검증 완료. 런타임 검증은 다음 명령으로 수행:

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
streamlit run app.py
```

본 자동 검수 환경에서는 streamlit 미설치 — 런타임 검증은 수동.
ImportError handling 은 `_missing_deps_panel()` 에서 안내 메시지 출력 후 종료
하도록 구현됨.

→ **(런타임) MANUAL**  /  **(구문)** PASS

---

## 7. 의학적 안전성

- README.md 상단·하단, app.py 상단 `st.warning`, 모든 리포트 상단/하단에
  "**참고용·연구용 / Not for clinical decision making**" 디스클레이머 노출 확인.
- de-identification 명시 (SHA-256 truncated hash + date-shift) — `modules/ingest.py`
  와 README에 기록.
- 외부 네트워크 / API 호출 0건 — `requests`, `urllib` 등 import 없음.
  (`grep -r "requests\|urllib" modules/ main.py app.py` 결과 0건)

→ **PASS**

---

## 8. 종합 판정

| 항목 | 상태 |
| --- | --- |
| 구문 (9/9) | PASS |
| CLI --help | PASS |
| --gen-data → 6 CSV | PASS |
| CSV 로드 | PASS |
| --analyze (stdlib only) | PASS |
| --report (md + docx, ko+en) | PASS |
| Streamlit 구문 | PASS |
| Streamlit 런타임 | MANUAL (venv 필요) |
| 의학 디스클레이머 | PASS |
| de-id 명시 | PASS |
| 외부 네트워크 0 | PASS |

**최종**: BariERASRecov-Kor — ⚠️ (CLI/분석/리포트 PASS, Streamlit 런타임은 venv
설치 후 수동 검증 필요)
