Browse Source

24小时开单待修改

zhoutg 4 years ago
parent
commit
7cd7b605a2

+ 0 - 1
src/main/java/com/diagbot/dto/PushDTO.java

@@ -25,7 +25,6 @@ public class PushDTO {
     private List<PushBaseDTO> pacs = new ArrayList<>();
     // 手术
     private List<PushBaseDTO> operations = new ArrayList<>();
-
     // 药品
     private List<PushBaseDTO> medicines = new ArrayList<>();
     // 并发症

+ 3 - 0
src/main/java/com/diagbot/process/BillProcess.java

@@ -180,6 +180,9 @@ public class BillProcess {
             // 服用药品(现病史一般情况后的药品)
             DrugRule.compareDrugWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
         }
+
+        // 24小时重复开单项
+        CommonRule.repeat24Bill(wordCrfDTO, billMsgList);
         indicationDTO.setBillMsgList(billMsgList);
     }
 

+ 197 - 0
src/main/java/com/diagbot/rule/CommonRule.java

@@ -1,13 +1,25 @@
 package com.diagbot.rule;
 
+import com.diagbot.biz.push.entity.Item;
+import com.diagbot.biz.push.entity.Lis;
+import com.diagbot.biz.push.entity.Pacs;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.TypeEnum;
 import com.diagbot.model.entity.Negative;
+import com.diagbot.util.CatalogueUtil;
 import com.diagbot.util.CoreUtil;
+import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -51,4 +63,189 @@ public class CommonRule {
             }
         }
     }
