Sfoglia il codice sorgente

部位和症状的对应关系

zhoutg 6 anni fa
parent
commit
d7808ca2b5

+ 19 - 0
aipt-service/src/main/java/com/diagbot/dto/PartDTO.java

@@ -0,0 +1,19 @@
+package com.diagbot.dto;
+
+import com.diagbot.entity.Symptom;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description: 部位症状关联信息
+ * @Author: ztg
+ * @Date: 2018/10/24 16:11
+ */
+@Getter
+@Setter
+public class PartDTO extends ConceptBaseDTO{
+    private List<Symptom> symptomList = new ArrayList<>(); //症状列表
+}

+ 18 - 0
aipt-service/src/main/java/com/diagbot/dto/PartSymptomDTO.java

@@ -0,0 +1,18 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description: 部位症状关联信息
+ * @Author: ztg
+ * @Date: 2018/10/24 16:11
+ */
+@Getter
+@Setter
+public class PartSymptomDTO extends ConceptBaseDTO{
+    private List<PartDTO> partDTO = new ArrayList<>(); //部位信息
+}

+ 22 - 0
aipt-service/src/main/java/com/diagbot/entity/Symptom.java

@@ -0,0 +1,22 @@
+package com.diagbot.entity;
+
+import com.diagbot.dto.ConceptBaseDTO;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 症状信息扩展表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2018-09-17
+ */
+@Getter
+@Setter
+public class Symptom extends ConceptBaseDTO {
+
+    @JsonIgnore
+    private Long partConceptId;
+}

+ 7 - 0
aipt-service/src/main/java/com/diagbot/entity/wrapper/ConceptWrapper.java

@@ -3,6 +3,8 @@ package com.diagbot.entity.wrapper;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @Description: 概念查询参数
  * @author: gaodm
@@ -33,4 +35,9 @@ public class ConceptWrapper {
     private Integer endAge;
     //关系终点术语类型
     private Integer endType;
+    //关系起点术语名称列表
+    private List<String> startNameList;
+    //关系终点术语名称列表
+    private List<String> endNameList;
+
 }

+ 175 - 0
aipt-service/src/main/java/com/diagbot/facade/PartFacade.java

