|
|
@@ -1,5 +1,6 @@
|
|
|
package org.jeecg.modules.medical.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -19,6 +20,8 @@ import org.jeecg.modules.medical.mapper.AfterwardsAuditMapper;
|
|
|
import org.jeecg.modules.medical.service.IAfterwardsAuditService;
|
|
|
import org.jeecg.modules.medical.service.IMedicalDoctorAppealRecordService;
|
|
|
import org.jeecg.modules.system.entity.SysDepart;
|
|
|
+import org.jeecg.modules.system.entity.SysUser;
|
|
|
+import org.jeecg.modules.system.service.ISysUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -26,6 +29,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -47,6 +51,8 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
|
|
|
/** 科室/医生复核服务 */
|
|
|
private final IMedicalDoctorAppealRecordService appealRecordService;
|
|
|
+ private final ISysUserService sysUserService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public IPage<ReportAfterQueryResponseBO> departmentStatistics(Page<AfterwardsAudit> page, AfterwardsAudit afterwardsAudit) {
|
|
|
@@ -78,7 +84,7 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
|
|
|
@Override
|
|
|
public IPage<AfterwardsAudit> auditQueryListPage(Page<AfterwardsAudit> page, QueryWrapper<AfterwardsAudit> queryWrapper) {
|
|
|
- Page<AfterwardsAudit> auditQueryPageList = this.page(page, queryWrapper);
|
|
|
+ Page<AfterwardsAudit> auditQueryPageList = this.page(page, queryWrapper); // TODO 待审核状态默认是空,需要查询为空
|
|
|
if (!CollectionUtils.isEmpty(auditQueryPageList.getRecords())) {
|
|
|
List<AfterwardsAudit> records = auditQueryPageList.getRecords();
|
|
|
records = records.stream().map(item -> {
|
|
|
@@ -100,16 +106,23 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
|
|
|
@Transactional(readOnly = false)
|
|
|
@Override
|
|
|
- public boolean audit(String loginUserName, AuditRequestBO param) {
|
|
|
+ public boolean audit(LoginUser loginUser, AuditRequestBO param) {
|
|
|
AfterwardsAudit a = new AfterwardsAudit();
|
|
|
|
|
|
a = loadAfterwardsAuditById(param.getId());
|
|
|
-
|
|
|
- // 检查当前状态
|
|
|
- if (!ObjectUtils.nullSafeEquals("wait", a.getCheckState()) && !ObjectUtils.nullSafeEquals("reAudit", a.getCheckState())) {
|
|
|
+ // 检查当前状态 、、兼容空
|
|
|
+ if (!ObjectUtils.nullSafeEquals(AfterwardsAuditStatusEnum.wait.getStatus() , a.getCheckState())
|
|
|
+ && !ObjectUtils.nullSafeEquals(AfterwardsAuditStatusEnum.process.getStatus(), a.getCheckState())) {
|
|
|
log.error("必须为待审核或医生符合后的重新审核状态才可以发起审核,当前数据状态为{}", a.getCheckState());
|
|
|
throw new JeecgBootException("当前状态不可发起审核,请检查");
|
|
|
}
|
|
|
+ // 如果当前状态为 process, 表示可能为医生申诉,或者科室处理,只有医生申诉了,才能继续
|
|
|
+ if (ObjectUtils.nullSafeEquals(AfterwardsAuditStatusEnum.process.getStatus(), a.getCheckState())) {
|
|
|
+ if (!ObjectUtils.nullSafeEquals(AfterwardsAuditStatusEnum.doctor_appeal.getStatus(), a.getReviewResults())) {
|
|
|
+ log.error("表记录状态为待审核={},则审查结果必须为医生申诉时,才能继续审核,当前审查结果为={}", a.getCheckState(), a.getReviewResults());
|
|
|
+ throw new JeecgBootException("处理中,必须为医生申诉状态才能继续,请检查!");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
Date nowTime = new Date();
|
|
|
|
|
|
@@ -119,6 +132,7 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
throw new JeecgBootException("不支持的审核状态,请检查");
|
|
|
}
|
|
|
|
|
|
+ String loginUserid = loginUser.getId();
|
|
|
switch (checkStatus) {
|
|
|
case pass: //系统问题,过了
|
|
|
case violation:
|
|
|
@@ -126,23 +140,29 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
a.setCheckState(AfterwardsAuditStatusEnum.finish.getStatus());
|
|
|
a.setStatus("");// 直接违规或者结果通过,这个给空
|
|
|
a.setReviewResults(checkStatus.getStatus());
|
|
|
- a.setCheckBy(loginUserName);// 审核人
|
|
|
+ a.setCheckBy(loginUserid);// 审核人
|
|
|
|
|
|
a.setAuditTime(nowTime);
|
|
|
a.setUpdateTime(nowTime);
|
|
|
- a.setUpdateBy(loginUserName);
|
|
|
+ a.setUpdateBy(loginUserid);
|
|
|
break;
|
|
|
case issue_review: //下发审核
|
|
|
a.setCheckState(AfterwardsAuditStatusEnum.process.getStatus()); // 审核流转为处理中
|
|
|
a.setStatus(AfterwardsAuditStatusEnum.dept_audit_wait.getStatus());// 状态为等待科室处理
|
|
|
a.setReviewResults(AfterwardsAuditStatusEnum.issue_review.getStatus());
|
|
|
- a.setPreCheckBy(loginUserName);
|
|
|
+ a.setPreCheckBy(loginUserid);
|
|
|
a.setPreAuditTime(nowTime); //审核人员
|
|
|
-
|
|
|
- a.setCheckBy(a.getDoctorId());// 分配给符合人
|
|
|
+ String doctorId = a.getDoctorId();
|
|
|
+ SysUser sysUser = sysUserService.getByDoctorId(doctorId);
|
|
|
+ if (null == sysUser) {
|
|
|
+ log.error("下发复核时,找不到指定给医生id={}的用户信息,请先给医生id={}创建用户", doctorId, doctorId);
|
|
|
+ throw new JeecgBootException("找不到复核医生的用户信息,请检查");
|
|
|
+ }
|
|
|
+ // 根据医生id,查询当前系统用户id
|
|
|
+ a.setCheckBy(sysUser.getId());// 分配给符合人
|
|
|
// a.setAuditTime(nowTime);
|
|
|
a.setUpdateTime(nowTime);
|
|
|
- a.setUpdateBy(loginUserName);
|
|
|
+ a.setUpdateBy(loginUserid);
|
|
|
break;
|
|
|
default:
|
|
|
log.error("不支持的审核状态={}", param.getCheckState());
|
|
|
@@ -165,12 +185,14 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
// 获取违规医生列表
|
|
|
List<DeptAuditItemResponse> deptDoctorViolationList = baseMapper.loadDeptDoctorViolationList(sysDepart.getMedicalDeptCode());
|
|
|
// 获取该科室的医生面板
|
|
|
- List<DeptAuditItemResponse> deptDoctorList = baseMapper.loadDeptDoctorList(loginUserName);
|
|
|
+ List<DeptAuditItemResponse> deptDoctorList = baseMapper.loadDeptDoctorList(sysDepart.getId());
|
|
|
List<DeptAuditItemResponse> allDeptDoctorList = new ArrayList<>();
|
|
|
// 下半部分要扣除掉违规的医生列表
|
|
|
if (!CollectionUtils.isEmpty(deptDoctorList) && !CollectionUtils.isEmpty(deptDoctorViolationList)) {
|
|
|
allDeptDoctorList = deptDoctorList.stream().filter(allDoctor -> deptDoctorViolationList.stream().map(DeptAuditItemResponse::getDoctorId)
|
|
|
.noneMatch(id -> Objects.equals(allDoctor.getDoctorId(), id))).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ allDeptDoctorList = deptDoctorList;
|
|
|
}
|
|
|
|
|
|
DeptAuditResponse result = new DeptAuditResponse();
|
|
|
@@ -181,9 +203,9 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
|
|
|
@Transactional(readOnly = false)
|
|
|
@Override
|
|
|
- public boolean deptAudit(String loginUserName, DeptAuditRequestBO param) {
|
|
|
+ public boolean deptAudit(LoginUser loginUser, DeptAuditRequestBO param) {
|
|
|
// 根据当前登录,先获取到医生面板
|
|
|
- SysDepart sysDepart = baseMapper.loadUserDept(loginUserName);
|
|
|
+ SysDepart sysDepart = baseMapper.loadUserDept(loginUser.getUsername());
|
|
|
if (null == sysDepart) {
|
|
|
log.error("找不到当前医生的科室,请检查");
|
|
|
throw new JeecgBootException("找不到当前医生的科室,请检查!");
|
|
|
@@ -223,7 +245,7 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
|
|
|
appealRecord.setAppealNumber(appealNumber);// TODO
|
|
|
appealRecord.setCreateTime(new Date()); // 处理时间
|
|
|
- appealRecord.setCreateBy(loginUserName);// 处理人
|
|
|
+ appealRecord.setCreateBy(loginUser.getId());// 处理人
|
|
|
appealRecord.setAppealStatus(param.getCheckState());
|
|
|
appealRecord.setMedicalDeptCode(medicalDeptCode);
|
|
|
appealRecord.setMedicalDeptName(audit.getMedicalDeptName());
|
|
|
@@ -237,22 +259,22 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
appealRecord.setImgPath(param.getImgPaths());
|
|
|
|
|
|
audit.setCheckBy(audit.getPreCheckBy()); //下一个审核人员为 下发给科室的人员继续审核
|
|
|
- audit.setPreCheckBy(loginUserName); // 上一个审核人员为当前审核人员
|
|
|
+ audit.setPreCheckBy(loginUser.getId()); // 上一个审核人员为当前审核人员
|
|
|
audit.setPreAuditTime(new Date()); // 上一个审查时间,是当前时间
|
|
|
- audit.setStatus(AfterwardsAuditStatusEnum.dept_audit_wait.getStatus()); //审核状态为等待科室处理
|
|
|
+ audit.setStatus(AfterwardsAuditStatusEnum.doctor_appeal.getStatus()); //审核状态为等待科室处理
|
|
|
audit.setReviewResults(AfterwardsAuditStatusEnum.doctor_appeal.getStatus());// 申诉时,审核结果为医生申诉
|
|
|
audit.setUpdateTime(new Date());
|
|
|
- audit.setUpdateBy(loginUserName);
|
|
|
+ audit.setUpdateBy(loginUser.getId());
|
|
|
break;
|
|
|
case "agree_audit": // 同意审核结果
|
|
|
audit.setCheckBy(audit.getPreCheckBy()); //下一个审核人员为 下发给科室的人员继续审核
|
|
|
- audit.setPreCheckBy(loginUserName); // 上一个审核人员为当前审核人员
|
|
|
+ audit.setPreCheckBy(loginUser.getId()); // 上一个审核人员为当前审核人员
|
|
|
audit.setPreAuditTime(new Date()); // 上一个审查时间,是当前时间
|
|
|
audit.setCheckState(AfterwardsAuditStatusEnum.finish.getStatus());
|
|
|
audit.setStatus("");// 直接完成,这个状态给空
|
|
|
audit.setReviewResults(AfterwardsAuditStatusEnum.agree_audit.getStatus());
|
|
|
audit.setUpdateTime(new Date());
|
|
|
- audit.setUpdateBy(loginUserName);
|
|
|
+ audit.setUpdateBy(loginUser.getId());
|
|
|
break;
|
|
|
default:
|
|
|
log.error("不支持的审核状态={}", param.getCheckState());
|
|
|
@@ -285,4 +307,82 @@ public class AfterwardsAuditServiceImpl extends ServiceImpl<AfterwardsAuditMappe
|
|
|
}
|
|
|
return a;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AuditInfoResponse loadAuditInfo(Integer id) {
|
|
|
+ AuditInfoResponse result = baseMapper.loadAuditInfo(id);
|
|
|
+ if (null == result) {
|
|
|
+ log.error("根据事后审核工单id={},获取不到事后审核工单信息", id);
|
|
|
+ throw new JeecgBootException("找不到审核工单信息");
|
|
|
+ }
|
|
|
+ if (null != result.getBirthday()) {
|
|
|
+ // TODO 计算年龄
|
|
|
+ }
|
|
|
+ //获取违规的detail数据
|
|
|
+ List<AuditInfoListResponse> auditInfoListResponseList = baseMapper.loadAuditInfoList(id);
|
|
|
+ if (!CollectionUtils.isEmpty(auditInfoListResponseList)) {
|
|
|
+ for (AuditInfoListResponse auditInfoListResponse : auditInfoListResponseList) {
|
|
|
+ // 计算异常多收-少收
|
|
|
+ BigDecimal detailTotalAmt = auditInfoListResponse.getErrorDetailAmt();
|
|
|
+ if (null != detailTotalAmt) {
|
|
|
+ if (detailTotalAmt.compareTo(BigDecimal.ZERO) > 0) { // 异常金额大于0,就是多收
|
|
|
+ auditInfoListResponse.setErrorRelativelyManyAmt(detailTotalAmt);
|
|
|
+ } else if (detailTotalAmt.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ auditInfoListResponse.setErrorRelativelyFewAmt(detailTotalAmt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ auditInfoListResponse.setVisitTime(result.getVisitTime());
|
|
|
+ auditInfoListResponse.setMedicalInsurance(result.getMedicalInsurance());
|
|
|
+ }
|
|
|
+ result.setDetailList(auditInfoListResponseList);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据工单号,获取诊断信息
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<DiagnosticInfoResponse> loadDiagnosticInfo(Integer id) {
|
|
|
+ return baseMapper.loadDiagnosticInfo(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<MedicalOrderInfoResponse> loadMedicalOrderInfo(Integer id) {
|
|
|
+ return baseMapper.loadMedicalOrderInfo(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取医生对应的违规列表
|
|
|
+ * @param page
|
|
|
+ * @param queryWrapper
|
|
|
+ * @param loginUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<AfterwardsAudit> getDoctorViolations(Page<AfterwardsAudit> page, QueryWrapper<AfterwardsAudit> queryWrapper, LoginUser loginUser) {
|
|
|
+ // 根据当前登录,先获取到医生面板
|
|
|
+ SysDepart sysDepart = baseMapper.loadUserDept(loginUser.getUsername());
|
|
|
+ if (null == sysDepart) {
|
|
|
+ log.error("找不到当前医生的科室,请检查");
|
|
|
+ throw new JeecgBootException("找不到当前医生的科室,请检查!");
|
|
|
+ }
|
|
|
+ // 当前登录科室/医生端的科室code
|
|
|
+ String medicalDeptCode = sysDepart.getMedicalDeptCode();
|
|
|
+ // 获取医生code
|
|
|
+ SysUser userByName = sysUserService.getUserByName(loginUser.getUsername());
|
|
|
+ if (null == userByName) {
|
|
|
+ log.error("找不到登录用户信息={}", loginUser.getUsername());
|
|
|
+ throw new JeecgBootException("找不到登录用户的医生用户信息,请检查!");
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(userByName.getDoctorId())) {
|
|
|
+ log.error("找不到登录用户信息={},的医生编码信息,请检查", loginUser.getUsername());
|
|
|
+ throw new JeecgBootException("找不到登录用户的医生编码(医生id)信息,请检查!");
|
|
|
+ }
|
|
|
+ queryWrapper.eq("doctor_id", userByName.getDoctorId());
|
|
|
+ queryWrapper.eq("medical_dept_code", medicalDeptCode);
|
|
|
+ return this.page(page, queryWrapper);
|
|
|
+ }
|
|
|
}
|