Browse Source

icu 特殊一点 需要和 医技科室 一样。

xiaochan 3 years ago
parent
commit
ead290414b

+ 3 - 2
src/main/java/thyyxxk/webserver/controller/yibao/XiangMuLuRuController.java

@@ -85,8 +85,9 @@ public class XiangMuLuRuController {
 
     @GetMapping("/yiZhuTuiFeiPiPei")
     public ResultVo<String> yiZhuTuiFeiPiPei(@RequestParam("inpatientNo") String inpatientNo,
-                                             @RequestParam("admissTimes") Integer admissTimes) {
-        return service.yiZhuTuiFeiPiPei(inpatientNo, admissTimes);
+                                             @RequestParam("admissTimes") Integer admissTimes,
+                                             @RequestParam("deptCode") String deptCode) {
+        return service.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, deptCode);
     }
 
     @GetMapping("/shanChuMuBan")

+ 3 - 0
src/main/java/thyyxxk/webserver/dao/his/PublicDao.java

@@ -147,4 +147,7 @@ public interface PublicDao {
     @Select("select top(1) code,dept_code,name,code_rs from a_employee_mi where (code = #{code}  or code_rs = #{code}) and isnull(del_flag,0) = 0 ")
     UserInfo huoQuYuanGongXinXi(String code);
 
+    @Select("SELECT small_dept FROM zd_dept_all where dept = #{deptCode}")
+    List<String> huoQuBingFanhKeShi(String deptCode);
+
 }

+ 25 - 10
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -821,14 +821,23 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
      * @param ZF          正的费用还是负的费用
      * @return 返回list 费用集合
      */
