
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for appointment
-- ----------------------------
DROP TABLE IF EXISTS `appointment`;
CREATE TABLE `appointment` (
  `id` int NOT NULL AUTO_INCREMENT,
  `pat_num` varchar(30) NOT NULL,
  `pat_name` varchar(10) NOT NULL,
  `pat_gender` bit(1) NOT NULL,
  `pat_birthday` date DEFAULT NULL,
  `pat_mobile` char(11) DEFAULT NULL,
  `pat_phone` varchar(20) DEFAULT NULL,
  `pat_identity_id` varchar(20) DEFAULT NULL COMMENT '身份证号',
  `pat_addr` varchar(45) DEFAULT NULL,
  `pat_dept_code` varchar(45) NOT NULL COMMENT '患者所在科室代码',	
  `pat_dept_desc` varchar(45) NOT NULL COMMENT '患者所在科室名称',
  `pat_ward_code` varchar(45) NOT NULL COMMENT '患者所在病区代码',
  `pat_ward_desc` varchar(45) NOT NULL COMMENT '患者所在病区名称',
  `pat_bed_no` varchar(45) NOT NULL COMMENT '床号', 
  `book_num` varchar(45) NOT NULL,
  `book_period_start` datetime NOT NULL COMMENT '预约检查时间段',
  `book_period_end` datetime NOT NULL COMMENT '预约检查时间段',
  `book_time` datetime NOT NULL COMMENT '预约发生时间',
  `book_check_type` tinyint(1) DEFAULT NULL,
  `book_src` varchar(45) NOT NULL COMMENT '预约来源：X系统、护士手动预约',
  `sync_time` datetime DEFAULT NULL,
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  `deleted` bit(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_book_num` (`book_num`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- ----------------------------
-- Table structure for queue
-- ----------------------------
DROP TABLE IF EXISTS `queue`;
CREATE TABLE `queue` (
  `id` int NOT NULL AUTO_INCREMENT,
  `pat_id` varchar(30) NOT NULL,
  `pat_name` varchar(10) NOT NULL,
  `pat_gender` bit(1) DEFAULT NULL,
  `book_time_slot` datetime NOT NULL,
  `book_check_type` tinyint(1) DEFAULT NULL,
  `seq_num` int NOT NULL COMMENT '排队序号',
  `status` tinyint(1) NOT NULL COMMENT '10:排队中 20:候诊准备 30:就诊中 40:就诊完成 50:过号 60:过期',
  `passed` tinyint(1) NOT NULL COMMENT '过号标记',
  `expired` tinyint(1) NOT NULL COMMENT '预约过期标记',
  `room_num` varchar(10) DEFAULT NULL,
  `bed_num` varchar(10) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_seq_num` (`seq_num`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- ----------------------------
-- Table structure for room_bed
-- ----------------------------
DROP TABLE IF EXISTS `room_bed`;
CREATE TABLE `room_bed` (
  `id` int NOT NULL AUTO_INCREMENT,
  `room_no` varchar(10) NOT NULL,
  `bed_no` varchar(10) NOT NULL,
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  `deleted` bit(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- ----------------------------
-- Table structure for device_model
-- ----------------------------
DROP TABLE IF EXISTS `device_model`;
CREATE TABLE `device_model` (
  `id` int NOT NULL,
  `category` varchar(45) DEFAULT NULL,
  `brand` varchar(45) DEFAULT NULL,
  `model` varchar(45) DEFAULT NULL,
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  `deleted` bit(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- ----------------------------
-- Table structure for device
-- ----------------------------
DROP TABLE IF EXISTS `device`;
CREATE TABLE `device` (
  `id` int NOT NULL,
  `dev_num` varchar(45) DEFAULT NULL,
  `category` varchar(45) DEFAULT NULL,
  `model` varchar(45) DEFAULT NULL,
  `brand` varchar(45) DEFAULT NULL,
  `purchase_date` date DEFAULT NULL,
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL,
  `deleted` bit(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `dev_num_UNIQUE` (`dev_num`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- ----------------------------
-- Table structure for dev_rent
-- ----------------------------
DROP TABLE IF EXISTS `dev_rent`;
CREATE TABLE `dev_rent` (
  `id` int NOT NULL,
  `dev_num` varchar(45) DEFAULT NULL,
  `pat_num` varchar(45) DEFAULT NULL,
  `pat_name` varchar(45) DEFAULT NULL,
  `rent_time` datetime DEFAULT NULL,
  `return_time` datetime DEFAULT NULL,
  `interference` int DEFAULT NULL COMMENT '干扰数',
  `baseline` varchar(100) DEFAULT NULL COMMENT '基线粗',
  `detachment` varchar(100) DEFAULT NULL COMMENT '脱离',  
  `remark` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

