use `med`;
drop table if exists `kl_symptom`;
CREATE TABLE `kl_symptom` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `is_deleted` char(1) 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) NOT NULL DEFAULT '0' COMMENT '创建人，0表示无创建人值',
  `modifier` varchar(20) NOT NULL DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
  `concept_id` bigint(20) NOT NULL COMMENT '术语概念id',
  `description` varchar(500) NOT NULL DEFAULT '' COMMENT '描述',
  `explains` text DEFAULT NULL COMMENT '详细阐述',
  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`),
  UNIQUE KEY `CONCEPT_ID_INDEX` (`concept_id`) USING BTREE COMMENT '概念id全表唯一'
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='症状扩展表';

insert into `med`.kl_symptom(`concept_id`)
select DISTINCT id from `med`.kl_concept where lib_type = 1;

update `med`.kl_symptom t,
    (select b.id, a.description, a.explains from `sys-prec`.prec_question_info a, `med`.kl_concept b
    where a.is_deleted = 'N' and b.is_deleted = 'N' and  b.lib_type = 1 and a.type = 1 and a.tag_type = 4
    and Encrypt_char(a.tag_name) = b.lib_name) m
set t.description = m.description, t.explains = m.explains
where t.concept_id = m.id;

