diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java b/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java index 0efebcd0..acb4a902 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java @@ -15,7 +15,7 @@ import java.util.List; @Api(tags = "疾病体格检查管理") @RestController -@RequestMapping("diseasePhysical") +@RequestMapping("/diseasePhysical") @RequiredArgsConstructor public class DiseasePhysicalManageController { diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java index 41063481..14d0fe05 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java @@ -1,14 +1,15 @@ package com.supervision.manage.service.impl; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import com.supervision.manage.service.DiseasePhysicalManageService; import com.supervision.manage.service.PhysicalLocationManageService; +import com.supervision.model.ConfigPhysicalLocation; import com.supervision.model.DefaultPhysicalIndicator; import com.supervision.model.DiseasePhysical; +import com.supervision.service.ConfigPhysicalLocationService; import com.supervision.service.DefaultPhysicalIndicatorService; import com.supervision.service.DiseasePhysicalService; import com.supervision.vo.manage.DiseasePhysicalLocationNodeVo; @@ -30,6 +31,8 @@ public class DiseasePhysicalManageServiceImpl implements DiseasePhysicalManageSe private final PhysicalLocationManageService physicalToolManageService; + private final ConfigPhysicalLocationService configPhysicalLocationService; + private final DefaultPhysicalIndicatorService defaultPhysicalIndicatorService; @@ -88,24 +91,32 @@ public class DiseasePhysicalManageServiceImpl implements DiseasePhysicalManageSe DiseasePhysicalLocationNodeVo bean = BeanUtil.toBean(physicalLocationNode, DiseasePhysicalLocationNodeVo.class); if (StrUtil.isEmpty(toolId)){ + // 工具id为空,全部设置为禁用标识 + bean.getChild().forEach(vo->vo.setFlag(true)); return bean.getChild(); } - // 2. 根据疾病id查询疾病体格检查项 - List diseasePhysicalResVos = diseasePhysicalService.queryListByDiseaseId(diseaseId); - if (CollectionUtil.isEmpty(diseasePhysicalResVos)){ + + // 在体格检查配置身体位置时,只能配置一级部位,此时默认下级的部位也已经被配置。如果工具没有设置,应该子节点设置为禁用 + List defaultPhysicalIndicatorList = defaultPhysicalIndicatorService.lambdaQuery().eq(DefaultPhysicalIndicator::getItemId, toolId).list(); + if (CollectionUtil.isEmpty(defaultPhysicalIndicatorList)){ + // 如果未配置,所有子节点设置为禁用 + bean.getChild().forEach(vo->vo.setFlag(true)); return bean.getChild(); } + // 2. 根据疾病id查询疾病体格检查项 + List diseasePhysicalResVos = diseasePhysicalService.queryListByDiseaseId(diseaseId); + List locationIds = diseasePhysicalResVos.stream().filter(vo->toolId.equals(vo.getToolId())) + .map(DiseasePhysical::getLocationId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + // 3. 填充疾病体格检查树中的flag属性 // 3.1 检查该位置是否已经配置 // 3.2检查工具没有配置检查位,设置禁用标识 - List locationIds = diseasePhysicalResVos.stream().filter(vo->toolId.equals(vo.getToolId())) - .map(DiseasePhysical::getLocationId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); - List defaultPhysicalIndicatorList = defaultPhysicalIndicatorService.lambdaQuery().eq(DefaultPhysicalIndicator::getItemId, toolId).list(); - if (CollectionUtil.isEmpty(defaultPhysicalIndicatorList)){ - return bean.getChild(); - } - // node: 现在认为一个检查项目和一个位置组成一条唯一数据 + // 二次子集查询身体部位 + List parentIds = defaultPhysicalIndicatorList.stream().map(DefaultPhysicalIndicator::getLocationId).distinct().collect(Collectors.toList()); + List childLocationIds = configPhysicalLocationService.lambdaQuery().in(ConfigPhysicalLocation::getParentId, parentIds) + .list().stream().map(ConfigPhysicalLocation::getId).collect(Collectors.toList()); + // note: 现在认为一个检查项目和一个位置组成一条唯一数据 Map indicatorMap = defaultPhysicalIndicatorList.stream() .collect(Collectors.toMap(DefaultPhysicalIndicator::getLocationId, p -> p, (v1, v2) -> v1)); for (DiseasePhysicalLocationNodeVo diseasePhysicalLocationNodeVo : bean.getChild()) { @@ -116,8 +127,11 @@ public class DiseasePhysicalManageServiceImpl implements DiseasePhysicalManageSe } for (DiseasePhysicalLocationNodeVo physicalLocationNodeVo : child) { String nodeId = physicalLocationNodeVo.getId(); + // 1. 该位置是否已经配置 结果为禁用 + // 2. 该身体部位(下级部位)配置了默认检查结果,结果为可用 physicalLocationNodeVo.setFlag( - locationIds.contains(nodeId) || !indicatorMap.containsKey(nodeId)); + locationIds.contains(nodeId) || + !(indicatorMap.containsKey(nodeId) || childLocationIds.contains(nodeId))); if (Objects.nonNull(indicatorMap.get(nodeId))) { physicalLocationNodeVo.setIndicatorValue(indicatorMap.get(nodeId).getIndicatorValue()); } @@ -126,18 +140,6 @@ public class DiseasePhysicalManageServiceImpl implements DiseasePhysicalManageSe return bean.getChild(); } - - private void populateDiseasePhysicalLocationNodeFlag(DiseasePhysicalLocationNodeVo node,List locationIds) { - if (StrUtil.isNotEmpty(node.getId())){ - node.setFlag(locationIds.contains(node.getId())); - } - if (CollectionUtil.isNotEmpty(node.getChild())){ - for (DiseasePhysicalLocationNodeVo childNode : node.getChild()) { - populateDiseasePhysicalLocationNodeFlag(childNode,locationIds); - } - } - } - private void assertDiseasePhysical(DiseasePhysical diseasePhysical){ Assert.isTrue(StrUtil.isNotEmpty(diseasePhysical.getDiseaseId()),"疾病id不能为空");