诊断流程提交

dev_v1.0.1
liu 2 years ago
parent acc0157d6d
commit 074adec6aa

@ -174,7 +174,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService
node.setType(0); node.setType(0);
node.setRecordName(e.getQuestion()); node.setRecordName(e.getQuestion());
node.setRecordId(e.getId()); node.setRecordId(e.getId());
node.setCorrect(requireCheckIdSet.contains(e.getQuestionAnswerId()) ? 1 : 0); node.setCorrect(requireCheckIdSet.contains(e.getAnswerId()) ? 1 : 0);
return node; return node;
}).collect(Collectors.toList()); }).collect(Collectors.toList());

@ -76,6 +76,7 @@ public class AskServiceImpl implements AskService {
// 这里设置的模板,对于action的动作全部是用ancillary_ | tool_进行标记,详情看生成rasa的yml的代码:RasaServiceImpl.generateDomain // 这里设置的模板,对于action的动作全部是用ancillary_ | tool_进行标记,详情看生成rasa的yml的代码:RasaServiceImpl.generateDomain
// ancillary_ | tool_ // ancillary_ | tool_
if (rasaResult.startsWith("ancillary_") || rasaResult.startsWith("tool_")) { if (rasaResult.startsWith("ancillary_") || rasaResult.startsWith("tool_")) {
log.info("呼出语句:{}", rasaResult);
List<String> actionList = StrUtil.split(rasaResult, '_'); List<String> actionList = StrUtil.split(rasaResult, '_');
if (actionList.size() > 1) { if (actionList.size() > 1) {
ActionDTO actionDTO = new ActionDTO(); ActionDTO actionDTO = new ActionDTO();
@ -90,8 +91,14 @@ public class AskServiceImpl implements AskService {
String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken());
AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult);
if (ObjectUtil.isEmpty(library)) { if (ObjectUtil.isEmpty(library)) {
log.info("{}:未从问题库中找到,回答未识别语句", rasaResult);
HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); HumanUtil.textDriven("您好,我没有听懂您说什么", roomId);
} else { } else {
AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId())
.eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one();
// 如果没有找到回答,去默认回答里面看看有没有
if (ObjectUtil.isEmpty(askPatientAnswer)) {
log.info("{}:病历配置的回答为空,尝试回答默认答案", rasaResult);
// 首先看看default里面是不是存在,如果存在,就从default里面去找 // 首先看看default里面是不是存在,如果存在,就从default里面去找
if (CollUtil.isNotEmpty(library.getDefaultAnswer())) { if (CollUtil.isNotEmpty(library.getDefaultAnswer())) {
String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size())); String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size()));
@ -106,13 +113,36 @@ public class AskServiceImpl implements AskService {
record.setAnswer(resText); record.setAnswer(resText);
record.setCreateUserId(UserUtil.getUser().getId()); record.setCreateUserId(UserUtil.getUser().getId());
record.insert(); record.insert();
log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText());
} else {
log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult);
HumanUtil.textDriven("您好,我没有听懂您说什么", roomId);
} }
AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) } else {
.eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); if (CollUtil.isEmpty(askPatientAnswer.getAnswer())) {
if (ObjectUtil.isEmpty(askPatientAnswer) || CollUtil.isEmpty(askPatientAnswer.getAnswer())) { log.info("{}:病历配置的回答不为空,但在获取的时候,答案为空,尝试回复默认语句", rasaResult);
if (CollUtil.isNotEmpty(library.getDefaultAnswer())) {
String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size()));
log.info("{}:病历配置的回答不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, resText);
HumanUtil.textDriven(resText, roomId);
// 保存记录
DiagnosisQaRecord record = new DiagnosisQaRecord();
record.setProcessId(talkReqVO.getProcessId());
record.setAnswerType("default");
// 注意,这里如果有默认回答,回答的结果是默认结果ID
record.setAnswerId(library.getId());
record.setQuestion(talkReqVO.getText());
record.setAnswer(resText);
record.setCreateUserId(UserUtil.getUser().getId());
record.insert();
} else {
log.info("{}:病历配置的回答不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult);
HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); HumanUtil.textDriven("您好,我没有听懂您说什么", roomId);
}
} else { } else {
String resText = askPatientAnswer.getAnswer().get(RandomUtil.randomInt(0, askPatientAnswer.getAnswer().size())); String resText = askPatientAnswer.getAnswer().get(RandomUtil.randomInt(0, askPatientAnswer.getAnswer().size()));
log.info("{}:找到了病历配置的回答语句,回答内容:{}", rasaResult, resText);
HumanUtil.textDriven(resText, roomId); HumanUtil.textDriven(resText, roomId);
// 保存记录 // 保存记录
DiagnosisQaRecord record = new DiagnosisQaRecord(); DiagnosisQaRecord record = new DiagnosisQaRecord();
@ -124,6 +154,8 @@ public class AskServiceImpl implements AskService {
record.setCreateUserId(UserUtil.getUser().getId()); record.setCreateUserId(UserUtil.getUser().getId());
record.insert(); record.insert();
} }
}
} }
} }
talkResultResVO.setType(1); talkResultResVO.setType(1);

Loading…
Cancel
Save