浏览代码

化验规则处理

zhoutg 4 年之前
父节点
当前提交
577f47025e

+ 11 - 13
src/main/java/com/diagbot/dto/BillNeoMaxDTO.java

@@ -22,7 +22,7 @@ public class BillNeoMaxDTO {
     /****************扩展数据结束******************/
 
     // 禁忌性别
-    private String gender;
+    private NodeNeoDTO gender;
 
     // 年龄
     private NodeNeoDTO ageNeoDTO;
@@ -31,16 +31,19 @@ public class BillNeoMaxDTO {
     private List<NodeNeoDTO> clinicfindings = new ArrayList<>();
 
     // 服用药品
-    private List<String> prescribe = new ArrayList<>();
+    private List<NodeNeoDTO> oralmeds = new ArrayList<>();
 
     // 禁忌过敏药品
-    private List<String> allergmeds = new ArrayList<>();
+    private List<NodeNeoDTO> allergicmeds = new ArrayList<>();
 
     // 禁忌手术
-    private List<String> operations = new ArrayList<>();
+    private List<NodeNeoDTO> operations = new ArrayList<>();
 
     // 禁忌操作
-    private List<String> procedures = new ArrayList<>();
+    private List<NodeNeoDTO> procedures = new ArrayList<>();
+
+    // 禁忌实验室检查
+    private List<NodeNeoDTO> lis = new ArrayList<>();
 
     // 禁忌辅助检查
     private List<NodeNeoDTO> pacs = new ArrayList<>();
@@ -49,14 +52,9 @@ public class BillNeoMaxDTO {
     private List<NodeNeoDTO> disease = new ArrayList<>();
 
     // 禁用人群
-    private List<String> group = new ArrayList<>();
-
-    // 禁忌过敏药品
-    private List<String> allergicmeds = new ArrayList<>();
-
-    // 禁忌实验室检查
-    private List<NodeNeoDTO> lis = new ArrayList<>();
+    private List<NodeNeoDTO> group = new ArrayList<>();
 
     // 配伍禁忌
-    private List<String> conflictmeds = new ArrayList<>();
+    private List<NodeNeoDTO> conflictmeds = new ArrayList<>();
+
 }

+ 12 - 7
src/main/java/com/diagbot/process/BillProcess.java

@@ -6,13 +6,18 @@ import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoDTO;
 import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.model.entity.Clinical;
 import com.diagbot.model.entity.Diag;
 import com.diagbot.model.label.ChiefLabel;
 import com.diagbot.model.label.DiagLabel;
 import com.diagbot.model.label.PresentLabel;
-import com.diagbot.rule.*;
+import com.diagbot.rule.AgeRule;
+import com.diagbot.rule.DiagRule;
+import com.diagbot.rule.LisRule;
+import com.diagbot.rule.PacsRule;
+import com.diagbot.rule.SexRule;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
@@ -44,9 +49,9 @@ public class BillProcess {
             billNeoMaxDTO.setOrderName(billNeoDTO.getName()); // 开单名称
             billNeoMaxDTO.setOrderStandName(billNeoDTO.getStandname()); // 开单标准名称
             // 测试数据开始
-            // billNeoMaxDTO.setGender("男");
-            // billNeoMaxDTO.getAgeNeoDTO().setMax(new BigDecimal(30));
-            // billNeoMaxDTO.getAgeNeoDTO().setMin(new BigDecimal(25));
+            NodeNeoDTO sexNeo = new NodeNeoDTO();
+            sexNeo.setName("男");
+            billNeoMaxDTO.setGender(sexNeo);
             // 测试数据结束
 
             System.out.println(billNeoMaxDTO);
@@ -78,7 +83,7 @@ public class BillProcess {
         List<BillMsg> billMsgList = new ArrayList<>();
         for (BillNeoMaxDTO bill : billNeoMaxDTOList) {
             // 性别
-            BillMsg sexMsg = SexRule.compareSexWithBill(bill.getGender(), wordCrfDTO, bill);
+            BillMsg sexMsg = SexRule.compareSexWithBill(wordCrfDTO, bill);
             CoreUtil.addBeanToList(billMsgList, sexMsg);
 
             // 诊断
@@ -86,7 +91,7 @@ public class BillProcess {
             CoreUtil.addBeanToList(billMsgList, billMsg_disease);
 
              //化验
-             BillMsg lisMsg = LisRule.compareLisWithBill(bill.getLis(), lis, bill);
+             BillMsg lisMsg = LisRule.compareLisWithBill(lis, bill);
              CoreUtil.addBeanToList(billMsgList, lisMsg);
 
              //辅检
@@ -98,7 +103,7 @@ public class BillProcess {
             CoreUtil.addBeanToList(billMsgList, clinicalMsg);
 
             // 年龄
-            BillMsg ageMsg = AgeRule.compareAgeWithBill(bill.getAgeNeoDTO(), wordCrfDTO, bill);
+            BillMsg ageMsg = AgeRule.compareAgeWithBill(wordCrfDTO, bill);
             CoreUtil.addBeanToList(billMsgList, ageMsg);
 
         }

+ 3 - 24
src/main/java/com/diagbot/rule/AgeRule.java

@@ -6,8 +6,6 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
 
-import java.math.BigDecimal;
-
 /**
  * @description: 年龄规则
  * @author: zhoutg
@@ -18,35 +16,16 @@ public class AgeRule {
     /**
      * 年龄比较
      *
-     * @param ageNeoDTO
      * @param wordCrfDTO
      * @param billNeoMaxDTO
      * @return
      */
-    public static BillMsg compareAgeWithBill(NodeNeoDTO ageNeoDTO, WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO) {
+    public static BillMsg compareAgeWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO) {
+        NodeNeoDTO ageNeoDTO = billNeoMaxDTO.getAgeNeoDTO();
         Boolean flag = false;
         if (ageNeoDTO != null && wordCrfDTO.getAge() != null) {
             Integer age = wordCrfDTO.getAge();
-            BigDecimal min = ageNeoDTO.getMin();
-            BigDecimal max = ageNeoDTO.getMax();
-
-            if (min != null && max != null) {
-                int minAge = min.intValue();
-                int maxAge = max.intValue();
-                if (minAge <= age && age <= maxAge) {
-                    flag = true;
-                }
-            } else if (min != null && max == null) {
-                int minAge = min.intValue();
-                if (minAge <= age) {
-                    flag = true;
-                }
-            } else if (min == null && max != null) {
-                int maxAge = max.intValue();
-                if (age <= maxAge) {
-                    flag = true;
-                }
-            }
+            flag = CoreUtil.compareValue(ageNeoDTO, age);
         }
         if (flag) {
             return CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),

+ 20 - 31
src/main/java/com/diagbot/rule/LisRule.java

@@ -6,13 +6,11 @@ import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 
-import java.math.BigDecimal;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * @description: 化验规则
@@ -20,42 +18,33 @@ import java.util.stream.Collectors;
  * @time: 2020/8/3 14:47
  */
 public class LisRule {
+
     /**
-     * 比较辅检
+     * 比较化验
      *
-     * @param drugLis
      * @param inputLis
+     * @param billNeoMaxDTO
      * @return
      */
-    public static BillMsg compareLisWithBill(List<NodeNeoDTO> drugLis, List<Lis> inputLis, BillNeoMaxDTO billNeoMaxDTO) {
-
-        Map<String,String> old_stand = new HashMap<>();
-        if(ListUtil.isNotEmpty(drugLis) && ListUtil.isNotEmpty(inputLis)){
-            Map<String, BigDecimal> nameMax = drugLis.stream().collect(Collectors.toMap(NodeNeoDTO::getName, NodeNeoDTO::getMax));
-            Map<String, BigDecimal> nameMin = drugLis.stream().collect(Collectors.toMap(NodeNeoDTO::getName, NodeNeoDTO::getMin));
-
-            for (Lis lis:inputLis) {
-                String val =lis.getUniqueName();
-                String val_name = lis.getDetailName();
-
-                if(StringUtils.isNotBlank(val)){
-                    if(nameMax.containsKey(val) && lis.getValue() > nameMax.get(val).doubleValue()){
-                        old_stand.put(val_name,"大于"+lis.getValue().toString());
+    public static BillMsg compareLisWithBill(List<Lis> inputLis, BillNeoMaxDTO billNeoMaxDTO) {
+        List<String> msgList = new ArrayList<>();
+        List<NodeNeoDTO> neoList = billNeoMaxDTO.getLis();
+        if(ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(inputLis)){
+            for (NodeNeoDTO neo : neoList) {
+                for (Lis lis : inputLis) {
+                    String val = lis.getUniqueName();
+                    if (StringUtil.isNotBlank(val) && neo.getName().equals(val)) {
+                        String val_name = lis.getDetailName();
+                        boolean flag = CoreUtil.compareValue(neo, lis.getValue());
+                        if (flag) {
+                            msgList.add(CoreUtil.getValueMsg(neo, val_name, lis.getValue(), lis.getUnits()));
+                        }
                     }
-                    if(nameMin.containsKey(val) && lis.getValue() < nameMin.get(val).doubleValue()){
-                        old_stand.put(val_name,"小于"+lis.getValue().toString());
-                    }
-
                 }
             }
         }
-        if(old_stand.size() > 0){
-            String message =null;
-            for (Map.Entry<String,String> ds:old_stand.entrySet()) {
-                message +=ds.getKey()+ds.getValue()+",";
-            }
-//            String message = StringUtils.join(old_stand.keySet(), ",");
-//            String standNames = StringUtils.join(old_stand.values().stream().collect(Collectors.toList()),",");
+        if (ListUtil.isNotEmpty(msgList)){
+           String message = StringUtils.join(msgList, ",");
             BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),billNeoMaxDTO.getOrderStandName(),message,null);
             return commonBillMsg;
         }

+ 7 - 3
src/main/java/com/diagbot/rule/SexRule.java

@@ -2,6 +2,7 @@ package com.diagbot.rule;
 
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoMaxDTO;
+import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.StringUtil;
@@ -12,15 +13,18 @@ import com.diagbot.util.StringUtil;
  * @time: 2020/8/3 14:47
  */
 public class SexRule {
+
     /**
      * 比较性别
      *
-     * @param sex
      * @param wordCrfDTO
+     * @param billNeoMaxDTO
      * @return
      */
-    public static BillMsg compareSexWithBill(String sex, WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO) {
-        if (StringUtil.isNotBlank(sex) && wordCrfDTO.getSex() != null) {
+    public static BillMsg compareSexWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO) {
+        NodeNeoDTO nodeNeoDTO = billNeoMaxDTO.getGender();
+        if (nodeNeoDTO != null && StringUtil.isNotBlank(nodeNeoDTO.getName()) && wordCrfDTO.getSex() != null) {
+            String sex = nodeNeoDTO.getName();
             String sexStr = "";
             if (1 == wordCrfDTO.getSex()) {
                 sexStr = "男";

+ 106 - 0
src/main/java/com/diagbot/util/CoreUtil.java

@@ -1,10 +1,12 @@
 package com.diagbot.util;
 
 import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.model.entity.Clinical;
 import org.apache.commons.lang.StringUtils;
 
 import java.lang.reflect.Field;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -234,6 +236,110 @@ public class CoreUtil {
         }
     }
 
+    /**
+     * 比较数值大小(int)
+     *
+     * @param nodeNeoDTO
+     * @param value
+     * @return
+     */
+    public static boolean compareValue(NodeNeoDTO nodeNeoDTO, int value) {
+        boolean flag = false;
+        BigDecimal min = nodeNeoDTO.getMin();
+        BigDecimal max = nodeNeoDTO.getMax();
+
+        if (min != null && max != null) {
+            int minAge = min.intValue();
+            int maxAge = max.intValue();
+            if (minAge <= value && value <= maxAge) {
+                flag = true;
+            }
+        } else if (min != null && max == null) {
+            int minAge = min.intValue();
+            if (minAge <= value) {
+                flag = true;
+            }
+        } else if (min == null && max != null) {
+            int maxAge = max.intValue();
+            if (value <= maxAge) {
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    /**
+     * 比较数值大小(double)
+     *
+     * @param nodeNeoDTO
+     * @param value
+     * @return
+     */
+    public static boolean compareValue(NodeNeoDTO nodeNeoDTO, double value) {
+        boolean flag = false;
+        BigDecimal min = nodeNeoDTO.getMin();
+        BigDecimal max = nodeNeoDTO.getMax();
+
+        if (min != null && max != null) {
+            int minAge = min.intValue();
+            int maxAge = max.intValue();
+            if (minAge <= value && value <= maxAge) {
+                flag = true;
+            }
+        } else if (min != null && max == null) {
+            int minAge = min.intValue();
+            if (minAge <= value) {
+                flag = true;
+            }
+        } else if (min == null && max != null) {
+            int maxAge = max.intValue();
+            if (value <= maxAge) {
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    /**
+     * 获取提示信息(int)
+     *
+     * @param nodeNeoDTO
+     * @param value
+     * @return
+     */
+    public static String getValueMsg(NodeNeoDTO nodeNeoDTO, String name, double value, String unit) {
+        if (nodeNeoDTO == null) {
+            return "";
+        }
+        StringBuffer sb = new StringBuffer();
+        sb.append(name);
+        sb.append(subZeroAndDot(String.valueOf(value))); // 去掉小数点后的0
+        if (StringUtil.isBlank(unit)) {
+            sb.append(unit);
+        }
+        sb.append("(禁忌范围[");
+        if (nodeNeoDTO.getMin() != null) {
+            sb.append(nodeNeoDTO.getMin());
+        }
+        sb.append(",");
+        if (nodeNeoDTO.getMax() != null) {
+            sb.append(nodeNeoDTO.getMax());
+        }
+        // if (nodeNeoDTO.getUnit() != null) {
+        //     sb.append(nodeNeoDTO.getUnit());
+        // }
+        sb.append("])");
+        return sb.toString();
+    }
+
+    public static String subZeroAndDot(String s){
+        if(s.indexOf(".") > 0){
+            s = s.replaceAll("0+?$", "");//去掉多余的0
+            s = s.replaceAll("[.]$", "");//如最后一位是.则去掉
+        }
+        return s;
+    }
+
     /**
      * list 转 string
      * @param list