Browse Source

优化代码以及取过敏史数据

wangfeng 4 years ago
parent
commit
3fd014b4c1

+ 1 - 1
src/main/java/com/diagbot/facade/IndicationFacade.java

@@ -93,7 +93,7 @@ public class IndicationFacade {
         }
         CoreUtil.getDebugStr(crfStart, "模型处理耗时", debug);
         //正则匹配开始
-        wordCrfDTO = sysRegularConfigFacade.getRegularConfigs(wordCrfDTO);
+        wordCrfDTO = sysRegularConfigFacade.getRegularConfigs(wordCrfDTO,indicationPushVO);
         //正则匹配结束
         // 标准词转换
         long standStart = System.currentTimeMillis();

+ 25 - 14
src/main/java/com/diagbot/facade/SysRegularConfigFacade.java

@@ -10,14 +10,13 @@ import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.RegularConfigEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
-import com.diagbot.model.entity.Allergy;
 import com.diagbot.model.entity.AllergyMedicine;
 import com.diagbot.model.label.PastLabel;
 import com.diagbot.service.impl.SysRegularConfigServiceImpl;
 import com.diagbot.util.ListUtil;
+import com.diagbot.vo.IndicationPushVO;
 import com.diagbot.vo.RegularConfigDataVO;
 import com.diagbot.vo.RegularConfigSaveVO;
-import org.neo4j.driver.summary.Plan;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -45,7 +44,7 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
                 String pattern = "";
                 String patternMax = "";
                 if (data.getRulesTepy().equals(RegularConfigEnum.allergy.getKey())) {
-                    pattern =  data.getRulesValue().split("¥")[0];
+                    pattern = data.getRulesValue().split("¥")[0];
                     patternMax = data.getRulesValue().split("¥")[1];
                 } else {
                     pattern = data.getRulesValue();
@@ -105,7 +104,8 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
      * @param wordCrfDTO
      * @return
      */
-    public WordCrfDTO getRegularConfigs(WordCrfDTO wordCrfDTO) {
+    public WordCrfDTO getRegularConfigs(WordCrfDTO wordCrfDTO, IndicationPushVO indicationPushVO) {
+        String allergyStr = indicationPushVO.getAllergy();
         String symptom = wordCrfDTO.getSymptom();//现病史
         RegularConfigDataVO regularConfigData = new RegularConfigDataVO();
         regularConfigData.setText(symptom);
@@ -116,12 +116,13 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
         if (ListUtil.isNotEmpty(regularConfigDatas)) {
             for (RegularValueDTO data : regularConfigDatas) {
                 if (data.getType().equals(RegularConfigEnum.lis.getKey())) {
+                    if(!data.getValue().equals("")){
                     Lis lis = new Lis();
                     lis.setUniqueName(data.getKey());
                     lis.setDetailName(data.getKey());
                     lis.setName(data.getKey());
                     lis.setValue(Double.valueOf(data.getValue()));
-                    lisData.add(lis);
+                    lisData.add(lis);}
                 } else if (data.getType().equals(RegularConfigEnum.allergy.getKey())) {
                     AllergyMedicine allergy = new AllergyMedicine();
                     allergy.setName(data.getKey());
@@ -136,13 +137,23 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
         regularConfigData.setRulesTepy(RegularConfigEnum.allergy.getKey());
         List<RegularValueDTO> regularConfigPastss = getRegularConfigDatas(regularConfigData);
         if (ListUtil.isNotEmpty(regularConfigPastss)) {
-            for(RegularValueDTO dataPasts : regularConfigPastss){
+            for (RegularValueDTO dataPasts : regularConfigPastss) {
                 AllergyMedicine allergy = new AllergyMedicine();
                 allergy.setName(dataPasts.getKey());
                 allergy.setStandName(dataPasts.getKey());
                 allergies.add(allergy);
             }
         }
+        if (null!= allergyStr && !allergyStr.equals("")) {
+            String[] result = allergyStr.split("[\\,\\,]");
+            for (String r : result) {
+                AllergyMedicine allergyMedicine = new AllergyMedicine();
+                allergyMedicine.setName(r.trim());
+                allergyMedicine.setStandName(r.trim());
+                allergies.add(allergyMedicine);
+
+            }
+        }
         pastLabel.setAllergyMedicines(allergies);
         wordCrfDTO.setPastLabel(pastLabel);
         wordCrfDTO.setLis(lisData);
@@ -152,28 +163,28 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
     public boolean saverRegularConfigDatas(RegularConfigSaveVO regularConfigSaveVO) {
         boolean res = false;
         List<String> name = regularConfigSaveVO.getName();
-        for (String str:name) {
+        for (String str : name) {
             int countTow = this.count(new QueryWrapper<SysRegularConfig>()
                     .eq("is_deleted", IsDeleteEnum.N.getKey())
                     .eq(str != null, "rules_name", str)
                     .eq(regularConfigSaveVO.getRulesTepy() != null, "rules_tepy", regularConfigSaveVO.getRulesTepy()));
             if (countTow > 0) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, str+"该方案编码已存在");
-            }else {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, str + "该方案编码已存在");
+            } else {
                 SysRegularConfig regularConfig = new SysRegularConfig();
                 regularConfig.setRulesName(regularConfigSaveVO.getStandardName());
                 regularConfig.setRulesTepy(regularConfigSaveVO.getRulesTepy());
                 String rulesValue = "";
-                if(regularConfigSaveVO.getRulesTepy().equals(RegularConfigEnum.allergy.getKey())){
+                if (regularConfigSaveVO.getRulesTepy().equals(RegularConfigEnum.allergy.getKey())) {
                     int num = str.length();
-                    rulesValue = "[\\、"+str+"过敏]{"+(num+3)+"}|[无"+str+"过敏]{"+(num+3)+"}|[否认"+str+"过敏]{"+(num+4)+"}¥["+str+"过敏]{"+(num+2)+"}";
-                }else if(regularConfigSaveVO.getRulesTepy().equals(RegularConfigEnum.lis.getKey())){
-                    rulesValue ="("+str+")\\s*[(\\-|\\+)?\\d+(\\.\\d+)?$]+";
+                    rulesValue = "[\\、" + str + "过敏]{" + (num + 3) + "}|[无" + str + "过敏]{" + (num + 3) + "}|[否认" + str + "过敏]{" + (num + 4) + "}¥[" + str + "过敏]{" + (num + 2) + "}";
+                } else if (regularConfigSaveVO.getRulesTepy().equals(RegularConfigEnum.lis.getKey())) {
+                    rulesValue = "(" + str + ")\\s*[(\\-|\\+)?\\d+(\\.\\d+)?$]+";
                 }
                 regularConfig.setRulesValue(rulesValue);
                 res = save(regularConfig);
             }
         }
-    return res;
+        return res;
     }
 }