@@ -0,0 +1,175 @@
+package com.diagbot.facade;
+
+import com.diagbot.dto.ConceptWithOrderRes;
+import com.diagbot.dto.PartDTO;
+import com.diagbot.dto.PartSymptomDTO;
+import com.diagbot.entity.Symptom;
+import com.diagbot.entity.wrapper.ConceptWrapper;
+import com.diagbot.enums.LexiconRSTypeEnum;
+import com.diagbot.enums.LexiconTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.util.EntityUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.PartSymptomVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 部位facade
+ * @Author: ztg
+ * @Date: 2018/10/23 16:33
+ */
+@Component
+public class PartFacade {
+
+    @Autowired
+    ConceptFacade conceptFacade;
+
+    /**
+     * 根据已选部位返回对应的症状
+     *
+     * @param partSymptomVO 参数
+     * @return 部位症状关联信息
+     */
+    public List<PartSymptomDTO> getSymptomByPartName(PartSymptomVO partSymptomVO) {
+        List<String> partList = partSymptomVO.getPartList();
+        if (ListUtil.isEmpty(partList)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                    "请选择部位");
+        }
+        if (partSymptomVO.getSexType() == null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                    "请选择性别");
+        }
+        if (partSymptomVO.getAge() == null) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
+                    "请选择年龄");
+        }
+        if (partSymptomVO.getAge().intValue() < 0 || partSymptomVO.getAge().intValue() > 200) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
+                    "超出年龄范围【0 — 200】");
+        }
+        List<PartSymptomDTO> res = new ArrayList<>();
+
+        // 获取顶级部位信息
+        ConceptWrapper conceptWrapper = new ConceptWrapper();
+        conceptWrapper.setStartNameList(partList);
+        conceptWrapper.setStartType(LexiconTypeEnum.BODYPART.getKey());
+//        conceptWrapper.setEndNameList(partList);
+        conceptWrapper.setEndType(LexiconTypeEnum.BODYPART.getKey());
+        conceptWrapper.setEndSex(partSymptomVO.getSexType());
+        conceptWrapper.setEndAge(partSymptomVO.getAge());
+        List<ConceptWithOrderRes> list = conceptFacade.getConceptWithOrder(conceptWrapper);
+        for (String s : partList) {
+            PartSymptomDTO dto = new PartSymptomDTO();
+            dto.setName(s);
+            res.add(dto);
+        }
+        // 设置一级部位
+        for (PartSymptomDTO dto : res) {
+            for (ConceptWithOrderRes concept : list) {
+                if(dto.getName().equals(concept.getStartName()) && dto.getName().equals(concept.getEndName())) {
+                    dto.setConceptId(concept.getStartId());
+                    break;
+                }
+            }
+        }
+        List<String> secPart = new ArrayList<>();
+        // 设置二级部位
+        for (PartSymptomDTO dto : res) {
+            List<PartDTO> partDTO = new ArrayList<>();
+            for (ConceptWithOrderRes concept : list) {
+                if (dto.getName().equals(concept.getStartName())
+                        && !concept.getStartName().equals(concept.getEndName())) {
+                    PartDTO dto1 = new PartDTO();
+                    dto1.setName(concept.getEndName());
+                    dto1.setConceptId(concept.getEndId());
+                    secPart.add(concept.getEndName());
+                    partDTO.add(dto1);
+                }
+            }
+            dto.setPartDTO(partDTO);
+        }
+
+        // 获取二级部位信息
+        ConceptWrapper wrapper = new ConceptWrapper();
+        wrapper.setStartNameList(secPart);
+        wrapper.setStartType(LexiconTypeEnum.BODYPART.getKey());
+        wrapper.setRelationType(LexiconRSTypeEnum.ORDER_BY.getKey());
+        wrapper.setEndType(LexiconTypeEnum.SYMPTOM.getKey());
+        wrapper.setEndSex(partSymptomVO.getSexType());
+        wrapper.setEndAge(partSymptomVO.getAge());
+        List<ConceptWithOrderRes> sympton = conceptFacade.getConceptWithOrder(wrapper);
+
+        List<Symptom> symptomList = new ArrayList<>();
+        for(ConceptWithOrderRes conceptWithOrderRes : sympton) {
+            Symptom bean = new Symptom();
+            bean.setName(conceptWithOrderRes.getEndName());
+            bean.setConceptId(conceptWithOrderRes.getEndId());
+            bean.setPartConceptId(conceptWithOrderRes.getStartId());
+            symptomList.add(bean);
+        }
+        Map<Long, List<Symptom>> keyMap = EntityUtil.makeEntityListMap(symptomList, "partConceptId");
+
+        // 设置部位对应的症状
+        for (PartSymptomDTO dto : res) {
+            for (PartDTO partDTO : dto.getPartDTO()) {
+                if(keyMap.get(partDTO.getConceptId()) != null) {
+                    partDTO.setSymptomList(keyMap.get(partDTO.getConceptId()));
+                }
+            }
+        }
+
+        // 如二级部位无关联的症状,则删除二级部位
+
+        //添加默认部位-全身
+//        QueryWrapper wrapper = new QueryWrapper();
+//        wrapper.eq("name", "全身");
+//        Part part = this.getOne(wrapper);
+//        partIds.add(part.getId());
+//        Map paramMap = new HashMap<>();
+//        paramMap.put("ids", partIds);
+//        List<PartSymptomDTO> res = this.getByPartId(paramMap);
+//        List<PartDTO> partList = this.getByParentId(paramMap);
+//
+//        //添加二级部位信息
+//        Map<Long, List<PartDTO>> keyMap = EntityUtil.makeEntityListMap(partList, "parentId");
+//        for(PartSymptomDTO bean : res) {
+//            bean.setPartDTO(keyMap.get(bean.getId()));
+//        }
+//
+//        //添加部位和症状的关联信息
+//        List<Long> idList = new ArrayList<>();
+//        for(PartDTO bean : partList) {
+//            idList.add(bean.getId());
+//        }
+//        Map paramMap1 = new HashMap<>();
+//        paramMap1.put("ids", idList);
+//        paramMap1.put("sexType", partSymptomVO.getSexType());
+//        paramMap1.put("age", partSymptomVO.getAge());
+//        List<SymptomWrapper> symptomList = symptomFacade.getByPartIdsFac(paramMap1);
+//        Map<Long, List<SymptomWrapper>> partSymptomMap = EntityUtil.makeEntityListMap(symptomList, "partId");
+//        for(PartDTO bean : partList) {
+//            bean.setSymptomList(partSymptomMap.get(bean.getId()));
+//        }
+//
+//        // 如二级部位无关联的症状,删除二级部位
+//        for(int i = 0; i < res.size(); i++) {
+//            List<PartDTO> partDTO = res.get(i).getPartDTO();
+//            for(int j = 0; j < partDTO.size(); j++) {
+//                if(ListUtil.isEmpty(partDTO.get(j).getSymptomList())) {
+//                    partDTO.remove(j--);
+//                }
+//            }
+//        }
+//        return res;
+        return res;
+    }
+
+
+}

