Jelajahi Sumber

医嘱时间修改中开始时间不能小于住院时间。

xiaochan 3 tahun lalu
induk
melakukan
07788ee179

+ 5 - 0
src/main/java/thyyxxk/webserver/dao/his/datamodify/YzActOrderModifyVerifyDao.java

@@ -79,4 +79,9 @@ public interface YzActOrderModifyVerifyDao extends BaseMapper<TYzActOrderModify>
     @Select("select count(inpatient_no) count,inpatient_no from t_yz_act_order_modify where audit_flag = 1  group by inpatient_no HAVING count(*) >= 5")
     List<TYzActOrderModify> getCount();
 
+    @Select("select admiss_date " +
+            "from zy_actpatien " +
+            "where inpatient_no = #{patNo} ")
+    Date huanZaiRuYuanShiJian(@Param("patNo") String patNo);
+
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/service/casefrontsheet/HuiZhenShenQingService.java

@@ -76,6 +76,7 @@ public class HuiZhenShenQingService {
         dao.chaRuHuiZhenShenQing(param);
         //申请成功了就还需要插入一条医嘱
         dao.chaRuYiZhu(param);
+        log.info("插入数据:{}", JSON.toJSONString(param));
 
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "会诊申请成功,正在通知会诊医生。 <p>(〜^㉨^)〜</p>");
     }
@@ -118,7 +119,6 @@ public class HuiZhenShenQingService {
      * @return 返回 医生的code 和 name
      */
     public ResultVo<List<GetDropdownBox>> huiZhenYiSheng(String deptCode, String hzType) {
-        log.info("查询会诊医生==》科室:{},级别:{}", deptCode, "00" + hzType);
         return ResultVoUtil.success(dao.huiZhenYiSheng(deptCode, "00" + hzType));
     }
 

+ 13 - 0
src/main/java/thyyxxk/webserver/service/datamodify/YzActOrderModifyVerifyService.java

@@ -13,12 +13,14 @@ import thyyxxk.webserver.constants.GetDateFormat;
 import thyyxxk.webserver.dao.his.datamodify.YzActOrderModifyVerifyDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.TYzActOrderModify;
+import thyyxxk.webserver.utils.DateUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
 import thyyxxk.webserver.utils.TokenUtil;
 import thyyxxk.webserver.websocket.WebSocketServer;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * <p>
@@ -99,6 +101,8 @@ public class YzActOrderModifyVerifyService {
         return dao.selectOne(qw);
     }
 
+
+
     /**
      * 审核判断要执行哪些动作
      *
@@ -113,6 +117,15 @@ public class YzActOrderModifyVerifyService {
         JSONObject obj = new JSONObject();
         obj.put("name", "systemNotification");
         if (auditFlag == YZ_APPROVED) {
+            Date admissDate = dao.huanZaiRuYuanShiJian(pojo.getInpatientNo());
+            // 开始时间不能小于于入院时间
+            if (DateUtil.shiJianDaXiao(pojo.getStartTime(), admissDate, "<")) {
+                dao.shenHeZhuangTaiGaiBian(YZ_REJECT, TokenUtil.getTokenUserId(), actOrderNo, "开始时间不能在入院时间之前。");
+                obj.put("type", "error");
+                obj.put("message", String.format("用户【%s】,医嘱号为【%s】已驳回,<br>驳回原因:%s", pojo.getProposerName(), actOrderNo, "开始时间不能在入院时间之前。"));
+                log.info("医嘱修改审核 --> 操作:{自动驳回},操作员:{},驳回医嘱号:{}", TokenUtil.getTokenUserId(), pojo.getActOrderNo());
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "开始时间不能在入院时间之前,已自动驳回。");
+            }
             if (judgeTheTime(pojo)) {
                 dao.shenHeZhuangTaiGaiBian(YZ_REJECT, TokenUtil.getTokenUserId(), actOrderNo, "结束时间不能在开始时间前面。");
                 obj.put("type", "error");

+ 41 - 1
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.utils;
 
 import lombok.extern.slf4j.Slf4j;
+import thyyxxk.webserver.constants.GetDateFormat;
 
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -46,6 +47,16 @@ public class DateUtil {
         return new Date();
     }
 
+    public static Date parse(String source, String pattern) {
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        try {
+            return sdf.parse(source);
+        } catch (ParseException e) {
+            log.error("将字符串转换成日期出错", e);
+        }
+        return new Date();
+    }
+
     public static long getTimestamp(String datetime) throws ParseException {
         DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         return df.parse(datetime).getTime();
@@ -172,7 +183,36 @@ public class DateUtil {
     }
 
     public static Boolean shiJianDaXiao(String startTime, String endTime, String yunSuanFu) {
-        return shiJianDaXiao(parse(startTime), parse(endTime), yunSuanFu);
+        if (dateStrIsValid(startTime, GetDateFormat.DATE_TIME) && dateStrIsValid(endTime, GetDateFormat.DATE_TIME)) {
+            return shiJianDaXiao(parse(startTime), parse(endTime), yunSuanFu);
+        } else if (dateStrIsValid(startTime, GetDateFormat.TIME) && dateStrIsValid(endTime, GetDateFormat.TIME)) {
+            return shiJianDaXiao(parse(startTime, GetDateFormat.TIME), parse(endTime, GetDateFormat.TIME), yunSuanFu);
+        } else if (dateStrIsValid(startTime, GetDateFormat.DATE) && dateStrIsValid(endTime, GetDateFormat.DATE)) {
+            return shiJianDaXiao(parse(startTime, GetDateFormat.DATE), parse(endTime, GetDateFormat.DATE), yunSuanFu);
+        } else {
+            log.info("日期格式错误");
+            return false;
+        }
+    }
+
+    /**
+     * 验证字符串是否为指定日期格式
+     *
+     * @param rawDateStr 待验证字符串
+     * @param pattern    日期字符串格式, 例如 "yyyy-MM-dd"
+     * @return 有效性结果, true 为正确, false 为错误
+     */
+    public static boolean dateStrIsValid(String rawDateStr, String pattern) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
+        Date date = null;
+        try {
+            // 转化为 Date类型测试判断
+            date = dateFormat.parse(rawDateStr);
+            return rawDateStr.equals(dateFormat.format(date));
+        } catch (ParseException e) {
+            return false;
+        }
+
     }
 
     /**