|
@@ -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(),
|