Bladeren bron

HIS与医保对总账

lighter 2 jaren geleden
bovenliggende
commit
abab009dab

+ 4 - 3
src/main/java/thyyxxk/webserver/dao/his/inpatient/DismissDao.java

@@ -189,13 +189,14 @@ public interface DismissDao {
 
     @Update("update zy_ledger_file set account_date=#{zjdzDatetime},settle_type='1',balance=0,last_balance=#{xjzf}, " +
             "settle=(deposit-#{xjzf}),ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{staffId},charge_yb=0," +
-            "fund_pay_sumamt=#{tczf},acct_pay=#{grzhzf} where inpatient_no=#{inpatientNo} and " +
-            "admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
+            "fund_pay_sumamt=#{tczf},acct_pay=#{grzhzf},hosp_part_amt=#{hospitalPay} where inpatient_no=#{inpatientNo} " +
+            "and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
     int updateCostStatusWithoutInfant(MedinsSettleFee settleFee);
 
     @Update("update zy_ledger_file set account_date=#{zjdzDatetime},settle_type='1',balance=0,charge_yb=0, " +
             "last_balance=(total_charge-#{tczf}-#{grzhzf}),settle=(deposit-total_charge+#{tczf}+#{grzhzf}), " +
-            "ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{staffId},fund_pay_sumamt=#{tczf},acct_pay=#{grzhzf} " +
+            "ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{staffId},fund_pay_sumamt=#{tczf}, " +
+            "acct_pay=#{grzhzf},hosp_part_amt=#{hospitalPay} " +
             "where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
     int updateCostStatusWithInfant(MedinsSettleFee settleFee);
 

+ 12 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiManageDao.java

@@ -53,6 +53,18 @@ public interface SiManageDao {
                                                           @Param("start") String start,
                                                           @Param("end") String end);
 
+    @Select("select pat_no,times,ledger_sn,medfee_sumamt,acct_pay,fund_pay_sumamt,hosp_part_amt " +
+            "from t_si_setlinfo where setl_type=#{clrType} and revoked=0 and setl_time>=#{start} and setl_time<=#{end} ")
+    List<InstSetlLdgChkBrf> selectSetlinfoBrfsForHisCheck(@Param("clrType") String clrType,
+                                                          @Param("start") String start,
+                                                          @Param("end") String end);
+
+    @Select("select rtrim(inpatient_no) as patNo,admiss_times as times,ledger_sn,total_charge as medfee_sumamt, " +
+            "acct_pay,fund_pay_sumamt,hosp_part_amt from zy_ledger_file where account_date>=#{start} and " +
+            "account_date<=#{end} and responce_type in ('ad','ae','af','ag','ah','ak') and ledger_sn>0")
+    List<InstSetlLdgChkBrf> selectLedgerBrfsForHisCheck(@Param("start") String start,
+                                                        @Param("end") String end);
+
     @Select("select pat_no,times,ledger_sn,setl_id,mdtrt_id,psn_no,medfee_sumamt,acct_pay,fund_pay_sumamt,psn_cash_pay,hosp_part_amt " +
             "from t_si_setlinfo where clr_type=#{clrType} and revoked=0 and clr_optins=#{clrOptins} and fund_pay_sumamt!=0 " +
             "and setl_time>=#{start} and setl_time<=#{end} and insuplc_admdvs like '43%' ")

+ 9 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/manage/InstStlLdgChk.java

@@ -15,6 +15,11 @@ import java.util.Date;
  */
 @Data
 public class InstStlLdgChk {
+    /**
+     * 对账方式:1-本院医保与医保中心;2-本院医保与本院HIS
+     * */
+    private Integer mode;
+
     /**
      * 医疗类别
      * */
@@ -71,4 +76,8 @@ public class InstStlLdgChk {
      * */
     @JSONField(name = "fixmedins_setl_cnt")
     private Integer fixmedinsSetlCnt;
+
+    public Integer getMode() {
+        return null == mode ? 1 : mode;
+    }
 }

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/setlinfo/SlctSetlPrm.java

@@ -15,6 +15,7 @@ import java.util.Date;
  */
 @Data
 public class SlctSetlPrm {
+    private Integer mode;
     private String insutype;
     @NotBlank(message = "结算类别不能为空!")
     private String clrType;
@@ -29,4 +30,8 @@ public class SlctSetlPrm {
     private Date stmtEnddate;
     private String patNo;
     private Integer revoked;
+
+    public Integer getMode() {
+        return null == mode ? 1 : mode;
+    }
 }

+ 50 - 23
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiManageService.java

@@ -170,23 +170,31 @@ public class SiManageService {
     public ResultVo<String> institutionSettlementLedgerCheck(InstStlLdgChk instStlLdgChk) {
         String startdate = DateUtil.getDayStartTime(instStlLdgChk.getStmtBegndate());
         String enddate = DateUtil.getDayEndTime(instStlLdgChk.getStmtEnddate());
-        List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfsWithInsutype(instStlLdgChk.getClrType(), instStlLdgChk.getInsutype(),
-                instStlLdgChk.getSetlOptins(), startdate, enddate);
-        BigDecimal medfeesum = new BigDecimal("0");
-        BigDecimal acctpaysum = new BigDecimal("0");
-        BigDecimal fundpaysum = new BigDecimal("0");
-        for (InstSetlLdgChkBrf brf : brfs) {
-            medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
-            acctpaysum = DecimalUtil.add(acctpaysum, brf.getAcctPay());
-            fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
-            if (null != brf.getHospPartAmt()) {
-                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPartAmt());
+        List<InstSetlLdgChkBrf> setlBrfs = instStlLdgChk.getMode() == 1 ?
+                dao.selectSetlChkBrfsWithInsutype(instStlLdgChk.getClrType(), instStlLdgChk.getInsutype(),
+                        instStlLdgChk.getSetlOptins(), startdate, enddate) :
+                dao.selectSetlinfoBrfsForHisCheck(instStlLdgChk.getClrType(), startdate, enddate);
+        fillInstStlLdgChk(instStlLdgChk, setlBrfs);
+
+        if (instStlLdgChk.getMode() == 2) {
+            List<InstSetlLdgChkBrf> hisBrfs = dao.selectLedgerBrfsForHisCheck(startdate, enddate);
+            if (hisBrfs.size() != setlBrfs.size()) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
+                        "对账结果:不平。对账结果说明:医保结算笔数:" + setlBrfs.size() + ";HIS结算笔数:" + hisBrfs.size());
             }
+            InstStlLdgChk hisLdgChk = new InstStlLdgChk();
+            fillInstStlLdgChk(hisLdgChk, hisBrfs);
+            if (hisLdgChk.getMedfeeSumamt().compareTo(instStlLdgChk.getMedfeeSumamt()) == 0 &&
+                hisLdgChk.getFundPaySumamt().compareTo(instStlLdgChk.getFundPaySumamt()) == 0) {
+                return ResultVoUtil.success("对账结果:平。对账结果说明:结算笔数:" + hisBrfs.size() +
+                        ",医疗费总额:" + hisLdgChk.getMedfeeSumamt() + ",基金支付总额:" + hisLdgChk.getFundPaySumamt());
+            }
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
+                    "对账结果:不平。对账结果说明:医保结算笔数:" + setlBrfs.size() + ",HIS结算笔数:" + hisBrfs.size() +
+                            ";医保医疗费总额:" + instStlLdgChk.getMedfeeSumamt() + ",HIS医疗费总额:" + hisLdgChk.getMedfeeSumamt() +
+                            ";医保基金支付总额:" + instStlLdgChk.getFundPaySumamt() + ";HIS基金支付总额:" + hisLdgChk.getFundPaySumamt());
         }
-        instStlLdgChk.setMedfeeSumamt(medfeesum);
-        instStlLdgChk.setAcctPay(acctpaysum);
-        instStlLdgChk.setFundPaySumamt(fundpaysum);
-        instStlLdgChk.setFixmedinsSetlCnt(brfs.size());
+
         JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_LEDGER_CHECK);
         String ref = JSONObject.toJSONStringWithDateFormat(instStlLdgChk, "yyyy-MM-dd");
         input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
@@ -217,8 +225,8 @@ public class SiManageService {
             }
             String dscr = info.getString("stmt_rslt_dscr");
             if (StringUtil.isBlank(dscr)) {
-                dscr = "结算笔数:" + brfs.size() +
-                        ",医疗费总额:" + medfeesum + ",基金支付总额:" + fundpaysum;
+                dscr = "结算笔数:" + setlBrfs.size() +
+                        ",医疗费总额:" + instStlLdgChk.getMedfeeSumamt() + ",基金支付总额:" + instStlLdgChk.getFundPaySumamt();
             }
             String data = "【清算机构:" + optins + "】对账结果:" + rslt + "。对账结果说明:" + dscr;
             if (rslt.equals(StmtRslt.CORRECT.getName())) {
@@ -229,6 +237,24 @@ public class SiManageService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
     }
 
+    private void fillInstStlLdgChk(InstStlLdgChk instStlLdgChk, List<InstSetlLdgChkBrf> brfs) {
+        BigDecimal medfeesum = new BigDecimal("0");
+        BigDecimal acctpaysum = new BigDecimal("0");
+        BigDecimal fundpaysum = new BigDecimal("0");
+        for (InstSetlLdgChkBrf brf : brfs) {
+            medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
+            acctpaysum = DecimalUtil.add(acctpaysum, brf.getAcctPay());
+            fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
+            if (null != brf.getHospPartAmt()) {
+                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPartAmt());
+            }
+        }
+        instStlLdgChk.setMedfeeSumamt(medfeesum);
+        instStlLdgChk.setAcctPay(acctpaysum);
+        instStlLdgChk.setFundPaySumamt(fundpaysum);
+        instStlLdgChk.setFixmedinsSetlCnt(brfs.size());
+    }
+
     public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChk insSetlDetlChk) {
         String snowId = SnowFlakeId.instance().nextId();
         String filename = snowId + ".txt";
@@ -237,7 +263,6 @@ public class SiManageService {
         String enddate = DateUtil.getDayEndTime(insSetlDetlChk.getStmtEnddate());
         List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfs(insSetlDetlChk.getClrType(),
                 insSetlDetlChk.getSetlOptins(), startdate, enddate);
-
         BigDecimal medfeesum = new BigDecimal("0");
         BigDecimal psnCashPay = new BigDecimal("0");
         BigDecimal fundpaysum = new BigDecimal("0");
@@ -316,14 +341,16 @@ public class SiManageService {
         if (StringUtil.notBlank(prm.getPatNo())) {
             wrapper.and(i -> i.like("pat_no", prm.getPatNo()).or().like("psn_name", prm.getPatNo()));
         }
-        String begndate = DateUtil.formatDatetime(prm.getStmtBegndate(), "yyyy-MM-dd") + " 00:00:00";
-        String enddate = DateUtil.formatDatetime(prm.getStmtEnddate(), "yyyy-MM-dd") + " 23:59:59";
-        wrapper.eq("clr_type", prm.getClrType());
+        String begndate = DateUtil.formatDatetime(prm.getStmtBegndate(), "yyyy-MM-dd") + " 00:00:00.000";
+        String enddate = DateUtil.formatDatetime(prm.getStmtEnddate(), "yyyy-MM-dd") + " 23:59:59.999";
+        wrapper.eq(prm.getMode() == 1 ? "clr_type" : "setl_type", prm.getClrType());
         wrapper.eq("revoked", YesOrNo.NO.getCode());
-        wrapper.apply("fund_pay_sumamt!=0");
         wrapper.apply("setl_time>='" + begndate + "'");
         wrapper.apply("setl_time<='" + enddate + "'");
-        wrapper.apply("insuplc_admdvs like '43%' ");
+        if (prm.getMode() == 1) {
+            wrapper.apply("fund_pay_sumamt!=0");
+            wrapper.apply("insuplc_admdvs like '43%' ");
+        }
         List<SiSetlinfo> list = setlinfoDao.selectList(wrapper);
         if (null == list || list.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到符合条件的数据。");