From e1e336f9c2799dacb05e7904b71b5b13a2150182 Mon Sep 17 00:00:00 2001 From: xueqingkun Date: Wed, 7 Feb 2024 10:26:16 +0800 Subject: [PATCH] =?UTF-8?q?manage=20:=20=E4=BF=AE=E6=94=B9=20queryMedicalD?= =?UTF-8?q?efaultAnswer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MedicalRecManageServiceImpl.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java index bc2aebef..ed2ed2d1 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java @@ -318,15 +318,19 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService { CommonDic systemDic = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").eq(CommonDic::getCode, "system").one(); Assert.notNull(systemDic, "未找到系统问题"); + List childCommonDicList = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT") + .eq(CommonDic::getParentId, systemDic.getId()).list(); + Assert.notNull(childCommonDicList, "未找到系统问题下的子问题"); + Map childCommonDicMap = childCommonDicList.stream().collect(Collectors.toMap(CommonDic::getId, Function.identity())); - Long systemDicId = systemDic.getId(); - + // 从疾病问题记录中查询数据 if (StrUtil.isNotEmpty(medicalRecId)) { List askPatientAnswerList = askPatientAnswerService.lambdaQuery() .eq(AskPatientAnswer::getMedicalId, medicalRecId).eq(AskPatientAnswer::getAnswerType, 0).list(); final Map libraryMap = new HashMap<>(); if (CollUtil.isNotEmpty(askPatientAnswerList)){ + // 查询问题库信息 List questionIds = askPatientAnswerList.stream() .map(AskPatientAnswer::getLibraryQuestionId).filter(Objects::nonNull).collect(Collectors.toList()); Map libraryMapTemp = askTemplateQuestionLibraryService.listByIds(questionIds) @@ -337,22 +341,28 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService { MedicalRecQaVO medicalRecQaVO = new MedicalRecQaVO(); medicalRecQaVO.setId(e.getId()); medicalRecQaVO.setLibraryQuestionId(e.getLibraryQuestionId()); - medicalRecQaVO.setDictId(systemDicId); - medicalRecQaVO.setDictNamePath(systemDic.getNameZhPath()); medicalRecQaVO.setMedicalRecAnswer(e.getAnswer()); + // 组装问题列表 和 字典数据 AskTemplateQuestionLibrary askTemplateQuestionLibrary = libraryMap.get(e.getLibraryQuestionId()); if (Objects.nonNull(askTemplateQuestionLibrary)){ medicalRecQaVO.setQuestionList(askTemplateQuestionLibrary.getQuestion()); + Long dictId = askTemplateQuestionLibrary.getDictId(); + if (Objects.nonNull(dictId)){ + medicalRecQaVO.setDictId(dictId); + medicalRecQaVO.setDictNamePath(childCommonDicMap.getOrDefault(dictId, new CommonDic()).getNameZhPath()); + } } return medicalRecQaVO; }).collect(Collectors.toList()); } - List askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.lambdaQuery().eq(AskTemplateQuestionLibrary::getDictId, systemDicId).list(); + + // 从问题库中查询数据 + List commonDicIdList = childCommonDicList.stream().map(CommonDic::getId).collect(Collectors.toList()); + List askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.lambdaQuery().in(AskTemplateQuestionLibrary::getDictId, commonDicIdList).list(); return askTemplateQuestionLibraryList.stream().map(e -> { MedicalRecQaVO medicalRecQaVO = new MedicalRecQaVO(); medicalRecQaVO.setLibraryQuestionId(e.getId()); - medicalRecQaVO.setDictId(systemDicId); - medicalRecQaVO.setDictNamePath(systemDic.getNameZhPath()); + medicalRecQaVO.setDictNamePath(childCommonDicMap.getOrDefault(e.getDictId(), new CommonDic()).getNameZhPath()); medicalRecQaVO.setMedicalRecAnswer(e.getDefaultAnswer()); medicalRecQaVO.setQuestionList(e.getQuestion()); return medicalRecQaVO;