瀏覽代碼

工具类

zhoutg 4 年之前
父節點
當前提交
8f88d1f1ea

+ 4 - 2
src/main/java/com/diagbot/process/BillProcess.java

@@ -5,7 +5,7 @@ import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoDTO;
 import com.diagbot.dto.DrugBillNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
-import com.diagbot.rule.AgeRule;
+import com.diagbot.rule.SexRule;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -65,10 +65,12 @@ public class BillProcess {
             List<DrugBillNeoDTO> drugBillNeoDTOList = bill.getDrugBillNeoDTOList();
             for (DrugBillNeoDTO drug : drugBillNeoDTOList) {
                 // 性别
-                BillMsg billMsg = AgeRule.compareSexWithBill(drug.getGender(), wordCrfDTO, bill.getName());
+                BillMsg billMsg = SexRule.compareSexWithBill(drug.getGender(), wordCrfDTO, bill.getName());
                 if (billMsg != null) {
                     drugBill.add(billMsg);
                 }
+
+                // 年龄
             }
         }
         billDTO.setDrugBill(drugBill);

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

@@ -1,36 +1,45 @@
 package com.diagbot.rule;
 
+import com.diagbot.dto.AgeNeoDTO;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.WordCrfDTO;
-import com.diagbot.util.StringUtil;
+import com.diagbot.util.CoreUtil;
 
 /**
- * @description: 性别规则
+ * @description: 年龄规则
  * @author: zhoutg
  * @time: 2020/8/3 14:47
  */
 public class AgeRule {
+
     /**
-     * 比较性别
+     * 年龄比较
      *
-     * @param sex
+     * @param ageNeoDTO
      * @param wordCrfDTO
+     * @param name
      * @return
      */
-    public static BillMsg compareSexWithBill(String sex, WordCrfDTO wordCrfDTO, String name) {
-        if (StringUtil.isNotBlank(sex) && wordCrfDTO.getSex() != null) {
-            String crfSex = "";
-            if (1 == wordCrfDTO.getSex()) {
-                crfSex = "男";
-            } else if (2 == wordCrfDTO.getSex()) {
-                crfSex = "女";
+    public static BillMsg compareAgeWithBill(AgeNeoDTO ageNeoDTO, WordCrfDTO wordCrfDTO, String name) {
+        Boolean flag = false;
+        if (ageNeoDTO != null && wordCrfDTO.getAge() != null) {
+            Integer age = wordCrfDTO.getAge();
+            Integer minAge = ageNeoDTO.getMinage();
+            if (minAge != null) {
+                if (age < minAge) {
+                    flag = true;
+                }
             }
-            if (sex.equals(crfSex)) {
-                BillMsg billMsg = new BillMsg();
-                billMsg.setMsg(name + "(" + crfSex + ")");
-                return billMsg;
+            Integer maxAge = ageNeoDTO.getMaxage();
+            if (maxAge != null) {
+                if (age > minAge) {
+                    flag = true;
+                }
             }
         }
+        if (flag) {
+            return CoreUtil.getCommonBillMsg(String.valueOf(wordCrfDTO.getAge() + "岁"), name);
+        }
         return null;
     }
 }

+ 39 - 0
src/main/java/com/diagbot/rule/SexRule.java

@@ -0,0 +1,39 @@
+package com.diagbot.rule;
+
+import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.util.CoreUtil;
+import com.diagbot.util.StringUtil;
+
+/**
+ * @description: 性别规则
+ * @author: zhoutg
+ * @time: 2020/8/3 14:47
+ */
+public class SexRule {
+    /**
+     * 比较性别
+     *
+     * @param sex
+     * @param wordCrfDTO
+     * @return
+     */
+    public static BillMsg compareSexWithBill(String sex, WordCrfDTO wordCrfDTO, String name) {
+        if (StringUtil.isNotBlank(sex) && wordCrfDTO.getSex() != null) {
+            String sexStr = "";
+            if (1 == wordCrfDTO.getSex()) {
+                sexStr = "男";
+            } else if (2 == wordCrfDTO.getSex()) {
+                sexStr = "女";
+            }
+            if (sex.equals(sexStr)) {
+                if ("男".equals(sexStr)) {
+                    return CoreUtil.getCommonBillMsg("男性", name);
+                } else if ("女".equals(sexStr)) {
+                    return CoreUtil.getCommonBillMsg("女性", name);
+                }
+            }
+        }
+        return null;
+    }
+}

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

@@ -1,5 +1,6 @@
 package com.diagbot.util;
 
+import com.diagbot.dto.BillMsg;
 import com.diagbot.model.entity.Clinical;
 
 import java.lang.reflect.Field;
@@ -168,7 +169,36 @@ public class CoreUtil {
     }
 
 
+    /**
+     * 开单合理性通用提示信息
+     *
+     * @param errMsg 提心信息
+     * @param name 项目名称
+     * @return
+     */
+    public static BillMsg getCommonBillMsg(String errMsg, String name) {
+        BillMsg billMsg = new BillMsg();
+        String msg = String.format(errMsg + ",不宜做%s", name);
+        billMsg.setMsg(msg);
+        return billMsg;
+    }
+
+    /**
+     * 开单合理性固定提示信息
+     *
+     * @param msg
+     * @param msg
+     * @return
+     */
+    public static BillMsg getBillMsgWithConst(String msg) {
+        BillMsg billMsg = new BillMsg(msg);
+        return billMsg;
+    }
+
     public static void main(String[] args) {
+
+        System.out.println(getCommonBillMsg("男性", "尿常规"));
+
         List<Clinical> clinicals = new ArrayList<>();
         Clinical c1 = new Clinical();
         c1.setName("a");