USE `med_2021`;

DROP TABLE IF EXISTS `kl_classic_case`;
CREATE TABLE `kl_classic_case` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `is_deleted` char(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N' COMMENT '是否删除,N:未删除，Y:删除',
  `gmt_create` datetime DEFAULT '1970-01-01 12:00:00',
  `gmt_modified` datetime DEFAULT '1970-01-01 12:00:00',
  `creator` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0' COMMENT '创建人，0表示无创建人值',
  `modifier` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
  `concept_id` bigint DEFAULT NULL COMMENT '医院术语id',
  `status` int NOT NULL DEFAULT '1' COMMENT '启用状态（0：禁用，1：启用）',
  `remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='经典病历标准术语表';

DROP TABLE IF EXISTS `kl_case_detail`;
CREATE TABLE `kl_case_detail` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `is_deleted` char(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N' COMMENT '是否删除,N:未删除，Y:删除',
  `gmt_create` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录创建时间',
  `gmt_modified` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录修改时间,如果时间是1970年则表示纪录未修改',
  `creator` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0' COMMENT '创建人，0表示无创建人值',
  `modifier` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
  `concept_id` bigint NOT NULL COMMENT '提示概念id',
  `title` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '提示明细标题',
  `content` mediumtext CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci COMMENT '提示明细内容',
  `text` mediumtext CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci COMMENT '纯文本',
  `order_no` int DEFAULT NULL COMMENT '提示明细序号',
  `content_type` varchar(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '1' COMMENT '内容类型（多选）：1-化验、辅检、手术和操作、诊断、药品静态信息，2-注意事项，3-临床路径，4-治疗方案',
  PRIMARY KEY (`id`),
  KEY `idx_concept_id` (`concept_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=199914 DEFAULT CHARSET=utf8mb3 COMMENT='经典病历内容表';

INSERT INTO `med_2021`.`kl_lexicon` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `is_has_common`, `only_one`, `can_change`, `remark`) VALUES (75, 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '经典病历', 411, 0, 0, 0, '');

INSERT INTO `med_2021`.`kl_dictionary_info` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `group_type`, `name`, `val`, `return_type`, `order_no`, `remark`) VALUES (390, 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', 10, '经典病历', '11', 2, 11, '经典病历');
INSERT INTO `med_2021`.`kl_dictionary_info` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `group_type`, `name`, `val`, `return_type`, `order_no`, `remark`) VALUES (389, 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', 13, '经典病历', '经典病历', 2, 412, '页面显示词性');

ALTER TABLE `kl_drug` ADD COLUMN `drug_c` VARCHAR(255) NULL COMMENT '药品分类' AFTER `drug`;

INSERT INTO `kl_dictionary_info` VALUES('388', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '50', '诊疗指南', '5', '1', '50', '静态知识类型')

UPDATE `kl_dictionary_info` SET `val` = CONCAT(`val`, ',5') WHERE `group_type` = 51 AND `val` LIKE '%3,4%';