Bläddra i källkod

根据匹配的基础规则ID获取确诊、拟诊、警惕的疾病

gaodm 4 år sedan
förälder
incheckning
12dadc8467

+ 17 - 0
src/main/java/com/diagbot/dto/DiagnoseDTO.java

@@ -0,0 +1,17 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/3/15 11:21
+ */
+@Getter
+@Setter
+public class DiagnoseDTO {
+    private Long conceptId;
+    private String libName;
+    private Integer conditionType;
+}

+ 5 - 115
src/main/java/com/diagbot/entity/KlDiagnoseCondition.java

@@ -2,6 +2,8 @@ package com.diagbot.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Getter;
+import lombok.Setter;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -14,6 +16,8 @@ import java.util.Date;
  * @author gaodm
  * @since 2021-03-15
  */
+@Getter
+@Setter
 public class KlDiagnoseCondition implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -77,119 +81,5 @@ public class KlDiagnoseCondition implements Serializable {
     /**
      * 基础规则id(condition_type为1:基础条件有效)
      */
-    private Long ruleBaseId;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public String getIsDeleted() {
-        return isDeleted;
-    }
-
-    public void setIsDeleted(String isDeleted) {
-        this.isDeleted = isDeleted;
-    }
-
-    public Date getGmtCreate() {
-        return gmtCreate;
-    }
-
-    public void setGmtCreate(Date gmtCreate) {
-        this.gmtCreate = gmtCreate;
-    }
-
-    public Date getGmtModified() {
-        return gmtModified;
-    }
-
-    public void setGmtModified(Date gmtModified) {
-        this.gmtModified = gmtModified;
-    }
-
-    public String getCreator() {
-        return creator;
-    }
-
-    public void setCreator(String creator) {
-        this.creator = creator;
-    }
-
-    public String getModifier() {
-        return modifier;
-    }
-
-    public void setModifier(String modifier) {
-        this.modifier = modifier;
-    }
-
-    public Long getDiagnoseId() {
-        return diagnoseId;
-    }
-
-    public void setDiagnoseId(Long diagnoseId) {
-        this.diagnoseId = diagnoseId;
-    }
-
-    public Integer getConditionType() {
-        return conditionType;
-    }
-
-    public void setConditionType(Integer conditionType) {
-        this.conditionType = conditionType;
-    }
-
-    public Integer getConditionGroup() {
-        return conditionGroup;
-    }
-
-    public void setConditionGroup(Integer conditionGroup) {
-        this.conditionGroup = conditionGroup;
-    }
-
-    public Integer getFitNo() {
-        return fitNo;
-    }
-
-    public void setFitNo(Integer fitNo) {
-        this.fitNo = fitNo;
-    }
-
-    public Integer getBaseGroup() {
-        return baseGroup;
-    }
-
-    public void setBaseGroup(Integer baseGroup) {
-        this.baseGroup = baseGroup;
-    }
-
-    public Long getRuleBaseId() {
-        return ruleBaseId;
-    }
-
-    public void setRuleBaseId(Long ruleBaseId) {
-        this.ruleBaseId = ruleBaseId;
-    }
-
-    @Override
-    public String toString() {
-        return "KlDiagnoseCondition{" +
-                "id=" + id +
-                ", isDeleted=" + isDeleted +
-                ", gmtCreate=" + gmtCreate +
-                ", gmtModified=" + gmtModified +
-                ", creator=" + creator +
-                ", modifier=" + modifier +
-                ", diagnoseId=" + diagnoseId +
-                ", conditionType=" + conditionType +
-                ", conditionGroup=" + conditionGroup +
-                ", fitNo=" + fitNo +
-                ", baseGroup=" + baseGroup +
-                ", ruleBaseId=" + ruleBaseId +
-                "}";
-    }
+    private Long diagnoseBaseId;
 }

+ 13 - 0
src/main/java/com/diagbot/facade/KlDiagnoseFacade.java

@@ -0,0 +1,13 @@
+package com.diagbot.facade;
+
+import com.diagbot.service.impl.KlDiagnoseServiceImpl;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/3/15 11:42
+ */
+@Component
+public class KlDiagnoseFacade extends KlDiagnoseServiceImpl {
+}

+ 6 - 1
src/main/java/com/diagbot/mapper/KlDiagnoseMapper.java

@@ -1,7 +1,11 @@
 package com.diagbot.mapper;
 
+import com.diagbot.dto.DiagnoseDTO;
 import com.diagbot.entity.KlDiagnose;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.vo.DiagnoseVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2021-03-15
  */
 public interface KlDiagnoseMapper extends BaseMapper<KlDiagnose> {
-
+    //根据匹配的基础规则ID获取确诊、拟诊、警惕的疾病
+    List<DiagnoseDTO> getDiagnoseByIds(DiagnoseVO diagnoseVO);
 }

+ 6 - 1
src/main/java/com/diagbot/service/KlDiagnoseService.java

@@ -1,7 +1,11 @@
 package com.diagbot.service;
 
+import com.diagbot.dto.DiagnoseDTO;
 import com.diagbot.entity.KlDiagnose;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.vo.DiagnoseVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2021-03-15
  */
 public interface KlDiagnoseService extends IService<KlDiagnose> {
-
+    //根据匹配的基础规则ID获取确诊、拟诊、警惕的疾病
+    List<DiagnoseDTO> getDiagnoseByIds(DiagnoseVO diagnoseVO);
 }

+ 8 - 1
src/main/java/com/diagbot/service/impl/KlDiagnoseServiceImpl.java

@@ -1,11 +1,15 @@
 package com.diagbot.service.impl;
 