+ 34 - 0
aipt-service/src/main/java/com/diagbot/service/PartService.java

@@ -0,0 +1,34 @@
+//package com.diagbot.service;
+//
+//import com.baomidou.mybatisplus.extension.service.IService;
+//import com.diagbot.dto.PartDTO;
+//import com.diagbot.dto.PartSymptomDTO;
+//import com.diagbot.entity.Part;
+//
+//import java.util.List;
+//import java.util.Map;
+//
+///**
+// * @Description: 服务类
+// * @Author: ztg
+// * @Date: 2018/10/24 16:03
+// */
+//public interface PartService extends IService<Part> {
+//
+//    /**
+//     * 根据部位ids获取部位信息
+//     * @param map
+//     * @return
+//     */
+//    public List<PartSymptomDTO> getByPartId(Map map);
+//
+//    /**
+//     * 根据部位parentIds获取部位信息
+//     * @param map
+//     * @return
+//     */
+//    public List<PartDTO> getByParentId(Map map);
+//
+//
+//
+//}

+ 31 - 0
aipt-service/src/main/java/com/diagbot/service/impl/PartServiceImpl.java

@@ -0,0 +1,31 @@
+//package com.diagbot.service.impl;
+//
+//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+//import com.diagbot.dto.PartDTO;
+//import com.diagbot.dto.PartSymptomDTO;
+//import com.diagbot.entity.Part;
+//import com.diagbot.mapper.PartMapper;
+//import com.diagbot.service.PartService;
+//import org.springframework.stereotype.Service;
+//
+//import java.util.List;
+//import java.util.Map;
+//
+///**
+// * @Description: 服务实现类
+// * @Author: ztg
+// * @Date: 2018/10/24 16:02
+// */
+//@Service
+//public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements PartService {
+//
+//    @Override
+//    public List<PartSymptomDTO> getByPartId(Map map) {
+//        return baseMapper.getByPartId(map);
+//    }
+//
+//    @Override
+//    public List<PartDTO> getByParentId(Map map) {
+//        return baseMapper.getByParentId(map);
+//    }
+//}

+ 20 - 0
aipt-service/src/main/java/com/diagbot/vo/PartSymptomVO.java

@@ -0,0 +1,20 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description: 部位症状参数
+ * @Author: ztg
+ * @Date: 2018/10/10 13:17
+ */
+@Getter
+@Setter
+public class PartSymptomVO {
+
+    private List<String> partList;
+    private Integer sexType;
+    private Integer age;
+}

