|
@@ -118,6 +118,12 @@ public class XiangMuLuRuService {
|
|
|
UserInfo userInfo = redisLikeService.getUserInfoByToken();
|
|
|
List<Integer> yongHuJueSe = userInfo.getRoles();
|
|
|
|
|
|
+ // 判断是否为婴儿
|
|
|
+ int infantFlag = publicServer.getInfantFlag(param.getInpatientNo());
|
|
|
+ if (infantFlag == 1) {
|
|
|
+ param.setInpatientNo(param.getInpatientNo().split("\\$")[0]);
|
|
|
+ }
|
|
|
+
|
|
|
if (!yongHuJueSe.contains(36) && !yongHuJueSe.contains(1)) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有权限退费。");
|
|
|
}
|
|
@@ -132,36 +138,35 @@ public class XiangMuLuRuService {
|
|
|
if (dao.getHuanZheSFZaiYuan(param.getInpatientNo(), param.getAdmissTimes()) == 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已出院");
|
|
|
}
|
|
|
- if (dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes()) == null || dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes()) != 0) {
|
|
|
+ Integer settlementFlag = dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
+
|
|
|
+ if (settlementFlag == null || settlementFlag != 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已经结算了");
|
|
|
}
|
|
|
-
|
|
|
- // 判断是否为婴儿
|
|
|
- int infantFlag = publicServer.getInfantFlag(param.getInpatientNo());
|
|
|
// 获取 患者的账页号
|
|
|
Integer ledgerSn = publicServer.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
// 获取原来的数据
|
|
|
List<ZyDetailCharge> yuanTuiFeiList = dao.huoQuJuTiFeiYong(param.getInpatientNo(), param.getAdmissTimes(), ledgerSn, param.getList());
|
|
|
// 获取当前用户 下面的科室
|
|
|
List<String> zhiXinKeShi = dao.chaXunZhiZXinKeShi(param.getDeptCode());
|
|
|
+ // 放入 自己的科室
|
|
|
+ if (!zhiXinKeShi.contains(userInfo.getDeptCode())) {
|
|
|
+ zhiXinKeShi.add(userInfo.getDeptCode());
|
|
|
+ }
|
|
|
|
|
|
- // 项目
|
|
|
List<ZyDetailCharge> xiangMu = new ArrayList<>();
|
|
|
- // 药品
|
|
|
List<ZyDetailCharge> yaoPin = new ArrayList<>();
|
|
|
- // 退费的list
|
|
|
List<ZyDetailCharge> tuiFeiList = new ArrayList<>();
|
|
|
- // 医技科室退药单
|
|
|
List<ZyDetailCharge> yaoPingDan = new ArrayList<>();
|
|
|
- // 把原来的更新 为 -1
|
|
|
- List<Integer> updateItemTags = new ArrayList<>();
|
|
|
+ // 保存被退费的流水号,把这些流水号修改为 -1 代表已经退费了
|
|
|
+ List<Integer> updateRefundFlag = new ArrayList<>();
|
|
|
// 把 药品 改成 -1 代表已经退了 -2 代表申请 -3 代表拒绝
|
|
|
List<Integer> updateDrugLabel = new ArrayList<>();
|
|
|
// 患者最大的 detail_sn
|
|
|
int maxDetailSn = publicServer.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
|
|
|
for (ZyDetailCharge item : yuanTuiFeiList) {
|
|
|
- // 拒绝发药是可以重新申请的
|
|
|
+ // -3 退药申请,拒绝退药申请是可以重新申请的
|
|
|
if (item.getOriDetailSn() != null && item.getOriDetailSn().equals(-3)) {
|
|
|
item.setOriDetailSn(null);
|
|
|
}
|
|
@@ -174,22 +179,27 @@ public class XiangMuLuRuService {
|
|
|
if (BigUtils.bigXiaoYu(item.getChargeFee(), 0) || BigUtils.bigXiaoYu(item.getChargeAmount(), 0)) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,该数据为负数。", item.getDetailSn()));
|
|
|
}
|
|
|
+
|
|
|
if ("00".equals(item.getSerial()) && !zhiXinKeShi.contains(item.getExecUnit())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,请对应的执行科室进行退费。", item.getDetailSn()));
|
|
|
}
|
|
|
+
|
|
|
+ if (item.getChargeCode().equals("BILL02")) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,中药无法退费。", item.getDetailSn()));
|
|
|
+ }
|
|
|
// 数据库有个 触发器 如果带了医嘱号且有篆刻那么这里就需要改成 0
|
|
|
if (BigUtils.bigDaYu(item.getOrderNo(), 10)) {
|
|
|
item.setOrderNo(new BigDecimal(0));
|
|
|
}
|
|
|
if ("00".equals(item.getSerial())) {
|
|
|
- maxDetailSn = setRefund(xiangMu, tuiFeiList, updateItemTags, maxDetailSn, item);
|
|
|
+ maxDetailSn = setRefund(xiangMu, tuiFeiList, updateRefundFlag, maxDetailSn, item);
|
|
|
} else {
|
|
|
if (item.getOrderNo().equals(new BigDecimal(3))) {
|
|
|
// todo 口服药不能退
|
|
|
if (!zhiXinKeShi.contains(item.getExecUnit())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,此药品为医技科室录入,请对应的医技科室退费。", item.getDetailSn()));
|
|
|
} else {
|
|
|
- maxDetailSn = setRefund(xiangMu, tuiFeiList, updateItemTags, maxDetailSn, item);
|
|
|
+ maxDetailSn = setRefund(xiangMu, tuiFeiList, updateRefundFlag, maxDetailSn, item);
|
|
|
yaoPingDan.add(item);
|
|
|
}
|
|
|
} else {
|
|
@@ -202,32 +212,51 @@ public class XiangMuLuRuService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (ListUtil.notBlank(xiangMu)) {
|
|
|
- List<List<ZyDetailCharge>> fenGe = ListUtils.partition(xiangMu, 20);
|
|
|
- fenGe.forEach(dao::xiangMuTuiFei);
|
|
|
- dao.genXinZhenShuTuiFeiLiuShui(param.getInpatientNo(), param.getAdmissTimes(), ledgerSn, updateItemTags, -1);
|
|
|
- log.info("项目录入==》项目退费,操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(xiangMu, DateUtil.DEFAULT_PATTERN));
|
|
|
- }
|
|
|
+ // 护士退药单
|
|
|
+ if (ListUtil.notBlank(yaoPin)) {
|
|
|
+ Map<String, ZyDetailCharge> getDrugClass = dao.getDrugClass(yaoPin).stream().collect(
|
|
|
+ Collectors.toMap(ZyDetailCharge::getChargeCodeMx, a -> a, (k1, k2) -> k1)
|
|
|
+ );
|
|
|
+
|
|
|
+ for (ZyDetailCharge item : yaoPin) {
|
|
|
+ ZyDetailCharge a = getDrugClass.get(item.getChargeCodeMx());
|
|
|
+ if (a == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,药品无法退费 原因没有查询到原药品请联系药库,编码为:【%s】。", item.getDetailSn(), item.getChargeCodeMx()));
|
|
|
+ } else {
|
|
|
+ if (a.getDrugClass().equals("d")) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,药品无法退费,原因口服药无法退费,开退费医嘱也不行", item.getDetailSn()));
|
|
|
+ }
|
|
|
+ item.setDrugClass(a.getDrugClass());
|
|
|
+ }
|
|
|
|
|
|
- if (ListUtil.notBlank(yaoPingDan)) {
|
|
|
- dao.shenQingYaoPing(param, yaoPingDan, infantFlag, ledgerSn, TokenUtil.getTokenUserId());
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if (ListUtil.notBlank(yaoPin)) {
|
|
|
- ZyActpatient 患者信息 = publicServer.huoQuHuanZheXinXi(param.getInpatientNo());
|
|
|
+ ZyActpatient patientInf = publicServer.huoQuHuanZheXinXi(param.getInpatientNo());
|
|
|
Integer pageNo = publicServer.getTheDrugListNo();
|
|
|
// 药品单号
|
|
|
String groupNo = publicServer.getGroupNo();
|
|
|
// 退药单汇总
|
|
|
- dao.drugReturnForm(pageNo, 患者信息.getWard(), TokenUtil.getTokenUserId(), groupNo);
|
|
|
+ dao.drugReturnForm(pageNo, patientInf.getWard(), TokenUtil.getTokenUserId(), groupNo);
|
|
|
// 退药明细
|
|
|
- dao.detailsOfDrugReturnForm(yaoPin, 患者信息.getInpatientNo(), 患者信息.getAdmissTimes(),
|
|
|
- 患者信息.getName(), 患者信息.getBedNo(), 患者信息.getWard(),
|
|
|
+ dao.detailsOfDrugReturnForm(yaoPin, patientInf.getInpatientNo(), patientInf.getAdmissTimes(),
|
|
|
+ patientInf.getName(), patientInf.getBedNo(), patientInf.getWard(),
|
|
|
infantFlag, groupNo, TokenUtil.getTokenUserId(), pageNo, ledgerSn);
|
|
|
dao.genXinZhenShuTuiFeiLiuShui(param.getInpatientNo(), param.getAdmissTimes(), ledgerSn, updateDrugLabel, -2);
|
|
|
log.info("项目录入==》药品退费,操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(yaoPin, DateUtil.DEFAULT_PATTERN));
|
|
|
}
|
|
|
|
|
|
+ // 医技科室药品单
|
|
|
+ if (ListUtil.notBlank(yaoPingDan)) {
|
|
|
+ dao.shenQingYaoPing(param, yaoPingDan, infantFlag, ledgerSn, TokenUtil.getTokenUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ListUtil.notBlank(xiangMu)) {
|
|
|
+ List<List<ZyDetailCharge>> fenGe = ListUtils.partition(xiangMu, 20);
|
|
|
+ fenGe.forEach(dao::xiangMuTuiFei);
|
|
|
+ dao.genXinZhenShuTuiFeiLiuShui(param.getInpatientNo(), param.getAdmissTimes(), ledgerSn, updateRefundFlag, -1);
|
|
|
+ log.info("项目录入==》项目退费,操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(xiangMu, DateUtil.DEFAULT_PATTERN));
|
|
|
+ }
|
|
|
+
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "退费成功。");
|
|
|
|
|
|
}
|
|
@@ -447,7 +476,8 @@ public class XiangMuLuRuService {
|
|
|
if (zyDetailCharge.getChargeCodeMx() == null) {
|
|
|
zyDetailCharge.setChargeCodeMx(zyDetailCharge.getChargeCode());
|
|
|
}
|
|
|
- if (dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes()) == null || dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes()) != 0) {
|
|
|
+ Integer settlementFlag = dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
+ if (settlementFlag == null || settlementFlag != 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已经结算了");
|
|
|
}
|
|
|
// 0 - 住院费用 3 - 门急诊 6 - 医技
|