|
@@ -10,7 +10,9 @@ import thyyxxk.webserver.constants.Capacity;
|
|
|
import thyyxxk.webserver.dao.his.yibao.DismissDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.yibao.dismiss.*;
|
|
|
+import thyyxxk.webserver.entity.yibao.patient.Overview;
|
|
|
import thyyxxk.webserver.entity.yibao.patient.Patient;
|
|
|
+import thyyxxk.webserver.service.externalhttp.SiZySrvc;
|
|
|
import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -25,10 +27,12 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class DismissService {
|
|
|
private final DismissDao dao;
|
|
|
+ private final SiZySrvc zySrvc;
|
|
|
|
|
|
@Autowired
|
|
|
- public DismissService(DismissDao dao) {
|
|
|
+ public DismissService(DismissDao dao, SiZySrvc zySrvc) {
|
|
|
this.dao = dao;
|
|
|
+ this.zySrvc = zySrvc;
|
|
|
}
|
|
|
|
|
|
public ResultVo<Object> dismiss(Patient param) {
|
|
@@ -93,11 +97,11 @@ public class DismissService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<NegativeFee>> calculateForDismiss(Patient param) {
|
|
|
- String logtype = param.getDismissFlag() == 1 ? "出院结算" : "中间断账";
|
|
|
+ String logtype = param.getMidSetl() ? "中间断账" : "出院结算";
|
|
|
log.info("{}费用计算:{}", logtype, param);
|
|
|
final String patNo = param.getInpatientNo();
|
|
|
final Integer times = param.getAdmissTimes();
|
|
|
- if (param.getDismissFlag() == 1) {
|
|
|
+ if (!param.getMidSetl()) {
|
|
|
Integer disActOrderCount = dao.countDisActOrders(patNo, times);
|
|
|
if (null == disActOrderCount || disActOrderCount == 0) {
|
|
|
disActOrderCount = dao.countDisActOrders2(patNo, times);
|
|
@@ -121,7 +125,7 @@ public class DismissService {
|
|
|
exception.setMessage("没有找到入院时间,请重新获取病人信息。");
|
|
|
throw new BizException(exception);
|
|
|
}
|
|
|
- Date actOrderDisDate = getDismissDate(param.getDismissFlag(), patNo, times, param.getZjdzDatetime());
|
|
|
+ Date actOrderDisDate = getDismissDate(param.getMidSetl(), patNo, times, param.getZjdzDatetime());
|
|
|
final int ledgerSn = dao.getLedgerSn(patNo, times);
|
|
|
if (dao.hasUnsettledStepOne(patNo, times, ledgerSn) < 0) {
|
|
|
ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
|
|
@@ -182,7 +186,7 @@ public class DismissService {
|
|
|
exception.setMessage("此患者明细费用与账页费用不一致。");
|
|
|
throw new BizException(exception);
|
|
|
}
|
|
|
- final Integer transFlag = param.getDismissFlag() == 1 ? 0 : 2;
|
|
|
+ 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()) {
|
|
@@ -191,6 +195,28 @@ public class DismissService {
|
|
|
throw new BizException(exception);
|
|
|
}
|
|
|
dao.deleteTemporaryTable(patNo, times);
|
|
|
+
|
|
|
+ String mdtrtId = dao.selectMdtrtId(patNo, times, ledgerSn);
|
|
|
+ if (StringUtil.notBlank(mdtrtId)) {
|
|
|
+ Overview o = new Overview();
|
|
|
+ o.setInpatientNo(patNo);
|
|
|
+ o.setAdmissTimes(times);
|
|
|
+ o.setLedgerSn(ledgerSn);
|
|
|
+ o.setStaffId(param.getStaffId());
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ ResultVo<String> feeCheck = zySrvc.uploadFeeDetail(o);
|
|
|
+ if (feeCheck.getCode() != ExceptionEnum.SUCCESS.getCode()) {
|
|
|
+ ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
|
|
|
+ exception.setMessage(feeCheck.getMessage());
|
|
|
+ throw new BizException(exception);
|
|
|
+ }
|
|
|
+ }
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
|
|
|
@@ -198,8 +224,9 @@ public class DismissService {
|
|
|
public ResultVo<String> doDismiss(YbSettleFee settleFee) throws BizException {
|
|
|
updateHicNo(settleFee.getInpatientNo());
|
|
|
settleFee.setLedgerSn(dao.getLedgerSn(settleFee.getInpatientNo(), settleFee.getAdmissTimes()));
|
|
|
- // 自费病人不进行医保结算
|
|
|
- if (!settleFee.getResponceType().trim().equals("01")) {
|
|
|
+ String mdtrtId = dao.selectMdtrtId(settleFee.getInpatientNo(), settleFee.getAdmissTimes(), settleFee.getLedgerSn());
|
|
|
+ // 医保病人进行医保结算
|
|
|
+ if (StringUtil.notBlank(mdtrtId)) {
|
|
|
int write;
|
|
|
dao.deleteZyLedgerFileYb(settleFee.getInpatientNo(), settleFee.getAdmissTimes(), settleFee.getLedgerSn());
|
|
|
String cashPay = settleFee.getXjzf();
|
|
@@ -222,8 +249,8 @@ public class DismissService {
|
|
|
exception.setMessage("写发票表失败。");
|
|
|
throw new BizException(exception);
|
|
|
}
|
|
|
- int code = settleFee.getFlag() == 1 ? setHisStatusOut(settleFee) : hisMiddleSettle(settleFee);
|
|
|
- if (updateCostStatusToSettled(settleFee) < 1) {
|
|
|
+ int code = settleFee.getMidSetl() ? setHisStatusOut(settleFee) : hisMiddleSettle(settleFee);
|
|
|
+ if (updateCostStatusToSettled(settleFee, StringUtil.notBlank(mdtrtId)) < 1) {
|
|
|
ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
|
|
|
exception.setMessage("更新费用状态失败。");
|
|
|
throw new BizException(exception);
|
|
@@ -244,9 +271,9 @@ public class DismissService {
|
|
|
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.getFlag(), indata.getInpatientNo(), indata.getAdmissTimes(),
|
|
|
+ final Date dismissDate = getDismissDate(indata.getMidSetl(), indata.getInpatientNo(), indata.getAdmissTimes(),
|
|
|
indata.getZjdzDatetime());
|
|
|
- final Integer transFlag = indata.getFlag() == 1 ? 0 : 2;
|
|
|
+ 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);
|
|
@@ -295,7 +322,7 @@ public class DismissService {
|
|
|
return new String[]{adultCharge, infantCharge};
|
|
|
}
|
|
|
|
|
|
- private Date getAdmissDate(String patNo, int times, String table) {
|
|
|
+ public Date getAdmissDate(String patNo, int times, String table) {
|
|
|
Date admdate = dao.selectAccountDate(patNo, times);
|
|
|
if (null == admdate) {
|
|
|
admdate = dao.selectAdmissDate(patNo, times, table);
|
|
@@ -303,8 +330,8 @@ public class DismissService {
|
|
|
return admdate;
|
|
|
}
|
|
|
|
|
|
- private Date getDismissDate(Integer flag, String patNo, Integer times, Date zjdzDate) {
|
|
|
- if (flag == 2) {
|
|
|
+ private Date getDismissDate(Boolean midsetl, String patNo, Integer times, Date zjdzDate) {
|
|
|
+ if (midsetl) {
|
|
|
return zjdzDate;
|
|
|
}
|
|
|
Date disdate = dao.selectActOrderDisDate(patNo, times);
|
|
@@ -314,19 +341,19 @@ public class DismissService {
|
|
|
return disdate;
|
|
|
}
|
|
|
|
|
|
- private int updateCostStatusToSettled(YbSettleFee param) {
|
|
|
- Date date = param.getFlag() == 1 ? new Date() : param.getZjdzDatetime();
|
|
|
+ private int updateCostStatusToSettled(YbSettleFee param, boolean medins) {
|
|
|
+ Date date = param.getMidSetl() ? param.getZjdzDatetime() : new Date();
|
|
|
final int code;
|
|
|
- if (param.getResponceType().equals("01")) {
|
|
|
- code = dao.updateZifeiCostStatus(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
|
|
|
- param.getWardCode(), param.getDeptCode(), param.getStaffId(), date);
|
|
|
- } else {
|
|
|
+ if (medins) {
|
|
|
final int hasInfant = dao.hasInfant(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
code = hasInfant == 0 ?
|
|
|
dao.updateCostStatusWithoutInfant(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
|
|
|
- param.getWardCode(), param.getDeptCode(), param.getStaffId(), date, param.getResponceType()) :
|
|
|
+ param.getWardCode(), param.getDeptCode(), param.getStaffId(), date) :
|
|
|
dao.updateCostStatusWithInfant(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
|
|
|
- param.getWardCode(), param.getDeptCode(), param.getStaffId(), date, param.getResponceType());
|
|
|
+ param.getWardCode(), param.getDeptCode(), param.getStaffId(), date);
|
|
|
+ } else {
|
|
|
+ code = dao.updateZifeiCostStatus(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
|
|
|
+ param.getWardCode(), param.getDeptCode(), param.getStaffId(), date);
|
|
|
}
|
|
|
if (code < 1) {
|
|
|
return -1;
|
|
@@ -369,7 +396,7 @@ public class DismissService {
|
|
|
|
|
|
private int insertNewZyWorkLog(YbSettleFee param) {
|
|
|
final String userName = dao.getOperateName(param.getStaffId());
|
|
|
- String logType = param.getFlag() == 1 ? "cyjs" : "zjdz";
|
|
|
+ String logType = param.getMidSetl() ? "zjdz" : "cyjs";
|
|
|
return dao.insertNewZyWorkLog(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
|
|
|
param.getWardCode(), logType, param.getDeptCode(), param.getStaffId(), userName);
|
|
|
}
|