manage : 添加 导入疾病问题回答 功能
parent
45260cadc8
commit
9c78933477
@ -1,25 +0,0 @@
|
||||
package com.supervision.manage.controller.medicalrec;
|
||||
|
||||
import com.supervision.manage.service.AnswerVideoResourceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Api(tags = "病历管理")
|
||||
@RestController
|
||||
@RequestMapping("/answerVideo")
|
||||
@RequiredArgsConstructor
|
||||
public class AnswerVideoResourceController {
|
||||
|
||||
private final AnswerVideoResourceService answerVideoResourceService;
|
||||
|
||||
@ApiOperation("初步诊断下拉列表联想(这个接口查询所有疾病,包含复合疾病)")
|
||||
@GetMapping("/preGenerationMedicalAnswerVideo")
|
||||
public void preGenerationMedicalAnswerVideo(String medicalId) {
|
||||
answerVideoResourceService.preGenerationMedicalAnswerVideo(medicalId);
|
||||
}
|
||||
}
|
@ -0,0 +1,225 @@
|
||||
package com.supervision.manage.dto;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.supervision.model.AskPatientAnswer;
|
||||
import com.supervision.model.AskTemplateQuestionLibrary;
|
||||
import com.supervision.model.MaterialLibrary;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class MedicalRecAnswerExcelDTO {
|
||||
|
||||
/**
|
||||
* 问诊类目1
|
||||
*/
|
||||
@Alias(value = "问诊类目Ⅰ")
|
||||
private String questionTypeOne;
|
||||
|
||||
/**
|
||||
* 问诊类目2
|
||||
*/
|
||||
@Alias(value = "问诊类目Ⅱ")
|
||||
private String questionTypeTwo;
|
||||
|
||||
/**
|
||||
* 问题
|
||||
*/
|
||||
@Alias(value = "* 知识")
|
||||
private String question;
|
||||
|
||||
/**
|
||||
* 回答
|
||||
*/
|
||||
@Alias(value = "* 回答")
|
||||
private String answer;
|
||||
|
||||
/**
|
||||
* 回答视频名称
|
||||
*/
|
||||
@Alias(value = "* 视频名称")
|
||||
private String answerVideoName;
|
||||
|
||||
@Alias(value = "错误信息")
|
||||
private static String errorReason;
|
||||
|
||||
private List<ErrorCodeEnum> errorCodeEnums = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 问诊问题库id
|
||||
*/
|
||||
private String libraryQuestionId;
|
||||
|
||||
/**
|
||||
* 问诊问题id
|
||||
*/
|
||||
private String askPatientAnswerId;
|
||||
|
||||
/**
|
||||
* 回答资源id
|
||||
*/
|
||||
private String answerResourceId;
|
||||
|
||||
|
||||
public static final List<String> READ_ANSWER_VIDEO_TITLE = CollUtil.newArrayList("问诊类目Ⅰ", "问诊类目Ⅱ", "* 知识", "* 回答","* 视频名称");
|
||||
|
||||
public static final List<String> WRITE_ANSWER_VIDEO_TITLE = CollUtil.newArrayList("问诊类目Ⅰ", "问诊类目Ⅱ", "* 知识", "* 回答","* 视频名称","错误原因");
|
||||
|
||||
public static final Map<String,String> READ_HEADER_ALIAS = getReadAlias();
|
||||
|
||||
public static final Map<String,String> WRITE_HEADER_ALIAS = getWriteAlias();
|
||||
|
||||
|
||||
public void doAction(List<AskTemplateQuestionLibrary> questionLibraryList,
|
||||
List<AskPatientAnswer> askPatientAnswerList,
|
||||
List<MaterialLibrary> materialLibraryList){
|
||||
this.absentCheck();
|
||||
this.matchQuestion(questionLibraryList);
|
||||
this.matchAskPatientAnswer(askPatientAnswerList);
|
||||
this.matchAnswerResource(materialLibraryList);
|
||||
}
|
||||
|
||||
public AskPatientAnswer toAskPatientAnswer(){
|
||||
AskPatientAnswer askPatientAnswer = new AskPatientAnswer();
|
||||
askPatientAnswer.setId(this.askPatientAnswerId);
|
||||
askPatientAnswer.setAnswerResourceId(this.answerResourceId);
|
||||
askPatientAnswer.setLibraryQuestionId(this.libraryQuestionId);
|
||||
askPatientAnswer.setAnswer(this.answer);
|
||||
// 默认自定义回答
|
||||
askPatientAnswer.setAnswerType("1");
|
||||
return askPatientAnswer;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> toExcelMap(){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("questionTypeOne",this.questionTypeOne);
|
||||
map.put("questionTypeTwo",this.questionTypeTwo);
|
||||
map.put("question",this.question);
|
||||
map.put("answer",this.answer);
|
||||
map.put("answerVideoName",this.answerVideoName);
|
||||
if (CollUtil.isNotEmpty(errorCodeEnums)){
|
||||
String errorMessage = errorCodeEnums.stream().map(i -> i.desc).collect(Collectors.joining(";"));
|
||||
map.put("errorReason",errorMessage);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public void absentCheck(){
|
||||
if (StrUtil.isEmpty(questionTypeOne)){
|
||||
errorCodeEnums.add(ErrorCodeEnum.QUESTION_TYPE_ONE_EMPTY);
|
||||
}
|
||||
if (StrUtil.isEmpty(questionTypeTwo)){
|
||||
errorCodeEnums.add(ErrorCodeEnum.QUESTION_TYPE_TWO_EMPTY);
|
||||
}
|
||||
if (StrUtil.isEmpty(question)){
|
||||
errorCodeEnums.add(ErrorCodeEnum.QUESTION_EMPTY);
|
||||
}
|
||||
if (StrUtil.isEmpty(answer)){
|
||||
errorCodeEnums.add(ErrorCodeEnum.ANSWER_EMPTY);
|
||||
}
|
||||
if (StrUtil.isEmpty(answerVideoName)){
|
||||
errorCodeEnums.add(ErrorCodeEnum.ANSWER_VIDEO_NAME_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配问题库
|
||||
* @param questionLibraryList 问题库
|
||||
*/
|
||||
public void matchQuestion(List<AskTemplateQuestionLibrary> questionLibraryList){
|
||||
if (StrUtil.isEmpty(this.question)){
|
||||
return;
|
||||
}
|
||||
if (CollUtil.isEmpty(questionLibraryList)){
|
||||
errorCodeEnums.add(ErrorCodeEnum.QUESTION_NOT_FIND);
|
||||
}
|
||||
for (AskTemplateQuestionLibrary questionLibrary : questionLibraryList) {
|
||||
String description = questionLibrary.getDescription();
|
||||
List<String> questionList = questionLibrary.getQuestion();
|
||||
if (this.question.equals(description)){
|
||||
this.libraryQuestionId = questionLibrary.getId();
|
||||
return;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(questionList) && questionList.contains(this.question)){
|
||||
this.libraryQuestionId = questionLibrary.getId();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配患者回答
|
||||
* @param askPatientAnswerList 只匹配libraryQuestionId不为空的数据
|
||||
*/
|
||||
public void matchAskPatientAnswer(List<AskPatientAnswer> askPatientAnswerList){
|
||||
if (StrUtil.isEmpty(this.libraryQuestionId)
|
||||
|| StrUtil.isEmpty(this.answer) || CollUtil.isEmpty(askPatientAnswerList)){
|
||||
return;
|
||||
}
|
||||
|
||||
for (AskPatientAnswer askPatientAnswer : askPatientAnswerList) {
|
||||
String questionId = askPatientAnswer.getLibraryQuestionId();
|
||||
String answerAnswer = askPatientAnswer.getAnswer();
|
||||
if (this.libraryQuestionId.equals(questionId) && this.answer.equals(answerAnswer)){
|
||||
this.askPatientAnswerId = askPatientAnswer.getId();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void matchAnswerResource(List<MaterialLibrary> materialLibraryList){
|
||||
if (StrUtil.isEmpty(this.answerVideoName)|| CollUtil.isEmpty(materialLibraryList)){
|
||||
return;
|
||||
}
|
||||
|
||||
for (MaterialLibrary materialLibrary : materialLibraryList) {
|
||||
if (this.answerVideoName.equals(materialLibrary.getMaterialName())){
|
||||
this.answerResourceId = materialLibrary.getId();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Map<String,String> getReadAlias(){
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("问诊类目Ⅰ","questionTypeOne");
|
||||
map.put("问诊类目Ⅱ", "questionTypeTwo");
|
||||
map.put("* 知识", "question");
|
||||
map.put("* 回答", "answer");
|
||||
map.put("* 视频名称", "answerVideoName");
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<String,String> getWriteAlias(){
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("questionTypeOne","问诊类目Ⅰ");
|
||||
map.put("questionTypeTwo", "问诊类目Ⅱ");
|
||||
map.put("question", "* 知识");
|
||||
map.put("answer", "* 回答");
|
||||
map.put("answerVideoName", "* 视频名称");
|
||||
map.put("errorReason", "错误原因");
|
||||
return map;
|
||||
}
|
||||
public enum ErrorCodeEnum{
|
||||
QUESTION_TYPE_ONE_EMPTY("0001","问诊类目1不能为空"),
|
||||
QUESTION_TYPE_TWO_EMPTY("0002","问诊类目2不能为空"),
|
||||
QUESTION_EMPTY("0003","知识不能为空"),
|
||||
ANSWER_EMPTY("0004","回答不能为空"),
|
||||
ANSWER_VIDEO_NAME_EMPTY("0005","视频名称不能为空"),
|
||||
QUESTION_NOT_FIND("40001","知识未找到"),
|
||||
ANSWER_VIDEO_NAME_NOT_FIND("40002","视频不存在");
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
ErrorCodeEnum(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.supervision.manage.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MedicalAnswerVideoResVo {
|
||||
|
||||
private String message;
|
||||
|
||||
private String fileId;
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package com.supervision.manage.service;
|
||||
|
||||
|
||||
import com.supervision.manage.pojo.vo.MedicalAnswerVideoResVo;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @Description: 病例答案视频资源服务
|
||||
**/
|
||||
public interface AnswerVideoResourceService {
|
||||
|
||||
/**
|
||||
* 预生成病例答案视频
|
||||
* @param medicalId 疾病id
|
||||
*/
|
||||
void preGenerationMedicalAnswerVideo(String medicalId);
|
||||
MedicalAnswerVideoResVo generationMedicalAnswerVideo(InputStream bookStream, String medicalId) throws Exception;
|
||||
}
|
||||
|
Loading…
Reference in New Issue