Browse Source

违规退费分析在医技科室也要使用。

xiaochan 3 years ago
parent
commit
cf71c7c5ef

+ 28 - 2
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -883,6 +883,21 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
                                       @Param("ledger") Integer ledger,
                                       @Param("detailSn") Integer detailSn);
 
+    @Select("<script>" +
+            "select code from yp_zd_dict where code in " +
+            "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
+            " #{item}" +
+            "</foreach> " +
+            " and serial = '01' and isnull(del_flag,0)  = 1 " +
+            "union all " +
+            "select code from zd_charge_item where code in " +
+            "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
+            " #{item}" +
+            "</foreach> " +
+            " and isnull(del_flag,0)  = 1" +
+            "</script>")
+    List<String> chaXunFeiYongShiFouTingYong(List<String> bianMa);
+
 
     @Delete("delete zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
             "and detail_sn = #{detailSn} and order_no <> 6 and trans_flag_yb <> 2")
@@ -898,6 +913,17 @@ 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" +
+            "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,
+                                   @Param("ledger") Integer ledger);
+
+    @Update("update zy_detail_charge set trans_flag_yb = 0 where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and  trans_flag_yb = 2")
+    void chongXingZhengFuXiangDi(@Param("inpatientNo") String inpatientNo,
+                                 @Param("admissTimes") Integer admissTimes,
+                                 @Param("ledger") Integer ledger);
+
 
     @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%' " +
@@ -1007,7 +1033,7 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
                                             @Param("riQiPaiXu") String riQiPaiXu);
 
     @Select("<script>" +
-            "select * from zy_detail_charge\n" +
+            "select * from zy_detail_charge " +
             "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag} and detail_sn in " +
             "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item}" +
@@ -1021,7 +1047,7 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
                                     @Param("list") int[] detailSnList);
 
 
-    @Select("select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_fee,charge_amount,ori_detail_sn,trans_flag_yb,exec_unit from zy_detail_charge\n" +
+    @Select("select inpatient_no,admiss_times,ledger_sn,detail_sn,charge_fee,charge_amount,ori_detail_sn,trans_flag_yb,exec_unit from zy_detail_charge " +
             "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and detail_sn = #{detailSn} " +
             "and infant_flag = #{infantFlag} and charge_fee < 0 and charge_amount < 0 ")
     ZyDetailCharge piPeiXinXiFuShu(@Param("inpatientNo") String inpatientNo,

+ 6 - 0
src/main/java/thyyxxk/webserver/entity/datamodify/ZyDetailCharge.java

@@ -269,6 +269,12 @@ public class ZyDetailCharge implements Serializable {
      */
     private String billItemName;
 
+    /**
+     * 费用 类型
+     * 0 - 项目  1 - 药品
+     */
+    private Integer feiYongType;
+
 
     /**
      * 0:全部

+ 17 - 4
src/main/java/thyyxxk/webserver/service/yibao/XiangMuLuRuService.java

@@ -304,6 +304,19 @@ public class XiangMuLuRuService {
         if (errorStr.length() > 3) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, errorStr.toString());
         }
+
+        List<String> shiFouTingYongXiangMu = new ArrayList<>();
+
+        param.getList().forEach(item -> {
+            shiFouTingYongXiangMu.add(item.getChargeCodeMx());
+        });
+
+        List<String> yiTingYong = dao.chaXunFeiYongShiFouTingYong(shiFouTingYongXiangMu);
+
+        if (ListUtil.notBlank(yiTingYong)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "项目录入错误,包含已停用的项目 【" + JSON.toJSONString(yiTingYong) + "】");
+        }
+
         // 婴儿 要特殊处理
         // 如果带有这个 $ 说明是婴儿
         int infantFlag = publicServer.getInfantFlag(param.getInpatientNo());
@@ -380,13 +393,9 @@ public class XiangMuLuRuService {
         FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(param.getList(), true);
         fy.setTotalCharge(sum);
         Integer ledgerSn = publicServer.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes());
-
         // 在此处 插入费用
         dao.chaRuFeiYong(param, param.getList(), infantFlag, ledgerSn);
-        dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_ledger_file");
-        dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
         if (ListUtil.notBlank(yaoPingShenQingDan)) {
-            log.info("shenqingdan:{}", JSON.toJSONStringWithDateFormat(yaoPingShenQingDan, DateUtil.DEFAULT_PATTERN));
             dao.shenQingYaoPing(param, yaoPingShenQingDan, infantFlag, ledgerSn, TokenUtil.getTokenUserId());
         }
         log.info("项目录入费用上传 ==》 操作人:{},数据:{}", param.getOpIdCode(), JSON.toJSONString(param));
@@ -596,6 +605,10 @@ public class XiangMuLuRuService {
 
         List<Integer> yaoPingBianMaTongBu = dao.weiGuiYaoPinInt(inpatientNo, admissTimes, ledger, infantFlag);
 
+        if (BigUtils.bigDaYu(dao.zhenFuXingDiFeiYong(inpatientNo, admissTimes, ledger), 0)) {
+            dao.chongXingZhengFuXiangDi(inpatientNo, admissTimes, ledger);
+        }
+
         if (yaoPingBianMaTongBu.size() > 0) {
             dao.genXinYaoPingPiPeiXinXi(yaoPingBianMaTongBu);
         }