-- 诊单编辑页：最近业务订单未完成时仍可修改患者基本信息（姓名/身份证/手机/性别/年龄）
-- 接口：tcm.diagnosis/edit（后端校验）；前端 edit.vue 同 perms 控制表单可编辑
SET @diag_menu_id := (SELECT id FROM zyt_system_menu WHERE perms = 'tcm.diagnosis/lists' LIMIT 1);

INSERT INTO zyt_system_menu (
    pid, type, name, icon, sort, perms, paths, component,
    selected, params, is_cache, is_show, is_disable, create_time, update_time
)
SELECT
    @diag_menu_id, 'A', '未完成订单改患者信息', '', 22,
    'tcm.diagnosis/editPatientBasic', '', '',
    '', '', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM DUAL
WHERE @diag_menu_id IS NOT NULL
  AND NOT EXISTS (SELECT 1 FROM zyt_system_menu WHERE perms = 'tcm.diagnosis/editPatientBasic');
