| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertPatArchive(PatArchive patArchive) { |
| | | public Integer insertPatArchive(PatArchive patArchive) { |
| | | patArchive.setCreateTime(DateUtils.getNowDate()); |
| | | List<PatArchive> patArchives = new ArrayList<>(); |
| | | patArchives.add(patArchive); |
| | | return patArchiveMapper.insertPatArchive(patArchives); |
| | | patArchiveMapper.insertPatArchive(patArchives); |
| | | if (CollectionUtils.isNotEmpty(patArchives)) { |
| | | patArchives.get(0).getPatid(); |
| | | log.info("患者id为: {}", patArchives.get(0).getPatid()); |
| | | return patArchives.get(0).getPatid().intValue(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 修改患者档案 |
| | | * 新增或修改患者档信息 |
| | | * |
| | | * @param patArchive 患者档案 |
| | | * @param patArchiveVO 新增或修改患者档信息 |
| | | * @return 结果 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Boolean updatePatArchive(PatArchive patArchive) { |
| | | patArchive.setUpdateTime(DateUtils.getNowDate()); |
| | | public Boolean saveOrUpdatePatInfo(PatArchiveVO patArchiveVO) { |
| | | //通过isoperation来判断是否新增 |
| | | PatArchive patArchive = DtoConversionUtils.sourceToTarget(patArchiveVO, PatArchive.class); |
| | | if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 1) { |
| | | //新增 |
| | | List<PatArchive> patArchives = new ArrayList<>(); |
| | | patArchive.setUpdateTime(DateUtils.getNowDate()); |
| | | patArchives.add(patArchive); |
| | | patArchiveMapper.insertPatArchive(patArchives); |
| | | } else if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 2) { |
| | | //修改 |
| | | patArchiveMapper.updatePatArchive(patArchive); |
| | | } |
| | | |
| | | for (String tagName : patArchive.getTagList()) { |
| | | BaseTag baseTag = new BaseTag(); |
| | | baseTag.setTagname(tagName); |
| | | List<BaseTag> baseTags = baseTagMapper.selectBaseTagList(baseTag); |
| | | |
| | | if (CollectionUtils.isEmpty(baseTags)) { |
| | | baseTag = new BaseTag(); |
| | | baseTag.setTagcategoryid(1L); |
| | | baseTag.setTagname(tagName); |
| | | baseTag.setOrgid(null); |
| | | baseTag.setDelFlag("0"); |
| | | baseTag.setCreateBy(null); |
| | | baseTag.setCreateTime(new Date()); |
| | | baseTag.setCreateBy(null); |
| | | baseTag.setCreateTime(new Date()); |
| | | baseTagMapper.insertBaseTag(baseTag); |
| | | //然后再往pat_archivetag表中新增 |
| | | } else { |
| | | //如果在basetag中存在,则根据tagid和patid去pat_archivetag表中查询是否存在 |
| | | baseTag = baseTags.get(0); |
| | | PatArchivetag patArchivetag = new PatArchivetag(); |
| | | patArchivetag.setPatid(patArchive.getPatid()); |
| | | patArchivetag.setTagid(baseTag.getTagid()); |
| | | List<PatArchivetag> patArchivetags = patArchivetagMapper.selectPatArchivetagAndBaseTagList(patArchivetag); |
| | | if (CollectionUtils.isNotEmpty(patArchivetags)) { |
| | | //如果存在,continue; |
| | | continue; |
| | | } else { |
| | | //如果不存在,则则pat_archivetag中新增 |
| | | // 新增患者档案标签 |
| | | if (CollectionUtils.isNotEmpty(patArchiveVO.getTagList())) { |
| | | //处理标签(新增、删除) |
| | | for (PatArchivetag patArchivetag : patArchiveVO.getTagList()) { |
| | | if (patArchivetag.getIsoperation() != null && patArchivetag.getIsoperation() == 1) { |
| | | //新增 |
| | | patArchivetag.setUpdateBy(null); |
| | | patArchivetag.setCreateTime(new Date()); |
| | | patArchivetag.setPatid(patArchive.getPatid()); |
| | | patArchivetagMapper.insertPatArchivetag(patArchivetag); |
| | | } else if (patArchivetag.getIsoperation() != null && patArchivetag.getIsoperation() == 3) { |
| | | patArchivetag.setDelFlag("1"); |
| | | //删除 |
| | | log.info("标签的id为:{}", patArchivetag.getTagid()); |
| | | patArchivetagMapper.deletePatArchivetagById(patArchivetag); |
| | | } |
| | | } |
| | | PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag, PatArchivetag.class); |
| | | patArchivetag.setUpdateBy(null); |
| | | patArchivetag.setCreateTime(new Date()); |
| | | patArchivetag.setPatid(patArchive.getPatid()); |
| | | patArchivetagMapper.insertPatArchivetag(patArchivetag); |
| | | |
| | | } |
| | | patArchiveMapper.updatePatArchive(patArchive); |
| | | return true; |
| | | } |
| | | |
| | |
| | | //对数据进行封装 |
| | | for (List<PatArchive> list : listMap.values()) { |
| | | PatArchive patArchive1 = new PatArchive(); |
| | | Set<String> stringList = new HashSet<>(); |
| | | Set<PatArchivetag> stringList = new HashSet<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (i == 0) { |
| | | patArchive1 = DtoConversionUtils.sourceToTarget(list.get(0), PatArchive.class); |
| | |
| | | patArchive1.setTag(""); |
| | | } |
| | | //将查出的tag,放到patArchive1里的TagList中 |
| | | stringList.add(list.get(i).getTag()); |
| | | PatArchivetag patArchivetag = new PatArchivetag(); |
| | | patArchivetag.setTagname(list.get(i).getTag()); |
| | | patArchivetag.setTagid(list.get(i).getTagid()); |
| | | stringList.add(patArchivetag); |
| | | } |
| | | patArchive1.setTagList(stringList.stream().collect(Collectors.toList())); |
| | | patArchives.add(patArchive1); |