+ 43 - 0
aipt-service/src/main/java/com/diagbot/web/PartController.java

@@ -0,0 +1,43 @@
+package com.diagbot.web;
+
+
+import com.diagbot.dto.PartSymptomDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.PartFacade;
+import com.diagbot.vo.PartSymptomVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @Description: 分诊部位Controller
+ * @Author: ztg
+ * @Date: 2018/10/23 15:09
+ */
+@RestController
+@RequestMapping("/part")
+@Api(value = "部位API", tags = { "知识库标准化-部位API" })
+@SuppressWarnings("unchecked")
+public class PartController {
+
+    @Autowired
+    PartFacade partFacade;
+
+
+    @ApiOperation(value = "知识库标准化-根据已选部位返回对应的症状[by:zhoutg]",
+            notes = "partList: 部位列表,数组<br>" +
+                    "sexType:性别,1:男,2:女<br>" +
+                    "age:年龄")
+    @PostMapping("/getSymptomByPartName")
+    public RespDTO<List<PartSymptomDTO>> getSymptomByPartName(@RequestBody PartSymptomVO partSymptomVO) {
+        return RespDTO.onSuc(partFacade.getSymptomByPartName(partSymptomVO));
+    }
+
+}
+

+ 69 - 81
aipt-service/src/main/resources/mapper/ConceptMapper.xml

@@ -25,48 +25,10 @@
             `kl_concept` t1,
             `kl_relation` t2,
             <if test="startSex != null or startAge != null">
