|
@@ -0,0 +1,451 @@
|
|
|
|
+package com.diagbot.facade;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.diagbot.dto.ModuleMappingDTO;
|
|
|
|
+import com.diagbot.dto.QcAllInputcasesDTO;
|
|
|
|
+import com.diagbot.dto.QcInputcasesAllDTO;
|
|
|
|
+import com.diagbot.dto.QcInputcasesMappingDTO;
|
|
|
|
+import com.diagbot.entity.CasesNumber;
|
|
|
|
+import com.diagbot.entity.Mode;
|
|
|
|
+import com.diagbot.entity.ModelMapping;
|
|
|
|
+import com.diagbot.entity.QcHospitalInfo;
|
|
|
|
+import com.diagbot.entity.QcInputcases;
|
|
|
|
+import com.diagbot.entity.QcInputcasesMapping;
|
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
|
+import com.diagbot.service.CasesNumberService;
|
|
|
|
+import com.diagbot.service.ModeService;
|
|
|
|
+import com.diagbot.service.ModelMappingService;
|
|
|
|
+import com.diagbot.service.QcInputcasesMappingService;
|
|
|
|
+import com.diagbot.service.QcInputcasesService;
|
|
|
|
+import com.diagbot.service.impl.QcInputcasesServiceImpl;
|
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
|
+import com.diagbot.vo.QcInputMappingSaveVO;
|
|
|
|
+import com.diagbot.vo.QcInputcasesAllVO;
|
|
|
|
+import com.diagbot.vo.QcInputcasesByIdVO;
|
|
|
|
+import com.diagbot.vo.QcInputcasesSaveVO;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author wangfeng
|
|
|
|
+ * @Description:
|
|
|
|
+ * @date 2020-03-10 17:17
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class QcInputcasesFacade extends QcInputcasesServiceImpl {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ QcInputcasesService qcInputcasesService;
|
|
|
|
+ @Autowired
|
|
|
|
+ QcInputcasesMappingService qcInputcasesMappingService;
|
|
|
|
+ @Autowired
|
|
|
|
+ CasesNumberService casesNumberService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ModelMappingService modelMappingService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ModeService modeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ QcHospitalInfoFacade qcHospitalInfoFacade;
|
|
|
|
+
|
|
|
|
+ /* public List<QcInputcasesAllDTO> getInputcasesAlls(Long textId) {
|
|
|
|
+ //查出所有病例
|
|
|
|
+ QueryWrapper<QcInputcases> qcInputcasesQuery = new QueryWrapper<>();
|
|
|
|
+ qcInputcasesQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .orderByDesc("gmt_modified")
|
|
|
|
+ .last("limit 30");
|
|
|
|
+ if (textId != null && textId != 0) {
|
|
|
|
+ qcInputcasesQuery.eq("id", textId);
|
|
|
|
+ }
|
|
|
|
+ List<QcInputcases> data = list(qcInputcasesQuery);
|
|
|
|
+ List<QcInputcasesAllDTO> dataNew = new ArrayList<QcInputcasesAllDTO>();
|
|
|
|
+ dataNew = BeanUtil.listCopyTo(data, QcInputcasesAllDTO.class);
|
|
|
|
+ // 查出所有病例病例类型
|
|
|
|
+ List<QcInputcasesMappingDTO> qcInputcasesMapping = qcInputcasesMappingService.getQcInputMappings(textId);
|
|
|
|
+ // 然后把所有病例类型放进去
|
|
|
|
+ Map<Long, List<QcInputcasesMappingDTO>> map
|
|
|
|
+ = EntityUtil.makeEntityListMap(qcInputcasesMapping, "textId");
|
|
|
|
+ if (dataNew.size() > 0) {
|
|
|
|
+ for (QcInputcasesAllDTO ts : dataNew) {
|
|
|
|
+ List<QcInputcasesMappingDTO> tmp = map.get(ts.getId());
|
|
|
|
+ if (ListUtil.isNotEmpty(tmp)) {
|
|
|
|
+ ts.setQcInputcasesMapping(tmp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return dataNew;
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param qcInputcasesSaveVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean saveAndUpdatas(QcInputcasesSaveVO qcInputcasesSaveVO) {
|
|
|
|
+ boolean res = false;
|
|
|
|
+ if (qcInputcasesSaveVO.getId() != null && qcInputcasesSaveVO.getId() != 0) {
|
|
|
|
+ //校验数据是否存在
|
|
|
|
+ QueryWrapper<QcInputcases> qcQuery = new QueryWrapper<>();
|
|
|
|
+ Map<String, Object> mapAll = new HashMap<>();
|
|
|
|
+ mapAll.put("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ mapAll.put("id", qcInputcasesSaveVO.getId());
|
|
|
|
+ qcQuery.allEq(mapAll);
|
|
|
|
+ int sum = count(qcQuery);
|
|
|
|
+ if (sum == 0) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病例不存在");
|
|
|
|
+ }
|
|
|
|
+ UpdateWrapper<QcInputcases> qcInputcasesQuery = new UpdateWrapper<>();
|
|
|
|
+ qcInputcasesQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", qcInputcasesSaveVO.getId())
|
|
|
|
+ .set("gmt_modified", DateUtil.now())
|
|
|
|
+ .set("creator", qcInputcasesSaveVO.getCreator())
|
|
|
|
+ .set("text", qcInputcasesSaveVO.getText())
|
|
|
|
+ .set("clinical_blood", qcInputcasesSaveVO.getClinicalBlood())
|
|
|
|
+ .set("consultation", qcInputcasesSaveVO.getConsultation())
|
|
|
|
+ .set("death_case_discuss", qcInputcasesSaveVO.getDeathCaseDiscuss())
|
|
|
|
+ .set("death_record", qcInputcasesSaveVO.getDeathRecord())
|
|
|
|
+ .set("difficult_case_discuss", qcInputcasesSaveVO.getDifficultCaseDiscuss())
|
|
|
|
+ .set("duty_shift_system", qcInputcasesSaveVO.getDutyShiftSystem())
|
|
|
|
+ .set("first_course_record", qcInputcasesSaveVO.getFirstCourseRecord())
|
|
|
|
+ .set("leave_hospital", qcInputcasesSaveVO.getLeaveHospital())
|
|
|
|
+ .set("nursing_system", qcInputcasesSaveVO.getNursingSystem())
|
|
|
|
+ .set("operation_discussion", qcInputcasesSaveVO.getOperationDiscussion())
|
|
|
|
+ .set("pre_operative_discussion", qcInputcasesSaveVO.getPreOperativeDiscussion())
|
|
|
|
+ .set("three_level_ward", qcInputcasesSaveVO.getThreeLevelWard())
|
|
|
|
+ .set("critical_value", qcInputcasesSaveVO.getCriticalValue());
|
|
|
|
+ res = update(qcInputcasesQuery);
|
|
|
|
+ UpdateWrapper<QcInputcasesMapping> qcMappingQuery = new UpdateWrapper<>();
|
|
|
|
+ qcMappingQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("text_id", qcInputcasesSaveVO.getId())
|
|
|
|
+ .set("gmt_modified", DateUtil.now())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = qcInputcasesMappingService.update(qcMappingQuery);
|
|
|
|
+ List<QcInputMappingSaveVO> inputMapping = qcInputcasesSaveVO.getQcInputMappingSaveVO();
|
|
|
|
+
|
|
|
|
+ List<QcInputcasesMapping> qcMappingList = new ArrayList<>();
|
|
|
|
+ for (QcInputMappingSaveVO t : inputMapping) {
|
|
|
|
+ QcInputcasesMapping qcList = new QcInputcasesMapping();
|
|
|
|
+ qcList.setCasesEntryId(t.getCasesEntryId());
|
|
|
|
+ qcList.setCreator(qcInputcasesSaveVO.getCreator());
|
|
|
|
+ qcList.setCasesId(t.getCasesId());
|
|
|
|
+ qcList.setPass(t.getPass());
|
|
|
|
+ /* qcList.setTextId(qcInputcasesSaveVO.getId());*/
|
|
|
|
+ qcList.setGmtModified(DateUtil.now());
|
|
|
|
+ qcMappingList.add(qcList);
|
|
|
|
+ }
|
|
|
|
+ res = qcInputcasesMappingService.saveBatch(qcMappingList);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ /*QueryWrapper<QcInputcases> qcInputcasesQuery = new QueryWrapper<>();
|
|
|
|
+ Map<String, Object> mapAll = new HashMap<>();
|
|
|
|
+ mapAll.put("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ mapAll.put("text", qcInputcasesSaveVO.getText());
|
|
|
|
+ qcInputcasesQuery.allEq(mapAll);
|
|
|
|
+ int sum = count(qcInputcasesQuery);
|
|
|
|
+ if (sum != 0) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病例存在");
|
|
|
|
+ }*/
|
|
|
|
+ QcInputcases qcInputcases = new QcInputcases();
|
|
|
|
+ /* qcInputcases.setText(qcInputcasesSaveVO.getText());
|
|
|
|
+ qcInputcases.setClinicalBlood(qcInputcasesSaveVO.getClinicalBlood());
|
|
|
|
+ qcInputcases.setConsultation(qcInputcasesSaveVO.getConsultation());
|
|
|
|
+ qcInputcases.setCriticalValue(qcInputcasesSaveVO.getCriticalValue());
|
|
|
|
+ qcInputcases.setDeathCaseDiscuss(qcInputcasesSaveVO.getDeathCaseDiscuss());
|
|
|
|
+ qcInputcases.setDeathRecord(qcInputcasesSaveVO.getDeathRecord());
|
|
|
|
+ qcInputcases.setDifficultCaseDiscuss(qcInputcasesSaveVO.getDifficultCaseDiscuss());
|
|
|
|
+ qcInputcases.setDutyShiftSystem(qcInputcasesSaveVO.getDutyShiftSystem());
|
|
|
|
+ qcInputcases.setFirstCourseRecord(qcInputcasesSaveVO.getFirstCourseRecord());
|
|
|
|
+ qcInputcases.setLeaveHospital(qcInputcasesSaveVO.getLeaveHospital());
|
|
|
|
+ qcInputcases.setNursingSystem(qcInputcasesSaveVO.getNursingSystem());
|
|
|
|
+ qcInputcases.setOperationDiscussion(qcInputcasesSaveVO.getOperationDiscussion());
|
|
|
|
+ qcInputcases.setPreOperativeDiscussion(qcInputcasesSaveVO.getPreOperativeDiscussion());
|
|
|
|
+ qcInputcases.setThreeLevelWard(qcInputcasesSaveVO.getThreeLevelWard());
|
|
|
|
+ qcInputcases.setCreator(qcInputcasesSaveVO.getCreator());
|
|
|
|
+ qcInputcases.setGmtModified(DateUtil.now());*/
|
|
|
|
+ BeanUtil.copyProperties(qcInputcasesSaveVO,qcInputcases);
|
|
|
|
+ qcInputcases.setGmtModified(DateUtil.now());
|
|
|
|
+ res = save(qcInputcases);
|
|
|
|
+ List<QcInputMappingSaveVO> inputMapping = qcInputcasesSaveVO.getQcInputMappingSaveVO();
|
|
|
|
+ if (res) {
|
|
|
|
+ List<QcInputcasesMapping> qcMappingList = new ArrayList<>();
|
|
|
|
+ for (QcInputMappingSaveVO t : inputMapping) {
|
|
|
|
+ QcInputcasesMapping qcList = new QcInputcasesMapping();
|
|
|
|
+ qcList.setCasesEntryId(t.getCasesEntryId());
|
|
|
|
+ qcList.setCreator(qcInputcasesSaveVO.getCreator());
|
|
|
|
+ qcList.setCasesId(t.getCasesId());
|
|
|
|
+ qcList.setPass(t.getPass());
|
|
|
|
+ /* qcList.setTextId(qcInputcases.getId());*/
|
|
|
|
+ qcMappingList.add(qcList);
|
|
|
|
+ }
|
|
|
|
+ res = qcInputcasesMappingService.saveBatch(qcMappingList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param qcInputcasesByIdVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean cancelByIds(QcInputcasesByIdVO qcInputcasesByIdVO) {
|
|
|
|
+ boolean res = false;
|
|
|
|
+ UpdateWrapper<QcInputcases> qcInputcasesQuery = new UpdateWrapper<>();
|
|
|
|
+ qcInputcasesQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", qcInputcasesByIdVO.getTextId())
|
|
|
|
+ .set("modifier", qcInputcasesByIdVO.getCreator())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = update(qcInputcasesQuery);
|
|
|
|
+ if (res) {
|
|
|
|
+ UpdateWrapper<QcInputcasesMapping> qcMappingQuery = new UpdateWrapper<>();
|
|
|
|
+ qcMappingQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("text_id", qcInputcasesByIdVO.getTextId())
|
|
|
|
+ .set("modifier", qcInputcasesByIdVO.getCreator())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = qcInputcasesMappingService.update(qcMappingQuery);
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<QcAllInputcasesDTO> getAllInputcases(QcInputcasesAllVO qcInputcasesAllVO){
|
|
|
|
+ List<Long> hospitalIds = new ArrayList<>();
|
|
|
|
+ if (StringUtil.isNotEmpty(qcInputcasesAllVO.getHospitalName())){
|
|
|
|
+ QueryWrapper<QcHospitalInfo> qcHospitalInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ qcHospitalInfoQueryWrapper.eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
|
+ .like("name",qcInputcasesAllVO.getHospitalName());
|
|
|
|
+ hospitalIds = qcHospitalInfoFacade.list().stream().map(QcHospitalInfo::getId).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ //病例
|
|
|
|
+ QueryWrapper<CasesNumber> casesNumberQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ casesNumberQueryWrapper.eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
|
+ .orderByDesc("gmt_modified");
|
|
|
|
+ if(StringUtil.isNotEmpty(qcInputcasesAllVO.getCaseNumber())){
|
|
|
|
+ casesNumberQueryWrapper.like("case_number",qcInputcasesAllVO.getCaseNumber());
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isNotEmpty(qcInputcasesAllVO.getHospitalName())){
|
|
|
|
+ casesNumberQueryWrapper.in("hospital_id",hospitalIds);
|
|
|
|
+ }
|
|
|
|
+ List<CasesNumber> casesNumbers = casesNumberService.list(casesNumberQueryWrapper);
|
|
|
|
+ List<QcAllInputcasesDTO> res = new ArrayList<>();
|
|
|
|
+ //病例内容
|
|
|
|
+ QueryWrapper<ModelMapping> modelMappingQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ modelMappingQueryWrapper.eq("is_deleted",IsDeleteEnum.N.getKey());
|
|
|
|
+ List<ModelMapping> modelMappings = modelMappingService.list();
|
|
|
|
+ Map<Long, List<ModelMapping>> modelMap
|
|
|
|
+ = EntityUtil.makeEntityListMap(modelMappings, "modeId");
|
|
|
|
+ //病例列表
|
|
|
|
+ QueryWrapper<Mode> modelQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ modelQueryWrapper.eq("is_deleted",IsDeleteEnum.N.getKey());
|
|
|
|
+ List<Mode> modes = modeService.list();
|
|
|
|
+ Map<Long,String> modeMap = new HashMap<>();
|
|
|
|
+ modeMap = modes.stream().collect(Collectors.toMap(Mode::getId,mode -> mode.getName()));
|
|
|
|
+ //病例列表
|
|
|
|
+ QueryWrapper<QcHospitalInfo> hospitalInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ hospitalInfoQueryWrapper.eq("is_deleted",IsDeleteEnum.N.getKey());
|
|
|
|
+ List<QcHospitalInfo> qcHospitalInfos = qcHospitalInfoFacade.list();
|
|
|
|
+ Map<Long,String> hospitalMap = new HashMap<>();
|
|
|
|
+ hospitalMap = qcHospitalInfos.stream().collect(Collectors.toMap(QcHospitalInfo::getId,hospitalInfo -> hospitalInfo.getName()));
|
|
|
|
+ //将病例内容放入出参
|
|
|
|
+ res = BeanUtil.listCopyTo(casesNumbers,QcAllInputcasesDTO.class);
|
|
|
|
+ List<ModuleMappingDTO> moduleMappingDTOS = new ArrayList<>();
|
|
|
|
+ List<Long> modIds = new ArrayList<>();
|
|
|
|
+ ModuleMappingDTO moduleMappingDTO = new ModuleMappingDTO();
|
|
|
|
+ List<String> modeList = new ArrayList();
|
|
|
|
+ for (QcAllInputcasesDTO qcAllInputcasesDTO : res) {
|
|
|
|
+ moduleMappingDTOS = new ArrayList<>();
|
|
|
|
+ for (Mode mode : modes) {
|
|
|
|
+ moduleMappingDTO = new ModuleMappingDTO();
|
|
|
|
+ moduleMappingDTO.setModeId(mode.getId());
|
|
|
|
+ moduleMappingDTO.setName(mode.getName());
|
|
|
|
+ if(modelMap.get(mode.getId()) != null){
|
|
|
|
+ modeList = new ArrayList();
|
|
|
|
+ for (ModelMapping modelMapping: modelMap.get(mode.getId())) {
|
|
|
|
+ if (modelMapping.getCaseNumberId().intValue() == qcAllInputcasesDTO.getId()){
|
|
|
|
+ modeList.add(modelMapping.getText());
|
|
|
|
+ moduleMappingDTO.setText(modeList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ moduleMappingDTOS.add(moduleMappingDTO);
|
|
|
|
+ }
|
|
|
|
+ qcAllInputcasesDTO.setHospitalName(hospitalMap.get(Long.parseLong(qcAllInputcasesDTO.getHospitalId())));
|
|
|
|
+ qcAllInputcasesDTO.setModuleMappingDTOList(moduleMappingDTOS);
|
|
|
|
+ }
|
|
|
|
+ /* for (QcAllInputcasesDTO qcAllInputcasesDTO : res) {
|
|
|
|
+ for (ModelMapping modelMapping : modelMappings) {
|
|
|
|
+ if (qcAllInputcasesDTO.getId().intValue() == modelMapping.getCaseNumberId().intValue()){
|
|
|
|
+ if(!modIds.contains(modelMapping.getModeId())){
|
|
|
|
+ moduleMappingDTO = new ModuleMappingDTO();
|
|
|
|
+ moduleMappingDTO.setModeId(modelMapping.getModeId());
|
|
|
|
+ moduleMappingDTO.setName(modeMap.get(modelMapping.getModeId()));
|
|
|
|
+ moduleMappingDTO.setText(modelMapping.getText());
|
|
|
|
+ moduleMappingDTOS.add(moduleMappingDTO);
|
|
|
|
+ modIds.add(modelMapping.getModeId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ qcAllInputcasesDTO.setHospitalName(hospitalMap.get(Long.parseLong(qcAllInputcasesDTO.getHospitalId())));
|
|
|
|
+ qcAllInputcasesDTO.setModuleMappingDTOList(moduleMappingDTOS);
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ // 查出所有病例病例类型
|
|
|
|
+ List<QcInputcasesMappingDTO> qcInputcasesMapping = qcInputcasesMappingService.getInputMapping(qcInputcasesAllVO.getCaseNumber());
|
|
|
|
+ // 然后把所有病例类型放进去
|
|
|
|
+ Map<Long, List<QcInputcasesMappingDTO>> map
|
|
|
|
+ = EntityUtil.makeEntityListMap(qcInputcasesMapping, "caseNumberId");
|
|
|
|
+ if (res.size() > 0) {
|
|
|
|
+ for (QcAllInputcasesDTO ts : res) {
|
|
|
|
+ List<QcInputcasesMappingDTO> tmp = map.get(ts.getId().toString());
|
|
|
|
+ if (ListUtil.isNotEmpty(tmp)) {
|
|
|
|
+ ts.setQcInputcasesMapping(tmp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param qcInputcasesByIdVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean deleteById(QcInputcasesByIdVO qcInputcasesByIdVO) {
|
|
|
|
+ boolean res = false;
|
|
|
|
+ UpdateWrapper<QcInputcases> qcInputcasesQuery = new UpdateWrapper<>();
|
|
|
|
+ qcInputcasesQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", qcInputcasesByIdVO.getCaseNumberId())
|
|
|
|
+ .set("modifier", qcInputcasesByIdVO.getCreator())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = update(qcInputcasesQuery);
|
|
|
|
+ if (res) {
|
|
|
|
+ UpdateWrapper<QcInputcasesMapping> qcMappingQuery = new UpdateWrapper<>();
|
|
|
|
+ qcMappingQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("case_number_id", qcInputcasesByIdVO.getCaseNumberId())
|
|
|
|
+ .set("modifier", qcInputcasesByIdVO.getCreator())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = qcInputcasesMappingService.update(qcMappingQuery);
|
|
|
|
+ }
|
|
|
|
+ if (res) {
|
|
|
|
+ UpdateWrapper<ModelMapping> modelMappingUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ modelMappingUpdateWrapper
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("case_number_id", qcInputcasesByIdVO.getCaseNumberId())
|
|
|
|
+ .set("modifier", qcInputcasesByIdVO.getCreator())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = modelMappingService.update(modelMappingUpdateWrapper);
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param qcInputcasesSaveVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean saveOrUpdata(QcInputcasesSaveVO qcInputcasesSaveVO) {
|
|
|
|
+ boolean res = false;
|
|
|
|
+ if (qcInputcasesSaveVO.getCaseNumberId() != null && qcInputcasesSaveVO.getCaseNumberId() != 0) {
|
|
|
|
+ //校验数据是否存在
|
|
|
|
+ QueryWrapper<CasesNumber> casesNumberQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ Map<String, Object> mapAll = new HashMap<>();
|
|
|
|
+ mapAll.put("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ mapAll.put("id", qcInputcasesSaveVO.getCaseNumberId());
|
|
|
|
+ casesNumberQueryWrapper.allEq(mapAll);
|
|
|
|
+ int sum = casesNumberService.count(casesNumberQueryWrapper);
|
|
|
|
+ if (sum == 0) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病例不存在");
|
|
|
|
+ }
|
|
|
|
+ UpdateWrapper<CasesNumber> casesNumberUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ casesNumberUpdateWrapper
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", qcInputcasesSaveVO.getCaseNumberId())
|
|
|
|
+ .set("gmt_modified", DateUtil.now())
|
|
|
|
+ .set("creator", qcInputcasesSaveVO.getCreator())
|
|
|
|
+ .set("hospital_id", qcInputcasesSaveVO.getHospitalId())
|
|
|
|
+ .set("case_number", qcInputcasesSaveVO.getCaseNumber())
|
|
|
|
+ .set("is_tag", qcInputcasesSaveVO.getIsTag());
|
|
|
|
+ res = casesNumberService.update(casesNumberUpdateWrapper);
|
|
|
|
+ /* UpdateWrapper<ModelMapping> modelMappingUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ modelMappingUpdateWrapper
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("case_number_id", qcInputcasesSaveVO.getId())
|
|
|
|
+ .set("gmt_modified", DateUtil.now())
|
|
|
|
+ .set("creator", qcInputcasesSaveVO.getCreator())
|
|
|
|
+ .set("mode_id", qcInputcasesSaveVO.getModeId())
|
|
|
|
+ .set("text", qcInputcasesSaveVO.getText());
|
|
|
|
+ res = modelMappingService.update(modelMappingUpdateWrapper);*/
|
|
|
|
+ QueryWrapper<QcInputcasesMapping> qcMappingQuery = new QueryWrapper<>();
|
|
|
|
+ qcMappingQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("case_number_id", qcInputcasesSaveVO.getCaseNumberId());
|
|
|
|
+ res = qcInputcasesMappingService.remove(qcMappingQuery);
|
|
|
|
+ List<QcInputMappingSaveVO> inputMapping = qcInputcasesSaveVO.getQcInputMappingSaveVO();
|
|
|
|
+
|
|
|
|
+ List<QcInputcasesMapping> qcMappingList = new ArrayList<>();
|
|
|
|
+ for (QcInputMappingSaveVO t : inputMapping) {
|
|
|
|
+ QcInputcasesMapping qcList = new QcInputcasesMapping();
|
|
|
|
+ qcList.setCasesEntryId(t.getCasesEntryId());
|
|
|
|
+ qcList.setCreator(qcInputcasesSaveVO.getCreator());
|
|
|
|
+ qcList.setCasesId(t.getCasesId());
|
|
|
|
+ qcList.setPass(t.getPass());
|
|
|
|
+ qcList.setCaseNumberId(qcInputcasesSaveVO.getCaseNumberId());
|
|
|
|
+ qcList.setGmtModified(DateUtil.now());
|
|
|
|
+ qcMappingList.add(qcList);
|
|
|
|
+ }
|
|
|
|
+ res = qcInputcasesMappingService.saveBatch(qcMappingList);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ CasesNumber casesNumber = new CasesNumber();
|
|
|
|
+ casesNumber.setGmtModified(DateUtil.now());
|
|
|
|
+ casesNumber.setCreator(qcInputcasesSaveVO.getCreator());
|
|
|
|
+ casesNumber.setCaseNumber(qcInputcasesSaveVO.getCaseNumber());
|
|
|
|
+ casesNumber.setHospitalId(qcInputcasesSaveVO.getHospitalId().toString());
|
|
|
|
+ casesNumber.setIsTag(qcInputcasesSaveVO.getIsTag());
|
|
|
|
+ casesNumber.setId(qcInputcasesSaveVO.getCaseNumberId());
|
|
|
|
+ res = casesNumberService.save(casesNumber);
|
|
|
|
+ /* ModelMapping modelMapping = new ModelMapping();
|
|
|
|
+ modelMapping.setCaseNumberId(qcInputcasesSaveVO.getCaseNumberId());
|
|
|
|
+ modelMapping.setCreator(qcInputcasesSaveVO.getCreator());
|
|
|
|
+ modelMapping.setGmtCreate(DateUtil.now());
|
|
|
|
+ modelMapping.setModeId(qcInputcasesSaveVO.getModeId());
|
|
|
|
+ modelMapping.setText(qcInputcasesSaveVO.getText());
|
|
|
|
+ res = modelMappingService.save(modelMapping);*/
|
|
|
|
+ List<QcInputMappingSaveVO> inputMapping = qcInputcasesSaveVO.getQcInputMappingSaveVO();
|
|
|
|
+ if (res) {
|
|
|
|
+ List<QcInputcasesMapping> qcMappingList = new ArrayList<>();
|
|
|
|
+ for (QcInputMappingSaveVO t : inputMapping) {
|
|
|
|
+ QcInputcasesMapping qcList = new QcInputcasesMapping();
|
|
|
|
+ qcList.setCasesEntryId(t.getCasesEntryId());
|
|
|
|
+ qcList.setCreator(qcInputcasesSaveVO.getCreator());
|
|
|
|
+ qcList.setCasesId(t.getCasesId());
|
|
|
|
+ qcList.setPass(t.getPass());
|
|
|
|
+ qcList.setCaseNumberId(casesNumber.getId());
|
|
|
|
+ qcMappingList.add(qcList);
|
|
|
|
+ }
|
|
|
|
+ res = qcInputcasesMappingService.saveBatch(qcMappingList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+}
|