Browse Source

量表结构和诊断依据结构统一

zhoutg 3 years ago
parent
commit
233d079868

+ 21 - 2
doc/008.20210629诊断依据基础表扩展/med_2021.sql

@@ -14,7 +14,26 @@ CREATE TABLE `kl_diagnose_base_relation` (
   PRIMARY KEY (`id`),
   PRIMARY KEY (`id`),
   KEY `diagnose_base_id` (`diagnose_base_id`),
   KEY `diagnose_base_id` (`diagnose_base_id`),
   KEY `concept_id` (`concept_id`)
   KEY `concept_id` (`concept_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='基础规则关联表';
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='基础规则关联表';
 
 
 ALTER TABLE `kl_diagnose_base` drop COLUMN `concept_id`;
 ALTER TABLE `kl_diagnose_base` drop COLUMN `concept_id`;
-ALTER TABLE `kl_diagnose_base` drop COLUMN `status`;
+ALTER TABLE `kl_diagnose_base` drop COLUMN `status`;
+
+drop TABLE if EXISTS kl_regulation_base_relation;
+CREATE TABLE `kl_regulation_base_relation` (
+  `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则表示纪录未修改',
+  `regulation_base_id` bigint(20) NOT NULL COMMENT 'regulation_base_id',
+  `concept_id` bigint(20) NOT NULL COMMENT 'concept_id',
+  `order_no` int(11) NOT NULL DEFAULT '0' COMMENT '排序号',
+  PRIMARY KEY (`id`),
+  KEY `regulation_base_id` (`regulation_base_id`),
+  KEY `concept_id` (`concept_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='通用基础规则关联表';
+
+ALTER TABLE `kl_regulation_base` drop COLUMN `concept_id`;
+ALTER TABLE `kl_regulation_base` drop COLUMN `status`;

+ 1 - 1
src/main/java/com/diagbot/config/CacheDeleteInit.java

@@ -54,7 +54,7 @@ public class CacheDeleteInit implements CommandLineRunner {
         cacheFacade.loadAllBaseDiagnoseCache();
         cacheFacade.loadAllBaseDiagnoseCache();
         log.info("CDSS-CORE服务启动加载诊断依据缓存成功!");
         log.info("CDSS-CORE服务启动加载诊断依据缓存成功!");
 
 
-        cacheFacade.loadAllRuleCache();
+        // cacheFacade.loadAllRuleCache();
         log.info("CDSS-CORE服务启动加载医学知识库中的所有规则缓存成功!");
         log.info("CDSS-CORE服务启动加载医学知识库中的所有规则缓存成功!");
 
 
         log.info("CDSS-CORE初始化完成!");
         log.info("CDSS-CORE初始化完成!");

+ 2 - 6
src/main/java/com/diagbot/dto/BaseRegulationDTO.java

@@ -11,10 +11,6 @@ import lombok.Setter;
 @Getter
 @Getter
 @Setter
 @Setter
 public class BaseRegulationDTO {
 public class BaseRegulationDTO {
-    /**
-     * 联合唯一键
-     */
-    private String baseKey;
 
 
     /**
     /**
      * id逗号隔开
      * id逗号隔开
@@ -32,9 +28,9 @@ public class BaseRegulationDTO {
     private Integer baseLibType;
     private Integer baseLibType;
 
 
     /**
     /**
-     * 提示概念id
+     * 多个概念id
      */
      */
-    private Long conceptId;
+    private String baseConceptids;
 
 
     /**
     /**
      * 基础规则类型(1:等于术语本身;2:存在比较;3:不等于术语本身;)
      * 基础规则类型(1:等于术语本身;2:存在比较;3:不等于术语本身;)

+ 0 - 5
src/main/java/com/diagbot/entity/KlRegulationBase.java

@@ -51,11 +51,6 @@ public class KlRegulationBase implements Serializable {
      */
      */
     private String modifier;
     private String modifier;
 
 
-    /**
-     * 提示概念id
-     */
-    private Long conceptId;
-
     /**
     /**
      * 描述
      * 描述
      */
      */

+ 1 - 1
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -501,7 +501,7 @@ public class NeoFacade {
     }
     }
 
 
     public void allBaseRegulation() {
     public void allBaseRegulation() {
-        List<BaseRegulationDTO> list = klRegulationBaseFacade.getAllBase();
+        List<BaseRegulationDTO> list = klRegulationBaseFacade.getSelectBase(new ArrayList<>());
         if (ListUtil.isNotEmpty(list)) {
         if (ListUtil.isNotEmpty(list)) {
             redisTemplate.opsForValue().set(RedisEnum.allBaseRegulation.getName(), list);
             redisTemplate.opsForValue().set(RedisEnum.allBaseRegulation.getName(), list);
         }
         }

+ 0 - 3
src/main/java/com/diagbot/mapper/KlRegulationBaseMapper.java

@@ -16,8 +16,5 @@ import java.util.List;
  */
  */
 public interface KlRegulationBaseMapper extends BaseMapper<KlRegulationBase> {
 public interface KlRegulationBaseMapper extends BaseMapper<KlRegulationBase> {
 
 
-    // 获取所有去重的基础规则
-    List<BaseRegulationDTO> getAllBase();
-
     List<BaseRegulationDTO> getSelectBase(List<String> codeList);
     List<BaseRegulationDTO> getSelectBase(List<String> codeList);
 }
 }

+ 0 - 3
src/main/java/com/diagbot/service/KlRegulationBaseService.java

@@ -16,8 +16,5 @@ import java.util.List;
  */
  */
 public interface KlRegulationBaseService extends IService<KlRegulationBase> {
 public interface KlRegulationBaseService extends IService<KlRegulationBase> {
 
 
-    // 获取所有去重的基础规则
-    List<BaseRegulationDTO> getAllBase();
-
     List<BaseRegulationDTO> getSelectBase(List<String> codeList);
     List<BaseRegulationDTO> getSelectBase(List<String> codeList);
 }
 }

+ 0 - 5
src/main/java/com/diagbot/service/impl/KlRegulationBaseServiceImpl.java

@@ -20,11 +20,6 @@ import java.util.List;
 @Service
 @Service
 public class KlRegulationBaseServiceImpl extends ServiceImpl<KlRegulationBaseMapper, KlRegulationBase> implements KlRegulationBaseService {
 public class KlRegulationBaseServiceImpl extends ServiceImpl<KlRegulationBaseMapper, KlRegulationBase> implements KlRegulationBaseService {
 
 
-    @Override
-    public List<BaseRegulationDTO> getAllBase() {
-        return baseMapper.getAllBase();
-    }
-
     @Override
     @Override
     public List<BaseRegulationDTO> getSelectBase(List<String> codeList) {
     public List<BaseRegulationDTO> getSelectBase(List<String> codeList) {
         return baseMapper.getSelectBase(codeList);
         return baseMapper.getSelectBase(codeList);

+ 66 - 102
src/main/resources/mapper/KlRegulationBaseMapper.xml

@@ -10,7 +10,6 @@
         <result column="gmt_modified" property="gmtModified" />
         <result column="gmt_modified" property="gmtModified" />
         <result column="creator" property="creator" />
         <result column="creator" property="creator" />
         <result column="modifier" property="modifier" />
         <result column="modifier" property="modifier" />
-        <result column="concept_id" property="conceptId" />
         <result column="description" property="description" />
         <result column="description" property="description" />
         <result column="type" property="type" />
         <result column="type" property="type" />
         <result column="min_operator" property="minOperator" />
         <result column="min_operator" property="minOperator" />
@@ -24,46 +23,26 @@
         <result column="eq_unit" property="eqUnit" />
         <result column="eq_unit" property="eqUnit" />
     </resultMap>
     </resultMap>
 
 
-    <select id="getAllBase" resultType="com.diagbot.dto.BaseRegulationDTO">
-        SELECT DISTINCT
-            CONCAT_WS(
-                "_",
-                t1.concept_id,
-                t1.type,
-                t1.max_operator,
-                t1.max_value,
-                t1.max_unit,
-                t1.min_operator,
-                t1.min_value,
-                t1.min_unit,
-                t1.eq_operator,
-                t1.eq_value,
-                t1.eq_unit
-            ) AS baseKey,
-            GROUP_CONCAT(t1.id) AS ids,
-            IFNULL(t2.lib_name, "") AS baseLibName,
-            IFNULL(t2.lib_type, 0) AS baseLibType,
-            t1.concept_id,
-            t1.type AS baseType,
-            t1.max_operator AS baseMaxOperator,
-            t1.max_value AS baseMaxValue,
-            t1.max_unit AS baseMaxUnit,
-            t1.min_operator AS baseMinOperator,
-            t1.min_value AS baseMinValue,
-            t1.min_unit AS baseMinUnit,
-            t1.eq_operator AS baseEqOperator,
-            t1.eq_value AS baseEqValue,
-            t1.eq_unit AS baseEqUnit
+    <select id="getSelectBase" resultType="com.diagbot.dto.BaseRegulationDTO">
+        SELECT
+            t.type baseType,
+            t.max_operator baseMaxOperator,
+            t.max_value baseMaxValue,
+            t.max_unit baseMaxUnit,
+            t.min_operator baseMinOperator,
+            t.min_value baseMinValue,
+            t.min_unit baseMinUnit,
+            t.eq_operator baseEqOperator,
+            t.eq_value baseEqValue,
+            t.eq_unit baseEqUnit,
+            t.conceptids baseConceptids,
+            t.lib_name baseLibName,
+            t.lib_type baseLibType,
+            GROUP_CONCAT(t.id) ids
         FROM
         FROM
-            kl_regulation_base t1
-        LEFT JOIN kl_concept t2 ON t1.concept_id = t2.id
-        AND t2.is_deleted = "N"
-        AND t2.`status` = 1
-        WHERE
-            t1.is_deleted = "N"
-        AND t1.`status` = 1
-        GROUP BY
-            t1.concept_id,
+        (
+            SELECT
+            t1.id,
             t1.type,
             t1.type,
             t1.max_operator,
             t1.max_operator,
             t1.max_value,
             t1.max_value,
@@ -73,77 +52,62 @@
             t1.min_unit,
             t1.min_unit,
             t1.eq_operator,
             t1.eq_operator,
             t1.eq_value,
             t1.eq_value,
-            t1.eq_unit
-    </select>
-
-    <select id="getSelectBase" resultType="com.diagbot.dto.BaseRegulationDTO">
-        SELECT DISTINCT
-            CONCAT_WS(
-                "_",
-                t1.concept_id,
-                t1.type,
-                t1.max_operator,
-                t1.max_value,
-                t1.max_unit,
-                t1.min_operator,
-                t1.min_value,
-                t1.min_unit,
-                t1.eq_operator,
-                t1.eq_value,
-                t1.eq_unit
-            ) AS baseKey,
-            GROUP_CONCAT(t1.id) AS ids,
-            IFNULL(t2.lib_name, "") AS baseLibName,
-            IFNULL(t2.lib_type, 0) AS baseLibType,
-            t1.concept_id,
-            t1.type AS baseType,
-            t1.max_operator AS baseMaxOperator,
-            t1.max_value AS baseMaxValue,
-            t1.max_unit AS baseMaxUnit,
-            t1.min_operator AS baseMinOperator,
-            t1.min_value AS baseMinValue,
-            t1.min_unit AS baseMinUnit,
-            t1.eq_operator AS baseEqOperator,
-            t1.eq_value AS baseEqValue,
-            t1.eq_unit AS baseEqUnit
-        FROM
-            kl_regulation_base t1
-        LEFT JOIN kl_concept t2 ON t1.concept_id = t2.id
-        AND t2.is_deleted = "N"
-        AND t2.`status` = 1
-        WHERE
-            t1.is_deleted = "N"
-        AND t1.`status` = 1
-        AND t1.id in
-        (
-            SELECT
-            b.regulation_base_id
+            t1.eq_unit,
+            IFNULL(t2.conceptids, 0) conceptids,
+            IFNULL(t2.lib_name, '') lib_name,
+            IFNULL(t2.lib_type, 0) lib_type
             FROM
             FROM
-            `kl_regulation` a,
-            kl_regulation_condition b
+            kl_regulation_base t1
+            LEFT JOIN (
+                SELECT
+                regulation_base_id,
+                lib_type,
+                GROUP_CONCAT(concept_id ORDER BY concept_id) conceptids,
+                GROUP_CONCAT(lib_name ORDER BY concept_id SEPARATOR '#') lib_name
+                FROM
+                `kl_regulation_base_relation` m,
+                kl_concept c
+                WHERE
+                m.is_deleted = 'N'
+                AND c.is_deleted = 'N'
+                AND c. STATUS = 1
+                AND m.concept_id = c.id
+                GROUP BY m.regulation_base_id, c.lib_type
+            ) t2 ON t1.id = t2.regulation_base_id
             WHERE
             WHERE
-            a.id = b.regulation_id
+            t1.is_deleted = 'N'
             <if test="list != null and list.size > 0">
             <if test="list != null and list.size > 0">
+                AND t1.id in
+                (
+                SELECT
+                b.regulation_base_id
+                FROM
+                `kl_regulation` a,
+                kl_regulation_condition b
+                WHERE
+                a.id = b.regulation_id
                 and a.`code` in
                 and a.`code` in
                 <foreach item="code" collection="list" open="(" separator="," close=")">
                 <foreach item="code" collection="list" open="(" separator="," close=")">
                     #{code}
                     #{code}
                 </foreach>
                 </foreach>
+                AND a.`status` = 1
+                AND b.condition_type = 1
+                )
             </if>
             </if>
-            AND a.`status` = 1
-            AND b.condition_type = 1
-        )
+        ) t
         GROUP BY
         GROUP BY
-            t1.concept_id,
-            t1.type,
-            t1.max_operator,
-            t1.max_value,
-            t1.max_unit,
-            t1.min_operator,
-            t1.min_value,
-            t1.min_unit,
-            t1.eq_operator,
-            t1.eq_value,
-            t1.eq_unit
+            t.type,
+            t.max_operator,
+            t.max_value,
+            t.max_unit,
+            t.min_operator,
+            t.min_value,
+            t.min_unit,
+            t.eq_operator,
+            t.eq_value,
+            t.eq_unit,
+            t.conceptids,
+            t.lib_name
     </select>
     </select>
 
 
 </mapper>
 </mapper>