فهرست منبع

输血其他值提醒

zhoutg 3 سال پیش
والد
کامیت
064d4c52c9

+ 2 - 0
doc/025.20220125其他提醒增加输血后相关提醒/med2021_init.sql

@@ -644,3 +644,5 @@ INSERT INTO `kl_rule_plan` VALUES ('27096', 'N', '1970-01-01 12:00:00', '1970-01
 INSERT INTO `kl_rule_plan` VALUES ('27097', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', 'rule', '1', '200', '给药途径集合', null, null, '329', '24', '');
 
 INSERT INTO `kl_dictionary_info` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `group_type`, `name`, `val`, `return_type`, `order_no`, `remark`) VALUES ('371', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '21', '其他值提醒输血-输血类型', '5-113-1', '1', '0', '附加信息特殊处理(必填)');
+INSERT INTO `kl_dictionary_info` (`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `group_type`, `name`, `val`, `return_type`, `order_no`, `remark`) VALUES ('372', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '8', '输血后时间间隔', '48', '1', '0', '输血后时间间隔(48小时)');
+

+ 0 - 1
src/main/java/com/diagbot/config/CacheDeleteInit.java

@@ -26,7 +26,6 @@ public class CacheDeleteInit implements CommandLineRunner {
     @Autowired
     private ConceptInfoFacade conceptInfoFacade;
 
-
     @Override
     public void run(String... args) {
         // 服务启动清除redis缓存

+ 3 - 1
src/main/java/com/diagbot/dto/RuleExtDTO.java

@@ -13,8 +13,10 @@ import lombok.Setter;
 public class RuleExtDTO extends RuleDTO{
     // 医院名称
     private String inputName;
-    // 时间
+    // 开单时间
     private String dateValue;
+    // 报告时间
+    private String finishDateValue;
     // 类型名称
     private String libTypeName;
     // // 剂型

+ 17 - 2
src/main/java/com/diagbot/enums/RedisEnum.java

@@ -1,8 +1,11 @@
 package com.diagbot.enums;
 
 import com.diagbot.core.KeyedNamed;
+import com.google.common.collect.Lists;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @author zhoutg
  * @Description: 标准词转换
@@ -32,7 +35,8 @@ public enum RedisEnum implements KeyedNamed {
     drugAllergen(23, "drugAllergen"),
     otherMsg(24, "otherMsg"),
     criticalMsg(25, "criticalMsg"),
-    dateInterval(26, "dateInterval");
+    dateInterval(26, "dateInterval",
+            Lists.newArrayList("重复开立时间间隔", "输血后时间间隔"));
 
 
     @Setter
@@ -41,11 +45,20 @@ public enum RedisEnum implements KeyedNamed {
     @Setter
     private String name;
 
+    @Setter
+    private List<String> field;
+
     RedisEnum(int key, String name) {
         this.key = key;
         this.name = name;
     }
 
+    RedisEnum(int key, String name, List<String> field) {
+        this.key = key;
+        this.name = name;
+        this.field = field;
+    }
+
     public static RedisEnum getEnum(int key) {
         for (RedisEnum item : RedisEnum.values()) {
             if (item.key == key) {
@@ -70,5 +83,7 @@ public enum RedisEnum implements KeyedNamed {
         return name;
     }
 
-
+    public List<String> getField() {
+        return field;
+    }
 }

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

@@ -256,7 +256,7 @@ public class CacheFacade {
         if (ListUtil.isNotEmpty(dictionaryInfoDTOList)) {
             // 加载时间间隔
             redisUtil.putHashMap(RedisEnum.dateInterval.getName(),
-                    dictionaryInfoDTOList.stream().collect(Collectors.toMap(k -> k.getName(), v -> Integer.parseInt(v.getVal()), (v1, v2) -> (v2))));
+                    dictionaryInfoDTOList.stream().collect(Collectors.toMap(k -> k.getName(), v -> Long.parseLong(v.getVal()), (v1, v2) -> (v2))));
         }
     }
 

+ 52 - 0
src/main/java/com/diagbot/process/OtherTipProcess.java

@@ -28,6 +28,7 @@ import com.diagbot.util.MsgUtil;
 import com.diagbot.util.RedisUtil;
 import com.diagbot.util.ReflectUtil;
 import com.diagbot.util.StringUtil;
+import com.diagbot.vo.ItemExt;
 import com.diagbot.vo.RuleVO;
 import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -188,6 +189,7 @@ public class OtherTipProcess {
     public void processTransfusion(WordCrfDTO wordCrfDTO, IndicationDTO res) {
         List<Lis> lisList = wordCrfDTO.getLis();
         List<BillMsg> otherList = res.getOtherList();
+        // 1、化验为key
         for (Lis lis : lisList) {
             RuleVO ruleVO = getRuleVO(lis, RuleTypeEnum.transfusion.getKey());
             // 1、获取相关数据
@@ -204,6 +206,35 @@ public class OtherTipProcess {
                 }
             }
         }
+
+        // 2、输血为key
+        List<ItemExt> transfusionList = wordCrfDTO.getTransfusion();
+        if (ListUtil.isNotEmpty(transfusionList)) {
+            Long dateInterval = redisUtil.getByKeyAndField(RedisEnum.dateInterval.getName(), RedisEnum.dateInterval.getField().get(1));
+            Long minute = (-1L == dateInterval) ? 99999999999L : 60L * dateInterval;
+
+            for (ItemExt bean : transfusionList) {
+                RuleVO ruleVO = getRuleVO(bean, RuleTypeEnum.transfusion.getKey());
+                // 1、获取相关数据
+                if (ruleVO != null) {
+                    RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                    if (ruleExtDTO == null) {
+                        continue;
+                    }
+                    // int dateFlag = CoreUtil.compareTime(ruleExtDTO.getFinishDateValue(), "2022-01-25 15:00:00", minute, false, false);
+                    int dateFlag = CoreUtil.compareTime(ruleExtDTO.getFinishDateValue(), DateUtil.formatDateTime(DateUtil.now()), minute, false, false);
+                    if (dateFlag != 1) {
+                        continue;
+                    }
+                    List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+                    for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                        List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                        // 2、规则匹配
+                        lisRule.otherTransfusionLis(bean, ruleBaseDTOList, ruleConditionDTO.getMsg(), otherList, wordCrfDTO, minute);
+                    }
+                }
+            }
+        }
     }
 
     /**
@@ -355,4 +386,25 @@ public class OtherTipProcess {
         }
         return null;
     }
+
+    /**
+     * 获取其他值提醒入参——输血
+     *
+     * @param i
+     * @return
+     */
+    public RuleVO getRuleVO(ItemExt i, Integer key) {
+        if (StringUtil.isNotBlank(i.getUniqueName())) {
+            RuleVO ruleVO = new RuleVO();
+            ruleVO.setInputName(i.getName());
+            ruleVO.setLibName(i.getUniqueName());
+            ruleVO.setLibType(LexiconEnum.Transfusion.getKey());
+            ruleVO.setLibTypeName(LexiconEnum.Transfusion.getName());
+            ruleVO.setDateValue(i.getDateValue());
+            ruleVO.setFinishDateValue(i.getFinishDateValue());
+            ruleVO.setSuffix(String.valueOf(key));
+            return ruleVO;
+        }
+        return null;
+    }
 }

+ 1 - 1
src/main/java/com/diagbot/rule/CommonRule.java

@@ -355,7 +355,7 @@ public class CommonRule {
      * @param billMsgList
      */
     public void repeatBill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
-        Integer repeat = redisUtil.getByKeyAndField(RedisEnum.dateInterval.getName(), "重复开立时间间隔");
+        Long repeat = redisUtil.getByKeyAndField(RedisEnum.dateInterval.getName(), RedisEnum.dateInterval.getField().get(0));
         // 转换为分钟
         Long repeatDate = 60L * repeat;
         // 当前开单项与当前开单项重复开立

+ 43 - 0
src/main/java/com/diagbot/rule/LisRule.java

@@ -8,6 +8,7 @@ import com.diagbot.dto.MatchDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.BaseTypeEnum;
 import com.diagbot.enums.ConEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.TypeEnum;
@@ -16,6 +17,7 @@ import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.StringUtil;
+import com.diagbot.vo.ItemExt;
 import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -328,6 +330,47 @@ public class LisRule {
         }
     }
 
+
+    /**
+     * 比较化验是否存在——其他值提醒输血
+     *
+     * @param bean
+     * @param ruleBaseDTOList
+     * @param msg
+     * @param wordCrfDTO
+     * @param otherList
+     * @param minute
+     */
+    public void otherTransfusionLis(ItemExt bean, List<RuleBaseDTO> ruleBaseDTOList, String msg, List<BillMsg> otherList, WordCrfDTO wordCrfDTO, Long minute) {
+        if (ListUtil.isEmpty(ruleBaseDTOList)) {
+            return;
+        }
+        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+            boolean flag = false;
+            if (BaseTypeEnum.getEnum(ruleBaseDTO.getBaseType()) != null) {// 避免空指针
+                switch (BaseTypeEnum.getEnum(ruleBaseDTO.getBaseType())) {
+                    case B7: // 化验历史开单项匹配
+                        flag = CoreUtil.hasLis(ruleBaseDTO, wordCrfDTO.getLis(), bean.getFinishDateValue(), minute);
+                        break;
+                    case B8: // 化验当前开单项匹配
+                        flag = CoreUtil.hasLis(ruleBaseDTO, wordCrfDTO.getLisOrder(), bean.getFinishDateValue(), minute);
+                        break;
+                    default:
+                        break;
+                }
+            }
+            // 有任一条件满足,直接退出
+            if (flag) {
+                return;
+            }
+        }
+
+        BillMsg billMsg = MsgUtil.getCommonOtherMsg(TypeEnum.other.getName(),
+                msg, msg, TypeEnum.transfusion.getName(), null);
+        otherList.add(billMsg);
+    }
+
+
     /**
      * 比较化验——危急值(多个条件)
      *

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

@@ -316,6 +316,51 @@ public class CoreUtil {
         return null;
     }
 
+    /**
+     * 比较化验是否存在
+     *
+     * @param ruleBaseDTO
+     * @param lisList
+     * @return
+     */
+    public static boolean hasLis(RuleBaseDTO ruleBaseDTO, List<Lis> lisList, String date, Long minute) {
+        if (ListUtil.isEmpty(lisList)) {
+            return false;
+        }
+        for (Lis lis : lisList) {
+            boolean flag = CoreUtil.hasLis(ruleBaseDTO, lis, date, minute);
+            if (flag) {
+                // 存在一个有效化验就返回
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 比较化验是否匹配
+     *
+     * @param ruleBaseDTO
+     * @param lis
+     * @return
+     */
+    public static boolean hasLis(RuleBaseDTO ruleBaseDTO, Lis lis, String date, Long minute) {
+        boolean flag = false; // 规则是否匹配
+        if (lis == null) {
+            return flag;
+        }
+        String uniqueName = lis.getUniqueName();
+        // 标准名称相同
+        if (StringUtil.isNotBlank(uniqueName) && uniqueName.equals(ruleBaseDTO.getBaseLibName())) {
+            int dateFlag = CoreUtil.compareTime(date, lis.getDateValue(), minute, false, false);
+            if (dateFlag == 1) {
+                // 存在有效化验
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
     /**
      * 比较化验是否匹配
      *

+ 3 - 1
src/main/java/com/diagbot/vo/RuleVO.java

@@ -19,8 +19,10 @@ public class RuleVO {
     private String libTypeName;
     // redis后缀,默认查开单项
     private String suffix = "1";
-    // 时间
+    // 开单时间
     private String dateValue;
+    // 报告时间
+    private String finishDateValue;
     // 剂型
     private String form;
     // 给药途径医院名称