|
@@ -0,0 +1,93 @@
|
|
|
+package thyyxxk.webserver.service.medicalinsurance;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.dao.his.medicalinsurance.HospitalApprovalDao;
|
|
|
+import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.medicalinsurance.hospitalapproval.PatientFeeItem;
|
|
|
+import thyyxxk.webserver.service.redislike.RedisLikeService;
|
|
|
+import thyyxxk.webserver.utils.DateUtil;
|
|
|
+import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
+import thyyxxk.webserver.utils.TokenUtil;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class HospitalApprovalService {
|
|
|
+ private final HospitalApprovalDao dao;
|
|
|
+ private final RedisLikeService redis;
|
|
|
+ private final SiZyService zyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public HospitalApprovalService(HospitalApprovalDao dao, RedisLikeService redis, SiZyService zyService) {
|
|
|
+ this.dao = dao;
|
|
|
+ this.redis = redis;
|
|
|
+ this.zyService = zyService;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<List<PatientFeeItem>> getPatientFeeList(String patNo, Integer times, Integer ledgerSn) {
|
|
|
+ return ResultVoUtil.success(dao.getPatientFeeList(patNo, times, ledgerSn));
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<List<PatientFeeItem>> getAppliedItems(String patNo, Integer times, Integer ledgerSn) {
|
|
|
+ List<PatientFeeItem> applies = dao.selectPatientApplies(patNo, times, ledgerSn);
|
|
|
+ if (applies.isEmpty()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "患者没有已申请医院审批的费用。");
|
|
|
+ }
|
|
|
+ for (PatientFeeItem item : applies) {
|
|
|
+ item.setStaffName(redis.getEmployeeName(item.getStaffId()));
|
|
|
+ item.setHandlerName(redis.getEmployeeName(item.getApplyHandler()));
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(applies);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> applyHospitalApproval(PatientFeeItem feeItem) {
|
|
|
+ feeItem.setStaffId(TokenUtil.getTokenUserId());
|
|
|
+ log.info("申请医院审批:{}", feeItem);
|
|
|
+ PatientFeeItem existItem = dao.selectAccurateApply(feeItem.getPatNo(), feeItem.getTimes(),
|
|
|
+ feeItem.getLedgerSn(), feeItem.getDetailSn());
|
|
|
+ if (null == existItem) {
|
|
|
+ dao.insertNewApply(feeItem);
|
|
|
+ return ResultVoUtil.success("已发起申请,请等待医保科审核。");
|
|
|
+ }
|
|
|
+ if (existItem.getApplyStatus() == 2) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此条费用的申请已被医保科驳回:"
|
|
|
+ + existItem.getHandleRemark());
|
|
|
+ }
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "此条费用已申请过,请勿重复申请。");
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<List<PatientFeeItem>> getAllApplies(String month) {
|
|
|
+ String begntime = month + "-01 00:00:00.000";
|
|
|
+ String endtime = DateUtil.getMonthEndtime(month);
|
|
|
+ List<PatientFeeItem> applies = dao.selectAllApplies(begntime, endtime);
|
|
|
+ if (applies.isEmpty()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有已申请医院审批的费用。");
|
|
|
+ }
|
|
|
+ for (PatientFeeItem item : applies) {
|
|
|
+ item.setStaffName(redis.getEmployeeName(item.getStaffId()));
|
|
|
+ item.setHandlerName(redis.getEmployeeName(item.getApplyHandler()));
|
|
|
+ item.setWardName(redis.getDeptName(item.getWardName()));
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(applies);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> confirmHandleApply(PatientFeeItem feeItem) {
|
|
|
+ feeItem.setApplyHandler(TokenUtil.getTokenUserId());
|
|
|
+ log.info("申审核医院审批:{}", feeItem);
|
|
|
+ dao.handleApply(feeItem);
|
|
|
+ if (feeItem.getApplyStatus() == 1) {
|
|
|
+ String transFlag = dao.selectFeeTransFlag(feeItem.getPatNo(), feeItem.getTimes(),
|
|
|
+ feeItem.getLedgerSn(), feeItem.getDetailSn());
|
|
|
+ if (Objects.equals(transFlag, "1")) {
|
|
|
+ return zyService.revokeSingleCharge(feeItem.getPatNo(), feeItem.getTimes(),
|
|
|
+ feeItem.getLedgerSn(), feeItem.getDetailSn());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success("处理成功。");
|
|
|
+ }
|
|
|
+}
|