|
|
|
@ -2,6 +2,8 @@ package com.supervision.manage.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
@ -20,12 +22,16 @@ import com.supervision.vo.manage.DiseaseTreatmentPlanResVo;
|
|
|
|
|
import com.supervision.vo.manage.MedicalRecPageResVO;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -34,9 +40,9 @@ import java.util.stream.Collectors;
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
private final String MEDICAL_ANSWER_EXCEL_PATH = "classpath:template/病历问诊问题导入模板.xlsx";
|
|
|
|
|
|
|
|
|
|
@Value("${answer.offline.template.empty}")
|
|
|
|
|
private String emptyTemplateResourceId;
|
|
|
|
|
private final ResourceLoader resourceLoader;
|
|
|
|
|
|
|
|
|
|
private final DiseaseService diseaseService;
|
|
|
|
|
|
|
|
|
@ -58,7 +64,7 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
|
|
|
|
|
private final AnswerVideoResourceService answerVideoResourceService;
|
|
|
|
|
|
|
|
|
|
private final FileManageService fileManageService;
|
|
|
|
|
private final MaterialLibraryService materialLibraryService;
|
|
|
|
|
|
|
|
|
|
public List<Disease> queryDiseaseListByDropList() {
|
|
|
|
|
return diseaseService.lambdaQuery().list();
|
|
|
|
@ -241,6 +247,15 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
Set<Long> dictIdSet = askTemplateQuestionLibraryList.stream().map(AskTemplateQuestionLibrary::getDictId).collect(Collectors.toSet());
|
|
|
|
|
Map<Long, CommonDic> dictMap = commonDicService.listByIds(dictIdSet).stream().collect(Collectors.toMap(CommonDic::getId, Function.identity()));
|
|
|
|
|
|
|
|
|
|
// 获取视频资源名
|
|
|
|
|
Set<String> answerResourceIds = medicalRecQaList.stream().map(MedicalRecQaVO::getAnswerResourceId).filter(StrUtil::isNotEmpty).collect(Collectors.toSet());
|
|
|
|
|
Map<String, String> videoInfoMaps = new HashMap<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(answerResourceIds)){
|
|
|
|
|
Map<String, String> videoInfoMapsTmp = materialLibraryService.listByIds(answerResourceIds).stream()
|
|
|
|
|
.collect(Collectors.toMap(MaterialLibrary::getId, MaterialLibrary::getMaterialName));
|
|
|
|
|
videoInfoMaps.putAll(videoInfoMapsTmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (MedicalRecQaVO medicalRecQaVO : medicalRecQaList) {
|
|
|
|
|
AskTemplateQuestionLibrary questionLibrary = askQuestionMap.get(medicalRecQaVO.getLibraryQuestionId());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(questionLibrary)) {
|
|
|
|
@ -252,6 +267,8 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
medicalRecQaVO.setDictNamePath(dictMap.getOrDefault(questionLibrary.getDictId(), new CommonDic()).getNameZhPath());
|
|
|
|
|
// 默认回答
|
|
|
|
|
medicalRecQaVO.setDefaultAnswer(questionLibrary.getDefaultAnswer());
|
|
|
|
|
// 回答视频
|
|
|
|
|
medicalRecQaVO.setAnswerResourceName(videoInfoMaps.get(medicalRecQaVO.getAnswerResourceId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -287,6 +304,15 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
if (StrUtil.isNotEmpty(medicalRecId)) {
|
|
|
|
|
List<AskPatientAnswer> askPatientAnswerList = askPatientAnswerService.lambdaQuery()
|
|
|
|
|
.eq(AskPatientAnswer::getMedicalId, medicalRecId).eq(AskPatientAnswer::getAnswerType, "0").list();
|
|
|
|
|
|
|
|
|
|
final Map<String, AskTemplateQuestionLibrary> libraryMap = new HashMap<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(askPatientAnswerList)){
|
|
|
|
|
List<String> questionIds = askPatientAnswerList.stream()
|
|
|
|
|
.map(AskPatientAnswer::getLibraryQuestionId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
Map<String, AskTemplateQuestionLibrary> libraryMapTemp = askTemplateQuestionLibraryService.listByIds(questionIds)
|
|
|
|
|
.stream().collect(Collectors.toMap(AskTemplateQuestionLibrary::getId, Function.identity()));
|
|
|
|
|
libraryMap.putAll(libraryMapTemp);
|
|
|
|
|
}
|
|
|
|
|
return askPatientAnswerList.stream().map(e -> {
|
|
|
|
|
MedicalRecQaVO medicalRecQaVO = new MedicalRecQaVO();
|
|
|
|
|
medicalRecQaVO.setId(e.getId());
|
|
|
|
@ -294,6 +320,10 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
return medicalRecQaVO;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
@ -304,12 +334,20 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
medicalRecQaVO.setDictId(systemDicId);
|
|
|
|
|
medicalRecQaVO.setDictNamePath(systemDic.getNameZhPath());
|
|
|
|
|
medicalRecQaVO.setMedicalRecAnswer(e.getDefaultAnswer());
|
|
|
|
|
medicalRecQaVO.setQuestionList(e.getQuestion());
|
|
|
|
|
return medicalRecQaVO;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void downloadMedicalAnswerTemplate(HttpServletResponse response) throws Exception {
|
|
|
|
|
fileManageService.downloadFile(emptyTemplateResourceId,response);
|
|
|
|
|
Resource resource = resourceLoader.getResource(MEDICAL_ANSWER_EXCEL_PATH);
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
File file = resource.getFile();
|
|
|
|
|
response.setContentType(FileUtil.getMimeType(file.getPath()));
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" +
|
|
|
|
|
URLEncoder.encode(FileUtil.getName(file), "UTF-8"));
|
|
|
|
|
|
|
|
|
|
IoUtil.copy(resource.getInputStream(),outputStream);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|