|
@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.dao.his.yibao.DismissDao;
|
|
|
import thyyxxk.webserver.dao.his.yibao.XiangMuLuRuDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.datamodify.FeiYongLeiXin;
|
|
@@ -37,13 +38,15 @@ public class XiangMuLuRuService {
|
|
|
|
|
|
private final XiangMuLuRuDao dao;
|
|
|
|
|
|
-
|
|
|
private final PublicServer publicServer;
|
|
|
|
|
|
+ private final DismissDao dismissDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
- public XiangMuLuRuService(XiangMuLuRuDao dao, PublicServer publicServer) {
|
|
|
+ public XiangMuLuRuService(XiangMuLuRuDao dao, PublicServer publicServer, DismissDao dismissDao) {
|
|
|
this.dao = dao;
|
|
|
this.publicServer = publicServer;
|
|
|
+ this.dismissDao = dismissDao;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -125,16 +128,19 @@ public class XiangMuLuRuService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "项目退费一次性大于100条数据<br/>╮(﹀_﹀”)╭");
|
|
|
}
|
|
|
if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null || param.getList().size() == 0) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "患者信息不全");
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "患者信息不全 (;´д`)ゞ");
|
|
|
}
|
|
|
if (dao.chaKanHuanZheSFZaiYuan(param.getInpatientNo()) == 0) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已出院");
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已出院 /(ㄒoㄒ)/~~");
|
|
|
+ }
|
|
|
+ if (dismissDao.countDisActOrders(param.getInpatientNo(), param.getAdmissTimes()) > 0 || dismissDao.countDisActOrders2(param.getInpatientNo(), param.getAdmissTimes()) > 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已有出院医嘱无法退费 ε(┬┬﹏┬┬)3");
|
|
|
}
|
|
|
// 判断数据是否为 退费数据
|
|
|
List<ZyDetailCharge> chaKanSFtuiFei = dao.chaKanSFYiJingTuiFeiLe(param.getInpatientNo(), param.getAdmissTimes(), param.getList());
|
|
|
|
|
|
for (ZyDetailCharge charge : chaKanSFtuiFei) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为:【%s】已退费,请勿重复退费 <br/>···=థ౪థ.... ", charge.getOriDetailSn()));
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为:【%s】已退费,请勿重复退费 <br/>···(。•́︿•̀。) ", charge.getOriDetailSn()));
|
|
|
}
|
|
|
// 判断是否为婴儿
|
|
|
if (param.getInpatientNo().contains("$")) {
|
|
@@ -287,6 +293,9 @@ public class XiangMuLuRuService {
|
|
|
if (errorStr.length() > 3) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, errorStr.toString());
|
|
|
}
|
|
|
+ if (dismissDao.countDisActOrders(param.getInpatientNo(), param.getAdmissTimes()) > 0 || dismissDao.countDisActOrders2(param.getInpatientNo(), param.getAdmissTimes()) > 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已有出院医嘱无法退费 ε(┬┬﹏┬┬)3");
|
|
|
+ }
|
|
|
|
|
|
// 婴儿 要特殊处理
|
|
|
// 如果带有这个 $ 说明是婴儿
|
|
@@ -318,19 +327,26 @@ public class XiangMuLuRuService {
|
|
|
zyDetailCharge.setChargeCode(zyDetailCharge.getChargeCodeMx());
|
|
|
break;
|
|
|
}
|
|
|
+ if (zyDetailCharge.getChargeAmount() == null || zyDetailCharge.getAmount() == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "数量或金额不能为空。(▼ヘ▼#)");
|
|
|
+ }
|
|
|
// 判断患者的费用是否存在负数
|
|
|
if (zyDetailCharge.getChargeAmount().signum() == -1 || zyDetailCharge.getAmount().signum() == -1) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.EXIST_NEGATIVE_FEES);
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "不能录入负数,(〃>皿<)");
|
|
|
+ }
|
|
|
+ if (zyDetailCharge.getChargeAmount().compareTo(new BigDecimal(0)) == 0 || zyDetailCharge.getAmount().compareTo(new BigDecimal(0)) == 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "录入费用为 0 (╯°Д°)╯");
|
|
|
}
|
|
|
if (StringUtil.isBlank(zyDetailCharge.getChargeCodeMx())) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "项目编码空值。( ´•︵•` )");
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "项目编码空值。( ´•︵•` )");
|
|
|
}
|
|
|
if (StringUtil.isBlank(zyDetailCharge.getDeptCode())) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "执行科室为空。( ´•︵•` )");
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "执行科室为空。( ´•︵•` )");
|
|
|
}
|
|
|
if (zyDetailCharge.getChargeCodeMx() == null) {
|
|
|
zyDetailCharge.setChargeCodeMx(zyDetailCharge.getChargeCode());
|
|
|
}
|
|
|
+ // 0 - 住院费用 3 - 门急诊 6 - 医技
|
|
|
if (param.getOrderNo() != null) {
|
|
|
zyDetailCharge.setOrderNo(param.getOrderNo());
|
|
|
} else {
|
|
@@ -363,7 +379,6 @@ public class XiangMuLuRuService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "模板名称重复,๐·°(৹˃̵﹏˂̵৹)°·๐");
|
|
|
}
|
|
|
zyDetailCharge.setOpIdCode(TokenUtil.getTokenUserId());
|
|
|
-
|
|
|
for (ZyDetailCharge detailCharge : zyDetailCharge.getList()) {
|
|
|
if (StringUtil.notBlank(zyDetailCharge.getBillItemCode())) {
|
|
|
if (detailCharge.getBillItemCode().equals("001") || detailCharge.getBillItemCode().equals("002")) {
|
|
@@ -424,6 +439,7 @@ public class XiangMuLuRuService {
|
|
|
Collectors.groupingBy(item -> item.getOrderNo() + DateUtil.formatDatetime(item.getChargeDate()) + item.getChargeCodeMx() + item.getChargeAmount() + item.getChargeFee() + item.getLedgerSn())
|
|
|
);
|
|
|
// 用负数拼接的 key 去查找
|
|
|
+ log.info("开始退费匹配住院号:{},次数:{}", inpatientNo, admissTimes);
|
|
|
for (ZyDetailCharge fuShu : getYiZhuFeiYongFuShu) {
|
|
|
String key = fuShu.getOrderNo() + DateUtil.formatDatetime(fuShu.getChargeDate()) + fuShu.getChargeCodeMx() + fuShu.getChargeAmount().negate()
|
|
|
+ fuShu.getChargeFee().negate() + fuShu.getLedgerSn();
|
|
@@ -433,7 +449,7 @@ public class XiangMuLuRuService {
|
|
|
fuShu.setOriDetailSn(zyDetailCharge.getDetailSn());
|
|
|
zyDetailCharge.setTuiFeiFlag(1);
|
|
|
piPei.add(fuShu);
|
|
|
- log.info("第一次匹配==》流水{},匹配流水:{},", fuShu.getDetailSn(), fuShu.getOriDetailSn());
|
|
|
+ log.info("第一次匹配==》流水:{},匹配流水:{},", fuShu.getDetailSn(), fuShu.getOriDetailSn());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -458,7 +474,7 @@ public class XiangMuLuRuService {
|
|
|
zyDetailCharge.setOriDetailSn(detailCharge.getDetailSn());
|
|
|
detailCharge.setTuiFeiFlag(1);
|
|
|
piPei.add(zyDetailCharge);
|
|
|
- log.info("第二次匹配==》流水{},匹配流水:{}", zyDetailCharge.getDetailSn(), zyDetailCharge.getOriDetailSn());
|
|
|
+ log.info("第二次匹配==》流水:{},匹配流水:{}", zyDetailCharge.getDetailSn(), zyDetailCharge.getOriDetailSn());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -506,7 +522,7 @@ public class XiangMuLuRuService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据病人科室
|
|
|
+ * 根据对应的病区来获取科室
|
|
|
*
|
|
|
* @param ward 科室编码
|
|
|
* @return 返回对应的
|