feat(iit): Complete CRA Agent V3.0 P0 milestone - autonomous QC pipeline
P0-1: Variable list sync from REDCap metadata P0-2: QC rule configuration with JSON Logic + AI suggestion P0-3: Scheduled QC + report generation + eQuery closed loop P0-4: Unified dashboard + AI stream timeline + critical events Backend: - Add IitEquery, IitCriticalEvent Prisma models + migration - Add cronEnabled/cronExpression to IitProject - Implement eQuery service/controller/routes (CRUD + respond/review/close) - Implement DailyQcOrchestrator (report -> eQuery -> critical events -> notify) - Add AI rule suggestion service - Register daily QC cron worker and eQuery auto-review worker - Extend QC cockpit with timeline, trend, critical events APIs - Fix timeline issues field compat (object vs array format) Frontend: - Create IIT business module with 6 pages (Dashboard, AI Stream, eQuery, Reports, Variable List + project config pages) - Migrate IIT config from admin panel to business module - Implement health score, risk heatmap, trend chart, critical event alerts - Register IIT module in App router and top navigation Testing: - Add E2E API test script covering 7 modules (46 assertions, all passing) Tested: E2E API tests 46/46 passed, backend and frontend verified Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
-- P0-3: eQuery 闭环 + 重大事件归档 + 项目 cron 配置
|
||||
|
||||
-- 1. eQuery 表(AI 自动生成的电子质疑,具有完整生命周期)
|
||||
CREATE TABLE IF NOT EXISTS iit_schema.equery (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
project_id TEXT NOT NULL,
|
||||
record_id TEXT NOT NULL,
|
||||
event_id TEXT,
|
||||
form_name TEXT,
|
||||
field_name TEXT,
|
||||
qc_log_id TEXT,
|
||||
report_id TEXT,
|
||||
query_text TEXT NOT NULL,
|
||||
expected_action TEXT,
|
||||
severity TEXT NOT NULL DEFAULT 'warning',
|
||||
category TEXT,
|
||||
status TEXT NOT NULL DEFAULT 'pending',
|
||||
assigned_to TEXT,
|
||||
responded_at TIMESTAMPTZ,
|
||||
response_text TEXT,
|
||||
response_data JSONB,
|
||||
review_result TEXT,
|
||||
review_note TEXT,
|
||||
reviewed_at TIMESTAMPTZ,
|
||||
closed_at TIMESTAMPTZ,
|
||||
closed_by TEXT,
|
||||
resolution TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_iit_equery_project ON iit_schema.equery(project_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_iit_equery_project_status ON iit_schema.equery(project_id, status);
|
||||
CREATE INDEX IF NOT EXISTS idx_iit_equery_record ON iit_schema.equery(record_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_iit_equery_assigned ON iit_schema.equery(assigned_to);
|
||||
|
||||
-- 2. 重大事件归档表(SAE、重大方案偏离等长期临床资产)
|
||||
CREATE TABLE IF NOT EXISTS iit_schema.critical_events (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
project_id TEXT NOT NULL,
|
||||
record_id TEXT NOT NULL,
|
||||
event_type TEXT NOT NULL,
|
||||
severity TEXT NOT NULL DEFAULT 'critical',
|
||||
title TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
detected_at TIMESTAMPTZ NOT NULL,
|
||||
detected_by TEXT NOT NULL DEFAULT 'ai',
|
||||
source_qc_log_id TEXT,
|
||||
source_equery_id TEXT,
|
||||
source_data JSONB,
|
||||
status TEXT NOT NULL DEFAULT 'open',
|
||||
handled_by TEXT,
|
||||
handled_at TIMESTAMPTZ,
|
||||
handling_note TEXT,
|
||||
reported_to_ec BOOLEAN NOT NULL DEFAULT false,
|
||||
reported_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_iit_critical_event_project ON iit_schema.critical_events(project_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_iit_critical_event_type ON iit_schema.critical_events(project_id, event_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_iit_critical_event_status ON iit_schema.critical_events(project_id, status);
|
||||
|
||||
-- 3. 项目表新增 cron 配置字段
|
||||
ALTER TABLE iit_schema.projects ADD COLUMN IF NOT EXISTS cron_enabled BOOLEAN NOT NULL DEFAULT false;
|
||||
ALTER TABLE iit_schema.projects ADD COLUMN IF NOT EXISTS cron_expression TEXT;
|
||||
Reference in New Issue
Block a user