Quellcode durchsuchen

优化中间断账和出院结算的计算流程。

lighter vor 4 Jahren
Ursprung
Commit
a9277489d9

+ 1 - 1
pom.xml

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

+ 0 - 6
src/main/java/thyyxxk/webserver/controller/yibao/DismissController.java

@@ -20,8 +20,6 @@ import thyyxxk.webserver.utils.TokenUtil;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 
-import static thyyxxk.webserver.service.yibao.YibaoHttpService.httpPost;
-
 @RestController
 @RequestMapping("/dismiss")
 public class DismissController {
@@ -91,10 +89,6 @@ public class DismissController {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保出院诊断不能为空,请联系医生填写。");
             }
             p.setStaffId(param.getStaffId());
-            ResultVo<Object> preCalRes = httpPost("preCalculateCost", p, p.getResponceType());
-            if (preCalRes.getCode() != 200) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, preCalRes.getMessage());
-            }
             p.setIcdCodes(mkIcdCodes(diags));
             p.setIcdTexts(mkIcdTexts(diags));
             return settleService.calculateCost(p, p.getResponceType());

+ 2 - 45
src/main/java/thyyxxk/webserver/controller/yibao/YiBaoController.java

@@ -13,15 +13,13 @@ import thyyxxk.webserver.pojo.yibao.patient.OverviewPojo;
 import thyyxxk.webserver.pojo.yibao.patient.PatientPojo;
 import thyyxxk.webserver.pojo.yibao.patient.ProofreadParam;
 import thyyxxk.webserver.service.yibao.SettleService;
-import thyyxxk.webserver.utils.FilterUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.TokenUtil;
-import thyyxxk.webserver.utils.YbActionLinks;
 
-import java.util.HashMap;
 import java.util.List;
 
-import static thyyxxk.webserver.service.yibao.YibaoHttpService.httpPost;
+import static thyyxxk.webserver.utils.YibaoHttpUtil.equalizeUpload;
+import static thyyxxk.webserver.utils.YibaoHttpUtil.httpPost;
 
 @RestController
 @RequestMapping("/yibao")
@@ -116,47 +114,6 @@ public class YiBaoController {
         return httpPost("cancelUploadFee", param, param.getResponceType());
     }
 
