-- 智能体表
CREATE TABLE `ai_agent` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `agent_id` varchar(64) NOT NULL COMMENT '智能体唯一标识（前端生成的ID）',
  `cluster_id` int(11) NOT NULL DEFAULT '1' COMMENT '集群编号：1-门诊，2-住院，3-居家，4-院管',
  `name` varchar(255) NOT NULL DEFAULT '' COMMENT '智能体名称',
  `sub_type` varchar(255) DEFAULT NULL COMMENT '子类型',
  `goal` text COMMENT '业务目标',
  `scenario` text COMMENT '业务场景',
  `status` varchar(20) NOT NULL DEFAULT 'draft' COMMENT '状态：enabled-启用，disabled-禁用，draft-草稿',
  `version` varchar(50) NOT NULL DEFAULT 'V1.0' COMMENT '版本号',
  `trigger_mode` varchar(50) DEFAULT NULL COMMENT '触发方式',
  `trigger_entry` varchar(255) DEFAULT NULL COMMENT '触发入口',
  `trigger_channels` text COMMENT '触发渠道（JSON数组）',
  `data_sources` text COMMENT '数据源（JSON数组）',
  `steps` text COMMENT '流程步骤（JSON数组）',
  `inputs` text COMMENT '输入字段（JSON数组）',
  `outputs` text COMMENT '输出字段（JSON数组）',
  `integrations` text COMMENT '集成配置（JSON数组）',
  `runtime_model` varchar(100) DEFAULT NULL COMMENT '运行时模型',
  `runtime_temperature` decimal(5,2) DEFAULT NULL COMMENT '温度参数',
  `runtime_max_tokens` int(11) DEFAULT NULL COMMENT '最大token数',
  `runtime_prompt_template_ids` text COMMENT '提示词模板ID列表（JSON数组）',
  `runtime_knowledge_ids` text COMMENT '知识库ID列表（JSON数组）',
  `runtime_tools` text COMMENT '工具列表（JSON数组）',
  `runtime_fallback` varchar(500) DEFAULT NULL COMMENT '兜底策略',
  `security_pii` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否包含PII',
  `security_audit` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否审计',
  `security_permissions` text COMMENT '权限点（JSON数组）',
  `security_escalation` varchar(500) DEFAULT NULL COMMENT '人工升级/兜底',
  `owner_product` varchar(255) DEFAULT NULL COMMENT '负责人（产品）',
  `kpis` text COMMENT 'KPI指标（JSON数组）',
  `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户ID',
  `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  `create_by` bigint(20) DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` bigint(20) DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_agent_id` (`agent_id`),
  KEY `idx_cluster_id` (`cluster_id`),
  KEY `idx_status` (`status`),
  KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='智能体表';

