Kaynağa Gözat

会诊退费问题

xiaochan 2 yıl önce
ebeveyn
işleme
51bdbb8390

+ 11 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/HuiZhenShenQingDao.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.entity.hospitalizationCosts.ZyDetailChargeTable;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
 
@@ -102,6 +103,16 @@ public interface HuiZhenShenQingDao {
                                             @Param("admissTimes") int admissTimes,
                                             @Param("actOrderNo") BigDecimal actOrderNo);
 
+    @Select("select ledger_sn, detail_sn from zy_detail_charge " +
+            "where " +
+            "inpatient_no = #{patNo} " +
+            "and admiss_times = #{times} " +
+            "and order_no = #{orderNo} and ori_detail_sn is null " +
+            "and charge_fee > 0")
+    List<ZyDetailChargeTable> selectChargeByOrderNo(String patNo,
+                                                    Integer times,
+                                                    BigDecimal orderNo);
+
 
     /**
      * 删除 会诊申请

+ 57 - 1
src/main/java/thyyxxk/webserver/service/hospitalizationCosts/HospitalizationCostsService.java

@@ -1,6 +1,5 @@
 package thyyxxk.webserver.service.hospitalizationCosts;
 
-import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.Data;
@@ -41,6 +40,31 @@ public class HospitalizationCostsService {
         private String miniUnit;
     }
 
+    @Data
+    public static class RefundParam {
+        private String patNo;
+        private Integer times;
+        /**
+         * ledgerSn 和 detailSn 加起来 使用下划线
+         */
+        private List<String> key;
+        private List<ZyDetailChargeTable> feeList;
+
+        // 3221
+        public void setFeeList(List<ZyDetailChargeTable> list) {
+            feeList = list;
+            if (ListUtil.notBlank(list)) {
+
+                if (key == null) {
+                    key = new ArrayList<>();
+                }
+                for (ZyDetailChargeTable item : list) {
+                    key.add(item.getLedgerSn() + "_" + item.getDetailSn());
+                }
+            }
+        }
+    }
+
     public HospitalizationCostsService(HospitalizationCostsDao dao, RedisLikeService redisLikeService, XiangMuLuRuDao luRuDao, PublicServer publicServer) {
         this.dao = dao;
         this.redisLikeService = redisLikeService;
@@ -269,5 +293,37 @@ public class HospitalizationCostsService {
         return clone;
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    public int thereAreNoRestrictionsOnRefunds(RefundParam param) {
+        QueryWrapper<ZyDetailChargeTable> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("inpatient_no", param.getPatNo())
+                .eq("admiss_times", param.getTimes())
+                .in("cast(ledger_sn as varchar(500)) + '_' + cast(detail_sn as varchar(500))", param.getKey())
+                .gt("charge_fee", 0)
+                .isNull("ori_detail_sn");
+
+        List<ZyDetailChargeTable> list = dao.selectList(queryWrapper);
+        if (ListUtil.isBlank(list)) {
+            return 0;
+        }
+
+        int maxDetailSn = publicServer.getMaxDetailSn(param.getPatNo(), param.getTimes());
+        List<ZyDetailChargeTable> refundOnly = new ArrayList<>();
+
+        for (ZyDetailChargeTable item : list) {
+            maxDetailSn += 1;
+            refundOnly.add(设置默认值以及自增(item, maxDetailSn, -1));
+        }
+
+        // 直接退费
+        if (ListUtil.notBlank(refundOnly)) {
+            // 插入退费数据
+            dao.insertRefundData(refundOnly);
+        }
+
+        dao.updateOriFlag(list);
+        return list.size();
+    }
+
 
 }

+ 17 - 3
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/HuiZhenShenQingService.java

@@ -13,9 +13,11 @@ import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.entity.hospitalizationCosts.ZyDetailChargeTable;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
 import thyyxxk.webserver.service.PublicServer;
+import thyyxxk.webserver.service.hospitalizationCosts.HospitalizationCostsService;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
 import thyyxxk.webserver.utils.ListUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
@@ -39,18 +41,19 @@ public class HuiZhenShenQingService {
     private final HuiZhenShenQingDao dao;
     private final PublicServer publicServer;
     private final YiZhuLuRuDao yiZhuLuRuDao;
-
     private final RedisLikeService redisLikeService;
+    private final HospitalizationCostsService refundService;
 
     private HuiZhenShenQingService getThis() {
         return SpringUtil.getBean(this.getClass());
     }
 
-    public HuiZhenShenQingService(HuiZhenShenQingDao dao, PublicServer publicServer, YiZhuLuRuDao yiZhuLuRuDao, RedisLikeService redisLikeService) {
+    public HuiZhenShenQingService(HuiZhenShenQingDao dao, PublicServer publicServer, YiZhuLuRuDao yiZhuLuRuDao, RedisLikeService redisLikeService, HospitalizationCostsService h) {
         this.dao = dao;
         this.publicServer = publicServer;
         this.yiZhuLuRuDao = yiZhuLuRuDao;
         this.redisLikeService = redisLikeService;
+        this.refundService = h;
     }
 
     /**
@@ -151,13 +154,24 @@ public class HuiZhenShenQingService {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该会诊已经完成了无法删除。");
         }
 
+        List<ZyDetailChargeTable> zy = dao.selectChargeByOrderNo(inpatientNo, admissTimes, actOrderNo);
+        int count = 0;
+
+        if (ListUtil.notBlank(zy)) {
+            HospitalizationCostsService.RefundParam param = new HospitalizationCostsService.RefundParam();
+            param.setPatNo(inpatientNo);
+            param.setTimes(admissTimes);
+            param.setFeeList(zy);
+            count = refundService.thereAreNoRestrictionsOnRefunds(param);
+        }
 
         //会诊申请是根据 住院号,住院次数,申请次数 来获取到 一条
         dao.shanChuShenQing(inpatientNo, admissTimes, reqTimes);
         //医嘱 只要根据医嘱号来删除
         dao.shanChuYiZhu(actOrderNo);
         log.info("删除会诊申请==》操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(huiZhenXinXi.get(0)));
-        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "删除成功");
+        String message = count > 0 ? "删除成功,会诊费用已退费。" : "删除成功";
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, message);
     }
 
     /**