-    @Select("select charge_date,charge_fee,charge_amount,charge_code_mx,detail_sn,ori_detail_sn,ABS(order_no),order_no,ledger_sn,exec_unit " +
+    @Select("<script>" +
+            "select charge_date,charge_fee,charge_amount,charge_code_mx,detail_sn,ori_detail_sn,ABS(order_no),order_no,ledger_sn,exec_unit " +
             "from zy_detail_charge where  inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and  ledger_sn = #{ledgerSn}  " +
-            "and ori_detail_sn is null and charge_amount ${ZF} 0 and charge_fee ${ZF} 0 and ledger_sn > 0 and infant_flag = #{infantFlag} and trans_flag_yb <> 2")
+            "and ori_detail_sn is null and charge_amount ${ZF} 0 and charge_fee ${ZF} 0 and infant_flag = #{infantFlag} and trans_flag_yb &lt;&gt; 2 " +
+            "<if test=\"list.size >0 \">" +
+            "and exec_unit in " +
+            "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
+            "#{item}" +
+            "</foreach>" +
+            "</if>" +
+            "</script>")
     List<ZyDetailCharge> getYiZhuFeiYong(@Param("inpatientNo") String inpatientNo,
                                          @Param("admissTimes") Integer admissTimes,
                                          @Param("ledgerSn") Integer ledgerSn,
                                          @Param("ZF") String ZF,
-                                         @Param("infantFlag") int infantFlag);
+                                         @Param("infantFlag") int infantFlag,
+                                         @Param("list") List<String> list);
 
     /**
      * @param inpatientNo 住院号
@@ -1003,16 +1012,19 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
             "  and charge_fee &lt; 0 and charge_code not like 'BILL%' " +
             "  and  trans_flag_yb not in (1,2) " +
-            "  and ori_detail_sn is null" +
-            "<if test=\"execUnit != null and execUnit != '' \">" +
-            " and exec_unit = #{execUnit} " +
+            "  and ori_detail_sn is null " +
+            "<if test=\"list.size >0 \">" +
+            " and exec_unit in " +
+            "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
+            "#{item}" +
+            "</foreach>" +
             "</if>" +
             "</script>")
     List<ZyDetailCharge> weiXieDaiYuanLiuShuiXiangMu(@Param("inpatientNo") String inpatientNo,
                                                      @Param("admissTimes") Integer admissTimes,
                                                      @Param("ledger") Integer ledger,
                                                      @Param("infantFlag") Integer infantFlag,
-                                                     @Param("execUnit") String execUnit);
+                                                     @Param("list") List<String> execUnit);
 
     @Select("<script>" +
             "select rtrim(inpatient_no) inpatient_no,admiss_times,ledger_sn,charge_code_mx,detail_sn,ori_detail_sn,charge_fee,charge_amount, " +
@@ -1023,15 +1035,18 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "  and charge_fee &lt; 0 and charge_code  like 'BILL%' " +
             "  and  trans_flag_yb not in (1,2) " +
             "  and ori_detail_sn is null" +
-            "<if test=\"execUnit != null and execUnit != '' \">" +
-            " and exec_unit = #{execUnit} " +
+            "<if test=\"list.size >0 \">" +
+            " and exec_unit in " +
+            "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
+            "#{item}" +
+            "</foreach>" +
             "</if>" +
             "</script>")
     List<ZyDetailCharge> weiXieDaiYuanLiuShuiYaoPing(@Param("inpatientNo") String inpatientNo,
                                                      @Param("admissTimes") Integer admissTimes,
                                                      @Param("ledger") Integer ledger,
                                                      @Param("infantFlag") Integer infantFlag,
-                                                     @Param("execUnit") String execUnit);
+                                                     @Param("list") List<String> execUnit);
 
     @Select("<script>" +
             "select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_amount,charge_fee,charge_code_mx,charge_date " +

+ 18 - 0
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -111,6 +111,12 @@ public class PublicServer {
         return dao.getKeShiLieBiao(deptCode);
     }
 
+    /**
+     * 获取科室的子科室和本科
+     *
+     * @param deptCodeList 科室代码
+     * @return 返回科室
+     */
     public List<String> getKeShiLieBiaoList(List<String> deptCodeList) {
         if (ListUtil.isBlank(deptCodeList)) {
             return new ArrayList<>();
@@ -184,5 +190,17 @@ public class PublicServer {
         return dao.huoQuYuanGongXinXi(code);
     }
 
+
+    public List<String> huoQuBingFangDeKeShi(String deptCode) {
+        if (getRoleCode().getData().contains(1) || StringUtil.isBlank(deptCode)) {
+            return new ArrayList<>();
+        }
+        List<String> keShiDaiMa = dao.huoQuBingFanhKeShi(deptCode);
+        if (ListUtil.isBlank(keShiDaiMa)) {
+            keShiDaiMa.add(deptCode);
+        }
+        return keShiDaiMa;
+    }
+
 }
 

+ 22 - 11
src/main/java/thyyxxk/webserver/service/yibao/XiangMuLuRuService.java

@@ -148,6 +148,9 @@ public class XiangMuLuRuService {
 
         List<Integer> genXingZhenShuTuiFeiLiuShui = new ArrayList<>();
         List<ZyDetailCharge> tuiFeiList = new ArrayList<>();
+        // 获取到用户角色   管理员角色可以无视
+        List<Integer> yongHuJueSe = dao.huoQuJueSe(TokenUtil.getTokenUserId());
+        List<String> zhiXinKeShi = dao.chaXunZhiZXinKeShi(param.getDeptCode());
         for (ZyDetailCharge pojo : yuanTuiFeiList) {
             // 判断患者的费用是否存在负数
             if (pojo.getChargeFee().signum() == -1 || pojo.getChargeAmount().signum() == -1) {
@@ -157,7 +160,7 @@ public class XiangMuLuRuService {
                 yaoPingDan.add(pojo);
             }
             // 在这里判断执行科室
-            ResultVo<String> LOGICAL_ERROR = getStringResultVo(param, pojo);
+            ResultVo<String> LOGICAL_ERROR = getStringResultVo(yongHuJueSe, zhiXinKeShi, param, pojo);
             if (LOGICAL_ERROR != null) return LOGICAL_ERROR;
             // 数据库有个 触发器 如果带了医嘱号且有篆刻那么这里就需要改成 0
             if (BigUtils.bigDaYu(pojo.getOrderNo(), 10)) {
@@ -197,14 +200,13 @@ public class XiangMuLuRuService {
         }
     }
 
-    private ResultVo<String> getStringResultVo(ZyDetailCharge xuYaoTuiDeShuJu, ZyDetailCharge piPeiDeShuJu) {
+    private ResultVo<String> getStringResultVo(List<Integer> yongHuJueSe, List<String> zhiXinKeShi, ZyDetailCharge xuYaoTuiDeShuJu,
+                                               ZyDetailCharge piPeiDeShuJu) {
         // 获取到用户角色   管理员角色可以无视
-        List<Integer> yongHuJueSe = dao.huoQuJueSe(TokenUtil.getTokenUserId());
         if (!yongHuJueSe.contains(1)) {
             // 科室开头 是 8 就不是医技科室 只有医技科室可以退药品
             if (xuYaoTuiDeShuJu.getDeptCode().startsWith("8")) {
                 //获取到这个人是否属于这个科室
-                List<String> zhiXinKeShi = dao.chaXunZhiZXinKeShi(xuYaoTuiDeShuJu.getDeptCode());
                 if (!zhiXinKeShi.contains(piPeiDeShuJu.getExecUnit())) {
                     return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。<br/>( ´Д`)y━・~~", piPeiDeShuJu.getDetailSn()));
                 }
@@ -214,7 +216,6 @@ public class XiangMuLuRuService {
                         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,包含药品费用,无法退费。<br/>( ´Д`)y━・~~", piPeiDeShuJu.getDetailSn()));
                     }
                 }
-
             } else if (!xuYaoTuiDeShuJu.getDeptCode().equals(piPeiDeShuJu.getExecUnit())) {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。<br/>( ´Д`)y━・~~", piPeiDeShuJu.getDetailSn()));
             }
@@ -450,15 +451,17 @@ public class XiangMuLuRuService {
      * @return 返回是否匹配成功
      */
     @Transactional(rollbackFor = Exception.class)
-    public ResultVo<String> yiZhuTuiFeiPiPei(String inpatientNo, Integer admissTimes) {
+    public ResultVo<String> yiZhuTuiFeiPiPei(String inpatientNo, Integer admissTimes, String deptCode) {
         int infantFlag = publicServer.getInfantFlag(inpatientNo);
         inpatientNo = publicServer.getInpatientNo(inpatientNo);
         Integer ledgerSn = publicServer.getLedgerSn(inpatientNo, admissTimes);
 
+        List<String> keShiLeiBiao = publicServer.huoQuBingFangDeKeShi(deptCode);
+
         // 获取正的医嘱费用
-        List<ZyDetailCharge> getYiZhuFeiYongZhenShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, ">", infantFlag);
+        List<ZyDetailCharge> getYiZhuFeiYongZhenShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, ">", infantFlag, keShiLeiBiao);
         // 获取负的医嘱费用
-        List<ZyDetailCharge> getYiZhuFeiYongFuShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, "<", infantFlag);
+        List<ZyDetailCharge> getYiZhuFeiYongFuShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, "<", infantFlag, keShiLeiBiao);
         // 获取负数的退费数据 主要是用来判断 这一条正的是否退费了。
         List<ZyDetailCharge> tuiFeiList = dao.tuiFeiList(inpatientNo, admissTimes, infantFlag);
         if (!tuiFeiList.isEmpty()) {
@@ -604,6 +607,12 @@ public class XiangMuLuRuService {
         int infantFlag = publicServer.getInfantFlag(inpatientNo);
         Integer ledger = publicServer.getLedgerSn(inpatientNo, admissTimes);
 
+        log.info("查询违规费用 =>>住院号{}次数{}执行科室{}", inpatientNo, admissTimes, execUnit);
+
+        List<String> keShi = publicServer.huoQuBingFangDeKeShi(execUnit);
+
+        publicServer.genXingYuanLiuShuiBiaoZhi(inpatientNo, admissTimes, ledger);
+
         WeiGuiFeiYongFenXi weiGuiFeiYongFenXi = new WeiGuiFeiYongFenXi();
         weiGuiFeiYongFenXi.setWeiPiPei(new ArrayList<>());
         weiGuiFeiYongFenXi.setWeiXieDaiYuanLiuShui(new ArrayList<>());
@@ -623,8 +632,8 @@ public class XiangMuLuRuService {
         }
         weiGuiFeiYongFenXi.getWeiPiPei().addAll(dao.weiGuiYaoPin(inpatientNo, admissTimes, ledger, infantFlag));
         weiGuiFeiYongFenXi.getWeiPiPei().addAll(dao.weiGuiXiangMu(inpatientNo, admissTimes, ledger, infantFlag));
-        weiGuiFeiYongFenXi.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiXiangMu(inpatientNo, admissTimes, ledger, infantFlag, execUnit));
-        weiGuiFeiYongFenXi.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiYaoPing(inpatientNo, admissTimes, ledger, infantFlag, execUnit));
+        weiGuiFeiYongFenXi.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiXiangMu(inpatientNo, admissTimes, ledger, infantFlag, keShi));
+        weiGuiFeiYongFenXi.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiYaoPing(inpatientNo, admissTimes, ledger, infantFlag, keShi));
         return ResultVoUtil.success(weiGuiFeiYongFenXi);
     }
 
@@ -654,8 +663,10 @@ public class XiangMuLuRuService {
         List<ZyDetailCharge> shuJuXinXi = dao.piPeiXinXi(inpatientNo, zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn(), infantFlag, detailSnList);
         BigDecimal chargeFeeSum = new BigDecimal(0);
         BigDecimal chargeAmountSum = new BigDecimal(0);
+        List<Integer> yongHuJueSe = dao.huoQuJueSe(TokenUtil.getTokenUserId());
+        List<String> zhiXinKeShi = dao.chaXunZhiZXinKeShi(zyDetailCharge.getDeptCode());
         for (ZyDetailCharge detailCharge : shuJuXinXi) {
-            ResultVo<String> LOGICAL_ERROR = getStringResultVo(zyDetailCharge, detailCharge);
+            ResultVo<String> LOGICAL_ERROR = getStringResultVo(yongHuJueSe, zhiXinKeShi, zyDetailCharge, detailCharge);
             if (LOGICAL_ERROR != null) return LOGICAL_ERROR;
             if (detailCharge.getOriDetailSn() != null || detailCharge.getTransFlagYb().equals("2")) {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为:{%d},已被退费请重新选择。", detailCharge.getDetailSn()));