Przeglądaj źródła

Merge branch 'dev/KLBstand' into dev/precSR

gaodm 6 lat temu
rodzic
commit
f955d5d822

+ 4 - 4
aipt-service/src/main/java/com/diagbot/client/NLPServiceClient.java

@@ -2,12 +2,12 @@ package com.diagbot.client;
 
 import com.diagbot.client.bean.Response;
 import com.diagbot.client.hystrix.NLPServiceHystrix;
+import com.diagbot.dto.FeatureConceptDTO;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description:调用NLP对接层服务
@@ -22,6 +22,6 @@ public interface NLPServiceClient {
      * @param text
      * @return
      */
-    @PostMapping(value = "/nlp-web/feature/find_symptom_feature")
-    Response<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text);
+    @GetMapping(value = "/nlp-web/feature/find_symptom_feature")
+    Response<List<FeatureConceptDTO>> symptomFeaturePageData(@RequestParam("text") String text);
 }

+ 2 - 2
aipt-service/src/main/java/com/diagbot/client/hystrix/NLPServiceHystrix.java

@@ -2,12 +2,12 @@ package com.diagbot.client.hystrix;
 
 import com.diagbot.client.NLPServiceClient;
 import com.diagbot.client.bean.Response;
+import com.diagbot.dto.FeatureConceptDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description:调用NLP对接层服务
@@ -25,7 +25,7 @@ public class NLPServiceHystrix implements NLPServiceClient {
      * @return
      */
     @Override
-    public Response<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text) {
+    public Response<List<FeatureConceptDTO>> symptomFeaturePageData(@RequestParam("text") String text) {
         log.error("【hystrix】调用{}异常", "symptomFeaturePageData");
         return null;
     }

+ 1 - 0
aipt-service/src/main/java/com/diagbot/dto/FeatureConceptDTO.java

@@ -13,4 +13,5 @@ import lombok.Setter;
 public class FeatureConceptDTO extends ConceptBaseDTO {
     private Integer libType;
     private Integer type;
+    private Integer chronicLabel; //是否慢病复诊标志
 }

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

@@ -60,7 +60,24 @@ public enum LexiconTypeEnum implements KeyedNamed {
     SIDE_EFFECTS(49,"不良反应"),
     CORE_INDICATORS(50,"核心指标"),
     TYPES_OF_DISEASE(51,"疾病类型(慢病|急诊)"),
-    PART_AREA(52,"部位区域");
+    PART_AREA(52,"部位区域"),
+    LOCATION_AREA(52,"部位区域"),
+    CHEMICAL_NAME_OF_DRUG(53,"药品化学名"),
+    DRUG_TRADE_NAMES(54,"药品商品名"),
+    HISTORY_OF_PAST_DISEASES(55,"既往疾病史"),
+    HISTORY_OF_TRAUMA(56,"外伤史"),
+    HISTORY_OF_SURGERY(57,"手术史"),
+    HISTORY_OF_BLOOD_TRANSFUSION(58,"输血史"),
+    INFECTIOUS_DISEASE_HISTORY(59,"传染病史"),
+    BAD_HABITS(60,"不良习惯"),
+    MARITAL_HISTORY(61,"冶游史"),
+    HISTORY_OF_MARRIAGE_AND_CHILDBEARING(62,"婚育史"),
+    BIRTH_HISTORY(63,"生育史"),
+    FAMILY_HISTORY(64,"家族史"),
+    FOOD_ALLERGY_HISTORY(65,"食物过敏史"),
+    HISTORY_OF_DRUG_ALLERGY(66,"药物过敏史"),
+    FAMILY_RELATED_INFECTIOUS_DISEASE_HISTORY(67,"家族相关传染病史");
+
 
     @Setter
     private Integer key;

+ 32 - 10
aipt-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -216,25 +216,47 @@ public class ConceptFacade extends ConceptServiceImpl {
     public List<ConceptRetrievalDTO> retrivelConceptInfo(RetrievalVO retrievalVO){
         List<Integer> typeList = new ArrayList<>();
         if (null != retrievalVO.getType()){
-            for (Integer type: retrievalVO.getType()) {
-                if(type.intValue() == ConceptTypeEnum.Lis.getKey()){//如果是化验,检索类型包括套餐和明细项
-                    typeList.add(LexiconTypeEnum.LIS_PACKAGE.getKey());
-                    typeList.add(LexiconTypeEnum.LIS_DETAILS.getKey());
-                } else{
-                    typeList.add(ParamConvertUtil.conceptConvert2Lib(type));//标签类型
-                }
+            if(retrievalVO.getType().intValue() == ConceptTypeEnum.Lis.getKey()){
+                retrievalVO.setDetilType(LexiconTypeEnum.LIS_DETAILS.getKey());
             }
-            retrievalVO.setType(typeList);
+            retrievalVO.setType(ParamConvertUtil.conceptConvert2Lib(retrievalVO.getType()));
         }
         List<ConceptRetrievalDTO> conceptRetrievalDTOS = this.retrievalConcept(retrievalVO);
+        List<ConceptRetrievalDTO> res = new ArrayList<>();
+        List<Long> selfList = new ArrayList<>(); // 本体
+        List<Long> subList = new ArrayList<>(); // 子项
+        for (ConceptRetrievalDTO bean : conceptRetrievalDTOS) {
+            if(StringUtil.isNotEmpty(bean.getParentName())) { // 重置showType
+                bean.setShowType(2L);
+            }
+            if (bean.getShowType().intValue() == 1) { // 本体
+                selfList.add(bean.getSelfId());
+            } else if (bean.getShowType().intValue() == 2) { // 子项
+                subList.add(bean.getSelfId());
+            }
+        }
+        // 有本体,过滤同义词和子项;无本体,有子项,过滤同义词
+        for (ConceptRetrievalDTO bean : conceptRetrievalDTOS) {
+            if(bean.getShowType().intValue() == 1) {
+                res.add(bean);
+            } else if (bean.getShowType().intValue() == 2) {
+                if(!selfList.contains(bean.getParentId())) {
+                    res.add(bean);
+                }
+            } else if (bean.getShowType().intValue() == 0) {
+                if(!selfList.contains(bean.getSelfId()) && !subList.contains(bean.getSelfId())) {
+                    res.add(bean);
+                }
+            }
+        }
         //把本体的sameName过滤掉
-        for (ConceptRetrievalDTO conceptRetrievalDTO : conceptRetrievalDTOS) {
+        for (ConceptRetrievalDTO conceptRetrievalDTO : res) {
             if(conceptRetrievalDTO.getSameName() != null && conceptRetrievalDTO.getSameName().equals(conceptRetrievalDTO.getSelfName())){
                 conceptRetrievalDTO.setSameName(null);
             }
             conceptRetrievalDTO.setType(ParamConvertUtil.libConvert2Concept(conceptRetrievalDTO.getLibTypeId().intValue()));
         }
-        return conceptRetrievalDTOS;
+        return res;
     }
 
 

+ 7 - 31
aipt-service/src/main/java/com/diagbot/facade/FeatureFacade.java

@@ -1,19 +1,14 @@
 package com.diagbot.facade;
 
 import com.diagbot.dto.FeatureConceptDTO;
-import com.diagbot.entity.Concept;
-import com.diagbot.enums.ConceptTypeEnum;
-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.google.common.collect.Lists;
+import com.diagbot.util.ParamConvertUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description:
@@ -24,8 +19,6 @@ import java.util.Map;
 public class FeatureFacade {
     @Autowired
     private NLPFacade nlpFacade;
-    @Autowired
-    private ConceptFacade conceptFacade;
 
     /**
      * 症状关键词提取
@@ -34,33 +27,16 @@ public class FeatureFacade {
      * @return
      */
     public List<FeatureConceptDTO> getSymptomFeature(String text) {
-        List<FeatureConceptDTO> symptomFeatureDTOList = Lists.newLinkedList();
-        List<Map<String, Object>> symptomFeatureList = nlpFacade.symptomFeaturePageData(text);
-        List<String> symptomNameList = Lists.newLinkedList();
-        for (Map<String, Object> symptomFeature : symptomFeatureList) {
-            if (symptomFeature != null) {
-                String symptomName = symptomFeature.get("feature_name").toString();
-                if (!symptomNameList.contains(symptomName) && symptomFeature.get("feature_type").toString().equals("1")) {
-                    symptomNameList.add(symptomName);
-                }
-            }
-        }
+        List<FeatureConceptDTO> symptomFeatureList = nlpFacade.symptomFeaturePageData(text);
         if (!ListUtil.isNotEmpty(symptomFeatureList)) {
             throw new CommonException(CommonErrorCode.NOT_EXISTS, "未提取到特征词");
         }
-        List<Concept> concepts = conceptFacade.getListByNamesAndType(symptomNameList, LexiconTypeEnum.SYMPTOM.getKey());
-        Map<String, Concept> conceptMap = EntityUtil.makeEntityMap(concepts, "libName");
-        for (String name : symptomNameList) {
-            FeatureConceptDTO featureConceptDTO = new FeatureConceptDTO();
-            featureConceptDTO.setName(name);
-            featureConceptDTO.setLibType(LexiconTypeEnum.SYMPTOM.getKey());
-            featureConceptDTO.setType(ConceptTypeEnum.Symptom.getKey());
-            if (conceptMap.containsKey(name) && conceptMap.get(name) != null) {
-                Concept concept = conceptMap.get(name);
-                featureConceptDTO.setConceptId(concept.getId());
+
+        for (FeatureConceptDTO featureConceptDTO : symptomFeatureList) {
+            if (null != featureConceptDTO.getLibType()) {
+                featureConceptDTO.setType(ParamConvertUtil.libConvert2Concept(featureConceptDTO.getLibType()));
             }
-            symptomFeatureDTOList.add(featureConceptDTO);
         }
-        return symptomFeatureDTOList;
+        return symptomFeatureList;
     }
 }

+ 4 - 4
aipt-service/src/main/java/com/diagbot/facade/NLPFacade.java

@@ -2,13 +2,13 @@ package com.diagbot.facade;
 
 import com.diagbot.client.NLPServiceClient;
 import com.diagbot.client.bean.Response;
+import com.diagbot.dto.FeatureConceptDTO;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description:
@@ -26,11 +26,11 @@ public class NLPFacade {
      * @param text
      * @return
      */
-    public List<Map<String, Object>> symptomFeaturePageData(String text) {
-        Response<List<Map<String, Object>>> response = nlpServiceClient.symptomFeaturePageData(text);
+    public List<FeatureConceptDTO> symptomFeaturePageData(String text) {
+        Response<List<FeatureConceptDTO>> response = nlpServiceClient.symptomFeaturePageData(text);
         if (response == null || response.getData() == null) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "NLP没有返回结果");
         }
         return response.getData();
     }
-}
+}

+ 3 - 1
aipt-service/src/main/java/com/diagbot/vo/RetrievalVO.java

@@ -14,11 +14,13 @@ import java.util.List;
 @Getter
 @Setter
 public class RetrievalVO {
-    private List<Integer> type;
+    private Integer type;
     private Integer age;
     @NotNull(message = "请输入症状")
     private String InputStr;
     private Integer sexType;
     //需要去重的id
     private List<Long> inputIds;
+    //获取子项时需要用到的type类型
+    private Integer detilType;
 }

+ 135 - 145
aipt-service/src/main/resources/mapper/ConceptMapper.xml

@@ -188,123 +188,6 @@
 
     <select id="retrievalConcept" resultType="com.diagbot.dto.ConceptRetrievalDTO">
         SELECT a1.* from (
-        SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
-        LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
-        LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
-        LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
-        LEFT JOIN kl_concept t5 on t5.id = t4.start_id
-        LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
-        WHERE
-        t1.is_deleted = 'N'
-        AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
-        AND t4.is_deleted = 'N'
-        AND t5.is_deleted = 'N'
-        AND t6.is_deleted = 'N'
-        AND t2.is_concept = 1
-        <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
-        </if>
-        <if test="sexType == 3">
-        and t3.sex_type in ('1','2','3')
-        </if>
-        <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
-        </if>
-        <if test="age != null and age != ''">
-        AND <![CDATA[ t3.min_age <= #{age} ]]>
-        AND <![CDATA[ t3.max_age >= #{age} ]]>
-        </if>
-        AND (t2.spell =  UPPER(#{InputStr}) OR t2.name =  #{InputStr})
-        <if test="inputIds != null and inputIds.size > 0">
-            and t1.id not in
-            <foreach item="id" collection="inputIds" open="(" separator="," close=")">
-                #{id}
-            </foreach>
-        </if>
-        AND t4.relation_id = 18
-        UNION
-        SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
-        LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
-        LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
-        LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
-        LEFT JOIN kl_concept t5 on t5.id = t4.start_id
-        LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
-        WHERE
-        t1.is_deleted = 'N'
-        AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
-        AND t4.is_deleted = 'N'
-        AND t5.is_deleted = 'N'
-        AND t6.is_deleted = 'N'
-        AND t2.is_concept = 1
-        <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
-        </if>
-        <if test="sexType == 3">
-            and t3.sex_type in ('1','2','3')
-        </if>
-        <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
-        </if>
-        <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
-        </if>
-        AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
-        <if test="inputIds != null and inputIds.size > 0">
-            and t1.id not in
-            <foreach item="id" collection="inputIds" open="(" separator="," close=")">
-                #{id}
-            </foreach>
-        </if>
-        AND t4.relation_id = 18
-        UNION
-        SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
-        LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
-        LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
-        LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
-        LEFT JOIN kl_concept t5 on t5.id = t4.start_id
-        LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
-        WHERE
-        t1.is_deleted = 'N'
-        AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
-        AND t4.is_deleted = 'N'
-        AND t5.is_deleted = 'N'
-        AND t6.is_deleted = 'N'
-        AND t2.is_concept = 1
-        <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
-        </if>
-        <if test="sexType == 3">
-            and t3.sex_type in ('1','2','3')
-        </if>
-        <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
-        </if>
-        <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
-        </if>
-        AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
-        <if test="inputIds != null and inputIds.size > 0">
-            and t1.id not in
-            <foreach item="id" collection="inputIds" open="(" separator="," close=")">
-                #{id}
-            </foreach>
-        </if>
-        AND t4.relation_id = 18
-        UNION
         SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
         LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
         LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
@@ -312,23 +195,20 @@
         WHERE
         t1.is_deleted = 'N'
         AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
         AND t6.is_deleted = 'N'
         <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
+            AND t1.lib_type = #{type}
         </if>
         <if test="sexType == 3">
-        and t3.sex_type in ('1','2','3')
+            and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
         </if>
         <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
+            and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
         </if>
         <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
+            AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>)
+            or (t3.min_age is null and t3.max_age is null))
         </if>
         <if test="inputIds != null and inputIds.size > 0">
             and t1.id not in
@@ -337,6 +217,7 @@
             </foreach>
         </if>
         AND (t2.spell =  UPPER(#{InputStr}) OR t2.name =  #{InputStr})
+        LIMIT 100
         UNION
         SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
         LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
@@ -345,23 +226,20 @@
         WHERE
         t1.is_deleted = 'N'
         AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
         AND t6.is_deleted = 'N'
         <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
+            AND t1.lib_type = #{type}
         </if>
         <if test="sexType == 3">
-            and t3.sex_type in ('1','2','3')
+            and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
         </if>
         <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
+            and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
         </if>
         <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
+            AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>)
+            or (t3.min_age is null and t3.max_age is null))
         </if>
         <if test="inputIds != null and inputIds.size > 0">
             and t1.id not in
@@ -370,6 +248,7 @@
             </foreach>
         </if>
         AND (t2.spell LIKE CONCAT( UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
+        LIMIT 100
         UNION
         SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
         LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
@@ -378,23 +257,20 @@
         WHERE
         t1.is_deleted = 'N'
         AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
         AND t6.is_deleted = 'N'
         <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
+            AND t1.lib_type = #{type}
         </if>
         <if test="sexType == 3">
-            and t3.sex_type in ('1','2','3')
+            and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
         </if>
         <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
+            and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
         </if>
         <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
+            AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>)
+            or (t3.min_age is null and t3.max_age is null))
         </if>
         <if test="inputIds != null and inputIds.size > 0">
             and t1.id not in
@@ -403,7 +279,121 @@
             </foreach>
         </if>
         AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
+        LIMIT 100
+        <if test="detilType != null and detilType != ''">
+            UNION
+            SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
+            LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
+            LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
+            LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
+            LEFT JOIN kl_concept t5 on t5.id = t4.start_id
+            LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
+            WHERE
+            t1.is_deleted = 'N'
+            AND t2.is_deleted = 'N'
+            AND t4.is_deleted = 'N'
+            AND t5.is_deleted = 'N'
+            AND t6.is_deleted = 'N'
+            AND t2.is_concept = 1
+            <if test="detilType != null">
+                AND t1.lib_type = #{detilType}
+            </if>
+            <if test="sexType == 3">
+                and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
+            </if>
+            <if test="sexType != 3">
+                and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
+            </if>
+            <if test="age != null and age != ''">
+                AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>)
+                or (t3.min_age is null and t3.max_age is null))
+            </if>
+            AND (t2.spell =  UPPER(#{InputStr}) OR t2.name =  #{InputStr})
+            <if test="inputIds != null and inputIds.size > 0">
+                and t1.id not in
+                <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+            AND t4.relation_id = 18
+            LIMIT 100
+            UNION
+            SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
+            LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
+            LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
+            LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
+            LEFT JOIN kl_concept t5 on t5.id = t4.start_id
+            LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
+            WHERE
+            t1.is_deleted = 'N'
+            AND t2.is_deleted = 'N'
+            AND t4.is_deleted = 'N'
+            AND t5.is_deleted = 'N'
+            AND t6.is_deleted = 'N'
+            AND t2.is_concept = 1
+            <if test="detilType != null">
+                AND t1.lib_type = #{detilType}
+            </if>
+            <if test="sexType == 3">
+                and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
+            </if>
+            <if test="sexType != 3">
+                and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
+            </if>
+            <if test="age != null and age != ''">
+                AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>)
+                or (t3.min_age is null and t3.max_age is null))
+            </if>
+            AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
+            <if test="inputIds != null and inputIds.size > 0">
+                and t1.id not in
+                <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+            AND t4.relation_id = 18
+            LIMIT 100
+            UNION
+            SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
+            LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
+            LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
+            LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
+            LEFT JOIN kl_concept t5 on t5.id = t4.start_id
+            LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
+            WHERE
+            t1.is_deleted = 'N'
+            AND t2.is_deleted = 'N'
+            AND t4.is_deleted = 'N'
+            AND t5.is_deleted = 'N'
+            AND t6.is_deleted = 'N'
+            AND t2.is_concept = 1
+            <if test="detilType != null">
+                AND t1.lib_type = #{detilType}
+            </if>
+            <if test="sexType == 3">
+                and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
+            </if>
+            <if test="sexType != 3">
+                and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
+            </if>
+            <if test="age != null and age != ''">
+                AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>)
+                or (t3.min_age is null and t3.max_age is null))
+            </if>
+            AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
+            <if test="inputIds != null and inputIds.size > 0">
+                and t1.id not in
+                <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+            AND t4.relation_id = 18
+            LIMIT 100
+        </if>
         ) a1
-        GROUP BY a1.selfId,a1.showType
+        LIMIT 100
     </select>
 </mapper>

+ 3 - 1
icss-service/src/main/java/com/diagbot/dto/FeatureConceptDTO.java

@@ -12,5 +12,7 @@ import lombok.Setter;
 @Setter
 public class FeatureConceptDTO extends ConceptBaseDTO {
     private Integer libType;
+    private Integer type;
     private Long id;
-}
+    private Integer chronicLabel;//是否慢病复诊标志
+}

+ 5 - 1
icss-service/src/main/java/com/diagbot/facade/FeatureFacade.java

@@ -39,7 +39,11 @@ public class FeatureFacade {
         RespDTO<List<FeatureConceptDTO>> res = aiptServiceClient.symptomFeature(text);
         RespDTOUtil.respNGDealCover(res, "AI没有返回结果");
         List<FeatureConceptDTO> symptomFeatureList = res.data;
-        symptomFeatureList = addQuestionId(symptomFeatureList, ConceptTypeEnum.Symptom.getKey());
+        if (ListUtil.isNotEmpty(symptomFeatureList)) {
+            if (!symptomFeatureList.get(0).getChronicLabel().equals(1)) {
+                symptomFeatureList = addQuestionId(symptomFeatureList, ConceptTypeEnum.Symptom.getKey());
+            }
+        }
         return symptomFeatureList;
     }
 

+ 11 - 0
icss-service/src/main/java/com/diagbot/facade/QuestionUsualFacade.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.QuestionUsualDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.QuestionTypeEnum;
 import com.diagbot.service.impl.QuestionUsualServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ListUtil;
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -75,6 +77,15 @@ public class QuestionUsualFacade extends QuestionUsualServiceImpl {
             }
             return questionUsualDTOList;
         }
+        //如何没有匹配到questionId就移除
+        Iterator<QuestionUsualDTO> questionUsualDTOIterator = questionUsualDTOList.iterator();
+        while (questionUsualDTOIterator.hasNext()){
+            if(questionUsualDTOIterator.next().getQuestionId() == null
+                    && questionUsualVO.getType().intValue() != QuestionTypeEnum.Pacs.getKey()
+                    && questionUsualVO.getType().intValue() != QuestionTypeEnum.Disease.getKey()){
+                questionUsualDTOIterator.remove();
+            }
+        }
         return questionUsualDTOList;
     }
 }

+ 17 - 2
icss-service/src/main/java/com/diagbot/facade/RetrievalFacade.java

@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -49,10 +50,12 @@ public class RetrievalFacade {
         List<String> questionNames = new ArrayList<>();
         if (ListUtil.isNotEmpty(conceptInfos.data)) {
             for (ConceptRetrievalDTO conceptRetrievalDTO : conceptInfos.data) {
-                if (!questionNames.contains(conceptRetrievalDTO.getSameName())) {
+                if (!questionNames.contains(conceptRetrievalDTO.getSameName())
+                        && conceptRetrievalDTO.getSelfName() != null) {
                     questionNames.add(conceptRetrievalDTO.getSelfName());
                 }
-                if (!questionNames.contains(conceptRetrievalDTO.getParentName())) {
+                if (!questionNames.contains(conceptRetrievalDTO.getParentName())
+                        && conceptRetrievalDTO.getParentName() != null) {
                     questionNames.add(conceptRetrievalDTO.getParentName());
                 }
             }
@@ -74,6 +77,7 @@ public class RetrievalFacade {
                     if(null != questionInfoMap.get(conceptRetrievalDTO.getParentName())){//如果匹配到就添加questionId
                         retrievalDTO.setQuestionId(questionInfoMap.get(conceptRetrievalDTO.getParentName()).getId());
                     }
+                    retrievalDTO.setConceptId(conceptRetrievalDTO.getParentId());
                     retrievalDTO.setName(conceptRetrievalDTO.getParentName());
                     retrievalDTO.setRetrievalName(conceptRetrievalDTO.getSelfName());
                 } else {//parent为空时说明没有子项返回本体id
@@ -91,6 +95,17 @@ public class RetrievalFacade {
                 retrievalDTOS.add(retrievalDTO);
             }
         }
+        //如何没有匹配到questionId就移除
+        Iterator<RetrievalDTO> retrievalDTOIterator = retrievalDTOS.iterator();
+        while (retrievalDTOIterator.hasNext()){
+            RetrievalDTO retrievalDTO = new RetrievalDTO();
+            retrievalDTO = retrievalDTOIterator.next();
+                if(retrievalDTO.getQuestionId() == null
+                        && retrievalDTO.getType().intValue() != QuestionTypeEnum.Pacs.getKey()
+                        && retrievalDTO.getType().intValue() != QuestionTypeEnum.Disease.getKey()){
+                        retrievalDTOIterator.remove();
+                }
+        }
         return retrievalDTOS;
     }
 

+ 1 - 1
icss-service/src/main/java/com/diagbot/vo/RetrievalVO.java

@@ -16,7 +16,7 @@ import java.util.List;
 public class RetrievalVO {
 
     @NotNull(message = "请输入标签类型")
-    private List<Integer> type;
+    private Integer type;
     @NotNull(message = "请输入病人年龄")
     private Integer age;
     @NotNull(message = "请输入症状")

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

@@ -60,7 +60,24 @@ public enum LexiconTypeEnum implements KeyedNamed {
     SIDE_EFFECTS(49,"不良反应"),
     CORE_INDICATORS(50,"核心指标"),
     TYPES_OF_DISEASE(51,"疾病类型(慢病|急诊)"),
-    PART_AREA(52,"部位区域");
+    PART_AREA(52,"部位区域"),
+    LOCATION_AREA(52,"部位区域"),
+    CHEMICAL_NAME_OF_DRUG(53,"药品化学名"),
+    DRUG_TRADE_NAMES(54,"药品商品名"),
+    HISTORY_OF_PAST_DISEASES(55,"既往疾病史"),
+    HISTORY_OF_TRAUMA(56,"外伤史"),
+    HISTORY_OF_SURGERY(57,"手术史"),
+    HISTORY_OF_BLOOD_TRANSFUSION(58,"输血史"),
+    INFECTIOUS_DISEASE_HISTORY(59,"传染病史"),
+    BAD_HABITS(60,"不良习惯"),
+    MARITAL_HISTORY(61,"冶游史"),
+    HISTORY_OF_MARRIAGE_AND_CHILDBEARING(62,"婚育史"),
+    BIRTH_HISTORY(63,"生育史"),
+    FAMILY_HISTORY(64,"家族史"),
+    FOOD_ALLERGY_HISTORY(65,"食物过敏史"),
+    HISTORY_OF_DRUG_ALLERGY(66,"药物过敏史"),
+    FAMILY_RELATED_INFECTIOUS_DISEASE_HISTORY(67,"家族相关传染病史");
+
 
     @Setter
     private Integer key;

+ 2 - 2
knowledgeman-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -203,9 +203,9 @@ public class ConceptFacade extends ConceptServiceImpl {
                 relationQe.in("start_id", conceptIdList);
                 relationQe.eq(getAllForRelationVO.getRelationConceptId() != null, "end_id", getAllForRelationVO.getRelationConceptId());
                 reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getStartId, Collectors.counting()));
-            } else {
+            } else if(getAllForRelationVO.getRelationConceptId() != null) {
                 relationQe.in("end_id", conceptIdList);
-                relationQe.eq(getAllForRelationVO.getRelationConceptId() != null, "start_id", getAllForRelationVO.getRelationConceptId());
+                relationQe.eq("start_id", getAllForRelationVO.getRelationConceptId());
                 reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getEndId, Collectors.counting()));
             }
         }

+ 2 - 2
knowledgeman-service/src/main/resources/mapper/RelationMapper.xml

@@ -102,7 +102,7 @@
 		WHERE b.id IS NULL <!-- AND c.id IS NULL AND d.id IS NULL -->) t1
 		JOIN kl_concept t2 ON t1.start_id=t2.id
 		JOIN kl_concept t3 ON t1.end_id=t3.id
-		JOIN kl_lexicon t4 ON t3.lib_type=t4.id
+		JOIN kl_lexicon t4 ON t2.lib_type=t4.id
 		where t2.is_deleted='N' AND t3.is_deleted='N' AND t4.is_deleted='N'
 		GROUP BY t2.id) tab
 		where 1=1
@@ -136,7 +136,7 @@
 		WHERE c.id IS NULL) t1
 		JOIN kl_concept t2 ON t1.start_id=t2.id
 		JOIN kl_concept t3 ON t1.end_id=t3.id
-		JOIN kl_lexicon t4 ON t3.lib_type=t4.id
+		JOIN kl_lexicon t4 ON t2.lib_type=t4.id
 		LEFT JOIN kl_relation_order t5 ON t1.id=t5.t_relation_id
 		where t2.is_deleted='N' AND t3.is_deleted='N' AND t4.is_deleted='N'
 		GROUP BY t2.id) tab