Bläddra i källkod

医嘱录入中复制父医嘱也可以复制子医嘱

DESKTOP-0GD05B0\Administrator 2 år sedan
förälder
incheckning
f51e34fd58

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/YizhuLuRuController.java

@@ -229,4 +229,9 @@ public class YizhuLuRuController {
         return server.confirmTheDoctorSOrderWithMedicine(patNo, times);
     }
 
+    @GetMapping("/copyTheDoctorSOrder")
+    public ResultVo<String> copyTheDoctorSOrder(@RequestParam("orderNo") BigDecimal orderNo) {
+        return server.copyTheDoctorSOrder(orderNo);
+    }
+
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -165,7 +165,7 @@ public class PublicServer {
         BigDecimal newId = oldId.add(BigDecimal.ONE);
         int num = dao.updateActOrderNo(newId, oldId);
         if (num == 0) {
-            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "生成医嘱号错误请重新,请重试!");
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "生成医嘱号错误,请重试!");
         }
         return newId;
     }

+ 50 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -1637,5 +1637,55 @@ public class YiZhuLuRuServer {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
 
+    public ResultVo<String> copyTheDoctorSOrder(BigDecimal orderNo) {
+        QueryWrapper<?> qw = new QueryWrapper<>();
+        qw.eq("a.act_order_no", orderNo);
+        List<XinZhenYzActOrder> yiZhuList = dao.selectOrderNo(qw);
+        if (ListUtil.isBlank(yiZhuList)) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "原医嘱已经不存在了。");
+        }
+        XinZhenYzActOrder fatherOrder = yiZhuList.get(0);
+        QueryWrapper<?> childQw = new QueryWrapper<>();
+        childQw.eq("a.parent_no", fatherOrder.getActOrderNo());
+        List<XinZhenYzActOrder> childOrderList = dao.selectOrderNo(childQw);
+        UserInfo us = redisLikeService.getUserInfoByToken();
+        revertToTheDefaultState(fatherOrder, us, null);
+
+        List<XinZhenYzActOrder> addOrderList = new ArrayList<>();
+        addOrderList.add(fatherOrder);
+
+        if (ListUtil.notBlank(childOrderList)) {
+            childOrderList.forEach(item -> {
+                revertToTheDefaultState(item, us, fatherOrder.getActOrderNo());
+                addOrderList.add(item);
+            });
+        }
+
+        XinZhenYiZhu patInfo = dao.queryPatientInfo(fatherOrder.getInpatientNo(), fatherOrder.getAdmissTimes());
+        getThis().insertATemplate(addOrderList, patInfo);
+        return ResultVoUtil.success();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void insertATemplate(List<XinZhenYzActOrder> list, XinZhenYiZhu patInfo) {
+        String userCode = TokenUtil.getTokenUserId();
+        list.forEach(item -> {
+            dao.insertEntryOrder(patInfo, item, userCode);
+        });
+    }
+
+    private void revertToTheDefaultState(XinZhenYzActOrder param, UserInfo us, BigDecimal parentNo) {
+        param.setActOrderNo(publicServer.getActOrderNo());
+        param.setStatusFlag("1");
+        Date newDate = new Date();
+        param.setOrderTime(newDate);
+        param.setStartTime(newDate);
+        param.setEndTime(null);
+        param.setEnterOper(us.getCode());
+        param.setSigner("");
+        param.setModifier("");
+        param.setParentNo(parentNo);
+    }
+
 
 }