feat(iit): Implement event-level QC architecture V3.1 with dynamic rule filtering, report deduplication and AI intent enhancement

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-08 21:22:11 +08:00
parent 45c7b32dbb
commit 7a299e8562
51 changed files with 10638 additions and 184 deletions

View File

@@ -959,19 +959,26 @@ model IitAuditLog {
/// Skill 配置存储表 - 存储质控规则、SOP流程图
/// 支持 webhook/cron/event 三种触发方式
/// V3.0 扩展:支持 CRA 五大规则体系
model IitSkill {
id String @id @default(uuid())
projectId String @map("project_id")
skillType String @map("skill_type") // qc_process | daily_briefing | general_chat | weekly_report | visit_reminder
skillType String @map("skill_type") // qc_process | daily_briefing | general_chat | weekly_report | visit_reminder | variable_qc | inclusion_exclusion | protocol_deviation | ae_monitoring | ethics_compliance
name String // 技能名称
description String? // 技能描述
config Json @db.JsonB // 核心配置 JSONSOP 流程图)
config Json @db.JsonB // 核心配置 JSONSOP 流程图 / 规则定义
isActive Boolean @default(true) @map("is_active")
version Int @default(1)
// V2.9 新增:主动触发能力
triggerType String @default("webhook") @map("trigger_type") // 'webhook' | 'cron' | 'event'
cronSchedule String? @map("cron_schedule") // Cron 表达式,如 "0 9 * * *"
triggerType String @default("webhook") @map("trigger_type") // 'webhook' | 'cron' | 'manual'
cronSchedule String? @map("cron_schedule") // Cron 表达式,如 "0 2 * * *" (每日凌晨2点)
// V3.0 新增CRA 质控引擎支持
ruleType String @default("HARD_RULE") @map("rule_type") // 'HARD_RULE' | 'LLM_CHECK' | 'HYBRID'
level String @default("normal") @map("level") // 'blocking' | 'normal' - 阻断性检查优先
priority Int @default(100) @map("priority") // 执行优先级,数字越小越优先
requiredTags String[] @default([]) @map("required_tags") // 数据依赖标签,如 ['#lab', '#demographics']
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@ -979,10 +986,41 @@ model IitSkill {
@@unique([projectId, skillType], map: "unique_iit_skill_project_type")
@@index([projectId], map: "idx_iit_skill_project")
@@index([isActive], map: "idx_iit_skill_active")
@@index([isActive, triggerType], map: "idx_iit_skill_active_trigger")
@@map("skills")
@@schema("iit_schema")
}
/// 质控报告存储表 - 存储预生成的 LLM 友好报告
/// 报告驱动模式:后台预计算 → LLM 阅读报告 → 回答用户
model IitQcReport {
id String @id @default(uuid())
projectId String @map("project_id")
// 报告类型
reportType String @default("daily") @map("report_type") // 'daily' | 'weekly' | 'on_demand'
// 统计摘要
summary Json @db.JsonB // { totalRecords, criticalIssues, pendingQueries, passRate }
// 详细问题列表
issues Json @db.JsonB // [{ record, rule, severity, description, evidence }]
// LLM 友好的 XML 报告
llmReport String @map("llm_report") @db.Text
// 报告生成时间
generatedAt DateTime @default(now()) @map("generated_at")
// 报告有效期(过期后需重新生成)
expiresAt DateTime? @map("expires_at")
@@index([projectId, reportType], map: "idx_qc_report_project_type")
@@index([generatedAt], map: "idx_qc_report_generated")
@@map("qc_reports")
@@schema("iit_schema")
}
/// 字段名映射字典表 - 解决 LLM 生成的字段名与 REDCap 实际字段名不一致的问题
model IitFieldMapping {
id String @id @default(uuid())