|
|
|
package com.supervision.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
import com.supervision.model.*;
|
|
|
|
import com.supervision.model.Process;
|
|
|
|
import com.supervision.pojo.vo.AskAncillaryResultReqVO;
|
|
|
|
import com.supervision.service.*;
|
|
|
|
import com.supervision.util.UserUtil;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import org.apache.commons.collections4.SetUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
public class AskAncillaryServiceImpl implements AskAncillaryService {
|
|
|
|
|
|
|
|
private final ProcessService processService;
|
|
|
|
|
|
|
|
private final DiseaseAncillaryService diseaseAncillaryService;
|
|
|
|
|
|
|
|
private final ConfigAncillaryItemService ancillaryItemService;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, List<ConfigAncillaryItem>> queryAncillaryItemList() {
|
|
|
|
List<ConfigAncillaryItem> list = ancillaryItemService.lambdaQuery().list();
|
|
|
|
return list.stream().collect(Collectors.groupingBy(ConfigAncillaryItem::getType));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DiagnosisAncillaryRecord execAskAncillaryResult(AskAncillaryResultReqVO reqVO) {
|
|
|
|
// 首先根据process_id查新到流程ID
|
|
|
|
Process process = Optional.ofNullable(processService.getById(reqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到流程ID"));
|
|
|
|
// 找到对应的项目的检查结果
|
|
|
|
|
|
|
|
DiseaseAncillary diseaseAncillary = diseaseAncillaryService.lambdaQuery().eq(DiseaseAncillary::getPatientId, process.getPatientId()).eq(DiseaseAncillary::getItemId, reqVO.getItemId())
|
|
|
|
.oneOpt().orElseGet(() -> {
|
|
|
|
DiseaseAncillary get = new DiseaseAncillary();
|
|
|
|
get.setResult("无相关资讯");
|
|
|
|
return get;
|
|
|
|
});
|
|
|
|
DiagnosisAncillaryRecord record = new DiagnosisAncillaryRecord();
|
|
|
|
record.setProcessId(process.getId());
|
|
|
|
record.setItemId(reqVO.getItemId());
|
|
|
|
record.setPrimaryId(reqVO.getPrimaryId());
|
|
|
|
record.setResult(diseaseAncillary.getResult());
|
|
|
|
record.setCreateUserId(UserUtil.getUser().getId());
|
|
|
|
record.setUpdateUserId(UserUtil.getUser().getId());
|
|
|
|
return record;
|
|
|
|
}
|
|
|
|
}
|