-- 插入初始数据
-- 集群1：门诊智能体集群（cluster_id = 1）
INSERT INTO `ai_agent` (`agent_id`, `cluster_id`, `name`, `sub_type`, `goal`, `scenario`, `status`, `version`, `trigger_mode`, `trigger_entry`, `trigger_channels`, `data_sources`, `steps`, `inputs`, `outputs`, `integrations`, `runtime_model`, `runtime_temperature`, `runtime_max_tokens`, `runtime_prompt_template_ids`, `runtime_knowledge_ids`, `runtime_tools`, `runtime_fallback`, `security_pii`, `security_audit`, `security_permissions`, `security_escalation`, `owner_product`, `kpis`, `tenant_id`) VALUES
('1737984000000-001', 1, '分诊挂号智能体', '分诊/挂号', '分诊推荐 + 急重症预警 + 一键挂号下单。', '患者描述症状→结构化采集→红旗预警→推荐科室/医生→生成挂号订单→回写预问诊单。', 'enabled', 'V1.0', '对话', '患者端-分诊挂号入口', '["APP","小程序"]', '["患者自述","HIS历史摘要","排班/号源","急重症规则库"]', '[{"title":"结构化采集","input":"症状对话","system":"LLM","output":"结构化病史","desc":"主诉/现病史/既往史/过敏史"},{"title":"急重症判断","input":"结构化病史","system":"规则引擎","output":"紧急等级","desc":"命中红旗→提示急诊/120/人工导诊"},{"title":"分诊推荐","input":"病史+排班","system":"LLM+映射","output":"推荐科室/医生","desc":"给出推荐理由"},{"title":"挂号下单","input":"选择项","system":"挂号系统","output":"挂号订单","desc":"同步回写预问诊单到医生端"}]', '[{"name":"patientId","type":"string","source":"就诊人选择","desc":"就诊人ID"},{"name":"complaint","type":"string","source":"对话输入","desc":"主诉/症状"}]', '[{"name":"triageDept","type":"string","sink":"挂号系统","desc":"推荐科室"},{"name":"registerOrderId","type":"string","sink":"挂号系统","desc":"挂号订单号"}]', '[{"system":"HIS","type":"API","direction":"in","endpoint":"/his/patient/summary","remark":"历史摘要"},{"system":"排班系统","type":"API","direction":"in","endpoint":"/schedule/doctor","remark":"号源"},{"system":"挂号系统","type":"API","direction":"out","endpoint":"/register/order","remark":"下单"}]', 'qwen3', 0.20, 2048, '[]', '[]', '["rule_engine"]', '不确定→转人工导诊', 1, 1, '["agent:outpatient:triage"]', '急重症→提示急诊/120并通知导诊台', '未指定', '[{"name":"分诊命中率","target":"≥85%","calc":"推荐科室与最终科室一致率","alert":"<70%告警"},{"name":"急重症召回率","target":"≥95%","calc":"红旗规则命中覆盖（抽检复核）","alert":"<90%告警"}]', '000000'),
('1737984000000-002', 1, '导航陪诊智能体（机器人）', '导航/提醒', '路径规划 + 队列提醒，降低跑动与漏检。', '基于定位+队列+预约，生成最优路线与时间序列，提醒签到/候诊/缴费/取药。', 'enabled', 'V1.0', '事件', '患者端-就诊导航入口', '["APP","小程序"]', '["院内地图/POI","队列系统","预约检查清单"]', '[{"title":"获取队列与预约","input":"visitId","system":"HIS/队列","output":"待办清单","desc":"候诊/检查/缴费/取药节点"},{"title":"路线规划","input":"待办清单+地图","system":"调度算法","output":"路线/时间表","desc":"减少折返"},{"title":"提醒推送","input":"时间表","system":"通知系统","output":"提醒","desc":"叫号/超时/变更"}]', '[{"name":"visitId","type":"string","source":"挂号系统","desc":"就诊单号"}]', '[{"name":"routePlan","type":"json","sink":"患者端","desc":"路线与时间表"}]', '[{"system":"队列系统","type":"API","direction":"in","endpoint":"/queue/realtime","remark":"实时队列"},{"system":"院内地图","type":"API","direction":"in","endpoint":"/map/route","remark":"路径规划"}]', 'qwen3', NULL, NULL, '[]', '[]', '["notify"]', '异常→人工陪诊台', 1, 1, '["agent:outpatient:navigation"]', '路径异常→人工导诊', '未指定', '[{"name":"漏检率","target":"≤1%","calc":"预约未到检比例","alert":">3%告警"}]', '000000'),
('1737984000000-003', 1, '预问诊智能体', '病史采集', '对话式采集结构化病史，减少医生重复询问。', '对话描述→追问补全→结构化输出→回写预问诊单。', 'enabled', 'V1.0', '对话', '患者端-预问诊入口', '["APP","小程序"]', '["患者自述","既往史摘要"]', '[{"title":"引导追问","input":"主诉","system":"LLM","output":"追问问题","desc":"按症状路径补全"},{"title":"结构化整理","input":"对话记录","system":"LLM","output":"结构化病史","desc":"字段化输出JSON"},{"title":"回写","input":"结构化病史","system":"EMR/HIS","output":"预问诊记录","desc":"医生端可见"}]', '[{"name":"dialog","type":"string","source":"对话记录","desc":"患者对话文本"}]', '[{"name":"structuredHistory","type":"json","sink":"EMR/HIS","desc":"结构化病史JSON"}]', '[{"system":"EMR/HIS","type":"API","direction":"out","endpoint":"/previsit/save","remark":"保存预问诊单"}]', 'qwen3', 0.30, 2048, '[]', '[]', '[]', '缺信息→追问补全', 1, 1, '["agent:outpatient:previsit"]', '严重症状→提示急诊', '未指定', '[{"name":"信息完整度","target":"≥90%","calc":"关键字段非空比例","alert":"<80%告警"}]', '000000'),
('1737984000000-004', 1, '舌诊智能体', '多模态（图像）', '舌像辅助辨证与健康评估（仅辅助，不替代诊断）。', '上传舌像→质量检测→特征提取→解释建议→写入就诊记录。', 'enabled', 'V1.0', '手动', '患者端-舌诊拍照入口', '["APP","小程序"]', '["舌像图片","基础信息（年龄/性别）"]', '[{"title":"质量检测","input":"舌像","system":"图像服务","output":"合格/不合格","desc":"清晰度/遮挡/光照"},{"title":"特征提取","input":"合格舌像","system":"CV模型","output":"特征指标","desc":"舌质/舌苔/裂纹等"},{"title":"解释与落地","input":"特征指标","system":"LLM","output":"解释建议","desc":"风险提示与建议"}]', '[{"name":"tongueImage","type":"file","source":"拍照上传","desc":"舌像图片"}]', '[{"name":"tongueFeatures","type":"json","sink":"EMR/患者端","desc":"舌像特征与解释"}]', '[{"system":"图像服务","type":"API","direction":"both","endpoint":"/vision/tongue/analyze","remark":"舌像分析"}]', 'qwen3', NULL, NULL, '[]', '[]', '[]', '不合格→引导重拍', 1, 1, '["agent:outpatient:tongue"]', '识别失败→引导重拍', '未指定', '[{"name":"一次采集通过率","target":"≥80%","calc":"质量检测一次通过比例","alert":"<60%告警"}]', '000000'),
('1737984000000-005', 1, '病历书写智能体', '医生工作站助手', '语音转写 + 结构化病历生成，减少文书时间。', '诊间语音→ASR转写→结构化病历→医生确认→写入EMR。', 'enabled', 'V1.0', '事件', '诊间-病历书写助手', '["医生工作站"]', '["诊间音频","门诊模板","既往史摘要"]', '[{"title":"语音转写","input":"音频","system":"ASR","output":"转写文本","desc":"实时/准实时"},{"title":"结构化生成","input":"转写文本+模板","system":"LLM","output":"病历草稿","desc":"主诉/现病史/诊断/处置"},{"title":"确认入库","input":"病历草稿","system":"EMR","output":"病历文书","desc":"医生确认后保存"}]', '[{"name":"asrText","type":"string","source":"ASR","desc":"转写文本"}]', '[{"name":"emrNote","type":"string","sink":"EMR","desc":"病历文书内容"}]', '[{"system":"EMR","type":"API","direction":"out","endpoint":"/emr/note/save","remark":"保存病历"}]', 'qwen3', 0.20, 3072, '[]', '[]', '["asr"]', '生成失败→返回模板空表', 1, 1, '["agent:outpatient:emr_write"]', '疑似误写→人工复核', '未指定', '[{"name":"平均节省时间","target":"≥30%","calc":"书写耗时对比（前后）","alert":"<10%告警"}]', '000000'),
('1737984000000-006', 1, '病历质控智能体', '质控/合规', '自动发现缺项/逻辑冲突/不规范用语，降低返工与合规风险。', '病历草稿/已提交病历→规则+LLM检查→给出修改建议→复核闭环。', 'enabled', 'V1.0', '事件', '病历保存/提交事件', '["医生工作站"]', '["病历内容","质控规则库","诊断/处置字典"]', '[{"title":"规则校验","input":"病历","system":"规则引擎","output":"硬性缺项","desc":"必填字段/格式"},{"title":"语义质控","input":"病历","system":"LLM","output":"软性问题","desc":"逻辑冲突/不规范用语"},{"title":"反馈闭环","input":"问题清单","system":"工作站","output":"修改记录","desc":"医生确认修改"}]', '[{"name":"emrNote","type":"string","source":"EMR","desc":"病历文本"}]', '[{"name":"qcIssues","type":"json","sink":"医生工作站","desc":"问题清单与建议"}]', '[{"system":"EMR","type":"API","direction":"both","endpoint":"/emr/qc","remark":"质控回写"}]', 'qwen3', NULL, NULL, '[]', '[]', '["rule_engine"]', '无法判断→仅输出规则结果', 1, 1, '["agent:outpatient:emr_qc"]', '高风险问题→质控员复核', '未指定', '[{"name":"返工率","target":"≤5%","calc":"质控后再次修改比例","alert":">10%告警"}]', '000000'),
('1737984000000-007', 1, '检验解读智能体', 'LIS解读', '将检验结果转为可理解解释与建议（仅辅助）。', '检验结果→异常识别→关联诊断线索→生成解释/建议→推送医生/患者端。', 'enabled', 'V1.0', '事件', 'LIS报告出具事件', '["医生工作站","APP"]', '["LIS结果","参考范围","常见疾病知识库"]', '[{"title":"异常识别","input":"检验结果","system":"规则引擎","output":"异常项","desc":"高/低/危急值"},{"title":"解释生成","input":"异常项+知识","system":"LLM","output":"解释建议","desc":"提示复查/就诊建议"}]', '[{"name":"labReport","type":"json","source":"LIS","desc":"检验报告结构化数据"}]', '[{"name":"labInterpretation","type":"string","sink":"医生工作站/患者端","desc":"解释与建议"}]', '[{"system":"LIS","type":"API","direction":"in","endpoint":"/lis/report","remark":"获取检验结果"}]', 'qwen3', NULL, NULL, '[]', '[]', '["rag_retrieval"]', '不确定→提示咨询医生', 1, 1, '["agent:outpatient:lab"]', '危急值→强提醒医生/护士站', '未指定', '[{"name":"危急值覆盖率","target":"100%","calc":"危急值必须触发提醒","alert":"漏报即告警"}]', '000000'),
('1737984000000-008', 1, '检查解读智能体', 'RIS/影像解读', '将检查/影像报告转为可理解解释与随访建议（仅辅助）。', 'RIS/影像报告→关键结论抽取→风险提示→建议下一步检查/随访。', 'enabled', 'V1.0', '事件', 'RIS报告出具事件', '["医生工作站","APP"]', '["RIS报告","影像结论术语库"]', '[{"title":"结论抽取","input":"报告文本","system":"LLM","output":"关键结论","desc":"所见/印象/建议"},{"title":"风险提示","input":"关键结论","system":"规则+LLM","output":"提示与建议","desc":"复查周期/就诊建议"}]', '[{"name":"imagingReport","type":"string","source":"RIS","desc":"影像报告文本"}]', '[{"name":"imagingInterpretation","type":"string","sink":"医生工作站/患者端","desc":"解释与建议"}]', '[{"system":"RIS","type":"API","direction":"in","endpoint":"/ris/report","remark":"获取影像报告"}]', 'qwen3', NULL, NULL, '[]', '[]', '[]', '输出原文+提示咨询医生', 1, 1, '["agent:outpatient:imaging"]', '高风险结论→提示尽快就医', '未指定', '[{"name":"解释可读性满意度","target":"≥4.5/5","calc":"患者端评价","alert":"<4.0告警"}]', '000000'),
('1737984000000-009', 1, '门诊缴费智能体', '缴费/结算', '将费用清单解释清楚并一键支付，减少窗口压力。', '费用清单→解释（医保/自费）→对账→发起支付→回写结果。', 'enabled', 'V1.0', '手动', '患者端-缴费入口', '["APP","小程序"]', '["费用清单","医保规则（简化）","支付订单"]', '[{"title":"费用解释","input":"费用清单","system":"LLM","output":"解释","desc":"项目含义/注意事项"},{"title":"支付下单","input":"确认支付","system":"支付系统","output":"支付订单","desc":"生成订单号"},{"title":"结果回写","input":"支付结果","system":"HIS","output":"缴费状态","desc":"回写缴费状态"}]', '[{"name":"feeList","type":"json","source":"HIS","desc":"费用清单"}]', '[{"name":"payStatus","type":"string","sink":"HIS/患者端","desc":"支付状态"}]', '[{"system":"HIS","type":"API","direction":"both","endpoint":"/his/fee/list|/his/fee/payResult","remark":"费用与回写"},{"system":"支付系统","type":"API","direction":"out","endpoint":"/pay/create","remark":"支付下单"}]', 'qwen3', NULL, NULL, '[]', '[]', '[]', '支付失败→提示重试/窗口', 1, 1, '["agent:outpatient:pay"]', '支付异常→客服/窗口', '未指定', '[{"name":"线上缴费占比","target":"≥70%","calc":"线上支付订单/总缴费订单","alert":"<50%告警"}]', '000000');

