浏览代码

Merge branch 'dev/tipsnew_20211019' into dev/log_20211020

gaodm 3 年之前
父节点
当前提交
90d59882f8

+ 3 - 1
src/main/java/com/diagbot/enums/RegularConfigEnum.java

@@ -11,7 +11,9 @@ import lombok.Setter;
 public enum RegularConfigEnum implements KeyedNamed {
     lis(1, "化验"),
     allergy(2, "过敏源"),
-    pacs(3, "辅检");
+    pacs(3, "辅检"),
+    vital(4, "体征"),
+    ;
 
     @Setter
     private int key;

+ 119 - 18
src/main/java/com/diagbot/facade/KlRegularConfigFacade.java

@@ -3,7 +3,6 @@ package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.biz.push.entity.Lis;
-import com.diagbot.biz.push.entity.Pacs;
 import com.diagbot.dto.RegularValueDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.entity.KlRegularConfig;
@@ -14,8 +13,10 @@ import com.diagbot.exception.CommonException;
 import com.diagbot.model.entity.AllergyMedicine;
 import com.diagbot.model.entity.PD;
 import com.diagbot.model.entity.PacsNum;
+import com.diagbot.model.entity.Vital;
 import com.diagbot.model.label.PacsLabel;
 import com.diagbot.model.label.PastLabel;
+import com.diagbot.model.label.VitalLabel;
 import com.diagbot.service.impl.KlRegularConfigServiceImpl;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
@@ -24,10 +25,11 @@ import com.diagbot.util.StringUtil;
 import com.diagbot.vo.IndicationPushVO;
 import com.diagbot.vo.RegularConfigSaveVO;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.commons.collections4.MapUtils;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -118,7 +120,12 @@ public class KlRegularConfigFacade extends KlRegularConfigServiceImpl {
         PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
         List<PacsNum> pacsNumList = pacsLabel.getPacsNumList();
         String pacs = pacsLabel.getText();
-        if (StringUtil.isBlank(symptom) && StringUtil.isBlank(pasts)&& StringUtil.isBlank(pacs)) {
+        //体征
+        String vital = wordCrfDTO.getVital();
+        VitalLabel vitalLabel = wordCrfDTO.getVitalLabel();
+        List<Vital> vitals = vitalLabel.getVitals();
+
+        if (StringUtil.isBlank(symptom) && StringUtil.isBlank(pasts) && StringUtil.isBlank(pacs)) {
             return wordCrfDTO;
         }
 
@@ -152,22 +159,76 @@ public class KlRegularConfigFacade extends KlRegularConfigServiceImpl {
 
         //辅检
         List<KlRegularConfig> rulesTepy = EntityUtil.makeEntityListMap(regularConfigs, "rulesTepy").get(RegularConfigEnum.pacs.getKey());
-        if(ListUtil.isNotEmpty(rulesTepy)){
-            for (KlRegularConfig klrc:rulesTepy) {
-                String rulesValue = klrc.getRulesValue();
-                List<List<String>> regexGroupData = RegexUtil.getRegexGroupData(pacs, rulesValue);
-                if(ListUtil.isNotEmpty(regexGroupData)){
-                    for (List<String> group_contents:regexGroupData) {
-                        PacsNum pacsNum = new PacsNum();
-                        pacsNum.setName(group_contents.get(0));
-                        pacsNum.setStandName(group_contents.get(0));
-                        PD pd = new PD();
-                        pd.setValue((group_contents.get(1)));
-                        pd.setUnit(group_contents.get(2));
-                        pacsNum.setPd(pd);
-                        pacsNumList.add(pacsNum);
+        Map<String, String> rulePacsCompiles = ruleAllCompile(rulesTepy, pacs);
+        if (MapUtils.isNotEmpty(rulePacsCompiles)) {
+            if (ListUtil.isNotEmpty(pacsNumList)) {
+                ListIterator<PacsNum> pacsNumListIterator = pacsNumList.listIterator();
+                while (pacsNumListIterator.hasNext()){
+                    PacsNum x = pacsNumListIterator.next();
+                    String name = x.getName();
+                    PD pd = x.getPd();
+                    if (pd != null) {
+                        String value = pd.getValue();
+                        String unit = pd.getUnit();
+                        String key = name + "_" + value;
+                        if (rulePacsCompiles.containsKey(key)) {
+                            if (StringUtil.isBlank(unit)) {
+                                unit = rulePacsCompiles.get(key);
+                                pd.setUnit(unit);
+                            }
+                        }
+                    }
+                }
+            } else {
+                rulePacsCompiles.forEach((x, y) -> {
+                    String[] nameValue = x.split("_");
+                    PacsNum pacsNum = new PacsNum();
+                    pacsNum.setName(nameValue[0]);
+                    pacsNum.setStandName(nameValue[0]);
+                    PD pdnew = new PD();
+                    pdnew.setValue(nameValue[1]);
+                    pdnew.setUnit(y);
+                    pacsNum.setPd(pdnew);
+                    pacsNumList.add(pacsNum);
+                });
+            }
+        }
+
+        //体征
+        List<KlRegularConfig> rulesTepyVitals = EntityUtil.makeEntityListMap(regularConfigs, "rulesTepy").get(RegularConfigEnum.vital.getKey());
+        Map<String, String> rulevitalsCompiles = ruleAllCompile(rulesTepyVitals, vital);
+        if (MapUtils.isNotEmpty(rulevitalsCompiles)) {
+            if (ListUtil.isNotEmpty(vitals)) {
+                Iterator<Vital> vitalIterator = vitals.listIterator();
+                while (vitalIterator.hasNext()) {
+                    Vital next = vitalIterator.next();
+                    String name = next.getName();
+                    PD pd = next.getPd();
+                    if (pd != null) {
+                        String value = pd.getValue();
+                        String unit = pd.getUnit();
+                        String key = name + "_" + value;
+                        if (rulevitalsCompiles.containsKey(key)) {
+                            if (StringUtil.isBlank(unit)) {
+                                unit = rulevitalsCompiles.get(key);
+                                pd.setUnit(unit);
+                            }
+                        }
                     }
                 }
+
+            } else {
+                rulevitalsCompiles.forEach((x, y) -> {
+                    String[] nameValue = x.split("_");
+                    Vital pacsNum = new Vital();
+                    pacsNum.setName(nameValue[0]);
+                    pacsNum.setStandName(nameValue[0]);
+                    PD pdnew = new PD();
+                    pdnew.setValue(nameValue[1]);
+                    pdnew.setUnit(y);
+                    pacsNum.setPd(pdnew);
+                    vitals.add(pacsNum);
+                });
             }
         }
         // 既往史过敏史
@@ -230,4 +291,44 @@ public class KlRegularConfigFacade extends KlRegularConfigServiceImpl {
         }
         return res;
     }
+
+    /**
+     * 把正则匹配出来的放在map里
+     * key:体温_37 value:℃
+     *
+     * @param regexGroupData
+     * @return
+     */
+    public Map<String, String> ruleCompile(List<List<String>> regexGroupData) {
+        Map<String, String> ruleCompileMap = Maps.newHashMap();
+        if (ListUtil.isNotEmpty(regexGroupData)) {
+            for (List<String> groupContents : regexGroupData) {
+                if (ListUtil.isNotEmpty(groupContents)) {
+                    String s = "";
+                    if(groupContents.size() > 2){
+                        s = groupContents.get(2);
+                    }
+
+                    ruleCompileMap.put(groupContents.get(0) + "_" + groupContents.get(1), s);
+                }
+            }
+
+        }
+        return ruleCompileMap;
+    }
+
+    public Map<String, String> ruleAllCompile(List<KlRegularConfig> rulesTepy, String txt) {
+        Map<String, String> ruleAllCompileMap = Maps.newHashMap();
+        if (ListUtil.isNotEmpty(rulesTepy)) {
+            for (KlRegularConfig klrc : rulesTepy) {
+                String rulesValue = klrc.getRulesValue();
+                List<List<String>> regexGroupData = RegexUtil.getRegexGroupData(txt, rulesValue);
+                Map<String, String> ruleCompileMap = ruleCompile(regexGroupData);
+                if (MapUtils.isNotEmpty(ruleCompileMap)) {
+                    ruleAllCompileMap.putAll(ruleCompileMap);
+                }
+            }
+        }
+        return ruleAllCompileMap;
+    }
 }