# Decision Tables for "Has Illegal Facts" Filter

## Field confirmed via introspection

### zq_zfba_xzcfjds (行政处罚决定书)
| Field | Type | Used For |
|-------|------|-----------|
| ajxx_ajbh | text | Case number join |
| xzcfjds_rybh | text | Person ID join |

### zq_zfba_byxzcfjds (不予行政处罚决定书)
| Field | Type | Used For |
|-------|------|-----------|
| ajxx_ajbh | text | Case number join |
| byxzcfjds_rybh | text | Person ID join |
| byxzcfjds_cbryj | text | **Processing opinion** — contains `违法事实不能成立` to exclude |
| byxzcfjds_cbr_sfzh | text | Handler ID number (NOT used for filtering) |
| byxzcfjds_cqr_sfzh | text | Maker ID number (NOT used for filtering) |

### zq_zfba_wenshu (法律文书表)
| Field | Type | Used For |
|-------|------|-----------|
| ajbh | text | Case number join |
| xgry_xm | text | **Person name** — used for join (NO rybh field in this table!) |
| wsmc | text | Document name — contains `终止侦查决定书` to exclude |

## Key Differences in Join Strategy
- Admin condition ①: `zq_zfba_xzcfjds` — join on **rybh** (人员编号)
- Admin condition ②: `zq_zfba_byxzcfjds` — join on **rybh** + filter `byxzcfjds_cbryj !~ '违法事实不能成立'`
- Criminal condition ①: `zq_zfba_byxzcfjds` — join on **rybh** + filter `byxzcfjds_cbryj ~ '违法事实不能成立'`
- Criminal condition ②: `zq_zfba_wenshu` — join on **xm** (姓名), NO rybh field available

## Admin vs Criminal Logic Summary
- **Admin**: EXISTS (keep if matched) — at least one of two tables has record
- **Criminal**: NOT EXISTS (keep if not matched) — neither exclusion condition triggers

## 送入专门教育学校 (wcnr_sfzxx table)

| Field | Type | Used For |
|-------|------|-----------|
| sfzhm | text | 身份证号 join key |
| rx_time | timestamp | 入校时间 — case_time must be <= this to count |
| bh | text | 编号 (NOT used for filtering) |
| xm | text | 姓名 (NOT used for filtering) |

**Logic**: A case is considered "送入" if `case_time <= rx_time` for the same person's id_card. Granularity is per case — same person with different cases may have different values.
