Selaa lähdekoodia

智能分诊获取部位下的症状信息

zhoutg 6 vuotta sitten
vanhempi
commit
d5c31cf597

+ 2 - 1
aipt-service/src/main/java/com/diagbot/enums/LexiconTypeEnum.java

@@ -59,7 +59,8 @@ public enum LexiconTypeEnum implements KeyedNamed {
     GAUGE(48,"量表"),
     SIDE_EFFECTS(49,"不良反应"),
     CORE_INDICATORS(50,"核心指标"),
-    TYPES_OF_DISEASE(51,"疾病类型(慢病|急诊)");
+    TYPES_OF_DISEASE(51,"疾病类型(慢病|急诊)"),
+    PART_AREA(52,"部位区域");
 
     @Setter
     private Integer key;

+ 56 - 55
aipt-service/src/main/java/com/diagbot/facade/PartFacade.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.ConceptWithOrderRes;
 import com.diagbot.dto.PartDTO;
 import com.diagbot.dto.PartSymptomDTO;
+import com.diagbot.entity.Concept;
 import com.diagbot.entity.ConceptDetail;
 import com.diagbot.entity.Symptom;
 import com.diagbot.entity.wrapper.ConceptWrapper;
@@ -62,99 +63,99 @@ public class PartFacade {
         }
         List<PartSymptomDTO> res = new ArrayList<>();
 
+        // 获取部位区域
+        List<Concept> conceptList = conceptFacade.list(new QueryWrapper<Concept>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("lib_type", LexiconTypeEnum.PART_AREA.getKey())
+                .in("lib_name", partList)
+        );
+
+        // 设置部位区域
+        for (Concept c : conceptList) {
+            PartSymptomDTO partSymptomDTO = new PartSymptomDTO();
+            partSymptomDTO.setConceptId(c.getId());
+            partSymptomDTO.setName(c.getLibName());
+            res.add(partSymptomDTO);
+        }
+
         // 获取部位信息
         ConceptWrapper conceptWrapper = new ConceptWrapper();
         conceptWrapper.setStartNameList(partList);
-        conceptWrapper.setStartType(LexiconTypeEnum.BODYPART.getKey());
+        conceptWrapper.setStartType(LexiconTypeEnum.PART_AREA.getKey());
         conceptWrapper.setRelationType(LexiconRSTypeEnum.ORDER_BY.getKey());
         conceptWrapper.setEndType(LexiconTypeEnum.BODYPART.getKey());
         conceptWrapper.setEndSex(partSymptomVO.getSexType());
         conceptWrapper.setEndAge(partSymptomVO.getAge());
         List<ConceptWithOrderRes> list = conceptFacade.getConceptWithOrder(conceptWrapper);
-        // 设置一级部位
-        for (ConceptWithOrderRes concept : list) {
-            if (concept.getStartId().equals(concept.getEndId())) { //startId 和 endId相同标识一级部位
-                PartSymptomDTO dto = new PartSymptomDTO();
-                dto.setName(concept.getStartName());
-                dto.setConceptId(concept.getStartId());
-                res.add(dto);
-            }
-        }
 
-        // 设置二级部位
-        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);
+        Map<Long, List<ConceptWithOrderRes>> partMap = EntityUtil.makeEntityListMap(list, "startId");
+        // 设置部位区域下的部位
+        for (PartSymptomDTO partSymptomDTO : res) {
+            List<ConceptWithOrderRes> part = partMap.get(partSymptomDTO.getConceptId());
+            if (ListUtil.isNotEmpty(part)) {
+                List<PartDTO> partDTOS = new ArrayList<>();
+                for (ConceptWithOrderRes conceptWithOrderRes : part) {
+                    PartDTO partDTO = new PartDTO();
+                    partDTO.setName(conceptWithOrderRes.getEndName());
+                    partDTO.setConceptId(conceptWithOrderRes.getEndId());
+                    partDTOS.add(partDTO);
                 }
+                partSymptomDTO.setPartDTO(partDTOS);
             }
-            dto.setPartDTO(partDTO);
         }
 
-        // 获取二级部位下症状信息
+        // 获取部位下症状
         ConceptWrapper wrapper = new ConceptWrapper();
-        wrapper.setStartNameList(secPart);
+        wrapper.setStartNameList(list.stream().map(r -> r.getEndName()).distinct().collect(Collectors.toList()));
         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);
-        }
+        List<ConceptWithOrderRes> symptomList = conceptFacade.getConceptWithOrder(wrapper);
+        Map<Long, List<ConceptWithOrderRes>> symptomMap = EntityUtil.makeEntityListMap(symptomList, "startId");
 