-- 集群2：住院智能体集群（cluster_id = 2）
INSERT INTO `ai_agent` (`agent_id`, `cluster_id`, `name`, `sub_type`, `goal`, `scenario`, `status`, `version`, `trigger_mode`, `trigger_entry`, `trigger_channels`, `data_sources`, `steps`, `inputs`, `outputs`, `integrations`, `runtime_model`, `runtime_temperature`, `runtime_max_tokens`, `runtime_prompt_template_ids`, `runtime_knowledge_ids`, `runtime_tools`, `runtime_fallback`, `security_pii`, `security_audit`, `security_permissions`, `security_escalation`, `owner_product`, `kpis`, `tenant_id`) VALUES
('1737984000000-010', 2, '入院智能体', '入院办理/床位/医嘱', '入院流程一站式：办理→床位→医嘱→宣教→风险评估。', '接收门急诊/转诊入院事件→核对资料→床位分配→生成入院评估与首日医嘱→推送宣教清单。', 'enabled', 'V1.0', '事件', 'HIS入院登记事件', '["住院工作站"]', '["HIS入院登记","床位系统","医嘱模板","护理评估量表"]', '[{"title":"资料核对与缺项提示","input":"入院登记+既往史摘要","system":"LLM","output":"缺项清单","desc":"证件/联系人/过敏史/用药史"},{"title":"床位推荐/分配","input":"科室/病区/隔离要求","system":"床位系统","output":"床位号","desc":"结合空床与护理等级"},{"title":"首日医嘱草拟","input":"诊断/风险","system":"LLM+模板","output":"医嘱草稿","desc":"检查/用药/护理级别"},{"title":"宣教与任务下发","input":"医嘱草稿","system":"护理任务系统","output":"任务清单","desc":"宣教/标本/监测"}]', '[{"name":"admissionId","type":"string","source":"HIS","desc":"入院单号"},{"name":"diagnosis","type":"string","source":"门急诊/转诊","desc":"拟诊断"}]', '[{"name":"bedNo","type":"string","sink":"床位系统","desc":"床位分配结果"},{"name":"orderDraft","type":"json","sink":"医嘱系统","desc":"首日医嘱草稿"}]', '[{"system":"HIS","type":"API","direction":"in","endpoint":"/his/admission/get","remark":"入院登记信息"},{"system":"床位系统","type":"API","direction":"out","endpoint":"/bed/assign","remark":"床位分配"},{"system":"医嘱系统","type":"API","direction":"out","endpoint":"/order/draft","remark":"医嘱草拟"}]', 'qwen3', 0.20, 3072, '[]', '[]', '["rule_engine"]', '不确定→转护士站人工确认', 1, 1, '["agent:inpatient:admission"]', '高风险→医生/护士长确认', '未指定', '[{"name":"入院办理耗时","target":"≤10min","calc":"入院登记→床位确认时间","alert":">20min告警"},{"name":"缺项一次提醒命中率","target":"≥80%","calc":"缺项提示后一次补齐比例","alert":"<60%告警"}]', '000000'),
('1737984000000-011', 2, '护理智能体（物联网设备）', '护理监测/预警', '物联网监测 + 风险预警 + 护理任务编排，提升安全。', '采集生命体征/输液泵/呼叫器事件→异常识别→推送护士站→生成护理处置任务与记录。', 'enabled', 'V1.0', '事件', 'IoT设备上报事件', '["护士站","物联网平台"]', '["生命体征监测","输液泵","呼叫系统","护理文书"]', '[{"title":"异常检测","input":"体征/设备数据","system":"规则引擎","output":"异常事件","desc":"危急阈值/趋势异常"},{"title":"风险解释与建议","input":"异常事件+病情摘要","system":"LLM","output":"处置建议","desc":"优先级与注意事项"},{"title":"任务下发与闭环","input":"处置建议","system":"护理任务系统","output":"任务与记录","desc":"完成后回写护理记录"}]', '[{"name":"iotEvent","type":"json","source":"IoT平台","desc":"设备事件/体征数据"}]', '[{"name":"nursingTask","type":"json","sink":"护士站系统","desc":"护理处置任务"}]', '[{"system":"IoT平台","type":"MQ","direction":"in","endpoint":"topic:/iot/vitals","remark":"体征事件"},{"system":"护士站系统","type":"API","direction":"out","endpoint":"/nurse/task/create","remark":"任务下发"}]', 'qwen3', 0.10, 2048, '[]', '[]', '["rule_engine","notify"]', '仅规则告警并升级人工', 1, 1, '["agent:inpatient:nursing"]', '持续异常→医生值班电话', '未指定', '[{"name":"危急值响应时间","target":"≤3min","calc":"告警产生→护士确认时间","alert":">5min告警"},{"name":"误报率","target":"≤5%","calc":"误报/总告警","alert":">10%告警"}]', '000000');

