Browse Source

出院计算时判断是否有不在住院时间内的费用。

lighter 3 years ago
parent
commit
06fb44318c

+ 14 - 6
src/main/java/thyyxxk/webserver/dao/his/yibao/DismissDao.java

@@ -6,6 +6,7 @@ import thyyxxk.webserver.entity.yibao.dismiss.ActOrderDetail;
 import thyyxxk.webserver.entity.yibao.dismiss.NegativeFee;
 import thyyxxk.webserver.entity.yibao.dismiss.ReceiptFee;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -121,14 +122,21 @@ public interface DismissDao {
     Integer countDisActOrders2(@Param("patNo") String patNo, @Param("times") Integer times);
 
     @Select("select (select isnull(sum(charge_fee),0) from zy_detail_charge where inpatient_no=#{patNo} " +
-            "AND admiss_times=#{times} AND ledger_sn=#{ledgerSn} and isnull(charge_status, '1') <> '1' " +
-            "and charge_date>=#{begntime} and charge_date<=#{endtime})-(select isnull(total_charge,0) from zy_ledger_file " +
+            "and admiss_times=#{times} and ledger_sn=#{ledgerSn} and isnull(charge_status, '1') <> '1') - " +
+            "(select isnull(total_charge,0) from zy_ledger_file " +
             "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn})")
-    int getFeeOffset(@Param("patNo") String patNo,
+    BigDecimal getFeeOffset(@Param("patNo") String patNo,
                      @Param("times") Integer times,
-                     @Param("ledgerSn") int ledgerSn,
-                     @Param("begntime") Date begntime,
-                     @Param("endtime") Date endtime);
+                     @Param("ledgerSn") int ledgerSn);
+
+    @Select("select isnull(sum(charge_fee),0) from zy_detail_charge where inpatient_no=#{patNo} and " +
+            "admiss_times=#{times} and ledger_sn=#{ledgerSn} and isnull(charge_status, '1') <> '1' and " +
+            "charge_date ${compare} #{timeLimit}")
+    BigDecimal selectOverTimeLimitFee(@Param("patNo") String patNo,
+                                      @Param("times") Integer times,
+                                      @Param("ledgerSn") int ledgerSn,
+                                      @Param("compare") String compare,
+                                      @Param("timeLimit") Date timeLimit);
 
     @Update("update zy_ledger_file set deposit=(select isnull(sum(depo_amount),0) from zy_deposit_file f with(nolock) " +
             "where f.inpatient_no=#{zyh} and f.admiss_times=#{times} and f.ledger_sn=#{ledger} and f.status in ('1','2')) " +

+ 14 - 2
src/main/java/thyyxxk/webserver/service/yibao/DismissService.java

@@ -18,6 +18,7 @@ import thyyxxk.webserver.service.externalhttp.SiInjurySystem;
 import thyyxxk.webserver.service.externalhttp.SiZySrvc;
 import thyyxxk.webserver.utils.*;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 /**
@@ -186,9 +187,20 @@ public class DismissService {
         Date begntime = getBegntime(patNo, times, "zy_actpatient");
         dismissFeeAnalyse(patNo, times, ledgerSn, begntime, tmpendtime);
 
-        if (dao.getFeeOffset(patNo, times, ledgerSn, begntime, tmpendtime) != 0) {
+        BigDecimal feeOffset = dao.getFeeOffset(patNo, times, ledgerSn);
+        if (feeOffset.compareTo(BigDecimal.ZERO) != 0) {
             ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
-            exception.setMessage("此患者明细费用与账页费用不一致。");
+            BigDecimal beforeAdmFee = dao.selectOverTimeLimitFee(patNo, times, ledgerSn, "<", begntime);
+            if (beforeAdmFee.compareTo(BigDecimal.ZERO) != 0) {
+                exception.setMessage("此患者明细费用与账页费用不一致,有【" + beforeAdmFee + "元】小于入院时间的费用。");
+                throw new BizException(exception);
+            }
+            BigDecimal afterDisFee = dao.selectOverTimeLimitFee(patNo, times, ledgerSn, ">", tmpendtime);
+            if (afterDisFee.compareTo(BigDecimal.ZERO) != 0) {
+                exception.setMessage("此患者明细费用与账页费用不一致,有【" + afterDisFee + "元】大于出院时间的费用。");
+                throw new BizException(exception);
+            }
+            exception.setMessage("此患者明细费用与账页费用不一致,请确认所有医嘱、药单等都已接收。");
             throw new BizException(exception);
         }