-        // 添加症状的简述信息
+        // 获取症状的简述信息
         List<ConceptDetail> conceptDetailList = conceptDetailFacade.list(
                 new QueryWrapper<ConceptDetail>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .in("concept_id", symptomList.stream().map(row -> row.getConceptId()).distinct().collect(Collectors.toList()))
+                .in("concept_id", symptomList.stream().map(row -> row.getEndId()).distinct().collect(Collectors.toList()))
                 .apply("find_in_set({0},position)", 7));
-        Map<Long, String> map = conceptDetailList.stream().collect(Collectors.toMap(row->row.getConceptId(), row->row.getText()));
-        System.out.println(list);
-        for (Symptom symptom : symptomList) {
-            if (map.get(symptom.getConceptId()) != null) {
-                symptom.setDesc(map.get(symptom.getConceptId()));
-            }
-        }
+        Map<Long, String> descMap = conceptDetailList.stream().collect(Collectors.toMap(row->row.getConceptId(), row->row.getText()));
 
-        Map<Long, List<Symptom>> keyMap = EntityUtil.makeEntityListMap(symptomList, "partConceptId");
 
-        // 设置二级部位对应的症状
-        for (PartSymptomDTO dto : res) {
-            for (PartDTO partDTO : dto.getPartDTO()) {
-                if (keyMap.get(partDTO.getConceptId()) != null) { // 去除null数据
-                    partDTO.setSymptomList(keyMap.get(partDTO.getConceptId()));
+        // 设置部位下的症状
+        for (PartSymptomDTO partSymptomDTO : res) {
+            List<PartDTO> partDTOS = partSymptomDTO.getPartDTO();
+            for (PartDTO partDTO : partDTOS) {
+                List<ConceptWithOrderRes> symptom = symptomMap.get(partDTO.getConceptId());
+                if (ListUtil.isNotEmpty(symptom)) {
+                    List<Symptom> symptoms = new ArrayList<>();
+                    for (ConceptWithOrderRes conceptWithOrderRes : symptom) {
+                        Symptom bean = new Symptom();
+                        bean.setConceptId(conceptWithOrderRes.getEndId());
+                        bean.setName(conceptWithOrderRes.getEndName());
+                        bean.setPartConceptId(conceptWithOrderRes.getStartId());
+                        if (descMap.get(conceptWithOrderRes.getEndId()) != null) {
+                            bean.setDesc(descMap.get(conceptWithOrderRes.getEndId()));
+                        }
+                        symptoms.add(bean);
+                    }
+                    partDTO.setSymptomList(symptoms);
                 }
             }
         }
 
-        // 如二级部位无关联的症状,则删除二级部位
+        // 如部位无关联的症状,则删除部位
         for (PartSymptomDTO dto : res) {
             for (int i = 0; i < dto.getPartDTO().size(); i++) {
                 PartDTO partDTO = dto.getPartDTO().get(i);
-                if (keyMap.get(partDTO.getConceptId()) != null) { // 去除null数据
-                    partDTO.setSymptomList(keyMap.get(partDTO.getConceptId()));
-                }
                 if (ListUtil.isEmpty(partDTO.getSymptomList())) {
                     dto.getPartDTO().remove(i--);
                 }
             }
         }
+
         return res;
     }
 

+ 2 - 1
knowledgeman-service/src/main/java/com/diagbot/enums/LexiconTypeEnum.java

@@ -59,7 +59,8 @@ public enum LexiconTypeEnum implements KeyedNamed {
     GAUGE(48,"量表"),
     SIDE_EFFECTS(49,"不良反应"),
     CORE_INDICATORS(50,"核心指标"),
-    TYPES_OF_DISEASE(51,"疾病类型(慢病|急诊)");
+    TYPES_OF_DISEASE(51,"疾病类型(慢病|急诊)"),
+    PART_AREA(52,"部位区域");
 
     @Setter
     private Integer key;

+ 1 - 1
triage-service/src/main/java/com/diagbot/enums/FixPartEnum.java

@@ -9,7 +9,7 @@ import lombok.Setter;
  * @date 2018年11月21日 下午2:31:42
  */
 public enum FixPartEnum {
-    PART("全身");
+    PART("全身区域");
 
     @Setter
     private String partName;

+ 1 - 1
triage-service/src/main/java/com/diagbot/web/PartController.java

@@ -30,7 +30,7 @@ public class PartController {
     PartFacade partFacade;
 
 
-    @ApiOperation(value = "知识库标准化-根据已选部位返回对应的症状[by:zhoutg]",
+    @ApiOperation(value = "知识库标准化-根据已选部位区域返回对应的症状[by:zhoutg]",
             notes = "partIds: 部位列表,数组<br>" +
                     "sexType:性别,1:男,2:女<br>" +
                     "age:年龄")