--- 5.2.0.230313_Release

--- 1.病人基本信息表缺失字段补充
ALTER TABLE patientbase add COLUMN IsMyself TINYINT(1) not null;
ALTER TABLE patientbase add COLUMN DeletedState INT(11) DEFAULT 0 not null;
ALTER TABLE patientbase add COLUMN UpdateTime datetime DEFAULT NULL;
ALTER TABLE patientbase add COLUMN CardType VARCHAR(6) DEFAULT NULL;

--- 2.支付表缺失字段补充
ALTER TABLE pay ADD COLUMN FeeId VARCHAR(32) DEFAULT NULL;
ALTER TABLE pay ADD COLUMN FeeInfo VARCHAR(1024) DEFAULT NULL;



--- 3.核酸配置表
CREATE TABLE `config_self_help`  (
                                     `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                     `UpdateTime` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
                                     `UpdateUser` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
                                     `GroupType` int(6) NOT NULL COMMENT '分组类型',
                                     `Seq` int(10) NULL DEFAULT NULL,
                                     `Code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '调用码',
                                     `Title` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'HIS开单名称',
                                     `ShowTitle` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信显示的申请单名称',
                                     `Fee` decimal(8, 3) NULL DEFAULT NULL COMMENT 'HIS申请单费用',
                                     `Description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提示说明',
                                     `ConfirmBtnText` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '确认按钮提示文字',
                                     `EnterDialogText` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '进入弹框文字',
                                     `EnterDialogTitle` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '进入弹框标题',
                                     `EnterDialogState` int(3) NOT NULL DEFAULT 0 COMMENT '弹框显示状态',
                                     `IsDisabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否禁用',
                                     `IsEnterDialog` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否进入弹框提示',
                                     `Color` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '主题颜色',
                                     `EveryDayNum` int(11) NULL DEFAULT NULL COMMENT '每日检测数量',
                                     `BegTime` time(0) NULL DEFAULT NULL COMMENT '限制开始时间',
                                     `EndTime` time(0) NULL DEFAULT NULL COMMENT '限制结束时间',
                                     `BegTime2` time(0) NULL DEFAULT NULL COMMENT '限制开始时间2',
                                     `EndTime2` time(0) NULL DEFAULT NULL COMMENT '限制结束时间2',
                                     PRIMARY KEY (`ID`) USING BTREE,
                                     UNIQUE INDEX `ID`(`ID`) USING BTREE,
                                     UNIQUE INDEX `Code`(`Code`) USING BTREE,
                                     INDEX `UpdateTime`(`UpdateTime`) USING BTREE,
                                     INDEX `Seq`(`Seq`) USING BTREE,
                                     INDEX `GroupType`(`GroupType`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Records of config_self_help
-- ----------------------------
INSERT INTO `config_self_help` VALUES (1, '2023-02-13 08:46:46', NULL, 0, 1, '1,0', '自助核酸（单检）', '自助核酸（单检）', NULL, '<div class=header-tip-item><span>1、如您的<span style=color:var(--color-danger)>体温≥37.3度</span> 或有咳嗽，乏力、胸闷、咽痛、腹泻、黄疸症状及新冠病毒流行病学史，请立即到医院大门入口预检分诊处，由我院医务人员引导至发热门诊就诊！</span></div><div class=header-tip-item>2、此入口为核酸检测便捷通道，在微信上缴费后，于每天<span style=color:var(--color-danger)>07:30-20:50</span>直接到医院核酸采样点展示门诊号采样；</div><div class=header-tip-item><span>3、于采集后12-24小时内在公众号上查阅电子报告，如需纸质报告单，取报告地点为<span style=color:var(--color-danger)>医院北大门口医学检验科</span>自助取报告机使用条形码自助打印检验报告。</div>', NULL, NULL, NULL, 0, 1, 0, 'teal', NULL, NULL, NULL, NULL, NULL);
INSERT INTO `config_self_help` VALUES (2, '2023-02-13 08:50:03', NULL, 0, 2, '1,1', '自助核酸（5混1）', '自助核酸（5混1）', NULL, '<div class=header-tip-item><span>1、如您的<span style=color:var(--color-danger)>体温≥37.3度</span> 或有咳嗽，乏力、胸闷、咽痛、腹泻、黄疸症状及新冠病毒流行病学史，请立即到医院大门入口预检分诊处，由我院医务人员引导至发热门诊就诊！</span></div><div class=header-tip-item>2、此入口为核酸检测便捷通道，在微信上缴费后，于每天<span style=color:var(--color-danger)>07:30-20:50</span>直接到医院核酸采样点展示门诊号采样；</div><div class=header-tip-item><span>3、于采集后12-24小时内在公众号上查阅电子报告，如需纸质报告单，取报告地点为<span style=color:var(--color-danger)>医院北大门口医学检验科</span>自助取报告机使用条形码自助打印检验报告。</div>', NULL, NULL, NULL, 0, 1, 0, 'rgba(255, 120, 0, 1)', 0, NULL, NULL, NULL, NULL);
INSERT INTO `config_self_help` VALUES (3, '2023-02-24 10:42:36', NULL, 0, 3, '2,0', '自助核酸（10混1）', '自助核酸（10混1）', NULL, '<div class=header-tip-item><span>1、如您的<span style=color:var(--color-danger)>体温≥37.3度</span> 或有咳嗽，乏力、胸闷、咽痛、腹泻、黄疸症状及新冠病毒流行病学史，请立即到医院大门入口预检分诊处，由我院医务人员引导至发热门诊就诊！</span></div><div class=header-tip-item>2、此入口为核酸检测便捷通道，在微信上缴费后，于每天<span style=color:var(--color-danger)>07:30-20:50</span>直接到医院核酸采样点展示门诊号采样；</div><div class=header-tip-item><span>3、于采集后12-24小时内在公众号上查阅电子报告，如需纸质报告单，取报告地点为<span style=color:var(--color-danger)>医院北大门口医学检验科</span>自助取报告机使用条形码自助打印检验报告。</div>', NULL, NULL, NULL, 0, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL);

SET FOREIGN_KEY_CHECKS = 1;



--- 4.核酸限号表
CREATE TABLE `self_help`  (
                              `ID` int(11) NOT NULL AUTO_INCREMENT,
                              `Openid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
                              `UpdateTime` datetime(0) NOT NULL,
                              `NoticeState` int(3) NOT NULL,
                              `TreatNum` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
                              `Code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
                              PRIMARY KEY (`ID`) USING BTREE,
                              UNIQUE INDEX `ID`(`ID`) USING BTREE,
                              UNIQUE INDEX `TreatNum`(`TreatNum`) USING BTREE,
                              INDEX `Openid`(`Openid`) USING BTREE,
                              INDEX `UpdateTime`(`UpdateTime`) USING BTREE,
                              INDEX `NoticeState`(`NoticeState`) USING BTREE,
                              INDEX `Code`(`Code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;

SET FOREIGN_KEY_CHECKS = 1;



--- 5.2.1.230423_Release [扫码盒子对账更新]

--- 1.pay_result 支付结果表新增字段 OrderType AuthCode

ALTER TABLE pay_result ADD COLUMN OrderType VARCHAR(16),ALGORITHM=INPLACE, LOCK=NONE;
ALTER TABLE pay_result ADD COLUMN AuthCode VARCHAR(30),ALGORITHM=INPLACE, LOCK=NONE;


--- 2.pay，register，pay_in_hosp 支付记录新增 RefundTime

ALTER TABLE pay ADD COLUMN RefundTime datetime;
ALTER TABLE register ADD COLUMN RefundTime datetime;
ALTER TABLE pay_in_hosp ADD COLUMN RefundTime datetime;


--- 5.3.1.20230621  新增 病案翻拍表，支付未用，字段预留

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for pay_casebook
-- ----------------------------
CREATE TABLE `pay_casebook`  (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `UpdateTime` datetime(0) NOT NULL,
  `OpenID` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `PatientID` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ApplyId` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '病案申请Id号',
  `UseToNo` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模版Id',
  `UseToName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模版名称',
  `GetWay` int(11) NOT NULL COMMENT '获取方式; 0自提 1邮寄',
  `Address` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮寄地址',
  `Phone` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系电话',
  `PatientName` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `OutTradeNo` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '',
  `BankTransNo` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TradeNo` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TreatNum` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TotalFee` decimal(10, 3),
  `PayWay` int(11) NULL DEFAULT 0,
  `PayMoney` decimal(10, 3) ,
  `PayStatus` int(11) ,
  `HisStatus` int(11) ,
  `HisTransNo` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `HisResult` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `InvoiceTransNo` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RefundResult` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `OperateUser` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `AuthCode` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `Remark` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PayOrdId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '医保订单号',
  `AcctFee` decimal(10, 3) NULL DEFAULT NULL COMMENT '医保个账金额',
  `HifpFee` decimal(10, 3) NULL DEFAULT NULL COMMENT '医保统筹金额',
  `ChrgBchno` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '顶',
  `MdTrtId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '医保就诊ID',
  `MdUserId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '医保用户ID',
  `BankMerchantNo` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '银行商户号',
  `RefundTime` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE,
  UNIQUE INDEX `ID`(`ID`) USING BTREE,
  UNIQUE INDEX `TradeNo`(`TradeNo`) USING BTREE,
  UNIQUE INDEX `AuthCode`(`AuthCode`) USING BTREE,
  INDEX `UpdateTime`(`UpdateTime`) USING BTREE,
  INDEX `OutTradeNo`(`OutTradeNo`) USING BTREE,
  INDEX `BankTransNo`(`BankTransNo`) USING BTREE,
  INDEX `TreatNum`(`TreatNum`) USING BTREE,
  INDEX `PayWay`(`PayWay`) USING BTREE,
  INDEX `PayStatus`(`PayStatus`) USING BTREE,
  INDEX `HisStatus`(`HisStatus`) USING BTREE,
  INDEX `InvoiceTransNo`(`InvoiceTransNo`) USING BTREE,
  INDEX `RefundTime`(`RefundTime`) USING BTREE,
  INDEX `MdUserId`(`MdUserId`) USING BTREE,
  INDEX `PayMoney`(`PayMoney`) USING BTREE,
  INDEX `TotalFee`(`TotalFee`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT;

SET FOREIGN_KEY_CHECKS = 1;





-- ----------------------------
-- 增加报表统计
-- ----------------------------

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for report
-- ----------------------------
CREATE TABLE `report` (
  `ReportId` int NOT NULL AUTO_INCREMENT,
  `UpdateTime` date DEFAULT NULL,
  `ReportCount` int DEFAULT NULL,
  `ReportType` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `Remark` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`ReportId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

SET FOREIGN_KEY_CHECKS = 1;



--- 处方表新增处方类型
ALTER TABLE pay ADD COLUMN OrderType VARCHAR(30),ALGORITHM=INPLACE, LOCK=NONE;




---  新增 体检预约缴费记录表

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for pay_casebook
-- ----------------------------
CREATE TABLE `peis_reserve`  (
  `ID` int NOT NULL AUTO_INCREMENT,
  `UpdateTime` datetime NOT NULL,
  `OpenID` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `PatientID` varchar(16) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `OutTradeNo` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `BankTransNo` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `TradeNo` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `RecipeID` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `TreatNum` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `TotalFee` decimal(10,3) DEFAULT NULL,
  `PayWay` int DEFAULT '0',
  `PayMoney` decimal(10,3) DEFAULT NULL,
  `PayStatus` int DEFAULT NULL,
  `PeisStatus` int DEFAULT NULL,
  `PeisResult` varchar(1024) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `PeisTransNo` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `InvoiceTransNo` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `RefundResult` varchar(1024) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `OperateUser` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `AuthCode` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `RecipeJson` varchar(600) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `Remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `Fee` varchar(600) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `DeptCode` varchar(16) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `DeptName` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `ReqDeptCode` varchar(16) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `ReqDeptName` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `HospitalArea` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `PayOrdId` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '医保订单号',
  `AcctFee` decimal(10,3) DEFAULT NULL COMMENT '医保个账金额',
  `HifpFee` decimal(10,3) DEFAULT NULL COMMENT '医保统筹金额',
  `ChrgBchno` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '顶',
  `MdTrtId` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '医保就诊ID',
  `MdUserId` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '医保用户ID',
  `FeeId` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `FeeInfo` varchar(1024) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `RefundTime` datetime DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE,
  UNIQUE KEY `ID` (`ID`) USING BTREE,
  UNIQUE KEY `TradeNo` (`TradeNo`) USING BTREE,
  UNIQUE KEY `AuthCode` (`AuthCode`) USING BTREE,
  KEY `UpdateTime` (`UpdateTime`) USING BTREE,
  KEY `OpenID` (`OpenID`) USING BTREE,
  KEY `PatientID` (`PatientID`) USING BTREE,
  KEY `OutTradeNo` (`OutTradeNo`) USING BTREE,
  KEY `BankTransNo` (`BankTransNo`) USING BTREE,
  KEY `RecipeID` (`RecipeID`) USING BTREE,
  KEY `TreatNum` (`TreatNum`) USING BTREE,
  KEY `TotalFee` (`TotalFee`) USING BTREE,
  KEY `PayWay` (`PayWay`) USING BTREE,
  KEY `PayStatus` (`PayStatus`) USING BTREE,
  KEY `PeisStatus` (`PeisStatus`) USING BTREE,
  KEY `InvoiceTransNo` (`InvoiceTransNo`) USING BTREE,
  KEY `MdUserId` (`MdUserId`) USING BTREE,
  KEY `PayMoney` (`PayMoney`) USING BTREE,
  KEY `RefundTime` (`RefundTime`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT;

SET FOREIGN_KEY_CHECKS = 1;
