|
@@ -0,0 +1,207 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.diagbot.client.BehospitalInfoHystrixClient;
|
|
|
+import com.diagbot.dto.AnalyzeMessageDTO;
|
|
|
+import com.diagbot.dto.MedQcresultDetailAllDTO;
|
|
|
+import com.diagbot.dto.QcHospitalInfoAllDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.dto.SthospitalInfoFindDTO;
|
|
|
+import com.diagbot.dto.SthospitalInfoPageDTO;
|
|
|
+import com.diagbot.dto.SthospitalInfoStatiDTO;
|
|
|
+import com.diagbot.entity.BasHospitalInfo;
|
|
|
+import com.diagbot.entity.MedBehospitalInfo;
|
|
|
+import com.diagbot.entity.StdBehospitalInfo;
|
|
|
+import com.diagbot.entity.StdQcresultDetail;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.StdBehospitalInfoService;
|
|
|
+import com.diagbot.service.impl.StdBehospitalInfoServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.vo.AnalyzeApiVO;
|
|
|
+import com.diagbot.vo.MedQcresultDetailAllVO;
|
|
|
+import com.diagbot.vo.StdQcresultDetailVO;
|
|
|
+import com.diagbot.vo.SthospitalInfoClearVO;
|
|
|
+import com.diagbot.vo.SthospitalInfoFindVO;
|
|
|
+import com.diagbot.vo.SthospitalInfoPageVO;
|
|
|
+import com.diagbot.vo.SthospitalInfoStatiVO;
|
|
|
+import com.diagbot.vo.SthospitalInfoUpdataVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wangfeng
|
|
|
+ * @Description:
|
|
|
+ * @date 2020-06-10 10:49
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class StdBehospitalInfoFacade extends StdBehospitalInfoServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ StdBehospitalInfoService stdBehospitalInfoService;
|
|
|
+ @Autowired
|
|
|
+ MedBehospitalInfoFacade medBehospitalInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ MedQcresultDetailFacade medQcresultDetailFacade;
|
|
|
+ @Autowired
|
|
|
+ StdQcresultDetailFacade stdQcresultDetailFacade;
|
|
|
+ @Autowired
|
|
|
+ BehospitalInfoHystrixClient behospitalInfoHystrixClient;
|
|
|
+ @Autowired
|
|
|
+ BasHospitalInfoFacade qcHospitalInfoFacade;
|
|
|
+
|
|
|
+ public IPage<SthospitalInfoPageDTO> getSthospitalInfoPages(SthospitalInfoPageVO sthospitalInfoPageVO) {
|
|
|
+ if (null != sthospitalInfoPageVO && null != sthospitalInfoPageVO.getLeaveHosDateStart()) {
|
|
|
+ sthospitalInfoPageVO.setLeaveHosDateStart(DateUtil.getFirstTimeOfDay(sthospitalInfoPageVO.getLeaveHosDateStart()));
|
|
|
+ }
|
|
|
+ if (null != sthospitalInfoPageVO && null != sthospitalInfoPageVO.getLeaveHosDateEnd()) {
|
|
|
+ sthospitalInfoPageVO.setLeaveHosDateEnd(DateUtil.getFirstTimeOfDay(DateUtil.addDay(sthospitalInfoPageVO.getLeaveHosDateEnd(), 1)));
|
|
|
+ }
|
|
|
+ if (null != sthospitalInfoPageVO && null != sthospitalInfoPageVO.getLeaveHosDateStart() && null != sthospitalInfoPageVO.getLeaveHosDateEnd()) {
|
|
|
+ if (DateUtil.after(sthospitalInfoPageVO.getLeaveHosDateStart(), sthospitalInfoPageVO.getLeaveHosDateEnd())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "入院时间的开始时间必须小于结束时间!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return stdBehospitalInfoService.getStdPage(sthospitalInfoPageVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean updataSthospitalInfos(SthospitalInfoUpdataVO sthospitalInfoUpdataVO) {
|
|
|
+ boolean res = false;
|
|
|
+ //先去原始表里找
|
|
|
+ QueryWrapper<MedBehospitalInfo> medbeHQuery = new QueryWrapper<>();
|
|
|
+ medbeHQuery.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("behospital_code", sthospitalInfoUpdataVO.getBehospitalCode())
|
|
|
+ .eq("hospital_id", sthospitalInfoUpdataVO.getHospitalId());
|
|
|
+ MedBehospitalInfo medBehospitalInfo = medBehospitalInfoFacade.getOne(medbeHQuery);
|
|
|
+ if (medBehospitalInfo == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病例没有找到");
|
|
|
+ }
|
|
|
+ if (medBehospitalInfo != null) {
|
|
|
+ String behospitalCode = medBehospitalInfo.getBehospitalCode();
|
|
|
+ Long hospitalId = medBehospitalInfo.getHospitalId();
|
|
|
+ MedQcresultDetailAllVO detailAllVO = new MedQcresultDetailAllVO();
|
|
|
+ detailAllVO.setBehospitalCode(behospitalCode);
|
|
|
+ detailAllVO.setHospitalId(hospitalId);
|
|
|
+ //取出该病例最新评分的扣分项及补全所有扣分明细
|
|
|
+ List<MedQcresultDetailAllDTO> medQcresultDetail = medQcresultDetailFacade.getMedQcresultDetail(detailAllVO);
|
|
|
+ if (medQcresultDetail.size() == 0) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病例没有扣分项");
|
|
|
+ }
|
|
|
+ StdBehospitalInfo sthospitalInfo = new StdBehospitalInfo();
|
|
|
+ BeanUtil.copyProperties(medBehospitalInfo, sthospitalInfo);
|
|
|
+ Date date = DateUtil.now();
|
|
|
+ sthospitalInfo.setGmtCreate(date);
|
|
|
+ sthospitalInfo.setGmtModified(date);
|
|
|
+ //先删除原数据,再保存病例到标准病例表里
|
|
|
+ QueryWrapper<StdBehospitalInfo> stdBehospitalInfoQuery = new QueryWrapper<>();
|
|
|
+ stdBehospitalInfoQuery
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("behospital_code", behospitalCode);
|
|
|
+ this.remove(stdBehospitalInfoQuery);
|
|
|
+ res = stdBehospitalInfoService.save(sthospitalInfo);
|
|
|
+
|
|
|
+ List<StdQcresultDetail> medBew = new ArrayList<>();
|
|
|
+ medBew = BeanUtil.listCopyTo(medQcresultDetail, StdQcresultDetail.class);
|
|
|
+ if (ListUtil.isNotEmpty(medBew)) {
|
|
|
+ StdQcresultDetailVO data = new StdQcresultDetailVO();
|
|
|
+ data.setHospitalId(hospitalId);
|
|
|
+ data.setBehospitalCode(behospitalCode);
|
|
|
+ data.setQcresultDetail(medBew);
|
|
|
+ //保存病例评分明细到标准评分明细表
|
|
|
+ res = stdQcresultDetailFacade.addSthospitalInfos(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean clearSthospitalInfos(SthospitalInfoClearVO sthospitalInfoClearVO) {
|
|
|
+ boolean res = false;
|
|
|
+ //先删除原数据
|
|
|
+ QueryWrapper<StdBehospitalInfo> stdBehospitalInfoQuery = new QueryWrapper<>();
|
|
|
+ stdBehospitalInfoQuery
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", sthospitalInfoClearVO.getHospitalId())
|
|
|
+ .eq("behospital_code", sthospitalInfoClearVO.getBehospitalCode());
|
|
|
+ res = stdBehospitalInfoService.remove(stdBehospitalInfoQuery);
|
|
|
+ QueryWrapper<StdQcresultDetail> stdQcresultDetailQuery = new QueryWrapper<>();
|
|
|
+ stdQcresultDetailQuery
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", sthospitalInfoClearVO.getHospitalId())
|
|
|
+ .eq("behospital_code", sthospitalInfoClearVO.getBehospitalCode());
|
|
|
+ res = stdQcresultDetailFacade.remove(stdQcresultDetailQuery);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public SthospitalInfoFindDTO findSthospitalInfos(SthospitalInfoFindVO sthospitalInfoFindVO) {
|
|
|
+ SthospitalInfoFindDTO stdDataDTO = new SthospitalInfoFindDTO();
|
|
|
+ //先去原始表里找
|
|
|
+ QueryWrapper<MedBehospitalInfo> medbeHQuery = new QueryWrapper<>();
|
|
|
+ medbeHQuery.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("behospital_code", sthospitalInfoFindVO.getBehospitalCode())
|
|
|
+ .eq("hospital_id", sthospitalInfoFindVO.getHospitalId());
|
|
|
+ MedBehospitalInfo medBehospitalInfo = medBehospitalInfoFacade.getOne(medbeHQuery);
|
|
|
+ if (medBehospitalInfo == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "暂无病历记录");
|
|
|
+ }
|
|
|
+ QueryWrapper<StdBehospitalInfo> stdBehospitalInfoQuery = new QueryWrapper<>();
|
|
|
+ stdBehospitalInfoQuery
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", sthospitalInfoFindVO.getHospitalId())
|
|
|
+ .eq("behospital_code", sthospitalInfoFindVO.getBehospitalCode());
|
|
|
+ StdBehospitalInfo stdData = stdBehospitalInfoService.getOne(stdBehospitalInfoQuery);
|
|
|
+ if (stdData != null) {
|
|
|
+ BeanUtil.copyProperties(medBehospitalInfo, stdDataDTO);
|
|
|
+ stdDataDTO.setDeptId(medBehospitalInfo.getBehDeptId());
|
|
|
+ stdDataDTO.setDeptName(medBehospitalInfo.getBehDeptName());
|
|
|
+ stdDataDTO.setStatus(1);
|
|
|
+ } else {
|
|
|
+ BeanUtil.copyProperties(medBehospitalInfo, stdDataDTO);
|
|
|
+ stdDataDTO.setDeptId(medBehospitalInfo.getBehDeptId());
|
|
|
+ stdDataDTO.setDeptName(medBehospitalInfo.getBehDeptName());
|
|
|
+ stdDataDTO.setStatus(0);
|
|
|
+ }
|
|
|
+ return stdDataDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ public IPage<SthospitalInfoStatiDTO> getStatistics(SthospitalInfoStatiVO sthospitalInfoStatiVO) {
|
|
|
+ return stdBehospitalInfoService.getStatistic(sthospitalInfoStatiVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ public AnalyzeMessageDTO analyze() {
|
|
|
+ AnalyzeMessageDTO analyzeMessageDTO = new AnalyzeMessageDTO();
|
|
|
+ QueryWrapper<StdBehospitalInfo> stdBehospitalInfoQuery = new QueryWrapper<>();
|
|
|
+ stdBehospitalInfoQuery.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ List<StdBehospitalInfo> list = stdBehospitalInfoService.list(stdBehospitalInfoQuery);
|
|
|
+ List<String> messages = new ArrayList<>();
|
|
|
+ List<QcHospitalInfoAllDTO> hospitalInfoData = qcHospitalInfoFacade.getHospitalInfoAll();
|
|
|
+ Map<Long,String> hospitalMap = new HashMap<>();
|
|
|
+ hospitalMap = hospitalInfoData.stream().collect(Collectors.toMap(QcHospitalInfoAllDTO::getId, hospitalInfo -> hospitalInfo.getName()));
|
|
|
+ if (ListUtil.isNotEmpty(list)) {
|
|
|
+ for (StdBehospitalInfo data : list) {
|
|
|
+ AnalyzeApiVO analyzeApiVO = new AnalyzeApiVO();
|
|
|
+ analyzeApiVO.setBehospitalCode(data.getBehospitalCode());
|
|
|
+ analyzeApiVO.setHospitalId(data.getHospitalId());
|
|
|
+ RespDTO<Map<String, Object>> mapRespDTO = behospitalInfoHystrixClient.analyzeApi(analyzeApiVO);
|
|
|
+ if(mapRespDTO.data == null){
|
|
|
+ messages.add("医院:"+hospitalMap.get(data.getHospitalId())+" 病人住院序号:"+data.getBehospitalCode()+" 错误信息:"+mapRespDTO.msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ analyzeMessageDTO.setMessages(messages);
|
|
|
+ return analyzeMessageDTO;
|
|
|
+ }
|
|
|
+}
|