You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.9 KiB
Java
60 lines
2.9 KiB
Java
2 years ago
|
package com.supervision.service.impl;
|
||
|
|
||
|
import cn.hutool.core.util.StrUtil;
|
||
|
import com.supervision.exception.BusinessException;
|
||
|
import com.supervision.model.*;
|
||
|
import com.supervision.model.Process;
|
||
|
import com.supervision.pojo.vo.AskPhysicalResultReqVO;
|
||
|
import com.supervision.service.*;
|
||
|
import com.supervision.util.UserUtil;
|
||
|
import lombok.RequiredArgsConstructor;
|
||
|
import org.springframework.stereotype.Service;
|
||
|
|
||
|
import java.util.Optional;
|
||
|
|
||
|
@Service
|
||
|
@RequiredArgsConstructor
|
||
|
public class AskPhysicalServiceImpl implements AskPhysicalService {
|
||
|
|
||
|
private final ConfigPhysicalLocationService locationService;
|
||
|
|
||
|
private final ConfigPhysicalToolService toolService;
|
||
|
|
||
|
private final DiseasePhysicalService diseasePhysicalService;
|
||
|
|
||
|
private final ProcessService processService;
|
||
|
|
||
|
@Override
|
||
|
public DiagnosisPhysicalRecord queryAskPhysicalResult(AskPhysicalResultReqVO reqVO) {
|
||
|
// 首先根据process_id查新到流程ID
|
||
|
Process process = Optional.ofNullable(processService.getById(reqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到流程ID"));
|
||
|
ConfigPhysicalTool tool = toolService.lambdaQuery().eq(ConfigPhysicalTool::getToolName, reqVO.getToolName()).last("limit 1")
|
||
|
.oneOpt().orElseThrow(() -> new BusinessException("工具不支持"));
|
||
|
// 是否需要具体的部位,0否1是
|
||
|
String locationId = null;
|
||
|
if (1 == tool.getRequireLocation()){
|
||
|
ConfigPhysicalLocation location = locationService.lambdaQuery().eq(ConfigPhysicalLocation::getLocationName, reqVO.getLocationName()).last("limit 1")
|
||
|
.oneOpt().orElseThrow(() -> new BusinessException("为找到对应部位"));
|
||
|
locationId = location.getId();
|
||
|
}
|
||
|
DiseasePhysical result = diseasePhysicalService.lambdaQuery().eq(DiseasePhysical::getPatientId, process.getPatientId())
|
||
|
.eq(DiseasePhysical::getToolId, tool.getId()).eq(StrUtil.isNotBlank(locationId), DiseasePhysical::getLocationId, locationId).last("limit 1")
|
||
|
.oneOpt()
|
||
|
.orElseGet(() -> {
|
||
|
DiseasePhysical diseasePhysical = new DiseasePhysical();
|
||
|
diseasePhysical.setResult("无相关资讯");
|
||
|
return diseasePhysical;
|
||
|
});
|
||
|
// 检查记录保存到数据库中
|
||
|
DiagnosisPhysicalRecord diagnosisPhysicalRecord = new DiagnosisPhysicalRecord();
|
||
|
diagnosisPhysicalRecord.setProcessId(process.getId());
|
||
|
diagnosisPhysicalRecord.setToolId(tool.getId());
|
||
|
diagnosisPhysicalRecord.setLocationId(locationId);
|
||
|
diagnosisPhysicalRecord.setResult(result.getResult());
|
||
|
diagnosisPhysicalRecord.setCreateUserId(UserUtil.getUser().getCreateUserId());
|
||
|
diagnosisPhysicalRecord.setUpdateUserId(UserUtil.getUser().getCreateUserId());
|
||
|
diagnosisPhysicalRecord.insert();
|
||
|
return diagnosisPhysicalRecord;
|
||
|
}
|
||
|
}
|