Kaynağa Gözat

优化出院结算和中间断账的费用计算。

lighter 3 yıl önce
ebeveyn
işleme
27596950f6

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>10.7.9</version>
+    <version>10.8.0</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 73 - 44
src/main/java/thyyxxk/webserver/dao/his/yibao/DismissDao.java

@@ -7,6 +7,7 @@ import thyyxxk.webserver.entity.yibao.dismiss.ReceiptFee;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface DismissDao {
@@ -100,15 +101,6 @@ public interface DismissDao {
     @Select("select admiss_date from ${table} where inpatient_no=#{patNo} and admiss_times=#{times}")
     Date selectAdmissDate(@Param("patNo") String patNo, @Param("times") Integer times, @Param("table") String table);
 
-    @Select("exec dbo.zy_cngl_fyjs @in_no=#{patNo}, @times=#{times}, @sn=#{ledgerSn}," +
-            "@op_id_code=#{codeRs}, @date_1 = #{admissDate}, @date_2 = #{dismissDate}, @ward_code = #{wardCode}, " +
-            "@dept_code = #{deptCode}, @trans_flag = #{transFlag}")
-    List<ReceiptFee> calculateCost(@Param("patNo") String patNo, @Param("times") Integer times,
-                                   @Param("ledgerSn") int ledgerSn, @Param("codeRs") String codeRs,
-                                   @Param("admissDate") Date admissDate, @Param("dismissDate") Date dismissDate,
-                                   @Param("wardCode") String wardCode, @Param("deptCode") String deptCode,
-                                   @Param("transFlag") Integer transFlag);
-
     @Select("SELECT settle_type FROM zy_ledger_file WHERE inpatient_no=#{patNo} " +
             "AND admiss_times=#{times} AND ledger_sn=#{ledgerSn}")
     int hasSettled(@Param("patNo") String patNo,
@@ -127,13 +119,15 @@ public interface DismissDao {
             "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')")
     Integer countDisActOrders2(@Param("patNo") String patNo, @Param("times") Integer times);
 
-    @Select("select (select sum(charge_fee) from zy_detail_charge where inpatient_no=#{patNo} " +
-            "AND admiss_times=#{times} AND ledger_sn=#{ledgerSn} and isnull " +
-            "(charge_status, '1') <> '1' )-(select total_charge from zy_ledger_file " +
+    @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 " +
             "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn})")
     int getFeeOffset(@Param("patNo") String patNo,
                      @Param("times") Integer times,
-                     @Param("ledgerSn") int ledgerSn);
+                     @Param("ledgerSn") int ledgerSn,
+                     @Param("begntime") Date begntime,
+                     @Param("endtime") Date endtime);
 
     @Delete("delete zy_ledger_file_yb where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
     void deleteZyLedgerFileYb(@Param("patNo") String patNo,
@@ -155,11 +149,6 @@ public interface DismissDao {
     int beforeWriteReceiptTable(@Param("patNo") String patNo,
                                 @Param("times") Integer times, @Param("ledgerSn") int ledgerSn);
 
-    @Select("select max(infant_flag) from zy_detail_charge where inpatient_no=#{patNo} " +
-            "and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
-    int selectInfantFlag(@Param("patNo") String patNo,
-                         @Param("times") Integer times, @Param("ledgerSn") int ledgerSn);
-
     @Insert("insert into zy_receipt (inpatient_no,admiss_times,ledger_sn,receipt_sn,receipt_no," +
             "account_date,date_1,date_2,ward,dept,print_date,responce_unit,op_id_code,total_charge," +
             "charge1,charge2,charge3,charge4,charge5,charge6,charge7,charge8,charge9,charge10,charge11," +
@@ -167,26 +156,15 @@ public interface DismissDao {
             "charge22,charge23,charge24,charge25,charge26,charge27,charge28,charge29,charge30) " +
             "values (#{patNo},#{times},#{ledgerSn},#{receiptSn},'0000000',#{dismissDate}," +
             "#{admissDate},#{dismissDate},#{wardCode},#{deptCode},#{printDate},#{responceUnit},#{codeRs}," +
-            "#{totalCharge},#{fee0},#{fee1},#{fee2},#{fee3},#{fee4},#{fee5},#{fee6},#{fee7},#{fee8},#{fee9}," +
-            "#{fee10},#{fee11},#{fee12},#{fee13},#{fee14},#{fee15},#{fee16},#{fee17},#{fee18},#{fee19},#{fee20},#{fee21}," +
-            "#{fee22},#{fee23},#{fee24},#{fee25},#{fee26},#{fee27},'0.00','0.00')")
+            "#{map.total},#{map.001},#{map.002},#{map.003},#{map.004},#{map.005},#{map.006},#{map.007},#{map.008},#{map.009},#{map.010}," +
+            "#{map.011},#{map.012},#{map.013},#{map.014},#{map.015},#{map.016},#{map.017},#{map.018},#{map.019},#{map.020},#{map.021},#{map.022}," +
+            "#{map.023},#{map.024},#{map.025},#{map.026},#{map.027},#{map.028},'0.00','0.00')")
     int writeReceiptTable(@Param("patNo") String patNo, @Param("times") Integer times,
                           @Param("ledgerSn") int ledgerSn, @Param("receiptSn") int receiptSn,
-                          @Param("admissDate") Date admissDate,
-                          @Param("dismissDate") Date dismissDate, @Param("wardCode") String wardCode,
-                          @Param("deptCode") String deptCode, @Param("printDate") Date printDate,
-                          @Param("responceUnit") String responceUnit,
-                          @Param("codeRs") String codeRs, @Param("totalCharge") String totalCharge,
-                          @Param("fee0") String fee0, @Param("fee1") String fee1, @Param("fee2") String fee2,
-                          @Param("fee3") String fee3, @Param("fee4") String fee4, @Param("fee5") String fee5,
-                          @Param("fee6") String fee6, @Param("fee7") String fee7, @Param("fee8") String fee8,
-                          @Param("fee9") String fee9, @Param("fee10") String fee10, @Param("fee11") String fee11,
-                          @Param("fee12") String fee12, @Param("fee13") String fee13, @Param("fee14") String fee14,
-                          @Param("fee15") String fee15, @Param("fee16") String fee16, @Param("fee17") String fee17,
-                          @Param("fee18") String fee18, @Param("fee19") String fee19, @Param("fee20") String fee20,
-                          @Param("fee21") String fee21, @Param("fee22") String fee22, @Param("fee23") String fee23,
-                          @Param("fee24") String fee24, @Param("fee25") String fee25, @Param("fee26") String fee26,
-                          @Param("fee27") String fee27);
+                          @Param("admissDate") Date admissDate, @Param("dismissDate") Date dismissDate,
+                          @Param("wardCode") String wardCode, @Param("deptCode") String deptCode,
+                          @Param("printDate") Date printDate, @Param("responceUnit") String responceUnit,
+                          @Param("codeRs") String codeRs, @Param("map") Map<String, String> map);
 
     @Select("select max(infant_flag) FROM zy_detail_charge WHERE inpatient_no=#{patNo} and admiss_times=#{times}")
     int hasInfant(@Param("patNo") String patNo, @Param("times") Integer times);
@@ -339,15 +317,66 @@ public interface DismissDao {
                          @Param("times") Integer times,
                          @Param("ledgerSn") int ledgerSn);
 
-    @Select("select sum(charge_fee) from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} " +
-            "and ledger_sn=#{ledgerSn} and isnull(charge_status,'1')!='1' and isnull(infant_flag,'0')!='1' ")
-    String selectAdultFee(@Param("patNo") String patNo,
-                          @Param("times") Integer times,
-                          @Param("ledgerSn") int ledgerSn);
 
     @Select("select sum(charge_fee) from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} " +
-            "and ledger_sn=#{ledgerSn} and isnull(charge_status,'1')!='1' and isnull(infant_flag,'0')='1' ")
+            "and ledger_sn=#{ledgerSn} and isnull(charge_status,'1')!='1' and isnull(infant_flag,'0')='1' " +
+            "and charge_date>=#{begntime} and charge_date<=#{endtime}")
     String selectInfantFee(@Param("patNo") String patNo,
-                          @Param("times") Integer times,
-                          @Param("ledgerSn") int ledgerSn);
+                           @Param("times") int times,
+                           @Param("ledgerSn") int ledgerSn,
+                           @Param("begntime") Date begntime,
+                           @Param("endtime") Date endtime);
+
+    @Update("update zy_actpatient set total_charge=#{charge} where inpatient_no>=#{patNo1} " +
+            "and inpatient_no<=#{patNo6} and admiss_times=#{times}")
+    void updateInfantfee(@Param("charge") String charge,
+                         @Param("patNo1") String patNo1,
+                         @Param("patNo6") String patNo6,
+                         @Param("times") int times);
+
+    @Select("select b.bill_item_zy as bill_code, ledger_fee=sum(a.charge_fee) " +
+            "from zy_detail_charge a, zd_charge_item b " +
+            "where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and " +
+            "a.ledger_sn=#{ledgerSn} and a.charge_status!='1' and " +
+            "a.charge_date>=#{begntime} and a.charge_date<=#{endtime} and " +
+            "a.charge_code=b.code group by b.bill_item_zy, a.ledger_sn")
+    List<ReceiptFee> selectReceiptFees(@Param("patNo") String patNo,
+                                       @Param("times") int times,
+                                       @Param("ledgerSn") int ledgerSn,
+                                       @Param("begntime") Date begntime,
+                                       @Param("endtime") Date endtime);
+
+    @Select("select code from zy_bill_item")
+    List<String> selectBillCodes();
+
+    @Update("update zy_ledger_file set balance=(deposit-#{map.total}), " +
+            "total_charge=#{map.total},charge1=#{map.001},charge2=#{map.002}, " +
+            "charge3=#{map.003},charge4=#{map.004},charge5=#{map.005},charge6=#{map.006},charge7=#{map.007}, " +
+            "charge8=#{map.008},charge9=#{map.009},charge10=#{map.010},charge11=#{map.011},charge12=#{map.012}, " +
+            "charge13=#{map.013},charge14=#{map.014},charge15=#{map.015},charge16=#{map.016},charge17=#{map.017}, " +
+            "charge18=#{map.018},charge19=#{map.019},charge20=#{map.020},charge21=#{map.021},charge22=#{map.022}," +
+            "charge23=#{map.023},charge24=#{map.024},charge25=#{map.025},charge26=#{map.026},charge27=#{map.027}, " +
+            "charge28=#{map.028},charge29=0,charge30=0 " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
+    void updateZyLedgerFileCharges(@Param("patNo") String patNo,
+                                   @Param("times") int times,
+                                   @Param("ledgerSn") int ledgerSn,
+                                   @Param("map") Map<String, String> map);
+
+    @Select("select isnull(balance,0) from zy_ledger_file WHERE inpatient_no=#{patNo} " +
+            "and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
+    String selectBalance(@Param("patNo") String patNo,
+                         @Param("times") int times,
+                         @Param("ledgerSn") int ledgerSn);
+
+    @Update("update zy_actpatient set balance=#{balance},total_charge=#{map.total},charge1=#{map.001},charge2=#{map.002}, " +
+            "charge3=#{map.003},charge4=#{map.004},charge5=#{map.005},charge6=#{map.006},charge7=#{map.007}, " +
+            "charge8=#{map.008},charge9=#{map.009},charge10=#{map.010},charge11=#{map.011},charge12=#{map.012}, " +
+            "charge13=#{map.013},charge14=#{map.014},charge15=#{map.015},charge16=#{map.016},charge17=#{map.017}, " +
+            "charge18=#{map.018},charge19=#{map.019},charge20=#{map.020},charge21=#{map.021},charge22=#{map.022}," +
+            "charge23=#{map.023},charge24=#{map.024},charge25=#{map.025},charge26=#{map.026},charge27=#{map.027}, " +
+            "charge28=#{map.028},charge29=0,charge30=0 where inpatient_no=#{patNo} ")
+    void updateZyActpatientCharges(@Param("patNo") String patNo,
+                                   @Param("balance") String balance,
+                                   @Param("map") Map<String, String> map);
 }

+ 2 - 2
src/main/java/thyyxxk/webserver/entity/yibao/dismiss/ReceiptFee.java

@@ -4,6 +4,6 @@ import lombok.Data;
 
 @Data
 public class ReceiptFee {
-    private String chargePercent;
-    private String chargeInfant;
+    private String billCode;
+    private String ledgerFee;
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiZyService.java

@@ -343,7 +343,7 @@ public class SiZyService {
     private ResultVo<String> inpatientSettlement(ZyPatientInfo p) {
         PreSetlmt preSetlmt;
         if (p.getMidSetl()) {
-            Date begntime = dismissService.getAdmissDate(p.getInpatientNo(), p.getAdmissTimes(), "zy_actpatient");
+            Date begntime = dismissService.getBegntime(p.getInpatientNo(), p.getAdmissTimes(), "zy_actpatient");
             preSetlmt = dao.selectPreSetlmtForMidSetl(p.getInpatientNo(), p.getAdmissTimes(),
                     p.getLedgerSn(), begntime, p.getZjdzDatetime());
         } else {

+ 53 - 61
src/main/java/thyyxxk/webserver/service/yibao/DismissService.java

@@ -7,6 +7,7 @@ import org.springframework.transaction.annotation.Transactional;
 import thyyxxk.webserver.config.exception.BizException;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.Capacity;
+import thyyxxk.webserver.constants.YesOrNo;
 import thyyxxk.webserver.dao.his.yibao.DismissDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.yibao.dismiss.*;
@@ -15,10 +16,7 @@ import thyyxxk.webserver.entity.yibao.patient.Patient;
 import thyyxxk.webserver.service.externalhttp.SiZySrvc;
 import thyyxxk.webserver.utils.*;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 
 /**
  * @author dj
@@ -125,7 +123,8 @@ public class DismissService {
             exception.setMessage("没有找到入院时间,请重新获取病人信息。");
             throw new BizException(exception);
         }
-        Date actOrderDisDate = getDismissDate(param.getMidSetl(), patNo, times, param.getZjdzDatetime());
+        Date endtime = getEndtime(param.getMidSetl(), patNo, times, param.getZjdzDatetime());
+        Date tmpendtime = param.getMidSetl() ? endtime : DateUtil.parse("2999-12-31 23:59:59");
         final int ledgerSn = dao.getLedgerSn(patNo, times);
         if (dao.hasUnsettledStepOne(patNo, times, ledgerSn) < 0) {
             ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
@@ -147,7 +146,7 @@ public class DismissService {
             exception.setMessage("此患者有未接收的药单。");
             throw new BizException(exception);
         }
-        if (dao.hasUnreceivedFees(patNo, times, actOrderDisDate) > 0) {
+        if (dao.hasUnreceivedFees(patNo, times, tmpendtime) > 0) {
             ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
             exception.setMessage("此患者有未接收的费用。");
             throw new BizException(exception);
@@ -162,7 +161,7 @@ public class DismissService {
             exception.setMessage("此患者有未处理的药品退药单。");
             throw new BizException(exception);
         }
-        if (dao.hasUnconfirmedMedicalTech(patNo, times, actOrderDisDate) > 0) {
+        if (dao.hasUnconfirmedMedicalTech(patNo, times, tmpendtime) > 0) {
             ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
             exception.setMessage("此患者有未确认的医技。");
             throw new BizException(exception);
@@ -181,19 +180,15 @@ public class DismissService {
             exception.setMessage("此患者有未结账的费用。");
             throw new BizException(exception);
         }
-        if (dao.getFeeOffset(patNo, times, ledgerSn) != 0) {
+
+        Date begntime = getBegntime(patNo,times,"zy_actpatient");
+        dismissFeeAnalyse(patNo, times, ledgerSn, begntime, tmpendtime);
+
+        if (dao.getFeeOffset(patNo, times, ledgerSn, begntime, tmpendtime) != 0) {
             ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
             exception.setMessage("此患者明细费用与账页费用不一致。");
             throw new BizException(exception);
         }
-        final Integer transFlag = param.getMidSetl() ? 2 : 0;
-        List<ReceiptFee> receiptFees = dao.calculateCost(patNo, times, ledgerSn, param.getStaffId(),
-                param.getAdmissDate(), actOrderDisDate, param.getAdmissWard(), param.getAdmissDept(), transFlag);
-        if (null == receiptFees || receiptFees.isEmpty()) {
-            ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
-            exception.setMessage("费用计算失败。执行zy_cngl_fyjs过程出错。");
-            throw new BizException(exception);
-        }
         dao.deleteTemporaryTable(patNo, times);
         String mdtrtId = dao.selectMdtrtId(patNo, times, ledgerSn);
         if (StringUtil.notBlank(mdtrtId)) {
@@ -205,9 +200,8 @@ public class DismissService {
             o.setSid(param.getSid());
             o.setMidSetl(param.getMidSetl());
             if (o.getMidSetl()) {
-                Date begntime = getAdmissDate(patNo,times,"zy_actpatient");
                 o.setBegntime(begntime);
-                o.setEndtime(param.getZjdzDatetime());
+                o.setEndtime(tmpendtime);
             }
             ResultVo<String> feeCheck = zySrvc.uploadFeeDetail(o);
             if (feeCheck.getCode() != ExceptionEnum.SUCCESS.getCode()) {
@@ -272,61 +266,59 @@ public class DismissService {
                 indata.getLedgerSn()) < 1) {
             return -1;
         }
-        final int infantFlag = dao.selectInfantFlag(indata.getInpatientNo(), indata.getAdmissTimes(),
-                indata.getLedgerSn()); // =0 无婴儿,>0 有婴儿
-        final Date admissDate = getAdmissDate(indata.getInpatientNo(), indata.getAdmissTimes(), indata.getTable());
-        final Date dismissDate = getDismissDate(indata.getMidSetl(), indata.getInpatientNo(), indata.getAdmissTimes(),
+        final Date admissDate = getBegntime(indata.getInpatientNo(), indata.getAdmissTimes(), indata.getTable());
+        final Date dismissDate = getEndtime(indata.getMidSetl(), indata.getInpatientNo(), indata.getAdmissTimes(),
                 indata.getZjdzDatetime());
-        final Integer transFlag = indata.getMidSetl() ? 2 : 0;
-        final List<ReceiptFee> fees = dao.calculateCost(indata.getInpatientNo(), indata.getAdmissTimes(),
-                indata.getLedgerSn(), indata.getStaffId(), admissDate, dismissDate, indata.getWardCode(),
-                indata.getDeptCode(), transFlag);
-        if (fees == null || fees.isEmpty()) {
-            return -1;
-        }
-        String[] receipts = getReceiptFees(fees);
+        Date tempendtime = indata.getMidSetl() ? dismissDate : DateUtil.parse("2999-12-31 23:59:59");
+        Map<String, String> receipts = dismissFeeAnalyse(indata.getInpatientNo(), indata.getAdmissTimes(),
+                indata.getLedgerSn(), admissDate, tempendtime);
         if (dao.writeReceiptTable(indata.getInpatientNo(), indata.getAdmissTimes(), indata.getLedgerSn(), 1,
                 admissDate, dismissDate, indata.getWardCode(), indata.getDeptCode(), dismissDate, "01",
-                indata.getStaffId(), receipts[0], fees.get(0).getChargePercent(), fees.get(1).getChargePercent(),
-                fees.get(2).getChargePercent(), fees.get(3).getChargePercent(), fees.get(4).getChargePercent(),
-                fees.get(5).getChargePercent(), fees.get(6).getChargePercent(), fees.get(7).getChargePercent(),
-                fees.get(8).getChargePercent(), fees.get(9).getChargePercent(), fees.get(10).getChargePercent(),
-                fees.get(11).getChargePercent(), fees.get(12).getChargePercent(), fees.get(13).getChargePercent(),
-                fees.get(14).getChargePercent(), fees.get(15).getChargePercent(), fees.get(16).getChargePercent(),
-                fees.get(17).getChargePercent(), fees.get(18).getChargePercent(), fees.get(19).getChargePercent(),
-                fees.get(20).getChargePercent(), fees.get(21).getChargePercent(), fees.get(22).getChargePercent(),
-                fees.get(23).getChargePercent(), fees.get(24).getChargePercent(), fees.get(25).getChargePercent(),
-                fees.get(26).getChargePercent(), fees.get(27).getChargePercent()) < 1) {
+                indata.getStaffId(), receipts) < 1) {
             return -1;
         }
-        if (infantFlag > 0) {
+        String infantFlag = receipts.get("infant"); // =0 无婴儿,>0 有婴儿
+        if (infantFlag.equals(YesOrNo.YES.getCodeStr())) {
             return dao.writeReceiptTable(indata.getInpatientNo(), indata.getAdmissTimes(), indata.getLedgerSn(), 4,
                     admissDate, dismissDate, indata.getWardCode(), indata.getDeptCode(), dismissDate, "04",
-                    indata.getStaffId(), receipts[1], fees.get(0).getChargeInfant(), fees.get(1).getChargeInfant(),
-                    fees.get(2).getChargeInfant(), fees.get(3).getChargeInfant(), fees.get(4).getChargeInfant(),
-                    fees.get(5).getChargeInfant(), fees.get(6).getChargeInfant(), fees.get(7).getChargeInfant(),
-                    fees.get(8).getChargeInfant(), fees.get(9).getChargeInfant(), fees.get(10).getChargeInfant(),
-                    fees.get(11).getChargeInfant(), fees.get(12).getChargeInfant(), fees.get(13).getChargeInfant(),
-                    fees.get(14).getChargeInfant(), fees.get(15).getChargeInfant(), fees.get(16).getChargeInfant(),
-                    fees.get(17).getChargeInfant(), fees.get(18).getChargeInfant(), fees.get(19).getChargeInfant(),
-                    fees.get(20).getChargeInfant(), fees.get(21).getChargeInfant(), fees.get(22).getChargeInfant(),
-                    fees.get(23).getChargeInfant(), fees.get(24).getChargeInfant(), fees.get(25).getChargeInfant(),
-                    fees.get(26).getChargeInfant(), fees.get(27).getChargeInfant());
+                    indata.getStaffId(), receipts);
         }
         return 1;
     }
 
-    private String[] getReceiptFees(List<ReceiptFee> fees) {
-        String adultCharge = "0.00";
-        String infantCharge = "0.00";
-        for (ReceiptFee item : fees) {
-            adultCharge = DecimalUtil.add(adultCharge, item.getChargePercent());
-            infantCharge = DecimalUtil.add(infantCharge, item.getChargeInfant());
-        }
-        return new String[]{adultCharge, infantCharge};
+    private Map<String, String> dismissFeeAnalyse(String patNo, int times, int ledgerSn, Date begntime, Date endtime) {
+        Map<String, String> map = initReceiptMap();
+        String infantfee = dao.selectInfantFee(patNo, times, ledgerSn, begntime, endtime);
+        if (StringUtil.notBlank(infantfee) && DecimalUtil.compare(infantfee, "0") == 1) {
+            String patNo1 = patNo + "$1";
+            String patNo6 = patNo + "$6";
+            dao.updateInfantfee(infantfee, patNo1, patNo6, times);
+            map.replace("infant", YesOrNo.YES.getCodeStr());
+        }
+        List<ReceiptFee> receiptFees = dao.selectReceiptFees(patNo, times, ledgerSn, begntime, endtime);
+        if (null == receiptFees) {
+            receiptFees = new ArrayList<>();
+        }
+        for (ReceiptFee fee : receiptFees) {
+            map.replace(fee.getBillCode(), fee.getLedgerFee());
+            map.replace("total", DecimalUtil.add(map.get("total"), fee.getLedgerFee()));
+        }
+        dao.updateZyLedgerFileCharges(patNo, times, ledgerSn, map);
+        String balance = dao.selectBalance(patNo, times, ledgerSn);
+        dao.updateZyActpatientCharges(patNo, balance, map);
+        return map;
+    }
+
+    private Map<String, String> initReceiptMap() {
+        Map<String, String> map = new HashMap<>();
+        map.put("infant", YesOrNo.NO.getCodeStr());
+        map.put("total", "0.00");
+        List<String> billCodes = dao.selectBillCodes();
+        billCodes.forEach(itm -> map.put(itm, "0.00"));
+        return map;
     }
 
-    public Date getAdmissDate(String patNo, int times, String table) {
+    public Date getBegntime(String patNo, int times, String table) {
         Date admdate = dao.selectAccountDate(patNo, times);
         if (null == admdate) {
             admdate = dao.selectAdmissDate(patNo, times, table);
@@ -334,7 +326,7 @@ public class DismissService {
         return admdate;
     }
 
-    private Date getDismissDate(Boolean midsetl, String patNo, Integer times, Date zjdzDate) {
+    private Date getEndtime(Boolean midsetl, String patNo, Integer times, Date zjdzDate) {
         if (midsetl) {
             return zjdzDate;
         }