Sfoglia il codice sorgente

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

wangyu 6 anni fa
parent
commit
6ea0fd9aab

+ 239 - 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, sData);
 
         sData.setLisArr(processLis(sData.getLisArr()));
 
@@ -180,4 +187,231 @@ 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 + 2).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();
+            System.out.println(e.getMessage()+ "不是标准数字");
+        }
+        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;
+    }
+
 }

+ 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
+肢体苍白

+ 7 - 1
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -316,7 +316,13 @@ public class PushFacade {
     public List<ConceptPushDTO> addQuestionId(List<ConceptPushDTO> concepts, Integer type) {
         QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
         List<String> nameList = concepts.stream().map(concept -> concept.getName()).collect(Collectors.toList());
-        questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).in("tag_name", nameList).eq("type", type);
+        questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).eq("type", type);
+        //化验填写单匹配name
+        if (type.equals(ConceptTypeEnum.Lis.getKey())) {
+            questionInfoQueryWrapper.in("name", nameList);
+        } else {
+            questionInfoQueryWrapper.in("tag_name", nameList);
+        }
         List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
         if (ListUtil.isNotEmpty(questionInfoList)) {
             Map<String, QuestionInfo> questionInfoMap = EntityUtil.makeEntityMap(questionInfoList, "tagName");

+ 25 - 0
icssman-service/src/main/java/com/diagbot/facade/QuestionFacade.java

@@ -466,6 +466,31 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
             paramMap.put("ids", Arrays.asList(ids.split(",")));
             paramMap.put("gmtModified", now);
             paramMap.put("modifier", person);
+
+            // 映射关系删除校验,如果有父项关联,不能删除
+            List<QuestionInfo> questionInfoList = getParentQuestion(Long.parseLong(id));
+            for (QuestionInfo questionInfo : questionInfoList) {
+                if (questionInfo.getTagType().equals(TagTypeEnum.T10.getKey())) {
+
+                }
+            }
+            if (ListUtil.isNotEmpty(questionInfoList)) {
+                StringBuffer sb = new StringBuffer();
+                sb.append("请先删除上级关联:");
+                for (QuestionInfo ques : questionInfoList) {
+                    if (ques.getTagType().equals(TagTypeEnum.T10.getKey())) {  // 既往史下特殊类型
+                        List<QuestionInfo> question2 = getParentQuestion(ques.getId());
+                        if (ListUtil.isNotEmpty(question2)) {
+                            sb.append("【" + question2.get(0).getTagName() + "】"); // 有且只有一个
+                        }
+                    } else {
+                        sb.append("【" + ques.getTagName() + "】");
+                    }
+                }
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                        sb.toString());
+            }
+
             //删除自身
             this.deleteByIds(paramMap);
             //删除明细