Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/dev/KLBstand' into dev/KLBstand

zhoutg 6 anni fa
parent
commit
c6fc3e5c82

+ 238 - 5
aipt-service/src/main/java/com/diagbot/facade/ClinicalFacade.java

@@ -7,29 +7,35 @@ import com.diagbot.client.bean.CalculateData;
 import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.Response;
 import com.diagbot.client.bean.ResponseData;
-import com.diagbot.dto.FeatureConceptDTO;
 import com.diagbot.dto.Lexeme;
 import com.diagbot.dto.LisResult;
 import com.diagbot.entity.ScaleContent;
-import com.diagbot.entity.SysLog;
 import com.diagbot.enums.ScaleTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.ScaleContentService;
-import com.diagbot.util.DateUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.SearchVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ResourceUtils;
 import org.springframework.web.bind.annotation.RequestBody;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
  * <p>
- *  数据处理业务层
+ * 数据处理业务层
  * </p>
  *
  * @author Mark Huang
@@ -60,8 +66,9 @@ public class ClinicalFacade {
      */
     public ResponseData processClinicalData(@RequestBody SearchVo searchVo) {
         SearchVo sData = searchVo;
-
+        Map<String, List<Map<String, String>>> standWord = getStandWord();
         Response<List<Lexeme>> resp = nlpServiceClient.split(sData.getSymptom());
+        addStandWord(resp.getData(), standWord, searchVo);
 
         sData.setLisArr(processLis(sData.getLisArr()));
 
@@ -180,4 +187,230 @@ public class ClinicalFacade {
         }
         return response;
     }
+
+    public SearchVo addStandWord(List<Lexeme> lexemes, Map<String, List<Map<String, String>>> standWords, SearchVo sData) {
+        List<Lexeme> feature = new ArrayList<>();
+        //收集分词结果中体征指标或体征指标值(数字)
+        for (int i = 0; i < lexemes.size(); i++) {
+            if (lexemes.get(i).getProperty().contains("33") || lexemes.get(i).getProperty().contains("28")
+                    || lexemes.get(i).getProperty().contains("2") || lexemes.get(i).getProperty().contains("9")
+                    ) {
+                feature.add(lexemes.get(i));
+            }
+        }
+        //根据收集到的分词结果把体征指标和对应体征指标值(数字)拼接
+        List<String> featureType = new ArrayList<>();
+        for (int i = 0; i < feature.size(); i++) {
+            if (i < feature.size() - 1) {
+                try {
+                    if (feature.get(i).getProperty().contains("33") && feature.get(i + 1).getProperty().contains("28")) {
+                        featureType.add(feature.get(i).getText() + "\t" + feature.get(i + 1).getText());
+                    }
+                } catch (NumberFormatException e) {
+                    e.printStackTrace();
+                    System.out.println(e.getMessage());
+                }
+            }
+            if (i < feature.size() - 2) {
+                try {
+                    if ((feature.get(i).getProperty().contains("33") && feature.get(i + 1).getProperty().contains("28")
+                            && feature.get(i + 2).getProperty().contains("2"))
+                            || (feature.get(i).getProperty().contains("33") && feature.get(i + 1).getProperty().contains("28")
+                            && feature.get(i + 1).getProperty().contains("9"))) {
+                        featureType.add(feature.get(i).getText() + "\t" + feature.get(i + 1).getText() + "\t"
+                                + feature.get(i + 2).getText());
+                    }
+                } catch (NumberFormatException e) {
+                    e.printStackTrace();
+                    System.out.println(e.getMessage());
+                }
+            }
+        }
+        //将标准词中体征指标值(数字)与分词结果中体征指标值(数字)比较
+        for (String f : featureType) {
+            String[] features = f.split("\t");
+            if (standWords.containsKey(features[0])) {
+                List<Map<String, String>> standWordList = standWords.get(features[0]);
+                for (Map<String, String> standWordMap : standWordList) {
+                    if (standWordMap.containsKey("op") && standWordMap.containsKey("unit")
+                            && standWordMap.containsKey("value")) {
+                        if (features.length == 2) {
+                            judgment(sData, features, features[0], standWordMap);
+                        } else {
+                            if (standWordMap.get("unit").equals(features[2])) {
+                                judgment(sData, features, features[0], standWordMap);
+                            }
+                        }
+                    } else if (standWordMap.containsKey("op") && standWordMap.containsKey("value")) {
+                        if (features.length == 2) {
+                            judgment(sData, features, features[0], standWordMap);
+                        }
+                    }
+                }
+            }
+        }
+        return sData;
+    }
+
+    //将标准词中体征指标值(数字)与分词结果中体征指标值(数字)比较
+    private void judgment(SearchVo sData, String[] features, String standWordKey, Map<String, String> standWordMap) {
+        if (standWordMap.get("op").contains(">=") || standWordMap.get("op").contains("≥")
+                || standWordMap.get("op").contains(">") || standWordMap.get("op").contains("大于")
+                || standWordMap.get("op").contains(">") || standWordMap.get("op").contains("大")) {
+            //单独处理  血压≥140/90mmHg   类似情况
+            if (features[1].contains("/")) {
+                if (standWordMap.get("value").contains("/")) {
+                    String[] feature = features[1].split("/");
+                    Integer featuresSBP = Integer.valueOf(feature[0]); //收缩压
+                    Integer featuresDBP = Integer.valueOf(feature[1]); //舒张压
+
+                    String[] values = standWordMap.get("value").split("/");
+                    Integer standWordSBP = Integer.valueOf(values[0]); //收缩压
+                    Integer standWordDBP = Integer.valueOf(values[1]); //舒张压
+                    if (featuresSBP > standWordSBP && featuresDBP > standWordDBP) {
+                        String standWord = standWordKey + standWordMap.get("op") + standWordMap.get("value") + standWordMap.get("unit") + "。";
+                        sData.setSymptom(sData.getSymptom() + standWord);
+                        System.out.println(sData.getSymptom());
+                    } else {
+                        return;
+                    }
+                } else {
+                    return;
+                }
+            } else {
+                String num = getNum(standWordMap.get("value"));
+                if (Double.valueOf(getNum(features[1])) > Double.valueOf(num)) {
+                    String standWord = standWordKey + standWordMap.get("op") + standWordMap.get("value") + standWordMap.get("unit") + "。";
+                    sData.setSymptom(sData.getSymptom() + standWord);
+                    System.out.println(sData.getSymptom());
+
+                }
+            }
+        } else if (standWordMap.get("op").contains("<=") || standWordMap.get("op").contains("≤")
+                || standWordMap.get("op").contains("<") || standWordMap.get("op").contains("小于")
+                || standWordMap.get("op").contains("<") || standWordMap.get("op").contains("少于")
+                || standWordMap.get("op").contains("小")) {
+            //单独处理  血压小于90/60mmHg   类似情况
+            if (standWordMap.get("value").contains("/")) {
+                if (features[1].contains("/")) {
+                    String[] feature = features[1].split("/");
+                    Integer featuresSBP = Integer.valueOf(feature[0]); //收缩压
+                    Integer featuresDBP = Integer.valueOf(feature[1]); //舒张压
+
+                    String[] values = standWordMap.get("value").split("/");
+                    Integer standWordSBP = Integer.valueOf(values[0]); //收缩压
+                    Integer standWordDBP = Integer.valueOf(values[1]); //舒张压
+                    if (featuresSBP < standWordSBP && featuresDBP < standWordDBP) {
+                        String standWord = standWordKey + standWordMap.get("op") + standWordMap.get("value") + standWordMap.get("unit") + "。";
+                        sData.setSymptom(sData.getSymptom() + standWord);
+                        System.out.println(sData.getSymptom());
+                    } else {
+                        return;
+                    }
+                } else {
+                    return;
+                }
+            } else {
+                String num = getNum(standWordMap.get("value"));
+                if (Double.valueOf(getNum(features[1])) < Double.valueOf(num)) {
+                    String standWord = standWordKey + standWordMap.get("op") + standWordMap.get("value") + standWordMap.get("unit") + "。";
+                    sData.setSymptom(sData.getSymptom() + standWord);
+                    System.out.println(sData.getSymptom());
+                }
+            }
+        }
+    }
+
+    private String getNum(String standWord) {
+        StringBuffer sb = new StringBuffer();
+        try {
+            for (String num : standWord.replaceAll("[^0-9]", ",").split(",")) {
+                if (num.length() > 0) {
+                    sb.append(num);
+                }
+            }
+        } catch (NumberFormatException e) {
+            e.printStackTrace();
+        }
+        return sb.toString();
+    }
+
+    private Map<String, List<Map<String, String>>> getStandWord() {
+        Map<String, List<Map<String, String>>> standWordObj = new HashMap<>();
+        List<List<Lexeme>> splitStandWords = new ArrayList<>();
+        List<Lexeme> data = null;
+        File file = null;
+        BufferedReader reader = null;
+        String line = "";
+        try {
+            file = ResourceUtils.getFile("classpath:standword.txt");
+            reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
+            while ((line = reader.readLine()) != null) {
+                data = nlpServiceClient.split(line).getData();
+                splitStandWords.add(data);
+                //                standWord.add(line);
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                reader.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        List<Map<String, String>> standWordObjValList = null;
+        Map<String, String> standWordObjVal = null;
+        for (List<Lexeme> splitStandWord : splitStandWords) {
+            standWordObjValList = new ArrayList<>();
+            standWordObjVal = new HashMap<>();
+            int i = 0;
+            String standWordObjKey = "";
+            for (Lexeme lexeme : splitStandWord) {
+                i++;
+                if ("\uFEFF".equals(lexeme.getText()) || lexeme.getText().length() <= 0) {
+                    continue;
+                }
+                if (lexeme.getProperty().contains("1") || lexeme.getProperty().contains("5")
+                        || lexeme.getProperty().contains("33")) {
+
+                    if (!standWordObj.containsKey(lexeme.getText())) {
+                        standWordObj.put(lexeme.getText(), standWordObjValList);
+                    } else {
+                        standWordObjKey = lexeme.getText();
+                    }
+                } else if (lexeme.getProperty().contains("44")) {
+
+                    if (standWordObjVal.containsKey("op")) {
+                        standWordObjVal.put("op", standWordObjVal.get("op") + "," + lexeme.getText());
+                    } else {
+                        standWordObjVal.put("op", lexeme.getText());
+                    }
+                } else if (lexeme.getProperty().contains("13") || lexeme.getProperty().contains("28")) {
+                    if (standWordObjVal.containsKey("value")) {
+                        standWordObjVal.put("value", standWordObjVal.get("value") + "," + lexeme.getText());
+                    } else {
+                        standWordObjVal.put("value", lexeme.getText());
+                    }
+                } else if (lexeme.getProperty().contains("2") || lexeme.getProperty().contains("9")) {
+                    if (standWordObjVal.containsKey("unit")) {
+                        standWordObjVal.put("unit", standWordObjVal.get("unit") + "," + lexeme.getText());
+                    } else {
+                        standWordObjVal.put("unit", lexeme.getText());
+                    }
+                }
+                if (splitStandWord.size() == i) {
+                    if (standWordObj.containsKey(standWordObjKey)) {
+                        standWordObj.get(standWordObjKey).add(standWordObjVal);
+                    } else {
+                        standWordObjValList.add(standWordObjVal);
+                    }
+                }
+            }
+        }
+        return standWordObj;
+    }
+
 }

+ 8 - 0
aipt-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -292,6 +292,14 @@ public class ConceptFacade extends ConceptServiceImpl {
         RetrievalVO retrievalVO = new RetrievalVO();
         RetrievalDTO retrievalDTO = new RetrievalDTO();
         BeanUtil.copyProperties(getStaticKnowledgeVO,retrievalVO);
+        List<Integer> types = new ArrayList<>();
+        for (Integer type : getStaticKnowledgeVO.getTypes()) {
+            types.add(ParamConvertUtil.conceptConvert2Lib(type));
+        }
+        //设置类型为诊断、药品、化验、辅检
+        retrievalVO.setOtherType(types);
+        //如果为化验时设置子项类型
+        retrievalVO.setDetilType(LexiconTypeEnum.LIS_DETAILS.getKey());
         //获取标签信息
         List<ConceptRetrievalDTO> conceptRetrievalDTOList = this.retrivelConceptInfo(retrievalVO);
         List<RetrievalDTO> staticRetrievalList = new ArrayList<>();

+ 2 - 0
aipt-service/src/main/java/com/diagbot/vo/GetStaticKnowledgeVO.java

@@ -17,4 +17,6 @@ public class GetStaticKnowledgeVO {
     private String InputStr;
     //需要去重的id
     private List<Long> inputIds;
+    //指定类型
+    private List<Integer> types;
 }

+ 51 - 0
aipt-service/src/main/resources/standword.txt

@@ -0,0 +1,51 @@
+排便少于每周3次
+布氏征阳性
+附件活动性包块
+收缩压≥140mmHg
+收缩压大于140mmHg
+舒张压≥90mmHg
+舒张压大于90mmHg
+血压大于140mmHg
+悬壅垂水肿
+腰/臀比例>0.85
+血压≥140/90mmHg
+胎体
+不规则阴道出血/阴道出血
+下腹肿块/腹块
+心率大于100次/分
+口咽黏膜弥漫性充血肿胀
+悬壅垂水肿
+悬壅垂水肿
+血压小于90/60mmHg
+胸痛持续时间大于10分钟
+悬壅垂水肿
+电解质检查
+肺功能检查
+淋巴结细胞学检查
+腹部彩超
+膝关节痛风石
+触觉语颤增强
+晨僵≥30分钟
+BMI小于21
+体重指数小于21
+右上腹部饱满
+胃脱落细胞学检查
+肢体活动受限
+DBP>90mmHg
+SBP>140mmHg
+收缩压>140mmHg
+舒张压>90mmHg
+血压>140/90mmHg
+心率>90次/分
+R>20次/分
+体温<36℃
+体温>38℃
+R≥24次/分钟
+呼吸频率大于24次/分钟
+Hachinski缺血积分<4分
+Hachinski评分<4分
+HIS缺血指数<4分
+HIS评分<4分
+关节僵硬<30min
+晨僵<30min
+肢体苍白

+ 15 - 0
icss-service/src/main/java/com/diagbot/dto/OrderRetrivevalDTO.java

@@ -0,0 +1,15 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2019/6/27 13:23
+ */
+@Getter
+@Setter
+public class OrderRetrivevalDTO extends RetrievalDTO {
+    private Integer orderNo;//排序号
+}

+ 31 - 8
icss-service/src/main/java/com/diagbot/facade/RetrievalFacade.java

@@ -3,15 +3,18 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.AiptServiceClient;
 import com.diagbot.dto.ConceptRetrievalDTO;
+import com.diagbot.dto.OrderRetrivevalDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.QuestionTypeEnum;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.GetStaticKnowledgeVO;
+import com.diagbot.vo.GetStaticVO;
 import com.diagbot.vo.RetrievalVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -112,20 +115,24 @@ public class RetrievalFacade {
     /**
      * 静态知识标签检索
      *
-     * @param getStaticKnowledgeVO
+     * @param getStaticVO
      * @return
      */
-    public List<RetrievalDTO> getStaticKnowledge(GetStaticKnowledgeVO getStaticKnowledgeVO){
+    public List<RetrievalDTO> getStaticKnowledge(GetStaticVO getStaticVO){
+        GetStaticKnowledgeVO getStaticKnowledgeVO = new GetStaticKnowledgeVO();
+        BeanUtil.copyProperties(getStaticVO,getStaticKnowledgeVO);
+        //标签类型
+        List<String> questionNames = new ArrayList<>();
+        List<Integer> typeList = new ArrayList<>();//规定标签类型,只取诊断,化验,辅检,药品类型
+        typeList.add(QuestionTypeEnum.Disease.getKey());
+        typeList.add(QuestionTypeEnum.Drug.getKey());
+        typeList.add(QuestionTypeEnum.Lis.getKey());
+        typeList.add(QuestionTypeEnum.Pacs.getKey());
+        getStaticKnowledgeVO.setTypes(typeList);
         //调用aipt-service获取有静态知识的标签
         RespDTO<List<RetrievalDTO>> retrievalDTOList = aiptServiceClient.getStaticKnowledge(getStaticKnowledgeVO);
         RespDTOUtil.respNGDeal(retrievalDTOList,"获取静态知识失败");
         if(ListUtil.isNotEmpty(retrievalDTOList.data)){
-            List<String> questionNames = new ArrayList<>();
-            List<Integer> typeList = new ArrayList<>();//规定标签类型,只取诊断,化验,辅检,药品类型
-            typeList.add(QuestionTypeEnum.Disease.getKey());
-            typeList.add(QuestionTypeEnum.Pacs.getKey());
-            typeList.add(QuestionTypeEnum.Lis.getKey());
-            typeList.add(QuestionTypeEnum.Drug.getKey());
             for (RetrievalDTO retrievalDTOInfo : retrievalDTOList.data) {
                 if(typeList.contains(retrievalDTOInfo.getType())){
                     questionNames.add(retrievalDTOInfo.getName());
@@ -146,6 +153,22 @@ public class RetrievalFacade {
                 }
             }
         }
+        List<OrderRetrivevalDTO> orderRetrivevalDTOS = BeanUtil.listCopyTo(retrievalDTOList.data,OrderRetrivevalDTO.class);
+        //设置排序编号
+        for (OrderRetrivevalDTO orderRetrivevalDTO : orderRetrivevalDTOS) {
+            if(orderRetrivevalDTO.getType().intValue() == QuestionTypeEnum.Disease.getKey()){//诊断
+                orderRetrivevalDTO.setOrderNo(1);
+            }else if(orderRetrivevalDTO.getType().intValue() == QuestionTypeEnum.Drug.getKey()){//药品
+                orderRetrivevalDTO.setOrderNo(2);
+            }else if(orderRetrivevalDTO.getType().intValue() == QuestionTypeEnum.Lis.getKey()){//化验
+                orderRetrivevalDTO.setOrderNo(3);
+            }else {//辅检
+                orderRetrivevalDTO.setOrderNo(4);
+            }
+        }
+        //给结果排序:诊断 > 药品 > 化验 > 辅检
+        orderRetrivevalDTOS.sort((OrderRetrivevalDTO o1, OrderRetrivevalDTO o2) -> o1.getOrderNo().compareTo(o2.getOrderNo()));
+        retrievalDTOList.data = BeanUtil.listCopyTo(orderRetrivevalDTOS,RetrievalDTO.class);
         return retrievalDTOList.data;
     }
 }

+ 2 - 0
icss-service/src/main/java/com/diagbot/vo/GetStaticKnowledgeVO.java

@@ -17,4 +17,6 @@ public class GetStaticKnowledgeVO {
     private String InputStr;
     //需要去重的id
     private List<Long> inputIds;
+    //指定类型
+    private List<Integer> types;
 }

+ 20 - 0
icss-service/src/main/java/com/diagbot/vo/GetStaticVO.java

@@ -0,0 +1,20 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2019/6/27 13:35
+ */
+@Getter
+@Setter
+public class GetStaticVO {
+    //检索内容
+    private String InputStr;
+    //需要去重的id
+    private List<Long> inputIds;
+}

+ 3 - 3
icss-service/src/main/java/com/diagbot/web/RetrievalController.java

@@ -5,7 +5,7 @@ import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.facade.RetrievalFacade;
-import com.diagbot.vo.GetStaticKnowledgeVO;
+import com.diagbot.vo.GetStaticVO;
 import com.diagbot.vo.RetrievalVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -54,8 +54,8 @@ public class RetrievalController {
                     "inputIds:需要去重的id<br>")
     @PostMapping("/getStaticKnowledge")
     @SysLogger("getStaticKnowledge")
-    public RespDTO<List<RetrievalDTO>> getStaticKnowledge(@Valid @RequestBody GetStaticKnowledgeVO getStaticKnowledgeVO) {
-        List<RetrievalDTO> data = retrievalFacade.getStaticKnowledge(getStaticKnowledgeVO);
+    public RespDTO<List<RetrievalDTO>> getStaticKnowledge(@Valid @RequestBody GetStaticVO getStaticVO) {
+        List<RetrievalDTO> data = retrievalFacade.getStaticKnowledge(getStaticVO);
         return RespDTO.onSuc(data);
     }
 }