-- 集群3：居家智能体集群（cluster_id = 3）
INSERT INTO `ai_agent` (`agent_id`, `cluster_id`, `name`, `sub_type`, `goal`, `scenario`, `status`, `version`, `trigger_mode`, `trigger_entry`, `trigger_channels`, `data_sources`, `steps`, `inputs`, `outputs`, `integrations`, `runtime_model`, `runtime_temperature`, `runtime_max_tokens`, `runtime_prompt_template_ids`, `runtime_knowledge_ids`, `runtime_tools`, `runtime_fallback`, `security_pii`, `security_audit`, `security_permissions`, `security_escalation`, `owner_product`, `kpis`, `tenant_id`) VALUES
('1737984000000-012', 3, '慢病管理智能体（物联网设备）', '连续监测/预警', '家庭场景下连续监测 + 风险预警 + 用药/生活方式干预。', '设备采集血压/血糖/心率→趋势分析→异常预警→生成干预建议→必要时升级随访/线下就医。', 'enabled', 'V1.0', '事件', 'IoT设备上报事件', '["IoT平台","APP"]', '["血压计/血糖仪/心电设备","用药计划","随访规则库"]', '[{"title":"数据接入与清洗","input":"IoT数据","system":"IoT平台","output":"标准化指标","desc":"去噪/异常值处理"},{"title":"风险识别","input":"指标+阈值/趋势","system":"规则引擎","output":"风险等级","desc":"高风险→立即提醒"},{"title":"解释与干预建议","input":"风险等级+近期数据","system":"LLM","output":"建议","desc":"用药提醒/生活方式建议"},{"title":"升级与闭环","input":"高风险事件","system":"随访/客服","output":"人工跟进","desc":"必要时建议就医"}]', '[{"name":"iotMetrics","type":"json","source":"IoT平台","desc":"连续监测指标"}]', '[{"name":"riskAlert","type":"json","sink":"患者端/家属端","desc":"风险预警与建议"}]', '[{"system":"IoT平台","type":"MQ","direction":"in","endpoint":"topic:/iot/chronic","remark":"慢病指标事件"},{"system":"通知系统","type":"API","direction":"out","endpoint":"/notify/push","remark":"推送提醒"}]', 'qwen3', 0.10, 2048, '[]', '[]', '["rule_engine","notify"]', '仅规则提示并建议联系医生', 1, 1, '["agent:home:chronic"]', '持续异常→医生随访/120提示', '未指定', '[{"name":"高风险响应时间","target":"≤5min","calc":"风险判定→推送成功时间","alert":">10min告警"},{"name":"连续上传率","target":"≥85%","calc":"日上传天数/总天数","alert":"<70%告警"}]', '000000'),
('1737984000000-013', 3, '随访智能体', '术后/出院随访', '标准化随访路径：问卷→风险分层→任务闭环→必要时回院。', '出院后定时触达→问卷采集→风险分层→生成随访记录与提醒→转人工/回院建议。', 'enabled', 'V1.0', '定时', '随访计划任务', '["APP","电话"]', '["出院小结","随访计划","问卷答案"]', '[{"title":"触达与采集","input":"随访计划","system":"通知/外呼","output":"问卷答案","desc":"未响应→多次触达"},{"title":"风险分层","input":"问卷答案","system":"规则引擎","output":"风险等级","desc":"高风险→转人工"},{"title":"记录与建议","input":"风险等级","system":"LLM","output":"随访记录","desc":"用药/复查/就医建议"}]', '[{"name":"survey","type":"json","source":"问卷系统","desc":"问卷答案"}]', '[{"name":"followupNote","type":"string","sink":"随访系统","desc":"随访记录与建议"}]', '[{"system":"随访系统","type":"API","direction":"out","endpoint":"/followup/save","remark":"保存随访记录"}]', 'qwen3', 0.20, 2048, '[]', '[]', '["rule_engine"]', '高风险→转人工', 1, 1, '["agent:home:followup"]', '高风险→人工随访/回院建议', '未指定', '[{"name":"随访完成率","target":"≥75%","calc":"完成随访/计划随访","alert":"<60%告警"}]', '000000');

