|
|
|
@ -3,6 +3,7 @@ package com.supervision.service.impl;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.model.*;
|
|
|
|
@ -15,6 +16,7 @@ import com.supervision.vo.ask.DiagnosisPhysicalRecordVo;
|
|
|
|
|
import com.supervision.vo.ask.AskPhysicalHistoryResVO;
|
|
|
|
|
import com.supervision.vo.ask.DiagnosisPrimaryVO;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -23,6 +25,7 @@ import java.util.function.Function;
|
|
|
|
|
import java.util.function.Predicate;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class AskPhysicalServiceImpl implements AskPhysicalService {
|
|
|
|
@ -41,6 +44,7 @@ public class AskPhysicalServiceImpl implements AskPhysicalService {
|
|
|
|
|
|
|
|
|
|
private final DiagnosisPrimaryService diagnosisPrimaryService;
|
|
|
|
|
|
|
|
|
|
private final DefaultPhysicalIndicatorService defaultPhysicalIndicatorService;
|
|
|
|
|
@Override
|
|
|
|
|
public List<ConfigPhysicalToolResVO> queryPhysicalToolList() {
|
|
|
|
|
|
|
|
|
@ -62,16 +66,12 @@ public class AskPhysicalServiceImpl implements AskPhysicalService {
|
|
|
|
|
.oneOpt().orElseGet(ConfigPhysicalLocation::new);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConfigPhysicalLocation finalLocation = location;
|
|
|
|
|
DiseasePhysical result = diseasePhysicalService.lambdaQuery().eq(DiseasePhysical::getDiseaseId, process.getDiseaseId())
|
|
|
|
|
.eq(DiseasePhysical::getToolId, tool.getId())
|
|
|
|
|
.eq(StrUtil.isNotBlank(location.getId()), DiseasePhysical::getLocationId, location.getId()).last("limit 1")
|
|
|
|
|
.oneOpt()
|
|
|
|
|
.orElseGet(() -> {
|
|
|
|
|
DiseasePhysical diseasePhysical = new DiseasePhysical();
|
|
|
|
|
diseasePhysical.setResult("无相关资讯");
|
|
|
|
|
return diseasePhysical;
|
|
|
|
|
});
|
|
|
|
|
.orElseGet(() -> queryDefaultPhysicalResult(tool.getId(), finalLocation.getId()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查记录保存到数据库中
|
|
|
|
@ -103,6 +103,51 @@ public class AskPhysicalServiceImpl implements AskPhysicalService {
|
|
|
|
|
return resVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询默认的体格检查结果
|
|
|
|
|
*/
|
|
|
|
|
private DiseasePhysical queryDefaultPhysicalResult(String itemId, String locationId) {
|
|
|
|
|
DiseasePhysical diseasePhysical = new DiseasePhysical();
|
|
|
|
|
try {
|
|
|
|
|
// 首先判断位置是否是空,如果位置是空,就查找不需要位置的默认值
|
|
|
|
|
if (StrUtil.isBlank(locationId)) {
|
|
|
|
|
DefaultPhysicalIndicator noLocationIndicator = defaultPhysicalIndicatorService.lambdaQuery().eq(DefaultPhysicalIndicator::getItemId, itemId).last("limit 1").one();
|
|
|
|
|
if (ObjectUtil.isEmpty(noLocationIndicator)) {
|
|
|
|
|
diseasePhysical.setResult("无相关资讯");
|
|
|
|
|
return diseasePhysical;
|
|
|
|
|
}
|
|
|
|
|
diseasePhysical.setResult(noLocationIndicator.getIndicatorValue());
|
|
|
|
|
return diseasePhysical;
|
|
|
|
|
}
|
|
|
|
|
// 如果位置不为空,则根据位置去找
|
|
|
|
|
DefaultPhysicalIndicator locationPhysicalIndicator = defaultPhysicalIndicatorService.lambdaQuery().eq(DefaultPhysicalIndicator::getItemId, itemId)
|
|
|
|
|
.eq(DefaultPhysicalIndicator::getLocationId, locationId).last("limit 1").one();
|
|
|
|
|
// 如果不为空,则返回结果
|
|
|
|
|
if (ObjectUtil.isNotEmpty(locationPhysicalIndicator)) {
|
|
|
|
|
diseasePhysical.setResult(locationPhysicalIndicator.getIndicatorValue());
|
|
|
|
|
return diseasePhysical;
|
|
|
|
|
}
|
|
|
|
|
// 如果为空,则根据上级部位去查
|
|
|
|
|
ConfigPhysicalLocation location = locationService.getById(locationId);
|
|
|
|
|
if (ObjectUtil.isNotEmpty(location) && ObjectUtil.isNotEmpty(location.getParentId())) {
|
|
|
|
|
DefaultPhysicalIndicator parentPhysicalIndicator = defaultPhysicalIndicatorService.lambdaQuery().eq(DefaultPhysicalIndicator::getItemId, itemId)
|
|
|
|
|
.eq(DefaultPhysicalIndicator::getLocationId, location.getParentId()).last("limit 1").one();
|
|
|
|
|
// 如果不为空,则返回结果
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parentPhysicalIndicator)) {
|
|
|
|
|
diseasePhysical.setResult(parentPhysicalIndicator.getIndicatorValue());
|
|
|
|
|
return diseasePhysical;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 最终,返回未找到
|
|
|
|
|
diseasePhysical.setResult("无相关资讯");
|
|
|
|
|
return diseasePhysical;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("查询默认值错误", e);
|
|
|
|
|
diseasePhysical.setResult("无相关资讯");
|
|
|
|
|
return diseasePhysical;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<AskPhysicalHistoryResVO> queryAskPhysicalHistory(String processId) {
|
|
|
|
|