|
@@ -1,8 +1,31 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.diagbot.dto.AlgorithmDTO;
|
|
|
+import com.diagbot.entity.QcresultDetail;
|
|
|
+import com.diagbot.entity.QcresultInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.impl.QcresultDetailServiceImpl;
|
|
|
import com.diagbot.service.impl.QcresultInfoServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.util.SysUserUtils;
|
|
|
+import com.diagbot.vo.AlgorithmVO;
|
|
|
+import com.diagbot.vo.QcResultAlgVO;
|
|
|
+import com.diagbot.vo.QcresultVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @Description:
|
|
|
* @Author:zhaops
|
|
@@ -10,4 +33,85 @@ import org.springframework.stereotype.Component;
|
|
|
*/
|
|
|
@Component
|
|
|
public class QcresultInfoFacade extends QcresultInfoServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("qcresultDetailServiceImpl")
|
|
|
+ private QcresultDetailServiceImpl qcresultDetailServiceImpl;
|
|
|
+ @Autowired
|
|
|
+ private AlgorithmFacade algorithmFacade;
|
|
|
+
|
|
|
+ public Boolean changeQcResult(QcresultVO qcresultVO) {
|
|
|
+ //入参验证
|
|
|
+ if (StringUtil.isBlank(qcresultVO.getBehospitalCode())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "病历id不能为空!");
|
|
|
+ }
|
|
|
+ if (null == qcresultVO.getOptResultAlgVO()) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "操作条目不能为空!");
|
|
|
+ }
|
|
|
+ //查询质控评分明细信息
|
|
|
+ qcresultVO.setHospitalId(Long.valueOf(SysUserUtils.getCurrentHospitalID()));
|
|
|
+ List<QcresultDetail> qcresultDetails
|
|
|
+ = qcresultDetailServiceImpl.list(
|
|
|
+ new QueryWrapper<QcresultDetail>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", qcresultVO.getHospitalId())
|
|
|
+ .eq("behospital_code", qcresultVO.getBehospitalCode()));
|
|
|
+
|
|
|
+ //评分
|
|
|
+ AlgorithmVO algorithmVO = new AlgorithmVO();
|
|
|
+ List<QcResultAlgVO> qcResultAlgVOList
|
|
|
+ = BeanUtil.listCopyTo(qcresultDetails, QcResultAlgVO.class);
|
|
|
+ algorithmVO.setOptResultAlgVO(qcresultVO.getOptResultAlgVO());
|
|
|
+ algorithmVO.setQcResultAlgVOList(qcResultAlgVOList);
|
|
|
+ AlgorithmDTO algorithmDTO = algorithmFacade.getAlgorithmRes(algorithmVO);
|
|
|
+ Long useId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ //更新质控评分结果信息
|
|
|
+ //获取旧记录
|
|
|
+ QcresultInfo qcresultInfo
|
|
|
+ = this.getOne(
|
|
|
+ new QueryWrapper<QcresultInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", qcresultVO.getHospitalId())
|
|
|
+ .eq("behospital_code", qcresultVO.getBehospitalCode()));
|
|
|
+ //删除记录
|
|
|
+ this.update(new UpdateWrapper<QcresultInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", qcresultVO.getHospitalId())
|
|
|
+ .eq("behospital_code", qcresultVO.getBehospitalCode())
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .set("modifier", useId)
|
|
|
+ .set("gmt_modified", now));
|
|
|
+ //新增记录
|
|
|
+ qcresultInfo.setScoreRes(algorithmDTO.getScore());
|
|
|
+ qcresultInfo.setLevel(algorithmDTO.getLevel());
|
|
|
+ qcresultInfo.setGmtCreate(now);
|
|
|
+ qcresultInfo.setCreator(useId.toString());
|
|
|
+ qcresultInfo.setGmtModified(now);
|
|
|
+ qcresultInfo.setModifier(useId.toString());
|
|
|
+ this.save(qcresultInfo);
|
|
|
+ //更新质控评分明细信息
|
|
|
+ //删除记录
|
|
|
+ qcresultDetailServiceImpl.update(new UpdateWrapper<QcresultDetail>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", qcresultVO.getHospitalId())
|
|
|
+ .eq("behospital_code", qcresultVO.getBehospitalCode())
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .set("modifier", useId)
|
|
|
+ .set("gmt_modified", now));
|
|
|
+ List<QcresultDetail> qcresultDetailList = new ArrayList<>();
|
|
|
+ List<QcResultAlgVO> qcResultAlgVORes = algorithmVO.getQcResultAlgVOList();
|
|
|
+ if (ListUtil.isNotEmpty(qcResultAlgVORes)) {
|
|
|
+ for (QcResultAlgVO qcResultAlgVO : qcResultAlgVORes) {
|
|
|
+ QcresultDetail qcresultDetail = new QcresultDetail();
|
|
|
+ BeanUtil.copyProperties(qcResultAlgVO, qcresultDetail);
|
|
|
+ qcresultDetail.setGmtCreate(now);
|
|
|
+ qcresultDetail.setCreator(useId.toString());
|
|
|
+ qcresultDetail.setGmtModified(now);
|
|
|
+ qcresultDetail.setModifier(useId.toString());
|
|
|
+ qcresultDetailList.add(qcresultDetail);
|
|
|
+ }
|
|
|
+ qcresultDetailServiceImpl.saveBatch(qcresultDetailList);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|