Browse Source

医嘱限制开一个

xiaochan 1 year ago
parent
commit
32aad3e27d

+ 27 - 0
src/main/java/thyyxxk/webserver/controller/CacheFlushedController.java

@@ -0,0 +1,27 @@
+package thyyxxk.webserver.controller;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+@RequestMapping("/cache/flushed")
+@RestController
+public class CacheFlushedController {
+
+    private RedisLikeService redisLikeService;
+
+    public CacheFlushedController(RedisLikeService redisLikeService) {
+        this.redisLikeService = redisLikeService;
+    }
+
+    @GetMapping("/specialMedicalAdvice")
+    @PassToken
+    public ResultVo<Boolean> specialMedicalAdvice() {
+        redisLikeService.refreshSpecialMedicalAdvice();
+        return ResultVoUtil.success(true);
+    }
+}

+ 0 - 1
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/emr/EmrAuditController.java

@@ -7,7 +7,6 @@ import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrAuditDetail;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrSetAudit;
 import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrAuditServer;
 
-import javax.annotation.PostConstruct;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;

+ 7 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -1488,4 +1488,11 @@ public interface YiZhuLuRuDao {
     @Select("select count(1) from yz_order_frequency where code = #{code}")
     int getTheFrequency(@Param("code") String code);
 
+    @Select("select item_name, order_code , count from yz_zd_order_item_confirm ")
+    List<YzZdOrderItemConfirm> selectYzItemConfirm();
+
+    @Select("select count(1) from yz_act_order where inpatient_no = '${patNo}' and admiss_times = ${times} and " +
+            "order_code = '${orderCode}' and serial = '00'")
+    Integer selectCountByOrderCode(String patNo,Integer times ,String orderCode);
+
 }

+ 32 - 0
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/yizhuluru/YzZdOrderItemConfirm.java

@@ -0,0 +1,32 @@
+package thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru;
+
+import java.io.Serializable;
+import lombok.Data;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+@Data
+@TableName(value = "yz_zd_order_item_confirm")
+public class YzZdOrderItemConfirm  implements Serializable {
+
+	private static final long serialVersionUID =  2090332477932407976L;
+
+	/**
+	 * itemName
+	 */
+	@TableField(value = "item_name")
+	private String itemName;
+
+	/**
+	 * orderCode
+	 */
+	@TableField(value = "order_code")
+	private String orderCode;
+
+	/**
+	 * count
+	 */
+	@TableField(value = "count")
+	private Integer count;
+
+}

+ 0 - 1
src/main/java/thyyxxk/webserver/service/inpatient/casefrontsheet/CaseFrontSheetMainService.java

@@ -33,7 +33,6 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @Service

+ 28 - 1
src/main/java/thyyxxk/webserver/service/redislike/RedisLikeService.java

@@ -3,20 +3,29 @@ package thyyxxk.webserver.service.redislike;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.dao.his.redislike.RedisLikeDao;
+import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.YzZdOrderItemConfirm;
 import thyyxxk.webserver.service.TokenService;
 import thyyxxk.webserver.service.externalhttp.CorpWxSrvc;
 import thyyxxk.webserver.utils.StringUtil;
 import thyyxxk.webserver.utils.TokenUtil;
 
+import javax.annotation.PostConstruct;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @Service
 @Slf4j
+@Component
 public class RedisLikeService {
 
     public final static String SCROLLING_MESSAGES = "scrollingMessages";
@@ -33,8 +42,11 @@ public class RedisLikeService {
     private final static Map<String, UserInfo> USER_MAP = new HashMap<>();
     private final static Map<String, String> YB_CONTACT_RELATION_MAP = new HashMap<>();
     private final static Map<String, String> YB_DEPT_MAP = new HashMap<>();
+
+    public static final Map<String, YzZdOrderItemConfirm> specialMedicalAdvice = new HashMap<>();
     private final RedisLikeDao dao;
     private final CorpWxSrvc srvc;
+    private final YiZhuLuRuDao yzDao;
     private final TokenService tokenService;
 
     private final static Map<String, String> MESSAGE = new HashMap<>(2);
@@ -47,9 +59,10 @@ public class RedisLikeService {
         return MESSAGE;
     }
 
-    public RedisLikeService(RedisLikeDao dao, CorpWxSrvc srvc, TokenService tokenService) {
+    public RedisLikeService(RedisLikeDao dao, CorpWxSrvc srvc, YiZhuLuRuDao yzDao, TokenService tokenService) {
         this.dao = dao;
         this.srvc = srvc;
+        this.yzDao = yzDao;
         this.tokenService = tokenService;
     }
 
@@ -248,4 +261,18 @@ public class RedisLikeService {
         USER_MAP.remove(code);
         getUserInfoByCode(code);
     }
+
+    @PostConstruct
+    public void initSpecialMedicalAdvice() {
+        refreshSpecialMedicalAdvice();
+    }
+
+    @Scheduled(cron = "0 0 0 * * ?")
+    public void refreshSpecialMedicalAdvice() {
+        specialMedicalAdvice.clear();
+        List<YzZdOrderItemConfirm> list = yzDao.selectYzItemConfirm();
+        list.forEach(item -> {
+            specialMedicalAdvice.put(item.getOrderCode(), item);
+        });
+    }
 }

+ 10 - 1
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/yizhuverify/YiZhuCheckData.java

@@ -6,6 +6,8 @@ import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYzActOrder;
+import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.YzZdOrderItemConfirm;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
 import thyyxxk.webserver.utils.*;
 
 import java.util.*;
@@ -132,6 +134,14 @@ public class YiZhuCheckData {
     private void itemCheck(XinZhenYzActOrder item) {
         List<XinZhenYzActOrder> projectDetails = project.get(item.getOrderCode(), dao::itemDataOne);
         String ZK_CODE = "06286";
+        Map<String, YzZdOrderItemConfirm> specialMedicalAdvice = RedisLikeService.specialMedicalAdvice;
+        if (strictVerification && specialMedicalAdvice.containsKey(item.getOrderCode())) {
+            YzZdOrderItemConfirm confirm = specialMedicalAdvice.get(item.getOrderCode());
+            if (confirm.getCount() > 0 && dao.selectCountByOrderCode(patientInformation.getInpatientNo(), patientInformation.getAdmissTimes(), item.getOrderCode()) > confirm.getCount()) {
+                errorMessage.add("该医嘱只能开一条,请先作废上一条医嘱");
+            }
+        }
+
         if (ZK_CODE.equals(item.getOrderCode())) {
             if (StringUtil.isBlank(item.getZkWardCode())) {
                 errorMessage.add("转科病房不能为空");
@@ -259,7 +269,6 @@ public class YiZhuCheckData {
         }
 
 
-
     }
 
     private void strictVerificationFunc(XinZhenYzActOrder item) {