+import com.diagbot.dto.DiagnoseDTO;
 import com.diagbot.entity.KlDiagnose;
 import com.diagbot.mapper.KlDiagnoseMapper;
 import com.diagbot.service.KlDiagnoseService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.vo.DiagnoseVO;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 诊断依据信息表 服务实现类
@@ -16,5 +20,8 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class KlDiagnoseServiceImpl extends ServiceImpl<KlDiagnoseMapper, KlDiagnose> implements KlDiagnoseService {
-
+    //根据匹配的基础规则ID获取确诊、拟诊、警惕的疾病
+    public List<DiagnoseDTO> getDiagnoseByIds(DiagnoseVO diagnoseVO){
+        return baseMapper.getDiagnoseByIds(diagnoseVO);
+    }
 }

+ 17 - 0
src/main/java/com/diagbot/vo/DiagnoseVO.java

@@ -0,0 +1,17 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/3/15 11:21
+ */
+@Getter
+@Setter
+public class DiagnoseVO {
+    private List<Long> ids;
+}

+ 1 - 1
src/main/resources/mapper/KlDiagnoseConditionMapper.xml

@@ -15,7 +15,7 @@
         <result column="condition_group" property="conditionGroup" />
         <result column="fit_no" property="fitNo" />
         <result column="base_group" property="baseGroup" />
-        <result column="rule_base_id" property="ruleBaseId" />
+        <result column="diagnose_base_id" property="diagnoseBaseId" />
     </resultMap>
 
 </mapper>

+ 98 - 10
src/main/resources/mapper/KlDiagnoseMapper.xml

@@ -1,18 +1,106 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.diagbot.mapper.KlDiagnoseMapper">
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.diagbot.entity.KlDiagnose">
-        <id column="id" property="id" />
-        <result column="is_deleted" property="isDeleted" />
-        <result column="gmt_create" property="gmtCreate" />
-        <result column="gmt_modified" property="gmtModified" />
-        <result column="creator" property="creator" />
-        <result column="modifier" property="modifier" />
-        <result column="concept_id" property="conceptId" />
-        <result column="description" property="description" />
-        <result column="status" property="status" />
+        <id column="id" property="id"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="gmt_create" property="gmtCreate"/>
+        <result column="gmt_modified" property="gmtModified"/>
+        <result column="creator" property="creator"/>
+        <result column="modifier" property="modifier"/>
+        <result column="concept_id" property="conceptId"/>
+        <result column="description" property="description"/>
+        <result column="status" property="status"/>
     </resultMap>
 
+    <select id="getDiagnoseByIds" resultType="com.diagbot.dto.DiagnoseDTO" parameterType="com.diagbot.vo.DiagnoseVO">
+        SELECT DISTINCT
+            t12.concept_id,
+            t12.lib_name,
+            t12.condition_type
+        FROM
+            (
+                SELECT DISTINCT
+                    t11.concept_id,
+                    t11.lib_name,
+                    t11.condition_type,
+                    t11.condition_group,
+                    (
+                        count(t11.condition_group) >= sum(baseGroupDiff)
+                    ) AS groupDiff
+                FROM
+                    (
+                        SELECT
+                            t3.*, IFNULL(0, t5.cnt) AS cnt,
+                            (
+                                t3.fit_no >= IFNULL(0, t5.cnt)
+                            ) AS baseGroupDiff
+                        FROM
+                            (
+                                SELECT
+                                    t1.concept_id,t2.*, c1.lib_name
+                                FROM
+                                    kl_diagnose t1,
+                                    kl_diagnose_condition t2,
+                                    kl_concept c1,
+                                    (
+                                        SELECT DISTINCT
+                                            t4.diagnose_id
+                                        FROM
+                                            `kl_diagnose_condition` t4
+                                        WHERE
+                                            t4.condition_type = 1
+                                        AND t4.is_deleted = "N"
+                                        <if test="ids != null and ids.size > 0">
+                                            and t4.diagnose_base_id in
+                                            <foreach item="id" collection="ids" open="(" separator="," close=")">
+                                                #{id}
+                                            </foreach>
+                                        </if>
+                                    ) t10
+                                WHERE
+                                    t1.is_deleted = "N"
+                                AND t1.`status` = 1
+                                AND t2.is_deleted = "N"
+                                AND t1.id = t2.diagnose_id
+                                AND t2.condition_type IN (2, 3, 4)
+                                AND c1.is_deleted = "N"
+                                AND c1.`status` = 1
+                                AND c1.id = t1.concept_id
+                                AND t1.id = t10.diagnose_id
+                            ) t3
+                        LEFT JOIN (
+                            SELECT
+                                t4.diagnose_id,
+                                t4.base_group,
+                                COUNT(t4.id) AS cnt
+                            FROM
+                                `kl_diagnose_condition` t4
+                            WHERE
+                                t4.condition_type = 1
+                            AND t4.is_deleted = "N"
+                            <if test="ids != null and ids.size > 0">
+                                and t4.diagnose_base_id in
+                                <foreach item="id" collection="ids" open="(" separator="," close=")">
+                                    #{id}
+                                </foreach>
+                            </if>
+                            GROUP BY
+                                t4.diagnose_id,
+                                t4.base_group
+                        ) t5 ON t3.diagnose_id = t5.diagnose_id
+                        AND t3.base_group = t5.base_group
+                    ) t11
+                GROUP BY
+                    t11.concept_id,
+                    t11.condition_type,
+                    t11.condition_group
+            ) t12
+        WHERE
+            t12.groupDiff = 1
+    </select>
+
 </mapper>