feat(iit): Implement real-time quality control system
Summary: - Add 4 new database tables: iit_field_metadata, iit_qc_logs, iit_record_summary, iit_qc_project_stats - Implement pg-boss debounce mechanism in WebhookController - Refactor QC Worker for dual output: QC logs + record summary - Enhance HardRuleEngine to support form-based rule filtering - Create QcService for QC data queries - Optimize ChatService with new intents: query_enrollment, query_qc_status - Add admin batch operations: one-click full QC + one-click full summary - Create IIT Admin management module: project config, QC rules, user mapping Status: Code complete, pending end-to-end testing Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,10 +4,11 @@
|
||||
> **更新日期:** 2026-02-05
|
||||
> **关联文档:** [IIT Manager Agent V2.6 综合开发计划](./IIT%20Manager%20Agent%20V2.6%20综合开发计划.md)
|
||||
>
|
||||
> **V2.9 更新**:
|
||||
> **V2.9.1 更新**:
|
||||
> - 扩展 `iit_skills` 表支持 Cron Skill(主动提醒)
|
||||
> - 扩展 `iit_conversation_history` 表增加反馈字段
|
||||
> - 更新 `iit_project_memory` 内容结构(用户画像)
|
||||
> - **新增 `iit_pii_audit_log` 表**:PII 脱敏审计日志(合规必需)
|
||||
|
||||
---
|
||||
|
||||
@@ -17,6 +18,7 @@
|
||||
|------|------|-------|--------|
|
||||
| `iit_skills` | Skill 配置存储 | 1 | P0 |
|
||||
| `iit_field_mapping` | 字段名映射字典 | 1 | P0 |
|
||||
| `iit_pii_audit_log` | PII 脱敏审计日志 | 1.5 | P0 |
|
||||
| `iit_task_run` | SOP 任务执行记录 | 2 | P0 |
|
||||
| `iit_pending_actions` | 待处理的违规记录 | 2 | P0 |
|
||||
| `iit_conversation_history` | 对话历史(流水账) | 2 | P1 |
|
||||
@@ -159,6 +161,64 @@ INSERT INTO iit_field_mapping (project_id, alias_name, actual_name) VALUES
|
||||
|
||||
---
|
||||
|
||||
## 2.5 Phase 1.5:隐私安全表(P0 合规必需)
|
||||
|
||||
### 2.5.1 iit_pii_audit_log - PII 脱敏审计日志
|
||||
|
||||
> **重要**:临床数据包含大量患者隐私信息(姓名、身份证、手机号),在调用第三方 LLM 之前**必须脱敏**。
|
||||
> 此表用于存储脱敏记录,便于事后合规审计。
|
||||
|
||||
```prisma
|
||||
model IitPiiAuditLog {
|
||||
id String @id @default(uuid())
|
||||
projectId String
|
||||
userId String // 操作者
|
||||
sessionId String // 会话 ID(关联 conversation_history)
|
||||
|
||||
// 脱敏内容(加密存储)
|
||||
originalHash String // 原始内容的 SHA256 哈希(不存明文)
|
||||
maskedPayload String @db.Text // 脱敏后发送给 LLM 的内容
|
||||
maskingMap String @db.Text // 加密存储的映射表 { "[PATIENT_1]": "张三", ... }
|
||||
|
||||
// 元数据
|
||||
piiCount Int // 检测到的 PII 数量
|
||||
piiTypes String[] // 检测到的 PII 类型 ['name', 'id_card', 'phone']
|
||||
llmProvider String // 'qwen' | 'deepseek' | 'openai'
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([projectId, userId])
|
||||
@@index([sessionId])
|
||||
@@index([createdAt])
|
||||
@@map("iit_pii_audit_log")
|
||||
@@schema("iit_schema")
|
||||
}
|
||||
```
|
||||
|
||||
**PII 类型说明**:
|
||||
|
||||
| PII 类型 | 正则模式 | 脱敏示例 |
|
||||
|----------|----------|----------|
|
||||
| `name` | 中文姓名(2-4字) | 张三 → [PATIENT_1] |
|
||||
| `id_card` | 身份证号(18位) | 420101... → [ID_CARD_1] |
|
||||
| `phone` | 手机号(11位) | 13800138000 → [PHONE_1] |
|
||||
| `mrn` | 病历号 | MRN123456 → [MRN_1] |
|
||||
|
||||
**脱敏流程**:
|
||||
|
||||
```
|
||||
用户输入: "张三(身份证420101199001011234)今天血压偏高"
|
||||
↓ AnonymizerService.mask()
|
||||
LLM 收到: "[PATIENT_1](身份证[ID_CARD_1])今天血压偏高"
|
||||
↓ 同时写入 iit_pii_audit_log
|
||||
↓ LLM 处理
|
||||
LLM 返回: "[PATIENT_1] 的血压需要关注..."
|
||||
↓ AnonymizerService.unmask()
|
||||
用户看到: "张三 的血压需要关注..."
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Phase 2:SOP 执行与记忆表
|
||||
|
||||
### 3.1 iit_task_run - SOP 任务执行记录
|
||||
|
||||
Reference in New Issue
Block a user