|
@@ -1,12 +1,33 @@
|
|
|
package com.lantone.report.facade;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.lantone.common.dto.appeal.GetReviewerDTO;
|
|
|
+import com.lantone.common.enums.IsDeleteEnum;
|
|
|
+import com.lantone.common.exception.Asserts;
|
|
|
+import com.lantone.common.util.DateUtil;
|
|
|
+import com.lantone.common.util.ListUtil;
|
|
|
+import com.lantone.common.vo.appeal.AddAppealInfoVO;
|
|
|
+import com.lantone.common.vo.appeal.GetReviewerVO;
|
|
|
import com.lantone.common.vo.appeal.MedAppealInfoVO;
|
|
|
+import com.lantone.dblayermbg.entity.appeal.AppealExamineInfo;
|
|
|
+import com.lantone.dblayermbg.entity.appeal.AppealInfo;
|
|
|
+import com.lantone.dblayermbg.entity.appeal.QcresultDetail;
|
|
|
import com.lantone.dblayermbg.entity.appeal.WorkFlowNode;
|
|
|
+import com.lantone.dblayermbg.facade.appeal.AppealExamineInfoFacade;
|
|
|
+import com.lantone.dblayermbg.facade.appeal.AppealInfoFacade;
|
|
|
+import com.lantone.dblayermbg.facade.appeal.QcresultDetailFacade2;
|
|
|
+import com.lantone.dblayermbg.facade.appeal.SysUserRoleFacade2;
|
|
|
import com.lantone.dblayermbg.facade.appeal.WorkFlowNodeFacade;
|
|
|
+import com.lantone.report.enums.WorkFlowNodeEnum;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @Description:申诉审核管理
|
|
|
* @Author: songxl
|
|
@@ -17,7 +38,185 @@ public class MedAppealInfoManagementFacade {
|
|
|
@Autowired
|
|
|
private WorkFlowNodeFacade workFlowNodeFacade;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AppealInfoFacade appealInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ private SysUserRoleFacade2 sysUserRoleFacade;
|
|
|
+ @Autowired
|
|
|
+ private QcresultDetailFacade2 qcresultDetailFacade;
|
|
|
+ @Autowired
|
|
|
+ private AppealExamineInfoFacade appealExamineInfoFacade;
|
|
|
+
|
|
|
public WorkFlowNode getWorkById(MedAppealInfoVO medAppealInfoVO) {
|
|
|
return workFlowNodeFacade.getById(medAppealInfoVO.getId());
|
|
|
}
|
|
|
+
|
|
|
+ public Boolean addAppealInfo(AddAppealInfoVO addAppealInfoVO) {
|
|
|
+
|
|
|
+ switch (addAppealInfoVO.getAppealOperationType()) {
|
|
|
+ //删改
|
|
|
+ case "0":
|
|
|
+ //通过缺陷id获取该缺陷记录
|
|
|
+ QcresultDetail qcresultDetail = getQcresultDetailById(addAppealInfoVO.getQcresultDetailId());
|
|
|
+ //获取该病历缺陷申诉记录(医院id+病历id+质控缺陷id+未删除)
|
|
|
+ AppealInfo appealInfo = getAppealInfo(addAppealInfoVO.getHospitalId()
|
|
|
+ , addAppealInfoVO.getBehospitalCode()
|
|
|
+ , addAppealInfoVO.getQcresultDetailId());
|
|
|
+ //缺陷状态-删除
|
|
|
+ if (qcresultDetail.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
+ Asserts.fail2("该缺陷已被删除,请走恢复流程");
|
|
|
+ }
|
|
|
+ //申诉记录不存在
|
|
|
+ if (appealInfo == null) {
|
|
|
+ //新增申诉记录+审核记录
|
|
|
+ return addAppealInfoAndExamineInfo(addAppealInfoVO);
|
|
|
+ }
|
|
|
+ //获取申诉记录当前节点状态(1:申诉|2:撤销|3:科室审核)
|
|
|
+ if (WorkFlowNodeEnum.APPEAL.getKey().equals(addAppealInfoVO.getWorkFlowNodeId()+"")) {
|
|
|
+ Asserts.fail2("该缺陷已被申诉");
|
|
|
+ } else {
|
|
|
+ //删除申诉记录
|
|
|
+ appealInfoFacade.update(new UpdateWrapper<AppealInfo>().set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .eq("id", appealInfo.getId()));
|
|
|
+ }
|
|
|
+ //新增申诉记录+审核记录
|
|
|
+ return addAppealInfoAndExamineInfo(addAppealInfoVO);
|
|
|
+ //新增已有
|
|
|
+ case "1":
|
|
|
+ //通过病历id+条目ID获取缺陷
|
|
|
+ List<QcresultDetail> qcresultDetails = qcresultDetailFacade.list(new QueryWrapper<QcresultDetail>()
|
|
|
+ .eq("hospital_id", addAppealInfoVO.getHospitalId())
|
|
|
+ .eq("behospital_code", addAppealInfoVO.getBehospitalCode())
|
|
|
+ .eq("cases_entry_id", addAppealInfoVO.getCasesEntryId()));
|
|
|
+ if (ListUtil.isNotEmpty(qcresultDetails)) {
|
|
|
+ Asserts.fail2("该缺陷已存在无需申诉新增");
|
|
|
+ }
|
|
|
+ //新增申诉记录+审核记录
|
|
|
+ return addAppealInfoAndExamineInfo(addAppealInfoVO);
|
|
|
+ //新增缺失
|
|
|
+ case "2":
|
|
|
+ //新增申诉记录+审核记录
|
|
|
+ return addAppealInfoAndExamineInfo(addAppealInfoVO);
|
|
|
+ //恢复
|
|
|
+ case "3":
|
|
|
+ //通过缺陷id获取该缺陷记录
|
|
|
+ QcresultDetail qcresultDetail1 = getQcresultDetailById(addAppealInfoVO.getQcresultDetailId());
|
|
|
+ //获取该病历缺陷申诉记录(医院id+病历id+质控缺陷id+未删除)
|
|
|
+ AppealInfo appealInfo1 = getAppealInfo(addAppealInfoVO.getHospitalId()
|
|
|
+ , addAppealInfoVO.getBehospitalCode()
|
|
|
+ , addAppealInfoVO.getQcresultDetailId());
|
|
|
+ //缺陷状态-删除
|
|
|
+ if (qcresultDetail1.getIsDeleted().equals(IsDeleteEnum.N.getKey())) {
|
|
|
+ Asserts.fail2("缺陷已被恢复无需再次恢复");
|
|
|
+ }
|
|
|
+ //申诉记录不存在
|
|
|
+ if (appealInfo1 == null) {
|
|
|
+ //新增申诉记录+审核记录
|
|
|
+ return addAppealInfoAndExamineInfo(addAppealInfoVO);
|
|
|
+ }
|
|
|
+ //获取申诉记录当前节点状态(1:申诉|2:撤销|3:科室审核)
|
|
|
+ if (WorkFlowNodeEnum.APPEAL.getKey().equals(addAppealInfoVO.getWorkFlowNodeId()+"")) {
|
|
|
+ Asserts.fail2("该缺陷已被申诉");
|
|
|
+ } else {
|
|
|
+ //删除申诉记录
|
|
|
+ appealInfoFacade.update(new UpdateWrapper<AppealInfo>().set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .eq("id", appealInfo1.getId()));
|
|
|
+ }
|
|
|
+ //新增申诉记录+审核记录
|
|
|
+ return addAppealInfoAndExamineInfo(addAppealInfoVO);
|
|
|
+ default:
|
|
|
+ Asserts.fail2("申诉操作类型不存在!");
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean addAppealInfoAndExamineInfo(AddAppealInfoVO addAppealInfoVO) {
|
|
|
+ AppealInfo appealInfo = new AppealInfo();
|
|
|
+ BeanUtils.copyProperties(addAppealInfoVO, appealInfo);
|
|
|
+ appealInfo.setGmtCreate(DateUtil.now());
|
|
|
+ //申诉记录插入成功
|
|
|
+ if (appealInfoFacade.save(appealInfo)) {
|
|
|
+ AppealExamineInfo appealExamineInfo = new AppealExamineInfo();
|
|
|
+ appealExamineInfo.setAppealInfoId(appealInfo.getId());
|
|
|
+ appealExamineInfo.setCheckId(addAppealInfoVO.getCheckId());
|
|
|
+ return appealExamineInfoFacade.save(appealExamineInfo);
|
|
|
+ }
|
|
|
+ Asserts.fail2("申诉记录插入失败!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param hospitalId
|
|
|
+ * @param behospitalCode
|
|
|
+ * @param qcresultDetailId
|
|
|
+ * @Description获取该病历缺陷申诉记录
|
|
|
+ * @Return com.lantone.dblayermbg.entity.appeal.AppealInfo
|
|
|
+ */
|
|
|
+ private AppealInfo getAppealInfo(Long hospitalId, String behospitalCode, Long qcresultDetailId) {
|
|
|
+
|
|
|
+ if (qcresultDetailId == null) {
|
|
|
+ Asserts.fail2("质控缺陷id为空");
|
|
|
+ }
|
|
|
+ List<AppealInfo> appealInfos = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("behospital_code", behospitalCode)
|
|
|
+ .eq("qcresult_detail_id", qcresultDetailId)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ if (ListUtil.isNotEmpty(appealInfos)) {
|
|
|
+ return appealInfos.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param qcresultDetailId
|
|
|
+ * @Description通过id获取质控缺陷条目
|
|
|
+ * @Return com.lantone.dblayermbg.entity.appeal.QcresultDetail
|
|
|
+ */
|
|
|
+ private QcresultDetail getQcresultDetailById(Long qcresultDetailId) {
|
|
|
+ if (qcresultDetailId == null) {
|
|
|
+ Asserts.fail2("质控缺陷id为空");
|
|
|
+ }
|
|
|
+ QcresultDetail qcresultDetail = qcresultDetailFacade.getById(qcresultDetailId);
|
|
|
+ if (qcresultDetail == null) {
|
|
|
+ Asserts.fail2("质控缺陷不存在");
|
|
|
+ }
|
|
|
+ return qcresultDetail;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param getReviewerVO
|
|
|
+ * @Description获取审核人列表
|
|
|
+ * @Return java.util.List<com.lantone.common.dto.appeal.GetReviewerDTO>
|
|
|
+ */
|
|
|
+ public List<GetReviewerDTO> getReviewer(GetReviewerVO getReviewerVO) {
|
|
|
+ //获取审核人列表
|
|
|
+ List<GetReviewerDTO> reviewers = sysUserRoleFacade.getBaseMapper().getUserByRole(getReviewerVO);
|
|
|
+ //获取申诉人申诉记录审核人(时间倒序)
|
|
|
+ List<AppealInfo> appealInfos = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
|
|
|
+ .select("check_id")
|
|
|
+ .eq("claimant_id", getReviewerVO.getClaimantId())
|
|
|
+ .orderByDesc("gmt_create"));
|
|
|
+ return sortReviewer(reviewers, appealInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<GetReviewerDTO> sortReviewer(List<GetReviewerDTO> reviewers, List<AppealInfo> appealInfos) {
|
|
|
+ if (ListUtil.isEmpty(appealInfos)) {
|
|
|
+ return reviewers;
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(reviewers)) {
|
|
|
+ List<GetReviewerDTO> out = new ArrayList<>();
|
|
|
+ for (AppealInfo appealInfo : appealInfos) {
|
|
|
+ for (GetReviewerDTO getReviewerDTO : reviewers) {
|
|
|
+ if (getReviewerDTO.getId().equals(appealInfo.getClaimantId())) {
|
|
|
+ out.add(getReviewerDTO);
|
|
|
+ reviewers.remove(getReviewerDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ out.addAll(reviewers);
|
|
|
+ return out;
|
|
|
+ }
|
|
|
+ return reviewers;
|
|
|
+ }
|
|
|
}
|