You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.7 KiB
SQL
95 lines
3.7 KiB
SQL
-- 检查部位字典表
|
|
DROP TABLE IF EXISTS `exam_body_part`;
|
|
CREATE TABLE `exam_body_part` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`code` varchar(20) NOT NULL COMMENT '部位编码',
|
|
`name` varchar(100) NOT NULL COMMENT '部位名称',
|
|
`parent_id` int(11) NULL DEFAULT NULL COMMENT '上级部位ID(为空则为一级部位)',
|
|
`sort_order` int(11) NULL DEFAULT 0 COMMENT '排序',
|
|
`status` tinyint(4) NULL DEFAULT 1 COMMENT '0停用1启用',
|
|
`deleted` tinyint(4) NOT NULL DEFAULT 0,
|
|
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE INDEX `uk_code` (`code`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='检查部位字典表';
|
|
|
|
-- 一级部位
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(1, '001', '头部', NULL, 1),
|
|
(2, '002', '颌面部', NULL, 2),
|
|
(3, '003', '颈部', NULL, 3),
|
|
(4, '004', '胸部', NULL, 4),
|
|
(5, '005', '腹部', NULL, 5),
|
|
(6, '006', '脊柱', NULL, 6),
|
|
(7, '007', '四肢', NULL, 7);
|
|
|
|
-- 二级部位-头部
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(11, '001001', '头颅', 1, 1),
|
|
(12, '001002', '垂体', 1, 2),
|
|
(13, '001003', '眼眶', 1, 3),
|
|
(14, '001004', '内耳', 1, 4),
|
|
(15, '001005', '鼻窦', 1, 5),
|
|
(16, '001006', '腮腺', 1, 6);
|
|
|
|
-- 二级部位-颌面部
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(21, '002001', '面部', 2, 1),
|
|
(22, '002002', '鼻咽部', 2, 2),
|
|
(23, '002003', '颌下腺', 2, 3);
|
|
|
|
-- 二级部位-颈部
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(31, '003001', '颈部', 3, 1),
|
|
(32, '003002', '甲状腺', 3, 2),
|
|
(33, '003003', '颈动脉', 3, 3);
|
|
|
|
-- 二级部位-胸部
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(41, '004001', '胸部', 4, 1),
|
|
(42, '004002', '心脏', 4, 2),
|
|
(43, '004003', '乳腺', 4, 3);
|
|
|
|
-- 二级部位-腹部
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(51, '005001', '上腹部', 5, 1),
|
|
(52, '005002', '下腹部', 5, 2),
|
|
(53, '005003', '盆腔', 5, 3),
|
|
(54, '005004', '肝胆胰', 5, 4),
|
|
(55, '005005', '双肾', 5, 5),
|
|
(56, '005006', '肾上腺', 5, 6),
|
|
(57, '005007', '膀胱', 5, 7),
|
|
(58, '005008', '前列腺', 5, 8),
|
|
(59, '005009', '子宫附件', 5, 9);
|
|
|
|
-- 二级部位-脊柱
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(61, '006001', '颈椎', 6, 1),
|
|
(62, '006002', '胸椎', 6, 2),
|
|
(63, '006003', '腰椎', 6, 3),
|
|
(64, '006004', '骶尾椎', 6, 4);
|
|
|
|
-- 二级部位-四肢
|
|
INSERT INTO `exam_body_part` (`id`, `code`, `name`, `parent_id`, `sort_order`) VALUES
|
|
(71, '007001', '肩关节', 7, 1),
|
|
(72, '007002', '肘关节', 7, 2),
|
|
(73, '007003', '腕关节', 7, 3),
|
|
(74, '007004', '髋关节', 7, 4),
|
|
(75, '007005', '膝关节', 7, 5),
|
|
(76, '007006', '踝关节', 7, 6),
|
|
(77, '007007', '上肢血管', 7, 7),
|
|
(78, '007008', '下肢血管', 7, 8);
|
|
|
|
-- 检查项目-部位关联表(多对多)
|
|
DROP TABLE IF EXISTS `exam_item_body_part`;
|
|
CREATE TABLE `exam_item_body_part` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`item_id` int(11) NOT NULL COMMENT '检查项目ID',
|
|
`body_part_id` int(11) NOT NULL COMMENT '部位ID',
|
|
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE INDEX `uk_item_part` (`item_id`, `body_part_id`),
|
|
INDEX `idx_body_part` (`body_part_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='检查项目-部位关联表';
|