Files
zyt/server/sql/update_past_history.sql
T
2026-03-04 15:32:30 +08:00

71 lines
6.0 KiB
SQL

-- 更新既往史字典数据
-- 添加50种常见疾病选项
-- 执行前请确保已有 past_history 字典类型
-- 获取既往史字典类型ID
SET @type_id = (SELECT id FROM zyt_dict_type WHERE type = 'past_history' LIMIT 1);
-- 先删除旧的既往史数据(如果需要)
-- DELETE FROM zyt_dict_data WHERE type_value = 'past_history';
-- 插入新的既往史选项(共50项)
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id, '高血压', 'hypertension', 'past_history', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '糖尿病', 'diabetes', 'past_history', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '胃溃疡', 'gastric_ulcer', 'past_history', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '高血脂', 'hyperlipidemia', 'past_history', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '甲状腺结节', 'thyroid_nodule', 'past_history', 5, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '浅表性胃炎', 'superficial_gastritis', 'past_history', 6, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '胃病', 'stomach_disease', 'past_history', 7, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '脑梗', 'cerebral_infarction', 'past_history', 8, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '乳腺结节', 'breast_nodule', 'past_history', 9, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '萎缩性胃炎', 'atrophic_gastritis', 'past_history', 10, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '心脏病', 'heart_disease', 'past_history', 11, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '脑缺血', 'cerebral_ischemia', 'past_history', 12, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肠梗阻', 'intestinal_obstruction', 'past_history', 13, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '甲肝', 'hepatitis_a', 'past_history', 14, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '乙肝', 'hepatitis_b', 'past_history', 15, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '丙肝', 'hepatitis_c', 'past_history', 16, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '大三阳', 'big_three_positive', 'past_history', 17, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '脑血栓', 'cerebral_thrombosis', 'past_history', 18, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '冠心病', 'coronary_heart_disease', 'past_history', 19, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '心绞痛', 'angina_pectoris', 'past_history', 20, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '心悸', 'palpitation', 'past_history', 21, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肾功能不全', 'renal_insufficiency', 'past_history', 22, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '良性肿瘤', 'benign_tumor', 'past_history', 23, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '胰腺炎', 'pancreatitis', 'past_history', 24, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '小三阳', 'small_three_positive', 'past_history', 25, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '心慌', 'palpitations', 'past_history', 26, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '水肿', 'edema', 'past_history', 27, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '传染病', 'infectious_disease', 'past_history', 28, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '眼底充血', 'fundus_congestion', 'past_history', 29, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肺结核', 'tuberculosis', 'past_history', 30, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肺炎', 'pneumonia', 'past_history', 31, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肺结节', 'pulmonary_nodule', 'past_history', 32, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '心脏支架', 'cardiac_stent', 'past_history', 33, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肾脏支架', 'renal_stent', 'past_history', 34, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肝炎', 'hepatitis', 'past_history', 35, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肿瘤', 'tumor', 'past_history', 36, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肺气肿', 'emphysema', 'past_history', 37, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '中度脂肪肝', 'moderate_fatty_liver', 'past_history', 38, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '腔梗', 'lacunar_infarction', 'past_history', 39, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '酒精肝', 'alcoholic_liver', 'past_history', 40, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '脑萎缩', 'brain_atrophy', 'past_history', 41, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肝囊肿', 'liver_cyst', 'past_history', 42, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '中风', 'stroke', 'past_history', 43, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '脑出血', 'cerebral_hemorrhage', 'past_history', 44, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '肝功能不全', 'hepatic_insufficiency', 'past_history', 45, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '动脉斑块', 'arterial_plaque', 'past_history', 46, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '子宫肌瘤', 'uterine_fibroids', 'past_history', 47, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '脾大', 'splenomegaly', 'past_history', 48, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '胃穿孔', 'gastric_perforation', 'past_history', 49, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id, '胃出血', 'gastric_bleeding', 'past_history', 50, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP())
ON DUPLICATE KEY UPDATE
`name` = VALUES(`name`),
`sort` = VALUES(`sort`),
`update_time` = UNIX_TIMESTAMP();
-- 验证插入结果
SELECT COUNT(*) as total_count FROM zyt_dict_data WHERE type_value = 'past_history';
SELECT * FROM zyt_dict_data WHERE type_value = 'past_history' ORDER BY sort;