-                (
-                SELECT
-                concept_id
-                FROM
-                kl_concept_common
-                WHERE
-                is_deleted = 'N'
-                <if test="startSex != null">
-                    <if test="startSex == 3">
-                        and sex_type in ('1','2','3')
-                    </if>
-                    <if test="startSex != 3">
-                        and sex_type in ('3',#{startSex})
-                    </if>
-                </if>
-                <if test="startAge != null">
-                    <![CDATA[ AND min_age <= #{startAge} ]]>
-                    <![CDATA[ AND max_age >= #{startAge} ]]>
-                </if>
-                ) c1,
+                kl_concept_common c1,
             </if>
             <if test="endSex != null or endAge != null">
-                (
-                SELECT
-                concept_id
-                FROM
-                kl_concept_common
-                WHERE
-                is_deleted = 'N'
-                <if test="endSex != null">
-                    <if test="endSex == 3">
-                        and sex_type in ('1','2','3')
-                    </if>
-                    <if test="endSex != 3">
-                        and sex_type in ('3',#{endSex})
-                    </if>
-                </if>
-                <if test="endAge != null">
-                    <![CDATA[ AND min_age <= #{endAge} ]]>
-                    <![CDATA[ AND max_age >= #{endAge} ]]>
-                </if>
-                ) c2,
+                kl_concept_common c2,
             </if>
             `kl_concept` t3
         WHERE
@@ -82,6 +44,19 @@
             AND t1.lib_name = #{startName}
         </if>
         <if test="startSex != null or startAge != null">
+            AND c1.is_deleted = 'N'
+            <if test="startSex != null">
+                <if test="startSex == 3">
+                    and c1.sex_type in ('1','2','3')
+                </if>
+                <if test="startSex != 3">
+                    and c1.sex_type in ('3',#{startSex})
+                </if>
+            </if>
+            <if test="startAge != null">
+                <![CDATA[ AND c1.min_age <= #{startAge} ]]>
+                <![CDATA[ AND c1.max_age >= #{startAge} ]]>
+            </if>
             AND t2.start_id = c1.concept_id
         </if>
         <if test="startType != null">
@@ -97,6 +72,19 @@
             AND t3.lib_name = #{endName}
         </if>
         <if test="endSex != null or endAge != null">
+            AND c2.is_deleted = 'N'
+            <if test="endSex != null">
+                <if test="endSex == 3">
+                    and c2.sex_type in ('1','2','3')
+                </if>
+                <if test="endSex != 3">
+                    and c2.sex_type in ('3',#{endSex})
+                </if>
+            </if>
+            <if test="endAge != null">
+                <![CDATA[ AND c2.min_age <= #{endAge} ]]>
+                <![CDATA[ AND c2.max_age >= #{endAge} ]]>
+            </if>
             AND t2.end_id = c2.concept_id
         </if>
         <if test="endType != null">
@@ -115,53 +103,15 @@
             `kl_concept` t1,
             `kl_relation` t2,
             <if test="startSex != null or startAge != null">
-                (
-                SELECT
-                concept_id
-                FROM
-                kl_concept_common
-                WHERE
-                is_deleted = 'N'
-                <if test="startSex != null">
-                    <if test="startSex == 3">
-                        and sex_type in ('1','2','3')
-                    </if>
-                    <if test="startSex != 3">
-                        and sex_type in ('3',#{startSex})
-                    </if>
-                </if>
-                <if test="startAge != null">
-                    <![CDATA[ AND min_age <= #{startAge} ]]>
-                    <![CDATA[ AND max_age >= #{startAge} ]]>
-                </if>
-                ) c1,
+                kl_concept_common c1,
             </if>
             <if test="endSex != null or endAge != null">
-                (
-                SELECT
-                concept_id
-                FROM
-                kl_concept_common
-                WHERE
-                is_deleted = 'N'
-                <if test="endSex != null">
-                    <if test="endSex == 3">
-                        and sex_type in ('1','2','3')
-                    </if>
-                    <if test="endSex != 3">
-                        and sex_type in ('3',#{endSex})
-                    </if>
-                </if>
-                <if test="endAge != null">
-                    <![CDATA[ AND min_age <= #{endAge} ]]>
-                    <![CDATA[ AND max_age >= #{endAge} ]]>
-                </if>
-                ) c2,
+                kl_concept_common c2,
             </if>
             `kl_concept` t3,
             `kl_relation_order` t4
         WHERE
-            t1.is_deleted = 'N'
+        t1.is_deleted = 'N'
         AND t2.is_deleted = 'N'
         AND t3.is_deleted = 'N'
         AND t4.is_deleted = 'N'
@@ -175,8 +125,27 @@
             AND t1.lib_name = #{startName}
         </if>
         <if test="startSex != null or startAge != null">
+            AND c1.is_deleted = 'N'
+            <if test="startSex != null">
+                <if test="startSex == 3">
+                    and c1.sex_type in ('1','2','3')
+                </if>
+                <if test="startSex != 3">
+                    and c1.sex_type in ('3',#{startSex})
+                </if>
+            </if>
+            <if test="startAge != null">
+                <![CDATA[ AND c1.min_age <= #{startAge} ]]>
+                <![CDATA[ AND c1.max_age >= #{startAge} ]]>
+            </if>
             AND t2.start_id = c1.concept_id
         </if>
+        <if test="startNameList != null and startNameList.size() > 0">
+            AND t1.lib_name in
+            <foreach collection="startNameList" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="startType != null">
             AND t1.lib_type = #{startType}
         </if>
@@ -190,8 +159,27 @@
             AND t3.lib_name = #{endName}
         </if>
         <if test="endSex != null or endAge != null">
+            AND c2.is_deleted = 'N'
+            <if test="endSex != null">
+                <if test="endSex == 3">
+                    and c2.sex_type in ('1','2','3')
+                </if>
+                <if test="endSex != 3">
+                    and c2.sex_type in ('3',#{endSex})
+                </if>
+            </if>
+            <if test="endAge != null">
+                <![CDATA[ AND c2.min_age <= #{endAge} ]]>
+                <![CDATA[ AND c2.max_age >= #{endAge} ]]>
+            </if>
             AND t2.end_id = c2.concept_id
         </if>
+        <if test="endNameList != null and endNameList.size() > 0">
+            AND t3.lib_name in
+            <foreach collection="endNameList" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="endType != null">
             AND t3.lib_type = #{endType}
         </if>