瀏覽代碼

辅检结果正则匹配放入pacslable中的pacsNumList
体征正则匹配放入vitallable中的vitals中

kongwz 3 年之前
父節點
當前提交
54cfadc1d4

+ 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;

+ 115 - 16
src/main/java/com/diagbot/facade/KlRegularConfigFacade.java

@@ -14,8 +14,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 +26,12 @@ 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.CollectionUtils;
+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,6 +122,11 @@ public class KlRegularConfigFacade extends KlRegularConfigServiceImpl {
         PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
         List<PacsNum> pacsNumList = pacsLabel.getPacsNumList();
         String pacs = pacsLabel.getText();
+        //体征
+        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 +161,74 @@ 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)){
+                for (PacsNum x: pacsNumList) {
+                    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.iterator();
+                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,42 @@ 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 = groupContents.get(2);
+                   if(StringUtil.isBlank(s)){
+                       s = "";
+                   }
+                   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;
+    }
 }