소스 검색

解决这个退费医嘱没有执行科室 的bug。

xiaochan 3 년 전
부모
커밋
86c77f8eee

+ 19 - 1
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -914,7 +914,7 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
                                      @Param("ledger") Integer ledger,
                                      @Param("detailSn") Integer detailSn);
 
-    @Select("select isnull(sum(charge_fee),0)  from zy_detail_charge\n" +
+    @Select("select isnull(sum(charge_fee),0)  from zy_detail_charge  " +
             "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and trans_flag_yb=2")
     BigDecimal zhenFuXingDiFeiYong(@Param("inpatientNo") String inpatientNo,
                                    @Param("admissTimes") Integer admissTimes,
@@ -925,6 +925,24 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
                                  @Param("admissTimes") Integer admissTimes,
                                  @Param("ledger") Integer ledger);
 
+    @Select("select act_order_no as order_no,exec_unit from yz_erase_order where act_order_no in  " +
+            "(select order_no from zy_detail_charge where  inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and charge_code like 'BILL%'  " +
+            "and exec_unit is null AND charge_fee < 0 and ori_detail_sn is null)")
+    List<ZyDetailCharge> huoQuYaoPingZhongKeShiWeiKongDe(@Param("inpatientNo") String inpatientNo,
+                                                         @Param("admissTimes") Integer admissTimes,
+                                                         @Param("ledger") Integer ledger);
+
+    @Update("<script>" +
+            " <foreach collection='list' item='item' separator=';' >" +
+            "update zy_detail_charge set exec_unit = #{item.execUnit}  where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
+            "and order_no = #{item.orderNo} and exec_unit is null  and charge_fee &lt; 0" +
+            "</foreach> " +
+            "</script> ")
+    void yiZhuTuiFeiGenXingZhiXingKeShi(@Param("inpatientNo") String inpatientNo,
+                                        @Param("admissTimes") Integer admissTimes,
+                                        @Param("ledger") Integer ledger,
+                                        @Param("list") List<ZyDetailCharge> map);
+
 
     @Select("select b.code from zy_detail_charge a, yp_zd_dict b " +
             "where order_no <> 6 and trans_flag_yb not in (1,2)  and charge_code like 'BILL%' " +

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

@@ -605,12 +605,15 @@ public class XiangMuLuRuService {
         weiGuiFeiYongFenXi.setWeiPiPei(new ArrayList<>());
         weiGuiFeiYongFenXi.setWeiXieDaiYuanLiuShui(new ArrayList<>());
 
+        // 药品 分大包装和小包装 可能大包装 匹配了 小包装没有 匹配 所以这里编码同步 一下
         List<Integer> yaoPingBianMaTongBu = dao.weiGuiYaoPinInt(inpatientNo, admissTimes, ledger, infantFlag);
-
         if (BigUtils.bigDaYu(dao.zhenFuXingDiFeiYong(inpatientNo, admissTimes, ledger), 0)) {
             dao.chongXingZhengFuXiangDi(inpatientNo, admissTimes, ledger);
         }
-
+        List<ZyDetailCharge> huoQuYaoPingZhongKeShiWeiKongDe = dao.huoQuYaoPingZhongKeShiWeiKongDe(inpatientNo, admissTimes, ledger);
+        if (!huoQuYaoPingZhongKeShiWeiKongDe.isEmpty()) {
+            dao.yiZhuTuiFeiGenXingZhiXingKeShi(inpatientNo, admissTimes, ledger, huoQuYaoPingZhongKeShiWeiKongDe);
+        }
         if (yaoPingBianMaTongBu.size() > 0) {
             dao.genXinYaoPingPiPeiXinXi(yaoPingBianMaTongBu);
         }
@@ -661,18 +664,20 @@ public class XiangMuLuRuService {
             if (shuJuXinXi.size() == 1) {
                 dao.zhiYouYiGeJiuGenXingFuShuLiuShui(zyDetailCharge.getInpatientNo(), zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn(), zyDetailCharge.getDetailSn(), shuJuXinXi.get(0).getDetailSn());
                 publicServer.genXingYuanLiuShuiBiaoZhi(inpatientNo, zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn());
+                return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用匹配成功。");
             } else {
                 ResultVo<String> tuiFei = xiangMuTuiFei(zyDetailCharge);
                 if (tuiFei.getCode() != 201) {
                     return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, tuiFei.getMessage());
                 }
                 dao.cheXiaoFeiYong(inpatientNo, zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn(), zyDetailCharge.getDetailSn());
+                return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用拆分成功。");
             }
-        } else {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
-                    String.format("负数费用:{%.2f},匹配费用:{%.2f} <br> 负数数量:{%.2f},匹配数量:{%.2f}", zy.getChargeFee().negate(), chargeFeeSum, zy.getChargeAmount().negate(), chargeAmountSum));
         }
-        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用拆分成功。");
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
+                String.format("负数费用:{%.2f},匹配费用:{%.2f} <br> 负数数量:{%.2f},匹配数量:{%.2f}", zy.getChargeFee().negate(), chargeFeeSum, zy.getChargeAmount().negate(), chargeAmountSum));
+
+
     }
 }