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

185 lines
12 KiB
SQL

-- 现病史字典数据
-- 共14个字典类型,包含所有现病史相关选项
-- 1. 口腔感觉
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('口腔感觉', 'appetite', 1, '口腔感觉选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_appetite = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_appetite, '干', 'dry', 'appetite', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_appetite, '苦', 'bitter', 'appetite', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_appetite, '腻', 'greasy', 'appetite', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 2. 每日饮水量
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('每日饮水量', 'water_intake', 1, '每日饮水量选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_water = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_water, '1瓶矿泉水', 'one_bottle', 'water_intake', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_water, '1.5瓶矿泉水', 'one_half_bottle', 'water_intake', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_water, '3瓶矿泉水', 'three_bottles', 'water_intake', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_water, '4瓶矿泉水', 'four_bottles', 'water_intake', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 3. 饮食情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('饮食情况', 'diet_condition', 1, '饮食情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_diet = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_diet, '多食', 'overeating', 'diet_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_diet, '纳呆', 'poor_appetite', 'diet_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_diet, '胃胀', 'stomach_bloating', 'diet_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_diet, '胃痛', 'stomach_pain', 'diet_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_diet, '反酸', 'acid_reflux', 'diet_condition', 5, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_diet, '食欲减退', 'loss_of_appetite', 'diet_condition', 6, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 4. 近一个月内体重变化
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('体重变化', 'weight_change', 1, '近一个月内体重变化', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_weight = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_weight, '瘦5斤', 'lose_5_jin', 'weight_change', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_weight, '瘦10斤', 'lose_10_jin', 'weight_change', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_weight, '瘦10斤以上', 'lose_over_10_jin', 'weight_change', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 5. 肢体感觉
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('肢体感觉', 'body_feeling', 1, '肢体感觉选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_body = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_body, '麻木', 'numbness', 'body_feeling', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_body, '乏力', 'weakness', 'body_feeling', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_body, '疼痛', 'pain', 'body_feeling', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_body, '畏寒', 'cold_aversion', 'body_feeling', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_body, '烧热', 'fever', 'body_feeling', 5, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 6. 睡眠情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('睡眠情况', 'sleep_condition', 1, '睡眠情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_sleep = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_sleep, '入睡难', 'difficulty_falling_asleep', 'sleep_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_sleep, '容易醒', 'easy_to_wake', 'sleep_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_sleep, '早醒', 'early_waking', 'sleep_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_sleep, '多梦', 'many_dreams', 'sleep_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 7. 眼睛情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('眼睛情况', 'eye_condition', 1, '眼睛情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_eye = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_eye, '模糊', 'blurred', 'eye_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_eye, '干涩', 'dry', 'eye_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_eye, '流泪', 'tearing', 'eye_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_eye, '飞蚊症', 'floaters', 'eye_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_eye, '出血', 'bleeding', 'eye_condition', 5, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 8. 头部感觉
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('头部感觉', 'head_feeling', 1, '头部感觉选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_head = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_head, '疲劳困倦', 'fatigue', 'head_feeling', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_head, '头晕', 'dizziness', 'head_feeling', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_head, '头痛', 'headache', 'head_feeling', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_head, '耳鸣', 'tinnitus', 'head_feeling', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 9. 出汗情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('出汗情况', 'sweat_condition', 1, '出汗情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_sweat = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_sweat, '日间出汗', 'daytime_sweating', 'sweat_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_sweat, '夜间出汗', 'night_sweating', 'sweat_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_sweat, '汗粘', 'sticky_sweat', 'sweat_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_sweat, '多汗', 'excessive_sweating', 'sweat_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 10. 皮肤情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('皮肤情况', 'skin_condition', 1, '皮肤情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_skin = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_skin, '干燥', 'dry', 'skin_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_skin, '瘙痒', 'itching', 'skin_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_skin, '脱皮', 'peeling', 'skin_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_skin, '水肿', 'edema', 'skin_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_skin, '湿疹', 'eczema', 'skin_condition', 5, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 11. 小便情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('小便情况', 'urine_condition', 1, '小便情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_urine = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_urine, '尿急', 'urgency', 'urine_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_urine, '尿黄', 'yellow_urine', 'urine_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_urine, '有泡', 'foamy', 'urine_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_urine, '尿频', 'frequency', 'urine_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_urine, '尿痛', 'painful', 'urine_condition', 5, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_urine, '夜尿多', 'nocturia', 'urine_condition', 6, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 12. 大便情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('大便情况', 'stool_condition', 1, '大便情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_stool = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_stool, '干燥', 'dry', 'stool_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_stool, '便秘', 'constipation', 'stool_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_stool, '粘腻', 'sticky', 'stool_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_stool, '腹泻', 'diarrhea', 'stool_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 13. 腰肾情况
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('腰肾情况', 'kidney_condition', 1, '腰肾情况选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_kidney = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_kidney, '酸胀', 'soreness', 'kidney_condition', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_kidney, '疼痛', 'pain', 'kidney_condition', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_kidney, '腰痛', 'lower_back_pain', 'kidney_condition', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_kidney, '性功能下降', 'sexual_dysfunction', 'kidney_condition', 4, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 14. 脂肪肝程度
INSERT INTO `zyt_dict_type` (`name`, `type`, `status`, `remark`, `create_time`, `update_time`)
VALUES ('脂肪肝程度', 'fatty_liver_degree', 1, '脂肪肝程度选项', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
SET @type_id_fatty = LAST_INSERT_ID();
INSERT INTO `zyt_dict_data` (`type_id`, `name`, `value`, `type_value`, `sort`, `status`, `remark`, `create_time`, `update_time`) VALUES
(@type_id_fatty, '轻度', 'mild', 'fatty_liver_degree', 1, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_fatty, '中度', 'moderate', 'fatty_liver_degree', 2, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(@type_id_fatty, '重度', 'severe', 'fatty_liver_degree', 3, 1, '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
-- 验证插入结果
SELECT dt.name as '字典类型', COUNT(dd.id) as '选项数量'
FROM zyt_dict_type dt
LEFT JOIN zyt_dict_data dd ON dt.id = dd.type_id
WHERE dt.type IN ('appetite', 'water_intake', 'diet_condition', 'weight_change', 'body_feeling',
'sleep_condition', 'eye_condition', 'head_feeling', 'sweat_condition', 'skin_condition',
'urine_condition', 'stool_condition', 'kidney_condition', 'fatty_liver_degree')
GROUP BY dt.name
ORDER BY dt.id;