+
+    /**
+     * 24小时重复开单总入口
+     *
+     * @param wordCrfDTO
+     * @param billMsgList
+     */
+    public static void repeat24Bill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
+        // repeat24BillWithLisType(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName()); // 化验重复开单
+        repeat24BillWithPacsType(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName()); // 辅检重复开单
+        repeat24BillWithType(billMsgList, wordCrfDTO.getDrugOrder(), TypeEnum.drug.getName()); // 药品重复开单
+        repeat24BillWithType(billMsgList, wordCrfDTO.getOperationOrder(), TypeEnum.operation.getName()); // 手术重复开单
+    }
+
+    /**
+     * 24小时重复开单入口(化验)
+     *
+     * @param billMsgList
+     * @param itemList
+     * @param type
+     */
+    public static <T> void repeat24BillWithPacsType(List<BillMsg> billMsgList, List<Pacs> itemList, String type) {
+        if (ListUtil.isEmpty(itemList)) {
+            return ;
+        }
+        Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
+        for (String key : map.keySet()) {
+            List<Pacs> items = map.get(key);
+
+            // 个数大于2个才比较
+            if (ListUtil.isNotEmpty(items) && items.size() > 1) {
+                // items 按照时间排序
+                Collections.sort(items, new Comparator<Pacs>() {
+                    @Override
+                    public int compare(Pacs o1, Pacs o2) {
+                        if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
+                            return -1;
+                        } else {
+                            return o1.getDateValue().compareTo(o2.getDateValue());
+                        }
+                    }
+                });
+
+                // 比较时间是否在24小时内
+                List<Date> dateList = new ArrayList<>();
+                for (Pacs it : items) {
+                    if (StringUtil.isNotBlank(it.getDateValue())) {
+                        Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
+                        // 如果为null,说明日期格式出错,不比较
+                        if (cur != null) {
+                            if (ListUtil.isNotEmpty(dateList)) {
+                                Date last = dateList.get(dateList.size() - 1);
+                                if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
+                                    BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
+                                            it.getName(), it.getUniqueName(),
+                                            it.getName(), type);
+                                    billMsgList.add(commonBillMsg);
+                                    break;
+                                } else {
+                                    dateList.add(cur);
+                                }
+                            } else {
+                                dateList.add(cur);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 24小时重复开单入口(化验)
+     *
+     * @param billMsgList
+     * @param itemList
+     * @param type
+     */
+    public static <T> void repeat24BillWithLisType(List<BillMsg> billMsgList, List<Lis> itemList, String type) {
+        if (ListUtil.isEmpty(itemList)) {
+            return ;
+        }
+        Map<String, List<Lis>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
+        for (String key : map.keySet()) {
+            List<Lis> items = map.get(key);
+
+            // 个数大于2个才比较
+            if (ListUtil.isNotEmpty(items) && items.size() > 1) {
+                // items 按照时间排序
+                Collections.sort(items, new Comparator<Lis>() {
+                    @Override
+                    public int compare(Lis o1, Lis o2) {
+                        if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
+                            return -1;
+                        } else {
+                            return o1.getDateValue().compareTo(o2.getDateValue());
+                        }
+                    }
+                });
+
+                // 比较时间是否在24小时内
+                List<Date> dateList = new ArrayList<>();
+                for (Lis it : items) {
+                    if (StringUtil.isNotBlank(it.getDateValue())) {
+                        Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
+                        // 如果为null,说明日期格式出错,不比较
+                        if (cur != null) {
+                            if (ListUtil.isNotEmpty(dateList)) {
+                                Date last = dateList.get(dateList.size() - 1);
+                                if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
+                                    BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
+                                            it.getName(), it.getUniqueName(),
+                                            it.getName(), type);
+                                    billMsgList.add(commonBillMsg);
+                                    break;
+                                } else {
+                                    dateList.add(cur);
+                                }
+                            } else {
+                                dateList.add(cur);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 24小时重复开单入口
+     *
+     * @param billMsgList
+     * @param itemList
+     * @param type
+     */
+    public static void repeat24BillWithType(List<BillMsg> billMsgList, List<Item> itemList, String type) {
+        if (ListUtil.isEmpty(itemList)) {
+            return ;
+        }
+        Map<String, List<Item>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
+        for (String key : map.keySet()) {
+            List<Item> items = map.get(key);
+
+            // 个数大于2个才比较
+            if (ListUtil.isNotEmpty(items) && items.size() > 1) {
+                // items 按照时间排序
+                Collections.sort(items, new Comparator<Item>() {
+                    @Override
+                    public int compare(Item o1, Item o2) {
+                        if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
+                            return -1;
+                        } else {
+                            return o1.getDateValue().compareTo(o2.getDateValue());
+                        }
+                    }
+                });
+
+                // 比较时间是否在24小时内
+                List<Date> dateList = new ArrayList<>();
+                for (Item it : items) {
+                    if (StringUtil.isNotBlank(it.getDateValue())) {
+                        Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
+                        // 如果为null,说明日期格式出错,不比较
+                        if (cur != null) {
+                            if (ListUtil.isNotEmpty(dateList)) {
+                                Date last = dateList.get(dateList.size() - 1);
+                                if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
+                                    BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
+                                            it.getName(), it.getUniqueName(),
+                                            it.getName(), type);
+                                    billMsgList.add(commonBillMsg);
+                                    break;
+                                } else {
+                                    dateList.add(cur);
+                                }
+                            } else {
+                                dateList.add(cur);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
 }

+ 2 - 3
src/main/java/com/diagbot/util/CatalogueUtil.java

@@ -170,7 +170,7 @@ public class CatalogueUtil {
         }
         Calendar calendar_s = Calendar.getInstance();
         Calendar calendar_e = Calendar.getInstance();
-        Long time_s, time_e, time_diff;
+        Long time_s, time_e;
         try {
             calendar_s.setTime(startDate);
             calendar_e.setTime(endDate);
@@ -178,8 +178,7 @@ public class CatalogueUtil {
             time_s = calendar_s.getTimeInMillis();
             time_e = calendar_e.getTimeInMillis();
 
-            time_diff = (time_e - time_s) / (1000 * 60);
-            if (time_diff > diff) {
+            if ((time_e - time_s) >  diff * 1000 * 60) {
                 overtime = true;
             }
         } catch (Exception e) {

+ 1 - 1
src/main/java/com/diagbot/util/Content.java

@@ -251,7 +251,7 @@ public class Content {
 
     public static final String timestamp = "timestamp";
 
-    public static String[] dateFormats = {
+    public static String[]  dateFormats = {
             "yyyy年MM月dd日HH时mm分",
             "yyyy年MM月dd日HH:mm",
             "yyyy年MM月dd日H时mm分",

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

@@ -253,6 +253,26 @@ public class CoreUtil {
         return billMsg;
     }
 
+    /**
+     * 开单合理性24小时重复开通用提示信息
+     *
+     * @param orderName 原开单项
+     * @param orderStandName 标准开单项
+     * @param content 匹配内容
+     * @param type 类型
+     * @return
+     */
+    public static BillMsg getBillMsg24Repeat(String orderName, String orderStandName, String content, String type) {
+        BillMsg billMsg = new BillMsg();
+        String msg = String.format("%s重复开立", orderName);
+        billMsg.setMsg(msg);
+        billMsg.setOrderName(orderName);
+        billMsg.setOrderStandName(orderStandName);
+        billMsg.setContent(content);
+        billMsg.setType(type);
+        return billMsg;
+    }
+
     /**
      * 将对象添加到列表中
      *

+ 1 - 1
src/main/java/com/diagbot/util/StringUtil.java

@@ -66,7 +66,7 @@ public class StringUtil {
     public static String remove_ctl(String str) {
         String trim = "";
         if(StringUtils.isNotEmpty(str)){
-            trim = str.replaceAll("\r|\n|\r\n|/r/n", "").trim();
+            trim = str.replaceAll("\r|\n|\r\n", "").trim();
         }
         return trim;
     }

+ 1 - 1
src/main/java/com/diagbot/vo/SearchData.java

@@ -122,7 +122,7 @@ public class SearchData extends HospitalBaseVO {
      */
     private List<Item> drug = new ArrayList<>();
     /**
-     * 手术操作
+     * 手术操作
      */
     private List<Item> operation = new ArrayList<>();
     /**