-- 集群4：院管智能体集群（cluster_id = 4）
INSERT INTO `ai_agent` (`agent_id`, `cluster_id`, `name`, `sub_type`, `goal`, `scenario`, `status`, `version`, `trigger_mode`, `trigger_entry`, `trigger_channels`, `data_sources`, `steps`, `inputs`, `outputs`, `integrations`, `runtime_model`, `runtime_temperature`, `runtime_max_tokens`, `runtime_prompt_template_ids`, `runtime_knowledge_ids`, `runtime_tools`, `runtime_fallback`, `security_pii`, `security_audit`, `security_permissions`, `security_escalation`, `owner_product`, `kpis`, `tenant_id`) VALUES
('1737984000000-014', 4, '资源调度智能体', '人/床/室/机调度', '面向峰谷与突发事件进行资源调度建议，降低拥堵与等待。', '汇总床位/手术间/影像设备/人员排班→识别瓶颈→生成调度建议→推送执行与复盘。', 'enabled', 'V1.0', '定时', '每日/每小时调度任务', '["院管后台"]', '["床位系统","排班系统","手术/检查预约","急诊事件"]', '[{"title":"数据汇总","input":"床位/排班/预约","system":"数据平台","output":"资源画像","desc":"按科室/时段聚合"},{"title":"瓶颈识别","input":"资源画像","system":"算法/规则","output":"瓶颈点","desc":"等待时间异常/饱和度"},{"title":"调度建议","input":"瓶颈点","system":"LLM","output":"建议清单","desc":"增开诊室/改期/加班建议"},{"title":"执行闭环","input":"建议清单","system":"院管后台","output":"执行记录","desc":"记录采纳与效果"}]', '[{"name":"resourceSnapshot","type":"json","source":"数据平台","desc":"资源实时快照"}]', '[{"name":"dispatchPlan","type":"json","sink":"院管后台","desc":"调度建议与优先级"}]', '[{"system":"数据平台","type":"API","direction":"in","endpoint":"/dw/resource/snapshot","remark":"资源快照"}]', 'qwen3', 0.20, 3072, '[]', '[]', '[]', '输出瓶颈点与数据依据', 0, 1, '["agent:management:dispatch"]', '重大异常→通知值班领导', '未指定', '[{"name":"平均等待时长","target":"下降≥15%","calc":"实施前后对比","alert":"不降反升告警"},{"name":"建议采纳率","target":"≥30%","calc":"采纳建议/总建议","alert":"<10%告警"}]', '000000'),
('1737984000000-015', 4, '运营决策智能体', '报表/洞察/预测', '提供可解释的运营洞察与预测建议，辅助管理决策。', '经营指标（门诊量/住院量/收入/成本）→异常检测→归因分析→策略建议→跟踪效果。', 'enabled', 'V1.0', '定时', '日/周/月报任务', '["院管后台"]', '["HIS经营数据","财务系统","人力与排班","患者满意度"]', '[{"title":"指标计算","input":"经营数据","system":"BI","output":"指标面板","desc":"标准口径"},{"title":"异常检测","input":"指标面板","system":"算法","output":"异常点","desc":"同比/环比/季节性"},{"title":"归因与建议","input":"异常点","system":"LLM","output":"洞察报告","desc":"可解释归因+建议"}]', '[{"name":"kpiBoard","type":"json","source":"BI","desc":"运营指标面板"}]', '[{"name":"insightReport","type":"string","sink":"院管后台","desc":"洞察报告与建议"}]', '[{"system":"BI","type":"API","direction":"in","endpoint":"/bi/kpi","remark":"获取指标"}]', 'qwen3', 0.30, 4096, '[]', '[]', '[]', '输出数据+简单描述', 0, 1, '["agent:management:ops"]', '重大异常→运营负责人确认', '未指定', '[{"name":"报告准时率","target":"100%","calc":"按计划生成","alert":"延迟即告警"}]', '000000'),
('1737984000000-016', 4, '客服智能体', '咨询/工单/投诉', '提升客服效率：自助解答 + 工单分流 + 关键投诉升级。', '患者咨询/投诉→识别意图与风险→知识检索→答复→工单创建/升级→闭环回访。', 'enabled', 'V1.0', '对话', '客服入口', '["电话","APP","公众号"]', '["FAQ知识库","工单系统","历史沟通记录"]', '[{"title":"意图识别","input":"用户问题","system":"LLM","output":"意图/风险","desc":"投诉/咨询/预约/费用"},{"title":"知识检索与答复","input":"意图","system":"RAG+LLM","output":"答复","desc":"可追溯引用"},{"title":"工单与升级","input":"高风险/未解决","system":"工单系统","output":"工单","desc":"分派并设置SLA"}]', '[{"name":"userMessage","type":"string","source":"客服渠道","desc":"咨询/投诉内容"}]', '[{"name":"reply","type":"string","sink":"客服渠道","desc":"答复内容或工单号"}]', '[{"system":"工单系统","type":"API","direction":"out","endpoint":"/ticket/create","remark":"创建工单"}]', 'qwen3', 0.40, 3072, '[]', '[]', '["rag_retrieval"]', '无法解决→转人工', 1, 1, '["agent:management:cs"]', '敏感投诉→主管升级', '未指定', '[{"name":"一次解决率","target":"≥70%","calc":"无需转人工比例","alert":"<50%告警"},{"name":"SLA超时率","target":"≤3%","calc":"超时工单/总工单","alert":">5%告警"}]', '000000');