-    private ResultVo<Object> equalizeUpload(String linkKey, String mode,
-                                    List<OverviewPojo> listParam,
-                                    OverviewPojo singleParam, String responce) {
-        ResultVo<Object> resultVo = null;
-        String[] links = YbActionLinks.uploadLinks.get(linkKey);
-        for (String link : links) {
-            if (null == listParam) {
-                resultVo = httpPost(link + mode, singleParam, responce);
-            } else {
-                resultVo = httpPost(link + mode, listParam, responce);
-            }
-            if (resultVo.getCode() != 10) {
-                break;
-            } else {
-                if (null != resultVo.getData()) {
-                    if (null == listParam) {
-                        if (resultVo.getData().toString().equals(singleParam.getInpatientNo())) {
-                            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号【" + singleParam.getInpatientNo() + "】的患者正在其他进程上传,请勿操作。");
-                        }
-                    } else {
-                        List<HashMap<String, String>> list = FilterUtil.cast(resultVo.getData());
-                        StringBuilder builder = new StringBuilder("【");
-                        for (HashMap<String, String> item : list) {
-                            for (OverviewPojo item2 : listParam) {
-                                if (item.get("inpatientNo").equals(item2.getInpatientNo())) {
-                                    builder.append(item2.getInpatientNo()).append(",");
-                                }
-                            }
-                        }
-                        builder.append("】");
-                        String msg = builder.toString();
-                        if (!msg.equals("【】")) {
-                            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号" + msg + "的患者正在其他进程上传,请取消对应的勾选后再进行操作。");
-                        }
-                    }
-                }
-            }
-        }
-        return resultVo;
-    }
-
     @PostMapping("/calculateCost")
     public ResultVo<String> calculateCost(@RequestBody PatientPojo param) {
         param.setStaffId(TokenUtil.getTokenUserId());

+ 24 - 9
src/main/java/thyyxxk/webserver/dao_his/yibao/DismissDao.java

@@ -16,8 +16,16 @@ public interface DismissDao {
     @Select("select account_date from zy_ledger_file where inpatient_no=#{inpatientNo} " +
             "and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
     Date getLastZjdzDatetime(@Param("inpatientNo") String inpatientNo,
-                               @Param("admissTimes") Integer admissTimes,
-                               @Param("ledgerSn") int ledgerSn);
+                             @Param("admissTimes") Integer admissTimes,
+                             @Param("ledgerSn") int ledgerSn);
+
+    @Update("update zy_detail_charge set trans_flag_yb=#{flag} where inpatient_no=#{inpatientNo} " +
+            "and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn} and charge_date>#{zjdzDatetime}")
+    void updateTransFlagForZjdz(@Param("inpatientNo") String inpatientNo,
+                                @Param("admissTimes") Integer admissTimes,
+                                @Param("ledgerSn") int ledgerSn,
+                                @Param("flag") int flag,
+                                @Param("zjdzDatetime") Date zjdzDatetime);
 
     @Select("select isnull(max ( ledger_sn ), isnull(min ( ledger_sn ), 1)) from zy_ledger_file where " +
             "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}")
@@ -52,7 +60,7 @@ public interface DismissDao {
                         @Param("admissTimes") Integer admissTimes,
                         @Param("ledgerSn") Integer ledgerSn);
 
-    @Select("select count(1) from  zy_detail_charge where inpatient_no=#{inpatientNo} and " +
+    @Select("select count(1) from zy_detail_charge where inpatient_no=#{inpatientNo} and " +
             "admiss_times=#{admissTimes} and isnull(trans_flag_yb,0)=0 and infant_flag=0 and " +
             "charge_date>=#{lastZjdzDatetime} and charge_date<=#{zjdzDatetime}")
     int hasFeeNotUploadWithZjdz(@Param("inpatientNo") String inpatientNo,
@@ -150,12 +158,19 @@ public interface DismissDao {
                      @Param("ledgerSn") int ledgerSn);
 
     @Select("select sum(charge_fee) from zy_detail_charge where inpatient_no=#{inpatientNo} and " +
-            "admiss_times=#{admissTimes} and infant_flag=0 and charge_date>=#{lastZjdzDatetime} and " +
-            "charge_date<=#{zjdzDatetime}")
-    String getTotalCharge(@Param("inpatientNo") String inpatientNo,
-                          @Param("admissTimes") Integer admissTimes,
-                          @Param("lastZjdzDatetime") Date lastZjdzDatetime,
-                          @Param("zjdzDatetime") Date zjdzDatetime);
+            "admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn} and infant_flag=0")
+    String getTotalChargeForCyjs(@Param("inpatientNo") String inpatientNo,
+                                 @Param("admissTimes") Integer admissTimes,
+                                 @Param("ledgerSn") Integer ledgerSn);
+
+    @Select("select sum(charge_fee) from zy_detail_charge where inpatient_no=#{inpatientNo} and " +
+            "admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn} and infant_flag=0 and " +
+            "charge_date>=#{lastZjdzDatetime} and charge_date<=#{zjdzDatetime}")
+    String getTotalChargeForZjdz(@Param("inpatientNo") String inpatientNo,
+                                 @Param("admissTimes") Integer admissTimes,
+                                 @Param("ledgerSn") Integer ledgerSn,
+                                 @Param("lastZjdzDatetime") Date lastZjdzDatetime,
+                                 @Param("zjdzDatetime") Date zjdzDatetime);
 
     @Delete("delete zy_ledger_file_yb where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
     void deleteZyLedgerFileYb(@Param("inpatientNo") String inpatientNo,

+ 79 - 28
src/main/java/thyyxxk/webserver/service/yibao/DismissService.java

@@ -13,6 +13,7 @@ import thyyxxk.webserver.pojo.yibao.dismiss.ActOrderDetail;
 import thyyxxk.webserver.pojo.yibao.dismiss.ActOrderGroup;
 import thyyxxk.webserver.pojo.yibao.dismiss.ReceiptFeePojo;
 import thyyxxk.webserver.pojo.yibao.dismiss.YbSettleFeePojo;
+import thyyxxk.webserver.pojo.yibao.patient.OverviewPojo;
 import thyyxxk.webserver.pojo.yibao.patient.PatientPojo;
 import thyyxxk.webserver.utils.*;
 
@@ -22,6 +23,9 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
+import static thyyxxk.webserver.utils.YibaoHttpUtil.equalizeUpload;
+import static thyyxxk.webserver.utils.YibaoHttpUtil.httpPost;
+
 @Slf4j
 @Service
 public class DismissService {
@@ -97,23 +101,7 @@ public class DismissService {
             throw new BizException(exception);
         }
         Date actOrderDisDate = getDismissDate(param.getDismissFlag(), inpatientNo, admissTimes, param.getZjdzDatetime());
-        Date lastZjdzDatetime = null;
         final int ledgerSn = dao.getLedgerSn(inpatientNo, admissTimes);
-        if (!param.getResponceType().equals("01")) {
-            int code;
-            if (param.getDismissFlag() == 1) {
-                code = dao.hasFeeNotUpload(inpatientNo, admissTimes, ledgerSn);
-            } else {
-                lastZjdzDatetime = ledgerSn == 1 ? param.getAdmissDate() :
-                        dao.getLastZjdzDatetime(inpatientNo, admissTimes, ledgerSn - 1);
-                code = dao.hasFeeNotUploadWithZjdz(inpatientNo, admissTimes, lastZjdzDatetime, param.getZjdzDatetime());
-            }
-            if (code > 0) {
-                ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
-                exception.setMessage("此患者有未上传的费用(" + code + "条)。");
-                throw new BizException(exception);
-            }
-        }
         if (dao.hasUnsettledStepOne(inpatientNo, admissTimes, ledgerSn) < 0) {
             ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
             exception.setMessage("获取记账信息失败。");
@@ -154,7 +142,6 @@ public class DismissService {
             exception.setMessage("此患者有未确认的医技。");
             throw new BizException(exception);
         }
-
         List<PureCodeName> feeNegativeList = dao.feeOrderNegative(inpatientNo, admissTimes);
         if (feeNegativeList.size() > 0) {
             return ResultVoUtil.fail(ExceptionEnum.EXIST_NEGATIVE_FEES, "此患者费用清单存在负数。",
@@ -183,11 +170,18 @@ public class DismissService {
             exception.setMessage("此患者明细费用与账页费用不一致。");
             throw new BizException(exception);
         }
-        if (param.getDismissFlag() == 2 && !param.getResponceType().trim().equals("01")) {
-            param.setStaffId(TokenUtil.getTokenUserId());
-            String hisTotalCharge = dao.getTotalCharge(inpatientNo, admissTimes, lastZjdzDatetime, actOrderDisDate);
-            ResultVo<Object> resultVo = YibaoHttpService.httpPost("preCalculateCost", param, param.getResponceType());
-            log.info("preCalculateCost: {}", resultVo);
+        String responce = param.getResponceType();
+        Date lastZjdzDatetime = null;
+        if (!responce.equals("01")) {
+            String hisTotalCharge;
+            if (param.getDismissFlag() == 2) {
+                lastZjdzDatetime = ledgerSn == 1 ? param.getAdmissDate() :
+                        dao.getLastZjdzDatetime(inpatientNo, admissTimes, ledgerSn - 1);
+                hisTotalCharge = dao.getTotalChargeForZjdz(inpatientNo, admissTimes, ledgerSn, lastZjdzDatetime, actOrderDisDate);
+            } else {
+                hisTotalCharge = dao.getTotalChargeForCyjs(inpatientNo, admissTimes, ledgerSn);
+            }
+            ResultVo<Object> resultVo = YibaoHttpUtil.httpPost("preCalculateCost", param, responce);
             if (resultVo.getCode() != 200 && resultVo.getCode() != 2002) {
                 ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
                 exception.setMessage(resultVo.getMessage());
@@ -196,15 +190,75 @@ public class DismissService {
                 HashMap<String, String> obj = FilterUtil.cast(resultVo.getData());
                 String ybTotalCharge = obj.get("totalCost");
                 if (DecimalUtil.compare(hisTotalCharge, ybTotalCharge) != 0) {
-                    ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
-                    exception.setMessage("此患者明细费用与医保中心费用不一致。");
-                    throw new BizException(exception);
+                    if (param.getDismissFlag() == 1) {
+                        int count = dao.hasFeeNotUpload(inpatientNo, admissTimes, ledgerSn);
+                        String message = "此患者明细费用与医保中心费用不一致。";
+                        if (count > 0) {
+                            message += "(有未上传的费用【" + count + "】条)";
+                        }
+                        ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
+                        exception.setMessage(message);
+                        throw new BizException(exception);
+                    } else {
+                        int count = dao.hasFeeNotUploadWithZjdz(param.getInpatientNo(), param.getAdmissTimes(),
+                                lastZjdzDatetime, param.getZjdzDatetime());
+                        if (responce.equals("02")) {
+                            String message = "此患者明细费用与医保中心费用不一致。";
+                            if (count > 0) {
+                                message += "(有未上传的费用【" + count + "】条)";
+                            }
+                            ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
+                            exception.setMessage(message);
+                            throw new BizException(exception);
+                        }
+                        if (count == 0) {
+                            httpPost("cancelUploadFee", param, param.getResponceType());
+                        }
+                        dao.updateTransFlagForZjdz(inpatientNo, admissTimes, ledgerSn, 1, param.getZjdzDatetime());
+                        OverviewPojo overview = makeOverview(param);
+                        if (responce.equals("04")) {
+                            resultVo = httpPost("uploadFee", overview, responce);
+                        } else {
+                            if (responce.equals("03") || responce.equals("09")) {
+                                resultVo = equalizeUpload("cssyb", "single", null, overview, responce);
+                            } else {
+                                resultVo = equalizeUpload("hnsyb", "single", null, overview, responce);
+                            }
+                        }
+                        dao.updateTransFlagForZjdz(inpatientNo, admissTimes, ledgerSn, 0, param.getZjdzDatetime());
+                        if (resultVo.getCode() != 200 && resultVo.getCode() != 2002) {
+                            ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
+                            exception.setMessage(resultVo.getMessage());
+                            throw new BizException(exception);
+                        } else {
+                            obj = FilterUtil.cast(resultVo.getData());
+                            ybTotalCharge = obj.get("totalCost");
+                            if (DecimalUtil.compare(hisTotalCharge, ybTotalCharge) != 0) {
+                                ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
+                                exception.setMessage("此患者明细费用与医保中心费用不一致。");
+                                throw new BizException(exception);
+                            }
+                        }
+                    }
                 }
             }
         }
         return ResultVoUtil.success();
     }
 
+    private OverviewPojo makeOverview(PatientPojo param) {
+        OverviewPojo overview = new OverviewPojo();
+        overview.setStaffId(param.getStaffId());
+        overview.setInpatientNo(param.getInpatientNo());
+        overview.setAdmissTimes(param.getAdmissTimes());
+        overview.setName(param.getName());
+        overview.setSex(param.getSex());
+        overview.setBedNo(param.getBedNo());
+        overview.setResponceType(param.getResponceType());
+        overview.setSid(param.getSid());
+        return overview;
+    }
+
     @Transactional(rollbackFor = Exception.class)
     public ResultVo<String> doDismiss(YbSettleFeePojo settleFee) throws BizException {
         updateHicNo(settleFee.getInpatientNo());
@@ -212,15 +266,12 @@ public class DismissService {
         if (!settleFee.getResponceType().trim().equals("01")) { // 自费病人不进行医保结算
             int write;
             dao.deleteZyLedgerFileYb(settleFee.getInpatientNo(), settleFee.getAdmissTimes(), settleFee.getLedgerSn());
-
             String cashPay = settleFee.getXjzf();
             String fundPay = settleFee.getTczf();
-
             // 如果医院支付为正,则 现金支付 = 现金支付 + 医院支付
             if (!settleFee.getHospitalPay().startsWith("-")) {
                 cashPay = DecimalUtil.add(cashPay, settleFee.getHospitalPay());
             }
-
             if (settleFee.getYzsCzdd() == null || settleFee.getYzsCzdd().trim().equals("") ||
                     settleFee.getYzsCzdd().trim().equals("null")) {
                 write = dao.writeYbSettleTableStepTwoShort(settleFee.getInpatientNo(), settleFee.getAdmissTimes(),

+ 2 - 3
src/main/java/thyyxxk/webserver/service/yibao/PatientService.java

@@ -20,7 +20,7 @@ import thyyxxk.webserver.utils.TokenUtil;
 
 import java.util.*;
 
-import static thyyxxk.webserver.service.yibao.YibaoHttpService.httpPost;
+import static thyyxxk.webserver.utils.YibaoHttpUtil.httpPost;
 import static thyyxxk.webserver.utils.FilterUtil.cast;
 
 @Slf4j
@@ -44,9 +44,8 @@ public class PatientService {
         PatientPojo data = dao.getPatientInfo(inpatientNo);
         if (null == data) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有住院号【" + inpatientNo + "】的在院业务!");
-        } else {
-            return ResultVoUtil.success(data);
         }
+        return ResultVoUtil.success(data);
     }
 
     public ResultVo<HashMap<String, Object>> getDisDiag(String inpatientNo, Integer admissTimes) {

+ 0 - 23
src/main/java/thyyxxk/webserver/service/yibao/YibaoHttpService.java

@@ -1,23 +0,0 @@
-package thyyxxk.webserver.service.yibao;
-
-import org.springframework.web.client.RestTemplate;
-import thyyxxk.webserver.config.exception.ExceptionEnum;
-import thyyxxk.webserver.pojo.ResultVo;
-import thyyxxk.webserver.utils.ResultVoUtil;
-import thyyxxk.webserver.utils.YbActionLinks;
-
-public class YibaoHttpService {
-
-    public static ResultVo<Object> httpPost(String tailUrl, Object param, String responce) {
-        if (null == responce || responce.trim().equals("01")) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "自费病人无需进行医保相关操作。");
-        }
-        RestTemplate restTemplate = new RestTemplate();
-        if (tailUrl.startsWith("http://")) {
-            return restTemplate.postForObject(tailUrl, param, ResultVo.class);
-        } else {
-            String url = YbActionLinks.getCompleteUrl(tailUrl, responce);
-            return restTemplate.postForObject(url, param, ResultVo.class);
-        }
-    }
-}

+ 66 - 0
src/main/java/thyyxxk/webserver/utils/YibaoHttpUtil.java

@@ -0,0 +1,66 @@
+package thyyxxk.webserver.utils;
+
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.pojo.ResultVo;
+import thyyxxk.webserver.pojo.yibao.patient.OverviewPojo;
+
+import java.util.HashMap;
+import java.util.List;
+
+public class YibaoHttpUtil {
+
+    public static ResultVo<Object> httpPost(String tailUrl, Object param, String responce) {
+        if (null == responce || responce.trim().equals("01")) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "自费病人无需进行医保相关操作。");
+        }
+        RestTemplate restTemplate = new RestTemplate();
+        if (tailUrl.startsWith("http://")) {
+            return restTemplate.postForObject(tailUrl, param, ResultVo.class);
+        } else {
+            String url = YbActionLinks.getCompleteUrl(tailUrl, responce);
+            return restTemplate.postForObject(url, param, ResultVo.class);
+        }
+    }
+
+    public static ResultVo<Object> equalizeUpload(String linkKey, String mode,
+                                            List<OverviewPojo> listParam,
+                                            OverviewPojo singleParam, String responce) {
+        ResultVo<Object> resultVo = null;
+        String[] links = YbActionLinks.uploadLinks.get(linkKey);
+        for (String link : links) {
+            if (null == listParam) {
+                resultVo = httpPost(link + mode, singleParam, responce);
+            } else {
+                resultVo = httpPost(link + mode, listParam, responce);
+            }
+            if (resultVo.getCode() != 10) {
+                break;
+            } else {
+                if (null != resultVo.getData()) {
+                    if (null == listParam) {
+                        if (resultVo.getData().toString().equals(singleParam.getInpatientNo())) {
+                            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号【" + singleParam.getInpatientNo() + "】的患者正在其他进程上传,请勿操作。");
+                        }
+                    } else {
+                        List<HashMap<String, String>> list = FilterUtil.cast(resultVo.getData());
+                        StringBuilder builder = new StringBuilder("【");
+                        for (HashMap<String, String> item : list) {
+                            for (OverviewPojo item2 : listParam) {
+                                if (item.get("inpatientNo").equals(item2.getInpatientNo())) {
+                                    builder.append(item2.getInpatientNo()).append(",");
+                                }
+                            }
+                        }
+                        builder.append("】");
+                        String msg = builder.toString();
+                        if (!msg.equals("【】")) {
+                            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号" + msg + "的患者正在其他进程上传,请取消对应的勾选后再进行操作。");
+                        }
+                    }
+                }
+            }
+        }
+        return resultVo;
+    }
+}